Esempio n. 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtSale_ID.Text))
            {
                strErr += "Sale_ID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtProduct_ID.Text))
            {
                strErr += "Product_ID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtSaleOrder_ID.Text))
            {
                strErr += "SaleOrder_ID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtQuantity.Text))
            {
                strErr += "Quantity格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtPrice.Text))
            {
                strErr += "Price格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtDiscount.Text))
            {
                strErr += "Discount格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int     Sale_ID      = int.Parse(this.txtSale_ID.Text);
            int     Product_ID   = int.Parse(this.txtProduct_ID.Text);
            int     SaleOrder_ID = int.Parse(this.txtSaleOrder_ID.Text);
            int     Quantity     = int.Parse(this.txtQuantity.Text);
            decimal Price        = decimal.Parse(this.txtPrice.Text);
            int     Discount     = int.Parse(this.txtDiscount.Text);

            ZhangWei.Model.Sale_Detail model = new ZhangWei.Model.Sale_Detail();
            model.Sale_ID      = Sale_ID;
            model.Product_ID   = Product_ID;
            model.SaleOrder_ID = SaleOrder_ID;
            model.Quantity     = Quantity;
            model.Price        = Price;
            model.Discount     = Discount;

            ZhangWei.BLL.Sale_Detail bll = new ZhangWei.BLL.Sale_Detail();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Esempio n. 2
0
        protected void SaleAgain()
        {
            Model.Sale ml_sale = bll_sale.GetModel(Convert.ToInt32(Request.QueryString["Sale_ID"]));
            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);
            ml_sale.StoreHouse_ID = Convert.ToInt32(DropDownList1.SelectedValue);
            ml_sale.Dept_ID       = Convert.ToInt32(DropDownList2.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.Sale_Detail ml_sa = new ZhangWei.Model.Sale_Detail();
                BLL.Sale_Detail   bl_sd = new ZhangWei.BLL.Sale_Detail();
                ml_sa.Sale_ID    = Convert.ToInt32(Request.QueryString["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        = Convert.ToInt32(DropDownList2.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(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_sd.Add(ml_sa);
            }
        }
Esempio n. 3
0
 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");
     }
 }