protected void btnExcel_Click(object sender, EventArgs e) { try { string print = ""; string appPath = HttpContext.Current.Server.MapPath("~"); string strexcelname = ""; if (appPath != "") { strexcelname = txtexcelname.Text; appPath = appPath.Replace("\\", "/"); if (strexcelname != "") { print = strexcelname; string szPath = appPath + "/Report/"; string szFile = print + ".xls"; // + DateTime.Now.ToString("yyyyMMddHHmmss") FpExternal.SaveExcel(szPath + szFile, FarPoint.Web.Spread.Model.IncludeHeaders.ColumnHeadersCustomOnly); Response.Clear(); Response.ClearHeaders(); Response.ClearContent(); Response.AddHeader("Content-Disposition", "attachment; filename=" + szFile); Response.ContentType = "application/vnd.ms-excel"; Response.Flush(); Response.WriteFile(szPath + szFile); //============================================= } else { lblnorec.Text = "Please enter your Report Name"; lblnorec.Visible = true; } } } catch (Exception ex) { lblnorec.Text = ex.ToString(); } }
protected void btnGo_Click(object sender, EventArgs e) { //try //{ string befvalstudentsappeared = ""; string befvalpassedstudent = ""; string aftvalstudentappeared = ""; string aftvalpassedstudent = ""; string beforevalpercentage = ""; string aftervaluepercentage = ""; string beforeoverall = ""; string afteroverall = ""; string beforoverallpercentage = ""; string afteroverallpercentage = ""; int sno = 0; bindspread(); if (ddlSec.Enabled == false) { section = ""; } else { if (ddlSec.SelectedItem.Text == "ALL") { section = ""; } else { section = ddlSec.SelectedItem.Text; } } degree_code = ddlBranch.SelectedValue.ToString(); yr_val = ddlSemYr.SelectedItem.ToString(); getyear(); current_sem = ddlSemYr.SelectedValue.ToString(); batch_year = ddlBatch.SelectedValue.ToString(); ExamCode = Get_UnivExamCode(Convert.ToInt32(degree_code), GetSemester_AsNumber(Convert.ToInt32(current_sem)), Convert.ToInt32(batch_year)); exam_month = ddlMonth.SelectedValue.ToString(); exam_year = ddlYear.SelectedItem.ToString(); string strsubject = ""; string getgradeflag = ""; if (ExamCode != 0) { string grade = "select grade_flag from grademaster where degree_code=" + degree_code + " and batch_year='" + batch_year + "' and exam_month=" + exam_month + " and exam_year= " + exam_year + ""; con.Close(); con.Open(); SqlDataReader drgrade; newcon.Close(); newcon.Open(); SqlCommand cmd_grade = new SqlCommand(grade, newcon); drgrade = cmd_grade.ExecuteReader(); int gradecheckcount = 0; while (drgrade.Read()) { getgradeflag = drgrade["grade_flag"].ToString(); if (ddlSec.Enabled == false || ddlSec.SelectedItem.Text == "ALL") { strsubject = "Select distinct st.staff_code,sm.staff_name, s.mintotal as mintot,s.min_int_marks as mimark, s.min_ext_marks as mxmark,s.maxtotal as maxtot,s.acronym as subacr,subject_name,subject_code as Subject_Code,mark_entry.subject_no as Subject_No,semester,subject_type as Subtype,credit_points from Mark_Entry,Subject s,sub_sem,syllabus_master,staff_selector st,staffmaster sm where syllabus_master.syll_code=s.syll_code and Mark_Entry.Subject_No = s..Subject_No and s.subtype_no= sub_sem.subtype_no and sm.staff_code=st.staff_code and Exam_Code = '" + ExamCode + "' and attempts=1 and st.subject_no=s.subject_no order by semester desc,subject_type desc, mark_entry.subject_no asc"; } else { strsubject = "Select distinct st.staff_code,sm.staff_name, s.mintotal as mintot,s.maxtotal as maxtot,s.min_int_marks as mimark, s.min_ext_marks as mxmark,s.acronym as subacr,subject_name,subject_code as Subject_Code,mark_entry.subject_no as Subject_No,semester,subject_type as Subtype,credit_points from Mark_Entry,Subject s,sub_sem,syllabus_master,staff_selector st,staffmaster sm,registration r where syllabus_master.syll_code=s.syll_code and Mark_Entry.Subject_No = s.Subject_No and s.subtype_no= sub_sem.subtype_no and sm.staff_code=st.staff_code and Exam_Code = '" + ExamCode + "' and mark_entry.attempts=1 and st.subject_no=s.subject_no and st.sections=r.sections and r.sections='" + ddlSec.SelectedItem.Text + "' and r.batch_year='" + ddlBatch.SelectedItem.Text + "' and r.degree_code='" + ddlBranch.SelectedValue.ToString() + "' order by semester desc,subject_type desc, mark_entry.subject_no asc"; } con.Close(); con.Open(); SqlCommand cmd_loadSub = new SqlCommand(strsubject, con); SqlDataReader dr_loadSub; dr_loadSub = cmd_loadSub.ExecuteReader(); while (dr_loadSub.Read()) { gradecheckcount++; if (Convert.ToInt32(getgradeflag) == 1) { sno++; FpExternal.Sheets[0].RowCount = FpExternal.Sheets[0].RowCount + 1; int rc = FpExternal.Sheets[0].RowCount - 1; FpExternal.Sheets[0].Cells[rc, 0].Text = sno.ToString(); FpExternal.Sheets[0].Cells[rc, 0].Tag = dr_loadSub["mintot"].ToString(); FpExternal.Sheets[0].Cells[rc, 0].HorizontalAlign = HorizontalAlign.Center; FpExternal.Sheets[0].Cells[rc, 1].Text = dr_loadSub["Subject_Code"].ToString(); FpExternal.Sheets[0].Cells[rc, 1].Tag = dr_loadSub["Subject_No"].ToString(); FpExternal.Sheets[0].Cells[rc, 2].Text = dr_loadSub["Subject_name"].ToString(); FpExternal.Sheets[0].Cells[rc, 2].Tag = dr_loadSub["mimark"].ToString(); FpExternal.Sheets[0].Cells[rc, 3].Text = dr_loadSub["staff_name"].ToString(); FpExternal.Sheets[0].Cells[rc, 3].Tag = dr_loadSub["mxmark"].ToString(); } if (Convert.ToInt32(getgradeflag) == 2) { sno++; FpExternal.Sheets[0].RowCount = FpExternal.Sheets[0].RowCount + 1; int rc = FpExternal.Sheets[0].RowCount - 1; FpExternal.Sheets[0].Cells[rc, 0].Text = sno.ToString(); FpExternal.Sheets[0].Cells[rc, 0].Tag = dr_loadSub["mintot"].ToString(); FpExternal.Sheets[0].Cells[rc, 0].HorizontalAlign = HorizontalAlign.Center; FpExternal.Sheets[0].Cells[rc, 1].Text = dr_loadSub["Subject_Code"].ToString(); FpExternal.Sheets[0].Cells[rc, 1].Tag = dr_loadSub["Subject_No"].ToString(); FpExternal.Sheets[0].Cells[rc, 2].Text = dr_loadSub["Subject_name"].ToString(); FpExternal.Sheets[0].Cells[rc, 2].Tag = dr_loadSub["mimark"].ToString(); FpExternal.Sheets[0].Cells[rc, 3].Text = dr_loadSub["staff_name"].ToString(); FpExternal.Sheets[0].Cells[rc, 3].Tag = dr_loadSub["mxmark"].ToString(); } } } if (gradecheckcount != 0) { FpExternal.SaveChanges(); for (int chk = 0; chk <= FpExternal.Sheets[0].RowCount - 1; chk++) { befvalstudentsappeared = ""; befvalpassedstudent = ""; aftvalstudentappeared = ""; aftvalpassedstudent = ""; beforevalpercentage = ""; aftervaluepercentage = ""; beforeoverall = ""; afteroverall = ""; beforoverallpercentage = ""; afteroverallpercentage = ""; string subno = FpExternal.Sheets[0].Cells[chk, 1].Tag.ToString(); if (!string.IsNullOrEmpty(subno)) { } int subjectno = Convert.ToInt32(FpExternal.Sheets[0].Cells[chk, 1].Tag.ToString()); int gradeflag = Convert.ToInt32(getgradeflag); double minintmark = Convert.ToInt32(FpExternal.Sheets[0].Cells[chk, 2].Tag.ToString()); double minextmark = Convert.ToInt32(FpExternal.Sheets[0].Cells[chk, 3].Tag.ToString()); double mintot = Convert.ToInt32(FpExternal.Sheets[0].Cells[chk, 0].Tag.ToString()); con.Close(); con.Open(); SqlCommand studinfo = new SqlCommand("spbeforeandafterrevaluation", con); studinfo.CommandType = CommandType.StoredProcedure; studinfo.Parameters.AddWithValue("@degreecode", degree_code); studinfo.Parameters.AddWithValue("@batchyear", batch_year); studinfo.Parameters.AddWithValue("@semester", current_sem); studinfo.Parameters.AddWithValue("@subject_no", subjectno); studinfo.Parameters.AddWithValue("@examcode", ExamCode); studinfo.Parameters.AddWithValue("@Section", section); studinfo.Parameters.AddWithValue("@gradeflag", gradeflag); studinfo.Parameters.AddWithValue("@minintmark", minintmark); studinfo.Parameters.AddWithValue("@minextmark", minextmark); studinfo.Parameters.AddWithValue("@mintot", mintot - 1); SqlDataAdapter studinfoada = new SqlDataAdapter(studinfo); DataSet studinfoads = new DataSet(); studinfoada.Fill(studinfoads); if (studinfoads.Tables[0].Rows.Count > 0) { for (int cnt = 0; cnt < studinfoads.Tables[0].Rows.Count; cnt++) { befvalstudentsappeared = studinfoads.Tables[0].Rows[cnt][0].ToString(); befvalpassedstudent = studinfoads.Tables[1].Rows[cnt][0].ToString(); aftvalstudentappeared = befvalstudentsappeared; aftvalpassedstudent = studinfoads.Tables[2].Rows[cnt][0].ToString(); beforeoverall = studinfoads.Tables[3].Rows[cnt][0].ToString(); afteroverall = studinfoads.Tables[4].Rows[cnt][0].ToString(); if (befvalstudentsappeared != "0") { passpercent1 = Convert.ToDouble((Convert.ToDouble(befvalpassedstudent) / Convert.ToDouble(befvalstudentsappeared)) * 100); double passpercent2 = Math.Round(passpercent1, 2); beforevalpercentage = Convert.ToString(passpercent2); } if (aftvalstudentappeared != "0") { double passpercent1 = 0; passpercent1 = Convert.ToDouble((Convert.ToDouble(aftvalpassedstudent) / Convert.ToDouble(aftvalstudentappeared)) * 100); double passpercent2 = Math.Round(passpercent1, 2); aftervaluepercentage = Convert.ToString(passpercent2); } if (beforeoverall != "0") { double passpercent1 = 0; passpercent1 = Convert.ToDouble((Convert.ToDouble(beforeoverall) / Convert.ToDouble(aftvalstudentappeared)) * 100); double passpercent2 = Math.Round(passpercent1, 2); passpercent3 = passpercent3 + passpercent2; beforoverallpercentage = Convert.ToString(passpercent3); } if (afteroverall != "0") { passpercent1 = Convert.ToDouble((Convert.ToDouble(afteroverall) / Convert.ToDouble(aftvalstudentappeared)) * 100); double passpercent2 = Math.Round(passpercent1, 2); passpercent4 = passpercent4 + passpercent2; afteroverallpercentage = Convert.ToString(passpercent4); } } FpExternal.Sheets[0].Cells[chk, 4].Text = befvalstudentsappeared.ToString(); FpExternal.Sheets[0].Cells[chk, 4].HorizontalAlign = HorizontalAlign.Center; FpExternal.Sheets[0].Cells[chk, 5].Text = befvalpassedstudent.ToString(); FpExternal.Sheets[0].Cells[chk, 5].HorizontalAlign = HorizontalAlign.Center; FpExternal.Sheets[0].Cells[chk, 6].Text = beforevalpercentage.ToString(); FpExternal.Sheets[0].Cells[chk, 6].HorizontalAlign = HorizontalAlign.Center; FpExternal.Sheets[0].Cells[chk, 7].Text = aftvalstudentappeared.ToString(); FpExternal.Sheets[0].Cells[chk, 7].HorizontalAlign = HorizontalAlign.Center; FpExternal.Sheets[0].Cells[chk, 8].Text = aftvalpassedstudent.ToString(); FpExternal.Sheets[0].Cells[chk, 8].HorizontalAlign = HorizontalAlign.Center; FpExternal.Sheets[0].Cells[chk, 9].Text = aftervaluepercentage.ToString(); FpExternal.Sheets[0].Cells[chk, 9].HorizontalAlign = HorizontalAlign.Center; } } FpExternal.Sheets[0].RowCount = FpExternal.Sheets[0].RowCount + 1; double afteroverallpercentage1 = Convert.ToDouble(afteroverallpercentage) / sno; double overallafter = Math.Round(afteroverallpercentage1, 2); double beforoverallpercentage1 = Convert.ToDouble(beforoverallpercentage) / sno; double overbefore = Math.Round(beforoverallpercentage1, 2); FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 0].Text = "Overall"; FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 0].HorizontalAlign = HorizontalAlign.Center; FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 0].Font.Bold = true; FpExternal.Sheets[0].SpanModel.Add(FpExternal.Sheets[0].RowCount - 1, 0, 1, 4); FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 4].Text = befvalstudentsappeared.ToString(); FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 4].HorizontalAlign = HorizontalAlign.Center; FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 5].Text = beforeoverall.ToString(); FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 5].HorizontalAlign = HorizontalAlign.Center; FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 6].Text = overbefore.ToString(); FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 6].HorizontalAlign = HorizontalAlign.Center; FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 7].Text = befvalstudentsappeared.ToString(); FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 7].HorizontalAlign = HorizontalAlign.Center; FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 8].Text = afteroverall.ToString(); FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 8].HorizontalAlign = HorizontalAlign.Center; FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 9].Text = overallafter.ToString(); FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 9].HorizontalAlign = HorizontalAlign.Center; FpExternal.Sheets[0].RowCount = FpExternal.Sheets[0].RowCount + 1; FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 0].Text = "Department OverAll Pass%(" + yr_string + ")"; FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 0].Font.Bold = true; FpExternal.Sheets[0].SpanModel.Add(FpExternal.Sheets[0].RowCount - 1, 0, 1, FpExternal.Sheets[0].ColumnCount); FpExternal.Sheets[0].RowCount++; FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 0].Text = "Before Revaluation:" + overbefore + " "; FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 0].Font.Bold = true; FpExternal.Sheets[0].SpanModel.Add(FpExternal.Sheets[0].RowCount - 1, 0, 1, FpExternal.Sheets[0].ColumnCount); FpExternal.Sheets[0].RowCount++; FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 0].Text = "After Revaluation:" + overallafter + " "; FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 0].Font.Bold = true; FpExternal.Sheets[0].SpanModel.Add(FpExternal.Sheets[0].RowCount - 1, 0, 1, FpExternal.Sheets[0].ColumnCount); FpExternal.Sheets[0].RowCount = FpExternal.Sheets[0].RowCount + 1; FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 0].Text = "HOD"; FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 0].Font.Bold = true; FpExternal.Sheets[0].SpanModel.Add(FpExternal.Sheets[0].RowCount - 1, 0, 1, 5); FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 0].HorizontalAlign = HorizontalAlign.Center; FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 5].Text = "PRINCIPAL"; FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 5].Font.Bold = true; FpExternal.Sheets[0].SpanModel.Add(FpExternal.Sheets[0].RowCount - 1, 5, 1, FpExternal.Sheets[0].ColumnCount); FpExternal.Sheets[0].Cells[FpExternal.Sheets[0].RowCount - 1, 5].HorizontalAlign = HorizontalAlign.Center; FpExternal.Sheets[0].PageSize = FpExternal.Sheets[0].RowCount; FpExternal.SaveChanges(); } else { } } else { FpExternal.Visible = false; btnExcel.Visible = false; txtexcelname.Visible = false; lblrptname.Visible = false; btnprintmaster.Visible = false; lblerrormsg.Text = "No record found"; lblerrormsg.Visible = true; } //} //catch (Exception ex) //{ //} }