示例#1
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            try
            {
                Animal_Negocio animalNegocio = new Animal_Negocio();
                Animal         animal        = animalNegocio.RecuperarPorRP(Convert.ToInt32(this.dgvControles.CurrentRow.Cells["rp"].Value));
                int            id_tambo      = Convert.ToInt32(this.dgvControles.CurrentRow.Cells["id_tambo"].Value);

                EdicionControles edicion = new EdicionControles();
                edicion.Animal                      = animal;
                edicion.txtIdControl.Text           = Convert.ToString(this.dgvControles.CurrentRow.Cells["id_control"].Value);
                edicion.dtpFechaControl.Text        = Convert.ToString(this.dgvControles.CurrentRow.Cells["fecha_control"].Value);
                edicion.txtPrimerControl.Text       = Convert.ToString(this.dgvControles.CurrentRow.Cells["primer_control"].Value);
                edicion.txtSegundoControl.Text      = Convert.ToString(this.dgvControles.CurrentRow.Cells["segundo_control"].Value);
                edicion.txtGrasaPrimerControl.Text  = Convert.ToString(this.dgvControles.CurrentRow.Cells["grasa_primercontrol"].Value);
                edicion.txtGrasaSegundoControl.Text = Convert.ToString(this.dgvControles.CurrentRow.Cells["grasa_segundocontrol"].Value);
                //edicion.cbAnimal.Text = animal.Nombre_animal;
                edicion.txtCaravana.Text     = animal.Caravana;
                edicion.txtNombreAnimal.Text = animal.Nombre_animal;
                edicion.controlAnimalGlobal  = MapearAControlAnimal();

                edicion.Show();
                CargarGrilla(id_tambo);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ocurrió un error", MessageBoxButtons.OK);
            }
        }
