//private void BindGrid()
        //{

        //    SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString);

        //    {
        //        using (SqlCommand cmd = new SqlCommand("SP_Common")) //new SqlCommand("SELECT  AdmissionID, OrgID, ApplicationDate, FeesCategory, FirstName, MiddleName, LastName, Gender, BirthDate, BirthPlace, Address1, Address2, Taluka, Mobile, EMail,  Nationality, BloodGroup, Religion, GuardianName, Relation, GuardianMobile, GuardianEMail, ParentName, MotherName, ParentMobile, ParentEMail, LastInstitute,   Username, Password, Status, MotherTongue FROM  tblAdmissionDetails where OrgID='" + orgId.ToString() + "'"))
        //        {
        //            using (SqlDataAdapter sda = new SqlDataAdapter())
        //            {
        //                cmd.Connection = cn;
        //                cmd.CommandType = CommandType.StoredProcedure;
        //                cmd.Parameters.AddWithValue("@Action", "GetAdmin_AdmmisionReports");
        //                cmd.Parameters.AddWithValue("@OrgId", orgId.ToString());
        //                cmd.Parameters.AddWithValue("@CourseId", ddlCourse.SelectedValue.ToString());
        //                cmd.Parameters.AddWithValue("@BranchId", ddlBranch.SelectedValue.ToString());
        //                cmd.Parameters.AddWithValue("@ClassId", ddlClass.SelectedValue.ToString());
        //                cmd.Parameters.AddWithValue("@AcademicYear", ddlAcademicYear.SelectedValue.ToString());
        //                sda.SelectCommand = cmd;
        //                using (DataTable dt = new DataTable())
        //                {
        //                    sda.Fill(dt);
        //                    if (dt.Rows.Count > 0)
        //                    {
        //                        Panel1.Visible = true;
        //                        btnExport.Visible = true;
        //                        GridView1.DataSource = dt;
        //                        GridView1.DataBind();
        //                    }
        //                    else
        //                    {
        //                       GridView1.DataSource = null;
        //                        GridView1.DataBind();
        //                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Record not found !!!')", true);
        //                    }

        //                 }
        //            }
        //        }

        //    }
        //}

        private void BindGrid1()
        {
            try
            {
                string strquery = "SELECT UserCode, FirstName +' ' + MiddleName + ' ' + LastName AS StudentName, CourseName as Course,BranchName as Branch,TCL.ClassName as Class,TFC.FeesCategoryName as FeesCategory,AY.AcademicYear FROM tblStudent TS LEFT JOIN tblCourse TC ON TC.CourseId = TS.CourseId LEFT JOIN tblBranch TB ON TB.BranchId = TS.BranchId LEFT OUTER JOIN tblClass TCL ON TCL.ClassId = TS.ClassId LEFT JOIN tblAcademicYear AY ON AY.AcademicYearId = TS.AcademicYearId LEFT JOIN tblFeesCategory TFC ON TS.FeesCategory = TFC.FeesCategoryId Where TS.OrgId ='" + Session["OrgId"].ToString() + "'";

                if (ddlCourse.SelectedValue != "0")
                {
                    strquery = strquery + " And TC.CourseId = '" + ddlCourse.SelectedValue + "'";
                }

                if (ddlBranch.SelectedValue != "0")
                {
                    strquery = strquery + " And TB.BranchId = '" + ddlBranch.SelectedValue + "'";
                }

                if (ddlClass.SelectedValue != "0")
                {
                    strquery = strquery + " And TCL.ClassId = '" + ddlClass.SelectedValue + "'";
                }

                if (ddlAcademicYear.SelectedValue != "0")
                {
                    strquery = strquery + " And AY.AcademicYearId = '" + ddlAcademicYear.SelectedValue + "'";
                }

                if (ddlFeesCategory.SelectedValue != "0")
                {
                    strquery = strquery + " And TFC.FeesCategoryId = '" + ddlFeesCategory.SelectedValue + "'";
                }

                strquery = strquery + " order by UserCode asc";

                Session["strquery"] = strquery;

                database  db = new database();
                DataTable dt = db.DisplaygridView(strquery);

                if (dt.Rows.Count > 0)
                {
                    Panel1.Visible       = true;
                    btnExport.Visible    = true;
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                }
                else
                {
                    GridView1.DataSource = null;
                    GridView1.DataBind();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Record not found !!!')", true);
                }
            }
            catch (Exception ex)
            {
            }
        }
        protected void ddlSearchStudent_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                database  db = new database();
                DataTable dt = new DataTable();
                //string sql= "select pr.UserCode,pr.FirstName As StudentName,cr.CourseName,br.BranchName,pr.Mobile,pr.pemail as MailId,pr.Company_Name,pr.Company_Address,pr.Position from Placement_Registration pr INNER JOIN tblStudent st ON st.UserCode = pr.UserCode INNER JOIN tblCourse cr ON st.CourseId = cr.CourseId INNER JOIN tblBranch br ON st.BranchId = br.BranchId where pr.Status = '"+ ddlSearchStudent.SelectedValue.ToString() +"' And pr.OrgId = '"+ Convert.ToInt32(Session["OrgId"]) +"'";
                string sql = "select pr.FirstName As Name,pr.Mobile,pr.pemail as MailId,pr.Company_Name AS Company,pr.Company_Address as Address,pr.Position from Placement_Registration pr INNER JOIN tblStudent st ON st.UserCode = pr.UserCode where LTRIM(RTRIM(pr.Status)) = '" + ddlSearchStudent.SelectedValue.ToString() + "' And pr.OrgId = '" + ddlOrganization.SelectedValue + "'";
                dt = db.DisplaygridView(sql);

                grdStudent.DataSource = dt;
                grdStudent.DataBind();
            }
            catch (Exception ex) {
                //Response.Redirect("~/CMSHome.aspx");
            }
        }
        //lnkBtnDownload_Click
        #region lnkBtnDownload_Click

        protected void lnkBtnDownload_Click(object sender, EventArgs e)
        {
            //try
            //{
            lock (this)
            {
                LinkButton  lnkBtnId = (LinkButton)sender;
                GridViewRow grdrow   = lnkBtnId.NamingContainer as GridViewRow;
                string      TestId   = grdResults.DataKeys[grdrow.RowIndex].Values["TestId"].ToString();
                DataTable   ddt      = db.DisplaygridView("select UploadedFile from tblUploadResultPDF where TestId=" + TestId);

                byte[] bytes;
                string fileName, contentType;

                bytes       = (byte[])ddt.Rows[0]["UploadedFile"];
                contentType = grdResults.DataKeys[grdrow.RowIndex].Values["ContentType"].ToString();
                fileName    = grdResults.DataKeys[grdrow.RowIndex].Values["FileName"].ToString();

                Response.Clear();
                Response.Buffer  = true;
                Response.Charset = "";
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.ContentType = contentType;
                Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
                Response.BinaryWrite(bytes);
                Response.Flush();
                Response.End();

                msgBox.ShowMessage("Download Successfully !!!", "Download", UserControls.MessageBox.MessageStyle.Successfull);
            }
            //}
            //catch (Exception exp)
            //{
            //    GeneralErr(exp.Message.ToString());
            //}
        }
        private void BindGrid1()
        {
            try
            {
                Session["class"]    = "";
                Session["strquery"] = "";

                if (ddlCourse.SelectedValue != "0")
                {
                    Session["strquery"] = "  tblCourse.CourseId = '" + ddlCourse.SelectedValue + "'";;
                }

                if (ddlBranch.SelectedValue != "0")
                {
                    Session["class"]    = ddlBranch.SelectedValue;
                    Session["strquery"] = Session["strquery"].ToString() + " And tblBranch.BranchId = '" + ddlBranch.SelectedValue + "'";
                }

                if (ddlClass.SelectedValue != "0")
                {
                    Session["class"]    = Session["class"] + " (" + ddlClass.SelectedItem.ToString() + ")";
                    Session["strquery"] = Session["strquery"].ToString() + " And tblClass.ClassId = '" + ddlClass.SelectedValue + "'";
                }

                if (ddlAcademicYear.SelectedValue != "0")
                {
                    Session["AcademicYearId"] = " AY.AcademicYearId = '" + ddlAcademicYear.SelectedValue + "'";
                }

                //Session["class"] = ddlBranch.SelectedItem.ToString() + " (" + ddlClass.SelectedItem.ToString() + ")";
                string query = "";

                if (Session["strquery"].ToString() == "")
                {
                    //query = "with AllData as(SELECT  tblStudent.UserCode," +
                    //" (tblStudent.FirstName + ' ' + tblStudent.MiddleName + ' ' + tblStudent.LastName) as StudentName,(tblBranch.branchname +'('+tblClass.className+')')Class ,Convert(decimal(18,2),max(tblStudentFeesPaid.TotalAmount)) Total, " +
                    //" Convert(decimal(18,2),sum(tblStudentFeesPaid.PaidAmount)) Paid, Convert(decimal(18,2),(max(tblStudentFeesPaid.TotalAmount)-sum(tblStudentFeesPaid.PaidAmount))) Pending" +
                    //" FROM  tblStudent INNER JOIN tblStudentFeesPaid ON tblStudent.UserCode = tblStudentFeesPaid.StudentId" +
                    // " INNER JOIN tblCourse ON tblStudent.CourseId = tblCourse.CourseId" +
                    // " INNER JOIN tblBranch ON tblStudent.BranchId = tblBranch.BranchId" +
                    // " INNER JOIN tblClass ON tblStudent.ClassId = tblClass.ClassId" +
                    // " INNER JOIN tblAcademicYear AY ON AY.AcademicYearId = tblStudent.AcademicYearId" +
                    //" where  tblStudent.OrgId='" + orgId.ToString() + "' And " + Session["AcademicYearId"].ToString() + " group by UserCode,FirstName,MiddleName,LastName,tblBranch.branchname,tblClass.className" +
                    //" union all" +
                    //" SELECT  tblStudent.UserCode," +
                    //" (tblStudent.FirstName + ' ' + tblStudent.MiddleName + ' ' + tblStudent.LastName) as StudentName,(tblBranch.branchname +'('+tblClass.className+')')Class ,isnull(Convert(decimal(18,2),(SELECT Amount From tblRoute where RouteId=(SELECT RouteId from tblStudentRouteAssign where UserCode=tblStudent.UserCode))),0) Total, " +
                    //" isnull(Convert(decimal(18,2),sum(tblStudentBusFeesPaid.PaidAmount)),0) Paid, isnull(Convert(decimal(18,2),(tblStudentBusFeesPaid.TotalAmount-sum(tblStudentBusFeesPaid.PaidAmount))),0) Pending FROM" +
                    //"  tblStudent INNER JOIN tblStudentBusFeesPaid ON tblStudent.UserCode = tblStudentBusFeesPaid.StudentId" +
                    // " INNER JOIN tblCourse ON tblStudent.CourseId = tblCourse.CourseId" +
                    // " INNER JOIN tblBranch ON tblStudent.BranchId = tblBranch.BranchId" +
                    // " INNER JOIN tblClass ON tblStudent.ClassId = tblClass.ClassId" +
                    // " INNER JOIN tblAcademicYear AY ON AY.AcademicYearId = tblStudent.AcademicYearId" +
                    //" where tblStudent.OrgId='" + orgId.ToString() + "' And " + Session["AcademicYearId"].ToString() + " group by UserCode,FirstName,MiddleName,LastName,tblBranch.branchname,tblClass.className,TotalAmount)" +
                    //" select  UserCode,StudentName 'Student Name',Class,Sum(Total) 'Total Fees',Sum(Paid) 'Paid Fees',Sum(pending) 'Due Fees'" +
                    //" from AllData group by UserCode,StudentNAme,Class order by Class,UserCode";

                    query = "with AllData as(SELECT  tblStudent.UserCode as StudentCode," +

                            " (tblStudent.FirstName + ' ' + tblStudent.MiddleName + ' ' + tblStudent.LastName) as StudentName ,'School Fee ' FeesType ,Convert(decimal(18,2),max(tblStudentFeesPaid.TotalAmount)) Total, " +
                            " Convert(decimal(18,2),sum(tblStudentFeesPaid.PaidAmount)) Paid,(tblFeesCategory.FeesCategoryName) FeesCategory, Convert(decimal(18,2),(max(tblStudentFeesPaid.TotalAmount)-sum(tblStudentFeesPaid.PaidAmount))) Pending" +
                            " from tblFees INNER join tblStudentFeesPaid on  isnull(tblFees.FeesId,0)=isnull(tblStudentFeesPaid.FeesId,0) " +
                            " INNER join tblStudent ON isnull(tblStudent.UserCode,0) = isnull(tblStudentFeesPaid.StudentId,0)" +
                            " INNER JOIN tblCourse ON tblFees.CourseId = tblCourse.CourseId" +
                            " INNER JOIN tblBranch ON tblFees.BranchId = tblBranch.BranchId" +
                            " INNER JOIN tblClass ON tblFees.ClassId = tblClass.ClassId" +
                            " INNER JOIN tblAcademicYear AY ON AY.AcademicYearId = tblStudent.AcademicYearId " +
                            " INNER JOIN tblFeesCategory ON tblFeesCategory.FeesCategoryId=tblFees.CasteCategoryId " +
                            " where tblStudent.OrgId='" + orgId.ToString() + "'And tblFees.AcademicYearId='" + ddlAcademicYear.SelectedValue + "' and tblFees.CourseId='" + ddlCourse.SelectedValue + "' and tblFees.ClassId='" + ddlClass.SelectedValue + "' and tblFees.BranchId='" + ddlBranch.SelectedValue + "'group by UserCode,FirstName,MiddleName,LastName,TotalAmount,tblBranch.branchname,FeesCategoryName" +
                            " union all" +
                            " SELECT  tblStudent.UserCode as StudentCode," +
                            " (tblStudent.FirstName + ' ' + tblStudent.MiddleName + ' ' + tblStudent.LastName) as StudentName,'Bus Fee' as FeesType,isnull(Convert(decimal(18,2),(SELECT Amount From tblRoute where RouteId=(SELECT RouteId from tblStudentRouteAssign where UserCode=tblStudent.UserCode and courseId='" + ddlCourse.SelectedValue + "' and ClassId='" + ddlClass.SelectedValue + "' and BranchId='" + ddlBranch.SelectedValue + "' and AcademicYearId='" + ddlAcademicYear.SelectedValue + "'))),0) Total, " +
                            " isnull(Convert(decimal(18,2),sum(tblStudentBusFeesPaid.PaidAmount)),0) Paid, (tblFeesCategory.FeesCategoryName) FeesCategory, isnull(Convert(decimal(18,2),(tblStudentBusFeesPaid.TotalAmount-sum(tblStudentBusFeesPaid.PaidAmount))),0) Pending FROM" +
                            "  tblStudent INNER JOIN tblStudentBusFeesPaid ON tblStudent.UserCode = tblStudentBusFeesPaid.StudentId" +
                            " Inner Join tblStudentRouteAssign ON tblStudentRouteAssign.studentRouteId=tblStudentBusFeesPaid.StudentRouteId" +
                            " INNER JOIN tblCourse ON tblStudent.CourseId = tblCourse.CourseId" +
                            " INNER JOIN tblBranch ON tblStudent.BranchId = tblBranch.BranchId" +
                            " INNER JOIN tblClass ON tblStudent.ClassId = tblClass.ClassId" +
                            " INNER JOIN tblAcademicYear AY ON AY.AcademicYearId = tblStudent.AcademicYearId" +
                            " INNER JOIN tblFeesCategory ON tblFeesCategory.FeesCategoryId=tblStudent.FeesCategory " +
                            " where  AY.AcademicYearId= " + Session["AcademicYearId"].ToString() + " and tblStudentRouteAssign.CourseId='" + ddlCourse.SelectedValue + "' and tblStudentRouteAssign.ClassId='" + ddlClass.SelectedValue + "' and tblStudentRouteAssign.BranchId='" + ddlBranch.SelectedValue + "' group by UserCode,FirstName,MiddleName,LastName,tblBranch.branchname,TotalAmount,FeesCategoryName)" +
                            " select  StudentCode,StudentName 'Student Name',FeesCategory 'Fees Category' ,Sum(Total) 'Total Fees',Sum(Paid) 'Paid Fees',Sum(pending) 'Due Fees',FeesType 'FeesType'" +
                            " from AllData group by StudentCode,StudentNAme,FeesCategory,FeesType order by StudentCode";
                }
                else
                {
                    //query = "with AllData as(SELECT  tblStudent.UserCode," +
                    //" (tblStudent.FirstName + ' ' + tblStudent.MiddleName + ' ' + tblStudent.LastName) as StudentName,(tblBranch.branchname +'('+tblClass.className+')')Class ,Convert(decimal(18,2),max(tblStudentFeesPaid.TotalAmount)) Total, " +
                    //" Convert(decimal(18,2),sum(tblStudentFeesPaid.PaidAmount)) Paid, Convert(decimal(18,2),(max(tblStudentFeesPaid.TotalAmount)-sum(tblStudentFeesPaid.PaidAmount))) Pending" +
                    //" FROM  tblStudent INNER JOIN tblStudentFeesPaid ON tblStudent.UserCode = tblStudentFeesPaid.StudentId" +
                    // " INNER JOIN tblCourse ON tblStudent.CourseId = tblCourse.CourseId" +
                    // " INNER JOIN tblBranch ON tblStudent.BranchId = tblBranch.BranchId" +
                    // " INNER JOIN tblClass ON tblStudent.ClassId = tblClass.ClassId" +
                    // " INNER JOIN tblAcademicYear AY ON AY.AcademicYearId = tblStudent.AcademicYearId" +
                    //" where tblStudent.OrgId='" + orgId.ToString() + "' And " + Session["AcademicYearId"].ToString() + "  And " + Session["strquery"].ToString() + " group by UserCode,FirstName,MiddleName,LastName,tblBranch.branchname,tblClass.className" +
                    //" union all" +
                    //" SELECT  tblStudent.UserCode," +
                    //" (tblStudent.FirstName + ' ' + tblStudent.MiddleName + ' ' + tblStudent.LastName) as StudentName,(tblBranch.branchname +'('+tblClass.className+')')Class ,isnull(Convert(decimal(18,2),(SELECT Amount From tblRoute where RouteId=(SELECT RouteId from tblStudentRouteAssign where UserCode=tblStudent.UserCode))),0) Total, " +
                    //" isnull(Convert(decimal(18,2),sum(tblStudentBusFeesPaid.PaidAmount)),0) Paid, isnull(Convert(decimal(18,2),(tblStudentBusFeesPaid.TotalAmount-sum(tblStudentBusFeesPaid.PaidAmount))),0) Pending FROM" +
                    //"  tblStudent INNER JOIN tblStudentBusFeesPaid ON tblStudent.UserCode = tblStudentBusFeesPaid.StudentId" +
                    // " INNER JOIN tblCourse ON tblStudent.CourseId = tblCourse.CourseId" +
                    // " INNER JOIN tblBranch ON tblStudent.BranchId = tblBranch.BranchId" +
                    // " INNER JOIN tblClass ON tblStudent.ClassId = tblClass.ClassId" +
                    // " INNER JOIN tblAcademicYear AY ON AY.AcademicYearId = tblStudent.AcademicYearId" +
                    //" where  tblStudent.OrgId='" + orgId.ToString() + "' And " + Session["AcademicYearId"].ToString() + "  And " + Session["strquery"].ToString() + " group by UserCode,FirstName,MiddleName,LastName,TotalAmount,tblBranch.branchname,tblClass.className)" +
                    //" select  UserCode,StudentName 'Student Name',Class,Sum(Total) 'Total Fees',Sum(Paid) 'Paid Fees',Sum(pending) 'Due Fees'" +
                    //" from AllData group by UserCode,StudentNAme,Class order by Class,UserCode";

                    query = "with AllData as(SELECT  tblStudent.UserCode as StudentCode," +
                            " (tblStudent.FirstName + ' ' + tblStudent.MiddleName + ' ' + tblStudent.LastName) as StudentName ,'School Fee ' FeesType,Convert(decimal(18,2),max(tblStudentFeesPaid.TotalAmount)) Total, " +
                            " Convert(decimal(18,2),sum(tblStudentFeesPaid.PaidAmount)) Paid,(tblFeesCategory.FeesCategoryName) FeesCategory, Convert(decimal(18,2),(max(tblStudentFeesPaid.TotalAmount)-sum(tblStudentFeesPaid.PaidAmount))) Pending" +
                            " from tblFees INNER join tblStudentFeesPaid on  isnull(tblFees.FeesId,0)=isnull(tblStudentFeesPaid.FeesId,0) " +
                            " INNER join tblStudent ON isnull(tblStudent.UserCode,0) = isnull(tblStudentFeesPaid.StudentId,0)" +
                            " INNER JOIN tblCourse ON tblFees.CourseId = tblCourse.CourseId" +
                            " INNER JOIN tblBranch ON tblFees.BranchId = tblBranch.BranchId" +
                            " INNER JOIN tblClass ON tblFees.ClassId = tblClass.ClassId" +
                            " INNER JOIN tblAcademicYear AY ON AY.AcademicYearId = tblStudent.AcademicYearId " +
                            "INNER JOIN tblFeesCategory ON tblFeesCategory.FeesCategoryId=tblFees.CasteCategoryId" +
                            " where tblFees.OrgId='" + orgId.ToString() + "' And tblFees.AcademicYearId='" + ddlAcademicYear.SelectedValue + "' and tblFees.CourseId='" + ddlCourse.SelectedValue + "' and tblFees.ClassId='" + ddlClass.SelectedValue + "' and tblFees.BranchId='" + ddlBranch.SelectedValue + "'group by tblStudent.UserCode,FirstName,MiddleName,LastName,TotalAmount,tblBranch.branchname,FeesCategoryName" +
                            " union all" +
                            " SELECT  tblStudent.UserCode as StudentCode," +
                            " (tblStudent.FirstName + ' ' + tblStudent.MiddleName + ' ' + tblStudent.LastName) as StudentName ,'Bus Fee' as FeesType,isnull(Convert(decimal(18,2),(SELECT Amount From tblRoute where RouteId=(SELECT RouteId from tblStudentRouteAssign where UserCode=tblStudent.UserCode and courseId='" + ddlCourse.SelectedValue + "' and ClassId='" + ddlClass.SelectedValue + "' and BranchId='" + ddlBranch.SelectedValue + "' and AcademicYearId='" + ddlAcademicYear.SelectedValue + "'))),0) Total, " +
                            " isnull(Convert(decimal(18,2),sum(tblStudentBusFeesPaid.PaidAmount)),0) Paid,(tblFeesCategory.FeesCategoryName) FeesCategory,  isnull(Convert(decimal(18,2),(tblStudentBusFeesPaid.TotalAmount-sum(tblStudentBusFeesPaid.PaidAmount))),0) Pending FROM" +
                            "  tblStudent INNER JOIN tblStudentBusFeesPaid ON tblStudent.UserCode = tblStudentBusFeesPaid.StudentId" +
                            " Inner Join tblStudentRouteAssign ON tblStudentRouteAssign.studentRouteId=tblStudentBusFeesPaid.StudentRouteId" +
                            " INNER JOIN tblCourse ON tblStudentRouteAssign.CourseId = tblCourse.CourseId" +
                            " INNER JOIN tblBranch ON tblStudentRouteAssign.BranchId = tblBranch.BranchId" +
                            " INNER JOIN tblClass ON tblStudentRouteAssign.ClassId = tblClass.ClassId" +
                            " INNER JOIN tblAcademicYear AY ON AY.AcademicYearId = tblStudentRouteAssign.AcademicYearId" +
                            //" INNER JOIN tblFees  ON tblFees.FeesId=tblStudentBusFeesPaid.BusFeesId" +
                            " INNER JOIN tblFeesCategory ON tblFeesCategory.FeesCategoryId=tblStudent.FeesCategory" +
                            " where tblStudent.OrgId='" + orgId.ToString() + "' And " + Session["AcademicYearId"].ToString() + " and tblStudentRouteAssign.CourseId='" + ddlCourse.SelectedValue + "' and tblStudentRouteAssign.ClassId='" + ddlClass.SelectedValue + "' and tblStudentRouteAssign.BranchId='" + ddlBranch.SelectedValue + "'group by tblStudent.UserCode,FirstName,MiddleName,LastName,TotalAmount,tblBranch.branchname,FeesCategoryName)" +
                            " select  StudentCode,StudentName 'Student Name',FeesCategory 'Fees Category',Sum(Total) 'Total Fees',Sum(Paid) 'Paid Fees',Sum(pending) 'Due Fees',FeesType 'FeesType'" +
                            " from AllData group by StudentCode,StudentNAme,FeesCategory,FeesType order by StudentCode";
                }

                Session["Staff"]     = "StudentFeesStatus";
                Session["strquery1"] = query;

                database  db = new database();
                DataTable dt = db.DisplaygridView(query);

                if (dt.Rows.Count > 0)
                {
                    Panel1.Visible    = true;
                    btnExport.Visible = true;
                    //  lblStatus.Text = Session["class"].ToString();
                    // lblStatus.Text = ddlCourse.SelectedValue;
                    lblStatus.Text        = ":" + ddlCourse.SelectedItem.Text + " " + ddlBranch.SelectedItem.Text + " " + ddlClass.SelectedItem.Text + " ( " + ddlAcademicYear.SelectedItem.Text + " ) ";
                    Session["CourseName"] = lblStatus.Text;
                    GridView1.DataSource  = dt;
                    GridView1.DataBind();
                }
                else
                {
                    GridView1.DataSource = null;
                    GridView1.DataBind();
                    // lblStatus.Text = Session["class"].ToString();
                    lblStatus.Text        = ":" + ddlCourse.SelectedItem.Text + " " + ddlBranch.SelectedItem.Text + " " + ddlClass.SelectedItem.Text + " ( " + ddlAcademicYear.SelectedItem.Text + " ) ";
                    Session["CourseName"] = lblStatus.Text;
                    btnExport.Visible     = false;
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Record not found !!!')", true);
                }
            }
            catch (Exception ex)
            {
            }
        }