private void button2_Click(object sender, EventArgs e) { DataTable dt = Program.get_dt("SELECT Permission FROM Login WHERE Id='" + u.Id + "'"); if (dt.Rows[0][0].Equals("HOD")) { this.Hide(); HeadOfDepart_Main HA = new HeadOfDepart_Main(((CHeadOfDepartment)u)); this.Closed += (s, args) => this.Close(); HA.Show(); } if (dt.Rows[0][0].Equals("TS")) { this.Hide(); TeachingStaffMenu Ts = new TeachingStaffMenu(((CTeachingStaff)u)); this.Closed += (s, args) => this.Close(); Ts.Show(); } if (dt.Rows[0][0].Equals("SEC")) { this.Hide(); SecretaryFolder.Secretary_Menu Sec = new SecretaryFolder.Secretary_Menu(((CSecretary)u)); this.Closed += (s, args) => this.Close(); Sec.Show(); } if (dt.Rows[0][0].Equals("ADS")) { this.Hide(); Administration.Administration_main Es = new Administration.Administration_main(((CAdministration)u)); this.Closed += (s, args) => this.Close(); Es.Show(); } }
private void button1_Click(object sender, EventArgs e) { TeachingStaffMenu form = new TeachingStaffMenu(TS); this.Hide(); this.Closed += (s, args) => this.Close(); form.Show(); }
public static Form LogIn(String id, String pass) {/*login to system*/ DataTable t, dt = Program.get_dt("Select * from Login where Id='" + id + "' and Password='******'"); if (dt.Rows.Count != 0) { if (dt.Rows[0][3].Equals("HOD")) { HeadOfDepart_Main HA = new HeadOfDepart_Main(new CHeadOfDepartment(dt.Rows[0][0].ToString(), dt.Rows[0][1].ToString(), dt.Rows[0][2].ToString(), dt.Rows[0][4].ToString(), dt.Rows[0][3].ToString())); return(HA); } if (dt.Rows[0][3].Equals("TS")) { t = Program.get_dt("Select * from Teaching_Staff where Id='" + id + "'"); TeachingStaffMenu Ts = new TeachingStaffMenu(new CTeachingStaff(dt.Rows[0][0].ToString(), dt.Rows[0][1].ToString(), dt.Rows[0][2].ToString(), dt.Rows[0][4].ToString(), dt.Rows[0][3].ToString(), t.Rows[0][1].ToString(), t.Rows[0][2].ToString())); return(Ts); } if (dt.Rows[0][3].Equals("SEC")) { SecretaryFolder.Secretary_Menu Sec = new SecretaryFolder.Secretary_Menu(new CSecretary(dt.Rows[0][0].ToString(), dt.Rows[0][1].ToString(), dt.Rows[0][2].ToString(), dt.Rows[0][4].ToString(), dt.Rows[0][3].ToString())); return(Sec); } if (dt.Rows[0][3].Equals("ADS")) { Administration.Administration_main Es = new Administration.Administration_main(new CAdministration(dt.Rows[0][0].ToString(), dt.Rows[0][1].ToString(), dt.Rows[0][2].ToString(), dt.Rows[0][4].ToString(), dt.Rows[0][3].ToString())); return(Es); } //Branch B/// if (dt.Rows[0][3].Equals("Student")) { String conect = @"Server=tcp:project-1.database.windows.net,1433;Initial Catalog=Data;Persist Security Info=False;User ID=Admin1;Password=Ad123456;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"; SqlConnection con = new SqlConnection(conect); SqlDataAdapter sda2 = new SqlDataAdapter("select * from Students where ID = '" + dt.Rows[0][0] + "'", con); DataTable dt2 = new DataTable(); sda2.Fill(dt2); Student student = new Student(dt2.Rows[0][1].ToString(), dt2.Rows[0][0].ToString(), dt.Rows[0][2].ToString(), dt2.Rows[0][2].ToString(), dt2.Rows[0][3].ToString(), (bool)dt2.Rows[0][4]); //first entrance of the student //need to change his initial password if (dt.Rows[0][0].Equals(dt.Rows[0][2]))//initial password equals ID { InitPassChange FM = new InitPassChange(); FM.RefToLastForm = new Login(); return(FM); } //not the first entrence of the student else { if (!student.getStatus()) { MessageBox.Show("Your student's status is NOT active,\nplease go to 'Student's Accounts'"); } else { StudentMenu HA = new StudentMenu(student); HA.RefToMainMenu = new Login(); return(HA); } } } if (dt.Rows[0][3].Equals("Secretary")) { String conect = @"Server=tcp:project-1.database.windows.net,1433;Initial Catalog=Data;Persist Security Info=False;User ID=Admin1;Password=Ad123456;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"; SqlConnection con = new SqlConnection(conect); SqlDataAdapter sda2 = new SqlDataAdapter("select * from Secretary;", con); DataTable dt2 = new DataTable(); sda2.Fill(dt2); Secretary secretery = new Secretary(dt.Rows[0][0].ToString(), dt.Rows[0][1].ToString(), dt.Rows[0][2].ToString(), dt2.Rows[0][2].ToString()); SecretaryMenu HA = new SecretaryMenu(secretery); HA.RefToMainMenu = new Login(); return(HA); } if (dt.Rows[0][3].Equals("President")) { President president = new President(dt.Rows[0][0].ToString(), dt.Rows[0][1].ToString(), dt.Rows[0][2].ToString()); PresidentMenu HA = new PresidentMenu(president); HA.RefToMainMenu = new Login(); return(HA); } if (dt.Rows[0][3].Equals("HK")) { HouseKeeper houseKeeper = new HouseKeeper(dt.Rows[0][0].ToString(), dt.Rows[0][1].ToString(), dt.Rows[0][2].ToString()); HouseKeeperMenu HA = new HouseKeeperMenu(houseKeeper); HA.RefToMainMenu = new Login(); return(HA); } } return(new Login()); }