private void btn_Login_Click(object sender, EventArgs e)
 {
     int member_id;
     if (txt_Username.Text == "")
     {
         MessageBox.Show("Username is required");
     }
     if(txt_Password.Text == "")
     {
         MessageBox.Show("Password is required");
     }
     if (txt_Password.Text != "" && txt_Username.Text != "")
     {
         try
         {
             connection.Open();
             OleDbDataAdapter da = new OleDbDataAdapter("select * from MemberData where username = '******' and pass='******'", connection);
             DataTable dt = new DataTable();
             da.Fill(dt);
             //เก็บค่า member_id เพื่อส่งต่อไปยัง doorder จะได้รุ้ว่าใครทำรายาการ
             member_id = Int32.Parse(dt.Rows[0][0].ToString());
             //ถ้า username และ password ถูกต้อง
             if (dt.Rows.Count == 1)
             {
                 MessageBox.Show("Login Successful");
                 DoOrder doorder = new DoOrder(member_id);
                 this.Hide();
                 doorder.ShowDialog();
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Your Username or Password is invalid");
             }
             connection.Close();
         }
         catch (Exception ex)
         {
             connection.Close();
             MessageBox.Show("Your Username or Password is invalid");
         }
     }
 }
 private void btn_Login_Click(object sender, EventArgs e)
 {
     int member_id;
     if (txt_RfidNumber.Text == "")
     {
         MessageBox.Show("Rfiudnumber is required");
     }
     if (txt_Password.Text == "")
     {
         MessageBox.Show("Password is required");
     }
     if (txt_RfidNumber.Text != "" && txt_Password.Text != "")
     {
         try
         {
             connection.Open();
             OleDbDataAdapter da = new OleDbDataAdapter("select * from MemberData where rfid_number = '" + txt_RfidNumber.Text + "' and pass='******'", connection);
             DataTable dt = new DataTable();
             da.Fill(dt);
             member_id = Int32.Parse(dt.Rows[0][0].ToString());
             if (dt.Rows.Count == 1)
             {
                 MessageBox.Show("Login Successful");
                 serialPort1.Close();
                 DoOrder doorder = new DoOrder(member_id);
                 this.Hide();
                 doorder.ShowDialog();
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Rfidnumber or Password is invalid");
             }
             connection.Close();
         }
         catch (Exception ex)
         {
             connection.Close();
             MessageBox.Show("Your Rfidnumber or Password is invalid");
         }
     }
 }