internal int InsertBackToBack(List <LC_BackToBack_Temp> _LC_BackToBack)
 {
     using (var _Context = new ERPSSL_LCEntities())
     {
         foreach (LC_BackToBack_Temp aitem in _LC_BackToBack)
         {
             LC_BackToBack_Temp planning = new LC_BackToBack_Temp();
             planning.POOrderNo         = aitem.POOrderNo;
             planning.Barcode           = aitem.Barcode;
             planning.ProductId         = aitem.ProductId;
             planning.ProductName       = aitem.ProductName;
             planning.StyleSize         = aitem.StyleSize;
             planning.Season            = aitem.Season;
             planning.Brand             = aitem.Brand;
             planning.OCode             = aitem.OCode;
             planning.CreateUser        = aitem.CreateUser;
             planning.CPU               = aitem.CPU;
             planning.ReqQty            = aitem.ReqQty;
             planning.BBLCAutoId        = aitem.BBLCAutoId;
             planning.Style             = aitem.Style;
             planning.MasterLC          = aitem.MasterLC;
             planning.PI                = aitem.PI;
             planning.Unit              = aitem.Unit;
             planning.PIDate            = aitem.PIDate;
             planning.B2BLCNo           = aitem.B2BLCNo;
             planning.ExpireDate        = aitem.ExpireDate;
             planning.BBLCDate          = aitem.BBLCDate;
             planning.ProductGroupId    = aitem.ProductGroupId;
             planning.BDTRate           = aitem.BDTRate;
             planning.BDTValue          = aitem.BDTValue;
             planning.USDRate           = aitem.USDRate;
             planning.USDValue          = aitem.USDValue;
             planning.BayerType         = aitem.BayerType;
             planning.SightDaysInterest = aitem.SightDaysInterest;
             planning.BBLCShipmentDate  = aitem.BBLCShipmentDate;
             planning.SupplierId        = aitem.SupplierId;
             planning.Article           = aitem.Article;
             _Context.LC_BackToBack_Temp.AddObject(planning);
             _Context.SaveChanges();
         }
         return(1);
     }
 }
