protected void bt_AddProduct_Click(object sender, EventArgs e)
    {
        SVM_InventoryBLL bll = new SVM_InventoryBLL((int)ViewState["InventoryID"]);
        int product = 0;
        if (int.TryParse(select_Product.SelectValue, out product) && product > 0)
        {
            PDT_Product pdt = new PDT_ProductBLL(product).Model;
            if (pdt == null) return;
            int quantity = int.Parse(tbx_Q1.Text) * pdt.ConvertFactor + int.Parse(tbx_Q2.Text);
            if (quantity == 0) return;
            SVM_Inventory_Detail _detail = bll.Items.FirstOrDefault(m => m.Product == product);
            if (_detail == null)
            {
                _detail = new SVM_Inventory_Detail();
                decimal factoryprice = 0, price = 0;
                PDT_ProductPriceBLL.GetPriceByClientAndType((int)ViewState["ClientID"], product, 2, out factoryprice, out price);
                _detail.FactoryPrice = factoryprice;
                _detail.Product = pdt.ID;
                _detail.Quantity = quantity;
                _detail.InventoryID = (int)ViewState["InventoryID"];
                bll.AddDetail(_detail);
            }
            else
            {
                _detail.Quantity = quantity;
                bll.UpdateDetail(_detail);
            }

            BindGrid();
        }
    }
Exemplo n.º 2
0
    protected void Save()
    {
        SVM_InventoryBLL bll       = new SVM_InventoryBLL((int)ViewState["InventoryID"]);
        DropDownList     ddl_Month = (DropDownList)UC_DetailView1.FindControl("SVM_Inventory_AccountMonth");

        bll.Model.InventoryDate = DateTime.Now.Date;
        bll.Model.AccountMonth  = int.Parse(ddl_Month.SelectedValue);
        bll.Model["SubmitFlag"] = "2";
        bll.Update();
        foreach (GridViewRow gr in gv_List.Rows)
        {
            int id = (int)gv_List.DataKeys[gr.RowIndex][0];
            SVM_Inventory_Detail item = bll.GetDetailModel(id);

            item.Quantity = int.Parse(((TextBox)gr.FindControl("tbx_Quantity1")).Text) * new PDT_ProductBLL(item.Product).Model.ConvertFactor +
                            int.Parse(((TextBox)gr.FindControl("tbx_Quantity2")).Text);
            item.Remark = ((TextBox)gr.FindControl("tbx_Remark")).Text;

            bll.UpdateDetail(item);
        }
    }
Exemplo n.º 3
0
    protected void bt_AddProduct_Click(object sender, EventArgs e)
    {
        SVM_InventoryBLL bll = new SVM_InventoryBLL((int)ViewState["InventoryID"]);
        int product          = 0;

        if (int.TryParse(select_Product.SelectValue, out product) && product > 0)
        {
            PDT_Product pdt = new PDT_ProductBLL(product).Model;
            if (pdt == null)
            {
                return;
            }
            int quantity = int.Parse(tbx_Q1.Text) * pdt.ConvertFactor + int.Parse(tbx_Q2.Text);
            if (quantity == 0)
            {
                return;
            }
            SVM_Inventory_Detail _detail = bll.Items.FirstOrDefault(m => m.Product == product);
            if (_detail == null)
            {
                _detail = new SVM_Inventory_Detail();
                decimal factoryprice = 0, price = 0;
                PDT_ProductPriceBLL.GetPriceByClientAndType((int)ViewState["ClientID"], product, 2, out factoryprice, out price);
                _detail.FactoryPrice = factoryprice;
                _detail.Product      = pdt.ID;
                _detail.Quantity     = quantity;
                _detail.InventoryID  = (int)ViewState["InventoryID"];
                bll.AddDetail(_detail);
            }
            else
            {
                _detail.Quantity = quantity;
                bll.UpdateDetail(_detail);
            }

            BindGrid();
        }
    }
    protected void Save()
    {
        SVM_InventoryBLL bll = new SVM_InventoryBLL((int)ViewState["InventoryID"]);
        DropDownList ddl_Month = (DropDownList)UC_DetailView1.FindControl("SVM_Inventory_AccountMonth");
        bll.Model.InventoryDate = DateTime.Now.Date;
        bll.Model.AccountMonth = int.Parse(ddl_Month.SelectedValue);
        bll.Model["SubmitFlag"] = "2";
        bll.Update();
        foreach (GridViewRow gr in gv_List.Rows)
        {
            int id = (int)gv_List.DataKeys[gr.RowIndex][0];
            SVM_Inventory_Detail item = bll.GetDetailModel(id);

            item.Quantity = int.Parse(((TextBox)gr.FindControl("tbx_Quantity1")).Text) * new PDT_ProductBLL(item.Product).Model.ConvertFactor +
                int.Parse(((TextBox)gr.FindControl("tbx_Quantity2")).Text);
            item.Remark = ((TextBox)gr.FindControl("tbx_Remark")).Text;

            bll.UpdateDetail(item);
        }
    }