//login button private void button2_Click(object sender, EventArgs e) { string username = textBox1.Text; Int64 password = textBox2.Text.GetHashCode(); var userList = loginCredential.AsQueryable().Where(n => n.UserName == username); if (userList.Count() != 0) { var user = userList.First(); if (user.Password == password) { textBox1.Text = textBox2.Text = String.Empty; if (user.Type == "teacher") { TeacherForm t = TeacherForm.GetInstance(); MainContainer.LoadForm(t); } else { StudentForm s = StudentForm.GetInstance(user.UserName); MainContainer.LoadForm(s); } } else { MessageBox.Show("Invalid Username or Password!", "Unauthorized acess", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } else { MessageBox.Show("Invalid Username or Password!", "Unauthorized acess", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
public static TeacherForm GetInstance() { if (_instance == null) { _instance = new TeacherForm(); } else { _instance.RefreshForm(); } return(_instance); }