/// <summary> /// Asigna a los componentes del form la información de la vaca seleccionada. /// </summary> private void LlenarInformcionVaca() { textBoxNumeroTrazableVaca.Text = this.informacionVacaSeleccionada.pkNumeroTrazable.ToString(); textBoxNombre.Text = this.informacionVacaSeleccionada.nombre; textBoxCaracteristicas.Text = this.informacionVacaSeleccionada.caracteriscas; textBoxFechaNacimiento.Text = this.informacionVacaSeleccionada.fecha.ToString(); textBoxModoPrennes.Text = this.informacionVacaSeleccionada.modoPrennes; textBoxIdMadre.Text = this.informacionVacaSeleccionada.fkNumeroTrazableMadre.ToString(); textBoxIdPadre.Text = this.informacionVacaSeleccionada.fkNumeroTrazablePadre.ToString(); textBoxRaza.Text = this.informacionVacaSeleccionada.razaStr; int edad = -1; if (this.informacionVacaSeleccionada.fecha != null) { edad = DateTime.Today.Year - ((DateTime)this.informacionVacaSeleccionada.fecha).Year; if (((DateTime)this.informacionVacaSeleccionada.fecha).Date > DateTime.Today.AddYears(-edad)) { edad--; } } textBoxEdad.Text = edad.ToString(); textBoxPeso.Text = this.informacionVacaSeleccionada.peso.ToString(); textBoxDesarrollo.Text = this.informacionVacaSeleccionada.desarrollo; if (this.informacionVacaSeleccionada.activa) { checkBoxActiva.Checked = true; textBoxCausaDeBaja.Visible = false; labelCausaDeBaja.Visible = false; } else { checkBoxActiva.Checked = false; textBoxCausaDeBaja.Visible = true; textBoxCausaDeBaja.Text = this.informacionVacaSeleccionada.causaDeBaja; } // Se calculan los parametros reproductivos de la vaca. ProgramConfiguration config = new ProgramConfiguration(); string unidadDeTiempo = config.ObtenerConfig(ProgramConfiguration.LLAVE_UNIDAD_DE_TIEMPO); try { double resultado = ProcedimientosAlmacenados.ProcObtenerUltimoIEP(this.informacionVacaSeleccionada.pkNumeroTrazable); if ((int)resultado == Utilities.RESULTADO_ERROR) { textBoxUltimoIEP.Text = "Error"; } else { switch (unidadDeTiempo) { case "Meses": labelIEPUltimo.Text = "Ultimo IEP (meses)"; textBoxUltimoIEP.Text = (resultado / Utilities.DIAS_MES).ToString("0.##"); break; case "Semanas": labelIEPUltimo.Text = "Ultimo IEP (semanas)"; textBoxUltimoIEP.Text = (resultado / Utilities.DIAS_SEMANA).ToString("0.##"); break; default: labelIEPUltimo.Text = "Ultimo IEP (días)"; textBoxUltimoIEP.Text = resultado.ToString("0.##"); break; } } } catch { textBoxUltimoIEP.Text = "Error"; } try { double resultado = ProcedimientosAlmacenados.ProcObtenerIEP(this.informacionVacaSeleccionada.pkNumeroTrazable); if ((int)resultado == Utilities.RESULTADO_ERROR) { textBoxIEPPromedio.Text = "Error"; } else { switch (unidadDeTiempo) { case "Meses": labelIEPPromedio.Text = "IEP promedio (meses)"; textBoxIEPPromedio.Text = (resultado / Utilities.DIAS_MES).ToString("0.##"); break; case "Semanas": labelIEPPromedio.Text = "Ultimo promedio (semanas)"; textBoxIEPPromedio.Text = (resultado / Utilities.DIAS_SEMANA).ToString("0.##"); break; default: labelIEPPromedio.Text = "Ultimo promedio (días)"; textBoxIEPPromedio.Text = resultado.ToString(); break; } } } catch { textBoxIEPPromedio.Text = "Error"; } // Se calcula una fecha de parto tentativa. Object resultadoQuery = Utilities.ObtenerAtributoTabla(QUERY_SELECT_FECHA_ULTIMO_CELO_VACA, VACA_PARAM, this.informacionVacaSeleccionada.pkNumeroTrazable); if (this.informacionVacaSeleccionada.modoPrennes != "No preñada") { if (resultadoQuery.GetType().ToString() != "System.DBNull") { labelFechaTentativaParto.Visible = textBoxFechaTentativaParto.Visible = true; labelFechaTentativaParto.Text = "Fecha tentativa de parto"; if (resultadoQuery.GetType().ToString() != "System.DateTime") { textBoxFechaTentativaParto.Text = "Error"; } else { try { DateTime fechaUltimoCeloVaca = (DateTime)resultadoQuery; DateTime fechaTentativaParto = fechaUltimoCeloVaca.AddMonths(Utilities.TIEMPO_GESTACION_VACA_MESES); textBoxFechaTentativaParto.Text = fechaTentativaParto.ToShortDateString(); } catch { textBoxFechaTentativaParto.Text = "Error"; } } } else { labelFechaTentativaParto.Visible = textBoxFechaTentativaParto.Visible = false; } } else { if (resultadoQuery.GetType().ToString() != "System.DBNull") { labelFechaTentativaParto.Visible = textBoxFechaTentativaParto.Visible = true; labelFechaTentativaParto.Text = "Fecha de palpación"; if (resultadoQuery.GetType().ToString() != "System.DateTime") { textBoxFechaTentativaParto.Text = "Error"; } else { try { DateTime fechaUltimoCeloVaca = (DateTime)resultadoQuery; DateTime fechaTentativaParto = fechaUltimoCeloVaca.AddDays(Int32.Parse(config.ObtenerConfig(ProgramConfiguration.LLAVE_ALERTA_PALPACION))); textBoxFechaTentativaParto.Text = fechaTentativaParto.ToShortDateString(); } catch { textBoxFechaTentativaParto.Text = "Error"; } } } else { labelFechaTentativaParto.Visible = textBoxFechaTentativaParto.Visible = false; } } }
/// <summary> /// Asigna a los componentes del form la información de la vaca seleccionada. /// </summary> private void LlenarInformcionVaca() { textBoxNumeroTrazableVaca.Text = this.informacionVacaSeleccionada.pkNumeroTrazable.ToString(); textBoxNombre.Text = this.informacionVacaSeleccionada.nombre; textBoxCaracteristicas.Text = this.informacionVacaSeleccionada.caracteriscas; textBoxFechaNacimiento.Text = this.informacionVacaSeleccionada.fecha.ToString(); textBoxModoPrennes.Text = this.informacionVacaSeleccionada.modoPrennes; textBoxIdMadre.Text = this.informacionVacaSeleccionada.fkNumeroTrazableMadre.ToString(); textBoxIdPadre.Text = this.informacionVacaSeleccionada.fkNumeroTrazablePadre.ToString(); textBoxRaza.Text = this.informacionVacaSeleccionada.razaStr; int edad = -1; if (this.informacionVacaSeleccionada.fecha != null) { edad = DateTime.Today.Year - ((DateTime)this.informacionVacaSeleccionada.fecha).Year; if (((DateTime)this.informacionVacaSeleccionada.fecha).Date > DateTime.Today.AddYears(-edad)) { edad--; } } textBoxEdad.Text = edad.ToString(); textBoxPeso.Text = this.informacionVacaSeleccionada.peso.ToString(); textBoxDesarrollo.Text = this.informacionVacaSeleccionada.desarrollo; if (this.informacionVacaSeleccionada.activa) { checkBoxActiva.Checked = true; textBoxCausaDeBaja.Visible = false; labelCausaDeBaja.Visible = false; } else { checkBoxActiva.Checked = false; textBoxCausaDeBaja.Visible = true; textBoxCausaDeBaja.Text = this.informacionVacaSeleccionada.causaDeBaja; } // Se calculan los parametros reproductivos de la vaca. try { double resultado = ProcedimientosAlmacenados.ProcObtenerUltimoIEP(this.informacionVacaSeleccionada.pkNumeroTrazable); if ((int)resultado == Utilities.RESULTADO_ERROR) { textBoxUltimoIEP.Text = "Error"; } else { textBoxUltimoIEP.Text = resultado.ToString(); } } catch { textBoxUltimoIEP.Text = "Error"; } try { double resultado = ProcedimientosAlmacenados.ProcObtenerIEP(this.informacionVacaSeleccionada.pkNumeroTrazable); if ((int)resultado == Utilities.RESULTADO_ERROR) { textBoxIEPPromedio.Text = "Error"; } else { textBoxIEPPromedio.Text = resultado.ToString(); } } catch { textBoxIEPPromedio.Text = "Error"; } // Se calcula una fecha de parto tentativa. Object resultadoQuery = Utilities.ObtenerAtributoTabla(QUERY_SELECT_FECHA_ULTIMO_CELO_VACA, VACA_PARAM, this.informacionVacaSeleccionada.pkNumeroTrazable); if (resultadoQuery != null) { if (resultadoQuery.GetType().ToString() == "System.Int32") { textBoxFechaTentativaParto.Text = "Error"; } else { try { DateTime fechaUltimoCeloVaca = (DateTime)resultadoQuery; DateTime fechaActual = DateTime.Now; int diferenciaMesesFechas = (fechaActual.Year - fechaUltimoCeloVaca.Year) * 12 + fechaActual.Month - fechaUltimoCeloVaca.Month; if (diferenciaMesesFechas < Utilities.TIEMPO_GESTACION_VACA_MESES) { DateTime fechaTentativaParto = fechaUltimoCeloVaca.AddMonths(Utilities.TIEMPO_GESTACION_VACA_MESES); textBoxFechaTentativaParto.Text = fechaTentativaParto.ToShortDateString(); } else { textBoxFechaTentativaParto.Text = ""; } } catch { textBoxFechaTentativaParto.Text = ""; } } } else { textBoxFechaTentativaParto.Text = ""; } }