public int InsertGradeSystem(BOGradeSytem grades) { DAGradeSystem pDAL = new DAGradeSystem(); try { return pDAL.InsertGradeSystem(grades); } catch { throw; } finally { pDAL = null; } }
public int InsertGradeSystem(BOGradeSytem grade) { SqlParameter[] sqlParams = new SqlParameter[12]; sqlParams[0] = new SqlParameter("@FirstMarks", grade.FirstMarks); sqlParams[1] = new SqlParameter("@SecondMarks", grade.SecondMarks); sqlParams[2] = new SqlParameter("@ExamType", grade.ExamTypeId); sqlParams[3] = new SqlParameter("@Grade", grade.GradeId); sqlParams[4] = new SqlParameter("@Marks", grade.Marks); sqlParams[5] = new SqlParameter("@Status", grade.Status); sqlParams[6] = new SqlParameter("@HostCode", grade.HostCode); sqlParams[7] = new SqlParameter("@RecordId", grade.Id); sqlParams[8] = new SqlParameter("@CreatedDate", DateTime.Now); sqlParams[9] = new SqlParameter("@ModifiedDate", DateTime.Now); sqlParams[10] = new SqlParameter("@CreatedBy", grade.UserId); sqlParams[11] = new SqlParameter("@ModifiedBy", grade.UserId); return cmnDA.ExecuteNonQuery("pr_Gradings_AddOrUpdate", sqlParams); }
protected void btn_Click(object sender, EventArgs e) { try { var gradeSys = new BOGradeSytem(); int catid = 0; if (ViewState["gradeid"] != null) catid = Convert.ToInt16(ViewState["gradeid"]); gradeSys.Id = catid; gradeSys.FirstMarks = Convert.ToInt16(txtFirstMark.Text.Trim()); gradeSys.SecondMarks = Convert.ToInt16(txtSecondMark.Text.Trim()); gradeSys.HostCode = "DEMO"; gradeSys.UserId = 1; gradeSys.ExamTypeId = Convert.ToInt16(drpExamType.SelectedValue); gradeSys.GradeId = Convert.ToInt16(drpGrade.SelectedValue); gradeSys.Marks = drpMarks.SelectedItem.Text; gradeSys.Status = "A"; var isInserted = (new BLGradeSystem()).InsertGradeSystem(gradeSys); if (isInserted == 1) { LoadGradeSystem(); GradeUpdatePanel.Update(); ResetControls(); lblErrorMsg.ForeColor = System.Drawing.Color.Red; lblErrorMsg.Text = "Grade system inserted successfully."; } else { lblErrorMsg.ForeColor = System.Drawing.Color.Red; lblErrorMsg.Text = "Process failed. Please try again."; } } catch (Exception ex) { lblErrorMsg.ForeColor = System.Drawing.Color.Red; lblErrorMsg.Text = "Unable to save data."; } }
public List<BOGradeSytem> LoadGradeSystems(int userid, string hostCode) { DAGradeSystem pDAL = new DAGradeSystem(); try { var dtCategories = pDAL.LoadGradeSystem(userid, hostCode); var grades = new List<BOGradeSytem>(); BOGradeSytem grade = null; foreach (DataRow item in dtCategories.Rows) { grade = new BOGradeSytem(); int firstMark; int.TryParse(item["FirstMarks"].ToString(), out firstMark); grade.FirstMarks = firstMark; int secondMark; int.TryParse(item["SecondMarks"].ToString(), out secondMark); grade.SecondMarks = secondMark; int examType; int.TryParse(item["ExamTypeId"].ToString(), out examType); grade.ExamTypeId = examType; int gradeid; int.TryParse(item["GradeId"].ToString(), out gradeid); grade.GradeId = gradeid; grade.ExamType = item["ExamType"].ToString(); grade.Grade = item["Grade"].ToString(); grade.Marks = item["Marks"].ToString(); grade.Id = Convert.ToInt32(item["Id"]); grades.Add(grade); } return grades; } catch { throw; } finally { pDAL = null; } }