internal int UpdateLCOrderPlanning(List <LC_Order_Planning_Temp> _LC_Order_Planning) { using (var _Context = new ERPSSL_LCEntities()) { foreach (LC_Order_Planning_Temp aitem in _LC_Order_Planning) { LC_Order_Planning_Temp planning = new LC_Order_Planning_Temp(); planning.OrderNo = aitem.OrderNo; 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.Qty = aitem.Qty; planning.UnitName = aitem.UnitName; planning.OrderPlanningAutoId = aitem.OrderPlanningAutoId; planning.Style = aitem.Style; planning.TotalQty = aitem.TotalQty; planning.USDRate = aitem.USDRate; planning.USDValue = aitem.USDValue; planning.BDTRate = aitem.BDTRate; planning.BDTValue = aitem.BDTValue; planning.Article = aitem.Article; _Context.LC_Order_Planning_Temp.AddObject(planning); _Context.SaveChanges(); } return(1); } }
protected void btnSubmit_Click(object sender, EventArgs e) { try { LC_Order_Planning_Temp orderPlanning = new LC_Order_Planning_Temp(); List <LC_Order_Planning_Temp> _LC_Order_Planning = new List <LC_Order_Planning_Temp>(); foreach (GridViewRow gvRow in grvOrderSheetEntry.Rows) { CheckBox rowChkBox = ((CheckBox)gvRow.FindControl("rowLevelCheckBox")); LC_Order_Planning_Temp _orderPlanning = new LC_Order_Planning_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.Qty = 0; } else { _orderPlanning.Qty = Convert.ToDouble(txtQty.Text.ToString()); } if (lblCpu.Text == "") { _orderPlanning.CPU = 0; } else { _orderPlanning.CPU = Convert.ToDecimal(lblCpu.Text.ToString()); } if (lblCpu.Text != "" && txtQty.Text != "") { _orderPlanning.TotalQty = Convert.ToDecimal(txtQty.Text.ToString()) * Convert.ToDecimal(lblCpu.Text.ToString()); } else { _orderPlanning.TotalQty = 0; } _orderPlanning.OrderPlanningAutoId = txtAutoOrderId.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.UnitName = 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.OrderNo = ddlPoOrder.SelectedItem.Text; _orderPlanning.Style = ddlStyle.SelectedItem.Text; _orderPlanning.Article = ddlArticle.SelectedItem.Text; _LC_Order_Planning.Add(_orderPlanning); } } if (_LC_Order_Planning.Count > 0) { //string type = drpEntryType.SelectedValue.ToString(); int result = _orderSheetbll.UpdateLCOrderPlanning(_LC_Order_Planning); if (result == 1) { Clear(); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Saved Successfully')", true); var result1 = _orderSheetbll.GetLCOrderPlanningTemp(ddlSeason.SelectedItem.Text.ToString()); if (result1.Count > 0) { gridOrderPlanning.DataSource = result1; gridOrderPlanning.DataBind(); } else { gridOrderPlanning.DataSource = null; gridOrderPlanning.DataBind(); } } } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('No Employee selected in the list!')", true); } } catch (Exception ex) { throw ex; } }