示例#2
0
 private void txtBuscar_KeyUp(object sender, KeyEventArgs e)
 {
     try
     {
         Animal_Negocio animalNegocio = new Animal_Negocio();
         if (this.cbBuscar.SelectedIndex == -1)
         {
             this.txtBuscar.Enabled = false;
             //MessageBox.Show("Debe seleccionar un parámetro a buscar en el combo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else if (this.cbBuscar.SelectedItem.ToString() == "Nombre animal")
         {
             this.dgvAnimales.DataSource = animalNegocio.FiltrarPorNombre(this.txtBuscar.Text, idtambo);
         }
         else if (this.cbBuscar.SelectedItem.ToString() == "Estado")
         {
             this.dgvAnimales.DataSource = animalNegocio.FiltrarPorEstado(this.txtBuscar.Text, idtambo);
         }
         else if (this.cbBuscar.SelectedItem.ToString() == "Caravana")
         {
             this.dgvAnimales.DataSource = animalNegocio.FiltrarPorCaravana(this.txtBuscar.Text, idtambo);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ocurrió un error", MessageBoxButtons.OK);
     }
 }
示例#3
0
 public ListaSeleccionAnimal(string modo)
 {
     InitializeComponent();
     modoGlobal       = modo;
     animalnegocio    = new Animal_Negocio();
     razanegocio      = new Raza_Negocio();
     categorianegocio = new Categoria_Negocio();
     Animal           = new Animal();
     CargarGrilla(modo);
 }
        public void CargaComboAnimal(int id_tambo)
        {
            Animal_Negocio animalNegocio = new Animal_Negocio();

            //Asigno primero el displaymember y el valuemember, despues el data source, sino tira error
            this.cbAnimal.DisplayMember = "nombre_animal";
            this.cbAnimal.ValueMember   = "rp";
            this.cbAnimal.DataSource    = animalNegocio.RecuperarVacasPorTambo(id_tambo);
            this.cbAnimal.SelectedIndex = -1;
        }
示例#5
0
 public AbmAnimales()
 {
     InitializeComponent();
     Animal           = new Animal();
     animalnegocio    = new Animal_Negocio();
     categorianegocio = new Categoria_Negocio();
     CargarComboEstado();
     CargaComboCategoria();
     CargarTextBoxTambo();
     CargaComboRaza();
     CargaUltimaCaravana();
 }
示例#6
0
 private void toolStripTextBox1_KeyUp(object sender, KeyEventArgs e)
 {
     try
     {
         Animal_Negocio animalNegocio = new Animal_Negocio();
         this.dgvAnimales.DataSource = animalNegocio.FiltrarPorCaravana(this.tstxtBuscar.Text, idtambo);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ocurrió un error", MessageBoxButtons.OK);
     }
 }
示例#7
0
 public AbmEvento()
 {
     InitializeComponent();
     eventonegocio       = new Evento_Negocio();
     dessubeventonegocio = new Desc_Subevento_Negocio();
     animalnegocio       = new Animal_Negocio();
     listadoSubeventos   = new List <Desc_Subevento>();
     Evento = new Evento();
     Animal = new Animal();
     Cria   = new Animal();
     Cria2  = new Animal();
     Inicializacion();
 }
示例#8
0
 public void CargarGrilla(int idtambo)
 {
     try
     {
         Animal_Negocio animalNegocio = new Animal_Negocio();
         this.dgvAnimales.AutoGenerateColumns = false;
         this.dgvAnimales.DataSource          = animalNegocio.RecuperarPorTamboDT(idtambo);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ocurrió un error", MessageBoxButtons.OK);
     }
 }
示例#9
0
 public void ValidarAnimales()
 {
     try
     {
         Animal_Negocio animalNegocio = new Animal_Negocio();
         if (!animalNegocio.HayAnimales(Principal.Tambo.Id_tambo))
         {
             MessageBox.Show("El tambo no posee animales", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ocurrió un error", MessageBoxButtons.OK);
     }
 }
示例#10
0
        public Control_Animal MapearAControlAnimal()
        {
            Control_Animal controlAnimal = new Control_Animal();
            Animal_Negocio animalNegocio = new Animal_Negocio();
            Animal         animal        = animalNegocio.RecuperarUno(Convert.ToInt32(this.dgvControles.CurrentRow.Cells["rp"].Value));

            controlAnimal.Rp                   = Convert.ToInt32(this.dgvControles.CurrentRow.Cells["rp"].Value);
            controlAnimal.Id_control           = Convert.ToInt32(this.dgvControles.CurrentRow.Cells["id_control"].Value);
            controlAnimal.Fecha_control        = Convert.ToDateTime(this.dgvControles.CurrentRow.Cells["fecha_control"].Value);
            controlAnimal.Primer_control       = Convert.ToDecimal(this.dgvControles.CurrentRow.Cells["primer_control"].Value);
            controlAnimal.Segundo_control      = Convert.ToDecimal(this.dgvControles.CurrentRow.Cells["segundo_control"].Value);
            controlAnimal.Grasa_primercontrol  = Convert.ToDecimal(this.dgvControles.CurrentRow.Cells["grasa_primercontrol"].Value);
            controlAnimal.Grasa_segundocontrol = Convert.ToDecimal(this.dgvControles.CurrentRow.Cells["grasa_segundocontrol"].Value);
            controlAnimal.Nombre_animal        = animal.Nombre_animal;
            return(controlAnimal);
        }
示例#11
0
        private void vpListadoAnimales_Load(object sender, EventArgs e)
        {
            try
            {
                Animal_Negocio     animal_Negocio = new Animal_Negocio();
                rptListadoAnimales reporte        = new rptListadoAnimales();

                reporte.SetDataSource(animal_Negocio.RecuperarDTPorTambo(idtambo));
                crvAnimales.ReportSource = reporte;
                crvAnimales.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ocurrió un error", MessageBoxButtons.OK);
            }
        }
示例#12
0
        public Control_Animal MapearAControlAnimal()
        {
            Animal_Negocio animalNegocio = new Animal_Negocio();
            //Animal animal = animalNegocio.RecuperarUno();
            Control_Animal control = new Control_Animal();

            control.Id_control           = Convert.ToInt32(txtIdControl.Text);
            control.Fecha_control        = dtpFechaControl.Value.Date;
            control.Primer_control       = string.IsNullOrEmpty(txtPrimerControl.Text) ? 0 : Convert.ToDecimal(txtPrimerControl.Text);
            control.Segundo_control      = string.IsNullOrEmpty(txtSegundoControl.Text) ? 0 : Convert.ToDecimal(txtSegundoControl.Text);
            control.Grasa_primercontrol  = string.IsNullOrEmpty(txtPrimerControl.Text) ? 0 : Convert.ToDecimal(txtGrasaPrimerControl.Text);
            control.Grasa_segundocontrol = string.IsNullOrEmpty(txtPrimerControl.Text) ? 0 : Convert.ToDecimal(txtGrasaSegundoControl.Text);
            control.Nombre_animal        = Animal.Nombre_animal;
            control.Rp = Animal.Rp;

            return(control);
        }
示例#13
0
        private void vpListadoSanidad_Load(object sender, EventArgs e)
        {
            try
            {
                Animal_Negocio    animal_Negocio = new Animal_Negocio();
                rptListadoSanidad reporte        = new rptListadoSanidad();

                reporte.SetDataSource(animal_Negocio.RecuperarDTPorTambo(Principal.Tambo.Id_tambo));
                reporte.SetDatabaseLogon("abcd", "123456");
                crv.ReportSource = reporte;
                crv.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ocurrió un error", MessageBoxButtons.OK);
            }
        }
        private void cbAnimal_SelectedIndexChanged(object sender, EventArgs e)
        {
            Control_Animal_Negocio controlAnimalNegocio = new Control_Animal_Negocio();
            Animal_Negocio         animalNegocio        = new Animal_Negocio();
            Animal animal = new Animal();

            animal = animalNegocio.RecuperarUno(Convert.ToInt32(this.cbAnimal.SelectedValue));
            this.dgvProduccionAnimal.DataSource = controlAnimalNegocio.ProduccionPorFiltroAnimal(idtambo, animal.Rp);
            if (this.dgvProduccionAnimal.Rows.Count != 0 && this.dgvProduccionAnimal.Rows != null)
            {
                this.btnExportar.Enabled = true;
            }
            else
            {
                this.btnExportar.Enabled = false;
            }
        }
示例#15
0
        private void vpEventos_Load(object sender, EventArgs e)
        {
            try
            {
                Animal_Negocio animalNegocio = new Animal_Negocio();
                rptEventos     reporte       = new rptEventos();

                if (this.opcioncombo == "Vacas en celo")
                {
                    reporte.SetDataSource(animalNegocio.RecuperarDTVacasEnCeloPorTambo(idtambo));
                    crvEventos.ReportSource = reporte;
                    crvEventos.Refresh();
                }
                else if (this.opcioncombo == "Animales enfermos")
                {
                    reporte.SetDataSource(animalNegocio.RecuperarDTAnimalesEnfermosPorTambo(idtambo));
                    crvEventos.ReportSource = reporte;
                    crvEventos.Refresh();
                }
                else if (this.opcioncombo == "Vacas con parto en los últimos 21 días")
                {
                    reporte.SetDataSource(animalNegocio.RecuperarDTVacasConPartoPorTambo(idtambo));
                    crvEventos.ReportSource = reporte;
                    crvEventos.Refresh();
                }
                else if (this.opcioncombo == "Vacas servidas en los últimos 21 días")
                {
                    reporte.SetDataSource(animalNegocio.RecuperarDTVacasServidasPorTambo(idtambo));
                    crvEventos.ReportSource = reporte;
                    crvEventos.Refresh();
                }
                else if (this.opcioncombo == "vacio")
                {
                    reporte.SetDataSource(animalNegocio.RecuperarDTPorTambo(idtambo));
                    crvEventos.ReportSource = reporte;
                    crvEventos.Refresh();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ocurrió un error", MessageBoxButtons.OK);
            }
        }
示例#16
0
 private void reporteProduccionToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         Animal_Negocio animalNegocio = new Animal_Negocio();
         if (animalNegocio.HayVacas(Principal.Tambo.Id_tambo))
         {
             ReporteProduccion reporteEventos = new ReporteProduccion();
             reporteEventos.ShowDialog();
         }
         else
         {
             MessageBox.Show("El tambo no posee vacas", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ocurrió un error", MessageBoxButtons.OK);
     }
 }
示例#17
0
 private void reporteEventosToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     try
     {
         Animal_Negocio animalNegocio = new Animal_Negocio();
         if (animalNegocio.HayAnimales(Principal.Tambo.Id_tambo))
         {
             vpExistencia vp = new vpExistencia();
             vp.Show();
         }
         else
         {
             MessageBox.Show("El tambo no posee animales", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ocurrió un error", MessageBoxButtons.OK);
     }
 }
示例#18
0
 private void nuevoControlToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         Animal_Negocio animalNegocio = new Animal_Negocio();
         if (animalNegocio.HayVacas(Principal.Tambo.Id_tambo))
         {
             AltaControles alta = new AltaControles(id_tambo);
             alta.ShowDialog();
         }
         else
         {
             MessageBox.Show("No es posible cargar controles si no exiten animales cargados. Primero debe dar de alta un animal.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ocurrió un error", MessageBoxButtons.OK);
     }
 }
示例#19
0
 private void btnEliminar_Click(object sender, EventArgs e)
 {
     try
     {
         Animal_Negocio animalNegocio = new Animal_Negocio();
         int            id            = Convert.ToInt32(this.dgvAnimales.CurrentRow.Cells["rp"].Value);
         Animal         animal        = animalNegocio.RecuperarUno(id);
         int            id_tambo      = Convert.ToInt32(this.dgvAnimales.CurrentRow.Cells["id_tambo"].Value);
         DialogResult   result        = MessageBox.Show("ATENCIÓN!! Al eliminar el animal " + animal.Nombre_animal + ", también eliminará sus controles y eventos asociados. ¿Desea continuar?", "Verificación", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
         if (result == DialogResult.Yes)
         {
             animalNegocio.Eliminar(id);
             this.CargarGrilla(id_tambo);
             MessageBox.Show("El animal " + animal.Nombre_animal + " fue eliminado", "Eliminación", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ocurrió un error", MessageBoxButtons.OK);
     }
 }
示例#20
0
 private void animalesToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     try
     {
         Animal_Negocio animalNegocio = new Animal_Negocio();
         if (animalNegocio.HayAnimales(Principal.Tambo.Id_tambo))
         {
             ListadoAnimales listadoAnimales = new ListadoAnimales(id_tambo);
             listadoAnimales.idtambo = id_tambo;
             listadoAnimales.ShowDialog();
         }
         else
         {
             MessageBox.Show("El tambo no posee animales", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ocurrió un error", MessageBoxButtons.OK);
     }
 }
示例#21
0
 public void CargarGrilla(int id_tambo)
 {
     try
     {
         if (this.cbFiltro.SelectedIndex == -1)
         {
             Animal_Negocio animalNegocio = new Animal_Negocio();
             this.dgvEventos.DataSource = animalNegocio.RecuperarParaReportePorTambo(id_tambo);
             if (this.dgvEventos.Rows.Count != 0 && this.dgvEventos.Rows != null)
             {
                 this.btnExportar.Enabled = true;
             }
             else
             {
                 this.btnExportar.Enabled = false;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ocurrió un error", MessageBoxButtons.OK);
     }
 }
示例#22
0
        public void CargarGrilla(int id_tambo)
        {
            try
            {
                Animal_Negocio animalNegocio = new Animal_Negocio();
                this.dgvAnimales.AutoGenerateColumns = false;

                this.dgvAnimales.DataSource = animalNegocio.RecuperarPorTamboDT(id_tambo);
                if (this.dgvAnimales.Rows.Count != 0 && this.dgvAnimales.Rows != null)
                {
                    this.btnEditar.Enabled   = true;
                    this.btnEliminar.Enabled = true;
                }
                else
                {
                    this.btnEditar.Enabled   = false;
                    this.btnEliminar.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ocurrió un error", MessageBoxButtons.OK);
            }
        }
示例#23
0
        public AbmAnimales(ModoForm modo, Animal animal)
        {
            InitializeComponent();
            ModoForm         = modo;
            Animal           = new Animal();
            animalnegocio    = new Animal_Negocio();
            categorianegocio = new Categoria_Negocio();
            CargarComboEstado();
            CargaComboCategoria();
            CargarTextBoxTambo();
            CargaComboRaza();
            CargaUltimaCaravana();

            lbTituloFormulario.Text = ModoForm.ToString();

            if (ModoForm == ModoForm.MODIFICACION)
            {
                if (animal != null)
                {
                    Animal = animal;
                }
                MapearDesdeAnimal();
            }
        }
示例#24
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                Animal_Negocio an           = new Animal_Negocio();
                Validaciones   validaciones = new Validaciones();
                string         validar      = validaciones.ValidarEdicionAnimales(cbCategoria.SelectedIndex, cbRaza.SelectedIndex, txtNombre.Text, txtHBA.Text, txtCaravana.Text);

                if (validar == "true")
                {
                    if (txtRPMadre.Text.Length <= 6 || txtRPMadre.Text == string.Empty)
                    {
                        if (txtRPPadre.Text.Length <= 6 || txtRPPadre.Text == string.Empty)
                        {
                            if (txtHBAMadre.Text.Length <= 6 || txtHBAMadre.Text == string.Empty)
                            {
                                if (txtHBAPadre.Text.Length <= 6 || txtHBAPadre.Text == string.Empty)
                                {
                                    if (txtCaravana.Text.Length <= 5)
                                    {
                                        Animal_Negocio animalNegocio = new Animal_Negocio();
                                        Animal         animal        = new Animal();
                                        animal = MapearAAnimal();
                                        animalNegocio.Actualizar(animal);
                                        DialogResult result = MessageBox.Show("El animal fue actualizado exitosamente", "Edición", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        this.Dispose();
                                    }
                                    else
                                    {
                                        MessageBox.Show("El campo Caravana no puede ser mayor a 5 (seis) dígitos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("El campo HBA Padre no puede ser mayor a 6 (seis) dígitos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                MessageBox.Show("El campo HBA Madre no puede ser mayor a 6 (seis) dígitos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            MessageBox.Show("El campo RP Padre no puede ser mayor a 6 (seis) dígitos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("El campo RP Madre no puede ser mayor a 6 (seis) dígitos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show(validar, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ocurrió un error", MessageBoxButtons.OK);
            }
        }
示例#25
0
        private void cbFiltro_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                Animal_Negocio animalNegocio = new Animal_Negocio();
                Tambo_Negocio  tamboNegocio  = new Tambo_Negocio();
                Tambo          tambo         = new Tambo();

                tambo = tamboNegocio.RecuperarPorNombre(this.txtTambo.Text);
                if (this.cbFiltro.SelectedIndex == -1)
                {
                    this.dgvEventos.DataSource = animalNegocio.RecuperarPorTambo(Principal.Tambo.Id_tambo);
                    if (this.dgvEventos.Rows.Count != 0 && this.dgvEventos.Rows != null)
                    {
                        this.btnExportar.Enabled = true;
                    }
                    else
                    {
                        this.btnExportar.Enabled = false;
                    }
                }
                else if (this.cbFiltro.SelectedItem.ToString() == "Vacas en celo")
                {
                    this.dgvEventos.DataSource = animalNegocio.RecuperarVacasEnCeloPorTambo(tambo.Id_tambo);
                    if (this.dgvEventos.Rows.Count != 0 && this.dgvEventos.Rows != null)
                    {
                        this.btnExportar.Enabled = true;
                    }
                    else
                    {
                        this.btnExportar.Enabled = false;
                    }
                }
                else if (this.cbFiltro.SelectedItem.ToString() == "Animales enfermos")
                {
                    this.dgvEventos.DataSource = animalNegocio.RecuperarAnimalesEnfermosPorTambo(tambo.Id_tambo);
                    if (this.dgvEventos.Rows.Count != 0 && this.dgvEventos.Rows != null)
                    {
                        this.btnExportar.Enabled = true;
                    }
                    else
                    {
                        this.btnExportar.Enabled = false;
                    }
                }
                else if (this.cbFiltro.SelectedItem.ToString() == "Vacas con parto en los últimos 21 días")
                {
                    this.dgvEventos.DataSource = animalNegocio.RecuperarVacasConPartoPorTambo(tambo.Id_tambo);
                    if (this.dgvEventos.Rows.Count != 0 && this.dgvEventos.Rows != null)
                    {
                        this.btnExportar.Enabled = true;
                    }
                    else
                    {
                        this.btnExportar.Enabled = false;
                    }
                }
                else if (this.cbFiltro.SelectedItem.ToString() == "Vacas servidas en los últimos 21 días")
                {
                    this.dgvEventos.DataSource = animalNegocio.RecuperarVacasServidasPorTambo(tambo.Id_tambo);
                    if (this.dgvEventos.Rows.Count != 0 && this.dgvEventos.Rows != null)
                    {
                        this.btnExportar.Enabled = true;
                    }
                    else
                    {
                        this.btnExportar.Enabled = false;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ocurrió un error", MessageBoxButtons.OK);
            }
        }