protected void btnAccept_Click(object sender, EventArgs e)
        {
            try
            {


                string msg = string.Empty;

                SalesOrderBLL salesOrder = new SalesOrderBLL();

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

                //dt.Columns.Add(new DataColumn("Barcode"));
                dt.Columns.Add(new DataColumn("MainProductId"));
                dt.Columns.Add(new DataColumn("MainProductName"));
                dt.Columns.Add(new DataColumn("MainPUnit"));
                dt.Columns.Add(new DataColumn("ProductName"));
                dt.Columns.Add(new DataColumn("Quantity"));
                dt.Columns.Add(new DataColumn("RatePerUnit"));

                
                    for (int i = 0; i < selectedProductListGridView.Rows.Count; i++)
                    {
                        dr = dt.NewRow();

                        //dr["Barcode"] = selectedProductListGridView.Rows[i].Cells[0].Text.ToString();
                        dr["MainProductId"] = selectedProductListGridView.Rows[i].Cells[0].Text.ToString();
                        dr["MainProductName"] = selectedProductListGridView.Rows[i].Cells[1].Text.ToString();
                        dr["MainPUnit"] = selectedProductListGridView.Rows[i].Cells[2].Text.ToString();
                        dr["ProductName"] = selectedProductListGridView.Rows[i].Cells[3].Text.ToString();
                        dr["RatePerUnit"] = selectedProductListGridView.Rows[i].Cells[5].Text.ToString();

                        TextBox orderQuantityTextBox =
                            (TextBox)selectedProductListGridView.Rows[i].FindControl("orderQuantityTextBox");
                        dr["Quantity"] = orderQuantityTextBox.Text.Trim();



                        dt.Rows.Add(dr);
                    }

                    if (totalAmountLabel.Text.Trim() == "")
                    {
                        msgbox.Visible = true;
                        msgTitleLabel.Text = "Warning!!!";
                        msgDetailLabel.Text = "Total Amount field is required.";
                        return;
                    }
                    //else if (vatLabel.Text.Trim() == "")
                    //{
                    //    msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = "VAT field is required.";
                    //    return;
                    //}
                    else if (totalReceivableLabel.Text.Trim() == "")
                    {
                        msgbox.Visible = true;
                        msgTitleLabel.Text = "Warning!!!";
                        msgDetailLabel.Text = "Total Receivable field is required.";
                        return;
                    }
                    //if (string.IsNullOrEmpty(vatLabel.Text))
                    //{
                    //    vatLabel.Text = "0";
                    //}

                    salesOrder.SalesRecordId = salesRecordIdlavel.Text;
                    salesOrder.RecordDate = recordDateLabel.Text;
                    salesOrder.JournalNumber = journalVoucharLavel.Text;
                    salesOrder.SalesCenterId = salesCenterIdLabel.Text;




                    //if (dt.Rows.Count == selectedProductListGridView.Rows.Count)
                    //{

                    string salesRecordId = salesOrder.ApproveSalesRecordRetailSubproducs(dt);
                    // salesOrder.UpdateSalesOrderOnApproved(salesRecordId, salesOrder.SalesOrderId);

                    if (!string.IsNullOrEmpty(salesRecordId))
                    {

                        string message =
                            "Product's <span class='actionTopic'>Sales Recorded</span> Successfully with Sale ID: <span class='actionTopic'>" +
                            salesRecordId + "</span>.";
                        MyAlertBox(
                            "var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/Sales/RetailSalesList.aspx\"; }; SuccessAlert(\"" +
                            "Process Succeed" + "\", \"" + message + "\", callbackOk);");


                    }
                    else
                    {
                        string message =
                            "Product's <span class='actionTopic'>Sales Recorded</span> Update Failed" +
                            salesRecordId + "</span>.";
                        MyAlertBox(
                            "var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/Sales/RetailSalesList.aspx\"; }; SuccessAlert(\"" +
                            "Process Succeed" + "\", \"" + message + "\", callbackOk);");
                    }
                
              
               
                //}
            }

            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null)
                {
                    message += " --> " + ex.InnerException.Message;
                }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                //salesOrder = null;
                //dtPrdList = null;
            }
        }