Exemple #1
0
        private async void BtnCrearAlerta_Clicked(object sender, EventArgs e)
        {
            var userLog = App.Current.Properties["user"].ToString();

            if (userLog != null)
            {
                DateTime dtmFinal = new DateTime(dtmFechaRec.Year,
                                                 dtmFechaRec.Month,
                                                 dtmFechaRec.Day,
                                                 tmpHora.Time.Hours,
                                                 tmpHora.Time.Minutes,
                                                 00);

                HuertaModel objHuertaSelec = new HuertaModel();
                objHuertaSelec = (HuertaModel)cmbHuertas.SelectedItem;
                String strIdHuertaSelec = objHuertaSelec.Id;

                TipoAlertaModel objTipoAlertaSelec = new TipoAlertaModel();
                objTipoAlertaSelec = (TipoAlertaModel)cmbTipoAlerta.SelectedItem;
                String strIdTipoAlertaSelec = objTipoAlertaSelec.Id;

                var ok = AlertaServicio.CrearAlerta(userLog, strIdHuertaSelec, txtDescripcion.Text, dtmFinal, chkAvisa.IsToggled, strIdTipoAlertaSelec);
                if (ok)
                {
                    await DisplayAlert("Registro correcto", "La alerta se ha grabado correctamente", "Ok");

                    await Navigation.PushAsync(new Calendario());
                }
                else
                {
                    await DisplayAlert("Registro incorrecto", "Revise los datos ingresados", "Cancelar");
                }
            }
        }
Exemple #2
0
        private async void BtnEditarAlerta_Clicked(object sender, EventArgs e)
        {
            var userLog = App.Current.Properties["user"].ToString();

            if (userLog != null)
            {
                //PRIMERO ELIMINO LA ALERTA ANTERIOR
                var okEliminado = AlertaServicio.EliminarAlerta(objAlerta.Id, objAlerta.avisa);
                if (okEliminado)
                {
                    DateTime dtmFinal = new DateTime(dtpFechaAlerta.Date.Year,
                                                     dtpFechaAlerta.Date.Month,
                                                     dtpFechaAlerta.Date.Day,
                                                     tmpHora.Time.Hours,
                                                     tmpHora.Time.Minutes,
                                                     00);

                    TipoAlertaModel objTipoAlertaSelec = new TipoAlertaModel();
                    objTipoAlertaSelec = (TipoAlertaModel)cmbTipoAlerta.SelectedItem;
                    String strIdTipoAlertaSelec = objTipoAlertaSelec.Id;

                    var ok = AlertaServicio.CrearAlerta(userLog, objAlerta.HuertaID, txtDescripcion.Text, dtmFinal, chkAvisa.IsToggled, strIdTipoAlertaSelec);
                    if (ok)
                    {
                        await DisplayAlert("Registro correcto", "La alerta se ha actualizado correctamente", "Ok");

                        await Navigation.PushAsync(new Calendario());
                    }
                    else
                    {
                        await DisplayAlert("Registro incorrecto", "No se ha podido actualizar la alerta", "Cancelar");
                    }
                }
                else
                {
                    await DisplayAlert("Registro incorrecto", "No se ha podido modificar la alerta original", "Cancelar");
                }
            }
        }