Exemplo n.º 1
0
        //——————————————————————————————————————————————————————————————[ Guardar ]———————————————————————————————————————————————————————————————
        private void GuardarButton_Click(object sender, RoutedEventArgs e)
        {
            {
                if (!Validar())
                {
                    return;
                }

                //———————————————————————————————————————————————————————[ VALIDAR SI ESTA VACIO ]———————————————————————————————————————————————————————
                //—————————————————————————————————[ Contacto Id ]—————————————————————————————————
                if (EmpleadoIdTextBox.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (Contacto Id) está vacío.\n\nPorfavor, Asigne un Id al Contacto.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    EmpleadoIdTextBox.Text = "0";
                    EmpleadoIdTextBox.Focus();
                    EmpleadoIdTextBox.SelectAll();
                    return;
                }

                //—————————————————————————————————[ NombreCompleto ]—————————————————————————————————
                if (NombreCompletoTextBox.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (Nombre Completo) está vacío.\n\nPorfavor, Asigne un Nombre al Contacto.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    NombreCompletoTextBox.Clear();
                    NombreCompletoTextBox.Focus();
                    return;
                }
                //—————————————————————————————————[ Telefono ]—————————————————————————————————
                if (TelefonoTextBox.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (Teléfono) está vacío.\n\nAsigne un Teléfono al Estudiante.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    TelefonoTextBox.Text = "0";
                    TelefonoTextBox.Focus();
                    TelefonoTextBox.SelectAll();
                    return;
                }
                if (TelefonoTextBox.Text.Length != 10)
                {
                    MessageBox.Show($"El Teféfono ({TelefonoTextBox.Text}) no es válido.\n\nEl Teléfono debe tener 10 dígitos (0-9).", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    TelefonoTextBox.Focus();
                    return;
                }
                //———————————————————————————————————————————————————————[ VALIDAR SI ESTA VACIO - FIN ]———————————————————————————————————————————————————————
                var paso = EmpleadosBLL.Guardar(empleados);
                if (paso)
                {
                    Limpiar();
                    MessageBox.Show("El Registro se pudo guardar satisfactoriamente.", "Éxito", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    MessageBox.Show("El Registro no se pudo guardar :(", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Exemplo n.º 2
0
        //—————————————————————————————————————————————————————————————[ TEXT CHANGED ]—————————————————————————————————————————————————————————————

        //—————————————————————————————————[ Contacto Id ]—————————————————————————————————
        private void EmpleadoIdTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                if (EmpleadoIdTextBox.Text.Trim() != string.Empty)
                {
                    int.Parse(EmpleadoIdTextBox.Text);
                }
            }
            catch
            {
                MessageBox.Show($"El valor digitado en el campo (Contacto Id) debe ser un número.\n\nPor favor, digite un número valido.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                EmpleadoIdTextBox.Text = "0";
                EmpleadoIdTextBox.Focus();
                EmpleadoIdTextBox.SelectAll();
            }
        }
Exemplo n.º 3
0
        //——————————————————————————————————————————————————————————————[ Buscar ]———————————————————————————————————————————————————————————————
        private void BuscarButton_Click(object sender, RoutedEventArgs e)
        {
            Empleados encontrado = EmpleadosBLL.Buscar(Utilidades.ToInt(EmpleadoIdTextBox.Text));

            if (encontrado != null)
            {
                this.empleados = encontrado;
                Cargar();
            }
            else
            {
                this.empleados   = new Empleados();
                this.DataContext = this.empleados;

                MessageBox.Show($"Este Contacto no fue encontrado.\n\nAsegúrese que existe o cree uno nuevo.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);

                Limpiar();
                EmpleadoIdTextBox.SelectAll();
                EmpleadoIdTextBox.Focus();
            }
        }