protected void btnChangeCommonInfo_Click(object sender, EventArgs e) { int groupId; Int32.TryParse(ddlCustomerGroup.SelectedValue, out groupId); customer.FirstName = HttpUtility.HtmlEncode(txtFirstName.Text); customer.LastName = txtLastName.Text; customer.Phone = txtWWW.Text; customer.SubscribedForNews = chkSubscribed4News.Checked; customer.EMail = lblEmail.Text; customer.CustomerGroupId = groupId; if (customer.CustomerRole != Role.Administrator) { var prevCustomerRole = customer.CustomerRole; customer.CustomerRole = (Role)Convert.ToInt32(ddlCustomerRole.SelectedValue); if (prevCustomerRole == Role.Moderator && customer.CustomerRole == Role.Moderator) { CustomerRoleActionsAdmin.SaveRole(); } else if (prevCustomerRole == Role.Moderator && customer.CustomerRole == Role.User) { RoleActionService.DeleteCustomerRoleActions(customer.Id); } } CustomerService.UpdateCustomer(customer); ShowRoleAccess = customer.CustomerRole == Role.Moderator; CustomerRoleActionsAdmin.Visible = ShowRoleAccess; }
protected void btnChangeCommonInfo_Click(object sender, EventArgs e) { int groupId; Int32.TryParse(ddlCustomerGroup.SelectedValue, out groupId); lblError.Visible = false; customer.FirstName = HttpUtility.HtmlEncode(txtFirstName.Text); customer.LastName = txtLastName.Text; customer.Phone = txtWWW.Text; customer.CustomerGroupId = groupId; customer.SubscribedForNews = chkSubscribed4News.Checked; if (customer.EMail != txtEmail.Text && CustomerService.ExistsEmail(txtEmail.Text)) { lblError.Text = Resource.Admin_CreateCustomer_CustomerErrorEmailExist; lblError.Visible = true; return; } customer.EMail = txtEmail.Text; customer.EMail = txtEmail.Text; var cardNumber = txtBonusCardNumber.Text.TryParseLong(true); if (BonusSystem.IsActive && txtBonusCardNumber.Text.IsNotEmpty()) { if (BonusSystemService.GetCard(cardNumber) == null) { lblError.Text = Resource.Admin_ViewCustomer_WrongCardNumber; lblError.Visible = true; return; } } customer.BonusCardNumber = cardNumber; var prevCustomerRole = customer.CustomerRole; customer.CustomerRole = (Role)SQLDataHelper.GetInt(ddlCustomerRole.SelectedValue); if (customer.CustomerRole == Role.Moderator) { CustomerRoleActionsAdmin.SaveRole(); } else if (prevCustomerRole == Role.Moderator && (customer.CustomerRole != Role.Moderator)) { RoleActionService.DeleteCustomerRoleActions(customer.Id); } CustomerService.UpdateCustomer(customer); ShowRoleAccess = customer.CustomerRole == Role.Moderator; CustomerRoleActionsAdmin.Visible = ShowRoleAccess; }