Example #1
0
        public async void borrarButton_Clicked(object sender, EventArgs e)
        {
            var rta = await DisplayAlert("Confirmación", "¿Desea borrar el empleado?", "Si", "No");
            if (!rta) return;

            using (var datos = new DataAccess())
            {
                datos.DeleteEmplado(empleado);
            }

            await DisplayAlert("Confirmación", "Empleado eliminado correctamente", "Aceptar");
            await Navigation.PushAsync(new HomePage());
        }
Example #2
0
        public HomePage()
        {
            InitializeComponent();

            nuevoButton.Clicked += nuevoButton_Clicked;

            datosListView.ItemSelected += datosListView_ItemSelected;

            datosListView.ItemTemplate = new DataTemplate(typeof(EmpleadoCell));

            using (var datos = new DataAccess())
            {
                datosListView.ItemsSource = datos.GetEmpleados();
            }
        }
Example #3
0
        public async void nuevoButton_Clicked(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(nombresEntry.Text))
            {
                await DisplayAlert("Error", "Debe ingresar nombres", "Aceptar");
                nombresEntry.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(apellidosEntry.Text))
            {
                await DisplayAlert("Error", "Debe ingresar apellidos", "Aceptar");
                apellidosEntry.Focus();
                return;
            }

            if (string.IsNullOrEmpty(salarioEntry.Text))
            {
                await DisplayAlert("Error", "Debe ingresar salario", "aceptar");
                salarioEntry.Focus();
                return;
            }

            Empleado empleado = new Empleado
            {
                Activo = activoSwitch.IsToggled,
                Apellidos = apellidosEntry.Text,
                FechaContrato = fechaContratoDatePicker.Date,
                Nombres = nombresEntry.Text,
                Salario = Convert.ToDecimal(salarioEntry.Text)
            };

            using (var datos = new DataAccess())
            {
                datos.InsertEmpleado(empleado);
                datosListView.ItemsSource = datos.GetEmpleados();
            }

            apellidosEntry.Text = String.Empty;
            fechaContratoDatePicker.Date = DateTime.Now;
            nombresEntry.Text = String.Empty;
            salarioEntry.Text = String.Empty;
            await DisplayAlert("Mensaje", "Empleado creado correctamente", "Aceptar");
        }
Example #4
0
        public async  void actualizarButton_Clicked(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(nombresEntry.Text))
            {
                await DisplayAlert("Error", "Debe ingresar nombres", "Aceptar");
                nombresEntry.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(apellidosEntry.Text))
            {
                await DisplayAlert("Error", "Debe ingresar apellidos", "Aceptar");
                apellidosEntry.Focus();
                return;
            }

            if (string.IsNullOrEmpty(salarioEntry.Text))
            {
                await DisplayAlert("Error", "Debe ingresar salario", "aceptar");
                salarioEntry.Focus();
                return;
            }

            Empleado empleado = new Empleado
            {
                IDEmpleado = this.empleado.IDEmpleado,
                Activo = activoSwitch.IsToggled,
                Apellidos = apellidosEntry.Text,
                FechaContrato = fechaContratoDatePicker.Date,
                Nombres = nombresEntry.Text,
                Salario = Convert.ToDecimal(salarioEntry.Text)
            };

            using (var datos = new DataAccess())
            {
                datos.updateEmpleado(empleado);
            }

            await DisplayAlert("Confirmación", "Empleado actualizado correctamente", "Aceptar");
            await Navigation.PushAsync(new HomePage());
        }