public bool IsAuthenticate(Account account) { account.UserName = Utilities.KillSqlInjection(account.UserName); account.Password = Utilities.KillSqlInjection(account.Password); AccountBUS accountBusiness = new AccountBUS(); var result = accountBusiness.GetUserByUserName(account); if (result.Item == null) { return(false); } AuthenticationHelper _authenticationHelper = new AuthenticationHelper(); var userDTO = accountBusiness.GetUserToCheck(result.Item.Id); string passwordSalt = userDTO.PasswordSalt; string passwordInput = _authenticationHelper.GetMd5Hash(passwordSalt + account.Password); string passwordUser = userDTO.Password; if (passwordInput.Equals(passwordUser)) { return(true); } else { return(false); } }
private void btnLogin_Click(object sender, EventArgs e) { string username = txtUsername.Text; string password = txtPassword.Text; AccountBUS bus = new AccountBUS(); LoginStatus status = bus.Login(username, password); switch (status) { case LoginStatus.WRONG_USERNAME: MessageBox.Show("Email không tồn tại"); return; case LoginStatus.WRONG_PASSWORD: MessageBox.Show("Mật khẩu không chính xác"); return; case LoginStatus.LOCKED: MessageBox.Show("Tài khoản đã bị khóa"); return; case LoginStatus.NO_PERMISSION: MessageBox.Show("Không đủ quyền hạn"); return; case LoginStatus.SUCCESS: this.Hide(); Manage frmManage = new Manage(); frmManage.ShowDialog(); this.Show(); return; } }
private void btnChangedPassword_Click(object sender, EventArgs e) { // check double password if (txtNewpassword.Text != txtRepassword.Text) { MessageBox.Show("Mật khẩu nhập lại không khớp!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtNewpassword.Text = txtOldpassword.Text = txtRepassword.Text = ""; return; } // check old password is correct ?? var acc = new AccountBUS().findAccountByID(tk.MaTaiKhoan); if (acc.MatKhau != txtOldpassword.Text) { MessageBox.Show("Mật khẩu hiện tại không đúng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtNewpassword.Text = txtOldpassword.Text = txtRepassword.Text = ""; return; } // Changed password new AccountBUS().changePassword(tk.MaTaiKhoan, txtNewpassword.Text); // reset data text txtNewpassword.Text = txtOldpassword.Text = txtRepassword.Text = ""; LoadDataAccount(); MessageBox.Show("Đổi mật khẩu thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void rbtDay_CheckedChanged(object sender, EventArgs e) { RadioButton rb = sender as RadioButton; List <Account> list = new AccountBUS().GetAllAccount(); int totalBill = 0, total = 0; if (rb.Name == "rbtDay") { foreach (Account item in list) { totalBill += item.CountDay; total += item.TotalDay; } } else { foreach (Account item in list) { totalBill += item.CountDay; total += item.TotalDay; } } txtTotalBill.Text = totalBill.ToString(); txtTotalRevenu.Text = total.ToString(); }
public IActionResult DeleteAccount(Account account) { AccountBUS accountBUS = new AccountBUS(); var result = accountBUS.DeleteAccount(account); return(Ok(result)); }
private void thôngTinTàiKhoảnToolStripMenuItem_Click(object sender, EventArgs e) { frm_ThongTinTaiKhoan frm_ThongTin = new frm_ThongTinTaiKhoan(AccountBUS.GetAccount((int)cbxNhanVien.SelectedValue)); Hide(); frm_ThongTin.ShowDialog(); }
private void bttrai1_Click(object sender, EventArgs e) { if (nameForm == "GiaoDienChinh") { RutTien_Load(); } else if (nameForm == "RutTien") { //rút 50.000 VNĐ var account = AccountBUS.getByAccountNo(SoThe); //lấy thông tin account từ số thẻ chuyển tiền if ((account.Balance - 100000) > 0) //kiểm tra số tiền sau khi rút còn đủ 50.000 duy trì thẻ hay không { //thực hiện giao dịch if (AccountBUS.RutTien(SoThe, 50000)) //thực hiện rút tiền { InHoaDon_Load(); //thành công } else { GiaoDienChinh_Load(); } } else { GiaoDienChinh_Load(); } } return; }
public IActionResult EditPassword(Account account) { AccountBUS accountBUS = new AccountBUS(); var result = accountBUS.EditPassword(account); return(Ok(result)); }
private void NotBanAccountMenuitem_Click(object sender, RoutedEventArgs e) { var t = lvListStaff.SelectedItem; if (t == null) { MessageBox.Show("Chọn tài khoản muốn mở khóa !"); return; } try { string userName = t.GetType().GetProperty("USERNAME").GetValue(t, null).ToString(); if (MessageBox.Show("Mở tài khoản: " + userName, "", MessageBoxButton.OKCancel) != MessageBoxResult.OK) { return; } if (AccountBUS.BanAccount(userName, false)) { LoadListStaff(); MessageBox.Show("Mở tài khoản: " + userName + " thành công !"); } else { MessageBox.Show("Tài khoản: " + userName + " đã không bị khóa !", "Không thể mở khóa", MessageBoxButton.OK, MessageBoxImage.Error); } } catch { MessageBox.Show("Không thể mở tài khoản, kiểm tra lại kết nối !"); } }
private void btnLogin_Click(object sender, EventArgs e) { acc.username = txtUsername.Text; if (AccountBUS.checkUsername(acc.username) == true) { txtUsername.Enabled = false; txtPass.Enabled = true; txtPass.Focus(); txtPass.PasswordChar = '*'; btnLogin.Enabled = false; btnContinue.BringToFront(); } else { if (attempt != 0) { if (MessageBox.Show("Login failed! Wrong password!\r\n" + --attempt + " left", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry) { txtUsername.Clear(); txtUsername.Focus(); } } else { MessageBox.Show("Application close now!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } } }
void ShowAccout() { this.lstAccount.Items.Clear(); List <AccountDTO> menulist = AccountBUS.GetAllListAccount(); for (int i = 0; i < menulist.Count; i++) { ListViewItem listitem = new ListViewItem(); listitem.Text = "#" + (i + 1).ToString(); listitem.SubItems.Add("03060" + menulist[i].ID.ToString()); listitem.SubItems.Add(menulist[i].Name); listitem.SubItems.Add(menulist[i].PlaceOfBirth); listitem.SubItems.Add(menulist[i].Telephone); listitem.SubItems.Add(menulist[i].Address); if (menulist[i].Right == 0) { listitem.SubItems.Add("Quản lý"); } else { listitem.SubItems.Add("Nhân viên"); } if (menulist[i].Status == 0) { listitem.SubItems.Add("Bị khóa"); } else { listitem.SubItems.Add("Đã được mở khóa"); } listitem.SubItems.Add(menulist[i].PassPort); listitem.Tag = menulist[i]; lstAccount.Items.Add(listitem); } }
private void btEnter_Click(object sender, EventArgs e) { if (nameForm == "SoTienKhoac") { var Form = Application.OpenForms[1]; TextBox txt_SoTien = Form.Controls["txtNhapLieu"] as TextBox; if (!string.IsNullOrEmpty(txt_SoTien.Text)) //check null số tiền nhập vào { var sotien = double.Parse(txt_SoTien.Text); var account = AccountBUS.getByAccountNo(SoThe); //lấy thông tin account từ số thẻ chuyển tiền if ((account.Balance - 50000 - sotien) > 0) //kiểm tra số tiền sau khi rút còn đủ 50.000 duy trì thẻ hay không { //thực hiện giao dịch if (AccountBUS.RutTien(SoThe, sotien)) //thực hiện rút tiền { InHoaDon_Load(); //thành công } else { GiaoDienChinh_Load(); } } else { GiaoDienChinh_Load(); } } else { RutTien_Load(); } } else if (nameForm == "DoiMaPIN") { var Form = Application.OpenForms[1]; TextBox txt_MaPinMoi = Form.Controls["txtNhapLieu"] as TextBox; if (!string.IsNullOrEmpty(txt_MaPinMoi.Text)) //check null nhập mã pin { var mapinmoi = double.Parse(txt_MaPinMoi.Text); if (CardBUS.DoiPin(SoThe, mapinmoi)) //Đổi mã pin { DoiMaPINThanhCong_Load(); //thông báo đổi pin thành công } else { DoiMaPINThanhCong_Load(); //thông báo đổi pin thất bại var Form_alert = Application.OpenForms[1]; //get form hiện tại Label lbl_alert = Form_alert.Controls["lbl_alert"] as Label; //get label thông báo thành công lbl_alert.Visible = false; //ẩn label thông báo thành công Label lbl_alert_err = Form_alert.Controls["lbl_alert_err"] as Label; //get label thông báo thất bại lbl_alert.Visible = true; //hiển thị label thông báo thất bại } } else { DoiMaPIN_Load(); //load lại nhập mà pin } } }
private void btnLock_Unlock_Click(object sender, EventArgs e) { Accounts acc = accountsBindingSource.Current as Accounts; int id = acc.Id; AccountBUS.lock_unlockUser(id); accountsBindingSource.DataSource = AccountBUS.GetAll(); }
private void LoadAccount() { List <AccountDTO> listtype = AccountBUS.GetListAccountOnStatus(1); cbxNhanVien.DataSource = listtype; cbxNhanVien.DisplayMember = "Name"; cbxNhanVien.ValueMember = "ID"; }
private void btnDeleteAccount_Click(object sender, EventArgs e) { try { if (this.lstAccount.SelectedItems.Count > 0) { ListViewItem lvw = lstAccount.SelectedItems[0]; AccountDTO sp = (AccountDTO)lvw.Tag; if (sp.ID == Program.sAccount.ID) { MessageBox.Show("Bạn không thể sử dụng chức năng này với chính bạn.", "Thông báo", MessageBoxButtons.OK); } else { frm_XacNhan frm_XN = new frm_XacNhan("Bạn vui lòng nhập mật khẩu để xác nhận thao tác này!", Program.sAccount); if (frm_XN.ShowDialog() == DialogResult.OK) { if (AccountBUS.IsLogin(Program.sAccount.ID, frm_XN.txtXacNhap.Text)) { if (!BillBUS.IsExistAccountInBill(sp.ID)) { if (AccountBUS.DeleteAccount(sp) == true) { MessageBox.Show("Bạn đã xóa thành công", "Thông báo", MessageBoxButtons.OK); ShowAccout(); DeleteTextAccount(); txtNameAcount.ReadOnly = false; this.btnEditAccount.Visible = false; this.btnAddAccount.Visible = true; btnDeleteAccount.Enabled = false; } else { MessageBox.Show("Xóa tài khoản thất bại.", "Thông báo", MessageBoxButtons.OK); } } else { MessageBox.Show("Tài khoản này đang hoạt động với hệ thống. Nên bạn không thể xóa tài khoản này khỏi hệ thống.", "Thông báo", MessageBoxButtons.OK); } } else { MessageBox.Show("Bạn đã nhập sai mật khẩu, vui lòng quay lại sau.", "Thông báo", MessageBoxButtons.OK); } } } } else { MessageBox.Show("Bạn chưa chọn được tài khoản nào.", "Thông báo", MessageBoxButtons.OK); } } catch { MessageBox.Show("Hệ thống đang bảo trì, bạn vui lòng thử lại.", "Thông báo", MessageBoxButtons.OK); } }
private void btphai2_Click(object sender, EventArgs e) { if (nameForm == "GiaoDienChinh") { NhapTaiKhoanChuyenDen_Load(); } else if (nameForm == "RutTien") { //rút 1.500.000 VNĐ var account = AccountBUS.getByAccountNo(SoThe); //lấy thông tin account từ số thẻ chuyển tiền if ((account.Balance - 1550000) > 0) //kiểm tra số tiền sau khi rút còn đủ 50.000 duy trì thẻ hay không { //thực hiện giao dịch if (AccountBUS.RutTien(SoThe, 1500000)) //thực hiện rút tiền { InHoaDon_Load(); //thành công } else { GiaoDienChinh_Load(); } } else { GiaoDienChinh_Load(); } } else if (nameForm == "ThongTinChuyenKhoan") { //thực hiện giao dịch if (AccountBUS.ChuyenTien(SoThe, sothechuyenden, sotienchuyenden) && LogBUS.ChuyenTien(SoThe, sothechuyenden, sotienchuyenden, details)) { //nếu giao dịch thành công và lưu lại lịch sử giao dịch thành công thì trở về giao diện chính ChuyenKhoanThanhCong_Load(); } } else if (nameForm == "SaoKeTaiKhoan") { //in sao kê //var Form = Application.OpenForms[1]; //DataGridView grid = Form.Controls["Grid_saoke"] as DataGridView; //exportExcel(grid); //btHoaDon.BackColor = Color.White; btHoaDon.BackColor = Color.Gray; // btHoaDon.BackColor = Color.White; } else if (nameForm == "SoDuTaiKhoan") { //in sao kê //var Form = Application.OpenForms[1]; //DataGridView grid = Form.Controls["Grid_saoke"] as DataGridView; //exportExcel(grid); //btHoaDon.BackColor = Color.White; btHoaDon.BackColor = Color.Gray; // btHoaDon.BackColor = Color.White; } return; }
public ReturnResult <User> EditUser(User user) { AuthenticationHelper _authenticationHelper = new AuthenticationHelper(); if (user.PasswordNew != null && !user.PasswordNew.Equals("")) { string passwordSalt = _authenticationHelper.RamdomString(5); string password = _authenticationHelper.GetMd5Hash(passwordSalt + user.PasswordNew); user.Password = password; user.PasswordSalt = passwordSalt; } else { var accountBusiness = new AccountBUS(); var userDTO = accountBusiness.GetUserToCheck(user.Id); user.Password = userDTO.Password; user.PasswordSalt = userDTO.PasswordSalt; } ReturnResult <User> result; DbProvider db; try { result = new ReturnResult <User>(); db = new DbProvider(); db.SetQuery("USER_EDIT", CommandType.StoredProcedure) .SetParameter("UserID", SqlDbType.Int, user.Id, ParameterDirection.Input) .SetParameter("UserName", SqlDbType.NVarChar, user.UserName, 50, ParameterDirection.Input) .SetParameter("Password", SqlDbType.NVarChar, user.Password, 50, ParameterDirection.Input) .SetParameter("PasswordSalt", SqlDbType.NVarChar, user.PasswordSalt, 50, ParameterDirection.Input) .SetParameter("NguoiCapNhat", SqlDbType.NVarChar, user.UpdatedBy, 50, ParameterDirection.Input) .SetParameter("NgayCapNhat", SqlDbType.NVarChar, user.UpdatedDate.ToString(), 100, ParameterDirection.Input) .SetParameter("status", SqlDbType.Int, user.Status, ParameterDirection.Input) .SetParameter("RoleID", SqlDbType.Int, user.RoleID, ParameterDirection.Input) .SetParameter("ErrorCode", SqlDbType.Int, DBNull.Value, ParameterDirection.Output) .SetParameter("ErrorMessage", SqlDbType.NVarChar, DBNull.Value, 4000, ParameterDirection.Output) .ExcuteNonQuery() .Complete(); db.GetOutValue("ErrorCode", out string errorCode) .GetOutValue("ErrorMessage", out string errorMessage); if (errorCode.ToString() == "0") { result.ErrorCode = "0"; result.ErrorMessage = ""; } else { result.Failed(errorCode, errorMessage); } } catch (Exception ex) { throw ex; } return(result); }
private void LoadAccount() { //load loại thức uống theo tên List <AccountDTO> listtype = AccountBUS.GetAllListAccount(); cbxNhanVien.DataSource = listtype; cbxNhanVien.DisplayMember = "Name"; cbxNhanVien.ValueMember = "ID"; }
public void Login() { AccountBUS acc = new AccountBUS(); AccountDTO b = new AccountDTO("admin", "123"); bool actual = acc.Login(b); bool expected = true; Assert.AreEqual(actual, expected); }
public ChangePassWordWindow(string userName) { _thisAccount = AccountBUS.GetById(userName); if (_thisAccount == null) { this.Close(); } InitializeComponent(); }
private void btnDeDrink_Click(object sender, EventArgs e) { try { if (lstDrink.SelectedItems != null) { ListViewItem lvw = lstDrink.SelectedItems[0]; DrinkDTO sp = (DrinkDTO)lvw.Tag; frm_XacNhan frm_XN = new frm_XacNhan("Xóa một sản phẩm rất quan trọng. Bạn vui lòng nhập mật khẩu để xác nhận thao tác này!", Program.sAccount); if (frm_XN.ShowDialog() == DialogResult.OK) { if (AccountBUS.IsLogin(Program.sAccount.ID, frm_XN.txtXacNhap.Text)) { if (DetailBillBUS.IsExistDrink(sp.ID) == -1) { if (lstDrink.SelectedItems.Count > 0) { if (DrinkBUS.DeleteDrink(sp) == true) { MessageBox.Show("Bạn đã xóa thành công sản phẩm SP00" + sp.ID + " khỏi hệ thống!", "Thông báo", MessageBoxButtons.OK); ShowDrink(); DeleteTextDrink(); btnEditDrink.Visible = false; btnAdddrink.Visible = true; } else { MessageBox.Show("Xóa sản phẩm thất bại, vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK); } } else { MessageBox.Show("Chưa chọn thức uống", "Thông báo", MessageBoxButtons.OK); } } else { MessageBox.Show("Thức uống này đã được người dùng chọn hoặc mua trong thời gian trước đó, bạn không thể xóa sản phẩm này!", "Thông báo", MessageBoxButtons.OK); } } else { MessageBox.Show("Bạn nhập sai mật khẩu, vui lòng nhập lại!", "Thông báo", MessageBoxButtons.OK); } } } else { MessageBox.Show("Bạn vui lòng chọn sản phẩm trước khi thực hiện chức năng này!", "Thông báo", MessageBoxButtons.OK); } } catch { MessageBox.Show("Hệ thống đang bảo trì chức năng này, vui lòng quay lại sau nhé!", "Thông báo", MessageBoxButtons.OK); } }
public fmChangePassword() { InitializeComponent(); _accountBus = new AccountBUS(); _accountEntries = _accountBus.getEntries(); labPassword.Hide(); labRePassword.Hide(); }
public fmLogin() { InitializeComponent(); _accountBus = new AccountBUS(); _accountEntries = _accountBus.getEntries(); _accountTypeBus = new AccountTypeBUS(); _accountTypeEntries = _accountTypeBus.getEntries(); }
private void btXoaTK_Click(object sender, EventArgs e) { Account acc = new Account(); acc.TenNguoiDung = tbUserName.Text; AccountBUS.XoaTK(acc); listAccounts.Items.Clear(); DisplayListViewAccount(); MessageBox.Show("Xóa tài khoản thành công!"); }
public fmSystemManager() { InitializeComponent(); _accountBus = new AccountBUS(); _accountEntries = _accountBus.getEntries(); _accountTypeBus = new AccountTypeBUS(); _accountTypeEntries = _accountTypeBus.getEntries(); }
public frm_LayLaiMatKhau(AccountDTO account, int @case) { InitializeComponent(); _Account = account; _case = @case;//0: hiện combobox 1: hiện label LoadAccount(); if (_case == 0) { _Account = AccountBUS.GetAccount((int)cbxNhanVien.SelectedValue); } }
private void btnCancel_Click(object sender, EventArgs e) { dataGridView.Enabled = true; panCRUD.Enabled = true; panSave.Enabled = false; accountsBindingSource.DataSource = AccountBUS.GetAll(); panSearch.Enabled = true; comboPosFilter.Enabled = true; comboPosRe.Visible = true; labelPos.Visible = true; }
public IActionResult CreateAccount(Account account) { AccountService accountService = new AccountService(); var hasedPassword = accountService.CreateHashedPassword(account.Password); // Assign a new hashed password to account account.Password = hasedPassword; AccountBUS accountBUS = new AccountBUS(); var result = accountBUS.CreateAccount(account); return(Ok(result)); }
public string idAccount() { AccountBUS dv = new AccountBUS(); List <AccountDTO> _list = dv.getAllAccount(); int idDichVu = 0; if (_list.Count != 0) { idDichVu = Int32.Parse(_list[_list.Count - 1].IDTaiKhoan.ToString()) + 1; } return(idDichVu.ToString()); }
public IActionResult Login([FromBody] Account account) { ReturnResult <User> loginResult; AccountService loginService = new AccountService(); try { if (loginService.IsAuthenticate(account)) { // Create Jwt token for client-side var jwtToken = loginService.CreateToken(); AccountBUS accountBusiness = new AccountBUS(); var quser = accountBusiness.GetUserByUserName(account); var user = new User() { Status = quser.Item.Status, RoleName = quser.Item.RoleName, UserRole = quser.Item.UserRole, UserName = account.UserName, Token = new Token() { JwtToken = jwtToken.JwtToken, Expiration = jwtToken.Expiration } }; loginResult = new ReturnResult <User>() { Item = user, ErrorCode = "0", ErrorMessage = "" }; } else { loginResult = new ReturnResult <User>() { IsSuccess = false, ErrorCode = "-1", ErrorMessage = "Tài khoản hoặc mật khẩu không chính xác, vui lòng thử lại.", }; } } catch (Exception ex) { loginResult = new ReturnResult <User>() { IsSuccess = false, ErrorCode = "1", ErrorMessage = ex.Message }; } return(Ok(loginResult)); }