示例#1
0
 //Ham thay doi mat khau
 private void changePassWord()
 {
     if (CodeDTO.getMD5Hash(txtPassOld.Text).Equals(ucLogin.m_EmployeeObject.matKhau))
     {
         if (txtPassReplay.Text.Equals(txtPassNew.Text))
         {
             //thục hiện Update mật khẩu
             ucLogin.m_EmployeeObject.matKhau = CodeDTO.getMD5Hash(txtPassReplay.Text.Trim());
             //
             if (m_EmployeeExecute.UpdateEmployeeToDatabase(ucLogin.m_EmployeeObject))
             {
                 XtraMessageBox.Show("Đổi mật khẩu thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.Close();
             }
             else
             {
                 txtPassNew.Text = txtPassOld.Text = txtPassReplay.Text = "";
                 XtraMessageBox.Show("Đổi mậu khẩu thất bại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         else
         {
             txtPassNew.Text = txtPassReplay.Text = "";
             XtraMessageBox.Show("Mật khẩu mới và xác nhận không hợp lệ. Vui lòng nhập lại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     else
     {
         XtraMessageBox.Show("Sai mật khẩu. Vui lòng nhập lại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
示例#2
0
 //Ham thay doi mat khau
 private void changePassWord()
 {
     if (CodeDTO.getMD5Hash(txtPassOld.Text).Equals(ucLogin.m_EmployeeObject.matKhau))
     {
         if (txtPassReplay.Text.Equals(txtPassNew.Text))
         {
             //thục hiện Update mật khẩu
             ucLogin.m_EmployeeObject.matKhau = CodeDTO.getMD5Hash(txtPassReplay.Text.Trim());
             //
             m_EmployeeObject = new CEmployeeDTO(ucLogin.m_EmployeeObject.maNhanVien, ucLogin.m_EmployeeObject.tenNhanVien, ucLogin.m_EmployeeObject.gioiTinh,
                                                 ucLogin.m_EmployeeObject.ngaySinh, ucLogin.m_EmployeeObject.soDienThoai, ucLogin.m_EmployeeObject.diaChi, ucLogin.m_EmployeeObject.ngayVaoLam, ucLogin.m_EmployeeObject.maChucVu, ucLogin.m_EmployeeObject.tenDangNhap, ucLogin.m_EmployeeObject.matKhau, ucLogin.m_EmployeeObject.email);
             if (m_EmployeeExecute.UpdateEmployeeToDatabase(m_EmployeeObject))
             {
                 ucLogin.m_EmployeeObject = m_EmployeeObject;
                 XtraMessageBox.Show("Đổi mật khẩu thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.Close();
             }
             else
             {
                 txtPassNew.Text = txtPassOld.Text = txtPassReplay.Text = "";
                 XtraMessageBox.Show("Đổi mậu khẩu thất bại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         else
         {
             txtPassNew.Text = txtPassReplay.Text = "";
             XtraMessageBox.Show("Mật khẩu mới và xác nhận không hợp lệ. Vui lòng nhập lại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     else
     {
         XtraMessageBox.Show("Sai mật khẩu. Vui lòng nhập lại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
示例#3
0
        public async Task <IActionResult> CreateARegistrationNumber(string id)
        {
            CodeDTO code = await codeService.CreateARegistrationCode(id);

            if (code == null)
            {
                return(Redirect("/Administration/Code/All"));
            }
            return(View(code));
        }
示例#4
0
        public async Task SendCode([FromBody] UserAccountDTO user)
        {
            CodeDTO verificationCode = new CodeDTO()
            {
                Code = rand.Next(100000, 999999)
            };
            string message = $"<h2>Your verification code: {verificationCode.Code}<h2>";

            _emailService.SendEmailAsync(user.Email, "Verification code", message);
            await Response.WriteAsync(JsonConvert.SerializeObject(verificationCode, new JsonSerializerSettings {
                Formatting = Formatting.Indented
            }));
        }
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (!checkData())
     {
         return;
     }
     try
     {
         if (m_IsAdd)
         {
             String _user = createUserName(txtEmployeeName.Text, dateBirthDay.DateTime.ToString());
             String _pass = CodeDTO.getMD5Hash("123456789");
             m_EmployeeObject = new CEmployeeDTO("NV0000000", txtEmployeeName.Text, cmbEmployeeGender.Text,
                                                 dateBirthDay.DateTime, txtEmployeePhone.Text, txtEmployeeAddress.Text, dateToWork.DateTime,
                                                 lkEmployeeCharge.EditValue.ToString(), _user, _pass, txtEmployeeEmail.Text);
             if (m_EmployeeExecute.AddEmployeeToDatabase(m_EmployeeObject))
             {
                 XtraCustomMessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", true);
             }
             else
             {
                 XtraCustomMessageBox.Show("Thêm dữ liệu thất bại!", "Lỗi", true);
             }
         }
         else
         {
             m_EmployeeObject = new CEmployeeDTO(txtEmployeeId.Text, txtEmployeeName.Text, cmbEmployeeGender.Text,
                                                 dateBirthDay.DateTime, txtEmployeePhone.Text, txtEmployeeAddress.Text,
                                                 dateToWork.DateTime, lkEmployeeCharge.EditValue.ToString(), txtEmployeeName.Text, null, txtEmployeeEmail.Text);
             if (m_EmployeeExecute.UpdateEmployeeToDatabase(m_EmployeeObject))
             {
                 XtraCustomMessageBox.Show("Cập nhật dữ liệu thành công!", "Thông báo", true);
             }
             else
             {
                 XtraCustomMessageBox.Show("Cập nhật dữ liệu thất bại!", "Lỗi", true);
             }
         }
     }
     catch (System.Exception)
     {
         XtraCustomMessageBox.Show("Lưu dữ liệu thất bại!", "Lỗi", true);
     }
     finally
     {
         updateEnableButtonAndResetValueOfControl(ref btnSave);
     }
 }
示例#6
0
        public async Task TestCreateARegistrationCodeGoodData()
        {
            ACMDbContext context     = ACMDbContextInMemoryFactory.InitializeContext();
            CodeService  codeService = new CodeService(context);
            Apartment    apartment1  = new Apartment {
                Number = 1
            };
            await context.Apartments.AddAsync(apartment1);

            await context.SaveChangesAsync();

            CodeDTO code = await codeService.CreateARegistrationCode("1");

            Assert.Single(context.RegistrationCodes.ToList());
            Assert.Equal(1, context.RegistrationCodes.FirstOrDefault().Apartment.Number);
            Assert.Equal(code.Code, context.RegistrationCodes.FirstOrDefault().Code);
        }
示例#7
0
        public void CodeValidation(CodeDTO codeDTO)
        {
            if (string.IsNullOrEmpty(codeDTO.Title))
            {
                throw new ServiceException(ExceptionMessages.CODENAME_CANNOT_BE_BLANK);
            }

            if (codeDTO.LookupId <= 0)
            {
                throw new ServiceException(ExceptionMessages.CODELANGUAGE_CANNOT_BE_BLANK);
            }

            if (string.IsNullOrEmpty(codeDTO.Code))
            {
                throw new ServiceException(ExceptionMessages.CODEBODY_CANNOT_BE_BLANK);
            }
        }
示例#8
0
        public void AddCode(CodeDTO codeDTO)
        {
            var  currentUser = _userService.GetLoggedInUser();
            Code code        = new Code
            {
                Body        = codeDTO.Code,
                LookupId    = codeDTO.LookupId,
                Description = codeDTO.Description,
                Title       = codeDTO.Title,
                UpdatedDate = null,
                UpdatedBy   = 0,
                CreatedBy   = currentUser.Id,
                Hashtags    = codeDTO.Hashtags
            };

            _context.Codes.Add(code);
            _context.SaveChanges();
        }
示例#9
0
        public IActionResult AddCode([FromBody] CodeDTO codeDTO)
        {
            try
            {
                _codeService.CodeValidation(codeDTO);
                _codeService.AddCode(codeDTO);
                return(Ok());
            }
            catch (AuthenticationException)
            {
                return(Forbid());
            }
            catch (ServiceException ex)
            {
                return(BadRequest(ex.Message));
            }

            catch (Exception ex)
            {
                return(BadRequest(ex.StackTrace));
            }
        }
示例#10
0
 //Ham thuc hien dang nhap
 private void actionLogin()
 {
     try
     {
         if (txtUser.Text.Equals("") || txtPass.Text.Equals(""))
         {
             XtraMessageBox.Show("Tên đăng nhập hoặc password chưa được nhập. Vui lòng nhập lại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             if (login(txtUser.Text, CodeDTO.getMD5Hash(txtPass.Text.Trim())))
             {
                 frmMain _frmMain = new frmMain();
                 _frmMain.WindowState = FormWindowState.Maximized;
                 _frmMain.Show();
                 _frmMain._loginShow = new frmMain.showLogin(loginShow);
                 _loginHide();
             }
         }
     }
     catch (Exception)
     {
     }
 }
示例#11
0
 public Code(CodeDTO itm)
 {
     CodeId = itm.Id;
     Name   = itm.Name;
 }