private void Login_Button_Click(object sender, EventArgs e) { string ID = this.SID_Text.Text; string PW = this.SPW_Text.Text; if (ID == "" || PW == "") { MessageBox.Show("Please enter your Student Number and Password Correctly"); SID_Text.Focus(); } else { try { objconn.Open(); string logQuery = "SELECT s.Student_no, s.Student_PW, s.FirstName, s.LastName, d.Depart_Name FROM Student_info s " + "inner join Depart_info d ON (s.Depart_ID = d.Depart_ID) " + "WHERE s.Student_no = '" + ID + "' and Student_PW = '" + PW + "'"; SqlCommand logCmd = new SqlCommand(logQuery, objconn); reader = logCmd.ExecuteReader(); if (reader.Read()) { string FN = reader["FirstName"].ToString(); string LN = reader["LastName"].ToString(); MessageBox.Show("Welcome " + FN + "!"); Register1_Form f2 = new Register1_Form(); f2.Show(); f2.SID_Text.Text = reader["Student_no"].ToString(); f2.SN_Text.Text = FN + " " + LN; f2.SD_Text.Text = reader["Depart_Name"].ToString(); this.Hide(); } else { MessageBox.Show("Invalid ID or Password. Please Enter again."); } objconn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public Start_Form() { InitializeComponent(); SearchTerm_Combo.SelectedIndex = 0; SID_Text.Focus(); }