protected void gridView1_SelectedIndexChanged(object sender, EventArgs e) { ClearAll(); edit_mode = true; site = new DBSite(); GridViewRow row = gridView1.SelectedRow; lblExamMasterId.Text = row.Cells[3].Text; SubjectMasterBLL sBll = new SubjectMasterBLL(); ExamMasterBll exBll = new ExamMasterBll(); ExamMasterBll.ExamMasterEntity exam = exBll.GetExamList(site, Util_BLL.User.UserId, lblExamMasterId.Text)[0]; lblExamMasterId.Text = util.CheckNull(exam.ExamMasterId); txtExamName.Text = exam.ExamName; txtExamCode.Text = exam.ExamCode; ///txtExamDate.Text = exam.ExamDate; txtMaxMarks.Text = util.CheckNull(exam.MaxMarks); txtPassMarks.Text = util.CheckNull(exam.PassMarks); ddlClass.SelectedValue = util.CheckNull(exam.ClassMasterID); ddlSection.SelectedValue = util.CheckNull(exam.SectionMasterID); ddlTerm.SelectedValue = util.CheckNull(exam.TermId); }
protected void btnDelete_Click(object sender, EventArgs e) { ExamMasterBll exBll = new ExamMasterBll(); site = new DBSite(); List <string> Ids = new List <string>(); foreach (GridViewRow gr in gridView1.Rows) { CheckBox cb = (CheckBox)gr.Cells[0].FindControl("myCheckBox"); if (cb.Checked) { Ids.Add(gr.Cells[3].Text); } } if (Ids.Count < 1) { lblError.Text = "Can't Delete Records [ Select at least one Record ] "; lblError.Visible = true; //ClearSuccessMessage(); return; } string cls_ids = util.ConvertListToCommaSeparatedString(Ids); // check if the exam exits in examMarks table String exam_Name = exBll.IsExamPresentInExamMarksTable(site, cls_ids); if (exam_Name.Length > 1) { lblMessage.Text = " [ '" + exam_Name + "'] Can not be Deleted. As it is present in Exam Marks."; } else { site.BeginTrans(); exBll.DeleteExam(site, cls_ids); site.Commit(); lblMessage.Text = " [ " + Ids.Count + "] Record Deleted "; } lblMessage.Visible = true; ClearErrorMessage(); GetExams(); }
private void GetExams() { exmBll = new ExamMasterBll(); site = new DBSite(); try { List <ExamMasterBll.ExamMasterEntity> examList = exmBll.GetExamList(site, Util_BLL.User.UserId); total_records = examList.Count; gridView1.DataSource = examList; gridView1.DataBind(); } catch (Exception exception) { util.HandleExpception(exception, Response); } finally { site.Close(); } }
protected void Page_Load(object sender, EventArgs e) { int trnID = util.CheckNullInt(Request.QueryString["new"]); isNewExamMarksEntry = trnID; isUpdate = isNewExamMarksEntry != 1; // change back gound color if (isUpdate) { form1.Attributes.Add("style", "background-color:lightBlue;"); } else { form1.Attributes.Add("style", "background-color:lightGrey;"); } btnDelete.Visible = isUpdate; if (!IsPostBack) { Clear(); site = new DBSite(); ClassMasterBLL cBll = new ClassMasterBLL(); List <ClassMasterBLL.ClassMasterEntity> clasList = cBll.GetClassListBySubUser(site, Util_BLL.User.UserId, "", true); //ddlClass.Items.Add(new ListItem("All", "0")); foreach (ClassMasterBLL.ClassMasterEntity cls in clasList) { ddlClass.Items.Add(new ListItem(cls.ClassName, cls.ClassMasterId.ToString())); } SectionMasterBll secBll = new SectionMasterBll(); List <SectionMasterBll.SectionMasterEntity> secList = secBll.GetSectionList(site, Util_BLL.User.UserId); ddlSection.Items.Add(new ListItem("All", "0")); foreach (SectionMasterBll.SectionMasterEntity sec in secList) { ddlSection.Items.Add(new ListItem(sec.SectionName, sec.SectionMasterId.ToString())); } ExamMasterBll exBll = new ExamMasterBll(); List <ExamMasterBll.ExamMasterEntity> examList = exBll.GetExamList(site, Util_BLL.User.UserId); ddlExam.Items.Add(new ListItem("All", "0")); foreach (ExamMasterBll.ExamMasterEntity exam in examList) { ddlExam.Items.Add(new ListItem(exam.ExamCode + " (MM." + exam.MaxMarks + ")", exam.ExamMasterId.ToString())); } //gridView3.DataSource = examList; //gridView3.DataBind(); SubjectMasterBLL subBll = new SubjectMasterBLL(); List <SubjectMasterBLL.SubjectMasterEntity> subList = subBll.GetSubjectsBySubUser(site, Util_BLL.User.UserId, "", true); ddlSubject.Items.Add(new ListItem("All", "0")); foreach (SubjectMasterBLL.SubjectMasterEntity subject in subList) { ddlSubject.Items.Add(new ListItem(subject.SubjectName + " (" + subject.SubjectGroupType + ")", subject.SubjectMasterId.ToString())); } // 7777 //gridView2.DataSource = subList; //gridView2.DataBind(); if (!isUpdate) { legendExamMarks.InnerText = "Enter New Exam Marks"; } else { legendExamMarks.InnerText = "Edit Exam Marks"; } } }
protected void SaveExamMarks() { ExamMarksBll emBll = new ExamMarksBll(); site = new DBSite(); List <ExamMarksBll.ExamMarksEntity> marksList = new List <ExamMarksBll.ExamMarksEntity>(); ExamMarksBll.ExamMarksEntity mark; decimal MaxMarksByExam = 0; ExamMasterBll exbLL = new ExamMasterBll(); SubjectMasterBLL sBll = new SubjectMasterBLL(); string subjectGrpType = "MARKS"; if (!isUpdate) { MaxMarksByExam = exbLL.GetExamMaxMarks(site, ddlExam.SelectedValue); subjectGrpType = sBll.GetSubjectGroupType(site, ddlSubject.SelectedValue); } foreach (GridViewRow gr in gridView1.Rows) { mark = new ExamMarksBll.ExamMarksEntity(); CheckBox cb = (CheckBox)gr.Cells[0].FindControl("ckbPresent"); if (cb.Checked) { mark.IsPresent = 1; } else { mark.IsPresent = 0; } mark.StudentMasterId = util.CheckNullInt(gr.Cells[2].Text); TextBox txt = (TextBox)gr.Cells[9].FindControl("txtMarksObtained"); mark.StudentName = util.CheckNull(gr.Cells[3].Text); // if new then check for subject type -grade or marks if (!isUpdate) { if (subjectGrpType.ToUpper() == "MARKS") { if (!util.isDecimal(txt.Text)) { lblError.Text = " Marks Obtained By '" + mark.StudentName + "' is not valid decimal."; lblError.Visible = true; return; } } else // grade { //if (util.isDecimal(txt.Text)) //{ // lblError.Text = " Marks Obtained By '" + mark.StudentName + "' is not valid Grade."; // lblError.Visible = true; // return; //} } } else // update { subjectGrpType = util.CheckNull(gr.Cells[11].Text); if (subjectGrpType.ToUpper() == "MARKS") { if (!util.isDecimal(txt.Text)) { lblError.Text = " Marks Obtained By '" + mark.StudentName + "' is not valid decimal."; lblError.Visible = true; return; } } else { //if (util.isDecimal(txt.Text)) //{ // lblError.Text = " Marks Obtained By '" + mark.StudentName + "' is not valid Grade."; // lblError.Visible = true; // return; //} } } if (util.isDecimal(txt.Text)) { if (isUpdate) { MaxMarksByExam = util.CheckNullDecimal(gr.Cells[10].Text); } decimal marksObtained = util.CheckNullDecimal(txt.Text); if (marksObtained <= MaxMarksByExam) { mark.MarksObtained = util.CheckNull(marksObtained); } else { lblError.Text = " Marks Obtained By '" + mark.StudentName + "' Can Not Be More Than Max Marks ( " + MaxMarksByExam + " ) "; lblError.Visible = true; return; } } else { mark.MarksObtained = util.CheckNull(txt.Text); } mark.classId = util.CheckNullInt(gridView1.DataKeys[gr.RowIndex].Values["classId"]); mark.SectionId = util.CheckNullInt(gridView1.DataKeys[gr.RowIndex].Values["SectionId"]); if (isUpdate) { mark.SubjectId = util.CheckNullInt(gridView1.DataKeys[gr.RowIndex].Values["SubjectId"]); mark.ExamId = util.CheckNullInt(gridView1.DataKeys[gr.RowIndex].Values["ExamId"]); } else { mark.SubjectId = util.CheckNullInt(ddlSubject.SelectedValue); mark.ExamId = util.CheckNullInt(ddlExam.SelectedValue); } mark.ExamMarksId = util.CheckNullInt(gridView1.DataKeys[gr.RowIndex].Values["ExamMarksId"]); mark.SubUserID = Util_BLL.SubUser.SubuserId; mark.UserID = Util_BLL.User.UserId; mark.FYear = Util_BLL.User.fYear; marksList.Add(mark); } emBll.SaveMarks(site, marksList, isUpdate, false); string msg = " Successfully Added ! "; if (isUpdate) { msg = " Successfully Updated ! "; } lblMessage.Text = msg; lblMessage.Visible = true; ClearErrorMessage(); }
void SaveExam() { exmBll = new ExamMasterBll(); ExamMasterBll.ExamMasterEntity exam = new ExamMasterBll.ExamMasterEntity(); try { string message = ""; exam.ExamName = this.txtExamName.Text; exam.ExamCode = this.txtExamCode.Text; exam.ExamDate = util.CheckNullDate(DateTime.Today); exam.ClassMasterID = util.CheckNullInt(ddlClass.SelectedValue); exam.SectionMasterID = util.CheckNullInt(ddlSection.SelectedValue); exam.TermId = util.CheckNullInt(ddlTerm.SelectedValue); exam.MaxMarks = util.CheckNullInt(txtMaxMarks.Text); exam.PassMarks = util.CheckNullInt(txtPassMarks.Text); exam.ExamOrder = util.CheckNullInt(txtExamOrder.Text); site = new DBSite(); // save or updare site.BeginTrans(); if (lblExamMasterId.Text == "New") { exmBll.SaveExam(site, exam); message = "\t '" + exam.ExamName + "' Successfully Added !"; } else { exam.ExamMasterId = util.CheckNullInt(lblExamMasterId.Text); exmBll.UpdateExam(site, exam); message = "\t '" + exam.ExamName + "' Successfully Updated !"; } site.Commit(); lblMessage.Text = message; lblMessage.Visible = true; ClearErrorMessage(); } catch (Exception ex) { site.RollBack(); if (ex.Message.Contains("UNQ_ExamName")) { lblMessage.Text = "\t '" + exam.ExamName + "' is already present !"; lblMessage.Visible = true; } else { util.HandleExpception(ex, Response); } } finally { site.Close(); } }