protected void cancelButton_Click(object sender, EventArgs e) { GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent; int cancelled = 1; ActualLesson acl = new ActualLesson(); SignedToLesson stl = new SignedToLesson(); int lesId = Convert.ToInt32(gvRow.Cells[1].Text); DateTime tmpDate = Convert.ToDateTime(gvRow.Cells[3].Text); string lesDate = tmpDate.ToString("yyyy-MM-dd"); Request stuReq = new Request(); string proff = gvRow.Cells[2].Text; string start = gvRow.Cells[4].Text; Session["cancelledLesId"] = lesId; Session["cancelledLesDate"] = lesDate; string lesDateMES = tmpDate.ToString("dd-MM-yyyy"); Manager m = (Manager)(Session["manUserSession"]); double manID = m.Man_id; DataTable dt = this.GetStudents(); string currnetDate = DateTime.Now.ToString("yyyy-MM-dd"); Messages mes; string mesContent = "תלמיד יקר, שיעור " + proff + " שחל בתאריך " + lesDateMES + " ובשעה " + start + " בוטל."; foreach (DataRow dr in dt.Rows) { double stuID = Convert.ToDouble(dr["StLes_stuId"]); mes = new Messages(manID, stuID, "ביטול שיעור", mesContent, false, currnetDate); int NumEffected = mes.InsertMessage(); } DataTable teaIDtable = this.GetTeaId(); double teaID = Convert.ToDouble(teaIDtable.Rows[0]["Les_Tea_Id"]); string mesToTeaContent = "מתגבר יקר, שיעור " + proff + " שחל בתאריך " + lesDateMES + " ובשעה " + start + " בוטל."; Messages TeaMes = new Messages(manID, teaID, "ביטול שיעור", mesToTeaContent, false, currnetDate); int numEffected1 = TeaMes.InsertMessageFromManagerToTeacher(); try { int numEffected2 = acl.cancelSpecificActualLesson(lesId, lesDate, cancelled); //עדכון שהתגבור בוטל int numEffected3 = stl.deleteStudentsFromLesson(lesId, lesDate); //מחיקת התלמידים שמשתתפים בתגבור זה בטבלת "רשום לתגבור" int numEffected4 = stuReq.deleteCancelldLessonRequests(lesId, lesDate); //מחיקת כל הבקשות להרשמה לתגבור זה Server.TransferRequest(Request.Url.AbsolutePath, false); } catch (Exception ex) { Response.Write("illegal values to the SignedToLesson attributes - error message is " + ex.Message); return; } }
protected void ApproveButton_Click(object sender, EventArgs e) { teachersRequests req = new teachersRequests(); GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent; int index = gvRow.RowIndex; int req_num = Convert.ToInt32(gvRow.Cells[1].Text); int status = 1; int cancelled = 1; ActualLesson acl = new ActualLesson(); SignedToLesson stl = new SignedToLesson(); int lesId = Convert.ToInt32(gvRow.Cells[2].Text); DateTime tmpDate = Convert.ToDateTime(gvRow.Cells[3].Text); string lesDate = tmpDate.ToString("yyyy-MM-dd"); Request stuReq = new Request(); string proff = gvRow.Cells[4].Text; string start = gvRow.Cells[6].Text; Session["cancelledLesId"] = lesId; Session["cancelledLesDate"] = lesDate; string lesDateMES = tmpDate.ToString("dd-MM-yyyy"); Manager m = (Manager)(Session["manUserSession"]); double manID = m.Man_id; DataTable dt = this.GetStudents(); string currnetDate = DateTime.Now.ToString("yyyy-MM-dd"); Messages mes; DataTable teaIDtable = this.GetTeaId(); double teaID = Convert.ToDouble(teaIDtable.Rows[0]["Les_Tea_Id"]); string mesToTeaContent = "מתגבר יקר, בקשתך לביטול שיעור " + proff + " שחל בתאריך " + lesDateMES + " ובשעה " + start + " אושרה והתגבור בוטל."; // Messages TeaMes = new Messages(manID, teaID, "ביטול שיעור", mesToTeaContent, false, currnetDate); Messages TeaMes = new Messages(); TeaMes.Msg_fromManagerId = manID; TeaMes.Msg_toTeacherId = teaID; TeaMes.Msg_subject = "ביטול שיעור"; TeaMes.Msg_content = mesToTeaContent; TeaMes.Msg_hasRead = false; TeaMes.Msg_date = currnetDate; int numEffected1 = TeaMes.InsertMessageFromManagerToTeacher(); string mesContent = "תלמיד יקר, שיעור " + proff + " שחל בתאריך " + lesDateMES + " ובשעה " + start + " בוטל."; foreach (DataRow dr in dt.Rows) { double stuID = Convert.ToDouble(dr["StLes_stuId"]); mes = new Messages(manID, stuID, "ביטול שיעור", mesContent, false, currnetDate); int NumEffected = mes.InsertMessage(); } try { int numEffected = req.updateSpecificTeacherRequest(req_num, status); int numEffected2 = acl.cancelSpecificActualLesson(lesId, lesDate, cancelled); int numEffected3 = stl.deleteStudentsFromLesson(lesId, lesDate); int numEffected4 = stuReq.deleteCancelldLessonRequests(lesId, lesDate); Server.TransferRequest(Request.Url.AbsolutePath, false); } catch (Exception ex) { Response.Write("illegal values to the SignedToLesson attributes - error message is " + ex.Message); return; } }