using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.IO; public partial class Product_browse : System.Web.UI.Page { Maticsoft.Model.nr_z_cpkc cpkcmodel = new Maticsoft.Model.nr_z_cpkc(); Maticsoft.BLL.nr_z_cpkc cpkcbll = new Maticsoft.BLL.nr_z_cpkc(); //创建一个操作记录模板 Maticsoft.Model.nr_sys_rizhi rizhi = new Maticsoft.Model.nr_sys_rizhi(); //创建一个操作记录bll Maticsoft.BLL.nr_sys_rizhi rizhibll = new Maticsoft.BLL.nr_sys_rizhi(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["user"] == null) { Response.Redirect("../index.aspx"); } Maticsoft.Model.nr_z_yhzh user = (Maticsoft.Model.nr_z_yhzh)(Session["user"]); if (Request.QueryString["uid"] != null && Request.QueryString["uid"] != "") { id.Value = Request.QueryString["uid"].ToString(); } initdata(Convert.ToInt32(id.Value)); pdquanxian(user.juese); setxmxq(id.Value); //getscyl(); } } #region 获取真正数据值 private void initdata(int did) { DataTable dt = DBHlper.Execute("select * from view_nr_z_cpkc where id=" + did).Tables[0]; if(dt.Rows.Count>0){ cpbh.Text = dt.Rows[0]["cpbh"].ToString(); cpmc.Text = dt.Rows[0]["cpmc"].ToString(); riqi.Text = dt.Rows[0]["riqi"].ToString(); gg.Text = dt.Rows[0]["gg"].ToString(); //zhongliang.Text = dt.Rows[0]["zhongliang"].ToString(); //zl.Text = dt.Rows[0]["zl"].ToString() ; //tiji.Text = dt.Rows[0]["tiji"].ToString(); dw.Text = dt.Rows[0]["dw"].ToString(); dj.Text = dt.Rows[0]["dj"].ToString(); jsr.Text = dt.Rows[0]["jsr"].ToString(); bz.Text = dt.Rows[0]["bz"].ToString(); tp.Src = "../Client_Folder/" + dt.Rows[0]["tp"].ToString() + ""; } } #endregion #region 获取项目需求 private void setxmxq(string cpid) { //加载前段项目 string qdgjstring = " "; string getgjsql = "select * from view_nr_z_cpkc_wlxq where cpid='" + id.Value + "'"; DataSet ds = DBHlper.Execute(getgjsql); int ges = 0; if (ds != null && ds.Tables[0].Rows.Count > 0) { foreach(DataRow r in ds.Tables[0].Rows) { ges = ges + 1; if (ges == 1) { qdgjstring += ""; } else { qdgjstring += ""; ges = 0; } } if (ges == 1) { qdgjstring += ""; ges = 0; } } xqwldiv.InnerHtml = qdgjstring + "
需求项目物料编号物料名称用量需求项目物料编号物料名称用量
" + r["xmmc"].ToString() + "" + r["wlbh"].ToString() + "" + r["wlmc"].ToString() + "" + Convert.ToDouble(r["xqyl"]).ToString() + "" + r["xmmc"].ToString() + "" + r["wlbh"].ToString() + "" + r["wlmc"].ToString() + "" + Convert.ToDouble(r["xqyl"]).ToString() + "
"; } #endregion #region 敏感权限查看 void pdquanxian(int juese) { Maticsoft.Model.nr_z_yhzh user = (Maticsoft.Model.nr_z_yhzh)(Session["user"]); if (DBHlper.getzt(user.id) != 1) { Response.Redirect("../index.aspx"); } if (DBHlper.GetPermission(juese, "产品档案", "nr_z_cpkc", "查看全部") == false && DBHlper.GetPermission(juese, "产品档案", "nr_z_cpkc", "查看个人") == false) { Response.Redirect("../Common/nopower.htm"); } if (DBHlper.GetPermission(juese, "产品档案", "nr_z_cpkc", "编辑个人") && jsr.Text == user.zhanghao) { bt_tj.Visible = true; } if (DBHlper.GetPermission(juese, "产品档案", "nr_z_cpkc", "编辑全部")) { bt_tj.Visible = true; } if (DBHlper.GetPermission(juese, "产品档案", "nr_z_cpkc", "删除个人") && jsr.Text == user.zhanghao) { shanchu.Visible = true; } if (DBHlper.GetPermission(juese, "产品档案", "nr_z_cpkc", "删除全部")) { shanchu.Visible = true; bt_shanchu.Visible = true; } if (DBHlper.GetPermission(juese, "产品档案", "nr_z_cpkc", "添加")) { //bt_add.Visible = true; } } #endregion #region 加载水彩信息 /* private void getscyl() { //加载前段工价 string getgjsql = "select * from view_nr_z_cpkc_scyl where cpid='" + id.Value + "'"; string cltable = "" + ""; DataSet ds = DBHlper.Execute(getgjsql); if (ds != null && ds.Tables[0].Rows.Count > 0) { int sjint = 0; int hcount = 1; foreach (DataRow r in ds.Tables[0].Rows) { if (sjint == 0) { cltable += ""; } sjint = sjint + 1; cltable += " "; if (sjint == 3) { cltable += ""; } hcount = hcount + 1; } if (3 - sjint > 0) { for (int hz = 0; hz < 3 - sjint; hz++) { cltable += " "; } cltable += ""; } } cltable += "
水彩用料用量备注水彩用料用量备注水彩用料用量备注
" + r["wlmc"].ToString() + "" + Convert.ToDouble(r["scyl"]).ToString() + "" + r["beizhu"].ToString() + "
"; scylxxdiv.InnerHtml = cltable; }*/ #endregion protected void Shanchu_Click(object sender, EventArgs e) { if (DBHlper.ExecuteReid("select count(*) from view_nr_z_cpkc where id="+id.Value+" and sl>0") > 0) { z_error.Text = "产品已有库存,不能删除"; return; } cpkcmodel = cpkcbll.GetModel(Convert.ToInt32(id.Value)); cpkcmodel.zt = 0; bool ci = cpkcbll.Update(cpkcmodel); if (ci) { //给日志模板赋值 rizhi.riqi = DateTime.Now; rizhi.leixing = "产品档案"; //将session转换对象取值 Maticsoft.Model.nr_z_yhzh zh = (Maticsoft.Model.nr_z_yhzh)Session["user"]; //拼接字符串插入日志 rizhi.jilu = zh.zhanghao + "删除了产品档案,产品档案号为:" + cpbh.Text.Trim(); rizhi.yonghuming = zh.zhanghao.ToString(); rizhibll.Add(rizhi); Response.Redirect("Product_list.aspx", false); } else { Response.Write(""); } } protected void wj_Click(object sender, EventArgs e) { DataSet ds = DBHlper.Execute("select wj from view_nr_z_cpkc where id='" + id.Value + "'"); string filenams = ds.Tables[0].Rows[0]["wj"].ToString(); if (filenams != "" && filenams != null) { string f5 = filenams; string fileName = f5;//客户端保存的文件名 string filePath = Server.MapPath("~/Client_Folder/" + f5);//路径 FileStream fs = new FileStream(filePath, FileMode.Open); byte[] bytes = new byte[(int)fs.Length]; fs.Read(bytes, 0, bytes.Length); fs.Close(); Response.ContentType = "application/octet-stream"; //通知浏览器下载文件而不是打开 Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); Response.BinaryWrite(bytes); Response.Flush(); Response.End(); } else { Response.Write(""); return; } } }