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 Productout_browse : System.Web.UI.Page { Maticsoft.Model.nr_z_cpck cpckmodel = new Maticsoft.Model.nr_z_cpck(); Maticsoft.BLL.nr_z_cpck cpckbll = new Maticsoft.BLL.nr_z_cpck(); //创建一个操作记录模板 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) { cpckmodel = cpckbll.GetModel(did); ckdh.Text = cpckmodel.ckbh; riqi.Text = cpckmodel.riqi.ToString("yyyy-MM-dd"); scdh.Text = cpckmodel.scdh; khming.Text = cpckmodel.khmc; cpbh.Text = cpckmodel.cpbh; cpmc.Text = cpckmodel.cpmc; danjia.Text = cpckmodel.cpdj.ToString(); guige.Text = cpckmodel.guige.ToString(); zzshuliang.Text = cpckmodel.zzsl.ToString(); lingtou.Text = cpckmodel.lt.ToString(); shuliang.Text = cpckmodel.sl.ToString(); danwei.Text = cpckmodel.danwei; lxr.Text = cpckmodel.lxr; zongjine.Text = cpckmodel.zje.ToString(); lxdh.Text = cpckmodel.lxdh; jingshouren.Text = cpckmodel.jsr; shr.Text = cpckmodel.shr; dizhi.Text = cpckmodel.shdizhi; txt_beizhu.Text = cpckmodel.beizhu; zhuangtai.Text = cpckmodel.zt; } #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_cpck", "查看全部") == false && DBHlper.GetPermission(juese, "成品出库", "nr_z_cpck", "查看个人") == false) { Response.Redirect("../Common/nopower.htm"); } if (DBHlper.GetPermission(juese, "成品出库", "nr_z_cpck", "编辑个人") && jingshouren.Text == user.zhanghao) { bt_tj.Visible = true; } if (DBHlper.GetPermission(juese, "成品出库", "nr_z_cpck", "编辑全部")) { bt_tj.Visible = true; } if (DBHlper.GetPermission(juese, "成品出库", "nr_z_cpck", "删除个人") && jingshouren.Text == user.zhanghao) { shanchu.Visible = true; } if (DBHlper.GetPermission(juese, "成品出库", "nr_z_cpck", "删除全部")) { shanchu.Visible = true; } if (DBHlper.GetPermission(juese, "成品出库", "nr_z_cpck", "出库确认")) { ckqr.Visible = true; } if (DBHlper.GetPermission(juese, "成品出库", "nr_z_cpck", "出库冲红")) { ckch.Visible = true; } if (DBHlper.GetPermission(juese, "成品出库", "nr_z_cpck", "添加")) { bt_add.Visible = true; } if (zhuangtai.Text == "已出库") { ckqr.Enabled = false; ckqr.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 (zhuangtai.Text == "待确认") { ckch.Enabled = false; ckch.BackColor = System.Drawing.Color.Gray; } if (DBHlper.GetPermission(juese, "成品出库", "nr_z_cpck", "打印")) { dayin.Visible = true; } } #endregion protected void bt_tj_Click(object sender, EventArgs e) { Response.Redirect("Productout_Form.aspx?uid=" + id.Value); } protected void Button1_Click(object sender, EventArgs e) { if (cpckbll.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 + "删除了成品出库,出库单号为:" + cpbh.Text.Trim(); rizhi.yonghuming = zh.zhanghao.ToString(); rizhibll.Add(rizhi); Response.Redirect("Productout_list.aspx", false); } else { Response.Write(""); } } protected void btnchonghong_Click(object sender, EventArgs e) { DataTable dt = DBHlper.Execute(string.Format("select * from nr_z_cpkc where scdh='{0}' and xmmc='{1}' and khmc='{2}'", scdh.Text, cpbh.Text, khming.Text)).Tables[0]; double sl = Convert.ToDouble(dt.Rows[0]["sl"]); double nowsl = Convert.ToDouble(shuliang.Text); int gxcount = DBHlper.excutecmd("update nr_z_cpkc set sl=" + (sl + nowsl) + " where id=" + dt.Rows[0]["id"]); if (gxcount > 0) { DBHlper.excutecmd("update nr_z_cpck set zt='待确认' where id=" + id.Value); } else { Response.Write(""); } //给日志模板赋值 rizhi.riqi = DateTime.Now; rizhi.leixing = "成品出库"; //将session转换对象取值 Maticsoft.Model.nr_z_yhzh zh = (Maticsoft.Model.nr_z_yhzh)Session["user"]; //拼接字符串插入日志 rizhi.jilu = zh.zhanghao + "执行了出库冲红,出库单号为:" + ckdh.Text.Trim(); rizhi.yonghuming = zh.zhanghao.ToString(); rizhibll.Add(rizhi); Response.Redirect("Productout_browse.aspx?uid=" + id.Value); } protected void btn_chuku_Click(object sender, EventArgs e) { //var sql = string.Format("select * from view_nr_z_cpkc where scdh='{0}' and xmmc='{1}' and khmc='{2}'", scdh.Text, cpbh.Text, khming.Text); var sql = string.Format("select * from view_nr_z_cpkc where cpbh='{0}'", cpbh.Text); var result = DBHlper.Execute(sql); DataTable dt = result.Tables[0]; if (dt.Rows.Count == 0) { Response.Write(""); return; } else { double sl = Convert.ToDouble(dt.Rows[0]["sl"]); double nowsl = Convert.ToDouble(shuliang.Text); if (sl < nowsl) { Response.Write(""); return; } else { DBHlper.excutecmd("update nr_z_cpkc set sl=" + (sl - nowsl) + " where id=" + dt.Rows[0]["id"]); DBHlper.excutecmd("update nr_z_cpck set zt='已出库' where id=" + 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 + "执行了成品出库,成品出库号为:" + ckdh.Text.Trim(); rizhi.yonghuming = zh.zhanghao.ToString(); rizhibll.Add(rizhi); Response.Redirect("Productout_browse.aspx?uid=" + id.Value); } } } }