コード例 #1
0
        protected void lkbSave_Click(object sender, EventArgs e)
        {
            var date = DateTime.ParseExact(txtAttandenceDate.Text, "MM/dd/yyyy", CultureInfo.InvariantCulture);

            foreach (ListViewDataItem item in lvStudentAttendance.Items)
            {
                CheckBox chkselect = (CheckBox)item.FindControl("selectone");
                //if (chkselect.Checked)
                // {
                MST_STUDENT_ATTENDANCE StudentAttend = new MST_STUDENT_ATTENDANCE();
                string studentdtlid = (lvStudentAttendance.DataKeys[item.DisplayIndex].Values["StudentAttendId"].ToString());
                int    studentid    = Convert.ToInt32(lvStudentAttendance.DataKeys[item.DisplayIndex].Values["StudentId"].ToString());
                StudentAttend.SectionId = Convert.ToInt32(ddlSectionName.SelectedValue);
                StudentAttend.StudentId = studentid;

                StudentAttend.IsPresent     = chkselect.Checked;
                StudentAttend.PresentDate   = date;
                StudentAttend.Attand_Status = chkselect.Checked ? "P" : "AB";
                StudentAttend.PresentDay    = date.Day.ToString();

                StudentAttend.CreatedBy   = cls_Common.UserProfile.Id;
                StudentAttend.CreatedDate = DateTime.Now;
                int exitstudentdtlid = Convert.ToInt32(studentdtlid);
                var existFeeDtl      = _StudentAttendanceDTO.GetDataForEdit(exitstudentdtlid, date);

                if (existFeeDtl == null)
                {
                    var result = _StudentAttendanceDTO.Save(StudentAttend);
                    uc_sucess.SuccessMessage = "Attendance Save Successfully";
                }
                else
                {
                    //   existFeeDtl.StudentAttendId = exitstudentdtlid;
                    existFeeDtl.StudentId     = studentid;
                    existFeeDtl.SectionId     = Convert.ToInt32(ddlSectionName.SelectedValue);
                    existFeeDtl.IsPresent     = chkselect.Checked;
                    existFeeDtl.PresentDate   = date;
                    existFeeDtl.Attand_Status = chkselect.Checked ? "P" : "AB";
                    existFeeDtl.PresentDay    = date.Day.ToString();

                    StudentAttend.UpdatedBy   = cls_Common.UserProfile.Id;
                    StudentAttend.UpdatedDate = DateTime.Now;
                    var result = _StudentAttendanceDTO.Update(existFeeDtl);
                    uc_sucess.SuccessMessage = "Attendance Update Successfully";
                }

                //   }
            }
            BindStudentAttendance();
        }