private void Login(object sender, EventArgs e) { UseWaitCursor = true; if (tbxUsername.Text == "") { MessageBox.Show(Resources.empty_username, Resources.title_information); UseWaitCursor = false; return; } var dm = new CorporateUserDataManager(); var user = dm.Login(tbxUsername.Text, tbxPassword.Text, BaseControl.CorporateId); if (user != null) { var em = new CustomerDataManager(); var corporate = em.GetFirst <CustomerModel>(WhereTerm.Default(user.CorporateId, "id", EnumSqlOperator.Equals)); if (corporate != null) { BaseControl.UserId = user.Id; BaseControl.UserLogin = user.UserName; BaseControl.CorporateName = corporate.Name; BaseControl.BranchId = corporate.BranchId; var branch = new BranchDataManager().GetFirst <BranchModel>(WhereTerm.Default(corporate.BranchId, "id", EnumSqlOperator.Equals)); BaseControl.CityId = branch.CityId; BaseControl.BranchCode = branch.Code; var city = new CityDataManager().GetFirst <CityModel>(WhereTerm.Default(branch.CityId, "id", EnumSqlOperator.Equals)); BaseControl.CityName = city.Name; BaseControl.CountryId = city.CountryId; var country = new CountryDataManager().GetFirst <CountryModel>(WhereTerm.Default(city.CountryId, "id", EnumSqlOperator.Equals)); BaseControl.CountryName = country.Name; Authorization.SetCorporateUserId(BaseControl.UserId); Dispose(); } else { MessageBox.Show(string.Format("{0} {1}", Resources.franchise_account_not_found, Resources.contact_it_support), Resources.title_information); } } else { MessageBox.Show(Resources.invalid_login, Resources.title_login_failed); } UseWaitCursor = false; }
private void ChangePassword(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtOldPassword.Text)) { txtOldPassword.Focus(); MessageBox.Show(@"Please enter your OLD password!"); return; } if (string.IsNullOrEmpty(txtNewPassword.Text)) { txtNewPassword.Focus(); MessageBox.Show(@"Please enter your NEW password!"); return; } if (!txtNewPassword.Text.Equals(txtConfirmPassword.Text)) { txtConfirmPassword.Focus(); MessageBox.Show(@"Confirm password must be the same as the new password!"); return; } var userDm = new CorporateUserDataManager(); var user = userDm.Login(txtUsername.Text, txtOldPassword.Text, BaseControl.CorporateId); if (user == null) { txtOldPassword.Focus(); MessageBox.Show(@"Incorrect old password!"); return; } user.Password = CorporateUserDataManager.GetMd5Hash(txtNewPassword.Text); userDm.Update <CorporateUserModel>(user); MessageBox.Show(@"Your password has been changed"); Close(); }