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; }
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"); }
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()); }
public void updateEmpleado(Empleado empleado) { connection.Update(empleado); }
public void InsertEmpleado(Empleado empleado) { connection.Insert(empleado); }
public void DeleteEmplado(Empleado empleado) { connection.Delete(empleado); }