protected void Txtchequeno_TextChanged(object sender, EventArgs e)
 {
     Txtchqtrndate.Focus();
 }
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            string Date = Today.ToString("dd-MM-yyyy");
            double BAL, AMT;
            BAL = Convert.ToDouble(txtBalance.Text == "" ? "0" : txtBalance.Text);
            AMT = Convert.ToDouble(TxtInstAmt.Text == "" ? "0" : TxtInstAmt.Text);
            if (AMT <= BAL)
            {
                if (ViewState["Flag"].ToString() == "AD")
                {
                    if (DDltransctntype.SelectedValue == "0")
                    {
                        WebMsgBox.Show("Please select Transaction Type", this.Page);
                        DDltransctntype.Focus();
                        return;
                    }
                    if (TxtInstAmt.Text == "")
                    {
                        WebMsgBox.Show("Please enter Instrument Amount", this.Page);
                        TxtInstAmt.Focus();
                        return;
                    }
                    if (DDltransctntype.SelectedItem.Text == "D" && Txtdraweloc.Text == "")
                    {
                        WebMsgBox.Show("Please enter Drawee Location ", this.Page);
                        Txtdraweloc.Focus();
                        return;
                    }
                    if (DDltransctntype.SelectedItem.Text == "N" && Txtcustrefno.Text == "")
                    {
                        WebMsgBox.Show("Please enter Cust ref No ", this.Page);
                        Txtcustrefno.Focus();
                        return;
                    }
                    if (Txtpayd5.Text == "")
                    {
                        WebMsgBox.Show("Please enter Payment Details 5", this.Page);
                        Txtpayd5.Focus();
                        return;
                    }
                    if (Txtpayd6.Text == "")
                    {
                        WebMsgBox.Show("Please enter Payment Details 6", this.Page);
                        Txtpayd6.Focus();
                        return;
                    }
                    if (Txtpayd7.Text == "")
                    {
                        WebMsgBox.Show("Please enter Payment Details 7", this.Page);
                        Txtpayd7.Focus();
                        return;
                    }
                    if (Txtchqtrndate.Text == "")
                    {
                        WebMsgBox.Show("Please enter Cheque Date", this.Page);
                        Txtchqtrndate.Focus();
                        return;
                    }
                    if (DDltransctntype.SelectedItem.Text == "R" && Txtifccode.Text == "")
                    {
                        WebMsgBox.Show("Please enter IFC Code", this.Page);
                        Txtifccode.Focus();
                        return;
                    }

                    if (DDltransctntype.SelectedItem.Text == "N" && Txtifccode.Text == "")
                    {
                        WebMsgBox.Show("Please enter IFC Code", this.Page);
                        Txtifccode.Focus();
                        return;
                    }
                    if (DDltransctntype.SelectedItem.Text == "R" && Txtbenebankname.Text == "")
                    {
                        WebMsgBox.Show("Please enter BeneBankName", this.Page);
                        Txtbenebankname.Focus();
                        return;
                    }
                    if (DDltransctntype.SelectedItem.Text == "N" && Txtbenebankname.Text == "")
                    {
                        WebMsgBox.Show("Please enter BeneBankName", this.Page);
                        Txtbenebankname.Focus();
                        return;
                    }
                    int Result = OW.Insertdata(DDltransctntype.SelectedItem.Text, Txtbeneficrycode.Text, TxtbeneAccno.Text, TxtInstAmt.Text, Txtbenename.Text, Txtdraweloc.Text, Txtprntloc.Text, Txtbeneadd1.Text,
                                               Txtbeneadd2.Text, Txtbeneadd3.Text, Txtbeneadd4.Text, Txtbeneadd5.Text, Txtinstrefno.Text, Txtcustrefno.Text, Txtpayd1.Text, Txtpayd2.Text, Txtpayd3.Text, Txtpayd4.Text, Txtpayd5.Text,
                                               Txtpayd6.Text, Txtpayd7.Text, Txtchequeno.Text, Txtchqtrndate.Text, Txtmicrno.Text, Txtifccode.Text, Txtbenebankname.Text, Txtbenebranchnme.Text, Txtbeneemail.Text, "1001", Session["BRCD"].ToString(),
                                               ddlPayType.SelectedItem.Text, txtProdType1.Text, TxtAccNo1.Text, Txtinstno.Text, TxtChequeDate.Text, txtNarration.Text, txtBalance.Text, Session["MID"].ToString());
                    if (Result > 0)
                    {
                        WebMsgBox.Show("Data Added successfully..!!", this.Page);

                        BindGrid();
                        FL = "Insert";//Dhanya Shetty
                        string Res = CLM.LOGDETAILS(FL, Session["BRCD"].ToString(), Session["MID"].ToString(), "OutwardRTGS_Add _" + TxtbeneAccno.Text + "_" + Session["LOGINCODE"].ToString() + "", "00", Session["MID"].ToString());
                        Cleardata();
                        return;
                    }
                }
                else if (ViewState["Flag"].ToString() == "AT")
                {
                    string ST     = "";
                    int    Result = OW.AuthoriseData(Session["BRCD"].ToString(), TxtbeneAccno.Text, ViewState["Id"].ToString(), Session["MID"].ToString());
                    if (Result > 0)
                    {
                        double CBAl  = Convert.ToDouble(txtBalance.Text);
                        double Total = Convert.ToDouble(TxtInstAmt.Text);
                        string CbalT = Convert.ToString(CBAl - Total);
                        ST = BD.GetSetNo(Session["EntryDate"].ToString(), "IBTSetNo", Session["BRCD"].ToString()).ToString();
                        if (ddlPayType.SelectedValue == "2")
                        {
                            int RM = AT.Authorized(Session["EntryDate"].ToString(), Session["EntryDate"].ToString(), Session["EntryDate"].ToString(), ViewState["GLCODE"].ToString(), txtProdType1.Text, TxtAccNo1.Text, txtNarration.Text, "RTGS/NFT",
                                                   CbalT, "1", "7", "TR", ST, Txtinstno.Text, TxtChequeDate.Text, "0", "0", "1001", "0", Session["BRCD"].ToString(), Session["MID"].ToString(), "0", "0", "OutwardDetail_TRF", "0", TxtAccName1.Text, "0", "0");
                            if (RM > 0)
                            {
                                RM = AT.Authorized(Session["EntryDate"].ToString(), Session["EntryDate"].ToString(), Session["EntryDate"].ToString(), ViewState["GLCODE"].ToString(), txtProdType1.Text, TxtbeneAccno.Text, txtNarration.Text, "RTGS/NFT",
                                                   TxtInstAmt.Text, "2", "7", "TR", ST, Txtinstno.Text, TxtChequeDate.Text, "0", "0", "1001", "0", Session["BRCD"].ToString(), Session["MID"].ToString(), "0", "0", "OutwardDetail_TRF", "0", Txtbenename.Text, "0", "0");
                                if (RM > 0)
                                {
                                    WebMsgBox.Show("Data authorised successfully and Voucher Posted  successfully With Set No: " + ST + "!!", this.Page);
                                    GenerateText();
                                    BindGrid();
                                    FL = "Insert";//Dhanya Shetty
                                    string Res = CLM.LOGDETAILS(FL, Session["BRCD"].ToString(), Session["MID"].ToString(), "OutwardRTGS_Auth_T _" + TxtbeneAccno.Text + "_" + ST + "_" + Session["LOGINCODE"].ToString() + "", "00", Session["MID"].ToString());
                                    Cleardata();

                                    return;
                                }
                            }
                        }
                        else if (ddlPayType.SelectedValue == "4")
                        {
                            int RM = AT.Authorized(Session["EntryDate"].ToString(), Session["EntryDate"].ToString(), Session["EntryDate"].ToString(), ViewState["GLCODE"].ToString(), txtProdType1.Text, TxtAccNo1.Text, txtNarration.Text, "RTGS/NFT",
                                                   CbalT, "1", "7", "TR", ST, Txtinstno.Text, TxtChequeDate.Text, "0", "0", "1001", "0", Session["BRCD"].ToString(), Session["MID"].ToString(), "0", "0", "OutwardDetail_Chq", "0", TxtAccName1.Text, "0", "0");
                            if (RM > 0)
                            {
                                RM = AT.Authorized(Session["EntryDate"].ToString(), Session["EntryDate"].ToString(), Session["EntryDate"].ToString(), ViewState["GLCODE"].ToString(), txtProdType1.Text, TxtbeneAccno.Text, txtNarration.Text, "RTGS/NFT",
                                                   TxtInstAmt.Text, "2", "7", "TR", ST, Txtinstno.Text, TxtChequeDate.Text, "0", "0", "1001", "0", Session["BRCD"].ToString(), Session["MID"].ToString(), "0", "0", "OutwardDetail_Chq", "0", Txtbenename.Text, "0", "0");
                                if (RM > 0)
                                {
                                    WebMsgBox.Show(" Data authorised successfully and Voucher Posted  successfully With Set No: " + ST + "!!", this.Page);
                                    GenerateText();
                                    BindGrid();
                                    FL = "Insert";//Dhanya Shetty
                                    string Res = CLM.LOGDETAILS(FL, Session["BRCD"].ToString(), Session["MID"].ToString(), "OutwardRTGS_Auth_Cq _" + TxtbeneAccno.Text + "_" + ST + "_" + Session["LOGINCODE"].ToString() + "", "00", Session["MID"].ToString());
                                    Cleardata();

                                    return;
                                }
                            }
                        }
                    }
                }
                else if (ViewState["Flag"].ToString() == "DL")
                {
                    int Result = OW.DeleteData(Session["BRCD"].ToString(), TxtbeneAccno.Text, ViewState["Id"].ToString(), Session["MID"].ToString());
                    if (Result > 0)
                    {
                        WebMsgBox.Show("Data Deleted successfully..!!", this.Page);

                        BindGrid();
                        FL = "Insert";//Dhanya Shetty
                        string Res = CLM.LOGDETAILS(FL, Session["BRCD"].ToString(), Session["MID"].ToString(), "OutwardRTGS_Del _" + TxtbeneAccno.Text + "_" + Session["LOGINCODE"].ToString() + "", "00", Session["MID"].ToString());
                        Cleardata();
                        return;
                    }
                }
            }
            else
            {
                WebMsgBox.Show("Amount is greater than balance!", this.Page);
                TxtInstAmt.Text = "";
                TxtInstAmt.Focus();
            }
        }

        catch (Exception Ex)
        {
            ExceptionLogging.SendErrorToText(Ex);
        }
    }