protected void Button2_Click(object sender, EventArgs e) { if (HiddenField1.Value == "") { Maticsoft.Common.MessageBox.Show(this, "请添加商品"); return; } else { Model.BuyOrder BuyOrder = new Model.BuyOrder(); BuyOrder.Dept_ID = Convert.ToInt32(DropDownList1.SelectedValue); BuyOrder.Employee_ID = Convert.ToInt32(DropDownList3.SelectedValue); BuyOrder.WriteDate = DateTime.Now; BuyOrder.InsureDate = DateTime.Now; BuyOrder.EndDate = DateTime.Now; BuyOrder.Supplier_ID = Convert.ToInt32(DropDownList2.SelectedValue); BLL.BuyOrder bo = new BLL.BuyOrder(); Int32 BuyOrderId = bo.Add(BuyOrder); 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.BuyOrder_Detail model = new Model.BuyOrder_Detail(); BLL.BuyOrder_Detail bd = new BLL.BuyOrder_Detail(); model.BuyOrder_ID = BuyOrderId; model.Product_ID = Convert.ToInt32(ArrIds[i]); model.Quantity = Convert.ToDecimal(ArrQty[i]); model.Price = Convert.ToDecimal(ArrPri[i]); bd.Add(model); } Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!请到进货管理页进行入库操作", "/warehouse/BuyOrder/List.aspx"); } }
protected void Button1_Click(object sender, EventArgs e) { BLL.BuyOrder bl_bo = new BLL.BuyOrder(); Model.BuyOrder ml_bo = bl_bo.GetModel(BuyOrder_ID); if (!ml_bo.Produced)//字段值为false,表示已经入过库 { Maticsoft.Common.MessageBox.Show(this, "该单号已经入库,不能重复操作!"); return; } if (DropDownList4.SelectedValue == "0") { Maticsoft.Common.MessageBox.Show(this, "请选择仓库!"); return; } Model.EnterStock ET = new Model.EnterStock(); ET.Dept_ID = Convert.ToInt32(DropDownList1.SelectedValue); ET.Employee_ID = Convert.ToInt32(DropDownList3.SelectedValue); ET.StoreHouse_ID = Convert.ToInt32(DropDownList4.SelectedValue); ET.EnterDate = DateTime.Now; Int32 ETId = new BLL.EnterStock().Add(ET); foreach (RepeaterItem item in Repeater1.Items) { Label LB1 = (Label)item.FindControl("Label5"); //单价 Label LB2 = (Label)item.FindControl("Label6"); //数量 Label LB3 = (Label)item.FindControl("Label7"); //合计 Label LB4 = (Label)item.FindControl("Label1"); //商品编号 Int32 pro_id = Convert.ToInt32(LB4.Text); decimal pro_qty = Convert.ToDecimal(LB2.Text); Model.EnterStock_Detail esd = new Model.EnterStock_Detail(); esd.EnterStock_ID = ETId; esd.Product_ID = pro_id; esd.Quantity = pro_qty; esd.Price = Convert.ToDecimal(LB1.Text); esd.HaveInvoice = false; esd.InvoiceNum = "0000"; BLL.EnterStock_Detail bll_esd = new BLL.EnterStock_Detail(); bll_esd.Add(esd); //Model.StockPile sp = new Model.StockPile(); BLL.StockPile bll_sp = new BLL.StockPile(); Model.StockPile sp = bll_sp.GetModelByProId(pro_id, Convert.ToInt32(DropDownList4.SelectedValue)); if (sp == null) { sp = new Model.StockPile(); sp.Dept_ID = Convert.ToInt32(DropDownList1.SelectedValue); sp.StoreHouse_ID = Convert.ToInt32(DropDownList4.SelectedValue); sp.Product_ID = pro_id; sp.FirstEnterDate = DateTime.Now; sp.LastLeaveDate = DateTime.Now; sp.Quantity = pro_qty; sp.Price = Convert.ToDecimal(LB1.Text); bll_sp.Add(sp); } else { sp.Quantity += pro_qty; bll_sp.Update(sp); } ml_bo.Produced = false; bl_bo.Update(ml_bo); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "入库已完成!", "/warehouse/BuyOrder/List.aspx"); } }