protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                DateTime?NullDate   = null;
                int      StyleId    = 0;
                int      BuyDept    = 0;
                int      StyleCatId = 0;
                if (txtPOrder.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Enter Order No!')", true);
                    return;
                }
                if (ddlStyle.SelectedItem.Text == "--Select Style--" && txtStyle.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select Style!')", true);
                    return;
                }
                if (ddlSeason.SelectedItem.Text == "--Select Season--" && txtSeason.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select Season!')", true);
                    return;
                }
                if (ddlBuyer.SelectedItem.Text == "--Select Buyer--")
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select Buyer!')", true);
                    return;
                }



                LC_Season aLC_Season = new LC_Season();

                if (ChkSeason.Checked == true)
                {
                    aLC_Season.Season_Name = txtSeason.Text;
                    aLC_Season.CreateDate  = DateTime.Today;
                    aLC_Season.CreateUser  = ((SessionUser)Session["SessionUser"]).UserId;
                    aLC_Season.OCode       = ((SessionUser)Session["SessionUser"]).OCode;

                    var result = _orderSheetbll.AddSeason(aLC_Season);
                }
                LC_BuyerDepartment _LC_BuyerDepartment = new LC_BuyerDepartment();

                if (chkBuyerDepartment.Checked == true)
                {
                    int count = (from Bd in _Context.LC_BuyerDepartment
                                 where Bd.BuyerDepartment_Name == _LC_BuyerDepartment.BuyerDepartment_Name
                                 select Bd.BuyerDepartment_Name).Count();
                    if (count > 0)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Buyer Department already Exist')", true);
                        return;
                    }
                    _LC_BuyerDepartment.BuyerDepartment_Name = txtBuyerDepartment.Text;
                    _LC_BuyerDepartment.Create_Date          = DateTime.Today;
                    _LC_BuyerDepartment.Create_User          = ((SessionUser)Session["SessionUser"]).UserId;
                    _LC_BuyerDepartment.OCode = ((SessionUser)Session["SessionUser"]).OCode;

                    int result = _orderSheetbll.AddBuyerDepartment(_LC_BuyerDepartment);
                    BuyDept = result;
                }

                LC_StyleCategor _LC_StyleCategor = new LC_StyleCategor();

                if (chkCategory.Checked == true)
                {
                    int count = (from Bd in _Context.LC_StyleCategor
                                 where Bd.Style_Category_Name == _LC_StyleCategor.Style_Category_Name
                                 select Bd.Style_Category_Name).Count();
                    if (count > 0)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Style Category already Exist')", true);
                        return;
                    }
                    _LC_StyleCategor.Style_Category_Name = txtCategory.Text;
                    _LC_StyleCategor.CreateDate          = DateTime.Today;
                    _LC_StyleCategor.CreateUser          = ((SessionUser)Session["SessionUser"]).UserId;
                    _LC_StyleCategor.OCode = ((SessionUser)Session["SessionUser"]).OCode;

                    int result = _orderSheetbll.AddStyleCategor(_LC_StyleCategor);
                    StyleCatId = result;
                }

                LC_OrderEntry orderEntry = new LC_OrderEntry();


                orderEntry.OrderReceiveDate = Convert.ToDateTime(txtOrderConfirmationDate.Text);


                if (ChkSeason.Checked == true)
                {
                    orderEntry.SeasonId = aLC_Season.Season_Id;
                    hidSeasonID.Value   = orderEntry.Season;
                }
                else
                {
                    orderEntry.SeasonId = Convert.ToInt32(ddlSeason.SelectedValue);
                    hidSeasonID.Value   = orderEntry.Season;
                }
                if (chkBuyerDepartment.Checked == true)
                {
                    orderEntry.Buyer_DepartmentId = BuyDept;
                }
                else
                {
                    orderEntry.Buyer_DepartmentId = Convert.ToInt32(ddlBuyerDepartment.SelectedValue);
                }

                orderEntry.OrderQuantity = txtOrderQty.Text;
                //orderEntry.FobQty = Convert.ToDouble(txtFob.Text);
                // orderEntry.UnitPrice = Convert.ToDecimal(txtFob.Text);
                if (chkStleWise.Checked == true)
                {
                    if (chkNewstyle.Checked == true)
                    {
                        LC_Style aLC_Style = new LC_Style();

                        aLC_Style.StyleName  = txtStyle.Text;
                        aLC_Style.CreateDate = DateTime.Today;
                        aLC_Style.CreateUser = ((SessionUser)Session["SessionUser"]).UserId;
                        aLC_Style.OCode      = ((SessionUser)Session["SessionUser"]).OCode;

                        var result = _Buyerbll.AddStyle(aLC_Style);
                        StyleId = result;
                    }

                    if (chkNewstyle.Checked == true)
                    {
                        orderEntry.StyleId = StyleId;
                    }
                    else
                    {
                        orderEntry.StyleId = Convert.ToInt32(ddlStyle.SelectedValue);
                    }
                    orderEntry.OrderNo = txtPOrder.Text;
                }
                else
                {
                    if (chkNewstyle2.Checked == true)
                    {
                        LC_Style aLC_Style = new LC_Style();

                        aLC_Style.StyleName  = txtStyle2.Text;
                        aLC_Style.CreateDate = DateTime.Today;
                        aLC_Style.CreateUser = ((SessionUser)Session["SessionUser"]).UserId;
                        aLC_Style.OCode      = ((SessionUser)Session["SessionUser"]).OCode;

                        var result = _Buyerbll.AddStyle(aLC_Style);
                        StyleId = result;
                    }

                    if (chkNewstyle.Checked == true)
                    {
                        orderEntry.StyleId = StyleId;
                    }
                    else
                    {
                        orderEntry.StyleId = Convert.ToInt32(ddlStyle2.SelectedValue);
                    }
                    orderEntry.OrderNo = txtPOrder2.Text;
                    // orderEntry.OrderNo = txtPOrder2.Text;
                }

                orderEntry.Style_Description = txtCustomerStyle.Text;

                orderEntry.EID = ddlMerchandiserName.SelectedValue;

                if (chkCategory.Checked == true)
                {
                    orderEntry.Style_Category_Id = StyleCatId;
                }
                else
                {
                    orderEntry.Style_Category_Id = Convert.ToInt32(ddlCategory.SelectedValue);
                }
                orderEntry.Currency = ddlCurrency.SelectedItem.Text;

                orderEntry.Unit_Id    = Convert.ToInt32(ddlUnit.SelectedValue);
                orderEntry.Office_ID  = Convert.ToInt32(ddlTTOffice.SelectedValue);
                orderEntry.Buyer_Name = ddlBuyer.SelectedValue;


                orderEntry.FOB_Port = txtFOBPort.Text;
                if (txtShipmentDate.Text == "")
                {
                    orderEntry.ShipmentDate = NullDate;
                }
                else
                {
                    orderEntry.ShipmentDate = Convert.ToDateTime(txtShipmentDate.Text);
                }
                if (txtOrderConfirmationDate.Text == "")
                {
                    orderEntry.LC_Reveived_Date = NullDate;
                }
                else
                {
                    orderEntry.LC_Reveived_Date = Convert.ToDateTime(txtOrderConfirmationDate.Text);
                }
                orderEntry.Shipment_Mode = ddlShipmentMode.SelectedItem.Text;

                orderEntry.Create_Date = DateTime.Today;
                orderEntry.Create_User = ((SessionUser)Session["SessionUser"]).UserId;
                orderEntry.OCODE       = ((SessionUser)Session["SessionUser"]).OCode;

                if (btnSubmit.Text == "Add")
                {
                    int count = (from orderentry in _Context.LC_OrderEntry
                                 where orderentry.OrderNo == orderEntry.OrderNo
                                 select orderentry.OrderNo).Count();
                    if (count > 0)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('PO Number already Exist')", true);
                    }
                    else
                    {
                        var result = masterBLL.InsertOrderEntry(orderEntry);
                        if (result == 1)
                        {
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Saved Successfully')", true);
                        }
                    }
                }
                else
                {
                    int orderid = Convert.ToInt32(hidorderid.Value);
                    var result  = masterBLL.UpdateOrderEntry(orderEntry, orderid);
                    if (result == 1)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Updated Successfully')", true);
                    }
                }
                LoadLCOrderGrid();
                Clear();
                ShowDiv.Visible  = false;
                ShowGrid.Visible = true;
                //AddOrder.Visible = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                int StyleId = 0;
                if (ddlStyle.SelectedItem.Text == "--Select Style--" && txtStyle.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select Style')", true);
                    return;
                }
                if (chkNewstyle.Checked == true)
                {
                    LC_Style aLC_Style = new LC_Style();

                    aLC_Style.StyleName  = txtStyle.Text;
                    aLC_Style.CreateDate = DateTime.Today;
                    aLC_Style.CreateUser = ((SessionUser)Session["SessionUser"]).UserId;
                    aLC_Style.OCode      = ((SessionUser)Session["SessionUser"]).OCode;

                    var result = _Buyerbll.AddStyle(aLC_Style);
                    StyleId = result;
                }

                int SesonId = 0;
                if (ddlSeason.SelectedItem.Text == "---Select One---" && txtSeason.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select Season')", true);
                    return;
                }
                if (chkSeason.Checked == true)
                {
                    LC_Season _LC_Season = new LC_Season();
                    _LC_Season.Season_Name = txtSeason.Text;
                    _LC_Season.CreateUser  = ((SessionUser)Session["SessionUser"]).UserId;
                    _LC_Season.CreateDate  = DateTime.Now;
                    _LC_Season.OCode       = ((SessionUser)Session["SessionUser"]).OCode;

                    int result = masterBLL.SaveLC_Season(_LC_Season);
                    SesonId = result;
                }

                LC_OrderEntry orderEntry = new LC_OrderEntry();

                //string seasonname = ddlSeason.SelectedItem.ToString();
                //string[] values = seasonname.Split('-');
                orderEntry.OrderReceiveDate = Convert.ToDateTime(txtOrderReceivedDate.Text);
                //orderEntry.Season = values[0].ToString();
                orderEntry.Buyer_Department   = txtBuyerDepartment.Text;
                orderEntry.Supplier_No        = txtSupplierNo.Text;
                orderEntry.OrderNo            = txtOrder.Text;
                orderEntry.LCNo               = lblLCNo.Text;
                orderEntry.Article            = txtArticle.Text;
                orderEntry.ColorSpecification = txtColor.Text;
                orderEntry.OrderQuantity      = txtOrderQty.Text;
                orderEntry.FobQty             = Convert.ToDouble(txtFob.Text);

                if (chkNewstyle.Checked == true)
                {
                    orderEntry.StyleId = StyleId;
                }
                else
                {
                    orderEntry.StyleId = Convert.ToInt32(ddlStyle.SelectedValue);
                }

                if (chkSeason.Checked == true)
                {
                    orderEntry.SeasonId = SesonId;
                }
                else
                {
                    orderEntry.SeasonId = Convert.ToInt32(ddlSeason.SelectedValue);
                }

                orderEntry.Size          = txtsize.Text;
                orderEntry.Shipment_Mode = ddlShipmentMode.SelectedValue;
                orderEntry.ShipmentDate  = Convert.ToDateTime(txtDate.Text);

                orderEntry.FiberContent1 = txtFiberContent1.Text;
                orderEntry.FiberContent2 = txtFiberContent2.Text;

                orderEntry.Create_Date = DateTime.Today;
                orderEntry.Create_User = ((SessionUser)Session["SessionUser"]).UserId;
                orderEntry.OCODE       = ((SessionUser)Session["SessionUser"]).OCode;
                orderEntry.TotalQty    = Convert.ToDouble(txtValue.Text);

                if (btnSubmit.Text == "Add")
                {
                    var result = masterBLL.InsertOrderEntry(orderEntry);
                    if (result == 1)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Saved Successfully')", true);
                    }
                }

                else
                {
                    int orderid = Convert.ToInt32(hidorderid.Value);
                    var result  = masterBLL.UpdateOrderEntry(orderEntry, orderid);
                    if (result == 1)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Updated Successfully')", true);
                    }
                }

                LoadGrid(lblLCNo.Text.ToString());
                Clear();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }