protected void GetPurchaseRecordsApprovalListByWarehouse(string warehouseId)
        {
            PurchaseToWHBLL purchaseRecord = new PurchaseToWHBLL();

            try
            {
                DataTable dt = purchaseRecord.GetPurchaseRecordsApprovalListByWarehouse(warehouseId);

                purchaseRecordListGridView.DataSource = dt;
                purchaseRecordListGridView.DataBind();

                if (purchaseRecordListGridView.Rows.Count > 0)
                {
                    purchaseRecordListGridView.UseAccessibleHeader = true;
                    purchaseRecordListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
                }
                else
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Data Not Found!!!"; msgDetailLabel.Text = "";
                }
            }
            catch (Exception ex)
            {
                msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = ex.Message;
            }
            finally
            {
                purchaseRecord = null;
            }
        }
        protected void GetPurchaseRecordById(string purchaseRecordId)
        {
            PurchaseToWHBLL purchaseRecord = new PurchaseToWHBLL();

            try
            {
                DataTable dt = purchaseRecord.GetPurchaseRecordById(purchaseRecordId);

                if (dt.Rows.Count > 0)
                {
                    //prIDLabel.Text = dt.Rows[0]["PurchaseRequisitionId"].ToString();
                    //prDateLabel.Text = " , " + dt.Rows[0]["PurchaseRequisitionDate"].ToString();
                    //poIDLabel.Text = dt.Rows[0]["PurchaseOrderId"].ToString();
                    //poDateLabel.Text = " , " + dt.Rows[0]["PurchaseOrderDate"].ToString();
                    warehouseIdLabel.Text = dt.Rows[0]["WarehouseId"].ToString();
                    warehouseNameLabel.Text = dt.Rows[0]["WarehouseName"].ToString();
                    vendorIdLabel.Text = dt.Rows[0]["VendorId"].ToString();
                    vendorNameLabel.Text = dt.Rows[0]["VendorName"].ToString();
                    //requisitionNarrationLabel.Text = dt.Rows[0]["RequisitionNarration"].ToString();
                    vendorOrderDateLabel.Text = dt.Rows[0]["VendorOrderDate"].ToString();
                    vendorOrderNumberLabel.Text = dt.Rows[0]["VendorOrderNumber"].ToString();
                    vendorInvoiceNumberLabel.Text = dt.Rows[0]["VendorInvoiceNumber"].ToString();
                    receivedDateLabel.Text = dt.Rows[0]["ReceivedDate"].ToString();
                    // lcNumberLabel.Text = dt.Rows[0]["LCNumber"].ToString();
                    //  transportTypeLabel.Text = dt.Rows[0]["TransportType"].ToString();
                    paymentModeLabel.Text = dt.Rows[0]["PaymentMode"].ToString();
                    narrationLabel.Text = dt.Rows[0]["Narration"].ToString();
                    bankLabel.Text = dt.Rows[0]["Bank"].ToString();
                    bankBranchLabel.Text = dt.Rows[0]["BankBranch"].ToString();
                    chequeNumberLabel.Text = dt.Rows[0]["ChequeNumber"].ToString();
                    chequeDateLabel.Text = dt.Rows[0]["ChequeDate"].ToString();
                    // shippingAddressLabel.Text = dt.Rows[0]["ShippingAddress"].ToString();
                    //  billingAddressLabel.Text = dt.Rows[0]["BillingAddress"].ToString();
                    recordDateLabel.Text = dt.Rows[0]["RecordDate"].ToString();
                    statusLabel.Text = dt.Rows[0]["Status"].ToString();
                    totalAmountLabel.Text = dt.Rows[0]["TotalAmount"].ToString();
                    //vatLabel.Text = dt.Rows[0]["VAT"].ToString();
                    //totalPayableLabel.Text = dt.Rows[0]["TotalPayable"].ToString();
                    paidAmountLabel.Text = dt.Rows[0]["PaidAmount"].ToString();
                    transportCostLabel.Text = dt.Rows[0]["TransportCost"].ToString();
                    discountAmountLabel.Text = dt.Rows[0]["DiscountAmount"].ToString();
                    totalPayableLabel.Text = dt.Rows[0]["TotalPayable"].ToString();
                    CreatedByLabel.Text = dt.Rows[0]["CreatedBy"].ToString();
                }
                else
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Data Not Found!!!"; msgDetailLabel.Text = "";
                }
            }
            catch (Exception ex)
            {
                msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = ex.Message;
            }
            finally
            {
                purchaseRecord = null;
            }
        }
        protected void saveButton_Click(object sender, EventArgs e)
        {
            PurchaseToWHBLL purchaseRecord = new PurchaseToWHBLL();

            string msg = string.Empty;
            TextBox quantityTextBox;
            TextBox ratePerUnitTextBox;
            TextBox amountTextBox;
            TextBox unitPriceTextBox;
            float fnum;
            float uprice;
            double num;
            int pNDCount = 0;

            DataTable dt = new DataTable();
            DataRow dr = null;

            dt.Columns.Add("ProductId");
            dt.Columns.Add("Quantity");
            dt.Columns.Add("Amount");
            dt.Columns.Add("RatePerUnit");
            dt.Columns.Add("UnitPrice");
            dt.Columns.Add("Status");
            dt.Columns.Add("Narration");

            try
            {
                //if (vendorOrderDateTextBox.Text.Trim() == "" || LumexLibraryManager.ParseAppDate(vendorOrderDateTextBox.Text.Trim()) == "False")
                //{
                //    msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = "Vendor Order Date field is required.";
                //    return;
                //}
                //else if (vendorOrderNumberTextBox.Text.Trim() == "")
                //{
                //    msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = "Vendor Order Number field is required.";
                //    return;
                //}
                //else
                if (vendorInvoiceNumberTextBox.Text.Trim() == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = "Vendor Invoice Number field is required.";
                    return;
                }
                //else if (receivedDateTextBox.Text.Trim() == "" || LumexLibraryManager.ParseAppDate(receivedDateTextBox.Text.Trim()) == "False")
                //{
                //    msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = "Received Date field is required.";
                //    return;
                //}
                //else if (transportTypeDropDownList.SelectedValue == "")
                //{
                //    msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = "Transport Type field is required.";
                //    return;
                //}

                if (paymentModeDropDownList.SelectedValue == "Cheque")
                {
                    if (chequeNumberTextBox.Text.Trim() == "")
                    {
                        msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = "Cheque Number field is required.";
                        return;
                    }
                    else if (chequeDateTextBox.Text.Trim() == "" || LumexLibraryManager.ParseAppDate(chequeDateTextBox.Text.Trim()) == "False")
                    {
                        msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = "Cheque Date field is required.";
                        return;
                    }
                    else if (bankDropDownList.Text == "")
                    {
                        msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = "Bank Name field is required.";
                        return;
                    }
                    //else if (bankBranchTextBox.Text.Trim() == "")
                    //{
                    //    msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = "Bank Branch Name field is required.";
                    //    return;
                    //}
                }

                UnitPriceCalculation();

                for (int i = 0; i < purchaseProductListGridView.Rows.Count; i++)
                {
                    quantityTextBox = (TextBox)purchaseProductListGridView.Rows[i].FindControl("quantityTextBox");
                    ratePerUnitTextBox = (TextBox)purchaseProductListGridView.Rows[i].FindControl("ratePerUnitTextBox");
                    amountTextBox = (TextBox)purchaseProductListGridView.Rows[i].FindControl("amountTextBox");
                    unitPriceTextBox = (TextBox)purchaseProductListGridView.Rows[i].FindControl("unitPriceTextBox");

                    if (!double.TryParse(quantityTextBox.Text.Trim(), out num))
                    {
                        msg = "Product ID [" + purchaseProductListGridView.Rows[i].Cells[0].Text.ToString() + "] has no valid Quantity.";
                        msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = msg;
                        return;
                    }
                    else if (!float.TryParse(ratePerUnitTextBox.Text.Trim(), out fnum))
                    {
                        msg = "Product ID [" + purchaseProductListGridView.Rows[i].Cells[0].Text.ToString() + "] has no valid Rate Per Unit.";
                        msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = msg;
                        return;
                    }
                    else if (!float.TryParse(amountTextBox.Text.Trim(), out fnum))
                    {
                        msg = "Product ID [" + purchaseProductListGridView.Rows[i].Cells[0].Text.ToString() + "] has no valid Amount.";
                        msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = msg;
                        return;
                    }
                    else if (!float.TryParse(unitPriceTextBox.Text.Trim(), out uprice))
                    {
                        msg = "Product ID [" + purchaseProductListGridView.Rows[i].Cells[0].Text.ToString() + "] has no valid Unit Price.";
                        msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = msg;
                        return;
                    }
                    else
                    {
                        dr = dt.NewRow();

                        dr["ProductId"] = purchaseProductListGridView.Rows[i].Cells[0].Text.ToString();
                        dr["Quantity"] = quantityTextBox.Text.Trim();
                        dr["Amount"] = amountTextBox.Text.Trim();
                        dr["RatePerUnit"] = ratePerUnitTextBox.Text.Trim();
                        dr["UnitPrice"] = unitPriceTextBox.Text.Trim();
                        dr["Status"] = "D";
                        dr["Narration"] = "";

                        //string[] oQty = purchaseProductListGridView.Rows[i].Cells[2].Text.ToString().Split(' ');

                        //if (int.Parse(quantityTextBox.Text.Trim()) == 0)
                        //{
                        //    dr["Status"] = "ND"; pNDCount++;
                        //}
                        //else if (oQty[0].ToString().Trim() == quantityTextBox.Text.Trim())
                        //{
                        //    dr["Status"] = "D";
                        //}
                        //else
                        //{
                        //    dr["Status"] = "PD";
                        //}

                        dt.Rows.Add(dr);
                    }
                }

                if (dt.Rows.Count == purchaseProductListGridView.Rows.Count)
                {
                    purchaseRecord.AccountId = accountHeadDropDownList.SelectedValue.Trim();
                    purchaseRecord.WarehouseId = warehouseDropDownList.SelectedValue;
                    purchaseRecord.PurchaseRequisitionId = "";
                    purchaseRecord.PurchaseOrderId = "";
                    purchaseRecord.VendorId = vendorDropDownList.SelectedValue;
                    purchaseRecord.VendorOrderDate = LumexLibraryManager.ParseAppDate(vendorOrderDateTextBox.Text.Trim());
                    purchaseRecord.VendorOrderNumber = vendorOrderNumberTextBox.Text.Trim();
                    purchaseRecord.VendorInvoiceNumber = vendorInvoiceNumberTextBox.Text.Trim();
                    purchaseRecord.ReceivedDate = LumexLibraryManager.ParseAppDate(receivedDateTextBox.Text.Trim());
                    purchaseRecord.TotalAmount = totalAmountTextBox.Text.Trim();
                    //purchaseRecord.VAT = vatTextBox.Text.Trim();
                    purchaseRecord.DiscountAmount = discountTextBox.Text.Trim();
                    purchaseRecord.TotalPayable = totalPayableTextBox.Text.Trim();
                    purchaseRecord.PaidAmount = paidAmountTextBox.Text.Trim();
                    purchaseRecord.TransportCost = transportCostTextBox.Text.Trim();
                    purchaseRecord.Narration = narrationTextBox.Text.Trim();
                    purchaseRecord.LCNumber = "";//lcNumberTextBox.Text.Trim();
                    purchaseRecord.TransportType = "";//transportTypeDropDownList.SelectedValue.Trim();
                    purchaseRecord.ShippingAddress = "";//shippingAddressTextBox.Text.Trim();
                    purchaseRecord.BillingAddress = "";//billingAddressTextBox.Text.Trim();
                    purchaseRecord.PaymentMode = paymentModeDropDownList.SelectedValue.Trim();
                    purchaseRecord.Bank = bankDropDownList.Text;
                    purchaseRecord.BankBranch = bankBranchTextBox.Text.Trim();
                    purchaseRecord.ChequeNumber = chequeNumberTextBox.Text.Trim();
                    purchaseRecord.ChequeDate = LumexLibraryManager.ParseAppDate(chequeDateTextBox.Text.Trim());

                    purchaseRecord.Status = "D";

                    //if (pNDCount > 0)
                    //{
                    //    purchaseRecord.Status = "PD";
                    //}
                    //else
                    //{
                    //    purchaseRecord.Status = "D";
                    //}

                    string id = purchaseRecord.SavePurchaseRecord(dt);

                    if (!string.IsNullOrEmpty(id))
                    {
                        string message = "Purchase Record <span class='actionTopic'>Created</span> Successfully with Purchase Record ID: <span class='actionTopic'>" + id + "</span>.";
                        MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/PurchaseToWH/PurchaseList.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");

                        // MyAlertBox("alert(\"Purchase Record Created Successfully with Purchase Record ID: " + id + " \"); window.location=\"/UI/PurchaseToWH/PurchaseList.aspx\"");
                    }
                    else
                    {
                        string message = "Purchase Record <span class='actionTopic'>Created</span> Is Faild </span>.";
                        MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/PurchaseToWH/PurchaseList.aspx\"; }; ErrorAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");

                        //  msgbox.Visible = true; msgTitleLabel.Text = "Failed to Create Purchase Record!!!"; msgDetailLabel.Text = "";
                    }
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");

            }
            finally
            {
                //  purchaseRecord = null;
            }
        }
        protected void GetPurchaseList()
        {
            PurchaseToWHBLL purchaseRecord = new PurchaseToWHBLL();

            try
            {
                if (warehouseDropDownList.SelectedValue == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Warehouse Name field is required.";
                }
                else if (fromDateTextBox.Text.Trim() == "" || LumexLibraryManager.ParseAppDate(fromDateTextBox.Text.Trim()) == "False")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Date From field is required.";
                }
                else if (toDateTextBox.Text.Trim() == "" || LumexLibraryManager.ParseAppDate(toDateTextBox.Text.Trim()) == "False")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Date To field is required.";
                }
                else
                {
                    string warehouseId = warehouseDropDownList.SelectedValue.Trim();
                    string fromDate = LumexLibraryManager.ParseAppDate(fromDateTextBox.Text.Trim());
                    string toDate = LumexLibraryManager.ParseAppDate(toDateTextBox.Text.Trim());
                    string status = statusDropDownList.SelectedValue.Trim();

                    DataTable dt = purchaseRecord.GetPurchaseRecordsListByWarehouseDateRangeAndStatus(warehouseId, fromDate, toDate, status);

                    purchaseRecordListGridView.DataSource = dt;
                    purchaseRecordListGridView.DataBind();

                    if (purchaseRecordListGridView.Rows.Count > 0)
                    {
                        purchaseRecordListGridView.UseAccessibleHeader = true;
                        purchaseRecordListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
                    }
                    else
                    {
                        msgbox.Visible = true; msgTitleLabel.Text = "Data Not Found!!!"; msgDetailLabel.Text = "";
                    }
                }
            }
            catch (Exception ex)
            {
                msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = ex.Message;
            }
            finally
            {
                purchaseRecord = null;
            }
        }
        public string SavePurchaseRecord(PurchaseToWHBLL purchaseRecord, DataTable dtPrdList, LumexDBPlayer db)
        {
            string purchaseRecordId = "";

            try
            {
                
                db.AddParameters("@WarehouseId", purchaseRecord.WarehouseId.Trim());
                db.AddParameters("@PurchaseRequisitionId", purchaseRecord.PurchaseRequisitionId.Trim());
                db.AddParameters("@PurchaseOrderId", purchaseRecord.PurchaseOrderId.Trim());
                db.AddParameters("@VendorId", purchaseRecord.VendorId.Trim());
                db.AddParameters("@VendorOrderDate", purchaseRecord.VendorOrderDate.Trim());
                db.AddParameters("@VendorOrderNumber", purchaseRecord.VendorOrderNumber.Trim());
                db.AddParameters("@VendorInvoiceNumber", purchaseRecord.VendorInvoiceNumber.Trim());
                db.AddParameters("@ReceivedDate", purchaseRecord.ReceivedDate.Trim());
                db.AddParameters("@TotalAmount", purchaseRecord.TotalAmount.Trim());
                //db.AddParameters("@VAT", purchaseRecord.VAT.Trim());
                db.AddParameters("@DiscountAmount", purchaseRecord.DiscountAmount.Trim());
                db.AddParameters("@TotalPayable", purchaseRecord.TotalPayable.Trim());
                db.AddParameters("@PaidAmount", purchaseRecord.PaidAmount.Trim());
                db.AddParameters("@TransportCost", purchaseRecord.TransportCost.Trim());
                db.AddParameters("@Narration", purchaseRecord.Narration.Trim());
                db.AddParameters("@LCNumber", purchaseRecord.LCNumber.Trim());
                db.AddParameters("@TransportType", purchaseRecord.TransportType.Trim());
                db.AddParameters("@ShippingAddress", purchaseRecord.ShippingAddress.Trim());
                db.AddParameters("@BillingAddress", purchaseRecord.BillingAddress.Trim());
                db.AddParameters("@PaymentMode", purchaseRecord.PaymentMode.Trim());
                db.AddParameters("@AccountId", purchaseRecord.AccountId.Trim());
                db.AddParameters("@Bank", purchaseRecord.Bank.Trim());
                db.AddParameters("@BankBranch", purchaseRecord.BankBranch.Trim());
                db.AddParameters("@ChequeNumber", purchaseRecord.ChequeNumber.Trim());
                db.AddParameters("@ChequeDate", purchaseRecord.ChequeDate.Trim());
                db.AddParameters("@CreatedBy", LumexSessionManager.Get("ActiveUserId").ToString());
                db.AddParameters("@CreatedFrom", LumexLibraryManager.GetTerminal());

                DataTable dt = db.ExecuteDataTable("INSERT_WAREHOUSE_PURCHASE_RECORD", true);

                if (dt.Rows.Count > 0)
                {
                    purchaseRecordId = dt.Rows[0][0].ToString();
                }

                for (int i = 0; i < dtPrdList.Rows.Count; i++)
                {
                    db.ClearParameters();
                    db.AddParameters("@WarehouseId", purchaseRecord.WarehouseId.Trim());
                    db.AddParameters("@PurchaseRecordId", purchaseRecordId.Trim());
                    db.AddParameters("@ProductId", dtPrdList.Rows[i]["ProductId"].ToString());
                    db.AddParameters("@Quantity", dtPrdList.Rows[i]["Quantity"].ToString());
                    db.AddParameters("@Amount", dtPrdList.Rows[i]["Amount"].ToString());
                    db.AddParameters("@RatePerUnit", dtPrdList.Rows[i]["RatePerUnit"].ToString());
                    db.AddParameters("@UnitPrice", dtPrdList.Rows[i]["UnitPrice"].ToString());
                    db.AddParameters("@Status", dtPrdList.Rows[i]["Status"].ToString());
                    db.AddParameters("@Narration", dtPrdList.Rows[i]["Narration"].ToString());

                    db.ExecuteNonQuery("INSERT_WAREHOUSE_PURCHASE_RECORD_PRODUCT", true);
                }

                db.ClearParameters();
                db.AddParameters("@PurchaseOrderId", purchaseRecord.PurchaseOrderId.Trim());
                db.AddParameters("@Status", purchaseRecord.Status.Trim());

                db.ExecuteNonQuery("UPDATE_PURCHASE_ORDER_STATUS_BY_ID", true);

                return purchaseRecordId;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                purchaseRecord = null;
                dtPrdList = null;
            }
        }
 protected void RejectBtn_OnClick(object sender, EventArgs e)
 {
     PurchaseToWHBLL purchaseRecord = new PurchaseToWHBLL();
     bool status = false;
     try
     {
         status = purchaseRecord.rejectPurchaseRecord(warehouseIdLabel.Text.Trim(), idLabel.Text.Trim());
         if (status)
         {
             string message = "Purchase Record <span class='actionTopic'>Rejected</span> Successfully.";
             MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/PurchaseToWH/PurchaseApprovalList.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");
         }
         else
         {
             msgbox.Visible = true; msgTitleLabel.Text = "Warning!!!"; msgDetailLabel.Text = "Purchase can not be Rejected";
             msgbox.Attributes.Add("Class", "alert alert-error");
         }
     }
     catch (Exception ex)
     {
         msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = ex.Message;
     }
 }
        protected void approveButton_Click(object sender, EventArgs e)
        {
            PurchaseToWHBLL purchaseRecord = new PurchaseToWHBLL();

            try
            {
                purchaseRecord.ApprovePurchaseRecord(warehouseIdLabel.Text.Trim(), idLabel.Text.Trim());

                string message = "Purchase Record <span class='actionTopic'>Approved</span> Successfully.";
                MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/PurchaseToWH/PurchaseApprovalList.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");

                //  MyAlertBox("alert(\"Purchase Record Approved Successfully.\"); window.location=\"/UI/PurchaseToWH/PurchaseApprovalList.aspx\"");
            }
            catch (Exception ex)
            {
                msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = ex.Message;
            }
            finally
            {
                purchaseRecord = null;
            }
        }
        protected void GetPurchaseRecordProductListById(string purchaseRecordId)
        {
            PurchaseToWHBLL purchaseRecord = new PurchaseToWHBLL();

            try
            {
                DataTable dt = purchaseRecord.GetPurchaseRecordProductListById(purchaseRecordId);

                if (dt.Rows.Count > 0)
                {
                    purchaseOrderProductListGridView.DataSource = dt;
                    purchaseOrderProductListGridView.DataBind();

                    if (purchaseOrderProductListGridView.Rows.Count > 0)
                    {
                        purchaseOrderProductListGridView.UseAccessibleHeader = true;
                        purchaseOrderProductListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;

                        approveButton.Enabled = true;
                    }
                    else
                    {
                        approveButton.Enabled = false;
                    }
                }
                else
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Data Not Found!!!"; msgDetailLabel.Text = "";
                }
            }
            catch (Exception ex)
            {
                msgbox.Visible = true; msgTitleLabel.Text = "Sorry!!!"; msgDetailLabel.Text = ex.Message;
            }
            finally
            {
                purchaseRecord = null;
            }
        }