public List <Mascota> getMascotaList(int idMiembro) { DataTable mascotasTbl = new DataTable(); List <Mascota> mascotas = new List <Mascota>(); bool status = DependencyService.Get <IWebService>().getMascota_Busca(idMiembro, -1); if (status) { mascotasTbl = DependencyService.Get <IWebService>().Mascota_Busca; foreach (DataRow dr in mascotasTbl.Rows) { int year = Convert.ToInt32(dr["YearBitrh"].ToString()); int month = Convert.ToInt32(dr["MonthBirth"].ToString()); int año = DateTime.Now.Year; int mes = DateTime.Now.Month; DateTime actual = new DateTime(año, mes, 1); DateTime nacimiento = new DateTime(year, month, 1); var mascotaTmp = new Mascota() { idMascota = Convert.ToInt32(dr["IDPet"]), idPais = Convert.ToInt32(dr["IDCountryLoc"]), idEstado = Convert.ToInt32(dr["IDStateLoc"]), idCiudad = Convert.ToInt32(dr["IDCityLoc"]), idSucursal = Convert.ToInt32(dr["IDPartnerLocation"]), nombre = dr["Name"].ToString(), codigo = dr["Code"].ToString(), tipo = dr["PetType"].ToString(), raza = dr["Breed"].ToString(), color = dr["Color"].ToString(), edad = years(nacimiento, actual), //No es el campo correcto sexo = dr["Sex"].ToString(), suscripcion = dr["SubscriptionType"].ToString(), idAsociado = Convert.ToInt32(dr["IDPartner"].ToString()), veterinario = dr["BusinessName"].ToString(), alta = dr["DateActivated"].ToString(), expira = dr["DateExpiration"].ToString(), botonIzq = (dr["PetStatusCode"].ToString() == "REG") ? "Reportar como perdida" : "Cancelar reporte", botonDer = (dr["PetStatusCode"].ToString() == "REG") ? "Reportar como robada" : "Reportar como encontrada" }; Mascota incidenteMascota = getMascotaListPerdidas(mascotaTmp.idMascota, idMiembro); if (incidenteMascota == null) { mascotaTmp.perdida = false; mascotaTmp.robada = false; mascotaTmp.estatus = "En casa con dueño"; } else { mascotaTmp.perdida = incidenteMascota.perdida; mascotaTmp.robada = incidenteMascota.robada; if (mascotaTmp.perdida) { mascotaTmp.estatus = "Reportada como extraviada"; } if (mascotaTmp.robada) { mascotaTmp.estatus = "Reportada como robada"; } } mascotas.Add(mascotaTmp); } } return(mascotas); }
public Registro_mascota(Mascota mascota, bool isEdit) { InitializeComponent(); pkrRazaMascota.IsEnabled = false; pkrColorMascota.IsEnabled = false; if (isEdit) { mascotaG = mascota; isEditG = isEdit; txtCodigo.Text = mascota.codigo; txtNombre.Text = mascota.nombre; txtedadMascota.Text = mascota.edad.ToString(); pkrSexoMascota.SelectedIndex = mascota.sexo == "M" ? 0 : 1; sexoMascotaC = pkrTipoMascota.SelectedIndex == 0 ? (char)77 : (char)72; chkTermino.IsChecked = true; //txtedadMascota.Text = mascota.edad.ToString(); } if (!CrossConnectivity.Current.IsConnected) { DisplayAlert("Error", "No estás conectado a internet", "Ok"); return; } DataTable tipoMascota = new DataTable(); DependencyService.Get <IWebService>().getMascotaTipo_Busca(); tipoMascota = DependencyService.Get <IWebService>().MascotaTipo_Busca; //get client data by memberId try { DependencyService.Get <IWebService>().getCliente_Busca(Preferences.Get("idMiembro", 0), -1); dtDueno = DependencyService.Get <IWebService>().Cliente_Busca; Console.WriteLine("Get idMiembro" + Preferences.Get("idMiembro", 0)); Console.WriteLine("Rows: " + dtDueno.Rows.Count); foreach (DataRow dr in dtDueno.Rows) { dueno = new Dueno() { nombre = dr["Name"].ToString(), apellidoP = dr["LastName"].ToString(), apellidoM = dr["LastName2"].ToString(), sexo = dr["Sex"].ToString() == "M" ? 77 : 70, correo = dr["EMail"].ToString().Replace("\t", "").Trim(), contrasena = Preferences.Get("password", "") }; Console.WriteLine("Nombre: " + nombre); Console.WriteLine("Apellido P: " + apellidoP); Console.WriteLine("Apellido M: " + apellidoM); Console.WriteLine("Sexo: " + sexo); Console.WriteLine("correo: " + correo); Console.WriteLine("contrasena: " + contrasena); } } catch (Exception ex) { Console.WriteLine("Error linea 68: " + ex); } pkrTipoMascota.Items.Clear(); tipoMascotaDic.Clear(); foreach (DataRow dr in tipoMascota.Rows) { pkrTipoMascota.Items.Add(dr[2].ToString()); tipoMascotaDic.Add(dr[2].ToString(), Convert.ToInt32(dr[0])); } pkrTipoMascota.SelectedIndexChanged += tipoMascotaSeleccionado; pkrSexoMascota.SelectedIndexChanged += (object sender, EventArgs eventArgs) => { int sexoSelected = pkrSexoMascota.SelectedIndex; if (sexoSelected == 0) { sexoMascotaC = (char)77; } else if (sexoSelected == 1) { sexoMascotaC = (char)72; } }; DataTable paises = new DataTable(); DependencyService.Get <IWebService>().getPais_Busca(); paises = DependencyService.Get <IWebService>().Pais_Busca; pkrPais.Items.Clear(); paisDic.Clear(); foreach (DataRow dr in paises.Rows) { pkrPais.Items.Add(dr["Name"].ToString()); paisDic.Add(dr["Name"].ToString(), Convert.ToInt32(dr["IDCountry"])); paisDicEdit.Add(Convert.ToInt32(dr["IDCountry"]), dr["Name"].ToString()); } pkrPais.SelectedIndexChanged += PkrPais_SelectedIndexChanged; if (isEdit) { pkrTipoMascota.SelectedItem = mascota.tipo; pkrRazaMascota.IsEnabled = true; tipoMascotaSeleccionado(null, null); try { pkrPais.SelectedItem = paisDicEdit[mascota.idPais]; PkrPais_SelectedIndexChanged(null, null); } catch (Exception) { } } }//Constructor
private void LsvMascotasExiste_ItemTapped(object sender, ItemTappedEventArgs e) { Mascota mascotaSelected = lsvMascotasExiste.SelectedItem as Mascota; Navigation.PushAsync(new Registro_mascota(mascotaSelected, true)); }