private void Button_Click(object sender, RoutedEventArgs e) { String connLine = ""; if (Application.Current.Properties["sqlCon"] == null) { Application.Current.Properties["sqlCon"] = "SERVER=localhost; uid=root; pwd='itkmitl2014'; database=factory management; charset=utf8;"; connLine = (String)Application.Current.Properties["sqlCon"]; } else { connLine = (String)Application.Current.Properties["sqlCon"]; } Boolean flag = ConnectionTester(connLine); if (flag == true) { //MessageBox.Show("Database connection is ok!", "สถานะ Database"); String[] dataComing = getPass(this.username.Text, connLine); String pass_out = MD5Convert(this.pass.Password); if (pass_out.ToLower() == dataComing[0]) { loginFlag = true; Application.Current.Properties["role"] = dataComing[1]; Application.Current.Properties["iduser"] = dataComing[2]; MessageBox.Show(this.username.Text); Mainprogram sesy = new Mainprogram(); sesy.Show(); this.Close(); } else { MessageBox.Show("รหัสผ่านหรือ username ผิด", "Factory Manager: Failed to login"); } Application.Current.Properties["userFlag"] = loginFlag; } else { if (MessageBox.Show("การเชื่อมต่อ database มีปัญหากรุณาใส่ข้อมูลการเชื่อมต่อใหม่", "สถานะ Database", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { checkConnect sesy = new checkConnect(); sesy.Show(); } else { Application.Current.Shutdown(); } } }