protected void Button1_Click(object sender, EventArgs e) { if (TextBox1.Text.Trim() == "") { dt = null; refreshAll(); } else { DateTime d; try { d = DateTime.Parse(TextBox1.Text.Trim()); List<Inin> ins = new DAL.IninDAO().getInsByDate(d.ToShortDateString()); GridView1.DataSource = ins; GridView1.DataBind(); new Warehouse.Tools.AddSysLog().addlog("1", "入库日报", "查询"); dt = TextBox1.Text.Trim(); refreshEmpty(); } catch { Response.Write("<script>alert('格式不正确,应输入例:2018-8-8!')</script>"); } } }
public void refreAllIn() { DataSet ds = new DAL.IninDAO().getInWhereFailToIn(); GridView2.DataSource = ds.Tables[0].DefaultView.ToTable(); GridView2.DataBind(); refreEmpty(); }
/// <summary> /// 刷新函数,刷新供货商 /// </summary> public void refre_provide() { if (inin == null) { List <Inin> dcs = new DAL.IninDAO().getAllIn(); GridView1.DataSource = dcs; } else { GridView1.DataSource = outout; } GridView1.DataBind(); refre_provide_Empty(); }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "editt") { int xy = Convert.ToInt32(e.CommandArgument); Model.Outout outs = new DAL.OutoutDAO().getOutsById(GridView1.Rows[xy].Cells[1].Text); addOut.Visible = true; Button btn = sender as Button; GridViewRow row = GridView1.Rows[xy]; Label13.Text = "库位编号"; outID = row.Cells[1].Text; outBatch = outs.BatchNum; TextBox7.Text = outs.PositionNum; TextBox7.ReadOnly = true; TextBox8.Text = outs.GoodsNum; TextBox9.Text = outs.OutAmount.ToString(); TextBox10.Text = new DAL.BatchDao().getBatchByNum(outs.BatchNum).ProorrecNum; TextBox10.ReadOnly = true; TextBox11.Text = outs.Remark; TextBox12.Text = outs.Date.ToShortDateString(); Button6.Text = "确认修改"; Button7.Text = "取消修改"; GridView1.Visible = false; } if (e.CommandName == "deletee") { new Warehouse.Tools.AddSysLog().addlog("1", "未完成出库", "删除"); int x = Convert.ToInt32(e.CommandArgument); string inid = GridView1.Rows[x].Cells[2].Text; bool yy = new DAL.IninDAO().deleteInById(inid); if (yy) { ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除成功!');", true); refreAllOut(); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除失败!');", true); } } }
/// <summary> /// 刷新全部信息 /// </summary> public void refreshAll() { if (dt == null) { List<Inin> dcs = new DAL.IninDAO().getAllIn(); GridView1.DataSource = dcs; GridView1.DataBind(); refreshEmpty(); } else { DateTime d =DateTime.Parse(dt); List<Inin> dcs = new DAL.IninDAO().getInsByDate(d.ToShortDateString()); GridView1.DataSource = dcs; GridView1.DataBind(); refreshEmpty(); } }
protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "editt") { int xy = Convert.ToInt32(e.CommandArgument); Model.Inin ins = new DAL.IninDAO().getInsById(GridView2.Rows[xy].Cells[1].Text); addIn.Visible = true; Button btn = sender as Button; GridViewRow row = GridView2.Rows[xy]; inID = row.Cells[1].Text; inBatch = ins.BatchNum; TextBox1.Text = ins.PositionNum; TextBox2.Text = ins.GoodsNum; TextBox3.Text = ins.InAmount.ToString(); TextBox4.Text = new DAL.BatchDao().getBatchByNum(ins.BatchNum).ProorrecNum; TextBox4.ReadOnly = true; TextBox5.Text = ins.Remark; TextBox6.Text = ins.Date.ToShortDateString(); Button4.Text = "确认修改"; Button5.Text = "取消修改"; GridView2.Visible = false; } if (e.CommandName == "deletee") { int x = Convert.ToInt32(e.CommandArgument); string inid = GridView2.Rows[x].Cells[2].Text; bool yy = new DAL.IninDAO().deleteInById(inid); if (yy) { new Warehouse.Tools.AddSysLog().addlog("1", "未完成入库", "删除"); ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除成功!');", true); refreAllIn(); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('删除失败!');", true); } } }
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 { } } }
protected void Button3_Click(object sender, EventArgs e) { if (in_out) { List <Inin> ins = null; List <string> sqlwhere = new List <string>(); if (TextBox1.Text.Trim() != "" && TextBox2.Text.Trim() != "") //判断时间是否填写 { DateTime dt1; DateTime dt2; try { dt1 = DateTime.Parse(TextBox1.Text.Trim()); dt2 = DateTime.Parse(TextBox2.Text.Trim()); if (dt1 > dt2) { Response.Write("<script>alert('日期区间错误应从小到大!')</script>"); return; } else { sqlwhere.Add(" and date between '" + dt1.ToShortDateString().ToString() + " 00:00:00' and '" + dt2.ToShortDateString().ToString() + " 00:00:00' "); } } catch { Response.Write("<script>alert('日期格式不正确,应输入例:2018-8-8!')</script>"); return; } } if (ListBox1.Text != "") //判断物品类别是否选择 { if (ListBox2.Text != "") { if (ListBox3.Text != "") { sqlwhere.Add(" and goods.goodsTypeNum='" + ListBox3.SelectedValue.ToString() + "'"); } else { sqlwhere.Add(" and goods.goodsTypeNum='" + ListBox2.SelectedValue.ToString() + "'"); } } else { sqlwhere.Add(" and goods.goodsTypeNum='" + ListBox1.SelectedValue.ToString() + "'"); } } if (ListBox4.Text != "") //判断库柜是否选择 { sqlwhere.Add(" and chest.chestNum='" + ListBox4.SelectedValue.ToString() + "'"); } if (ListBox5.Text != "") //判断经办人是否选择 { sqlwhere.Add(" and sysuser.staffNum='" + ListBox5.SelectedValue.ToString() + "'"); } if (ListBox6.Text != "") //判断供应商是否选择 { sqlwhere.Add(" and provider.providerNum='" + ListBox6.SelectedValue.ToString() + "'"); } ins = new DAL.IninDAO().getInsByWhere(sqlwhere); inin = ins; GridView1.DataSource = ins; GridView1.DataBind(); new Warehouse.Tools.AddSysLog().addlog("1", "出入库汇总", "查询"); refre_provide_Empty(); } else { List <Outout> outs = null; List <string> sqlwhere = new List <string>(); if (TextBox3.Text.Trim() != "" && TextBox4.Text.Trim() != "") //判断时间是否填写 { DateTime dt1; DateTime dt2; try { dt1 = DateTime.Parse(TextBox3.Text.Trim()); dt2 = DateTime.Parse(TextBox4.Text.Trim()); if (dt1 > dt2) { Response.Write("<script>alert('日期区间错误应从小到大!')</script>"); return; } else { sqlwhere.Add(" and date between '" + dt1.ToShortDateString().ToString() + " 00:00:00' and '" + dt2.ToShortDateString().ToString() + " 00:00:00' "); } } catch { Response.Write("<script>alert('日期格式不正确,应输入例:2018-8-8!')</script>"); return; } } if (ListBox1.Text != "") //判断物品类别是否选择 { if (ListBox2.Text != "") { if (ListBox3.Text != "") { sqlwhere.Add(" and goods.goodsTypeNum='" + ListBox3.SelectedValue.ToString() + "'"); } else { sqlwhere.Add(" and goods.goodsTypeNum='" + ListBox2.SelectedValue.ToString() + "'"); } } else { sqlwhere.Add(" and goods.goodsTypeNum='" + ListBox1.SelectedValue.ToString() + "'"); } } if (ListBox4.Text != "") //判断库柜是否选择 { sqlwhere.Add(" and chest.chestNum='" + ListBox4.SelectedValue.ToString() + "'"); } if (ListBox5.Text != "") //判断经办人是否选择 { sqlwhere.Add(" and sysuser.staffNum='" + ListBox5.SelectedValue.ToString() + "'"); } if (ListBox6.Text != "") //判断供应商是否选择 { sqlwhere.Add(" and receiver.receiverNum='" + ListBox6.SelectedValue.ToString() + "'"); } outs = new DAL.OutoutDAO().getOutsByWhere(sqlwhere); outout = outs; GridView2.DataSource = outs; GridView2.DataBind(); new Warehouse.Tools.AddSysLog().addlog("1", "出入库汇总", "查询"); refre_receive_Empty(); } }