protected void Button1_Click(object sender, EventArgs e) { DepartmentCourses c = new DepartmentCourses(TextBoxDepartment.Text, TextBoxYear.Text, TextBoxSemester.Text, TextBoxName.Text, (Txtid.Text), TxtDay.Text, TextBoxhour.Text, txtHour2.Text, TextBoxCreadits.Text, TextBoxMandatory.Text, txtLec.Text, txtRegister.Text, txtMaxNum.Text, txtLecName.Text); if (c.insertCourse()) { msg.Text = "has been add"; msg.Visible = true; Txtid.Text = ""; TxtDay.Text = ""; TextBoxhour.Text = ""; txtHour2.Text = ""; TextBoxName.Text = ""; TextBoxCreadits.Text = ""; TextBoxDepartment.Text = ""; TextBoxMandatory.Text = ""; TextBoxYear.Text = ""; TextBoxSemester.Text = ""; txtLec.Text = ""; txtRegister.Text = ""; txtMaxNum.Text = ""; txtLecName.Text = ""; } else { msg.Text = "has not been add"; msg.Visible = true; } }
public void AddExistingCourse() { //Create New Object From DepartmentCourses Class DepartmentCourses c = new DepartmentCourses("software", "3", "1", "Course 1", "2212", "Sunday", "8", "13", "3", "Yes", "1111", "10", "20", "GG"); //Insert The Course to the Database bool result = c.insertCourse(); //We Should Get False Because The Course Exists Assert.AreEqual(result, false); }
protected void btnDelete_Click(object sender, EventArgs e) { DepartmentCourses l = new DepartmentCourses(txtDeleteCourse.Text); if (l.DeleteCourse()) { lblMSN.Text = "The Course has been delete"; lblMSN.Visible = true; } else { lblMSN.Text = "this is not exsist"; lblMSN.Visible = true; } }
protected void btnAdd_Click(object sender, EventArgs e) { DepartmentCourses nd = new DepartmentCourses(txtIdCourse.Text); if (nd.CheckCourseNull()) { Lecture l = new Lecture(Session["ID_Lecture"].ToString()); if (l.checkIfLectureExsist()) { LectureOfCourse lec = new LectureOfCourse(txtIdCourse.Text, Session["ID_Lecture"].ToString()); if (lec.insertCourseForLecture()) { lblMsn.Visible = true; lblMsn.Text = "Has Been Added"; DepartmentCourses dd = new DepartmentCourses(Session["ID_Lecture"].ToString(), Session["Lecture"].ToString(), txtIdCourse.Text, Session["DepartmentLecture"].ToString()); //dd.UpdateRegisteringLecture(); dd.updateLectureName(); dd.UdpateLectureId(); } else { lblMsn.Visible = true; lblMsn.Text = "Already Exsist!"; } } else { lblMsn.Visible = true; lblMsn.Text = "Lecture is not exsist"; } } else { lblMsn.Visible = true; lblMsn.Text = "the course is unavailable "; } string sql = "select * from DepartmentCourses where Department='" + Session["DepartmentLecture"].ToString() + "' and Lecture='null' and LectureName='null'"; DataTable d = DBFunctions.SelectFromTable(sql); GridViewlist.DataSource = d; DataBind(); }
protected void btnExploreCourse_Click(object sender, EventArgs e) { DepartmentCourses L = new DepartmentCourses(txtIdCourse.Text); DataTable f = null; f = L.UpdateExsistCourse(); if (f != null) { //txtNameHotel.Text = f.Rows[0]["Name_HVA"].ToString(); Session["IdCourse"] = txtIdCourse; pnlUpdtaeMandatory.Visible = true; } else { lblMsn.Text = " the Id of Course not Exsist"; lblMsn.Visible = true; pnlUpdtaeMandatory.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { DepartmentCourses cc = new DepartmentCourses(Session["ID_Lecture"].ToString()); //lbltest.Text = Session["ID_Lecture"].ToString(); //Lecture c = new Lecture(Session["ID_Lecture"].ToString()); if (!IsPostBack) { string sql = "Select * From [DepartmentCourses] where Lecture='" + Session["ID_Lecture"] + "'"; DataTable dt = DBFunctions.SelectFromTable(sql); GridViewLuctureCourses.DataSource = dt; DataBind(); //להופעת טבלה } int sum = 0; string sqlCredits = "select Credits from [DepartmentCourses] where Lecture='" + Session["ID_Lecture"] + "'"; DataTable dt1 = DBFunctions.SelectFromTable(sqlCredits); // while (dt1.Rows.Count > 0) { sum = sum + dt1.ToString(); } lblTotalCredits.Text = sum.ToString(); }
protected void btnUpdate_Click(object sender, EventArgs e) { // Courses L = new Courses(); if (dropUpdateMandatory.SelectedItem.Text.Equals("No")) { Session["Drop"] = "No"; //DepartmentCourses c1 = new DepartmentCourses(txtIdCourse.Text); DepartmentCourses c = new DepartmentCourses(txtIdCourse.Text, Session["Drop"].ToString()); c.UpdateCourses(); lblMsn.Visible = true; lblMsn.Text = "Successfully Update it"; } if (dropUpdateMandatory.SelectedItem.Text.Equals("Yes")) { Session["Drop"] = "Yes"; DepartmentCourses c = new DepartmentCourses(txtIdCourse.Text, Session["Drop"].ToString()); c.UpdateCourses(); lblMsn.Visible = true; lblMsn.Text = "Successfully Update it"; } }
protected void btnCancel_Click1(object sender, EventArgs e) { /* DataTable data=null; * string sql = "select [Id_Course] from [StudentAtCourse] where Id_Student='" + Session["ID"] + "'"; * DataTable dt = DBFunctions.SelectFromTable(sql); * int h = dt.Rows.Count; * if (h>0) * { * string s = dt.Rows[0]["Id_Course"].ToString(); * string year = "select Year from [DepartmentCourses] where IdCourse= '" + s + "'"; * string sem = "select semester from [DeaprtmentCourses] where IdCourse='" + s + "'"; * if(Session["Year"].ToString()==year && Session["Semester"].ToString()==sem) * { * string sql1 = "select * from [DepartmentCourses] where IdCourse='" + s + "'"; * data = DBFunctions.SelectFromTable(sql1); * } * * for(int d = 1; d < h; d++) * { * s = dt.Rows[0]["Id_Course"].ToString(); * year = "select Year from [DepartmentCourses] where IdCourse= '" + s + "'"; * sem = "select semester from [DeaprtmentCourses] where IdCourse='" + s + "'"; * if (Session["Year"].ToString() == year && Session["Semester"].ToString() == sem) * { * string sql2 = "select * from [DepartmentCourses] where IdCourse='" + s + "'"; * DataTable data2 = DBFunctions.SelectFromTable(sql2); * data.Merge(data2); * } * else * { * h = h - 1; * } * * * } * GridViewAdded.DataSource = data; * DataBind(); * * }*/ string sql = "select * from [DepartmentCourses] where Department='" + Session["Department"] + "' and Year='" + Session["Year"] + "' and Semster='" + Session["Semester"] + "'"; DataTable dt = DBFunctions.SelectFromTable(sql); GridViewRegistering.DataSource = (dt); for (int j = 0; j < GridViewAdded.Rows.Count; j++) { if (((CheckBox)GridViewAdded.Rows[j].FindControl("CheckBox1")).Checked == true) { string s = GridViewAdded.Rows[j].ToString(); StudentAtCourse ss = new StudentAtCourse(s, Session["ID"].ToString()); if (ss.DeleteCourseForStudent()) { string muchStudents = dt.Rows[j]["RegisteredStudents"].ToString(); string maxStudent = dt.Rows[j]["MaxStudent"].ToString(); int num = Convert.ToInt32(muchStudents) - 1; DepartmentCourses d = new DepartmentCourses(num.ToString(), maxStudent, s); d.UpdateRegisteringStudent(); lblMsn.Text = "Has Been Deleted"; GridViewAdded.Rows[j].Visible = false; } else { lblMsn.Text = "Is Already not exsist"; } } else { string s = dt.Rows[j]["IdCourse"].ToString(); string sql2 = "select * from [DepartmentCourses] where IdCourse= '" + s + "'"; DataTable dt2 = DBFunctions.SelectFromTable(sql2); if (dt1 == null) { dt1 = dt2; } else { dt1.Merge(dt2); } } } GridViewAdded.DataSource = (dt1); DataBind(); }
protected void BTNADDED_Click1(object sender, EventArgs e) { int num = 0; string sql = "select * from [DepartmentCourses] where Department='" + Session["Department"] + "' and Year='" + Session["Year"] + "' and Semster='" + Session["Semester"] + "'"; DataTable dt = DBFunctions.SelectFromTable(sql); GridViewRegistering.DataSource = (dt); // DataTable dt1=null; if (((CheckBox)GridViewRegistering.Rows[0].FindControl("CheckBox1")).Checked == true) { string s = dt.Rows[0]["IdCourse"].ToString(); string sql2 = "select * from [DepartmentCourses] where IdCourse= '" + s + "'"; DataTable dt2 = DBFunctions.SelectFromTable(sql2); string muchStudents = dt.Rows[0]["RegisteredStudents"].ToString(); string maxStudent = dt.Rows[0]["MaxStudent"].ToString(); StudentAtCourse c = new StudentAtCourse(s, Session["ID"].ToString()); if (Convert.ToInt32(muchStudents) < Convert.ToInt32(maxStudent)) { if (c.insertCourseForStudent()) { num = Convert.ToInt32(muchStudents) + 1; DepartmentCourses d = new DepartmentCourses(num.ToString(), maxStudent, s); d.UpdateRegisteringStudent(); lblMsn.Visible = true; lblMsn.Text = "Has Been Added"; } else { lblMsn.Visible = true; lblMsn.Text = "Already Exsist!"; } dt1 = DBFunctions.SelectFromTable(sql2); } } for (int i = 1; i < dt.Rows.Count; i++) { if (((CheckBox)GridViewRegistering.Rows[i].FindControl("CheckBox1")).Checked == true) { string s = dt.Rows[i]["IdCourse"].ToString(); string muchStudents = dt.Rows[i]["RegisteredStudents"].ToString(); string maxStudent = dt.Rows[i]["MaxStudent"].ToString(); StudentAtCourse c = new StudentAtCourse(s, Session["ID"].ToString()); if (Convert.ToInt32(muchStudents) < Convert.ToInt32(maxStudent)) { if (c.insertCourseForStudent()) { num = Convert.ToInt32(muchStudents) + 1; DepartmentCourses d = new DepartmentCourses(num.ToString(), maxStudent, s); d.UpdateRegisteringStudent(); lblMsn.Visible = true; lblMsn.Text = "Has Been Added"; } else { lblMsn.Visible = true; lblMsn.Text = "Already Exsist!"; } } else { lblMsn.Visible = true; lblMsn.Text = "There is no place in this course!"; } string sql2 = "select * from [DepartmentCourses] where IdCourse= '" + s + "'"; DataTable dt2 = DBFunctions.SelectFromTable(sql2); if (dt1 == null) { dt1 = dt2; } else { dt1.Merge(dt2); } } } GridViewAdded.DataSource = (dt1); newDt = DBFunctions.CopyDataTable(dt1, dt1.Rows.Count); DataBind(); }
protected void btnAdd_Click(object sender, EventArgs e) { DataTable dt1 = null; string sql = "select * from DepartmentCourses where Department='" + Session["DepartmentLecture"] + "'and Lecture='null' and LectureName='null'"; DataTable dt = DBFunctions.SelectFromTable(sql); GridViewRegistering.DataSource = dt; if (((CheckBox)GridViewRegistering.Rows[0].FindControl("CheckBox2")).Checked == true) { string s = dt.Rows[0]["IdCourse"].ToString(); string sql1 = "select * from DepartmentCourses where IdCourse='" + s + "'"; LectureOfCourse l = new LectureOfCourse(s, Session["ID_Lecture"].ToString()); if (l.insertCourseForLecture()) { DepartmentCourses d = new DepartmentCourses(Session["ID_Lecture"].ToString(), Session["Lecture"].ToString(), s, Session["DepartmentLecture"].ToString()); d.UpdateRegisteringLecture(); lblMsn.Visible = true; lblMsn.Text = "Has Been Added"; } else { lblMsn.Visible = true; lblMsn.Text = "Error!"; } dt1 = DBFunctions.SelectFromTable(sql1); } for (int i = 1; i < dt.Rows.Count; i++) { if (((CheckBox)GridViewRegistering.Rows[i].FindControl("CheckBox2")).Checked == true) { string s = dt.Rows[i]["IdCourse"].ToString(); // string sql1 = "select * from DeaprtmentCourses where IdCourse='" + s + "'"; LectureOfCourse l = new LectureOfCourse(s, Session["ID_Lecture"].ToString()); if (l.insertCourseForLecture()) { DepartmentCourses d = new DepartmentCourses(Session["ID_Lecture"].ToString(), Session["Lecture"].ToString(), s, Session["DepartmentLecture"].ToString()); d.UpdateRegisteringLecture(); lblMsn.Visible = true; lblMsn.Text = "Has Been Added"; } else { lblMsn.Visible = true; lblMsn.Text = "Error!"; } string sql2 = "select * from [DepartmentCourses] where IdCourse= '" + s + "'"; DataTable dt2 = DBFunctions.SelectFromTable(sql2); if (dt1 == null) { dt1 = dt2; } else { dt1.Merge(dt2); } } } GridViewPrint.DataSource = dt1; DataBind(); }
protected void btnCurSem_Click(object sender, EventArgs e) { DataTable dt1 = new DataTable(); int sum = 0, num; string sql = "Select [Id_Course] From [StudentAtCourse] where Id_Student='" + Session["ID"] + "'"; DataTable dt = DBFunctions.SelectFromTable(sql); Session["data"] = dt.Rows[0]; if (dt.Rows.Count > 0) { string s = dt.Rows[0]["Id_Course"].ToString(); string sql2 = "select * from [DepartmentCourses] where IdCourse= '" + s + "' and Year='" + Session["YearStudent"] + "' and Semster='" + Session["SemsterSud"] + "'"; // string totsql = "select Credits from [Courses] where ID='" + s + "'"; string tot = "select Credits from [DepartmentCourses] where IdCourse='" + s + "' and Year='" + Session["YearStudent"] + "' and Semster='" + Session["SemsterSud"] + "'"; string h1 = "select HourStart from [DepartmentCourses] where IdCourse='" + s + "' and Year='" + Session["YearStudent"] + "' and Semster='" + Session["SemsterSud"] + "'"; string h2 = "select HourEnd from [DepartmentCourses] where IdCourse ='" + s + "' and Year='" + Session["YearStudent"] + "' and Semster='" + Session["SemsterSud"] + "'"; DataTable hourst = DBFunctions.SelectFromTable(h1); DataTable houre = DBFunctions.SelectFromTable(h2); DepartmentCourses hsd = new DepartmentCourses(s); DataTable hss = hsd.sessionHourStart(); DataTable hee = hsd.sessionHourEnd(); string hs = hss.Rows[0]["HourStart"].ToString(); string he = hee.Rows[0]["HourEnd"].ToString(); int countt = Math.Abs(Convert.ToInt32(hs) - Convert.ToInt32(he)); // DataTable dtHours1 = DBFunctions.SelectFromTable(countt.ToString()); DataTable tott = DBFunctions.SelectFromTable(tot); DataTable dt2 = DBFunctions.SelectFromTable(sql2); for (int i = 1; i < dt.Rows.Count; i++) { s = dt.Rows[i]["Id_Course"].ToString(); sql2 = "select * from [DepartmentCourses] where IdCourse= '" + s + "' and Year='" + Session["YearStudent"] + "' and Semster='" + Session["SemsterSud"] + "'"; tot = "select Credits from [DepartmentCourses] where IdCourse='" + s + "' and Year='" + Session["YearStudent"] + "' and Semster='" + Session["SemsterSud"] + "'"; h1 = "select HourStart from [DepartmentCourses] where IdCourse='" + s + "' and Year='" + Session["YearStudent"] + "' and Semster='" + Session["SemsterSud"] + "'"; h2 = "select HourEnd from [DepartmentCourses] where IdCourse ='" + s + "' and Year='" + Session["YearStudent"] + "' and Semster='" + Session["SemsterSud"] + "'"; DataTable hourst2 = DBFunctions.SelectFromTable(h1); DataTable houre2 = DBFunctions.SelectFromTable(h2); DepartmentCourses hssd = new DepartmentCourses(s); DataTable hsss = hssd.sessionHourStart(); DataTable heee = hssd.sessionHourEnd(); string hs1 = hsss.Rows[0]["HourStart"].ToString(); string he1 = heee.Rows[0]["HourEnd"].ToString(); countt += Math.Abs(Convert.ToInt32(hs1) - Convert.ToInt32(he1)); // DataTable dtHours2 = DBFunctions.SelectFromTable(count.ToString()); DataTable tt = DBFunctions.SelectFromTable(tot); DataTable dt3 = DBFunctions.SelectFromTable(sql2); dt2.Merge(dt3); tott.Merge(tt); // dtHours1.Merge(dtHours2); } // string cc = dtHours1.Rows[0].ToString(); int c = 0; c += countt; string ss = tott.Rows[0]["Credits"].ToString(); num = Convert.ToInt32(ss); sum = num; // txttot.Text = tott.Rows.Count.ToString(); // string totsql = "select Credits from [Courses] where ID='" + s + "'"; // DataTable newdt = DBFunctions.SelectFromTable(totsql); for (int i = 1; i < tott.Rows.Count; i++) { ss = tott.Rows[i]["Credits"].ToString(); sum += Convert.ToInt32(ss); } int counttt = 0; for (int a = 0; a < dt2.Rows.Count; a++) { s = dt2.Rows[a]["IdCourse"].ToString(); DepartmentCourses hssd = new DepartmentCourses(s); DataTable hsss = hssd.sessionHourStart(); DataTable heee = hssd.sessionHourEnd(); string hs1 = hsss.Rows[0]["HourStart"].ToString(); string he1 = heee.Rows[0]["HourEnd"].ToString(); counttt += Math.Abs(Convert.ToInt32(hs1) - Convert.ToInt32(he1)); } /* for(int j=0;j<dtHours1.Rows.Count;j++) * { * cc = dtHours1.Rows[j].ToString(); * c += Convert.ToInt32(cc); * }*/ lblFinalTot.Text = sum.ToString(); lblFinalHours.Text = counttt.ToString(); GridViewPrint.DataSource = dt2; DataBind(); //להופעת טבלה } }
protected void btnDelete_Click(object sender, EventArgs e) { StudentAtCourse nd = new StudentAtCourse(txtIdCourse.Text, Session["ID"].ToString()); if (nd.DeleteCourseForStudent()) { string re = "select * from StudentAtCourse where Id_Course='" + txtIdCourse.Text + "'"; DataTable dr = DBFunctions.SelectFromTable(re); DepartmentCourses ds = new DepartmentCourses(txtIdCourse.Text); // int muchStudent=Convert.ToInt32( ds.sessionMuchStudent()); DataTable dtmaxStudent = ds.sessionMaxStudents(); string maxStudent = dtmaxStudent.Rows[0]["maxStudent"].ToString(); //int num11 = (muchStudent) - 1; int r = dr.Rows.Count; if (r == 0) { // r--; DepartmentCourses d1 = new DepartmentCourses("0", maxStudent, txtIdCourse.Text); d1.UpdateRegisteringStud(); } else { r--; DepartmentCourses d1 = new DepartmentCourses(r.ToString(), maxStudent, txtIdCourse.Text); d1.UpdateRegisteringStud(); } lblMsn.Visible = true; lblMsn.Text = "Has Been Delete it!"; } else { lblMsn.Visible = true; lblMsn.Text = "Not Exsist!"; } int sum = 0, num; string sql = "Select [Id_Course] From [StudentAtCourse] where Id_Student='" + Session["ID"] + "'"; DataTable dt = DBFunctions.SelectFromTable(sql); Session["data"] = dt.Rows[0]; if (dt.Rows.Count > 0) { string s = dt.Rows[0]["Id_Course"].ToString(); string sql2 = "select * from [DepartmentCourses] where IdCourse= '" + s + "'"; // string totsql = "select Credits from [Courses] where ID='" + s + "'"; string tot = "select Credits from [DepartmentCourses] where IdCourse='" + s + "'"; DataTable tott = DBFunctions.SelectFromTable(tot); DataTable dt2 = DBFunctions.SelectFromTable(sql2); for (int i = 1; i < dt.Rows.Count; i++) { s = dt.Rows[i]["Id_Course"].ToString(); sql2 = "select * from [DepartmentCourses] where IdCourse= '" + s + "'"; tot = "select Credits from [DepartmentCourses] where IdCourse='" + s + "'"; DataTable tt = DBFunctions.SelectFromTable(tot); DataTable dt3 = DBFunctions.SelectFromTable(sql2); dt2.Merge(dt3); tott.Merge(tt); } string ss = tott.Rows[0]["Credits"].ToString(); num = Convert.ToInt32(ss); sum = num; // txttot.Text = tott.Rows.Count.ToString(); // string totsql = "select Credits from [Courses] where ID='" + s + "'"; // DataTable newdt = DBFunctions.SelectFromTable(totsql); for (int i = 1; i < tott.Rows.Count; i++) { ss = tott.Rows[i]["Credits"].ToString(); sum += Convert.ToInt32(ss); } lblFinalTot.Text = sum.ToString(); GridViewDelete.DataSource = dt2; DataBind();//להופעת טבלה } }