public void escribir_buscar() { List<Mascota> lista = new NMascota().N_Listar_Mascotas(); var filtro = from Mascota in lista where Mascota.Nombre.ToString().ToUpper().Contains(text_buscar.Text.ToUpper()) || ("00-00" + Mascota.Serie.ToString().ToUpper()).Contains(text_buscar.Text.ToUpper()) || Mascota.Ser_usu.Codigo.ToString().ToUpper().Contains(text_buscar.Text.ToUpper()) || Mascota.Tipomascota.Descripcion.ToString().ToUpper().Contains(text_buscar.Text.ToUpper()) || Mascota.Tamano.ToString().ToUpper().Contains(text_buscar.Text.ToUpper()) || Mascota.Estado.ToString().ToUpper().Contains(text_buscar.Text.ToUpper()) || Mascota.Raza.ToString().ToUpper().Contains(text_buscar.Text.ToUpper()) || Mascota.Sexo.ToString().ToUpper().Contains(text_buscar.Text.ToUpper()) || Mascota.Color.ToString().ToUpper().Contains(text_buscar.Text.ToUpper()) || Mascota.Edad.ToString().ToUpper().Contains(text_buscar.Text.ToUpper()) || Mascota.Esterilizado.ToString().ToUpper().Contains(text_buscar.Text.ToUpper()) select Mascota; lista = filtro.ToList<Mascota>(); this.grilla_mascota.Rows.Clear(); for (int i = 0; i < lista.Count; i++) { int reglon = this.grilla_mascota.Rows.Add(); this.grilla_mascota.Rows[reglon].Cells["SERIE"].Value = lista[i].Serie; this.grilla_mascota.Rows[reglon].Cells["ID_RESCATISTA"].Value = lista[i].Ser_usu.Serie; this.grilla_mascota.Rows[reglon].Cells["SERIE_FORMATO"].Value = "00-00" + lista[i].Serie; this.grilla_mascota.Rows[reglon].Cells["COD_RESCATISTA"].Value = lista[i].Ser_usu.Codigo; this.grilla_mascota.Rows[reglon].Cells["RESCATISTA"].Value = lista[i].Ser_usu.Nombres + " " + lista[i].Ser_usu.Apellidos; if ((!String.IsNullOrEmpty(lista[i].Fic_tem.Id.ToString())) || (lista[i].Fic_tem.Id != 0)) { this.grilla_mascota.Rows[reglon].Cells["TEMPORAL"].Value = lista[i].Fic_tem.Id; } else { this.grilla_mascota.Rows[reglon].Cells["TEMPORAL"].Value = ""; } this.grilla_mascota.Rows[reglon].Cells["FECHA_INGRE"].Value = lista[i].Fecha_ingreso.ToShortDateString(); this.grilla_mascota.Rows[reglon].Cells["ID_TIPO"].Value = lista[i].Tipomascota.Id; this.grilla_mascota.Rows[reglon].Cells["TIPO"].Value = lista[i].Tipomascota.Descripcion; this.grilla_mascota.Rows[reglon].Cells["TAMANO"].Value = lista[i].Tamano; this.grilla_mascota.Rows[reglon].Cells["ESTADO"].Value = lista[i].Estado; this.grilla_mascota.Rows[reglon].Cells["NOMBRE"].Value = lista[i].Nombre; this.grilla_mascota.Rows[reglon].Cells["RAZA"].Value = lista[i].Raza; this.grilla_mascota.Rows[reglon].Cells["SEXO"].Value = lista[i].Sexo; this.grilla_mascota.Rows[reglon].Cells["COLOR"].Value = lista[i].Color; this.grilla_mascota.Rows[reglon].Cells["EDAD"].Value = lista[i].Edad; this.grilla_mascota.Rows[reglon].Cells["ESTERILIZADO"].Value = lista[i].Esterilizado; } }
private void btn_modificar_ficha_Click(object sender, EventArgs e) { btn_eliminar_ficha.Enabled = false; if (btn_modificar_ficha.Text.Equals("Editar")) { btn_modificar_ficha.Text = "Guardar Cambios"; habilitar_cajas(); btn_cancelar_registro.Enabled = true; if (radio_conoce_no.Checked == true) { fecha_esterilizacion.Enabled = false; } if (radio_conoce_si.Checked == true) { fecha_esterilizacion.Enabled = true; } } else { if (btn_modificar_ficha.Text.Equals("Guardar Cambios")) { Boolean band1 = false, band2 = false, band3 = false, band4 = false, band5 = false; String mensaje = "Por Favor Complete los campos obligatorios : \n"; String esterilizado = ""; String nom_rescatista = ""; String nom_mascota = ""; String estado = ""; String raza = ""; String color = ""; String edad = ""; String sexo = ""; int serie = int.Parse(lb_serie_mascota.Text); int serie_resca = 0; Usuario rescatista = null; if ((!String.IsNullOrEmpty(text_nombre_rescatista.Text)) && (!String.IsNullOrEmpty(lb_id_usuario.Text))) { serie_resca = int.Parse(lb_id_usuario.Text); nom_rescatista = text_nombre_rescatista.Text; rescatista = new Usuario(); rescatista.Serie = serie_resca; } else { mensaje = mensaje + "\n - No a Buscado el Rescatista "; band1 = true; } DateTime fingreso = Convert.ToDateTime(fecha_ingreso.Text); if (!String.IsNullOrEmpty(text_nombre.Text)) { nom_mascota = text_nombre.Text; } else { mensaje = mensaje + "\n - Casilla de Nombre de Mascota "; band2 = true; } if (radio_recuperacion.Checked == true) { estado = "En Recuperacion"; } else { if (radio_apto.Checked == true) { estado = "Apto"; } else { if (radio_adoptado.Checked == true) { estado = "Adoptado"; } } } if (!String.IsNullOrEmpty(this.text_raza.Text)) { raza = text_raza.Text; } else { mensaje = mensaje + "\n - Casilla de raza"; band3 = true; } if (!String.IsNullOrEmpty(text_color.Text)) { color = text_color.Text; } else { mensaje = mensaje + "\n - Casilla de Color "; band4 = true; } if (radio_macho.Checked == true) { sexo = "Macho"; } else { sexo = "Hembra"; } String tamaño = combo_tamaño.SelectedItem.ToString(); TipoMascota tipoM = (TipoMascota)combo_tipo.SelectedItem; Object f_esterilizado = null; if (!String.IsNullOrEmpty(text_edad.Text)) { edad = text_edad.Text; } if (radio_afirmativo.Checked == true) { esterilizado = "Si"; if (radio_conoce_si.Checked == true) { f_esterilizado = Convert.ToDateTime(fecha_esterilizacion.Text); } else { if (radio_conoce_no.Checked == true) { f_esterilizado = null; } } } else { if (radio_negativo.Checked == true) { esterilizado = "No"; f_esterilizado = null; } } FichaTemporal fTemporal; if (radio_temporal_si.Checked == true) { if (combo_temporal.Items.Count > 0) { fTemporal = (FichaTemporal)combo_temporal.SelectedItem; } else { fTemporal = null; } } else { fTemporal = null; } if (band1 == true || band2 == true || band3 == true || band4 == true || band5 == true) { MessageBox.Show(mensaje); } else { if (f_esterilizado != null) { DateTime t = Convert.ToDateTime(f_esterilizado); int confir1 = new NMascota().N_modificar_mascota_confecha_esterilizado(serie, rescatista, fTemporal, fingreso, tipoM, tamaño, estado, nom_mascota, raza, sexo, color, edad, esterilizado, t); if (confir1 == 0) { MessageBox.Show("Error Al Guardar Por favor intente nuevamente"); } else { MessageBox.Show("Cambios Guardados Correctamente"); invalidar_todo(); btn_registrar_ficha.Enabled = false; btn_cancelar_registro.Enabled = false; btn_nuevo_ficha.Enabled = true; btn_modificar_ficha.Text = "Editar"; tab_Historial.Parent = Tab_Mascota; tab_vacunas.Parent = Tab_Mascota; tab_Visitas.Parent = Tab_Mascota; tab_fotos.Parent = Tab_Mascota; group_conoce.Enabled = false; group_esterilizado.Enabled = false; inicio_listar(); combo_temporal.Enabled = false; group_temporal.Enabled = false; } } else { int confir1 = new NMascota().N_Modificar_mascota_Sinfecha_esterilizado(serie, rescatista, fTemporal, fingreso, tipoM, tamaño, estado, nom_mascota, raza, sexo, color, edad, esterilizado); if (confir1 == 0) { MessageBox.Show("Error Al Guardar Por favor intente nuevamente"); } else { MessageBox.Show("Cambios Guardados Correctamente"); invalidar_todo(); btn_registrar_ficha.Enabled = false; btn_cancelar_registro.Enabled = false; btn_nuevo_ficha.Enabled = true; btn_modificar_ficha.Text = "Editar"; tab_Historial.Parent = Tab_Mascota; tab_vacunas.Parent = Tab_Mascota; tab_Visitas.Parent = Tab_Mascota; tab_fotos.Parent = Tab_Mascota; group_conoce.Enabled = false; group_esterilizado.Enabled = false; inicio_listar(); combo_temporal.Enabled = false; group_temporal.Enabled = false; } } } } } }
private void grilla_general_CellClick(object sender, DataGridViewCellEventArgs e) { invalidar_todo(); btn_modificar_ficha.Text = "Editar"; limpiar_cajas(); contador = 0; btn_modificar_ficha.Enabled = true; this.lb_serie_mascota.Text = this.grilla_general.CurrentRow.Cells[2].Value.ToString(); this.mostra_serie_masco.Text = this.grilla_general.CurrentRow.Cells[0].Value.ToString(); this.lb_id_usuario.Text = this.grilla_general.CurrentRow.Cells[1].Value.ToString(); this.text_codigo.Text = this.grilla_general.CurrentRow.Cells[3].Value.ToString(); this.text_nombre_rescatista.Text = this.grilla_general.CurrentRow.Cells[4].Value.ToString(); this.pictureBox1.Image = null; String id_tempo = this.grilla_general.CurrentRow.Cells[5].Value.ToString(); if (!String.IsNullOrEmpty(id_tempo)) { int id_verdadero = Convert.ToInt32(id_tempo); for (int i = 0; i < combo_temporal.Items.Count; i++) { FichaTemporal ficha = (FichaTemporal)combo_temporal.Items[i]; if (ficha.Id == id_verdadero) { combo_temporal.SelectedIndex = i; radio_temporal_si.Checked = true; combo_temporal.Enabled = false; break; } } } else { radio_temporal_no.Checked = true; } this.fecha_ingreso.Text = this.grilla_general.CurrentRow.Cells[6].Value.ToString(); int id_tipo = Convert.ToInt32(this.grilla_general.CurrentRow.Cells[7].Value.ToString()); for (int i = 0; i < combo_tipo.Items.Count; i++) { TipoMascota tipo = (TipoMascota)combo_tipo.Items[i]; if (tipo.Id == id_tipo) { combo_tipo.SelectedIndex = i; break; } } String tamano = this.grilla_general.CurrentRow.Cells[9].Value.ToString(); if (tamano.Equals("Pequeño")) { combo_tamaño.SelectedIndex = 0; } else { if (tamano.Equals("Mediano")) { combo_tamaño.SelectedIndex = 1; } else { if (tamano.Equals("Grande")) { combo_tamaño.SelectedIndex = 2; } } } String estado = this.grilla_general.CurrentRow.Cells[10].Value.ToString(); if (estado.Equals("En Recuperacion")) { radio_recuperacion.Checked = true; } else { if (estado.Equals("Apto")) { radio_apto.Checked = true; } else { if (estado.Equals("Adoptado")) { radio_adoptado.Checked = true; } } } this.text_nombre.Text = this.grilla_general.CurrentRow.Cells[11].Value.ToString(); this.text_raza.Text = this.grilla_general.CurrentRow.Cells[12].Value.ToString(); lb_etiqueta_nombre.Visible = true; lb_etiqueta_mascota.Visible = true; lb_etiqueta_mascota.Text = "" + text_nombre.Text; String sexo = this.grilla_general.CurrentRow.Cells[13].Value.ToString(); if (sexo.Equals("Macho")) { radio_macho.Checked = true; } else { if (sexo.Equals("Hembra")) { radio_hembra.Checked = true; } } this.text_color.Text = this.grilla_general.CurrentRow.Cells[14].Value.ToString(); this.text_edad.Text = this.grilla_general.CurrentRow.Cells[15].Value.ToString(); String esterilizado = this.grilla_general.CurrentRow.Cells[16].Value.ToString(); if (esterilizado.Equals("Si")) { radio_afirmativo.Checked = true; int id_serie = Convert.ToInt32(lb_serie_mascota.Text); String fech = new NMascota().N_Ver_FechaEsterilizacion(id_serie); if (!String.IsNullOrEmpty(fech)) { radio_conoce_si.Checked = true; this.fecha_esterilizacion.Text = fech; } else { radio_conoce_no.Checked = true; } } else { if (esterilizado.Equals("No")) { radio_negativo.Checked = true; } } //historial clinico int idserieMascota = Convert.ToInt32(this.lb_serie_mascota.Text); activar_tabs(); Lista_HistorialClinicobyMascota(idserieMascota); #region inicio_fotos listar_imagenes(idserieMascota); inicio(); cargar_inciobotones(); #endregion btn_registrar_ficha.Enabled = false; btn_cancelar_registro.Enabled = false; #region opciones historial clinico limpieza_cajasHistorial(); Inhabilitar_CajasHistorial(); btn_nuevo_histo.Enabled = true; btn_registrar_histo.Enabled = false; btn_modificar_histo.Enabled = false; btn_eliminar_histo.Enabled = false; btn_cancelar_histo.Enabled = false; #endregion #region vacunas Listar_Vacunas(idserieMascota); #endregion #region visitas listar_visitar_mascota(idserieMascota); #endregion btn_verDatos.Enabled = true; btn_eliminar_ficha.Enabled = true; }
private void btn_eliminar_ficha_Click(object sender, EventArgs e) { if (MessageBox.Show("Seguro que dese Eliminar?", "Salir", MessageBoxButtons.YesNo) == DialogResult.Yes) { int serie = int.Parse(lb_serie_mascota.Text); int respuesta2 = new NMascota().N_eliminar_mascota(serie); if (respuesta2 == 0) { MessageBox.Show("Error Al Eliminar Por favor intente nuevamente"); } else { MessageBox.Show("Eliminado Correctamente"); lb_etiqueta_nombre.Visible = false; lb_etiqueta_mascota.Visible = false; lb_etiqueta_mascota.Text = ""; lb_id_usuario.Text = ""; lb_serie_mascota.Text = ""; tab_Historial.Parent = null; tab_vacunas.Parent = null; tab_Visitas.Parent = null; tab_fotos.Parent = null; Ver_serie_mascota(); limpiar_cajas(); invalidar_todo(); btn_registrar_ficha.Enabled = true; btn_cancelar_registro.Enabled = true; btn_eliminar_ficha.Enabled = false; btn_modificar_ficha.Enabled = false; if (radio_negativo.Checked == true) { group_conoce.Enabled = false; radio_conoce_no.Checked = true; fecha_esterilizacion.Enabled = false; } btn_modificar_visita.Text = "Editar"; inicio_listar(); } } }
public void inicio_listar() { List<Mascota> lista = new NMascota().N_Listar_Mascotas(); this.grilla_general.Rows.Clear(); for (int i = 0; i < lista.Count; i++) { int reglon = this.grilla_general.Rows.Add(); this.grilla_general.Rows[reglon].Cells["SERIE"].Value = lista[i].Serie; this.grilla_general.Rows[reglon].Cells["ID_RESCATISTA"].Value = lista[i].Ser_usu.Serie; this.grilla_general.Rows[reglon].Cells["SERIE_FORMATO"].Value = "00-00" + lista[i].Serie; this.grilla_general.Rows[reglon].Cells["COD_RESCATISTA"].Value = lista[i].Ser_usu.Codigo; this.grilla_general.Rows[reglon].Cells["RESCATISTA"].Value = lista[i].Ser_usu.Nombres + " " + lista[i].Ser_usu.Apellidos; if ((!String.IsNullOrEmpty(lista[i].Fic_tem.Id.ToString())) || (lista[i].Fic_tem.Id != 0)) { this.grilla_general.Rows[reglon].Cells["TEMPORAL"].Value = lista[i].Fic_tem.Id; combo_temporal.Enabled = true; } else { this.grilla_general.Rows[reglon].Cells["TEMPORAL"].Value = ""; } this.grilla_general.Rows[reglon].Cells["FECHA_INGRE"].Value = lista[i].Fecha_ingreso.ToShortDateString(); this.grilla_general.Rows[reglon].Cells["ID_TIPO"].Value = lista[i].Tipomascota.Id; this.grilla_general.Rows[reglon].Cells["TIPO"].Value = lista[i].Tipomascota.Descripcion; this.grilla_general.Rows[reglon].Cells["TAMANO"].Value = lista[i].Tamano; this.grilla_general.Rows[reglon].Cells["ESTADO"].Value = lista[i].Estado; this.grilla_general.Rows[reglon].Cells["NOMBRE"].Value = lista[i].Nombre; this.grilla_general.Rows[reglon].Cells["RAZA"].Value = lista[i].Raza; this.grilla_general.Rows[reglon].Cells["SEXO"].Value = lista[i].Sexo; this.grilla_general.Rows[reglon].Cells["COLOR"].Value = lista[i].Color; this.grilla_general.Rows[reglon].Cells["EDAD"].Value = lista[i].Edad; this.grilla_general.Rows[reglon].Cells["ESTERILIZADO"].Value = lista[i].Esterilizado; } }