private void button1_Click(object sender, EventArgs e) { String courses = ""; for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (Convert.ToBoolean(dataGridView1.Rows[i].Cells[0].Value) == true) { courses += dataGridView1.Rows[i].Cells[1].Value.ToString() + "#"; } } if (lect != null) { if (lect.COURSES.Count == 0) { db.SimpleUpdate(db.TEMPLOYEE, "Courses = '" + courses + "'", "id = " + lect.ID); } else { db.SimpleUpdate(db.TEMPLOYEE, "Courses = Courses + '" + courses + "'", "id = " + lect.ID); } lect.decrypt_courses(courses); MessageBox.Show("The courses that selected are added"); F_Add_Courses_Load(new object(), new EventArgs()); } if (stud != null) { if (stud.COURSES.Count == 0) { db.SimpleUpdate(db.TSTUDENT, "Courses = '" + courses + "'", "id = " + stud.ID); } else { db.SimpleUpdate(db.TSTUDENT, "Courses = Courses + '" + courses + "'", "id = " + stud.ID); } stud.decrypt_courses(courses); for (int i = 0; i < stud.COURSES.Count; i++) { foreach (Course value in stud.GRADES) { if (value.CNUM == stud.COURSES[i].CNUM) { stud.GRADES.Remove(value); break; } } } String gradecode = ""; for (int i = 0; i < stud.GRADES.Count; i++) { gradecode += stud.GRADES[i].CNUM + '$' + stud.GRADES[i].GRADE + '#'; } db.SimpleUpdate(db.TSTUDENT, "grades = '" + gradecode + "'", "id = " + stud.ID); MessageBox.Show("The courses that were selected are added"); F_Add_Courses_Load(new object(), new EventArgs()); } }
public Employee getEmployee(String Conditions) { Employee _emp = null; List <String> itemList = new List <String>(); itemList = FetchList(TPerson, "*", Conditions); switch (Convert.ToInt32(itemList[9])) { case 1: //secretary Secretary _sec = new Secretary(); _sec.USERNAME = itemList[0]; _sec.PASSWORD = itemList[1]; _sec.ID = itemList[2]; _sec.FIRSTNAME = itemList[3]; _sec.LASTNAME = itemList[4]; _sec.MAIL = itemList[5]; _sec.PHONE = itemList[6]; _sec.GENDER = (Gender)(Convert.ToInt32(itemList[7])); _sec.DEPT = (Department)(Convert.ToInt32(itemList[8])); //-------------------------------------------------------------------------------------------// itemList = FetchList(TEmployee, "*", "id = " + _sec.ID); //-------------------------------------------------------------------------------------------// _sec.SALARY = Convert.ToSingle(itemList[1]); _sec.DEGREE = (Degree)(Convert.ToInt32(itemList[3])); _sec.JOB = (Job)(Convert.ToInt32(itemList[4])); _emp = _sec; break; case 2: //tutor Tutor _tut = new Tutor(); _tut.USERNAME = itemList[0]; _tut.PASSWORD = itemList[1]; _tut.ID = itemList[2]; _tut.FIRSTNAME = itemList[3]; _tut.LASTNAME = itemList[4]; _tut.MAIL = itemList[5]; _tut.PHONE = itemList[6]; _tut.GENDER = (Gender)(Convert.ToInt32(itemList[7])); _tut.DEPT = (Department)(Convert.ToInt32(itemList[8])); //-------------------------------------------------------------------------------------------// itemList = FetchList(TEmployee, "*", "id = " + _tut.ID); //-------------------------------------------------------------------------------------------// _tut.SALARY = Convert.ToSingle(itemList[1]); _tut.decrypt_courses(itemList[2]); _tut.DEGREE = (Degree)(Convert.ToInt32(itemList[3])); _tut.JOB = (Job)(Convert.ToInt32(itemList[4])); _emp = _tut; break; case 3: //lecturer Lecturer _lect = new Lecturer(); _lect.USERNAME = itemList[0]; _lect.PASSWORD = itemList[1]; _lect.ID = itemList[2]; _lect.FIRSTNAME = itemList[3]; _lect.LASTNAME = itemList[4]; _lect.MAIL = itemList[5]; _lect.PHONE = itemList[6]; _lect.GENDER = (Gender)(Convert.ToInt32(itemList[7])); _lect.DEPT = (Department)(Convert.ToInt32(itemList[8])); //-------------------------------------------------------------------------------------------// itemList = FetchList(TEmployee, "*", "id = " + _lect.ID); //-------------------------------------------------------------------------------------------// _lect.SALARY = Convert.ToSingle(itemList[1]); _lect.decrypt_courses(itemList[2]); _lect.DEGREE = (Degree)(Convert.ToInt32(itemList[3])); _lect.JOB = (Job)(Convert.ToInt32(itemList[4])); _emp = _lect; break; case 4: //dept head HeadDept _hoad = new HeadDept(); _hoad.USERNAME = itemList[0]; _hoad.PASSWORD = itemList[1]; _hoad.ID = itemList[2]; _hoad.FIRSTNAME = itemList[3]; _hoad.LASTNAME = itemList[4]; _hoad.MAIL = itemList[5]; _hoad.PHONE = itemList[6]; _hoad.GENDER = (Gender)(Convert.ToInt32(itemList[7])); _hoad.DEPT = (Department)(Convert.ToInt32(itemList[8])); //-------------------------------------------------------------------------------------------// itemList = FetchList(TEmployee, "*", "id = " + _hoad.ID); //-------------------------------------------------------------------------------------------// _hoad.SALARY = Convert.ToSingle(itemList[1]); _hoad.DEGREE = (Degree)(Convert.ToInt32(itemList[3])); _hoad.JOB = (Job)(Convert.ToInt32(itemList[4])); _emp = _hoad; break; } return(_emp); }