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 OtherOut_browse : System.Web.UI.Page { //创建一个共用的物料bll层 Maticsoft.BLL.nr_z_qtck qtckbll = new Maticsoft.BLL.nr_z_qtck(); //创建一个共用的物料模板 Maticsoft.Model.nr_z_qtck qtck = new Maticsoft.Model.nr_z_qtck(); //创建一个操作记录模板 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() { qtck = qtckbll.GetModel(Convert.ToInt32(id.Value)); //给日志模板赋值 rizhi.riqi = DateTime.Now; rizhi.leixing = "材料其它出库"; } #endregion #region 修改时获取真正数据值 private void initdata(string rkid) { int idz = Convert.ToInt32(rkid); qtck = qtckbll.GetModel(idz); if (qtck != null) { bh.Text = qtck.ckdh; riqi.Text = DateTime.Parse(qtck.ckrq.ToString()).ToString("yyyy-MM-dd"); cangku.Text = qtck.kf; scdh.Text = qtck.scdbh; wlbh.Text = qtck.wlbh; danwei.Text = qtck.wldw; sl.Text = qtck.sl.ToString(); guige.Text = DBHlper.getfirstcolmn("select top 1 guige from nr_z_wuliao where wlbh='" + qtck.wlbh + "' and zt=1"); wlmc.Text = qtck.wlmc; wlpp.Text = qtck.wlpp; bm.Text = qtck.bm; khbh.Text = qtck.khbh; khmc.Text = DBHlper.getfirstcolmn("select mingcheng from nr_z_kehu where bianhao='" + qtck.khbh + "'"); rklx.Text = qtck.cklx; jsr.Text = qtck.jsr; beizhu.Text = qtck.bz; zt.Text = qtck.zt; jine.Text = qtck.jine.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_qtck", "查看全部") == false && DBHlper.GetPermission(juese, "其它出库", "nr_z_qtck", "查看个人") == false) { Response.Redirect("../Common/nopower.htm"); } if (DBHlper.GetPermission(juese, "其它出库", "nr_z_qtck", "编辑个人") && jsr.Text == user.zhanghao) { bt_tj.Visible = true; } if (DBHlper.GetPermission(juese, "其它出库", "nr_z_qtck", "编辑全部")) { bt_tj.Visible = true; } if (DBHlper.GetPermission(juese, "其它出库", "nr_z_qtck", "删除个人") && jsr.Text == user.zhanghao) { shanchu.Visible = true; } if (DBHlper.GetPermission(juese, "其它出库", "nr_z_qtck", "删除全部")) { shanchu.Visible = true; } if (DBHlper.GetPermission(juese, "其它出库", "nr_z_qtck", "出库确认")) { rkqr.Visible = true; } if (DBHlper.GetPermission(juese, "其它出库", "nr_z_qtck", "出库冲红")) { rkch.Visible = true; } if (DBHlper.GetPermission(juese, "其它出库", "nr_z_qtck", "添加")) { bt_add.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) { string cslsql = "select isnull(kucun,0) from nr_z_wuliao where wlbh='" + wlbh.Text + "' and kufang='" + cangku.Text + "'"; string sjsl = DBHlper.getfirstcolmn(cslsql); if (sjsl != "" && sjsl.Length > 0) { decimal kcsl = Convert.ToDecimal(sjsl); if (kcsl < Convert.ToDecimal(sl.Text)) { z_error.Text = "库存不足,无法进行出库操作!"; return; } } else { z_error.Text = "库存不足,无法进行出库操作!"; return; } getmd(); qtck.zt = "已确认"; qtck.ckrq = DateTime.Now; qtckbll.Update(qtck); int fh =0; string sql = "update nr_z_wuliao set kucun=kucun-" + sl.Text + ",jine=isnull(jine,0)-" + jine.Text + " where wlbh='" + wlbh.Text + "' and kufang='" + cangku.Text + "'"; 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("OtherOut_browse.aspx?uid=" + id.Value, false); } else { z_error.Text = "出库确认失败!"; } } protected void rkch_Click(object sender, EventArgs e) { if (zt.Text == "待确认") { z_error.Text = "采购未出库确认,冲红操作失败!"; return; } string sql = "update nr_z_wuliao set kucun=kucun+" + sl.Text + ",jine=isnull(jine,0)+" + jine.Text + "where wlbh='" + wlbh.Text + "' and kufang='" + cangku.Text + "'"; int fh = DBHlper.excutecmd(sql); if (fh > 0) { getmd(); qtck.zt = "待确认"; if (qtckbll.Update(qtck)) { //将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("OtherOut_browse.aspx?uid=" + id.Value, false); } } else { z_error.Text = "出库冲红失败!"; } } protected void shanchu_Click(object sender, EventArgs e) { if (zt.Text == "已确认") { z_error.Text = "已确认出库,不能进行删除操作!"; return; } getmd(); if (qtckbll.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("OtherOut_list.aspx", false); } } protected void bt_tj_Click(object sender, EventArgs e) { Response.Redirect("OtherOut_Form.aspx?uid=" + id.Value); } protected void bt_add_Click(object sender, EventArgs e) { Response.Redirect("OtherOut_Form.aspx"); } }