private void OKButton_Click(object sender, RoutedEventArgs e) { if (ProvostNametextbox.Text.Length == 0) { MessageBox.Show("Enter User Name", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } if (ProvostPasswordtextbox.Password.Length == 0) { MessageBox.Show("Enter Password", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } if (string.IsNullOrEmpty(ProvostRankComboBox.Text)) { MessageBox.Show("Select Designation", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } else { string user = ProvostNametextbox.Text; string password = ProvostPasswordtextbox.Password; string Utype =ProvostRankComboBox.SelectedItem.ToString(); SqlConnection dataConnection = new SqlConnection(dataconnection); dataConnection.Open(); SqlCommand cmd = new SqlCommand("Select * from Users where UserName='******' And Password='******'", dataConnection); cmd.CommandType = CommandType.Text; SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = cmd; DataSet dataSet = new DataSet(); adapter.Fill(dataSet); if (dataSet.Tables[0].Rows.Count > 0) { string level = dataSet.Tables[0].Rows[0]["UserType"].ToString(); string nm = dataSet.Tables[0].Rows[0]["UserName"].ToString(); if (Utype == level) { if (level == "Provost") { MainWindow1 mainwindow = new MainWindow1(); mainwindow.Welcometextblock.Text = nm; mainwindow.Entertextblock.Text = level; mainwindow.ShowDialog(); Close(); } else if (level == "Assistant Provost") { AssistantProvostWindow mainwindow = new AssistantProvostWindow(); mainwindow.Welcometextblock.Text = nm; mainwindow.Entertextblock.Text = level; mainwindow.ShowDialog(); Close(); } else { MessageBox.Show("Select a User", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show("Incorrect User Type", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show("Sorry! Please enter existing User Name/ Password.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } dataConnection.Close(); } }
private void backButton_Click(object sender, RoutedEventArgs e) { MainWindow1 main = new MainWindow1(); main.Show(); this.Close(); }