public UserForm(User user) : this() { isEditing = true; //populate the form IdField.Text = user.ID; IdField.IsEnabled = false; RoleField.SelectedIndex = Convert.ToInt32(user.ROLE_ID) - 1; SellerField.Text = user.SELLER_ID; }
public bool Persist() { FiltrateForm(); if (ValidateForm()) { User u = new User() { ID = IdField.Text, PASSWORD = PasswordField.Password, ROLE_ID = Convert.ToInt64(RoleField.SelectedIndex) + 1, SELLER_ID = SellerField.Text }; if (isEditing) return UserController.Instance.Update(u); else return UserController.Instance.Create(u); } else { FocusFirstField(); throw new ValidationException("Не сте попълнили валидно всички полета."); } }