//Button click navigates user to previous window. private void Btn_Cancel(object sender, RoutedEventArgs e) { ModifyManagerWindow window = new ModifyManagerWindow(); window.Show(); this.Close(); }
private void btnSubmit_Click(object sender, RoutedEventArgs e) { if (txtUsername.Text == "WPFadmin" && txtPassword.Password == "WPFadmin") { AddManagerWindow window = new AddManagerWindow(); window.Show(); this.Close(); return; } SqlConnection sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString()); try { //User is extracted from the database matching inserted paramaters Username and Password. SqlCommand query = new SqlCommand("SELECT * FROM tblManager WHERE Username=@Username AND Password=@Password", sqlCon); query.CommandType = CommandType.Text; query.Parameters.AddWithValue("@Username", txtUsername.Text); query.Parameters.AddWithValue("@Password", txtPassword.Password); sqlCon.Open(); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(query); DataTable dataTable = new DataTable(); sqlDataAdapter.Fill(dataTable); Manager m = new Manager(); foreach (DataRow row in dataTable.Rows) { m = new Manager { AccessLevel = row[12].ToString(), }; } if (m.AccessLevel == "Modify") { ModifyManagerWindow window = new ModifyManagerWindow(); window.Show(); this.Close(); } else if (m.AccessLevel == "Read-Only") { ReadOnlyManagerWindow window = new ReadOnlyManagerWindow(); window.Show(); this.Close(); } else { MessageBox.Show("Username or password is incorrect."); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { sqlCon.Close(); } }
//Button click executes EditEmploye method. private void Btn_Confirm(object sender, RoutedEventArgs e) { if (EditEmployeValidation.Validate(mmvm.Employe)) { mmvm.EditEmploye(); ModifyManagerWindow window = new ModifyManagerWindow(); window.Show(); this.Close(); } }
//Button click executes AddEmploye method. private void Btn_Confirm(object sender, RoutedEventArgs e) { //Validation for Employe properties. if (AddEmployeValidation.Validate(mmvm.Employe)) { mmvm.AddEmploye(); ModifyManagerWindow window = new ModifyManagerWindow(); window.Show(); this.Close(); } }