public List<User> SelectAll() { try { List<User> oUserList = new List<User>(); User oUser = new User(); oUser.Id = 1; oUser.name = "Admin"; oUser.password = "******"; oUser.type = "Administrator"; oUser.userId = "Admin"; oUserList.Add(oUser); oUser = new User(); oUser.Id = 2; oUser.name = "User"; oUser.password = "******"; oUser.type = "User"; oUser.userId = "User"; oUserList.Add(oUser); return oUserList; } catch (Exception) { throw; } }
public ucAddEditUser( User oUser, bool isEdit) { InitializeComponent(); cboUserType.ItemsSource = new List<string>() { "Administrator", "User" }; this.oUser = oUser; this.isEdit = isEdit; if (isEdit) { InitializeWindow(); } }
private void btnAddUser_Click(object sender, RoutedEventArgs e) { try { User oUser= new User(); ucAddEditUser oucAddEditUser = new ucAddEditUser(oUser, false); winDialog oDialog = new winDialog(oucAddEditUser) { ShowInTaskbar = true, WindowTitle = "Add a new User", Height = 300, Width = 390 }; oDialog.ShowDialog(); dtgUsers.Items.Refresh(); } catch (Exception) { MessageBox.Show("Can not add user now"); } }