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 Development_browse : System.Web.UI.Page { Maticsoft.Model.nr_z_cpkf cpkcmodel = new Maticsoft.Model.nr_z_cpkf(); Maticsoft.BLL.nr_z_cpkf cpkcbll = new Maticsoft.BLL.nr_z_cpkf(); //创建一个操作记录模板 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); } } #region 获取真正数据值 private void initdata(int did) { DataTable dt = DBHlper.Execute("select * from nr_z_cpkf where id=" + did).Tables[0]; if (dt.Rows.Count > 0) { kfbh.Text = dt.Rows[0]["kfbh"].ToString(); sjly.Text = dt.Rows[0]["sjly"].ToString(); xlh.Text = dt.Rows[0]["xlh"].ToString(); zhqx.Text = Convert.ToDateTime(dt.Rows[0]["zhqx"]).ToString("yyyy-MM-dd"); riqi.Text = Convert.ToDateTime(dt.Rows[0]["riqi"]).ToString("yyyy-MM-dd"); zwsjmc.Text = dt.Rows[0]["zwsjmc"].ToString(); ywsjmc.Text = dt.Rows[0]["ywsjmc"].ToString(); ydrq.Text = Convert.ToDateTime(dt.Rows[0]["ydrq"]).ToString("yyyy-MM-dd"); dyrq.Text = Convert.ToDateTime(dt.Rows[0]["dyrq"]).ToString("yyyy-MM-dd"); ydksrq.Text = Convert.ToDateTime(dt.Rows[0]["ydksrq"]).ToString("yyyy-MM-dd"); ydjsrq.Text = Convert.ToDateTime(dt.Rows[0]["ydjsrq"]).ToString("yyyy-MM-dd"); sjnr.Text = dt.Rows[0]["sjnr"].ToString(); rwgx.Text = dt.Rows[0]["rwgx"].ToString(); beizhu.Text = dt.Rows[0]["beizhu"].ToString(); tp.Src = "../Client_Folder/" + dt.Rows[0]["tp"].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_cpkf", "查看全部") == false && DBHlper.GetPermission(juese, "产品开发", "nr_z_cpkf", "查看个人") == false) { Response.Redirect("../Common/nopower.htm"); } if (DBHlper.GetPermission(juese, "产品开发", "nr_z_cpkf", "编辑全部")) { bt_tj.Visible = true; } if (DBHlper.GetPermission(juese, "产品开发", "nr_z_cpkf", "删除全部")) { shanchu.Visible = true; bt_shanchu.Visible = true; } if (DBHlper.GetPermission(juese, "产品开发", "nr_z_cpkf", "添加")) { bt_add.Visible = true; } } #endregion protected void Shanchu_Click(object sender, EventArgs e) { int sid = Convert.ToInt32(id.Value); bool ci = cpkcbll.Delete(sid); 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 + "删除了产品开发,产品开发号为:" + kfbh.Text.Trim(); rizhi.yonghuming = zh.zhanghao.ToString(); rizhibll.Add(rizhi); Response.Redirect("Development_list.aspx", false); } else { Response.Write(""); } } protected void wj_Click(object sender, EventArgs e) { DataSet ds = DBHlper.Execute("select wj from nr_z_cpkf 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; } } }