protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtDept_ID.Text)) { strErr += "Dept_ID格式错误!\\n"; } if (!PageValidate.IsNumber(txtStoreHouse_ID.Text)) { strErr += "StoreHouse_ID格式错误!\\n"; } if (!PageValidate.IsNumber(txtProduct_ID.Text)) { strErr += "Product_ID格式错误!\\n"; } if (!PageValidate.IsDateTime(txtFirstEnterDate.Text)) { strErr += "FirstEnterDate格式错误!\\n"; } if (!PageValidate.IsDateTime(txtLastLeaveDate.Text)) { strErr += "LastLeaveDate格式错误!\\n"; } if (!PageValidate.IsNumber(txtQuantity.Text)) { strErr += "Quantity格式错误!\\n"; } if (!PageValidate.IsDecimal(txtPrice.Text)) { strErr += "Price格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int Dept_ID = int.Parse(this.txtDept_ID.Text); int StoreHouse_ID = int.Parse(this.txtStoreHouse_ID.Text); int Product_ID = int.Parse(this.txtProduct_ID.Text); DateTime FirstEnterDate = DateTime.Parse(this.txtFirstEnterDate.Text); DateTime LastLeaveDate = DateTime.Parse(this.txtLastLeaveDate.Text); int Quantity = int.Parse(this.txtQuantity.Text); decimal Price = decimal.Parse(this.txtPrice.Text); ZhangWei.Model.StockPile model = new ZhangWei.Model.StockPile(); model.Dept_ID = Dept_ID; model.StoreHouse_ID = StoreHouse_ID; model.Product_ID = Product_ID; model.FirstEnterDate = FirstEnterDate; model.LastLeaveDate = LastLeaveDate; model.Quantity = Quantity; model.Price = Price; ZhangWei.BLL.StockPile bll = new ZhangWei.BLL.StockPile(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }
/// <summary> /// 根据商品ID和仓库ID得到一个对象实体 /// </summary> /// <param name="Product_ID"></param> /// <returns></returns> public ZhangWei.Model.StockPile GetModelByProId(int Product_ID, int StoreHouse_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 StockPile_ID,Dept_ID,StoreHouse_ID,Product_ID,FirstEnterDate,LastLeaveDate,Quantity,Price from StockPile "); strSql.Append(" where Product_ID=@Product_ID AND StoreHouse_ID = @StoreHouse_ID"); SqlParameter[] parameters = { new SqlParameter("@Product_ID", SqlDbType.Int, 4), new SqlParameter("@StoreHouse_ID", SqlDbType.Int, 4) }; parameters[0].Value = Product_ID; parameters[1].Value = StoreHouse_ID; ZhangWei.Model.StockPile model = new ZhangWei.Model.StockPile(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["StockPile_ID"] != null && ds.Tables[0].Rows[0]["StockPile_ID"].ToString() != "") { model.StockPile_ID = int.Parse(ds.Tables[0].Rows[0]["StockPile_ID"].ToString()); } if (ds.Tables[0].Rows[0]["Dept_ID"] != null && ds.Tables[0].Rows[0]["Dept_ID"].ToString() != "") { model.Dept_ID = int.Parse(ds.Tables[0].Rows[0]["Dept_ID"].ToString()); } if (ds.Tables[0].Rows[0]["StoreHouse_ID"] != null && ds.Tables[0].Rows[0]["StoreHouse_ID"].ToString() != "") { model.StoreHouse_ID = int.Parse(ds.Tables[0].Rows[0]["StoreHouse_ID"].ToString()); } if (ds.Tables[0].Rows[0]["Product_ID"] != null && ds.Tables[0].Rows[0]["Product_ID"].ToString() != "") { model.Product_ID = int.Parse(ds.Tables[0].Rows[0]["Product_ID"].ToString()); } if (ds.Tables[0].Rows[0]["FirstEnterDate"] != null && ds.Tables[0].Rows[0]["FirstEnterDate"].ToString() != "") { model.FirstEnterDate = DateTime.Parse(ds.Tables[0].Rows[0]["FirstEnterDate"].ToString()); } if (ds.Tables[0].Rows[0]["LastLeaveDate"] != null && ds.Tables[0].Rows[0]["LastLeaveDate"].ToString() != "") { model.LastLeaveDate = DateTime.Parse(ds.Tables[0].Rows[0]["LastLeaveDate"].ToString()); } if (ds.Tables[0].Rows[0]["Quantity"] != null && ds.Tables[0].Rows[0]["Quantity"].ToString() != "") { model.Quantity = decimal.Parse(ds.Tables[0].Rows[0]["Quantity"].ToString()); } if (ds.Tables[0].Rows[0]["Price"] != null && ds.Tables[0].Rows[0]["Price"].ToString() != "") { model.Price = decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString()); } return(model); } else { return(null); } }
protected void EnterAgain()//重新入库 { //Model.Sale ml_sale = bll_sale.GetModel(Convert.ToInt32(Request.Params["Sale_ID"])); Model.EnterStock ml_es = bl_es.GetModel(EnterStock_ID); ml_es.StoreHouse_ID = Convert.ToInt32(DropDownList1.SelectedValue); bl_es.Update(ml_es); //ml_sale.GatheringWay = this.DropDownList6.SelectedItem.Text; //ml_sale.Account = this.DropDownList4.SelectedItem.Text; //ml_sale.Address = this.TextBox1.Text; //ml_sale.Customer = Convert.ToInt32(DropDownList5.SelectedValue); //bll_sale.Update(ml_sale); string Ids = this.newId.Value.Replace(" ", "").Replace("\r\n", ""); string Qtys = this.newQty.Value.Replace(" ", "").Replace("\r\n", ""); string Prices = this.newPrice.Value.Replace(" ", "").Replace("\r\n", ""); string[] ArrIds = Ids.Split(new char[] { '|' }); string[] ArrQty = Qtys.Split(new char[] { '|' }); string[] ArrPri = Prices.Split(new char[] { '|' }); for (int i = 0; i < ArrIds.Length - 1; i++) { Model.EnterStock_Detail ml_esd = new ZhangWei.Model.EnterStock_Detail(); ml_esd.EnterStock_ID = EnterStock_ID; ml_esd.Product_ID = Convert.ToInt32(ArrIds[i]); ml_esd.Quantity = Convert.ToDecimal(ArrQty[i]); ml_esd.Price = Convert.ToDecimal(ArrPri[i]); BLL.Sale_Detail bl_sd = new ZhangWei.BLL.Sale_Detail(); //ml_sa.Sale_ID = Convert.ToInt32(Request.Params["Sale_ID"]); //ml_sa.Product_ID = Convert.ToInt32(ArrIds[i]); //ml_sa.SaleOrder_ID = 0; //ml_sa.Quantity = Convert.ToDecimal(ArrQty[i]); //ml_sa.Price = Convert.ToDecimal(ArrPri[i]); Model.StockPile ml_sp = new BLL.StockPile().GetModelByProId(Convert.ToInt32(ArrIds[i]), Convert.ToInt32(DropDownList1.SelectedValue)); BLL.StockPile bl_sp = new ZhangWei.BLL.StockPile(); if (ml_sp == null) { Model.Product ml_pr = new BLL.Product().GetModel(Convert.ToInt32(ArrIds[i])); ml_sp = new ZhangWei.Model.StockPile(); ml_sp.Product_ID = Convert.ToInt32(ArrIds[i]); ml_sp.Dept_ID = 1; ml_sp.FirstEnterDate = DateTime.Now; ml_sp.LastLeaveDate = DateTime.Now; ml_sp.Price = Convert.ToDecimal(ArrPri[i]); ml_sp.Quantity = 0; ml_sp.StoreHouse_ID = Convert.ToInt32(DropDownList1.SelectedValue); ml_sp.Quantity += Convert.ToDecimal(ArrQty[i]); bl_sp.Add(ml_sp); } else { ml_sp.Quantity += Convert.ToDecimal(ArrQty[i]); //ml_sp.LastLeaveDate = DateTime.Now; bl_sp.Update(ml_sp); } bl_esd.Add(ml_esd); } }
private void ShowInfo(int StockPile_ID) { ZhangWei.BLL.StockPile bll = new ZhangWei.BLL.StockPile(); ZhangWei.Model.StockPile model = bll.GetModel(StockPile_ID); this.lblStockPile_ID.Text = model.StockPile_ID.ToString(); this.lblDept_ID.Text = model.Dept_ID.ToString(); this.lblStoreHouse_ID.Text = model.StoreHouse_ID.ToString(); this.lblProduct_ID.Text = model.Product_ID.ToString(); this.lblFirstEnterDate.Text = model.FirstEnterDate.ToString(); this.lblLastLeaveDate.Text = model.LastLeaveDate.ToString(); this.lblQuantity.Text = model.Quantity.ToString(); this.lblPrice.Text = model.Price.ToString(); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ZhangWei.Model.StockPile model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update StockPile set "); strSql.Append("Dept_ID=@Dept_ID,"); strSql.Append("StoreHouse_ID=@StoreHouse_ID,"); strSql.Append("Product_ID=@Product_ID,"); strSql.Append("FirstEnterDate=@FirstEnterDate,"); strSql.Append("LastLeaveDate=@LastLeaveDate,"); strSql.Append("Quantity=@Quantity,"); strSql.Append("Price=@Price"); strSql.Append(" where StockPile_ID=@StockPile_ID"); SqlParameter[] parameters = { new SqlParameter("@Dept_ID", SqlDbType.Int, 4), new SqlParameter("@StoreHouse_ID", SqlDbType.Int, 4), new SqlParameter("@Product_ID", SqlDbType.Int, 4), new SqlParameter("@FirstEnterDate", SqlDbType.DateTime), new SqlParameter("@LastLeaveDate", SqlDbType.DateTime), new SqlParameter("@Quantity", SqlDbType.Decimal, 9), new SqlParameter("@Price", SqlDbType.Money, 8), new SqlParameter("@StockPile_ID", SqlDbType.Int, 4) }; parameters[0].Value = model.Dept_ID; parameters[1].Value = model.StoreHouse_ID; parameters[2].Value = model.Product_ID; parameters[3].Value = model.FirstEnterDate; parameters[4].Value = model.LastLeaveDate; parameters[5].Value = model.Quantity; parameters[6].Value = model.Price; parameters[7].Value = model.StockPile_ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(ZhangWei.Model.StockPile model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into StockPile("); strSql.Append("Dept_ID,StoreHouse_ID,Product_ID,FirstEnterDate,LastLeaveDate,Quantity,Price)"); strSql.Append(" values ("); strSql.Append("@Dept_ID,@StoreHouse_ID,@Product_ID,@FirstEnterDate,@LastLeaveDate,@Quantity,@Price)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Dept_ID", SqlDbType.Int, 4), new SqlParameter("@StoreHouse_ID", SqlDbType.Int, 4), new SqlParameter("@Product_ID", SqlDbType.Int, 4), new SqlParameter("@FirstEnterDate", SqlDbType.DateTime), new SqlParameter("@LastLeaveDate", SqlDbType.DateTime), new SqlParameter("@Quantity", SqlDbType.Decimal, 9), new SqlParameter("@Price", SqlDbType.Money, 8) }; parameters[0].Value = model.Dept_ID; parameters[1].Value = model.StoreHouse_ID; parameters[2].Value = model.Product_ID; parameters[3].Value = model.FirstEnterDate; parameters[4].Value = model.LastLeaveDate; parameters[5].Value = model.Quantity; parameters[6].Value = model.Price; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
protected void Button2_Click(object sender, EventArgs e) { if (HiddenField1.Value == "") { Maticsoft.Common.MessageBox.Show(this, "请添加商品"); return; } else { Model.Sale ml_sale = new ZhangWei.Model.Sale(); ml_sale.SaleDate = Convert.ToDateTime(TextBox1.Text); ml_sale.Dept_ID = Convert.ToInt32(DropDownList1.SelectedValue); ml_sale.Customer = Convert.ToInt32(DropDownList5.SelectedValue);//客户 ml_sale.Employee_ID = Convert.ToInt32(DropDownList2.SelectedValue); ml_sale.Account = DropDownList4.SelectedValue; ml_sale.Address = TextBox2.Text; ml_sale.GatheringWay = DropDownList6.SelectedValue; ml_sale.StoreHouse_ID = Convert.ToInt32(DropDownList3.SelectedValue); ml_sale.TradeNo = GetTradeNo(); Int32 sale_id = new BLL.Sale().Add(ml_sale); string Ids = HiddenField1.Value.Replace(" ", "").Replace("\r\n", ""); string Qtys = HiddenField2.Value.Replace(" ", "").Replace("\r\n", ""); string Prices = HiddenField3.Value.Replace(" ", "").Replace("\r\n", ""); string[] ArrIds = Ids.Split(new char[] { '|' }); string[] ArrQty = Qtys.Split(new char[] { '|' }); string[] ArrPri = Prices.Split(new char[] { '|' }); for (int i = 0; i < ArrIds.Length - 1; i++) { Model.Sale_Detail ml_sa = new ZhangWei.Model.Sale_Detail(); BLL.Sale_Detail bl_sd = new ZhangWei.BLL.Sale_Detail(); ml_sa.Sale_ID = sale_id; ml_sa.Product_ID = Convert.ToInt32(ArrIds[i]); //ml_sa.SaleOrder_ID = 0; ml_sa.Quantity = Convert.ToDecimal(ArrQty[i]); ml_sa.Price = Convert.ToDecimal(ArrPri[i]); Model.StockPile ml_sp = new BLL.StockPile().GetModelByProId(Convert.ToInt32(ArrIds[i]), Convert.ToInt32(DropDownList3.SelectedValue)); BLL.StockPile bl_sp = new ZhangWei.BLL.StockPile(); if (ml_sp == null) { Model.Product ml_pr = new BLL.Product().GetModel(Convert.ToInt32(ArrIds[i])); ml_sp = new ZhangWei.Model.StockPile(); ml_sp.Product_ID = Convert.ToInt32(ArrIds[i]); ml_sp.Dept_ID = Convert.ToInt32(DropDownList1.SelectedValue); ml_sp.FirstEnterDate = DateTime.Now; ml_sp.LastLeaveDate = DateTime.Now; ml_sp.Price = Convert.ToDecimal(ArrPri[i]); ml_sp.Quantity = 0; ml_sp.StoreHouse_ID = Convert.ToInt32(DropDownList3.SelectedValue); ml_sp.Quantity -= Convert.ToDecimal(ArrQty[i]); bl_sp.Add(ml_sp); } else { ml_sp.Quantity -= Convert.ToDecimal(ArrQty[i]); ml_sp.LastLeaveDate = DateTime.Now; bl_sp.Update(ml_sp); } bl_sd.Add(ml_sa); } Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功,单号为:" + ml_sale.TradeNo, "/Sales/SaleReport.aspx"); } }
protected void Button2_Click(object sender, EventArgs e) { if (HiddenField1.Value == "") { Maticsoft.Common.MessageBox.Show(this, "请添加商品"); return; } else { Model.LeaveStock LeaveStock = new Model.LeaveStock(); LeaveStock.LeaveDate = Convert.ToDateTime(txtWriteDate.Text); LeaveStock.Dept_ID = Convert.ToInt32(DropDownList1.SelectedValue); LeaveStock.Employee_ID = Convert.ToInt32(DropDownList4.SelectedValue); LeaveStock.StoreHouse_ID = Convert.ToInt32(DropDownList2.SelectedValue); LeaveStock.ToStoreHouse_ID = Convert.ToInt32(DropDownList3.SelectedValue); Int32 LeaveStock_ID = new BLL.LeaveStock().Add(LeaveStock); string Ids = HiddenField1.Value.Replace(" ", "").Replace("\r\n", ""); string Qtys = HiddenField2.Value.Replace(" ", "").Replace("\r\n", ""); string Prices = HiddenField3.Value.Replace(" ", "").Replace("\r\n", ""); string[] ArrIds = Ids.Split(new char[] { '|' }); string[] ArrQty = Qtys.Split(new char[] { '|' }); string[] ArrPri = Prices.Split(new char[] { '|' }); for (int i = 0; i < ArrIds.Length - 1; i++) { Model.LeaveStock_Detail ml_ld = new Model.LeaveStock_Detail(); BLL.LeaveStock_Detail bl_ld = new BLL.LeaveStock_Detail(); ml_ld.LeaveStock_ID = LeaveStock_ID; ml_ld.Product_ID = Convert.ToInt32(ArrIds[i]); ml_ld.Quantity = Convert.ToDecimal(ArrQty[i]); ml_ld.Price = Convert.ToDecimal(ArrPri[i]); Model.StockPile ml_sp_out = new BLL.StockPile().GetModelByProId(Convert.ToInt32(ArrIds[i]), Convert.ToInt32(DropDownList2.SelectedValue)); Model.StockPile ml_sp_in = new BLL.StockPile().GetModelByProId(Convert.ToInt32(ArrIds[i]), Convert.ToInt32(DropDownList3.SelectedValue)); BLL.StockPile bl_sp = new ZhangWei.BLL.StockPile(); if (ml_sp_out == null) { //Model.Product ml_pr = new BLL.Product().GetModel(Convert.ToInt32(ArrIds[i])); ml_sp_out = new ZhangWei.Model.StockPile(); ml_sp_out.Product_ID = Convert.ToInt32(ArrIds[i]); ml_sp_out.Dept_ID = Convert.ToInt32(DropDownList1.SelectedValue); ml_sp_out.FirstEnterDate = DateTime.Now; ml_sp_out.LastLeaveDate = DateTime.Now; ml_sp_out.Price = Convert.ToDecimal(ArrPri[i]); ml_sp_out.Quantity = 0; ml_sp_out.StoreHouse_ID = Convert.ToInt32(DropDownList2.SelectedValue); ml_sp_out.Quantity -= Convert.ToDecimal(ArrQty[i]); bl_sp.Add(ml_sp_out); } else { ml_sp_out.Quantity -= Convert.ToDecimal(ArrQty[i]); ml_sp_out.LastLeaveDate = DateTime.Now; bl_sp.Update(ml_sp_out); } if (ml_sp_in == null) { Model.Product ml_pr = new BLL.Product().GetModel(Convert.ToInt32(ArrIds[i])); ml_sp_in = new ZhangWei.Model.StockPile(); ml_sp_in.Product_ID = Convert.ToInt32(ArrIds[i]); ml_sp_in.Dept_ID = Convert.ToInt32(DropDownList1.SelectedValue); ml_sp_in.FirstEnterDate = DateTime.Now; ml_sp_in.LastLeaveDate = DateTime.Now; ml_sp_in.Price = Convert.ToDecimal(ArrPri[i]); ml_sp_in.Quantity = 0; ml_sp_in.StoreHouse_ID = Convert.ToInt32(DropDownList3.SelectedValue); ml_sp_in.Quantity += Convert.ToDecimal(ArrQty[i]); bl_sp.Add(ml_sp_in); } else { ml_sp_in.Quantity += Convert.ToDecimal(ArrQty[i]); ml_sp_in.LastLeaveDate = DateTime.Now; bl_sp.Update(ml_sp_in); } bl_ld.Add(ml_ld); } Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "/warehouse/TransferRecord.aspx"); } }
protected void Button2_Click(object sender, EventArgs e) { if (HiddenField1.Value == "") { Maticsoft.Common.MessageBox.Show(this, "请添加商品"); return; } else { Model.BackStock ml_bs = new ZhangWei.Model.BackStock(); ml_bs.BackDate = Convert.ToDateTime(BackDate.Text); ml_bs.Dept_ID = Convert.ToInt32(DropDownList1.SelectedValue); ml_bs.Employee_ID = Convert.ToInt32(DropDownList2.SelectedValue); ml_bs.StoreHouse_ID = Convert.ToInt32(DropDownList3.SelectedValue); ml_bs.Remark = this.TextBox1.Text; Int32 BackStock_id = new BLL.BackStock().Add(ml_bs); string Ids = HiddenField1.Value.Replace(" ", "").Replace("\r\n", ""); string Qtys = HiddenField2.Value.Replace(" ", "").Replace("\r\n", ""); string Prices = HiddenField3.Value.Replace(" ", "").Replace("\r\n", ""); string[] ArrIds = Ids.Split(new char[] { '|' }); string[] ArrQty = Qtys.Split(new char[] { '|' }); string[] ArrPri = Prices.Split(new char[] { '|' }); for (int i = 0; i < ArrIds.Length - 1; i++) { //Model.Sale_Detail ml_sa = new ZhangWei.Model.Sale_Detail(); Model.BackStock_Detail ml_bsd = new ZhangWei.Model.BackStock_Detail(); ml_bsd.BackStock_ID = BackStock_id; ml_bsd.Product_ID = Convert.ToInt32(ArrIds[i]); ml_bsd.Price = Convert.ToDecimal(ArrPri[i]); ml_bsd.Quantity = Convert.ToDecimal(ArrQty[i]); BLL.BackStock_Detail bl_bsd = new ZhangWei.BLL.BackStock_Detail(); Model.StockPile ml_sp = new BLL.StockPile().GetModelByProId(Convert.ToInt32(ArrIds[i]), Convert.ToInt32(DropDownList3.SelectedValue)); BLL.StockPile bl_sp = new ZhangWei.BLL.StockPile(); if (ml_sp == null) { Model.Product ml_pr = new BLL.Product().GetModel(Convert.ToInt32(ArrIds[i])); ml_sp = new ZhangWei.Model.StockPile(); ml_sp.Product_ID = Convert.ToInt32(ArrIds[i]); ml_sp.Dept_ID = Convert.ToInt32(DropDownList1.SelectedValue); ml_sp.FirstEnterDate = DateTime.Now; ml_sp.LastLeaveDate = DateTime.Now; ml_sp.Price = Convert.ToDecimal(ArrPri[i]); ml_sp.StoreHouse_ID = Convert.ToInt32(DropDownList3.SelectedValue); ml_sp.Quantity = 0; ml_sp.Quantity -= Convert.ToDecimal(ArrQty[i]); bl_sp.Add(ml_sp); } else { ml_sp.Quantity -= Convert.ToDecimal(ArrQty[i]); ml_sp.LastLeaveDate = DateTime.Now; bl_sp.Update(ml_sp); } bl_bsd.Add(ml_bsd); } Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "/warehouse/BackStock/List.aspx"); } }