Exemplo n.º 1
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            sessionId = Convert.ToInt32(Session["sessionId"]);
            Collection <AttendanceCL> attendanceCL = new Collection <AttendanceCL>();

            foreach (GridViewRow item in grdStudent.Rows)
            {
                int          studentId           = Convert.ToInt32(grdStudent.DataKeys[item.RowIndex].Value.ToString());
                int          attendanceId        = attendanceBLL.viewAttendanceByStudentIdandDate(studentId, Convert.ToDateTime(txtDate.Text)).id;
                StudentCL    studentCL           = studentBLL.viewStudentById(studentId, sessionId);
                DropDownList ddlStudentLeaveType = item.FindControl("ddlGrdStudentLeaveType") as DropDownList;
                if (Convert.ToInt32(ddlStudentLeaveType.SelectedValue) != -1)
                {
                    attendanceCL.Add(new AttendanceCL()
                    {
                        classId            = studentCL.classId,
                        date               = Convert.ToDateTime(txtDate.Text),
                        dateCreated        = DateTime.Now,
                        dateModified       = DateTime.Now,
                        isDeleted          = false,
                        studentId          = studentId,
                        studentLeaveType   = ddlStudentLeaveType.SelectedItem.ToString(),
                        studentLeaveTypeId = Convert.ToInt32(ddlStudentLeaveType.SelectedValue),
                        id = attendanceId,
                    });
                }
            }
            int attendanceUpdated = attendanceBLL.deleteAttendance(attendanceCL);

            lblUpdate.Text = attendanceUpdated + " Entries have been deleted. The page will refresh in 5 seconds";
            Response.AppendHeader("Refresh", "5;url=ManageAttendance.aspx");
        }