private void CoursesForTheSemester_FormClosed(object sender, FormClosedEventArgs e) { this.Close(); MainStudent s = (MainStudent)this.Owner; s.Show(); }
private void StudentEditSchedule_FormClosed(object sender, FormClosedEventArgs e) { this.Close(); MainStudent s = (MainStudent)this.Owner; s.Show(); }
private void EmailsOfLecturers_FormClosed(object sender, FormClosedEventArgs e) { this.Close(); MainStudent s = (MainStudent)this.Owner; s.Show(); }
private void AllCompulsoryCourses_FormClosed(object sender, FormClosedEventArgs e) { this.Close(); MainStudent s = (MainStudent)this.Owner; s.Show(); }
public void login_run(String un, String pass, Form login_form) { DBC newcon = new DBC(); List <String> userinfo = newcon.get_row_by_username(un); if (userinfo.Count > 0) { if (userinfo[1].Replace(" ", "") == pass) { //MessageBox.Show("succesfully loged in "); if (Convert.ToInt32(userinfo[2]) == (int)permission.admin) { nperson = new Admin(userinfo); (nperson as Admin).run(login_form); } else if (Convert.ToInt32(userinfo[2]) == (int)permission.sec) { nperson = new Secretary(userinfo); (nperson as Secretary).run(login_form); } else if (Convert.ToInt32(userinfo[2]) == (int)permission.prac) { nperson = new Teacher(userinfo); (nperson as Teacher).run(login_form); } else if (Convert.ToInt32(userinfo[2]) == (int)permission.lect) { nperson = new Teacher(userinfo); (nperson as Teacher).run(login_form); } else if (Convert.ToInt32(userinfo[2]) == (int)permission.md) { nperson = new deptmanager(userinfo); (nperson as deptmanager).run(login_form); } else if (Convert.ToInt32(userinfo[2]) == (int)permission.student) { char year; OPerson p; year = newcon.getStudyYear(userinfo[0]); p = new OStudent(userinfo[0], userinfo[3], userinfo[4], userinfo[5], year); MainStudent ms = new MainStudent(p as OStudent, constring); login_form.Hide(); ms.ShowDialog(login_form); } } else { MessageBox.Show("wrong password"); } } else { MessageBox.Show("wrong username or password"); } }
/*this func send massege if user name empy*/ private void Login_Click(object sender, EventArgs e) { SqlConnection c = new SqlConnection(scn); if (string.IsNullOrEmpty(Usertxt.Text)) //if string empty { MessageBox.Show("Please enter your user name", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); //shoe warning Usertxt.Focus(); //focus on username box return; //end }//end click if (string.IsNullOrEmpty(txtPassword.Text)) //if string empty { MessageBox.Show("Please enter your user password", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); //shoe warning Usertxt.Focus(); //focus on username box return; //end } String q = "select Users.userid,Users.permission,Users.first_name,Users.last_name,Users.Email from Users where username like '" + Usertxt.Text.ToString() + "' and Users.password like '" + txtPassword.Text + "'"; SqlDataAdapter da = new SqlDataAdapter(q, c); DataTable dt = new DataTable(); if (c.State != ConnectionState.Open) { c.Open(); } da.Fill(dt); if (dt.Rows.Count == 0) { MessageBox.Show("incorect username and password", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);//shoe warning } else if (dt.Rows.Count >= 2) { MessageBox.Show("more then one account", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);//shoe warning } else { if (dt.Rows[0].Field <int>("permission") == 5) { c.Close(); //c is bussy so close c.Open(); //open to new connection. da = new SqlDataAdapter("select Year from Student where username like '" + Usertxt.Text.ToString() + "'", c); //get year DataTable dr = new DataTable(); // da.Fill(dr); OStudent s = new OStudent(dt.Rows[0].Field <int>("userid").ToString(), dt.Rows[0].Field <String>("first_name").ToString(), dt.Rows[0].Field <String>("last_name").ToString(), dt.Rows[0].Field <String>("Email").ToString(), dr.Rows[0].Field <String>("Year")[0]); c.Close(); MainStudent f = new MainStudent(s, scn); this.Hide(); f.ShowDialog(this); } if (dt.Rows[0].Field <int>("permission") == 1) { c.Close();//c is bussy so close MenuStudentCoordinator f = new MenuStudentCoordinator(scn); this.Hide(); f.ShowDialog(this); } if (dt.Rows[0].Field <int>("permission") == 3) { c.Close();//c is bussy so close OLecture l = new OLecture(dt.Rows[0].Field <int>("userid").ToString(), dt.Rows[0].Field <String>("first_name").ToString(), dt.Rows[0].Field <String>("last_name").ToString(), dt.Rows[0].Field <String>("Email").ToString()); c.Close(); MenuLecturer f = new MenuLecturer(l, c); this.Hide(); f.ShowDialog(this); } if (dt.Rows[0].Field <int>("permission") == 2) { c.Close();//c is bussy so close OTutor t = new OTutor(dt.Rows[0].Field <int>("userid").ToString(), dt.Rows[0].Field <String>("first_name").ToString(), dt.Rows[0].Field <String>("last_name").ToString(), dt.Rows[0].Field <String>("Email").ToString()); c.Close(); MenuTutor f = new MenuTutor(c, t); this.Hide(); f.ShowDialog(this); } } }