コード例 #1
0
 protected void lkbSaveExamReport_Click(object sender, EventArgs e)
 {
     try
     {
         List <MST_EXAM_REPORT> NEWEXAM_REPORT = new List <MST_EXAM_REPORT>();
         List <MST_EXAM_REPORT> OLDEXAM_REPORT = new List <MST_EXAM_REPORT>();
         if (ddlStudent.SelectedIndex < 1)
         {
             uc_sucess1.ErrorMessage = "Student Year must be selected before Save";
             uc_sucess1.VisibleError = true;
             return;
         }
         foreach (var item in lvExamStudent.Items)
         {
             int ExamId     = Convert.ToInt32(lvExamStudent.DataKeys[item.DisplayIndex].Values["EXAMID"].ToString().Trim() != "" ? lvExamStudent.DataKeys[item.DisplayIndex].Values["EXAMID"].ToString() : "0");
             int Id         = Convert.ToInt32(lvExamStudent.DataKeys[item.DisplayIndex].Values["ID"].ToString().Trim() != "" ? lvExamStudent.DataKeys[item.DisplayIndex].Values["ID"].ToString() : "0");
             var ExamReport = ExamDTO.GetExamReportById(Id);
             if (ExamReport != null)
             {
                 ExamReport.ObtainedMarks = Convert.ToByte(((TextBox)(item.FindControl("txtObtainedMarks"))).Text);
                 OLDEXAM_REPORT.Add(ExamReport);
             }
             else
             {
                 MST_EXAM_REPORT NewExamReport = new MST_EXAM_REPORT();
                 NewExamReport.StudentId     = Int32.Parse(ddlStudent.SelectedValue);
                 NewExamReport.ObtainedMarks = Convert.ToByte(((TextBox)(item.FindControl("txtObtainedMarks"))).Text);
                 NewExamReport.ExamId        = ExamId;
                 NEWEXAM_REPORT.Add(NewExamReport);
             }
         }
         foreach (var Exam in NEWEXAM_REPORT)
         {
             if (!ExamDTO.Create(Exam))
             {
                 throw new Exception();
             }
         }
         foreach (var Exam in OLDEXAM_REPORT)
         {
             if (!ExamDTO.Update(Exam))
             {
                 throw new Exception();
             }
         }
         //lvExamStudent.Items.Clear();
         uc_sucess1.SuccessMessage = "Saved Successfully!";
         uc_sucess1.Visible        = true;
         lvExamStudent.DataSource  = null;
         lvExamStudent.DataBind();
         lvExamStudent.DataSourceID = "SqlDataSource2";
         lvExamStudent.DataBind();
     }
     catch (Exception ex)
     {
         uc_sucess1.ErrorMessage = ex.Message;
         uc_sucess1.VisibleError = true;
     }
 }
コード例 #2
0
 public bool Create(MST_EXAM_REPORT exam)
 {
     try
     {
         unitOfWork.ExamReportRepository.Create(exam);
         unitOfWork.Save();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #3
0
 public bool Update(MST_EXAM_REPORT examReportData)
 {
     try
     {
         unitOfWork.ExamReportRepository.Update(examReportData);
         unitOfWork.Save();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #4
0
        public MST_EXAM_REPORT GetExamReportById(int id)
        {
            MST_EXAM_REPORT data = unitOfWork.ExamReportRepository.Filter(x => x.ID == id).SingleOrDefault();

            return(data);
        }