public decimal GetExamMaxMarks(DBSite site, string examId) { string mmStr = util.CheckNull(GetExamList(site, Util_BLL.User.UserId, examId)[0].MaxMarks); if (util.isDecimal(mmStr)) { return(util.CheckNullDecimal(mmStr)); } else { return(-1); } }
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(); }