private void BuscarBtn_Click(object sender, EventArgs e) { int idAnimal = -1; string idChip = string.Empty; if (etFiltro.Text.Length >= 10) { idChip = etFiltro.Text; } else { idAnimal = Convert.ToInt32(etFiltro.Text); } Animal animalEncontrado = new Animal() { ID = -1 }; if (idAnimal > 0) { var animalesId = Business.Animal.Select(new Animal() { ID = idAnimal }); if (animalesId.Count == 1 && animalesId[0].ID_Chip == null) { animalEncontrado = animalesId[0]; if (permisoAsociar == "True") { bnAsociarChip.Visibility = ViewStates.Visible; } else { bnAsociarChip.Visibility = ViewStates.Invisible; } } } else { var animalesChip = Business.Animal.Select(new Animal() { ID = 0 }).Where(x => x.ID_Chip == idChip).ToList(); if (animalesChip.Count() == 1) { animalEncontrado = animalesChip[0]; } } if (animalEncontrado.ID > 0 || animalEncontrado.ID_Chip != null) { _animal = animalEncontrado; MostrarDatos(animalEncontrado); } else { Utiles.MostrarMensaje(this, "Animal inexistente", "El animal buscado no se encontró"); } }
public static List <Entities.Animal> Select(Entities.Animal animal) { if (animal.ID > 0) { return(SyntexLocal.Select <Entities.Animal>().Where(x => x.ID == animal.ID).ToList()); } else { return(SyntexLocal.Select <Entities.Animal>()); } }
public static void Delete(Entities.Animal animal) { if (animal != null) { SyntexLocal.Delete <Entities.Animal>(animal.ID_Chip); } else { SyntexLocal.Delete <Entities.Animal>(string.Empty); } }
private void click_limpiar(object sender, EventArgs e) { etFiltro.Text = ""; etID.Text = ""; etIDChip.Text = ""; etCategoria.Text = ""; etTipo.Text = ""; etFecha.Text = ""; etPelaje.Text = ""; etEdadIngreso.Text = ""; etEdadActual.Text = ""; etPotrero.Text = ""; bnAsociarChip.Visibility = ViewStates.Invisible; _animal = null; }
Entities.Animal BuscarAnimal(string sChip) { int idAnimal = -1; string idChip = string.Empty; if (sChip.Length >= 10) { idChip = sChip; } else { idAnimal = Convert.ToInt32(sChip); } Entities.Animal animalEncontrado = new Entities.Animal() { ID = -1 }; if (idAnimal > 0) { var animalesId = Business.Animal.Select(new Entities.Animal() { ID = idAnimal }); if (animalesId.Count >= 1) { var etapa = animalesId.Max(x => x.EtapaProduccion); animalEncontrado = animalesId.Where(x => x.EtapaProduccion == etapa).FirstOrDefault(); } } else { var animalesChip = Business.Animal.Select(new Entities.Animal() { ID = 0 }).Where(x => x.ID_Chip == idChip).ToList(); if (animalesChip.Count() == 1) { var etapa = animalesChip.Max(x => x.EtapaProduccion); animalEncontrado = animalesChip.Where(x => x.EtapaProduccion == etapa).FirstOrDefault(); } } return(animalEncontrado); }
private int ValidarMuestreo(Entities.Animal animal) { int valor = 0; var sangrias = Business.Sangria.Select(new Entities.Sangria()). Where(x => x.IdAnimal == animal.ID && x.IdCategoria == animal.ID_Categoria && x.IdEtapaProduccion == animal.EtapaProduccion && x.Litros == null); var abortos = Business.Aborto.Select(new Entities.Aborto()).Where( x => x.ID_ANIMAL == animal.ID && x.ID_CATEGORIA == animal.ID_Categoria && x.ID_ETAPA_PRODUCCION == animal.EtapaProduccion && x.FECHA_ABORTO == null); var gestacion = Business.AMuestrear.Select(new Entities.AMuestrear()).Where( x => x.ID_ANIMAL == animal.ID && x.ID_CATEGORIA == animal.ID_Categoria && x.ID_ETAPA_PRODUCCION == animal.EtapaProduccion ).OrderByDescending(x => x.FECHA_TACTO).FirstOrDefault(); var muestreos = Business.MuestreoProd.Select(new Entities.MuestreoProd()).Where(x => x.ID_ANIMAL == animal.ID && x.ID_CATEGORIA == animal.ID_Categoria && x.ID_ETAPA_PRODUCCION == animal.EtapaProduccion); var ultimoMuestreo = muestreos.OrderByDescending(x => x.FECHA_MUESTREO).FirstOrDefault(); if (ultimoMuestreo != null) { if ((DateTime.Now - ultimoMuestreo.FECHA_ALTA).TotalDays < 1 && ultimoMuestreo.nuevoEditado == 1) { return(valor); } else { valor = 7; } } else { var datos = Business.DatosDefault.Select(new Entities.DatosDefault()); var estados = Business.Estado.Select(new Entities.Estado()); var diasMuestreoInicial = datos.Where(x => x.Codigo == "GEST_MUESTREO").First(); var estadoServicio = estados.Where(x => x.Nombre == "Servicio").FirstOrDefault(); if (sangrias != null) { valor = 1; } if (abortos != null) { valor = 2; } if (gestacion != null) { return(6); } if ((gestacion.GESTACION + (DateTime.Now - gestacion.FECHA_TACTO).TotalDays) < Convert.ToInt32(diasMuestreoInicial.Valor)) { valor = 3; } if (animal.ID_Estado != estadoServicio.ID) { valor = 4; } decimal value; if (!Decimal.TryParse(etPeso.Text, out value)) { valor = 5; } return(valor); } return(valor); }
public static void UpdateChip(Entities.Animal animal) { Data.Animal.UpdateChip(animal); }
public static List <Entities.Animal> Select(Entities.Animal animal) { return(Data.Animal.Select(animal)); }
public static void Insert(Entities.Animal animal) { Data.Animal.Insert(animal); }
public static void Delete(Entities.Animal animal) { Data.Animal.Delete(animal); }
public static void UpdateChip(Entities.Animal animal) { SyntexLocal.UpdateChip(animal); }
public static void Insert(Entities.Animal animal) { SyntexLocal.Insert(animal); }