public PaginadeInicio() { InitializeComponent(); AgregarButton.Clicked += AgregarButton_Clicked; listaListView.ItemSelected += ListaListView_ItemSelected; listaListView.ItemTemplate = new DataTemplate(typeof(EmpleadoCell)); using (var datos = new AccesoAlosDatos()) { listaListView.ItemsSource = datos.GetEmpleado(); } }
public async void BorrarButton_Clicked(object sender, EventArgs e) { var rta = await DisplayAlert("Confirmacion", "Desea borrar el empleado?", "Si", "No"); if (!rta) { return; } using (var datos = new AccesoAlosDatos()) { datos.DeleteEmpleado(empleado); } await DisplayAlert("Confirmacion", "Empleado borrado correctamente", "Aceptar"); await Navigation.PushAsync(new PaginadeInicio()); }
public async void AgregarButton_Clicked(object sender, EventArgs e) { if (string.IsNullOrEmpty(nombresEntry.Text)) { await DisplayAlert("Error", "Debe ingresar nombres", "Aceptar"); nombresEntry.Focus(); return; } if (string.IsNullOrEmpty(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 = decimal.Parse(salarioEntry.Text) }; using (var datos = new AccesoAlosDatos()) { datos.InsertEmpleado(empleado); listaListView.ItemsSource = datos.GetEmpleado(); } 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.IsNullOrEmpty(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, Nombres = nombresEntry.Text, FechaContrato = fechaContratoDatePicker.Date, Salario = decimal.Parse(salarioEntry.Text) }; using (var datos = new AccesoAlosDatos()) { datos.UpdateEmpleado(empleado); } await DisplayAlert("Confirmacion", "Empleado actualizado correctamente", "Aceptar"); await Navigation.PushAsync(new PaginadeInicio()); }