protected void btnAddStu_onClick(object sender, EventArgs e) { string stuId = ddlSearch.SelectedValue.ToString(); double selectedStuId = Convert.ToDouble(stuId); int lessID = Convert.ToInt32(Session["selectedLessonNum"]); DateTime lesDate = Convert.ToDateTime(Session["selectedLessonDate"]); string dateFormat = lesDate.ToString("yyyy-MM-dd"); ActualLesson acl = new ActualLesson(); SignedToLesson stl; int studentsNum = Convert.ToInt32(Session["studentsNumber"]); int actual_quan = studentsNum + 1; try { stl = new SignedToLesson(lessID, dateFormat, selectedStuId); int numEffected3 = acl.updateSpecificActualLesson(lessID, dateFormat, actual_quan); //הגדלת כמות משתתפים ב-1 int numEffected2 = stl.InsertSigendToLesson(); //הכנסת התלמיד לטבלת "רשום לתגבור" Server.TransferRequest(Request.Url.AbsolutePath, false); } catch (Exception ex) { Response.Write("There was an error " + ex.Message); } }
protected void ApproveButton_Click(object sender, EventArgs e) { Request req = new Request(); 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 numEffected = req.updateSpecificRequest(req_num, status); int req_type = 1; string req_typeName = gvRow.Cells[15].Text; if (req_typeName != "ביטול השתתפות") { req_type = 0; } ActualLesson acl = new ActualLesson(); SignedToLesson stl; double stuId = Convert.ToDouble(gvRow.Cells[3].Text); int lesId = Convert.ToInt32(gvRow.Cells[14].Text); DateTime tmpDate = Convert.ToDateTime(gvRow.Cells[7].Text); string lesDate = tmpDate.ToString("yyyy-MM-dd"); if (req_type != 1) //אם זו בקשה להרשמה (זו לא בקשה לביטול השתתפות) { try { stl = new SignedToLesson(lesId, lesDate, stuId); } catch (Exception ex) { Response.Write("illegal values to the SignedToLesson attributes - error message is " + ex.Message); return; } int actual_quan = Convert.ToInt32(gvRow.Cells[11].Text) + 1; try { int numEffected3 = acl.updateSpecificActualLesson(lesId, lesDate, actual_quan); //הגדלת כמות משתתפים ב-1 int numEffected2 = stl.InsertSigendToLesson(); //הכנסת התלמיד לטבלת "רשום לתגבור" Server.TransferRequest(Request.Url.AbsolutePath, false); } catch (Exception ex) { Response.Write("There was an error " + ex.Message); } } }
public void delBTNButton_Click(Object sender, EventArgs e) { SignedToLesson stl = new SignedToLesson(); Button button = (Button)sender; string buttonId = button.ID; string stuId = buttonId.Substring(6); int delStuId = Convert.ToInt32(stuId); string lessDate = (Session["selectedLessonDate"]).ToString(); DateTime lesDate = Convert.ToDateTime(lessDate); int lesId = (int)(Session["selectedLessonNum"]); int numEff = stl.deleteStudentFromLesson(delStuId, lesId, lesDate.ToString("yyyy-MM-dd")); ActualLesson actl = new ActualLesson(); int quan = (int)Session["studentsNumber"] - 1; int numEf = actl.updateSpecificActualLesson(lesId, lesDate.ToString("yyyy-MM-dd"), quan); Server.TransferRequest(Request.Url.AbsolutePath, false); }
protected void ApproveButton_Click(object sender, EventArgs e) { Session["flgSendReq"] = "1"; Request req = new Request(); GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent; int req_num = Convert.ToInt32(gvRow.Cells[1].Text); ActualLesson acl = new ActualLesson(); SignedToLesson stl; double stuId = Convert.ToDouble(gvRow.Cells[3].Text); int lesId = Convert.ToInt32(gvRow.Cells[5].Text); DateTime tmpDate = Convert.ToDateTime(gvRow.Cells[7].Text); string lesDate = tmpDate.ToString("yyyy-MM-dd"); int req_type = 1; string req_typeName = gvRow.Cells[2].Text; if (req_typeName != "ביטול השתתפות") { req_type = 0; } else //נאשר בקשה לביטול השתתפות- נשנה סטטוס בקשה ל-1 { int status = 1; int numEffected = req.updateSpecificRequest(req_num, status); try { stl = new SignedToLesson(lesId, lesDate, stuId); } catch (Exception ex) { Response.Write("illegal values to the SignedToLesson attributes - error message is " + ex.Message); return; } int actual_quan = Convert.ToInt32(gvRow.Cells[13].Text) - 1; try { int numEffected3 = acl.updateSpecificActualLesson(lesId, lesDate, actual_quan); //הקטנת כמות משתתפים ב-1 int numEffected2 = stl.deleteStudentFromLesson(stuId, lesId, lesDate); //הוצאת התלמיד מטבלת "רשום לתגבור" Server.TransferRequest(Request.Url.AbsolutePath, false); } catch (Exception ex) { Response.Write("There was an error " + ex.Message); } } int flg = 0; //מסמן שאין התנגשות בין תגבור מבוקש לבין תגבור אחר כלשהו שהתלמיד משובץ אליו DataTable checkTable = new DataTable(); checkTable.Columns.Add("flg", typeof(int)); //מסמן אם ניתן להוסיף תגבור או לא- 1 ניתן 0 לא ניתן if (req_type != 1) //אם זו בקשה להרשמה (זו לא בקשה לביטול השתתפות) { //ניקח את שעות התגבור המבוקש ע"מ לראות אם באותם שעות בתאריך התגבור, התלמיד משובץ לתגבור אחר DateTime reqLesStart = DateTime.Parse((gvRow.Cells[9].Text).ToString()); DateTime reqLesEnd = DateTime.Parse((gvRow.Cells[10].Text).ToString()); Session["reqStuId"] = stuId; Session["reqLesDate"] = lesDate; //נביא את כל התגבורים (תאריך+שעת התחלה+שעת סיום+מס תגבור) עבור מתגבר זה DataTable DTclassForReqStuId = this.GetClassForReqStuId(); if (DTclassForReqStuId.Rows.Count > 0)//המשמעות שהתלמיד המבקש משובץ לתגבורים אחרים בתאריך המבוקש- נבדוק התנגשות בשעות { foreach (DataRow dr in DTclassForReqStuId.Rows) { //אם יש לו תגבור באותו יום, אבל התגבור הנבחר מתחיל ומסתיים לפני התגבורים אחרים שיש לו באותו יום- ניתן לשבץ if (reqLesStart < DateTime.Parse((dr["Les_StartHour"]).ToString()) && reqLesEnd <= DateTime.Parse((dr["Les_StartHour"]).ToString())) { DataRow newRow = checkTable.NewRow(); // Set values in the columnn: newRow["flg"] = 1; // Add the row to the rows collection. checkTable.Rows.Add(newRow); } //אם יש לו תגבור באותו יום, אבל התגבור הנבחר מתחיל אחרי שהתגבורים אחרים שיש לו באותו יום כבר התחילו והסתיימו- ניתן לשבץ else if (reqLesStart > DateTime.Parse((dr["Les_StartHour"]).ToString()) && reqLesStart >= DateTime.Parse((dr["Les_EndHour"]).ToString())) { DataRow newRow = checkTable.NewRow(); // Set values in the column newRow["flg"] = 1; // Add the row to the rows collection. checkTable.Rows.Add(newRow); } else //כל מצב אחר המשמעות שיש תגבור לתלמיד באותו התאריך וגם השעות מתנגשות { DataRow newRow = checkTable.NewRow(); // Set values in the column newRow["flg"] = 0; // Add the row to the rows collection. checkTable.Rows.Add(newRow); } } } if (checkTable.Rows.Count > 0) { foreach (DataRow dr in checkTable.Rows) { if (Convert.ToInt32(dr["flg"]) != 1) { flg = 1; break;//מספיק שלפחות אחד מהתגבורים בתאריך זה מתנגש עם שעות התגבור הנבחר } } } if (flg == 0) //אין התנגשות, אז נבדוק האם יש מקום בתגבור ואם כן נאשר { if (Convert.ToInt32(gvRow.Cells[13].Text) < (Convert.ToInt32(gvRow.Cells[12].Text))) //אם יש מקום בתגבור הבקשה תאושר והתלמיד נרשם לתגבור { int status = 1; int numEffected = req.updateSpecificRequest(req_num, status); try { stl = new SignedToLesson(lesId, lesDate, stuId); } catch (Exception ex) { Response.Write("illegal values to the SignedToLesson attributes - error message is " + ex.Message); return; } int actual_quan = Convert.ToInt32(gvRow.Cells[13].Text) + 1; try { int numEffected3 = acl.updateSpecificActualLesson(lesId, lesDate, actual_quan); //הגדלת כמות משתתפים ב-1 int numEffected2 = stl.InsertSigendToLesson(); //הכנסת התלמיד לטבלת "רשום לתגבור" Server.TransferRequest(Request.Url.AbsolutePath, false); } catch (Exception ex) { Response.Write("There was an error " + ex.Message); } } } else //התלמיד משובץ כבר לתגבור אחר שמתנגש עם התגבור המבוקש- נדחה את הבקשה עם סיבת דחייה לתלמיד ואלרט למנהלת { int status = 0; int Decliend = 1; int numEffected = req.updateSpecificRequest(req_num, status); //נעדכן שהבקשה נדחתה int numEffected4 = req.updateReqDecliendField(req_num, Decliend); //נעדכן שהסיבה לדחיית הבקשה היא "אילוץ" ההתנגשות string proffTitle = gvRow.Cells[6].Text; string start = gvRow.Cells[9].Text; string LesDateFormat = tmpDate.ToString("dd/MM/yyyy"); string currnetDate = DateTime.Now.ToString("yyyy-MM-dd"); Messages mes; Manager m = (Manager)(Session["manUserSession"]); double manID = m.Man_id; string mesContent = "תלמיד יקר, שיעור " + proffTitle + " שחל בתאריך " + LesDateFormat + ", בשעה " + reqLesStart.ToString("HH:mm") + " מתנגש עם תגבור אחר שאתה משובץ אליו בתאריך זה"; mes = new Messages(manID, stuId, "בקשתך להירשם לתגבור נדחתה", mesContent, false, currnetDate); int NumEffected = mes.InsertMessage(); Session["declineReq"] = true; Server.TransferRequest(Request.Url.AbsolutePath, false); } } }
protected void updateForm_Click(object sender, EventArgs e) { int lessID = Convert.ToInt32(Session["selectedLessonNum"]); string lesDate = (string)(Session["selectedLessonDate"]); DateTime lessDate = Convert.ToDateTime(lesDate); DataTable dt = (DataTable)(Session["studentsList"]); foreach (DataRow dr in dt.Rows) { double Stu_id = Convert.ToDouble(dr["StLes_stuId"]); CheckBox cb = (CheckBox)PlaceHolder1.FindControl("cb" + Stu_id.ToString()); if (cb != null) { if (cb.Checked == false) { int stuPresence = 0; SignedToLesson stl = new SignedToLesson(); stl.updateStudentPresence(lessID, lessDate, Stu_id, stuPresence); Student stud = new Student(); stud.updateStudentCounter(Stu_id); DataTable dtCounter = stud.getStudentCounter(Stu_id); DataTable manDT = this.GetManeger(); foreach (DataRow drMan in manDT.Rows) { double msg_toManagerId = Convert.ToDouble(drMan["Man_Id"]); Session["msg_toManagerId"] = msg_toManagerId; } bool msg_has_read = false; DateTime msg_date = DateTime.Now; foreach (DataRow d in dtCounter.Rows) { if (Convert.ToInt32(d[0]) == 5)//להכניס את התלמיד לרשימת הלא זכאים { int updateIsEntitledTo = 0; string currnetDate = DateTime.Now.ToString("yyyy-MM-dd"); Messages mes; double msg_ManagerId = Convert.ToDouble(Session["msg_toManagerId"]); string mesContent = "תלמיד יקר, עקב אי הגעתך לתגבורים אינך זכאי להגיש בקשות. אנא פנה למנהל/ת"; mes = new Messages(msg_ManagerId, Stu_id, "עדכון זכאות לתגבורים", mesContent, false, currnetDate); Messages messageForStudent = new Messages(); messageForStudent.Msg_fromStudentId = Stu_id; messageForStudent.Msg_toManagerId = msg_ManagerId; messageForStudent.Msg_subject = "עדכון זכאות- הודעת מערכת"; messageForStudent.Msg_content = " זוהי הודעה אוטומטית: המערכת הכניסה את תלמיד זה לרשימת הלא זכאים, עקב אי הגעתו לתגבורים. באפשרותך להוציא אותו מהרשימה"; messageForStudent.Msg_hasRead = msg_has_read; messageForStudent.System_msg = 1; messageForStudent.Msg_date = msg_date.ToString("yyyy-MM-dd"); string date = lessDate.ToString("yyyy-MM-dd"); Session["entStu"] = Stu_id; try { Request req = new Request(); int numEf = req.deleteRequests(Stu_id); // מחיקת כל הבקשות שלו להרשמה לתגבורים שעוד לא עברו int numEffected = stud.updateIsEntittled(Stu_id, updateIsEntitledTo); int NumEffected2 = mes.InsertMessage(); int numEffected11 = messageForStudent.InsertMessageSystemStudent(); SignedToLesson delStu = new SignedToLesson(); //int numEf1 = delStu.deleteStudentFromLesson(Stu_id, lessID, date); //נביא את כל התגבורים שבהם התלמיד משתתף ותאריך התגבור עוד לא עבר ונמחק את התלממיד מתגבורים אלה DataTable classesForStuIdDT = this.GetClassForStu(); foreach (DataRow ro in classesForStuIdDT.Rows) { DateTime dat = (DateTime)(ro["StLes_ActLesDate"]); if (dat >= DateTime.Now) { string da = dat.ToString("yyyy-MM-dd"); int lesNum = Convert.ToInt32(ro["StLes_ActLesId"]); int numEf1 = delStu.deleteStudentFromLesson(Stu_id, lesNum, da); ActualLesson actl = new ActualLesson(); int quan = actl.readSpecificActualLessonQuan(lesNum, da) - 1; int numEfc = actl.updateSpecificActualLesson(lesNum, da, quan); } } } catch (Exception ex) { Response.Write("There was an error when trying to insert the product into the database" + ex.Message); } } } } else { int stuPresence = 1; SignedToLesson stl = new SignedToLesson(); stl.updateStudentPresence(lessID, lessDate, Stu_id, stuPresence); } } TextBox tb = (TextBox)PlaceHolder1.FindControl("tb" + Stu_id.ToString()); if (tb != null) { string stuNotes = tb.Text; SignedToLesson stl = new SignedToLesson(); stl.updateStudentNotes(lessID, lessDate, Stu_id, stuNotes); } Session["updateForm"] = true; } Response.Redirect("ClassesForTeacher.aspx"); }