/// <summary> /// 更新某个库存对象 /// </summary> /// <param name="aamount">库存对象</param> public bool update(Model.Amount aamount) { string sqltext = "update amount set amount=@amount,V=@V where positionNum=@positionNum1 and goodsNum=@goodsNum1 and Vp=@Vp"; List <SqlParameter> para = new List <SqlParameter>(); SqlParameter sqlpara1 = new SqlParameter("@V", aamount.V); SqlParameter sqlpara2 = new SqlParameter("@amount", aamount.Amounts); SqlParameter sqlpara4 = new SqlParameter("@positionNum1", aamount.PositionNum); SqlParameter sqlpara6 = new SqlParameter("@goodsNum1", aamount.GoodsNum); SqlParameter sqlpara7 = new SqlParameter("@Vp", aamount.Vp); para.Add(sqlpara2); para.Add(sqlpara1); para.Add(sqlpara4); para.Add(sqlpara6); para.Add(sqlpara7); int i = DBTools.exenonquerySQL(sqltext, para); if (i == 1) { return(true); } else { return(false); } }
/// <summary> /// 添加一条库存记录。 /// </summary> /// <param name="aamount">库存记录对象</param> public bool addAmount(Model.Amount aamount) { string sqltext = "insert amount(num,positionNum,goodsNum,amount,per,V,Vp) values(@num,@positionNum,@goodsNum,@amount,@per,@V,@Vp)"; List <SqlParameter> para = new List <SqlParameter>(); SqlParameter sqlpara = new SqlParameter("@num", aamount.Num); SqlParameter sqlpara1 = new SqlParameter("@positionNum", aamount.PositionNum); SqlParameter sqlpara2 = new SqlParameter("@goodsNum", aamount.GoodsNum); SqlParameter sqlpara3 = new SqlParameter("@amount", aamount.Amounts); SqlParameter sqlpara4 = new SqlParameter("@per", aamount.AmountPer); SqlParameter sqlpara5 = new SqlParameter("@V", aamount.V); SqlParameter sqlpara6 = new SqlParameter("@Vp", aamount.Vp); para.Add(sqlpara); para.Add(sqlpara1); para.Add(sqlpara2); para.Add(sqlpara3); para.Add(sqlpara4); para.Add(sqlpara5); para.Add(sqlpara6); int i = DBTools.exenonquerySQL(sqltext, para); if (i == 1) { return(true); } else { return(false); } }
/// <summary> /// 更新某个库存对象 /// </summary> /// <param name="aamount">库存对象</param> public bool updateAmount(Model.Amount aamount) { string sqltext = "update amount set goodsNum=@goodsNum,amount=@amount,per=@per,v=@v where positionNum=@positionNum1 and goodsNum=@goodsNum1"; List <SqlParameter> para = new List <SqlParameter>(); SqlParameter sqlpara1 = new SqlParameter("@goodsNum", aamount.GoodsNum); SqlParameter sqlpara2 = new SqlParameter("@amount", aamount.Amounts); SqlParameter sqlpara3 = new SqlParameter("@per", aamount.AmountPer); SqlParameter sqlpara = new SqlParameter("@v", aamount.V); SqlParameter sqlpara4 = new SqlParameter("@positionNum1", aamount.PositionNum); SqlParameter sqlpara6 = new SqlParameter("@goodsNum1", aamount.GoodsNum); para.Add(sqlpara1); para.Add(sqlpara2); para.Add(sqlpara3); para.Add(sqlpara); para.Add(sqlpara4); para.Add(sqlpara6); int i = DBTools.exenonquerySQL(sqltext, para); if (i == 1) { return(true); } else { return(false); } }
/// <summary> /// 获取所有库存对象。 /// </summary> public List <Model.Amount> getAllAmounts() { List <Model.Amount> amount = new List <Model.Amount>(); string sqltext = "select * from amount"; SqlDataReader sdr = DBTools.exereaderSQL(sqltext, new List <SqlParameter>()); while (sdr.Read()) { Model.Amount a = new Model.Amount(); a.PositionNum = sdr["positionNum"].ToString(); a.GoodsNum = sdr["goodsNum"].ToString(); a.Amounts = double.Parse(sdr["amount"].ToString()); a.AmountPer = sdr["per"].ToString(); amount.Add(a); } sdr.Close(); DBTools.DBClose(); return(amount); }
protected void Button66_Click(object sender, EventArgs e) { Model.Outout add = new Model.Outout(); if (Button66.Text == "增加") { if (Image1.ImageUrl == "~/Image/对号.png" && Image2.ImageUrl == "~/Image/对号.png" && Image3.ImageUrl == "~/Image/对号.png" && Image4.ImageUrl == "~/Image/对号.png" && Image5.ImageUrl == "~/Image/对号.png" && Image6.ImageUrl == "~/Image/对号.png" && Image7.ImageUrl == "~/Image/对号.png" && Image8.ImageUrl == "~/Image/对号.png") { Warehouse.Tools.queryV qq = new Tools.queryV(); DAL.Query quu = new DAL.Query(); int n = quu.query("Outout"); add.Num = n + 1; add.OuID = TextBox11.Text; add.GoodsNum = TextBox12.Text; add.PositionNum = TextBox9.Text; add.OutAmount = Convert.ToDouble(TextBox2.Text); add.BatchNum = TextBox3.Text; add.Date = Convert.ToDateTime(TextBox4.Text); add.UserId = qu.query("select staffNum from Staff where staffName='" + TextBox5.Text + "'"); add.Remark = TextBox6.Text; bool xx = new DAL.OutoutDAO().addOut(add); if (xx) { Model.Amount update = new Model.Amount(); update.Amounts = Convert.ToDouble(Session["max"].ToString()) - Convert.ToDouble(add.OutAmount); double d = Convert.ToDouble(Session["V"].ToString()) / Convert.ToDouble(Session["max"].ToString()); update.V = (update.Amounts * d).ToString(); update.GoodsNum = TextBox12.Text; update.PositionNum = TextBox9.Text; update.Vp = d.ToString(); bool yy = new DAL.AmountDAO().update(update); if (yy) { double rest = Convert.ToDouble(qu.query("select Rest from Position where positionNum='" + TextBox9.Text + "'")); Model.Position Update = new Model.Position(); Update.Rest = (rest + d * add.OutAmount).ToString(); Update.PositionNum = TextBox9.Text; bool cc = new DAL.PositionDAO().update(Update); } ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('添加成功!');window.location.href='出库登记.aspx'", true); } } } }
/// <summary> /// 获取满足指定位置和物品编号条件的。 /// </summary> public Model.Amount getAmountsByWherePoAndGo(List <string> Conditions) { Model.Amount a = null; string sqltext = "select * from amount where 1=1"; foreach (string sql in Conditions) { sqltext += sql; } SqlDataReader sdr = DBTools.exereaderSQL(sqltext, new List <SqlParameter>()); while (sdr.Read()) { a = new Model.Amount(); a.PositionNum = sdr["positionNum"].ToString(); a.GoodsNum = sdr["goodsNum"].ToString(); a.Amounts = int.Parse(sdr["amount"].ToString()); a.AmountPer = sdr["per"].ToString(); } sdr.Close(); DBTools.DBClose(); return(a); }
/// <summary> /// 获取满足指定条件的。 /// </summary> public List <Model.Amount> getAmountsByWhere(List <string> Conditions) { List <Model.Amount> amount = new List <Model.Amount>(); string sqltext = "select * from amount,position,goods,goodsType,chest where Amount.goodsNum=Goods.goodsNum and Amount.positionNum=Position.positionNum and Goods.goodsTypeNum=Goodstype.goodsTypeNum and Position.chestNum=Chest.chestNum"; foreach (string sql in Conditions) { sqltext += sql; } SqlDataReader sdr = DBTools.exereaderSQL(sqltext, new List <SqlParameter>()); while (sdr.Read()) { Model.Amount a = new Model.Amount(); a.PositionNum = sdr["positionNum"].ToString(); a.GoodsNum = sdr["goodsNum"].ToString(); a.Amounts = int.Parse(sdr["amount"].ToString()); a.AmountPer = sdr["per"].ToString(); amount.Add(a); } sdr.Close(); DBTools.DBClose(); return(amount); }
/// <summary> /// 更新某个库存对象。 /// </summary> /// <param name="aamount">库存对象</param> /// <returns>通过布尔值判断操作是否成功。</returns> public bool updateAmount(Model.Amount aamount) { throw new System.NotImplementedException(); }
protected void Button66_Click(object sender, EventArgs e) { if (Button66.Text == "增加") { if (Image1.ImageUrl == "~/Image/对号.png" && Image2.ImageUrl == "~/Image/对号.png" && Image3.ImageUrl == "~/Image/对号.png" && Image4.ImageUrl == "~/Image/对号.png" && Image5.ImageUrl == "~/Image/对号.png" && Image6.ImageUrl == "~/Image/对号.png" && Image7.ImageUrl == "~/Image/对号.png" && Image8.ImageUrl == "~/Image/对号.png") { Warehouse.Tools.queryV qq = new Tools.queryV(); Model.Inin add = new Model.Inin(); DAL.Query qu = new DAL.Query(); int n = qu.query("Inin"); add.Num = n + 1; add.InID = TextBox11.Text; add.PositionNum = TextBox9.Text; add.GoodsNum = TextBox12.Text; add.InAmount = double.Parse(TextBox2.Text); add.V = (Convert.ToDouble(tiqu.tiqu(TextBox2.Text)) * Convert.ToDouble(tiqu.tiqu(TextBox7.Text))).ToString(); add.BatchNum = TextBox3.Text; add.Date = DateTime.Now; add.UserId = TextBox5.Text; add.Remark = TextBox6.Text; bool xx = new DAL.IninDAO().addIn(add); if (xx) { if ((Convert.ToInt32(new Warehouse.Tools.queryV().query("select count(*) from Amount where goodsNum='" + add.GoodsNum + "' and PositionNum ='" + add.PositionNum + "' ")) > 0) && (Convert.ToInt32(new Warehouse.Tools.queryV().query("select count(*) from Amount where Vp='" + (tiqu.tiqu(TextBox7.Text)).ToString() + "' "))) > 0) { Model.Amount addd = new Model.Amount(); addd.Num = Convert.ToInt32(new Warehouse.Tools.queryV().query("select count(*) from Amount where 1=1 ")) + 1; addd.GoodsNum = add.GoodsNum; addd.PositionNum = add.PositionNum; addd.Vp = (tiqu.tiqu(TextBox7.Text)).ToString(); addd.Amounts = add.InAmount + Convert.ToDouble(new Warehouse.Tools.queryV().query("select amount from Amount where goodsNum='" + add.GoodsNum + "' and PositionNum ='" + add.PositionNum + "' ")); switch (new Warehouse.Tools.queryV().query("select goodsStyle from Goods where goodsNum='" + add.GoodsNum + "'").ToString()) { case "固态": addd.AmountPer = "Kg"; break; case "液态": addd.AmountPer = "L"; break; case "气态": addd.AmountPer = "L"; break; case "其他": addd.AmountPer = "Kg"; break; } addd.V = (Convert.ToDouble(new Warehouse.Tools.queryV().query("select V from Amount where goodsNum='" + add.GoodsNum + "' and PositionNum ='" + add.PositionNum + "' ")) + (Convert.ToDouble(TextBox2.Text) * Convert.ToDouble(tiqu.tiqu(TextBox7.Text)))).ToString(); new DAL.AmountDAO().updateAmount(addd); } else { Model.Amount addd = new Model.Amount(); addd.Num = Convert.ToInt32(new Warehouse.Tools.queryV().query("select count(*) from Amount where 1=1 ")) + 1; addd.GoodsNum = add.GoodsNum; addd.PositionNum = add.PositionNum; addd.Amounts = add.InAmount; switch (new Warehouse.Tools.queryV().query("select goodsStyle from Goods where goodsNum='" + add.GoodsNum + "' ").ToString()) { case "固态": addd.AmountPer = "Kg"; break; case "液态": addd.AmountPer = "L"; break; case "气态": addd.AmountPer = "L"; break; case "其他": addd.AmountPer = "Kg"; break; } addd.Vp = (tiqu.tiqu(TextBox7.Text)).ToString(); addd.V = (Convert.ToDouble(tiqu.tiqu(TextBox2.Text)) * Convert.ToDouble(tiqu.tiqu(TextBox7.Text))).ToString(); new DAL.AmountDAO().addAmount(addd); } Warehouse.Tools.update up = new Tools.update(); double xxxx1 = (tiqu.tiqu(TextBox7.Text) * (tiqu.tiqu(TextBox2.Text))); double xxxx2 = tiqu.tiqu(qq.query("select Rest from Position where positionNum='" + TextBox9.Text + "' ")); string rest = (xxxx2 - xxxx1).ToString(); up.updates("update Position set Rest='" + rest + "' where positionNum='" + TextBox9.Text + "' "); ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('添加成功!');", true); Div1.Visible = false; GridView1.Visible = true; if (GridView1.Visible == true) { Button1.Visible = true; Button4.Visible = true; ListBox11.Visible = true; TextBox1.Visible = true; Button5.Visible = true; } rg.Refresh("select * from Inin order by num", "inID", GridView1); Warehouse.TextBox_Clear tx = new TextBox_Clear(); tx.clear(Div1); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('添加失败!');", true); } } else { Response.Write("<script>window.location.href='#div_kkk'</script>"); } } else if (Button66.Text == "确定") { Model.Inin add = new Model.Inin(); add.InID = TextBox11.Text; add.PositionNum = TextBox9.Text; add.GoodsNum = TextBox12.Text; add.InAmount = Int32.Parse(TextBox2.Text); add.BatchNum = TextBox3.Text; add.Date = DateTime.Now; add.UserId = TextBox5.Text; add.Remark = TextBox6.Text; bool xx = new DAL.IninDAO().updateIn(add); if (xx) { ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('修改成功!');", true); Div1.Visible = false; GridView1.Visible = true; if (GridView1.Visible == true) { Button1.Visible = true; Button4.Visible = true; ListBox11.Visible = true; TextBox1.Visible = true; Button5.Visible = true; } rg.Refresh("select * from Inin order by num", "inID", GridView1); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('修改失败!');", true); } } }