Beispiel #1
0
        private void ValidateUsername()
        {
            if (string.IsNullOrEmpty(client.Credentials.Username))
            {
                ErrorMessages.Add($"El campo nombre de {singleProfileName} no puede quedar vacío.");
                return;
            }

            if (client.Credentials.Username.Length < UsernameLength)
            {
                ErrorMessages.Add(
                    $"El largo del nombre de {singleProfileName} no puede ser inferior a {UsernameLength} caracteres");
                return;
            }

            if (EditMode)
            {
                return;
            }
            var useCase   = ClientUseCase.CreateUseCase(profileId, singleProfileName);
            var dataTable = useCase.FindClientById(client.Credentials.Username);

            if (dataTable.Rows.Count > 0)
            {
                ErrorMessages.Add("El username ingresado no esta disponible.");
            }
        }
        private void LoadUsers(int filterType)
        {
            try{
                var useCase = ClientUseCase.CreateUseCase(Profile.ProfileId, Profile.SingleProfileName);
                var data    = new DataTable();
                ListDataGridView.DataSource = null;
                switch (filterType)
                {
                case 0:
                    data = useCase.FindAll();
                    break;

                case 1:
                    data = useCase.FindClientByName(ListFilterTextBox.Text);
                    break;

                case 2:
                    data = useCase.FindActiveClients();
                    break;

                case 3:
                    data = useCase.FindInactiveClients();
                    break;
                }

                ListDataGridView.DataSource = data;
                HideColumns();
                DisplayCounts();
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message, "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Beispiel #3
0
        private void EnableOrDisableClient()
        {
            var message = new StringBuilder();

            message.Append(
                $"¿Esta seguro de {(client.Credentials.IsActive ? "inhabilitar" : "habilitar")} el {Profile.SingleProfileName} {client}?");
            var result = MessageBox.Show(message.ToString(), "Atención", MessageBoxButtons.YesNo,
                                         MessageBoxIcon.Question);

            if (result == DialogResult.No)
            {
                return;
            }

            var oldStatus = client.Credentials.IsActive;

            try{
                var usecase = ClientUseCase.CreateUseCase(Profile.ProfileId, Profile.SingleProfileName);
                usecase.EnableDisableClient(client.Credentials.UserId, client.Credentials.IsActive);
                message.Clear();
                message.Append(
                    $"El {Profile.SingleProfileName} {client} fue {(client.Credentials.IsActive ? "inhabilitado" : "habilitado")} correctamente, los usuarios administradores pueden volver a rebocar esta acción.");
                MessageBox.Show(message.ToString(), "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                IsSaved = true;
                Close();
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message, "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                client.Credentials.IsActive = oldStatus;
            }

            ChangeTextStatusClient();
        }
Beispiel #4
0
        private bool SaveClientData()
        {
            bool result;

            PutUserDataIntoObject();
            try{
                string message;
                var    usecase = ClientUseCase.CreateUseCase(Profile.ProfileId, Profile.SingleProfileName);
                if (IsNewRecord)
                {
                    usecase.NewClient(client);
                    message = $"El {Profile.SingleProfileName} {client} ha sido almacenado correctamente.";
                    MessageBox.Show(message, "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    usecase.EditEmployee(client, true, passwordChanged);
                    message = $"El {Profile.SingleProfileName} {client} ha sido actualizado correctamente.";
                    MessageBox.Show(message, "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                result = true;
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message, "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                result = false;
            }
            return(result);
        }
Beispiel #5
0
 private void LoadUserInfo()
 {
     try{
         var usecase = ClientUseCase.CreateUseCase(Profile.ProfileId, Profile.SingleProfileName);
         GetClientData(usecase.FindClientById(IdSelected));
     }
     catch (Exception ex) {
         MessageBox.Show(ex.Message, "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         Close();
     }
 }
 private void LoadUserInfo()
 {
     try{
         var usecase = ClientUseCase.CreateUseCase(Profile.ProfileId, Profile.SingleProfileName);
         GetClientData(usecase.FindClientById(idSelected));
         var usecaseCd = ComercialDataUseCase.CreateUseCase();
         CustomerFound.ComercialInfo = usecaseCd.FindComercialDataById(CustomerFound.Id);
     }
     catch (Exception ex) {
         MessageBox.Show(ex.Message, "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         IsFound = false;
         Close();
     }
 }
Beispiel #7
0
        private void LoadUsers(int filterType)
        {
            try{
                var useCase = ClientUseCase.CreateUseCase(Profile.ProfileId, Profile.SingleProfileName);
                var data    = new DataTable();
                ListDataGridView.DataSource = null;
                switch (filterType)
                {
                case 0:
                    data = useCase.FindAll();
                    break;

                case 1:
                    data = useCase.FindClientByName(ListFilterTextBox.Text);
                    break;

                case 2:
                    data = useCase.FindActiveClients();
                    break;

                case 3:
                    data = useCase.FindInactiveClients();
                    break;
                }

                ListDataGridView.DataSource = data;
                var            configurator = DataGridViewConfigurator.CreateConfigurator(ListDataGridView);
                IList <string> columns      = new List <string> {
                    "id_cliente", "id_usuario", "id_rol", "nombre_cliente", "apellido_cliente", "password", "is_active"
                };
                configurator.HideColumns(columns);
                DisplayCounts();
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message, "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }