private void btnSave_Click(object sender, EventArgs e) { string oldpass = UtilityFunction.GetSHA256Hash(txtOldPass.Text.Trim()); if (oldpass != m_User.Password) { lblNotify.SetText(UI.passwordnotsame, ToolBoxCS.LabelNotify.EnumStatus.Failed); return; } if (txtNewPass.Text.Length < 8) { lblNotify.SetText(UI.passwordtooshort, ToolBoxCS.LabelNotify.EnumStatus.Failed); return; } string hashedpass = UtilityFunction.GetSHA256Hash(txtNewPass.Text.Trim()); m_User.Password = hashedpass; m_User.ModifyBy = UserManagement.UserSession.UserName; m_User.ModifyDate = DateTime.Now; try { using (IUnitOfWork uow = new UnitOfWork()) { uow.UsersRepository.Update(m_User); uow.Commit(); } Close(); } catch { lblNotify.SetText(UI.updatefailed, ToolBoxCS.LabelNotify.EnumStatus.Failed); } }
private void btnCreateAccount_Click(object sender, EventArgs e) { if (ValidationUtility.FieldNotAllowNull(groupSubsupplier) == false) { lblNotify1.SetText(UI.hasnoinfomation, LabelNotify.EnumStatus.Failed); return; } if (m_User == null) { m_User = new Users(); } CoverObjectUtility.GetAutoBindingData(groupSubsupplier, m_User); if (string.IsNullOrWhiteSpace(m_User.Password)) { m_User.Password = UtilityFunction.GetSHA256Hash(m_User.UserName); } m_User.UserId = 0; if (m_User == null) { return; } try { SaveAccount(m_User); lblNotify1.SetText(UI.success, LabelNotify.EnumStatus.Success); gridUtility1.AddNewRow <SubSupplier>(m_Subsupplier); } catch { lblNotify1.SetText(UI.failed, LabelNotify.EnumStatus.Failed); } }
private void btnSave_Click_1(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtUserName.Text) || string.IsNullOrWhiteSpace(txtPass.Text) || string.IsNullOrWhiteSpace(txtRetypePass.Text) || string.IsNullOrWhiteSpace(txtRecoverEmail.Text)) { FlatMessageBox.FlatMsgBox.Show("Bạn phải nhập đủ thông tin", "", FlatMessageBox.FlatMsgBox.Buttons.OK, FlatMessageBox.FlatMsgBox.Icon.Info); return; } if (txtPass.Text.Trim() != txtRetypePass.Text.Trim()) { FlatMessageBox.FlatMsgBox.Show("Mật khẩu không khớp", "", FlatMessageBox.FlatMsgBox.Buttons.OK, FlatMessageBox.FlatMsgBox.Icon.Info); return; } Users user = new Users(); user.UserName = txtUserName.Text; user.Password = UtilityFunction.GetSHA256Hash(txtPass.Text); user.Email = txtRecoverEmail.Text; user.ModifyDate = DateTime.Now; user.ModifyBy = UserManagement.UserSession.UserName; user.FullName = txtFullName.Text; user.CreateDate = DateTime.Now; user.CreateBy = user.ModifyBy; if (cbbUserGroup.SelectedValue != null) { user.UserGroupId = int.Parse(cbbUserGroup.SelectedValue.ToString()); } if (Create(user) == true) { FlatMessageBox.FlatMsgBox.Show("Success"); frmUsersView frmViewUser = FormUtility.FindUserCtrl("frmUsersView") as frmUsersView; if (frmViewUser != null) { if (UserManagement.AllowViewAll("USers") == true) { frmViewUser.isLoadAll = true; } else { frmViewUser.isLoadAll = false; } delgRefresh delgLoadUser = new delgRefresh(frmViewUser.LoadGrid); delgLoadUser(); Close(); } } else { FlatMessageBox.FlatMsgBox.Show("Không thành công"); } }
private void btnSave_Click(object sender, EventArgs e) { if (m_User == null) { return; } if (m_User.UserId <= 0) { return; } if (ValidationUtility.FieldNotAllowNull(this) == false) { lblNotify.SetText(UI.hasnoinfomation, ToolBoxCS.LabelNotify.EnumStatus.Failed); return; } if (ValidationUtility.ContainsUnicodeCharacter(txtPass.Text) == true) { lblNotify.SetText(UI.passwordnotallowspace, ToolBoxCS.LabelNotify.EnumStatus.Failed); return; } if (txtPass.Text != txtRePass.Text) { lblNotify.SetText(UI.passwordnotsame, ToolBoxCS.LabelNotify.EnumStatus.Failed); return; } if (txtPass.TextLength < 8) { lblNotify.SetText(UI.passwordtooshort, ToolBoxCS.LabelNotify.EnumStatus.Failed); return; } m_User.Password = UtilityFunction.GetSHA256Hash(txtPass.Text); try { using (IUnitOfWork uow = new UnitOfWork()) { uow.UsersRepository.Update(m_User); uow.Commit(); } lblNotify.SetText(UI.success, ToolBoxCS.LabelNotify.EnumStatus.Success); } catch { } }
private void btnSave_Click(object sender, EventArgs e) { if (ValidationUtility.FieldNotAllowNull(this) == false) { return; } Deputy deputy = new Deputy { Skype = txtSkype.Text, Address = txtDiaChi.Text, Email = txtEmail.Text, DeputyName = txtNameContact.Text, Phone = txtPhone.Text, CompanyId = _companyID, IsActive = true, IsMain = false, Sex = (cbSex.SelectedIndex) < 1 ? false : true, CreateBy = UserManagement.UserSession.UserName, CreateDate = DateTime.Now }; Users userNew = new Users { UserName = txtAccount.Text, Password = UtilityFunction.GetSHA256Hash(txtPassword.Text), Email = txtEmail.Text, FullName = txtNameContact.Text, CreateBy = deputy.CreateBy, CreateDate = deputy.CreateDate, UserGroupId = 2 }; Users userCheck = null; using (IUnitOfWork uow = new UnitOfWork()) { userCheck = uow.UsersRepository.IsExist(userNew.UserName); } if (userCheck != null) { UtilityMessageBox.ShowText("UserName is exit, not valid"); return; } using (IUnitOfWork uow = new UnitOfWork()) { //int k = uow.UsersRepository.Add(userNew); //deputy.UserId = k; //uow.DeputyRepository.Add(deputy); uow.Commit(); } UtilityMessageBox.ShowText("Thêm mới thành công"); if (_xulyThemMoiDeputy != null) { _xulyThemMoiDeputy(deputy); } Close(); }
private void btnSave_Click(object sender, EventArgs e) { if (ValidationUtility.FieldNotAllowNull(this) == false) { return; } var company = new Company { CompanyName = txtCompanyName.Text, CompanyCode = txtCompanyCode.Text, Taxcode = txtTaxCode.Text, Address = txtAddree.Text, SwiftCode = txtSwich.Text, NumberOfEmployee = ValidationUtility.StringIsNull(txtStaft.Text) == false?int.Parse(txtStaft.Text) : 0, Branch = ValidationUtility.StringIsNull(txtNoBrach.Text) == false?int.Parse(txtNoBrach.Text) : 0, TagetValue = ValidationUtility.StringIsNull(txtTargertValue.Text) == false?int.Parse(txtTargertValue.Text) : 0, Website = txtWebsite.Text, CreateDate = DateTime.Now, CreateBy = UserManagement.UserSession.UserName, Note = txtNote.Text, isActive = true, Accountant = txtAccount.Text, AccountantPhone = txtPhoneAccountant.Text, }; var companyClass = cbClassCustormer.SelectedItem as CompanyClass; if (companyClass != null) { company.ClassId = cbClassCustormer.SelectedValue != null ? companyClass.CompanyClassId : 0; } var accountBank = (cbSelectBank.SelectedValue != null) ? cbSelectBank.SelectedValue.ToString() : string.Empty; switch (cboTypeOfCompany.SelectedIndex) { case 1: company.TypeId = 1; break; default: company.TypeId = 0; break; } if (PictureLogo.Tag != null) { company.PictureLogo = PictureUtility.SaveImg(PictureLogo.Tag.ToString()); } if (PictureSgnature.Tag != null) { company.Photo = PictureUtility.SaveImg(PictureSgnature.Tag.ToString()); } var deputy = new Deputy { DeputyName = txtNameContact.Text, Address = txtAddree.Text, Phone = txtPhone.Text, IsMain = true, IsActive = true, Email = txtEmail.Text, Sex = (cbSex.SelectedIndex <= 0), CreateBy = UserManagement.UserSession.UserName, CreateDate = DateTime.Now }; var userNew = new Users { UserName = txtAccount.Text, Password = UtilityFunction.GetSHA256Hash(txtPassword.Text), Email = txtEmail.Text, FullName = txtNameContact.Text, CreateBy = deputy.CreateBy, CreateDate = deputy.CreateDate, UserGroupId = 2 }; Users userCheck; using (IUnitOfWork uow = new UnitOfWork()) { userCheck = uow.UsersRepository.IsExist(userNew.UserName); } if (userCheck != null) { UtilityMessageBox.ShowText("UserName is exist, not valid"); return; } if (PictureSgnature.Tag != null) { company.Photo = PictureUtility.SaveImg(PictureSgnature.Tag.ToString()); } if (PictureLogo.Tag != null) { company.PictureLogo = PictureUtility.SaveImg(PictureLogo.Tag.ToString()); } var companyId = _companyBussiness.Insert(company); company.CompanyId = companyId; deputy.CompanyId = companyId; using (IUnitOfWork uow = new UnitOfWork()) { //var useridnew = uow.UsersRepository.Add(userNew); //deputy.UserId = useridnew; //uow.DeputyRepository.Add(deputy); //uow.Commit(); } if (Xulysaukhithemmoi == null) { return; } Xulysaukhithemmoi(company, deputy); Close(); }