namespace Project { /// <summary> /// Description of MainForm. /// </summary> public partial class MainForm : Form { MySqlConnection con1; MySqlCommand cmd1; MySqlDataReader reader; public string eid = "0"; public MainForm() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // // TODO: Add constructor code after the InitializeComponent() call // } private bool CompareStrings(string string1, string string2) { return String.Compare(string1, string2, true, System.Globalization.CultureInfo.InvariantCulture) == 0 ? true : false; } void Button1Click(object sender, EventArgs e) { try { string url = "Server=localhost;Database=golf;uid=root;password=1234"; string q = "SELECT emp_id,emp_username,emp_password FROM employee WHERE emp_username='" + textusername.Text + "' and emp_password='" + textpassword.Text + "'"; con1 = new MySqlConnection(url); con1.Open(); cmd1 = new MySqlCommand(); cmd1.Connection = con1; cmd1.CommandText = q; reader = cmd1.ExecuteReader(); string userText = textusername.Text; string passText = textpassword.Text; while (reader.Read()) { if (this.CompareStrings(reader["emp_username"].ToString(), userText) && this.CompareStrings(reader["emp_password"].ToString(), passText)){ eid = reader["emp_id"].ToString(); MessageBox.Show("Login Successful"); } else { MessageBox.Show("Error"); } } con1.Close(); } catch(Exception ex) { MessageBox.Show(ex.Message); textusername.Text = ""; textpassword.Text = ""; } }
void Button2Click(object sender, EventArgs e) { MainForm m1 = new MainForm(); MessageBox.Show(m1.eid); }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง