internal bool ChangeChequeStatusForOutFlow(LumexDBPlayer db, chequeInventoryBLL chequeInventoryBLL, string statusType)
 {
     bool status = false;
     try
     {
         db.AddParameters("@Serial", chequeInventoryBLL.chequeSerial.Trim());
         db.AddParameters("@CreatedBy", LumexSessionManager.Get("ActiveUserId").ToString().Trim());
         db.AddParameters("@CreatedFrom", LumexLibraryManager.GetTerminal());
         db.AddParameters("@Trandate",chequeInventoryBLL.Finaldate.Trim());
         db.AddParameters("@Naration", chequeInventoryBLL.naration.Trim());
         if (statusType == "R")
         {
             status = Convert.ToBoolean(db.ExecuteNonQuery("UPDATE_CHEQUE_INVENTORY_WHEN_REJECT", true));
         }
         if (statusType == "A")
         {
             status = Convert.ToBoolean(db.ExecuteNonQuery("[UPDATE_CHEQUE_INVENTORY_FOR_OUT_WHEN_APPROVE]", true));
         }
         if (statusType == "AC")
         {
             status = Convert.ToBoolean(db.ExecuteNonQuery("[UPDATE_CHEQUE_INVENTORY_FOR_OUT_WHEN_APPROVE_BY_CASH]", true));
         }
     }
     catch (Exception ex)
     {
         throw;
     }
     return status;
 }
        protected void getChequeInventoryDetails()
        {
            chequeInventoryBLL chekQueInventoryBll = new chequeInventoryBLL();
            DataTable dt = new DataTable();
            try
            {
                if (ddlStatus.SelectedValue != "P")
                {
                    gridChequeInventory.Columns[8].Visible = false;
                    gridChequeInventory.Columns[10].Visible = false;

                }
                else
                {
                    gridChequeInventory.Columns[8].Visible = true;
                }

                chekQueInventoryBll.folowType = ddlType.SelectedValue.ToString().Trim();
                chekQueInventoryBll.status = ddlStatus.SelectedValue.ToString().Trim();
                chekQueInventoryBll.branchId = salesCenterDropDownList.SelectedValue.ToString().Trim();

                dt = chekQueInventoryBll.getChequeInventory();

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


                if (gridChequeInventory.Rows.Count > 0)
                {
                    gridChequeInventory.UseAccessibleHeader = true;
                    gridChequeInventory.HeaderRow.TableSection = TableRowSection.TableHeader;
                }
                else
                {
                    msgTitleLabel.Text = "Warning !!!";
                    msgDetailLabel.Text = "No data Found On the cheque Inventory";
                    msgbox.Visible = true;
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
        }
        public DataTable getChequeInventoryList(LumexDBPlayer db, chequeInventoryBLL chequeInventoryBLL)
        {
            DataTable dt = new DataTable();
            try
            {
                db.AddParameters("@IsInflow", chequeInventoryBLL.folowType.Trim());
                db.AddParameters("@ChequeStatus", chequeInventoryBLL.status.Trim());
                db.AddParameters("@BranchId", chequeInventoryBLL.branchId.Trim());

                dt = db.ExecuteDataTable("GET_CHEQUE_INVENTORY_BY_FLOWSTATUS_Cheque_Status", true);

                return dt;
            }
            catch (Exception)
            {
                throw;
            }
        }
        protected void ddlStatusInGrid_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                
                bool status = false;
                DropDownList drpDownList = (DropDownList)sender;
                GridViewRow gridRow = (GridViewRow)drpDownList.NamingContainer;

                chequeInventoryBLL chqInventoryBll = new chequeInventoryBLL();
                chqInventoryBll.chequeSerial = gridChequeInventory.Rows[gridRow.RowIndex].Cells[0].Text.ToString();
                TextBox txtbxNaration= (TextBox)gridChequeInventory.Rows[gridRow.RowIndex].FindControl("txtchqNaration");
                chqInventoryBll.naration = txtbxNaration.Text;
                TextBox txtbxFinalDate = (TextBox)gridChequeInventory.Rows[gridRow.RowIndex].FindControl("txtFinalDate");
                string finalDate = txtbxFinalDate.Text.Trim();
                if(!string.IsNullOrEmpty(finalDate))
                {
                    chqInventoryBll.Finaldate =LumexLibraryManager.ParseAppDate(txtbxFinalDate.Text);
                }
                DropDownList ddlStatusInGrid = (DropDownList)gridChequeInventory.Rows[gridRow.RowIndex].FindControl("ddlStatusInGrid");
                string statusType = ddlStatusInGrid.SelectedValue.ToString();

                if (!string.IsNullOrEmpty(txtbxFinalDate.Text)&&statusType!="0")
                {
                    if (ddlType.SelectedValue == "Y")
                    {
                        status = chqInventoryBll.ChangeChequeStatus(statusType);
                        getChequeInventoryDetails();
                        if (statusType == "R")
                        {


                            if (status)
                            {
                                string message =
                                    "Sales <span class='actionTopic'>Cheque</span> Successfully Rejected</span>.";
                                MyAlertBox(
                                    "var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/SalesReturn/SalesReturnList.aspx\"; }; SuccessAlert(\"" +
                                    "Process Succeed" + "\", \"" + message + "\", \"\");");

                            }
                            else
                            {
                                string message =
                                    "Sales <span class='actionTopic'>Cheque</span> does not Rejected</span>.";
                                MyAlertBox(
                                    "var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/SalesReturn/SalesReturnList.aspx\"; }; WarningAlert(\"" +
                                    "Process Succeed" + "\", \"" + message + "\", \"\");");

                            }

                        }
                        if (ddlStatusInGrid.SelectedValue == "A")
                        {
                            // status = chekInventoryBll.ChangeChequeStatus(statusType);
                            if (status)
                            {
                                string message =
                                    " <span class='actionTopic'>Cheque</span> Successfully Approved</span>.";
                                MyAlertBox(
                                    "var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/SalesReturn/SalesReturnList.aspx\"; }; SuccessAlert(\"" +
                                    "Process Succeed" + "\", \"" + message + "\", \"\");");
                                //  getChequeInventoryDetails();
                            }
                            else
                            {
                                string message =
                                    " <span class='actionTopic'>Cheque</span> Does Not Approved</span>.";
                                MyAlertBox(
                                    "var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/SalesReturn/SalesReturnList.aspx\"; }; WarningAlert(\"" +
                                    "Process Succeed" + "\", \"" + message + "\", \"\");");
                                //  getChequeInventoryDetails();
                            }
                        }

                        if (ddlStatusInGrid.SelectedValue == "AC")
                        {
                            //  status = chekInventoryBll.ChangeChequeStatus(statusType);
                            if (status)
                            {
                                string message =
                                    "<span class='actionTopic'>Cheque</span> Successfully Approved by Cash</span>.";
                                MyAlertBox(
                                    "var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/SalesReturn/SalesReturnList.aspx\"; }; SuccessAlert(\"" +
                                    "Process Succeed" + "\", \"" + message + "\", \"\");");
                                //  getChequeInventoryDetails();
                            }
                            else
                            {
                                string message =
                                    "<span class='actionTopic'>Cheque</span> Does Not Approved by Cash</span>.";
                                MyAlertBox(
                                    "var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/SalesReturn/SalesReturnList.aspx\"; }; WarningAlert(\"" +
                                    "Process Succeed" + "\", \"" + message + "\", \"\");");
                                // getChequeInventoryDetails();
                            }
                        }
                    }
                    else
                    {
                        status = chqInventoryBll.ChangeChequeStatusForOutFlow(statusType);
                        getChequeInventoryDetails();
                        if (statusType == "R")
                        {


                            if (status)
                            {
                                string message =
                                    " <span class='actionTopic'>Cheque</span> Successfully Rejected</span>.";
                                MyAlertBox(
                                    "var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/SalesReturn/SalesReturnList.aspx\"; }; SuccessAlert(\"" +
                                    "Process Succeed" + "\", \"" + message + "\", \"\");");

                            }
                            else
                            {
                                string message =
                                    " <span class='actionTopic'>Cheque</span> doesw not Rejected</span>.";
                                MyAlertBox(
                                    "var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/SalesReturn/SalesReturnList.aspx\"; }; WarningAlert(\"" +
                                    "Process Succeed" + "\", \"" + message + "\", \"\");");

                            }

                        }
                        if (ddlStatusInGrid.SelectedValue == "A")
                        {
                            // status = chekInventoryBll.ChangeChequeStatus(statusType);
                            if (status)
                            {
                                string message =
                                    " <span class='actionTopic'>Cheque</span> Successfully Approved</span>.";
                                MyAlertBox(
                                    "var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/SalesReturn/SalesReturnList.aspx\"; }; SuccessAlert(\"" +
                                    "Process Succeed" + "\", \"" + message + "\", \"\");");
                                //  getChequeInventoryDetails();
                            }
                            else
                            {
                                string message =
                                    " <span class='actionTopic'>Cheque</span> Does Not Approved</span>.";
                                MyAlertBox(
                                    "var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/SalesReturn/SalesReturnList.aspx\"; }; WarningAlert(\"" +
                                    "Process Succeed" + "\", \"" + message + "\", \"\");");
                                //  getChequeInventoryDetails();
                            }
                        }

                        if (ddlStatusInGrid.SelectedValue == "AC")
                        {
                            //  status = chekInventoryBll.ChangeChequeStatus(statusType);
                            if (status)
                            {
                                string message =
                                    " <span class='actionTopic'>Cheque</span> Successfully Approved by Cash</span>.";
                                MyAlertBox(
                                    "var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/SalesReturn/SalesReturnList.aspx\"; }; SuccessAlert(\"" +
                                    "Process Succeed" + "\", \"" + message + "\", \"\");");
                                //  getChequeInventoryDetails();
                            }
                            else
                            {
                                string message =
                                    " <span class='actionTopic'>Cheque</span> Does Not Approved by cash</span>.";
                                MyAlertBox(
                                    "var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/SalesReturn/SalesReturnList.aspx\"; }; WarningAlert(\"" +
                                    "Process Succeed" + "\", \"" + message + "\", \"\");");
                                // getChequeInventoryDetails();
                            }
                        }

                    }
                }
                else
                {
                    string message = "Please  <span class='actionTopic'>Select</span> The Final Date. or select correct Action</span>.";
                    MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/SalesReturn/SalesReturnList.aspx\"; }; WarningAlert(\"" +"Warning" + "\", \"" + message + "\", \"\");");
                    ddlStatusInGrid.ClearSelection();
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
        }