protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int studId = CurrentSession.CurrStudent.StudentId; int CourseId = CurrentSession.CurrStudent.Product.UniqueId; int SemId = CurrentSession.CurrStudent.ExamResultDetail.Semester.SemesterId; int SchId = CurrentSession.CurrStudent.ExSchId; int ResDetId = CurrentSession.CurrStudent.ExamResultDetail.ExmResultDetailId; bool isModExam = CurrentSession.CurrStudent.isModExam; ExamUserComponent euc = new ExamUserComponent(); int success = 0; success = euc.GenerateQuestions(studId, CourseId, SchId, ResDetId, SemId, isModExam); rdbtnQuesNo.DataSource = euc.GetQuestionaires(1, "1", 1, studId, ResDetId, 0, 0, isModExam); rdbtnQuesNo.DataBind(); rdbtnQuesNo.SelectedIndex = 0; //GetQuestions(); int SeqNo = Convert.ToInt32(rdbtnQuesNo.SelectedItem.Text); SaveAnswerAndGetQuestion(1, "NoSave", 1, studId, ResDetId, SeqNo, 0, isModExam); divPrev.Visible = false; CurrentSession.ExamPrevId = rdbtnQuesNo.SelectedValue; //hdnPrevExamDetId.Value = rdbtnQuesNo.SelectedValue; //Session["PrevExamDetId"] = rdbtnQuesNo.SelectedValue; //ViewState["seconds"] = 0; hdnDuration.Value = CurrentSession.CurrStudent.Duration.ToString(); } }
private void SaveReport() { //clsNum2Word csw = new clsNum2Word(); ExamUserComponent ec = new ExamUserComponent(); int ResDetId = CurrentSession.CurrStudent.ExamResultDetail.ExmResultDetailId; int StudId = CurrentSession.CurrStudent.StudentId; string FileName = CurrentSession.FileName.ToString(); bool isModExam = CurrentSession.CurrStudent.isModExam; DataSet dsComp = ec.GetCompInfo(); DataSet dsExamRes = ec.GetExamResultPrint(ResDetId, StudId, 1, false); DataSet dsExResSum = ec.GetExamResultPrint(ResDetId, StudId, 2, false); Microsoft.Reporting.WebForms.ReportViewer rview = new Microsoft.Reporting.WebForms.ReportViewer(); rview.ProcessingMode = ProcessingMode.Local; rview.LocalReport.ReportPath = Server.MapPath("~/eReports/Rdlc/rpt_examResult.rdlc"); rview.LocalReport.DataSources.Clear(); rview.LocalReport.DataSources.Add(new ReportDataSource("dsCompInfo", dsComp.Tables[0])); rview.LocalReport.DataSources.Add(new ReportDataSource("dsResPrint", dsExamRes.Tables[0])); rview.LocalReport.DataSources.Add(new ReportDataSource("dsExamSum", dsExResSum.Tables[0])); rview.LocalReport.Refresh(); string mimeType, encoding, extension, deviceInfo; string[] streamids; Microsoft.Reporting.WebForms.Warning[] warnings; //Desired format goes here (PDF, Excel, or Image) deviceInfo = "<DeviceInfo>" + "<SimplePageHeaders>True</SimplePageHeaders>" + "</DeviceInfo>"; byte[] bytes = rview.LocalReport.Render("PDF", deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings); Response.Clear(); System.IO.FileStream oFileStream = null; string strFilePath = string.Empty; //strFilePath = ConfigurationManager.AppSettings["AttachFile"].ToString() + FileName + ".pdf";// Server.MapPath("../EmailAttachments/" + filename1 + ".pdf"); //strFilePath = strFilePath.Replace("\\\\", "\\"); strFilePath = Server.MapPath("~/AttachFile/" + FileName + ".pdf"); oFileStream = new System.IO.FileStream(strFilePath, System.IO.FileMode.Create); oFileStream.Write(bytes, 0, bytes.Length); oFileStream.Close(); //string script = string.Format("~/eReports/PdfReport.aspx?FileName={0}", FileName); //ScriptManager.RegisterStartupScript(this, this.GetType(), "openprintwindow", "javascript:window.open('" + ResolveClientUrl(script) + "',null,'width=850px,height=630px,scrollbars=yes,,resizable=yes,toolbar=no,menubar=no,location=no');", true); }
protected void btnSubmit_Click(object sender, EventArgs e) { //Response.Redirect("Welcome.aspx"); string username, password; bool isModExm = chkIsModExam.Checked; username = txtUName.Text.Trim(); password = txtPass.Text.Trim(); var ucs = new ExamUserComponent(); Student usr = ucs.StudExmUserLogin(username, password, isModExm); if (usr == null) { lblInvalid.Text = "Invalid Credentials"; // WrongCredentialsError.Attributes.Add("style", "visibility:inline"); } else { if (usr.StudentId == 0) { lblInvalid.Text = "Invalid Credentials"; // emptyError.Visible = false; // WrongCredentialsError.Attributes.Add("style", "visibility:inline"); } else if (usr.isExpired == true) { lblInvalid.Text = "Your exam period has not yet started or has been expired "; } else if (usr.isStatus == false) { lblInvalid.Text = "You have already taken your exam or it is not yet published"; } else { CurrentSession.CurrStudent = usr; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Close", "StartExam()", true); //int centreId = CurrentSession.CurrUser.Centre.CentreId; //string menustr = ucs.GetUserMenu(usr.UserType.Id.ToString(), centreId); //CurrentSession.UserMenu = menustr; //Response.Redirect("Welcome.aspx"); } } }
private void UpdateResult() { int ResDetId = CurrentSession.CurrStudent.ExamResultDetail.ExmResultDetailId; int StudId = CurrentSession.CurrStudent.StudentId; bool IsModuleTest = CurrentSession.CurrStudent.isModExam; string getDate = DateTime.Now.ToString("dd-MM-yyyy"); string getTime = DateTime.Now.ToShortTimeString(); getTime = getTime.Replace(":", ""); string fileName = "EXM" + "_" + ResDetId + "_" + getDate + "_" + getTime; CurrentSession.FileName = fileName; ExamUserComponent ec = new ExamUserComponent(); int success; success = ec.UpdateResult(ResDetId, StudId, fileName, IsModuleTest); SaveReport(); }
private void ShowReport() { ExamUserComponent ec = new ExamUserComponent(); int ResDetId = CurrentSession.CurrStudent.ExamResultDetail.ExmResultDetailId; int StudId = CurrentSession.CurrStudent.StudentId; string isDetailed = "0"; //if (chkIsDetailed.Checked) //isDetailed = "2"; bool isModExam = CurrentSession.CurrStudent.isModExam; string FileName = hdnFileName.Value; DataSet dsComp = ec.GetCompInfo(); DataSet dsExamRes = ec.GetExamResultPrint(ResDetId, StudId, 1, false); DataSet dsExResSum = ec.GetExamResultPrint(ResDetId, StudId, 2, false); Microsoft.Reporting.WebForms.ReportViewer rview = new Microsoft.Reporting.WebForms.ReportViewer(); rview.ProcessingMode = ProcessingMode.Local; rview.LocalReport.ReportPath = Server.MapPath("~/eReports/Rdlc/rpt_examResult.rdlc"); rview.LocalReport.DataSources.Clear(); rview.LocalReport.DataSources.Add(new ReportDataSource("dsCompInfo", dsComp.Tables[0])); rview.LocalReport.DataSources.Add(new ReportDataSource("dsResPrint", dsExamRes.Tables[0])); rview.LocalReport.DataSources.Add(new ReportDataSource("dsExamSum", dsExResSum.Tables[0])); rview.LocalReport.Refresh(); string mimeType, encoding, extension, deviceInfo; string[] streamids; Microsoft.Reporting.WebForms.Warning[] warnings; //Desired format goes here (PDF, Excel, or Image) deviceInfo = "<DeviceInfo>" + "<SimplePageHeaders>True</SimplePageHeaders>" + "</DeviceInfo>"; byte[] bytes = rview.LocalReport.Render("PDF", deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings); System.Web.HttpContext.Current.Response.Clear(); System.Web.HttpContext.Current.Response.ContentType = mimeType; System.Web.HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=Result.PDF"); System.Web.HttpContext.Current.Response.BinaryWrite(bytes); System.Web.HttpContext.Current.Response.End(); }
private void SaveAnswerAndGetQuestion(int ExamDetId, string Answer, int TypeId, int StudId, int ResDetId, int SeqId = 0, int fin = 0, bool isModExam = false) { ExamUserComponent euc = new ExamUserComponent(); List <QnStudentExamDet> lstExamDet = new List <QnStudentExamDet>(); lstExamDet = euc.GetQuestionaires(ExamDetId, Answer, TypeId, StudId, ResDetId, SeqId, fin, isModExam); if (fin != 1) { lblMarks.Text = "Marks : " + lstExamDet[0].QuestionMaster.Marks.ToString(); lblQues.Text = Server.HtmlEncode(lstExamDet[0].QuestionMaster.Description); string QuesNo; QuesNo = rdbtnQuesNo.SelectedItem.Text; lblQuestionNo.Text = "Question No : " + QuesNo; lblTypeId.Text = lstExamDet[0].TypeId.ToString(); if (lstExamDet[0].TypeId == 1) { rdbtnAns.Visible = true; chkAns.Visible = false; rdbtnAns.DataSource = lstExamDet; rdbtnAns.DataBind(); foreach (ListItem rdnlst in rdbtnAns.Items) { rdnlst.Text = Server.HtmlEncode(rdnlst.Text); } foreach (QnStudentExamDet _examDet in lstExamDet) { if (_examDet.isSelected == true) { rdbtnAns.SelectedValue = _examDet.OptionSeqNo.ToString(); break; } } //Abdul if (lstExamDet[0].QuestionMaster.ImgFileName != null)//code to show image from solution folder { //string path = Server.MapPath("~/QuestImage/" + lstExamDet[0].QuestionMaster.ImgFileName); string path = ConfigurationManager.AppSettings["QstImgUrl"].ToString() + lstExamDet[0].QuestionMaster.ImgFileName; if (File.Exists(path)) { plnImage.Visible = true; string photoName = lstExamDet[0].QuestionMaster.ImgFileName; string filenopic = string.Format("~/QuestImage/" + photoName, photoName, "e"); imgPhoto.ImageUrl = path; //filenopic; } else { plnImage.Visible = false; } } else { imgPhoto.ImageUrl = ""; plnImage.Visible = false; } //Abdul } else { rdbtnAns.Visible = false; chkAns.Visible = true; chkAns.DataSource = lstExamDet; chkAns.DataBind(); foreach (ListItem chklst in chkAns.Items) { chklst.Text = Server.HtmlEncode(chklst.Text); } int i; for (i = 0; i < lstExamDet.Count; i++) { if (chkAns.Items[i].Value == lstExamDet[i].OptionSeqNo.ToString()) { if (lstExamDet[i].isSelected) { chkAns.Items[i].Selected = true; } } //if (_examDet.isSelected == true) // chkAns.SelectedValue = _examDet.OptionSeqNo.ToString(); } //Abdul if (lstExamDet[0].QuestionMaster.ImgFileName != null)//code to show image from solution folder { string newpath = Server.MapPath("~/QuestImage/" + lstExamDet[0].QuestionMaster.ImgFileName); string srcPath = ConfigurationManager.AppSettings["QstImgUrl"].ToString() + lstExamDet[0].QuestionMaster.ImgFileName; getImage(srcPath, newpath); if (File.Exists(newpath)) { plnImage.Visible = true; string photoName = lstExamDet[0].QuestionMaster.ImgFileName; string filenopic = string.Format("~/QuestImage/" + photoName, photoName, "e"); imgPhoto.ImageUrl = filenopic; } else { plnImage.Visible = false; } } else { imgPhoto.ImageUrl = ""; plnImage.Visible = false; } //Abdul } } }