async void enter() { database_connection dc = new database_connection(); DataSet ds; string query; try { query = $@"select Id,Pass from AdminLogin where Id='" + TextBox_IdNo.Text + "'and Pass='******'"; Loading_User.Visibility = Visibility.Visible; ds = await dc.Connection1Async(query); Loading_User.Visibility = Visibility.Hidden; int count; count = ds.Tables[0].Rows.Count; if (count > 0) { MainWindow mw = new MainWindow(); success s = new success(); this.Visibility = Visibility.Hidden; AdminContent ac = new AdminContent(); admin_drawhost ad = new admin_drawhost(); foreach (Window window in Application.Current.Windows) { if (window.GetType() == typeof(MainWindow)) { (window as MainWindow).Rectangle_MainContent.Visibility = Visibility.Hidden; (window as MainWindow).Rectangle_MainWindow.Visibility = Visibility.Hidden; (window as MainWindow).Drawer_HostContent.Content = ad; (window as MainWindow).UserContent.Content = ac; } } } else { Loading_UserInform.Visibility = Visibility.Visible; Icon2.Kind = MahApps.Metro.IconPacks.PackIconMaterialKind.MessageAlert; TextBlock_Message2.Text = "The ID No. and Password you've \n entered doesn't match".ToString(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
async void enter() { database_connection dc = new database_connection(); DataSet ds; DataRow drow; string query; try { query = $@"select Id,Pass,Firstname,Lastname,Department from UserLogin where Id='" + TextBox_IdNo.Text + "'and Pass='******'"; Loading_User.Visibility = Visibility.Visible; ds = await dc.Connection1Async(query); Loading_User.Visibility = Visibility.Hidden; int count; count = ds.Tables[0].Rows.Count; if (count > 0) { drow = ds.Tables[0].Rows[0]; userId = drow.ItemArray.GetValue(0).ToString(); firstName = drow.ItemArray.GetValue(2).ToString(); lastName = drow.ItemArray.GetValue(3).ToString(); department = drow.ItemArray.GetValue(4).ToString(); fullName = firstName + " " + lastName; MainWindow mw = new MainWindow(); success s = new success(); this.Visibility = Visibility.Hidden; user_content uc = new user_content(); user_drawhost us = new user_drawhost(); foreach (Window window in Application.Current.Windows) { if (window.GetType() == typeof(MainWindow)) { (window as MainWindow).Rectangle_MainContent.Visibility = Visibility.Hidden; (window as MainWindow).Rectangle_MainWindow.Visibility = Visibility.Hidden; (window as MainWindow).Drawer_HostContent.Content = us; (window as MainWindow).UserContent.Content = uc; } } } else { Loading_UserInform.Visibility = Visibility.Visible; Icon2.Kind = MahApps.Metro.IconPacks.PackIconMaterialKind.MessageAlert; TextBlock_Message2.Text = "The ID No. and Password you've \n entered doesn't match".ToString(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }