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.Data.SqlClient; public partial class PurchaseInto_browse : System.Web.UI.Page { //创建一个物料模板 Maticsoft.Model.nr_z_wuliao wlmd = new Maticsoft.Model.nr_z_wuliao(); //创建一个物料模板bll Maticsoft.BLL.nr_z_wuliao wlbll = new Maticsoft.BLL.nr_z_wuliao(); //创建一个采购入库记录模板 Maticsoft.Model.nr_z_cgrk cgrkmd = new Maticsoft.Model.nr_z_cgrk(); //创建一个采购入库记录bll Maticsoft.BLL.nr_z_cgrk cgrkbll = new Maticsoft.BLL.nr_z_cgrk(); //创建一个操作记录模板 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 获取页面参数赋值model对象 private void getmd() { cgrkmd = cgrkbll.GetModel(Convert.ToInt32(id.Value)); //给日志模板赋值 rizhi.riqi = DateTime.Now; rizhi.leixing = "采购入库记录"; } #endregion #region 修改时获取真正数据值 private void initdata(string rkid) { DataTable dt = DBHlper.Execute("select * from view_nr_z_cgrk where id=" + rkid).Tables[0]; if (dt != null && dt.Rows.Count > 0) { bh.Text = dt.Rows[0]["rkbh"].ToString(); cgdh.Text = dt.Rows[0]["cgdh"].ToString(); gysbh.Text = dt.Rows[0]["gysbh"].ToString(); wlbh.Text = dt.Rows[0]["wlbh"].ToString(); wlmc.Text = dt.Rows[0]["mingcheng"].ToString(); wlpp.Text = dt.Rows[0]["pinpai"].ToString(); guige.Text=dt.Rows[0]["guige"].ToString(); danwei.Text = dt.Rows[0]["danwei"].ToString(); kufang.Text = dt.Rows[0]["kufang"].ToString(); jsr.Text = dt.Rows[0]["jsr"].ToString(); riqi.Text = dt.Rows[0]["rkrq"].ToString(); shuliang.Text = dt.Rows[0]["sl"].ToString(); danjia.Text = dt.Rows[0]["dj"].ToString(); jine.Text = dt.Rows[0]["je"].ToString(); beizhu.Text = dt.Rows[0]["bz"].ToString(); zt.Text = dt.Rows[0]["zt"].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_cgrk", "查看全部") == false && DBHlper.GetPermission(juese, "采购入库记录", "nr_z_cgrk", "查看个人") == false) { Response.Redirect("../Common/nopower.htm"); } if (DBHlper.GetPermission(juese, "采购入库记录", "nr_z_cgrk", "编辑个人") && jsr.Text == user.zhanghao) { bt_tj.Visible = true; } if (DBHlper.GetPermission(juese, "采购入库记录", "nr_z_cgrk", "编辑全部")) { bt_tj.Visible = true; } if (DBHlper.GetPermission(juese, "采购入库记录", "nr_z_cgrk", "删除个人") && jsr.Text == user.zhanghao) { shanchu.Visible = true; } if (DBHlper.GetPermission(juese, "采购入库记录", "nr_z_cgrk", "删除全部")) { shanchu.Visible = true; } if (DBHlper.GetPermission(juese, "采购入库记录", "nr_z_cgrk", "出库确认")) { rkqr.Visible = true; } if (DBHlper.GetPermission(juese, "采购入库记录", "nr_z_cgrk", "出库冲红")) { rkch.Visible = true; } if (zt.Text == "已确认") { rkqr.Enabled = false; rkqr.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 (zt.Text == "待确认") { rkch.Enabled = false; rkch.BackColor = System.Drawing.Color.Gray; } } #endregion protected void rkqr_Click(object sender, EventArgs e) { getmd(); cgrkmd.zt = "已确认"; cgrkmd.rkrq = DateTime.Now; cgrkbll.Update(cgrkmd); string sql = "update nr_z_wuliao set kucun=kucun+" + shuliang.Text + ",jine=ISNULL(jine,0)+" + jine.Text + " where wlbh='" + wlbh.Text + "' and kufang='" + kufang.Text + "'"; int fh = DBHlper.excutecmd(sql); //将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; rizhibll.Add(rizhi); if (fh > 0) { Response.Redirect("PurchaseInto_browse.aspx?uid=" + id.Value, false); } } protected void rkch_Click(object sender, EventArgs e) { if (zt.Text == "待确认") { z_error.Text = "采购未入库确认,冲红操作失败!"; return; } string sql = "update nr_z_wuliao set kucun=kucun-" + shuliang.Text + ",jine=ISNULL(jine,0)-" + jine.Text + " where wlbh='" + wlbh.Text + "' and kufang='" + kufang.Text + "'"; int fh = DBHlper.excutecmd(sql); if (fh > 0) { getmd(); cgrkmd.zt = "待确认"; if (cgrkbll.Update(cgrkmd)) { //将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; rizhibll.Add(rizhi); Response.Redirect("PurchaseInto_browse.aspx?uid=" + id.Value, false); } } } protected void shanchu_Click(object sender, EventArgs e) { if (zt.Text == "已确认") { z_error.Text = "已确认入库,不能进行删除操作!"; return; } getmd(); if (cgrkbll.Delete(Convert.ToInt32(id.Value))) { //将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; rizhibll.Add(rizhi); Response.Redirect("Picking_list.aspx", false); } } protected void bt_tj_Click(object sender, EventArgs e) { Response.Redirect("PurchaseInto_Form.aspx?bid=" + id.Value); } }