protected void cmbResident_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        try
        {
            lblname.Text          = cmbResident.SelectedItem.Text;
            ReportList.Visible    = false;
            ReportList.DataSource = string.Empty;
            ReportList.DataBind();
            ReportListAll.Visible    = false;
            ReportListAll.DataSource = string.Empty;
            ReportListAll.DataBind();
            if (cmbResident.SelectedValue == "0")
            {
                ddlAccountNumber.Items.Clear();
                ddlAccountNumber.Items.Add(new ListItem("All", "0"));
                //ddlAccountNumber.Items.Add("G1000000");
                //ddlAccountNumber.Items.Add("D1000000");
            }
            else
            {
                DataSet dsResident = new DataSet();
                DataSet ds         = new DataSet();

                dsResident = sqlobj.ExecuteSP("SP_GenDropDownList",
                                              new SqlParameter()
                {
                    ParameterName = "@iMode", SqlDbType = SqlDbType.Int, Value = 11
                },
                                              new SqlParameter()
                {
                    ParameterName = "@RTRSN", SqlDbType = SqlDbType.Decimal, Value = cmbResident.SelectedValue
                });
                ddlAccountNumber.DataSource     = dsResident.Tables[0];
                ddlAccountNumber.DataValueField = "AccountNo";
                ddlAccountNumber.DataTextField  = "AccountNo";
                ddlAccountNumber.DataBind();
                LoadOtherDet();
                ReportList.DataSource = string.Empty;
                ReportList.DataBind();
            }
        }
        catch (Exception ex)
        {
        }
    }
    protected void chkstatus_CheckedChanged(object sender, EventArgs e)
    {
        DataSet dsStatement = new DataSet();

        if (chkstatus.Checked == true)
        {
            if (cmbResident.SelectedValue == "0")
            {
                dsStatement = sqlobj.ExecuteSP("SP_GetUnbilledTransactions",
                                               new SqlParameter()
                {
                    ParameterName = "@iMode", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int, Value = 3
                },
                                               new SqlParameter()
                {
                    ParameterName = "@FromDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpfordate.SelectedDate
                },
                                               new SqlParameter()
                {
                    ParameterName = "@ToDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpuntildate.SelectedDate
                },
                                               new SqlParameter()
                {
                    ParameterName = "@RTRSN", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Decimal, Value = 1
                },
                                               new SqlParameter()
                {
                    ParameterName = "@AccountNo", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Value = "NA"
                });
            }
            else if (cmbResident.SelectedValue != "0")
            {
                dsStatement = sqlobj.ExecuteSP("SP_GetUnbilledTransactions",
                                               new SqlParameter()
                {
                    ParameterName = "@iMode", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int, Value = 4
                },
                                               new SqlParameter()
                {
                    ParameterName = "@FromDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpfordate.SelectedDate
                },
                                               new SqlParameter()
                {
                    ParameterName = "@ToDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpuntildate.SelectedDate
                },
                                               new SqlParameter()
                {
                    ParameterName = "@RTRSN", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Decimal, Value = cmbResident.SelectedValue
                },
                                               new SqlParameter()
                {
                    ParameterName = "@AccountNo", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Value = ddlAccountNumber.SelectedValue
                });
            }
        }
        if (chkstatus.Checked == false)
        {
            if (cmbResident.SelectedValue == "0")
            {
                dsStatement = sqlobj.ExecuteSP("SP_GetUnbilledTransactions",
                                               new SqlParameter()
                {
                    ParameterName = "@iMode", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int, Value = 1
                },
                                               new SqlParameter()
                {
                    ParameterName = "@FromDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpfordate.SelectedDate
                },
                                               new SqlParameter()
                {
                    ParameterName = "@ToDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpuntildate.SelectedDate
                },
                                               new SqlParameter()
                {
                    ParameterName = "@RTRSN", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Decimal, Value = 1
                },
                                               new SqlParameter()
                {
                    ParameterName = "@AccountNo", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Value = "NA"
                });
            }
            else if (cmbResident.SelectedValue != "0")
            {
                dsStatement = sqlobj.ExecuteSP("SP_GetUnbilledTransactions",
                                               new SqlParameter()
                {
                    ParameterName = "@iMode", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int, Value = 2
                },
                                               new SqlParameter()
                {
                    ParameterName = "@FromDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpfordate.SelectedDate
                },
                                               new SqlParameter()
                {
                    ParameterName = "@ToDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpuntildate.SelectedDate
                },
                                               new SqlParameter()
                {
                    ParameterName = "@RTRSN", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Decimal, Value = cmbResident.SelectedValue
                },
                                               new SqlParameter()
                {
                    ParameterName = "@AccountNo", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Value = ddlAccountNumber.SelectedValue
                });
            }
        }
        if (dsStatement.Tables[0].Rows.Count > 0)
        {
            LoadOtherDet();
            ReportList.DataSource = dsStatement;
            ReportList.DataBind();
            ReportListAll.DataSource = dsStatement;
            ReportListAll.DataBind();
            lblDebitCnt.Text = Convert.ToString(dsStatement.Tables[0].Rows.Count);
        }
        else
        {
            lblDebitCnt.Visible   = false;
            lblCreditcnt.Visible  = false;
            lblTCt.Visible        = false;
            lblLatTxnDt.Visible   = false;
            lblTDt.Visible        = false;
            lblTCt.Visible        = false;
            Label5.Visible        = false;
            Label6.Visible        = false;
            Label8.Visible        = false;
            Label10.Visible       = false;
            Label11.Visible       = false;
            ReportList.DataSource = string.Empty;
            ReportList.DataBind();
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "alert", "alert('No record for your selected date range.');", true);
        }



        //if (dsStatement.Tables[0].Rows.Count > 0)
        //{

        //    ReportList.DataSource = dsStatement;
        //    ReportList.DataBind();
        //}

        dsStatement.Dispose();
    }
    protected void LoadGrid1()
    {
        try
        {
            drpSessionfilters.SelectedValue = "0";
            string  STR         = cmbResident.SelectedValue;
            DataSet dsStatement = new DataSet();
            if (chkstatus.Checked == true)
            {
                if (cmbResident.SelectedValue == "0")
                {
                    dsStatement = sqlobj.ExecuteSP("SP_GetUnbilledTransactions",
                                                   new SqlParameter()
                    {
                        ParameterName = "@iMode", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int, Value = 3
                    },
                                                   new SqlParameter()
                    {
                        ParameterName = "@FromDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpfordate.SelectedDate
                    },
                                                   new SqlParameter()
                    {
                        ParameterName = "@ToDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpuntildate.SelectedDate
                    },
                                                   new SqlParameter()
                    {
                        ParameterName = "@RTRSN", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Decimal, Value = 1
                    },
                                                   new SqlParameter()
                    {
                        ParameterName = "@AccountNo", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Value = "NA"
                    });
                }
                else if (cmbResident.SelectedValue != "0")
                {
                    dsStatement = sqlobj.ExecuteSP("SP_GetUnbilledTransactions",
                                                   new SqlParameter()
                    {
                        ParameterName = "@iMode", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int, Value = 4
                    },
                                                   new SqlParameter()
                    {
                        ParameterName = "@FromDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpfordate.SelectedDate
                    },
                                                   new SqlParameter()
                    {
                        ParameterName = "@ToDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpuntildate.SelectedDate
                    },
                                                   new SqlParameter()
                    {
                        ParameterName = "@RTRSN", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Decimal, Value = cmbResident.SelectedValue
                    },
                                                   new SqlParameter()
                    {
                        ParameterName = "@AccountNo", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Value = ddlAccountNumber.SelectedValue
                    });
                }
            }
            if (chkstatus.Checked == false)
            {
                if (cmbResident.SelectedValue == "0")
                {
                    dsStatement = sqlobj.ExecuteSP("SP_GetUnbilledTransactions",
                                                   new SqlParameter()
                    {
                        ParameterName = "@iMode", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int, Value = 1
                    },
                                                   new SqlParameter()
                    {
                        ParameterName = "@FromDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpfordate.SelectedDate
                    },
                                                   new SqlParameter()
                    {
                        ParameterName = "@ToDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpuntildate.SelectedDate
                    },
                                                   new SqlParameter()
                    {
                        ParameterName = "@RTRSN", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Decimal, Value = 1
                    },
                                                   new SqlParameter()
                    {
                        ParameterName = "@AccountNo", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Value = "NA"
                    });
                }
                else if (cmbResident.SelectedValue != "0")
                {
                    dsStatement = sqlobj.ExecuteSP("SP_GetUnbilledTransactions",
                                                   new SqlParameter()
                    {
                        ParameterName = "@iMode", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int, Value = 2
                    },
                                                   new SqlParameter()
                    {
                        ParameterName = "@FromDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpfordate.SelectedDate
                    },
                                                   new SqlParameter()
                    {
                        ParameterName = "@ToDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpuntildate.SelectedDate
                    },
                                                   new SqlParameter()
                    {
                        ParameterName = "@RTRSN", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Decimal, Value = cmbResident.SelectedValue
                    },
                                                   new SqlParameter()
                    {
                        ParameterName = "@AccountNo", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Value = ddlAccountNumber.SelectedValue
                    });
                }
            }

            if (dsStatement.Tables[0].Rows.Count > 0)
            {
                LoadOtherDet();
                ReportList.DataSource = dsStatement;
                ReportList.DataBind();
                ReportListAll.DataSource = dsStatement;
                ReportListAll.DataBind();
                lblDebitCnt.Text = Convert.ToString(dsStatement.Tables[0].Rows.Count);
            }
            else
            {
                lblDebitCnt.Visible  = false;
                lblCreditcnt.Visible = false;
                lblTCt.Visible       = false;
                lblLatTxnDt.Visible  = false;
                lblTDt.Visible       = false;
                lblTCt.Visible       = false;
                Label5.Visible       = false;
                Label6.Visible       = false;
                Label8.Visible       = false;
                Label10.Visible      = false;
                Label11.Visible      = false;

                ReportList.DataSource = string.Empty;
                ReportList.DataBind();
                ReportListAll.DataSource = string.Empty;
                ReportListAll.DataBind();
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "alert", "alert('No record for your selected date range.');", true);
            }



            //if (dsStatement.Tables[0].Rows.Count > 0)
            //{

            //    ReportList.DataSource = dsStatement;
            //    ReportList.DataBind();
            //}

            dsStatement.Dispose();


            DataSet dsdatewise = sqlobj.ExecuteSP("[SP_GetDatewiseDebitCreditTotal]",
                                                  new SqlParameter()
            {
                ParameterName = "@FromDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpfordate.SelectedDate
            },
                                                  new SqlParameter()
            {
                ParameterName = "@ToDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpuntildate.SelectedDate
            });

            if (dsdatewise.Tables[0].Rows.Count > 0)
            {
                decimal totdebit  = Convert.ToDecimal(dsdatewise.Tables[0].Rows[0]["TotalDebit"].ToString());
                decimal totcredit = Convert.ToDecimal(dsdatewise.Tables[0].Rows[0]["TotalCredit"].ToString());

                decimal FOutstading = totdebit - totcredit;
                String  SFOutstading;

                if (FOutstading < 0)
                {
                    SFOutstading = Convert.ToString(FOutstading * -1) + " CR";
                }
                else
                {
                    SFOutstading = Convert.ToString(FOutstading);
                }


                lbltotdebitcredit.Text = "Total Debit:" + totdebit.ToString("0.00") + "  Total Credit:" + totcredit.ToString("0.00");
                lbltotoutstanding.Text = DateTime.Now.ToString("dd/MM/yyyy HH:mm") + " Total Current Outstanding as of now :" + SFOutstading;
            }

            dsdatewise.Dispose();


            DataSet dsgetdebitcredittoal = sqlobj.ExecuteSP("[SP_GetFTDebitCreditTotal]");

            if (dsgetdebitcredittoal.Tables[0].Rows.Count > 0)
            {
                decimal totdebit  = Convert.ToDecimal(dsgetdebitcredittoal.Tables[0].Rows[0]["TotalDebit"].ToString());
                decimal totcredit = Convert.ToDecimal(dsgetdebitcredittoal.Tables[0].Rows[0]["TotalCredit"].ToString());

                //lbltotoutstanding.Text = DateTime.Now.ToString("dd/MM/yyyy HH:mm") + " Total Current Outstanding as of now :" + (totdebit - totcredit).ToString("0.00");
            }
            else
            {
                lbltotdebitcredit.Text = "";
            }


            dsgetdebitcredittoal.Dispose();
        }
        catch (Exception ex)
        {
            WebMsgBox.Show(ex.Message);
        }
    }
 protected void drpSessionfilters_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         DataSet dsStatement = new DataSet();
         if (drpSessionfilters.SelectedValue == "0")
         {
             BtnShow_Click(sender, e);
         }
         else
         {
             if (chkstatus.Checked == true)
             {
                 if (cmbResident.SelectedValue == "0")
                 {
                     dsStatement = sqlobj.ExecuteSP("SP_GetUnbilledTxnsFilter",
                                                    new SqlParameter()
                     {
                         ParameterName = "@iMode", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int, Value = 3
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@FromDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpfordate.SelectedDate
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@ToDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpuntildate.SelectedDate
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@RTRSN", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Decimal, Value = 1
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@AccountNo", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Value = "NA"
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@Session", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Value = drpSessionfilters.SelectedValue
                     }
                                                    );
                 }
                 else if (cmbResident.SelectedValue != "0")
                 {
                     dsStatement = sqlobj.ExecuteSP("SP_GetUnbilledTxnsFilter",
                                                    new SqlParameter()
                     {
                         ParameterName = "@iMode", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int, Value = 4
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@FromDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpfordate.SelectedDate
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@ToDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpuntildate.SelectedDate
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@RTRSN", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Decimal, Value = cmbResident.SelectedValue
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@AccountNo", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Value = ddlAccountNumber.SelectedValue
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@Session", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Value = drpSessionfilters.SelectedValue
                     });
                 }
             }
             if (chkstatus.Checked == false)
             {
                 if (cmbResident.SelectedValue == "0")
                 {
                     dsStatement = sqlobj.ExecuteSP("SP_GetUnbilledTxnsFilter",
                                                    new SqlParameter()
                     {
                         ParameterName = "@iMode", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int, Value = 1
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@FromDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpfordate.SelectedDate
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@ToDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpuntildate.SelectedDate
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@RTRSN", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Decimal, Value = 1
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@AccountNo", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Value = "NA"
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@Session", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Value = drpSessionfilters.SelectedValue
                     });
                 }
                 else if (cmbResident.SelectedValue != "0")
                 {
                     dsStatement = sqlobj.ExecuteSP("SP_GetUnbilledTxnsFilter",
                                                    new SqlParameter()
                     {
                         ParameterName = "@iMode", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int, Value = 2
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@FromDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpfordate.SelectedDate
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@ToDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Value = dtpuntildate.SelectedDate
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@RTRSN", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Decimal, Value = cmbResident.SelectedValue
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@AccountNo", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Value = ddlAccountNumber.SelectedValue
                     },
                                                    new SqlParameter()
                     {
                         ParameterName = "@Session", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Value = drpSessionfilters.SelectedValue
                     });
                 }
             }
             if (dsStatement.Tables[0].Rows.Count > 0)
             {
                 if (cmbResident.SelectedValue == "0")
                 {
                     ReportListAll.DataSource = dsStatement.Tables[0]; ReportListAll.DataBind();
                 }
                 else
                 {
                     ReportList.DataSource = dsStatement.Tables[0]; ReportList.DataBind();
                 }
             }
             else
             {
                 if (cmbResident.SelectedValue == "0")
                 {
                     ReportListAll.DataSource = string.Empty; ReportListAll.DataBind();
                 }
                 else
                 {
                     ReportList.DataSource = string.Empty; ReportList.DataBind();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "alert", "alert('" + ex.Message.ToString() + "');", true);
     }
 }