Example #1
0
        public EditPage(Empleado empleado)
        {
            InitializeComponent();
            this.empleado = empleado;

            actualizarButton.Clicked += actualizarButton_Clicked;
            borrarButton.Clicked += borrarButton_Clicked;

            nombresEntry.Text = empleado.Nombres;
            apellidosEntry.Text = empleado.Apellidos;
            salarioEntry.Text = empleado.Salario.ToString();
            fechaContratoDatePicker.Date = empleado.FechaContrato;
            activoSwitch.IsToggled = empleado.Activo;
        }
Example #2
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 #3
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());
        }
Example #4
0
 public void updateEmpleado(Empleado empleado)
 {
     connection.Update(empleado);
 }
Example #5
0
 public void InsertEmpleado(Empleado empleado)
 {
     connection.Insert(empleado);
 }
Example #6
0
 public void DeleteEmplado(Empleado empleado)
 {
     connection.Delete(empleado);
 }