protected void btnGetSummary_Click(object sender, EventArgs e)
        {
            using (SqlConnection con = new SqlConnection(cs))
            {
                SqlCommand csm = new SqlCommand("SELECT distinct Students.Batch, Session.SessionName, StudentFeeStatus.Rollno, StudentFeeStatus.Status, StudentFeeStatus.Semester FROM     Session INNER JOIN StudentFeeStatus ON Session.SessionId = StudentFeeStatus.SessionId INNER JOIN  Students ON StudentFeeStatus.Rollno = Students.Rollno where Students.DepttId = @depttid and SessionName =@sessionName and Batch = @batch", con);

                csm.Parameters.AddWithValue("@depttid", FeeHelper2.ConvertDepartmentNameToId(ddlDepttName.Text));
                csm.Parameters.AddWithValue("@sessionName", ddlSessionName.Text);
                csm.Parameters.AddWithValue("@batch", ddlBatch.Text);
                con.Open();
                SqlDataReader rdr = csm.ExecuteReader();

                gvStudentFeeStatusAdmin.DataSource = rdr;
                gvStudentFeeStatusAdmin.DataBind();
            }
        }
        private void GetFeeAmountFrosmb()
        {
            ddlSessionName.Items.Clear();



            SqlConnection con = new SqlConnection(cs);
            SqlCommand    csm = new SqlCommand("select SessionId from dbo.MasterFee where YearOfAdmission = @yearofadmission and DepttId = @depttid", con);

            csm.Parameters.AddWithValue("@yearofadmission", lblBatch.Text);
            csm.Parameters.AddWithValue("@depttid", FeeHelper2.ConvertDepartmentNameToId(lblDepttName.Text));

            try
            {
                ListItem newItem = new ListItem();
                newItem.Text  = "<Select Session>";
                newItem.Value = "0";
                ddlSessionName.Items.Add(newItem);

                con.Open();

                SqlDataReader rdr = csm.ExecuteReader();
                while (rdr.Read())
                {
                    newItem      = new ListItem();
                    newItem.Text = StudentFeeHelper.ConvertSessionIdToSessionName(rdr["SessionId"].ToString());
                    ddlSessionName.Items.Add(newItem);
                    //ddlSessionName.DataValueField = rdr["SessionId"].ToString();
                }
                rdr.Close();
            }
            catch (Exception)
            {
            }
            finally
            {
                con.Close();
            }
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                string tmpsql = "";

                using (SqlConnection con = new SqlConnection(cs))
                {
                    int i = 0;
                    foreach (TableRow objrow in tblresult.Rows)

                    {
                        if (i == 0)
                        {
                            i += 1;
                            continue;
                        }

                        i += 1;


                        objtext = (TextBox)objrow.Cells[3].FindControl("fee" + Convert.ToString(i - 1));

                        if (objtext == null)
                        {
                            continue;
                        }


                        objtext2 = (TextBox)objrow.Cells[4].FindControl("hfee" + Convert.ToString(i - 1));

                        if (objtext2 == null)
                        {
                            continue;
                        }

                        //tmpsql += "insert into masterfee () values () " + objtext2.Text + " ";



                        tmpsql += "insert into dbo.MasterFee values(" + objrow.Cells[0].Text + "," + FeeHelper.convertsessionnametoid(objrow.Cells[1].Text) + "," + FeeHelper2.ConvertDepartmentNameToId(objrow.Cells[2].Text) + ", " + objtext.Text + "," + objtext2.Text + ");";
                    }
                    SqlCommand csm = new SqlCommand(tmpsql, con);
                    con.Open();
                    csm.ExecuteNonQuery();
                    con.Close();
                }



                // Response.Write(tmpsql);
                // Response.Redirect("~/Admin/View_Fee.aspx");



                //Response.Write(tmpsql);
            }
            catch (Exception)
            {
            }
            finally
            {
                Response.Redirect("~/Admin/View_Fee.aspx");
            }
        }
        protected void btnGetPdf_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection con;
                if (ddlFeeType.Text == "Examination Fee")
                {
                    using (con = new SqlConnection(cs))
                    {
                        SqlCommand cmd = new SqlCommand("select ExaminationFeeAmount from dbo.MasterFee where YearOfAdmission=@yoa and SessionId=@sessionid and DepttId=@depttid", con);
                        cmd.Parameters.AddWithValue("@yoa", ddlBatch.Text);
                        cmd.Parameters.AddWithValue("@sessionid", FeeHelper.convertsessionnametoid(ddlSessionName.Text));
                        cmd.Parameters.AddWithValue("@depttid", FeeHelper2.ConvertDepartmentNameToId(ddlDepttName.Text));
                        con.Open();
                        SqlDataReader rdr = cmd.ExecuteReader();
                        if (rdr.Read())
                        {
                            lbltempfee.Text = rdr["ExaminationFeeAmount"].ToString();
                        }
                    }
                }
                if (ddlFeeType.Text == "Tution Fee")
                {
                    using (con = new SqlConnection(cs))
                    {
                        SqlCommand cmd = new SqlCommand("select TutionFeeAmount from dbo.MasterFee where YearOfAdmission=@yoa and SessionId=@sessionid and DepttId=@depttid", con);
                        cmd.Parameters.AddWithValue("@yoa", ddlBatch.Text);
                        cmd.Parameters.AddWithValue("@sessionid", FeeHelper.convertsessionnametoid(ddlSessionName.Text));
                        cmd.Parameters.AddWithValue("@depttid", FeeHelper2.ConvertDepartmentNameToId(ddlDepttName.Text));
                        con.Open();
                        SqlDataReader rdr = cmd.ExecuteReader();
                        if (rdr.Read())
                        {
                            lbltempfee.Text = rdr["TutionFeeAmount"].ToString();
                        }
                    }
                }
            }
            catch (Exception)
            {
            }

            try
            {
                using (SqlConnection con = new SqlConnection(cs))
                {
                    SqlCommand cmd = new SqlCommand("SELECT distinct StudentFeeStatus.txn_id as Id, Students.StudentFullName as Student_Name, Students.Rollno, Deptts.DepttShortName as Department, Students.Batch, Session.SessionName as Session, StudentFeeStatus.FeeAmount as Amount, StudentFeeStatus.Semester, StudentFeeStatus.TimeStamp as Date_Paid FROM StudentFeeStatus INNER JOIN Session ON StudentFeeStatus.SessionId = Session.SessionId INNER JOIN Students ON StudentFeeStatus.Rollno = Students.Rollno CROSS JOIN Deptts where Deptts.DepttID=@depttid and SessionName = @sessionName and Batch = @batch and StudentFeeStatus.Status = 'completed' and FeeAmount=@feeamount", con);
                    cmd.Parameters.AddWithValue("@depttid", FeeHelper2.ConvertDepartmentNameToId(ddlDepttName.Text));
                    cmd.Parameters.AddWithValue("@sessionName", ddlSessionName.Text);
                    cmd.Parameters.AddWithValue("@batch", ddlBatch.Text);
                    cmd.Parameters.AddWithValue("@feeamount", lbltempfee.Text);
                    con.Open();
                    SqlDataReader rdr = cmd.ExecuteReader();

                    gvStudentFeeRecieptAdmin.DataSource = rdr;
                    gvStudentFeeRecieptAdmin.DataBind();
                }
            }
            catch (Exception)
            {
            }
        }