internal LC_PurchaseOrder GetPurchaseOrderById(int Id)
        {
            LC_PurchaseOrder _PurschaseOrder = _Context.LC_PurchaseOrder
                                               .Where(po => po.LC_PurchaseOrder_Id == Id).FirstOrDefault();

            return(_PurschaseOrder);
        }
 private bool IsExist(int Id)
 {
     try
     {
         bool             status        = true;
         LC_PurchaseOrder purchaseorder = aLC_RequisitionBLL.GetPurchaseOrderById(Id);
         if (purchaseorder == null)
         {
             status = false;
         }
         return(status);
     }
     catch (Exception)
     {
         throw;
     }
 }
        private bool IsExist(LC_PurchaseOrder purchaseorder)
        {
            try
            {
                bool status    = true;
                int  productID = Convert.ToInt16(purchaseorder.ProductId);
                ERPSSL.LC.DAL.Inv_Product _invProduct = aLC_RequisitionBLL.GetProductByProductID(productID);

                if (_invProduct == null)
                {
                    status = false;
                }
                return(status);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #4
0
        protected void btnProcess_Click(object sender, EventArgs e)
        {
            List <LC_PurchaseOrder> lstLC_PurchaseOrder = new List <LC_PurchaseOrder>();

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

                if (rowChkBox.Checked == true)
                {
                    LC_PurchaseOrder aLC_PurchaseOrder = new LC_PurchaseOrder();

                    TextBox txtReqQty    = ((TextBox)gvRow.FindControl("txtApproveQty"));
                    Label   lblProductId = ((Label)gvRow.FindControl("lblProductId"));

                    aLC_PurchaseOrder.LC_PO_No        = txtPONo.Text;
                    aLC_PurchaseOrder.PO_ApprovedDate = Convert.ToDateTime(txtDate.Text);
                    aLC_PurchaseOrder.ProductId       = Convert.ToInt32(lblProductId.Text);

                    if (txtReqQty.Text == "")
                    {
                        aLC_PurchaseOrder.PO_Approved_Qty = 0;
                    }
                    else
                    {
                        aLC_PurchaseOrder.PO_Approved_Qty = Convert.ToDouble(txtReqQty.Text);
                    }

                    lstLC_PurchaseOrder.Add(aLC_PurchaseOrder);
                }
            }

            var result = aLC_RequisitionBLL.UpdatePOApprovedStatus(lstLC_PurchaseOrder);

            if (result == 1)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Approved Successfully')", true);
                txtDate.Text = "";
                gridApprovalDetails.DataSource = null;
                gridApprovalDetails.DataBind();
            }
        }
        protected void btnTransfer_Click(object sender, EventArgs e)
        {
            try
            {
                bool status      = true;
                bool CheckStatus = false;

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

                    if (rowChkBox.Checked == true)
                    {
                        CheckStatus = true;
                    }
                }

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

                        if (rowChkBox.Checked == true)
                        {
                            TextBox txtbxReceive = (TextBox)gvRow.FindControl("txtbxReceiveAmount");
                            if (txtbxReceive.Text != "")
                            {
                                //Label lblLastRceceive = ((Label)gvRow.FindControl("lblLastReceive"));
                                //double lastReceive = Convert.ToDouble(lblLastRceceive.Text);

                                double ReceiveQty = Convert.ToDouble(txtbxReceive.Text);

                                Label  lblOrderQty = ((Label)gvRow.FindControl("lblOrderQty"));
                                double Poqty       = Convert.ToDouble(lblOrderQty.Text);

                                if (ReceiveQty == 0)
                                {
                                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Check Quantity!')", true);
                                    status = false;
                                    break;
                                }
                                //else if (ReceiveQty + lastReceive > Poqty)
                                //{
                                //    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Check Quantity!')", true);
                                //    status = false;
                                //    break;
                                //}
                            }
                            else
                            {
                                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Input Receive Qty!')", true);
                                status = false;
                                break;
                            }
                        }
                    }

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

                            if (rowChkBox.Checked == true)
                            {
                                Label lbl = ((Label)gvRow.FindControl("lblID"));

                                Label lblPO = ((Label)gvRow.FindControl("lblPONo"));

                                Label lblOrderQty     = ((Label)gvRow.FindControl("lblOrderQty"));
                                Label lblStyleAndSize = ((Label)gvRow.FindControl("lblStyleAndSize"));


                                TextBox txtbxReceive = (TextBox)gvRow.FindControl("txtbxReceiveAmount");
                                double  ReceiveQty   = Convert.ToDouble(txtbxReceive.Text);

                                DropDownList ddlStoreName = (DropDownList)gvRow.FindControl("ddlStoreName");

                                //Label lblLastRceceive = ((Label)gvRow.FindControl("lblLastReceive"));
                                //double lastReceive = Convert.ToDouble(lblLastRceceive.Text);
                                TextBox txtRemarks  = (TextBox)gvRow.FindControl("txtRemarks");
                                string  ItemsRemark = txtRemarks.Text;

                                //for new product

                                int Id = Convert.ToInt16(lbl.Text);
                                //if (IsExist(Id))
                                //{
                                //    ProductBLL _productBll = new ProductBLL();
                                //    LC_PurchaseOrder purchaseorder = aLC_RequisitionBLL.GetPurchaseOrderById(Id);

                                //if (!IsExist(purchaseorder))
                                //{
                                //    Inv_Product _productObj = new Inv_Product();
                                //    _productObj.ProductName = purchaseorder.ProductName;
                                //    _productObj.StyleAndSize = purchaseorder.StyleAndSize;
                                //    _productObj.ReOrderQty = 0;
                                //    _productObj.Price = purchaseorder.Price;
                                //    _productObj.Brand = "HB";
                                //    _productObj.GroupId = purchaseorder.GroupId;
                                //    _productObj.UnitId = purchaseorder.UnitId;
                                //    _productObj.UnitName = purchaseorder.UnitName;
                                //    _productObj.EditDate = DateTime.Now;
                                //    _productObj.EditUser = ((SessionUser)Session["SessionUser"]).UserId;
                                //    _productObj.OCode = ((SessionUser)Session["SessionUser"]).OCode.ToString();
                                //    int productId = _productBll.InsertProductAndGetID(_productObj);
                                //    if (productId > 0)
                                //    {
                                //        _purchaseOrderbll.UpdatePurchaseOrder(Id, productId);

                                //    }
                                //}
                                //}

                                string CType = "CENTRAL";
                                if (CType == "CENTRAL")
                                {
                                    LC_PurchaseOrder purchaseorder = aLC_RequisitionBLL.GetPurchaseOrderById(Id);

                                    //if (purchaseorder.ItemType == "New Item")
                                    //{
                                    //    string productName = purchaseorder.ProductName.ToString();
                                    //    string StyleandSize = purchaseorder.StyleAndSize.ToString();
                                    //    Inv_Product _invProduct = _purchaseOrderbll.GetProductByProductNameandStyle(productName, StyleandSize);
                                    //    //   Inv_Product _invProduct = _purchaseOrderbll.GetProductByProductId(Convert.ToInt32(purchaseorder.BarCode));
                                    //    string id = Convert.ToString(Id);
                                    //    string ChalanNo = GetChalanNo(id);
                                    //    Inv_BuyCentral buyCentral = buyCentralBll.GetBuyCentralByCompanyAndBarcode(hdnBarCode.Value, ddlCompanyCode.SelectedValue);
                                    //    if (buyCentral == null)
                                    //    { // Insert New
                                    //        Inv_BuyCentral newBuyCentral = new Inv_BuyCentral();
                                    //        newBuyCentral.ChallanNo = ChalanNo;
                                    //        //newBuyCentral.CompanyId = Convert.ToInt32(ddlCompanyCode.SelectedValue);
                                    //        newBuyCentral.CompanyCode = HiddenCompanyCode.Value;
                                    //        newBuyCentral.CompanyName = HiddenCompanyName.Value;
                                    //        newBuyCentral.BarCode = _invProduct.ProductId.ToString();
                                    //        newBuyCentral.ProductId = _invProduct.ProductId;
                                    //        newBuyCentral.ProductGroup = _invProduct.GroupId;
                                    //        newBuyCentral.ProductName = _invProduct.ProductName;
                                    //        newBuyCentral.Brand = _invProduct.Brand;
                                    //        newBuyCentral.Item_Remarks = ItemsRemark;
                                    //        //-------------------------------------------------------------
                                    //        //if (ddlProject.SelectedValue != "0")
                                    //        //{
                                    //        //    newBuyCentral.Project_Code = ddlProject.SelectedValue;
                                    //        //}

                                    //        if (ddlStoreName.SelectedValue != "0")
                                    //        {
                                    //            newBuyCentral.Store_Code = ddlStoreName.SelectedValue.ToString();
                                    //        }

                                    //        //if (ddlStoreUnit.SelectedValue != "0")
                                    //        //{
                                    //        //    newBuyCentral.Store_Unit_Id = Convert.ToInt16(ddlStoreUnit.SelectedValue);
                                    //        //}

                                    //        //DropDownList drpumCheck = (DropDownList)gvRow.FindControl("drpumCkeck");
                                    //        //DropDownList drpRecieptCondition = (DropDownList)gvRow.FindControl("ddlRecieptCondition");

                                    //        newBuyCentral.StyleSize = _invProduct.StyleAndSize;
                                    //        //newBuyCentral.FloorName = rchallan.FloorName;
                                    //        newBuyCentral.UnitName = _invProduct.UnitName;
                                    //        newBuyCentral.ReceiveQuantity = ReceiveQty;// Convert.ToInt32(purchaseorder.OrderedQty);
                                    //        //newBuyCentral.CPU = rchallan.CPU;
                                    //        //newBuyCentral.RPU = rchallan.RPU;
                                    //        //newBuyCentral.ExpireDate = rchallan.ExpireDate;
                                    //        newBuyCentral.BalanceQuanity = ReceiveQty;//Convert.ToInt32(purchaseorder.OrderedQty);
                                    //        try
                                    //        {
                                    //            newBuyCentral.PurchaseDate = DateTime.Now;
                                    //        }
                                    //        catch
                                    //        {
                                    //            newBuyCentral.PurchaseDate = DateTime.Today;
                                    //        }

                                    //        newBuyCentral.EditDate = DateTime.Now;
                                    //        newBuyCentral.EditUser = ((SessionUser)Session["SessionUser"]).UserId;
                                    //        newBuyCentral.OCode = ((SessionUser)Session["SessionUser"]).OCode;
                                    //        buyCentralBll.Insert(newBuyCentral);
                                    //    }

                                    //    else
                                    //    {
                                    //        buyCentral.BalanceQuanity = buyCentral.BalanceQuanity + ReceiveQty;// Convert.ToInt32(purchaseorder.OrderedQty);
                                    //        //buyCentral.CPU = rchallan.CPU;
                                    //        //buyCentral.RPU = rchallan.RPU;
                                    //        //buyCentral.ExpireDate = rchallan.ExpireDate;
                                    //        buyCentral.ReceiveQuantity = buyCentral.ReceiveQuantity + ReceiveQty;// Convert.ToInt32(purchaseorder.OrderedQty);
                                    //        buyCentralBll.Update(buyCentral, Convert.ToInt32(buyCentral.Id));
                                    //    }
                                    //    //}
                                    //    Inv_RChallan rchallan = new Inv_RChallan();
                                    //    rchallan.ChallanNo = ChalanNo;
                                    //    rchallan.PO_No = lblPO.Text;
                                    //    rchallan.ChallanDate = DateTime.Now;
                                    //    //   rchallan.CompanyId = Convert.ToInt32(ddlCompanyCode.SelectedValue);
                                    //    rchallan.CompanyCode = HiddenCompanyCode.Value;
                                    //    rchallan.CompanyName = HiddenCompanyName.Value;
                                    //    rchallan.Barcode = hdnBarCode.Value;
                                    //    rchallan.ProductId = _invProduct.ProductId;
                                    //    rchallan.ProductGroup = _invProduct.GroupId;
                                    //    rchallan.ProductName = _invProduct.ProductName;
                                    //    rchallan.Brand = _invProduct.Brand;
                                    //    rchallan.Remarks = ItemsRemark;

                                    //    //if (ddlProject.SelectedValue != "0")
                                    //    //{

                                    //    //    rchallan.Project_Code = ddlProject.SelectedValue;
                                    //    //}

                                    //    if (ddlStoreName.SelectedValue != "0")
                                    //    {
                                    //        rchallan.Store_Code = ddlStoreName.SelectedValue.ToString();
                                    //    }
                                    //    //if (ddlStoreUnit.SelectedValue != "0")
                                    //    //{
                                    //    //    rchallan.Store_Unit_Id = Convert.ToInt16(ddlStoreUnit.SelectedValue);
                                    //    //}

                                    //    //DropDownList drpumCheck1 = (DropDownList)gvRow.FindControl("drpumCkeck");
                                    //    //DropDownList drpRecieptConditio1n = (DropDownList)gvRow.FindControl("ddlRecieptCondition");

                                    //    //if (drpumCheck1.SelectedValue != "0")
                                    //    //{
                                    //    //    rchallan.Unit_Cheked = drpumCheck1.SelectedItem.Text;
                                    //    //}

                                    //    //if (drpRecieptConditio1n.SelectedValue != "0")
                                    //    //{
                                    //    //    rchallan.Reciept_Condition = drpRecieptConditio1n.SelectedItem.Text;
                                    //    //}

                                    //    //rchallan.StyleSize = rchallan.StyleSize;
                                    //    //rchallan.FloorName = rchallan.FloorName;
                                    //    rchallan.UnitName = _invProduct.UnitName;
                                    //    rchallan.ReceiveQuantity = ReceiveQty;// Convert.ToInt32(purchaseorder.OrderedQty);
                                    //    //rchallan.CPU = rchallan.CPU;
                                    //    //rchallan.RPU = rchallan.RPU;
                                    //    //rchallan.ExpireDate = rchallan.ExpireDate;
                                    //    rchallan.BalanceQty = ReceiveQty;// Convert.ToInt32(purchaseorder.OrderedQty);
                                    //    try
                                    //    {
                                    //        rchallan.PurchaseDate = DateTime.Today;
                                    //    }
                                    //    catch
                                    //    {
                                    //        rchallan.PurchaseDate = DateTime.Today;
                                    //    }

                                    //    rchallan.EditDate = DateTime.Now;
                                    //    rchallan.EditUser = ((SessionUser)Session["SessionUser"]).UserId;
                                    //    rchallan.Ocode = ((SessionUser)Session["SessionUser"]).OCode;
                                    //    rChallanBll.Insert(rchallan);
                                    //    //  string Po = lblPO.Text;

                                    //    if (lastReceive == 0 && ReceiveQty == Convert.ToDouble(lblOrderQty.Text))
                                    //    {

                                    //        PurchaseOrderBll.PurchaseDone(id);
                                    //        // PurchaseOrderBll.UpdateLastQty(id, ReceiveQty);
                                    //    }
                                    //    else if ((Convert.ToInt16(lblOrderQty.Text) == ReceiveQty + Convert.ToInt16(lastReceive)))
                                    //    {

                                    //        PurchaseOrderBll.UpdateLastQty(id, ReceiveQty);
                                    //        PurchaseOrderBll.PurchaseDone(id);
                                    //        // PurchaseOrderBll.UpdateLastQty(id, ReceiveQty);
                                    //    }
                                    //    else
                                    //    {
                                    //        ReceiveQty = ReceiveQty + Convert.ToDouble(lastReceive);
                                    //        PurchaseOrderBll.UpdateLastQty(id, ReceiveQty);
                                    //    }

                                    //    // lblMessage.Text = "<font color='green'>Purchase information posted successfully</font>";
                                    //    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Purchase information posted successfully')", true);
                                    //    SetGriview();
                                    //}
                                    //else
                                    //{

                                    int productId = Convert.ToInt32(purchaseorder.ProductId);
                                    ERPSSL.LC.DAL.Inv_Product _invProduct = aLC_RequisitionBLL.GetProductByProductID(productId);

                                    //   Inv_Product _invProduct = _purchaseOrderbll.GetProductByProductId(Convert.ToInt32(purchaseorder.BarCode));

                                    string id = Convert.ToString(Id);

                                    string ChalanNo = rChallanBll.GetNewRChalanNo(purchaseorder.SupplierCode, DateTime.Now);
                                    //string ChalanNo = GetChalanNo(id);

                                    //ERPSSL.INV.DAL.Inv_BuyCentral buyCentral = buyCentralBll.GetBuyCentralByCompanyAndBarcode(productId, ddlCompanyCode.SelectedValue);

                                    ERPSSL.INV.DAL.Inv_BuyCentral buyCentral = buyCentralBll.GetBuyCentralByCompanyAndBarcode(productId.ToString(), ddlCompanyCode.SelectedValue);

                                    if (buyCentral == null)
                                    { // Insert New
                                        ERPSSL.INV.DAL.Inv_BuyCentral newBuyCentral = new ERPSSL.INV.DAL.Inv_BuyCentral();
                                        newBuyCentral.ChallanNo = ChalanNo;
                                        //newBuyCentral.CompanyId = Convert.ToInt32(ddlCompanyCode.SelectedValue);
                                        newBuyCentral.CompanyCode  = HiddenCompanyCode.Value;
                                        newBuyCentral.CompanyName  = HiddenCompanyName.Value;
                                        newBuyCentral.BarCode      = _invProduct.ProductId.ToString();
                                        newBuyCentral.ProductId    = _invProduct.ProductId;
                                        newBuyCentral.ProductGroup = _invProduct.GroupId;
                                        newBuyCentral.ProductName  = _invProduct.ProductName;
                                        newBuyCentral.Brand        = _invProduct.Brand;
                                        newBuyCentral.Item_Remarks = ItemsRemark;

                                        //if (ddlProject.SelectedValue != "0")
                                        //{
                                        //    newBuyCentral.Project_Code = ddlProject.SelectedValue;
                                        //}

                                        if (ddlStoreName.SelectedValue != "0")
                                        {
                                            newBuyCentral.Store_Code = ddlStoreName.SelectedValue.ToString();
                                        }

                                        //if (ddlStoreUnit.SelectedValue != "0")
                                        //{
                                        //    newBuyCentral.Store_Unit_Id = Convert.ToInt16(ddlStoreUnit.SelectedValue);
                                        //}

                                        //DropDownList drpumCheck1 = (DropDownList)gvRow.FindControl("drpumCkeck");
                                        //DropDownList drpRecieptConditio1n = (DropDownList)gvRow.FindControl("ddlRecieptCondition");

                                        newBuyCentral.StyleSize = _invProduct.StyleAndSize;
                                        //newBuyCentral.FloorName = rchallan.FloorName;
                                        newBuyCentral.UnitName        = _invProduct.UnitName;
                                        newBuyCentral.ReceiveQuantity = ReceiveQty;// Convert.ToInt32(purchaseorder.OrderedQty);
                                        //newBuyCentral.CPU = rchallan.CPU;
                                        //newBuyCentral.RPU = rchallan.RPU;
                                        //newBuyCentral.ExpireDate = rchallan.ExpireDate;
                                        newBuyCentral.BalanceQuanity = ReceiveQty;// Convert.ToInt32(purchaseorder.OrderedQty);
                                        try
                                        {
                                            newBuyCentral.PurchaseDate = DateTime.Now;
                                        }
                                        catch
                                        {
                                            newBuyCentral.PurchaseDate = DateTime.Today;
                                        }

                                        newBuyCentral.EditDate = DateTime.Now;
                                        newBuyCentral.EditUser = ((SessionUser)Session["SessionUser"]).UserId;
                                        newBuyCentral.OCode    = ((SessionUser)Session["SessionUser"]).OCode;
                                        buyCentralBll.Insert(newBuyCentral);
                                    }

                                    else
                                    {
                                        buyCentral.BalanceQuanity = buyCentral.BalanceQuanity + ReceiveQty;// Convert.ToInt32(purchaseorder.OrderedQty);
                                        //buyCentral.CPU = rchallan.CPU;
                                        //buyCentral.RPU = rchallan.RPU;
                                        //buyCentral.ExpireDate = rchallan.ExpireDate;
                                        buyCentral.ReceiveQuantity = buyCentral.ReceiveQuantity + ReceiveQty;// Convert.ToInt32(purchaseorder.OrderedQty);
                                        buyCentralBll.Update(buyCentral, Convert.ToInt32(buyCentral.Id));
                                    }
                                    //}
                                    Inv_RChallan rchallan = new Inv_RChallan();
                                    rchallan.ChallanNo   = ChalanNo;
                                    rchallan.PO_No       = lblPO.Text;
                                    rchallan.ChallanDate = DateTime.Now;
                                    //   rchallan.CompanyId = Convert.ToInt32(ddlCompanyCode.SelectedValue);
                                    rchallan.CompanyCode  = HiddenCompanyCode.Value;
                                    rchallan.CompanyName  = HiddenCompanyName.Value;
                                    rchallan.Barcode      = hdnBarCode.Value;
                                    rchallan.ProductId    = _invProduct.ProductId;
                                    rchallan.ProductGroup = _invProduct.GroupId;
                                    rchallan.ProductName  = _invProduct.ProductName;
                                    rchallan.Brand        = _invProduct.Brand;

                                    //if (ddlProject.SelectedValue != "0")
                                    //{

                                    //    rchallan.Project_Code = ddlProject.SelectedValue;
                                    //}

                                    if (ddlStoreName.SelectedValue != "0")
                                    {
                                        rchallan.Store_Code = ddlStoreName.SelectedValue.ToString();
                                    }
                                    //if (ddlStoreUnit.SelectedValue != "0")
                                    //{
                                    //    rchallan.Store_Unit_Id = Convert.ToInt16(ddlStoreUnit.SelectedValue);
                                    //}

                                    //DropDownList drpumCheck11 = (DropDownList)gvRow.FindControl("drpumCkeck");
                                    //DropDownList drpRecieptConditio11n = (DropDownList)gvRow.FindControl("ddlRecieptCondition");

                                    //if (drpumCheck11.SelectedValue != "0")
                                    //{
                                    //    rchallan.Unit_Cheked = drpumCheck11.SelectedItem.Text;
                                    //}

                                    //if (drpRecieptConditio11n.SelectedValue != "0")
                                    //{
                                    //    rchallan.Reciept_Condition = drpRecieptConditio11n.SelectedItem.Text;
                                    //}

                                    rchallan.Remarks = ItemsRemark;

                                    //rchallan.StyleSize = rchallan.StyleSize;
                                    //rchallan.FloorName = rchallan.FloorName;
                                    rchallan.UnitName        = _invProduct.UnitName;
                                    rchallan.ReceiveQuantity = ReceiveQty;// Convert.ToInt32(purchaseorder.OrderedQty);
                                    //rchallan.CPU = rchallan.CPU;
                                    //rchallan.RPU = rchallan.RPU;
                                    //rchallan.ExpireDate = rchallan.ExpireDate;
                                    rchallan.BalanceQty = rchallan.BalanceQty;
                                    try
                                    {
                                        rchallan.PurchaseDate = DateTime.Today;
                                    }
                                    catch
                                    {
                                        rchallan.PurchaseDate = DateTime.Today;
                                    }

                                    rchallan.EditDate = DateTime.Now;
                                    rchallan.EditUser = ((SessionUser)Session["SessionUser"]).UserId;
                                    rchallan.Ocode    = ((SessionUser)Session["SessionUser"]).OCode;
                                    rChallanBll.Insert(rchallan);
                                    //  string Po = lblPO.Text;

                                    //   PurchaseOrderBll.PurchaseDone(id);
                                    //if (lastReceive == 0 && ReceiveQty == Convert.ToDouble(lblOrderQty.Text))
                                    //{
                                    //    PurchaseOrderBll.PurchaseDoneByPO(id);
                                    //    // PurchaseOrderBll.UpdateLastQty(id, ReceiveQty);
                                    //}
                                    //else if ((Convert.ToDouble(lblOrderQty.Text) == ReceiveQty + Convert.ToInt16(lastReceive)))
                                    //{
                                    //    PurchaseOrderBll.PurchaseDoneByPO(id);
                                    //    // PurchaseOrderBll.UpdateLastQty(id, ReceiveQty);
                                    //}
                                    //else
                                    //{
                                    //    ReceiveQty = ReceiveQty + Convert.ToDouble(lastReceive);
                                    //PurchaseOrderBll.UpdatePOLastQty(id, ReceiveQty);
                                    //}

                                    // lblMessage.Text = "<font color='green'>Purchase information posted successfully</font>";
                                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Purchase information posted successfully')", true);
                                    SetGriview();
                                    //}
                                }
                            }
                        }
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Select Items')", true);
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }
        protected void btnProcess_Click(object sender, EventArgs e)
        {
            CreatePONo();
            List <LC_PurchaseOrder> lstLC_PurchaseOrder = new List <LC_PurchaseOrder>();

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

                if (rowChkBox.Checked == true)
                {
                    LC_PurchaseOrder aLC_PurchaseOrder = new LC_PurchaseOrder();

                    TextBox txtPOQty        = ((TextBox)gvRow.FindControl("txtPOQty"));
                    Label   lblEstimateId   = ((Label)gvRow.FindControl("lblEstimateId"));
                    Label   lblLC_ReqNo     = ((Label)gvRow.FindControl("lblLC_ReqNo"));
                    Label   lblUnitId       = ((Label)gvRow.FindControl("lblUnitId"));
                    Label   lblBuyerID      = ((Label)gvRow.FindControl("lblBuyerID"));
                    Label   lblProductId    = ((Label)gvRow.FindControl("lblProductId"));
                    Label   lblLc_Style     = ((Label)gvRow.FindControl("lblLc_Style"));
                    Label   lblLc_Order     = ((Label)gvRow.FindControl("lblLc_Order"));
                    Label   lblGroupId      = ((Label)gvRow.FindControl("lblGroupId"));
                    Label   lblSupplierCode = ((Label)gvRow.FindControl("lblSupplierCode"));

                    aLC_PurchaseOrder.LC_PO_No = txtPO_NO.Text;
                    aLC_PurchaseOrder.LC_ReqNo = txtReqNo.Text;

                    if (txtPOQty.Text == "")
                    {
                        aLC_PurchaseOrder.LC_PO_Qty = 0;
                    }
                    else
                    {
                        aLC_PurchaseOrder.LC_PO_Qty = Convert.ToDouble(txtPOQty.Text);
                    }

                    aLC_PurchaseOrder.UnitId           = Convert.ToInt32(lblUnitId.Text);
                    aLC_PurchaseOrder.Cost_Estimate_ID = lblEstimateId.Text;
                    aLC_PurchaseOrder.Buyer_ID         = Convert.ToInt32(lblBuyerID.Text);
                    aLC_PurchaseOrder.ProductId        = Convert.ToInt32(lblProductId.Text);
                    aLC_PurchaseOrder.LC_Style         = lblLc_Style.Text;
                    aLC_PurchaseOrder.SupplierCode     = lblSupplierCode.Text;
                    aLC_PurchaseOrder.GroupId          = Convert.ToInt32(lblGroupId.Text);
                    aLC_PurchaseOrder.LC_PO_Date       = Convert.ToDateTime(txtDate.Text);
                    aLC_PurchaseOrder.LC_Order         = lblLc_Order.Text;
                    aLC_PurchaseOrder.PO_Type          = ddlPOType.SelectedItem.Text;

                    aLC_PurchaseOrder.OCode         = Convert.ToString(((SessionUser)Session["SessionUser"]).OCode);
                    aLC_PurchaseOrder.EditUser      = ((SessionUser)Session["SessionUser"]).UserId;
                    aLC_PurchaseOrder.EditDate      = DateTime.Today;
                    aLC_PurchaseOrder.IsPO_Approved = false;
                    lstLC_PurchaseOrder.Add(aLC_PurchaseOrder);
                }
            }
            var result = aLC_RequisitionBLL.SavePO(lstLC_PurchaseOrder);

            if (result == 1)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Saved Successfully')", true);
                txtDate.Text  = "";
                txtReqNo.Text = "";
                txtPO_NO.Text = "";
                gridApprovalDetails.DataSource = null;
                gridApprovalDetails.DataBind();
            }
        }