public F_Secretary() { InitializeComponent(); user = (Secretary)db.USER; show_info(); frm = new Form(); }
public static Boolean Create(int type, String values, String id) { db.AddToTable(db.TPERSON, values); Employee _user; switch (type) { case 0: //student values = id + ", 0.0, 1, '', '', '', 1, 1"; //default student values db.AddToTable(db.TSTUDENT, values); break; case 1: //secretary _user = new Secretary(); values = id + ", " + _user.SALARY + ", null, 0, " + type; //default secretary values db.AddToTable(db.TEMPLOYEE, values); break; case 2: //tutor _user = new Tutor(); values = id + ", " + _user.SALARY + ", null, 1, " + type; //default tutor values db.AddToTable(db.TEMPLOYEE, values); db.AddToTable(db.TRECEPTION, id + ", '1', '2015-05-26 00:00:00.000', '2015-05-26 00:00:00.000'"); break; case 3: //lecturer _user = new Lecturer(); values = id + ", " + _user.SALARY + ", null, 2, " + type; //default lecturer values db.AddToTable(db.TEMPLOYEE, values); db.AddToTable(db.TRECEPTION, id + ", '1', '2015-05-26 00:00:00.000', '2015-05-26 00:00:00.000'"); break; case 4: //department head _user = new HeadDept(); values = id + ", " + _user.SALARY + ", null, 2, " + type; //default head dept values db.AddToTable(db.TEMPLOYEE, values); break; } return(db.checkExistance(db.TPERSON, "id = " + id)); }
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); }
//Methods-------------------------------------------------------------------------------------------// public F_Register() { InitializeComponent(); user = (Secretary)db.USER; if (user != null) { Point pt = new Point(); type_box.Hide(); label6.Hide(); dept_box.Hide(); label10.Hide(); type_box.Items.Add("Student"); type_box.SelectedIndex = 0; dept_box.Items.Add(user.SDEPT()); dept_box.SelectedIndex = 0; grade_label.Show(); grade_box.Show(); WindowState = FormWindowState.Normal; StartPosition = FormStartPosition.CenterScreen; FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; // password label pt = label2.Location; pt.Offset(0, 20); label2.Location = pt; // password box pt = pass_box.Location; pt.Offset(0, 20); pass_box.Location = pt; // id label pt = label3.Location; pt.Offset(0, 40); label3.Location = pt; // id box pt = id_box.Location; pt.Offset(0, 40); id_box.Location = pt; // firstname label pt = label4.Location; pt.Offset(0, 60); label4.Location = pt; // firstname box pt = fname_box.Location; pt.Offset(0, 60); fname_box.Location = pt; // lastname label pt = label5.Location; pt.Offset(0, 80); label5.Location = pt; // lastname box pt = lname_box.Location; pt.Offset(0, 80); lname_box.Location = pt; // email label pt = label8.Location; pt.Offset(0, 100); label8.Location = pt; // email box pt = mail_box.Location; pt.Offset(0, 100); mail_box.Location = pt; //phone label pt = label8.Location; pt.Offset(0, 46); label9.Location = pt; //phone box pt = mail_box.Location; pt.Offset(0, 46); phon_box.Location = pt; phon_box.Size = mail_box.Size; //m radio pt = phon_box.Location; pt.Offset(6, 46); m_radio.Location = pt; //f radio pt = m_radio.Location; pt.Offset(62, 0); f_radio.Location = pt; //gender label pt = label9.Location; pt.Offset(0, 46); label7.Location = pt; //grade label pt = label7.Location; pt.Offset(-5, 40); grade_label.Location = pt; //grade box pt = phon_box.Location; pt.Offset(1, 86); grade_box.Location = pt; grade_box.Size = mail_box.Size; //ok button pt = grade_label.Location; pt.Offset(-10, 40); ok_button.Location = pt; //exit button pt = ok_button.Location; pt.Offset(120, 0); ex_button.Location = pt; stud_dept = user.DEPT; } else { type_box.Show(); label6.Show(); dept_box.Show(); label10.Show(); grade_label.Hide(); grade_box.Hide(); type_box.Items.AddRange(new object[] { "Tutor", "Lecturer", "Secretary", "Head of a Department" }); dept_box.Items.AddRange(new object[] { "Software", "Electronic", "Civil", "Chemistry", "Industrial-Management", "Machines" }); } }