private void BindingUsers() { try { Admin_UserController _controller = new Admin_UserController(); List <Admin_User> _list = _controller.GetUsers(-1, txtSearchKey.Text); dgvUsers.DataSource = _list; } catch (Exception ex) { Message.ErrorMessage("Lỗi khi nạp danh sách người dùng"); SingletonLogger.Instance.Error(this.Name, ex); } }
private void btnSave_Click(object sender, EventArgs e) { try { Admin_UserController _controller = new Admin_UserController(); Admin_User _user = new Admin_User(); _user.Firstname = txtFirstname.Text; _user.Lastname = txtLastname.Text; _user.FullName = txtFirstname.Text + " " + txtLastname.Text; _user.Email = txtEmail.Text; _user.PhoneNo = txtPhone.Text; if (txtUserId.Text == string.Empty) { _user.UserName = txtUsername.Text; _user.Password = txtPassword.Text; _user.Created = DateTime.Now; _controller.Add(_user); } else { _user.Id = Convert.ToInt32(txtUserId.Text); _user.Modified = DateTime.Now; _controller.Edit(_user); } } catch (Exception ex) { Message.ErrorMessage("Lỗi khi lưu người dùng"); SingletonLogger.Instance.Error(this.Name, ex); } BindingUsers(); tabControl1.SelectedIndex = 0; }