/// <summary> /// 绑定下拉框的数据 /// </summary> public void refredatabind() { /* 绑定供应商 */ //List<Provider> ps = new DAL.ProviderDAO().getAllProviders(); //ListBox6.DataSource = ps; //ListBox6.DataTextField = "providerName"; //ListBox6.DataValueField = "providerNum"; //ListBox6.DataBind(); //ListItem lt1 = new ListItem(); //lt1.Value = ""; //ListBox6.Items.Add(lt1); //ListBox6.SelectedValue = ""; /* 绑定物品 */ List <Goods> gs = new DAL.GoodsDAO().getAllGoods(); //ListBox4.DataSource = cs; //ListBox4.DataTextField = "chestName"; //ListBox4.DataValueField = "chestNum"; //ListBox4.DataBind(); DropDownList1.DataSource = gs; DropDownList1.DataTextField = "goodsname"; DropDownList1.DataValueField = "goodsnum"; DropDownList1.DataBind(); ListItem lt2 = new ListItem(); lt2.Value = ""; DropDownList1.Items.Add(lt2); DropDownList1.SelectedValue = ""; /* 绑定经办人 */ //List<SysUser> sys = new DAL.SysUserDAO().getAllUsers(); //ListBox5.DataSource = sys; //ListBox5.DataTextField = "userId"; //ListBox5.DataValueField = "staffNum"; //ListBox5.DataBind(); //ListItem lt3 = new ListItem(); //lt3.Value = ""; //ListBox5.Items.Add(lt3); //ListBox5.SelectedValue = ""; /* 绑定物品类别第一项 */ List <GoodsType> gts = new DAL.GoodsTypeDAO().getParentGoodsTypes(); ListBox1.DataSource = gts; ListBox1.DataTextField = "goodsTypeName"; ListBox1.DataValueField = "goodsTypeNum"; ListBox1.DataBind(); ListItem lt4 = new ListItem(); lt4.Value = ""; ListBox1.Items.Add(lt4); ListBox1.SelectedValue = ""; }
protected void Button6_Click(object sender, EventArgs e) //添加出库按钮点击事件 { cleaTitle(); Button b = sender as Button; if (TextBox7.Text.Trim() == "" || TextBox8.Text.Trim() == "" || TextBox9.Text.Trim() == "" || TextBox10.Text.Trim() == "" || TextBox11.Text.Trim() == "" || TextBox12.Text.Trim() == "") { Response.Write("<script>alert('所有信息不能为空!')</script>"); } else { bool condition = true; //记录输入的东西是否符合条件,全都正确为true Inin i = new DAL.IninDAO().getInsById(TextBox7.Text.Trim()); if (i == null) { condition = false; Label14.Text = "没有查询到此入库"; } Goods g = new DAL.GoodsDAO().getGoodsByNum(TextBox8.Text.Trim()); Amount am = null; if (g == null) { condition = false; Label16.Text = "没有查询到此物品"; } else { List <string> sql = new List <string>(); sql.Add(" and positionNum ='" + i.PositionNum + "'"); sql.Add(" and GoodsNum='" + g.GoodsNum + "'"); am = new DAL.AmountDAO().getAmountsByWherePoAndGo(sql); if (am == null) { condition = false; Label16.Text = "此物品在此库位无存货"; } else if (am.Amounts <= 0) { condition = false; Label16.Text = "此物品在此库位无存货"; } } int outamount; try { outamount = int.Parse(TextBox9.Text.Trim()); if (outamount <= 0) { condition = false; outamount = 0; Label18.Text = "输入格式错误,请输入大于0的整数"; } else if (am != null) { if (am.Amounts < outamount) { condition = false; outamount = 0; Label18.Text = "库存数量小于出货数量"; } } } catch { condition = false; outamount = 0; Label18.Text = "输入格式错误,请输入整数"; } Receiver re = new DAL.ReceiverDAO().getReceiverByNum(TextBox10.Text.Trim()); if (re == null) { condition = false; Label20.Text = "没有查询到此收货商"; } if (TextBox11.Text.Length >= 100) { condition = false; Label22.Text = "输入长度必须小于100"; } DateTime dt; try { dt = DateTime.Parse(TextBox12.Text.Trim()); if (b.Text != "确认修改") { if (dt < DateTime.Now) { condition = false; Label24.Text = "输入日期必须大于等于今天的日期"; } } } catch { condition = false; dt = DateTime.Parse("2018-8-8"); Label24.Text = "输入日期的格式不正确"; } if (condition) { if (b.Text != "确认修改") { Batch bt = new Batch(); bt.BatchNum = new Warehouse.Tools.batchNum().protect_batchNumByWPB("收货"); bt.ProorrecNum = TextBox10.Text.Trim(); bt.Condition = "准备"; bt.OutorinType = "出库"; bool batchsucc = new DAL.BatchDao().addBatch(bt); new Warehouse.Tools.AddSysLog().addlog("1", "批次", "添加"); Outout oo = new Outout(); oo.PositionNum = i.PositionNum; oo.GoodsNum = TextBox8.Text.Trim(); oo.OutAmount = outamount; oo.Remark = TextBox11.Text.Trim(); oo.Date = dt; bool outoutsucc = new DAL.OutoutDAO().addOut(oo); if (batchsucc && outoutsucc) { new Warehouse.Tools.AddSysLog().addlog("1", "未完成出库", "添加"); ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('添加成功!');", true); addOut.Visible = true; refreAllOut(); clea(); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('添加失败!');", true); } } else { Outout oo = new Outout(); oo.PositionNum = TextBox1.Text.Trim(); oo.GoodsNum = TextBox2.Text.Trim(); oo.OutAmount = outamount; oo.Remark = TextBox5.Text.Trim(); oo.Date = dt; oo.OuID = outID; oo.BatchNum = outBatch; oo.UserId = "1"; bool ininsucc = new DAL.OutoutDAO().updateOut(oo); if (ininsucc) { new Warehouse.Tools.AddSysLog().addlog("1", "未完成出库", "修改"); ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('修改成功!');", true); addIn.Visible = false; GridView2.Visible = true; refreAllIn(); outID = null; outBatch = null; clea(); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('修改失败!');", true); } } } else { } } }
protected void Button4_Click(object sender, EventArgs e) //入库确定添加按钮点击事件 { cleaTitle(); Button b = sender as Button; if (TextBox1.Text.Trim() == "" || TextBox2.Text.Trim() == "" || TextBox3.Text.Trim() == "" || TextBox4.Text.Trim() == "" || TextBox5.Text.Trim() == "" || TextBox6.Text.Trim() == "") { Response.Write("<script>alert('所有信息不能为空!')</script>"); } else { bool condition = true; //记录输入的东西是否符合条件,全都正确为true Position p = new DAL.PositionDAO().getPositionByNum(TextBox1.Text.Trim()); if (p == null) { condition = false; Label2.Text = "没有查询到此库位"; } Goods g = new DAL.GoodsDAO().getGoodsByNum(TextBox2.Text.Trim()); if (g == null) { condition = false; Label4.Text = "没有查询到此物品"; } int inamount; try { inamount = int.Parse(TextBox3.Text.Trim()); if (inamount <= 0) { int.Parse("测试"); } } catch { condition = false; inamount = 0; Label6.Text = "输入格式错误,请输入大于0的整数"; } Provider pr = new DAL.ProviderDAO().getProviderByNum(TextBox4.Text.Trim()); if (pr == null) { condition = false; Label8.Text = "没有查询到此供应商"; } if (TextBox5.Text.Length >= 100) { condition = false; Label10.Text = "输入长度大于100"; } DateTime dt; try { dt = DateTime.Parse(TextBox6.Text.Trim()); if (b.Text != "确认修改") { if (dt < DateTime.Now) { condition = false; Label12.Text = "输入日期必须大于等于今天的日期"; } } } catch { condition = false; dt = DateTime.Parse("2018-8-8"); Label12.Text = "输入日期的格式不正确"; } if (condition) { if (b.Text != "确认修改") { Batch bt = new Batch(); bt.BatchNum = new Warehouse.Tools.batchNum().protect_batchNumByWPB("供货"); bt.ProorrecNum = TextBox4.Text.Trim(); bt.Condition = "准备"; bt.OutorinType = "入库"; bool batchsucc = new DAL.BatchDao().addBatch(bt); new Warehouse.Tools.AddSysLog().addlog("1", "批次", "添加"); Inin ii = new Inin(); ii.PositionNum = TextBox1.Text.Trim(); ii.GoodsNum = TextBox2.Text.Trim(); ii.InAmount = inamount; ii.Remark = TextBox5.Text.Trim(); ii.Date = dt; bool ininsucc = new DAL.IninDAO().addIn(ii); if (batchsucc && ininsucc) { ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('添加成功!');", true); new Warehouse.Tools.AddSysLog().addlog("1", "未完成入库", "添加"); addIn.Visible = false; refreAllIn(); clea(); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('添加失败!');", true); } } else { Inin ii = new Inin(); ii.PositionNum = TextBox1.Text.Trim(); ii.GoodsNum = TextBox2.Text.Trim(); ii.InAmount = inamount; ii.Remark = TextBox5.Text.Trim(); ii.Date = dt; ii.InID = inID; ii.BatchNum = inBatch; ii.UserId = "1"; bool ininsucc = new DAL.IninDAO().updateIn(ii); if (ininsucc) { ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('修改成功!');", true); new Warehouse.Tools.AddSysLog().addlog("1", "未完成入库", "修改"); addIn.Visible = false; GridView2.Visible = true; refreAllIn(); inID = null; inBatch = null; clea(); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('修改失败!');", true); } } } else { } } }