Beispiel #2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                LC_BackToBack             LcBack         = new LC_BackToBack();
                List <LC_BackToBack_Temp> _LC_BackToBack = new List <LC_BackToBack_Temp>();
                if (txtPIDate.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Input PI Date !')", true);
                    return;
                }
                if (txtBBLCDate.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Input BBLC Date !')", true);
                    return;
                }


                foreach (GridViewRow gvRow in grvOrderSheetEntry.Rows)
                {
                    CheckBox rowChkBox = ((CheckBox)gvRow.FindControl("rowLevelCheckBox"));

                    LC_BackToBack_Temp _orderPlanning = new LC_BackToBack_Temp();

                    if (rowChkBox.Checked == true)
                    {
                        Label   lblProductId   = ((Label)gvRow.FindControl("lblProductId"));
                        Label   lblCpu         = ((Label)gvRow.FindControl("lblCpu"));
                        Label   lblBalanceQty  = ((Label)gvRow.FindControl("lblBalanceQty"));
                        Label   lblProductName = ((Label)gvRow.FindControl("lblProductName"));
                        Label   lblUnitName    = ((Label)gvRow.FindControl("lblUnitName"));
                        Label   lblStyleSize   = ((Label)gvRow.FindControl("lblStyleSize"));
                        Label   lblBrand       = ((Label)gvRow.FindControl("lblBrand"));
                        TextBox txtQty         = ((TextBox)gvRow.FindControl("txtQty"));
                        TextBox txtUSDRate     = ((TextBox)gvRow.FindControl("txtUSDRate"));
                        // TextBox txtBDTRate = ((TextBox)gvRow.FindControl("txtBDTRate"));
                        Label lblValue = ((Label)gvRow.FindControl("lblValue"));
                        // Label lblBDTValue = ((Label)gvRow.FindControl("lblBDTValue"));
                        if (txtUSDRate.Text == "")
                        {
                            _orderPlanning.USDRate = 0;
                        }
                        else
                        {
                            _orderPlanning.USDRate  = Convert.ToDecimal(txtUSDRate.Text.ToString());
                            _orderPlanning.USDValue = Convert.ToDecimal(lblValue.Text.ToString());
                        }
                        //if (txtBDTRate.Text == "")
                        //{
                        //    _orderPlanning.BDTRate = 0;
                        //    _orderPlanning.BDTValue = 0;
                        //}
                        //else
                        //{
                        //    _orderPlanning.BDTRate = Convert.ToDecimal(txtBDTRate.Text.ToString());
                        //    _orderPlanning.BDTValue = Convert.ToDecimal(lblBDTValue.Text.ToString());
                        //}


                        if (txtQty.Text == "")
                        {
                            _orderPlanning.ReqQty = 0;
                        }
                        else
                        {
                            _orderPlanning.ReqQty = Convert.ToDouble(txtQty.Text.ToString());
                        }
                        if (lblCpu.Text == "")
                        {
                            _orderPlanning.CPU = 0;
                        }
                        else
                        {
                            _orderPlanning.CPU = Convert.ToDecimal(lblCpu.Text.ToString());
                        }
                        if (rdbForeign.Checked == true)
                        {
                            _orderPlanning.BayerType = rdbForeign.Text;
                        }
                        else
                        {
                            _orderPlanning.BayerType = rdbLocal.Text;
                        }
                        _orderPlanning.BBLCDate          = Convert.ToDateTime(txtBBLCDate.Text);
                        _orderPlanning.ExpireDate        = Convert.ToDateTime(txtExpireDate.Text);
                        _orderPlanning.BBLCAutoId        = txtAutoChallanId.Text;
                        _orderPlanning.BBLCShipmentDate  = Convert.ToDateTime(txtBBLCDate.Text);
                        _orderPlanning.SightDaysInterest = txtSigntDayInterest.Text;
                        _orderPlanning.ProductId         = Convert.ToInt32(lblProductId.Text.ToString());
                        _orderPlanning.Barcode           = lblProductId.Text.ToString();
                        _orderPlanning.ProductName       = lblProductName.Text.ToString();
                        _orderPlanning.Brand             = lblBrand.Text.ToString();
                        _orderPlanning.StyleSize         = lblStyleSize.Text.ToString();
                        _orderPlanning.Unit           = lblUnitName.Text.ToString();
                        _orderPlanning.OCode          = ((SessionUser)Session["SessionUser"]).OCode;
                        _orderPlanning.EditDate       = DateTime.Now;
                        _orderPlanning.CreateUser     = ((SessionUser)Session["SessionUser"]).UserId;
                        _orderPlanning.Season         = ddlSeason.SelectedItem.Text;
                        _orderPlanning.POOrderNo      = ddlPoOrder.SelectedItem.Text;
                        _orderPlanning.Style          = ddlStyle.SelectedItem.Text;
                        _orderPlanning.Article        = ddlArticle.SelectedItem.Text;
                        _orderPlanning.MasterLC       = txtMasterLC.Text;
                        _orderPlanning.B2BLCNo        = txtB2BLCNo.Text;
                        _orderPlanning.PI             = txtPI.Text;
                        _orderPlanning.PIDate         = Convert.ToDateTime(txtPIDate.Text);
                        _orderPlanning.ProductGroupId = Convert.ToInt32(drpItemCategory.SelectedValue);
                        _orderPlanning.SupplierId     = ddlSupplier.SelectedValue.ToString();
                        _LC_BackToBack.Add(_orderPlanning);
                    }
                }

                if (_LC_BackToBack.Count > 0)
                {
                    int result = _orderSheetbll.InsertBackToBack(_LC_BackToBack);
                    if (result == 1)
                    {
                        Clear();
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Saved Successfully')", true);
                        GridBackTobBackLoad();
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('No Employee selected in the list!')", true);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }