using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; public partial class DemandSheet_browse : CommonPage { //创建一个共用的物料需求单bll Maticsoft.BLL.nr_z_shengoudan sgdbll = new Maticsoft.BLL.nr_z_shengoudan(); //创建一个物料需求单模板 Maticsoft.Model.nr_z_shengoudan sgdmodel = new Maticsoft.Model.nr_z_shengoudan(); //创建一个操作记录模板 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(id.Value); pdquanxian(user.juese); } } #region 获取真正数据值 private void initdata(string did) { DataTable dtsgd = DBHlper.Execute("select * from view_nr_z_shengoudan where id=" + did).Tables[0]; if (dtsgd != null) { id.Value = dtsgd.Rows[0]["id"].ToString(); bh.Text = dtsgd.Rows[0]["sgdbianhao"].ToString(); txt_shengchandan.Text = dtsgd.Rows[0]["scdbh"].ToString(); txt_sgriqi.Text = DateTime.Parse(dtsgd.Rows[0]["riqi"].ToString()).ToString("yyyy-MM-dd"); txt_wlbianhao.Text = dtsgd.Rows[0]["wlbh"].ToString(); txt_wlmingcheng.Text = dtsgd.Rows[0]["mingcheng"].ToString(); txt_wlpinpai.Text = dtsgd.Rows[0]["pinpai"].ToString(); txt_wlguige.Text = dtsgd.Rows[0]["guige"].ToString(); txt_yhriqi.Text = DateTime.Parse(dtsgd.Rows[0]["yhriqi"].ToString()).ToString("yyyy-MM-dd"); txt_qxshuliang.Text = dtsgd.Rows[0]["xuqiushuliang"].ToString(); txt_kucun.Text = dtsgd.Rows[0]["kucun"].ToString(); txt_shengoushu.Text = dtsgd.Rows[0]["shengoushu"].ToString(); txt_shengouren.Text = dtsgd.Rows[0]["shengouren"].ToString(); lbl_zt.Text = dtsgd.Rows[0]["zt"].ToString(); txt_beizhu.Text = dtsgd.Rows[0]["beizhu"].ToString(); cgzt.Text = dtsgd.Rows[0]["cgzt"].ToString(); txt_danwei.Text = dtsgd.Rows[0]["danwei"].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_shengoudan", "查看全部") == false && DBHlper.GetPermission(juese, "物料需求单", "nr_z_shengoudan", "查看个人") == false) { Response.Redirect("../Common/nopower.htm"); } if (DBHlper.GetPermission(juese, "物料需求单", "nr_z_shengoudan", "编辑个人") && txt_shengouren.Text == user.zhanghao) { bt_tj.Visible = true; } if (DBHlper.GetPermission(juese, "物料需求单", "nr_z_shengoudan", "编辑全部")) { bt_tj.Visible = true; } if (DBHlper.GetPermission(juese, "物料需求单", "nr_z_shengoudan", "删除个人") && txt_shengouren.Text == user.zhanghao) { shanchu.Visible = true; } if (DBHlper.GetPermission(juese, "物料需求单", "nr_z_shengoudan", "删除全部")) { shanchu.Visible = true; } if (DBHlper.GetPermission(juese, "物料需求单", "nr_z_shengoudan", "添加")) { fuzhi.Visible = true; } if (DBHlper.GetPermission(juese, "物料需求单", "nr_z_shengoudan", "审核")) { btn_tongguo.Visible = true; btn_butongguo.Visible = true; } if (lbl_zt.Text == "审核通过") { btn_tongguo.Enabled = false; btn_tongguo.BackColor = System.Drawing.Color.Gray; shanchu.Enabled = false; shanchu.BackColor = System.Drawing.Color.Gray; bt_tj.Enabled = false; bt_tj.BackColor = System.Drawing.Color.Gray; } if (lbl_zt.Text == "不通过") { btn_butongguo.Enabled = false; btn_butongguo.BackColor = System.Drawing.Color.Gray; } } #endregion protected void bt_tj_Click(object sender, EventArgs e) { Response.Redirect("DemandSheet_Form.aspx?uid=" + id.Value); } protected void Shanchu_Click(object sender, EventArgs e) { if (sgdbll.Delete(Convert.ToInt32(id.Value))) { //给日志模板赋值 rizhi.riqi = DateTime.Now; rizhi.leixing = "物料需求单"; //将session转换对象取值 Maticsoft.Model.nr_z_yhzh zh = (Maticsoft.Model.nr_z_yhzh)Session["user"]; //拼接字符串插入日志 rizhi.jilu = zh.zhanghao + "删除了物料需求单,物料需求单号为:" + bh.Text.Trim(); rizhi.yonghuming = zh.zhanghao.ToString(); rizhibll.Add(rizhi); Response.Redirect("DemandSheet_list.aspx", false); } else { Response.Write(""); } } protected void btntongguo_Click(object sender, EventArgs e) { int s=DBHlper.excutecmd("update nr_z_shengoudan set zt='审核通过' where id="+id.Value); if (s > 0) { //给日志模板赋值 rizhi.riqi = DateTime.Now; rizhi.leixing = "物料需求单"; //将session转换对象取值 Maticsoft.Model.nr_z_yhzh zh = (Maticsoft.Model.nr_z_yhzh)Session["user"]; //拼接字符串插入日志 rizhi.jilu = zh.zhanghao + "审核通过了物料需求单,物料需求单号为:" + bh.Text.Trim(); rizhi.yonghuming = zh.zhanghao.ToString(); rizhibll.Add(rizhi); Response.Redirect("DemandSheet_browse.aspx?uid=" + id.Value); } } protected void btn_butong_Click(object sender, EventArgs e) { int s=DBHlper.excutecmd("update nr_z_shengoudan set zt='不通过' where id=" + id.Value); if (s > 0) { //给日志模板赋值 rizhi.riqi = DateTime.Now; rizhi.leixing = "物料需求单"; //将session转换对象取值 Maticsoft.Model.nr_z_yhzh zh = (Maticsoft.Model.nr_z_yhzh)Session["user"]; //拼接字符串插入日志 rizhi.jilu = zh.zhanghao + "审核不通过了物料需求单,物料需求单号为:" + bh.Text.Trim(); rizhi.yonghuming = zh.zhanghao.ToString(); rizhibll.Add(rizhi); Response.Redirect("DemandSheet_browse.aspx?uid=" + id.Value); } } }