Exemple #1
0
        public MascotaEN getDataGridViewState(DataGridViewCellEventArgs ev, ref Utils.State st, ref ClienteEN aux_cliente)
        {
            string    IdMascota = "", idCliente = "";
            MascotaEN mascota = null;

            if (form.dataGridView.Columns[ev.ColumnIndex].Name.Equals("Ver"))
            {
                st        = Utils.State.MODIFY;
                IdMascota = form.dataGridView.Rows[ev.RowIndex].Cells[0].Value.ToString();
                if (lista_mascotas != null && lista_mascotas.Count > 0 && IdMascota != "")
                {
                    for (int i = 0; i < lista_mascotas.Count; i++)
                    {
                        if (lista_mascotas[i].IdMascota == Convert.ToInt32(IdMascota))
                        {
                            mascota = lista_mascotas[i];
                            break;
                        }
                    }
                }
            }

            idCliente = form.dataGridView.Rows[ev.RowIndex].Cells[4].Value.ToString();
            if (idCliente != "")
            {
                aux_cliente = Utils._IClienteCAD.DameClientePorOID(idCliente);
            }


            return(mascota);
        }
Exemple #2
0
        public MascotaEN BuscarMascotaPorOID(int IdMascota)
        {
            MascotaEN mascotaEN = null;

            mascotaEN = _IMascotaCAD.BuscarMascotaPorOID(IdMascota);
            return(mascotaEN);
        }
Exemple #3
0
        public int New_(MascotaEN mascota)
        {
            try
            {
                SessionInitializeTransaction();
                if (mascota.Cliente != null)
                {
                    mascota.Cliente = (GestionVeterinariaGenNHibernate.EN.GestionVeterinaria.ClienteEN)session.Load(typeof(GestionVeterinariaGenNHibernate.EN.GestionVeterinaria.ClienteEN), mascota.Cliente.DNI);

                    mascota.Cliente.Mascota.Add(mascota);
                }

                session.Save(mascota);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is GestionVeterinariaGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new GestionVeterinariaGenNHibernate.Exceptions.DataLayerException("Error in MascotaCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(mascota.IdMascota);
        }
Exemple #4
0
        public MascotaEN ReadOIDDefault(int IdMascota)
        {
            MascotaEN mascotaEN = null;

            try
            {
                SessionInitializeTransaction();
                mascotaEN = (MascotaEN)session.Get(typeof(MascotaEN), IdMascota);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is GestionVeterinariaGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new GestionVeterinariaGenNHibernate.Exceptions.DataLayerException("Error in MascotaCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(mascotaEN);
        }
Exemple #5
0
        public void Destroy(int IdMascota)
        {
            try
            {
                SessionInitializeTransaction();
                MascotaEN mascotaEN = (MascotaEN)session.Load(typeof(MascotaEN), IdMascota);
                session.Delete(mascotaEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is GestionVeterinariaGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new GestionVeterinariaGenNHibernate.Exceptions.DataLayerException("Error in MascotaCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Exemple #6
0
        public void Modify(MascotaEN mascota)
        {
            try
            {
                SessionInitializeTransaction();
                MascotaEN mascotaEN = (MascotaEN)session.Load(typeof(MascotaEN), mascota.IdMascota);

                mascotaEN.Nombre = mascota.Nombre;


                mascotaEN.Raza = mascota.Raza;


                mascotaEN.Sexo = mascota.Sexo;


                mascotaEN.Peso = mascota.Peso;


                mascotaEN.Especie = mascota.Especie;


                mascotaEN.FNacimiento = mascota.FNacimiento;


                mascotaEN.Tamanyo = mascota.Tamanyo;


                mascotaEN.Color = mascota.Color;


                mascotaEN.Microchip = mascota.Microchip;

                session.Update(mascotaEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is GestionVeterinariaGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new GestionVeterinariaGenNHibernate.Exceptions.DataLayerException("Error in MascotaCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Exemple #7
0
        override public bool LaunchConsultaScreenVeterinario(MascotaEN mascota, ConsultaEN consulta)
        {
            bool ret = false;

            if (FormActual != f_consulta.ID)
            {
                ret        = true;
                FormActual = f_consulta.ID;
                f_consulta.Show();
                f_consulta.changeState(mascota, consulta);
            }
            return(ret);
        }
        public void cargarDatosMascota(MascotaEN msc)
        {
            mascotaEN = msc;

            if (mascotaEN != null)
            {
                form.combo_nombreAnimal.SelectedItem = mascotaEN.Nombre;
                form.text_especie.Text            = mascotaEN.Especie;
                form.text_raza.Text               = mascotaEN.Raza;
                form.combo_tamanyo.SelectedItem   = mascotaEN.Tamanyo;
                form.text_peso.Text               = mascotaEN.Peso.ToString();
                form.dateTime_fnac.Value          = mascotaEN.FNacimiento.Value;
                form.combo_sexo.SelectedItem      = mascotaEN.Sexo;
                form.text_color.Text              = mascotaEN.Color;
                form.combo_microchip.SelectedItem = mascotaEN.Microchip;

                if (mascotaEN.Microchip == true)
                {
                    form.combo_microchip.Enabled = false;
                }
                else
                {
                    form.combo_microchip.Enabled = true;
                }

                //Cargamos la imagen
                try
                {
                    System.IO.FileStream fs = new System.IO.FileStream(Environment.CurrentDirectory + @"\" + mascotaEN.IdMascota + ".png", System.IO.FileMode.Open);
                    form.log_photo.Image    = Image.FromStream(fs);
                    form.log_photo.SizeMode = PictureBoxSizeMode.StretchImage;
                    fs.Close();
                }
                catch (Exception ex)
                {
                    System.IO.FileStream fs = new System.IO.FileStream(Environment.CurrentDirectory + @"\sinFotoa.png", System.IO.FileMode.Open);
                    form.log_photo.Image = Image.FromStream(fs);
                    fs.Close();
                }

                cargarConsultasAnimal();
            }
            else
            {
                ClearForm();
                form.combo_microchip.Enabled = true;
                form.text_cliente.Text       = clienteEN.DNI;
            }
        }
Exemple #9
0
        private void dataGrid_consultas_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow   fila = dataGrid_consultas.Rows[e.RowIndex];
            String            s    = Convert.ToString(fila.Cells["Nombre"].Value);
            String            num  = Convert.ToString(fila.Cells["Numero"].Value);
            IList <MascotaEN> m    = Utils._MascotaCEN.DameMascotaPorNombre(s);

            mascota = m[0];

            ConsultaEN c = Utils._ConsultaCEN.DameConsultaPorOID(Convert.ToInt32(num));

            if (menu.LaunchConsultaScreenVeterinario(mascota, c))
            {
                DesactivateForm();
            }
        }
Exemple #10
0
        public void cargarDatosMascota(MascotaEN mascota)
        {
            if (mascota != null)
            {
                if (consultaEN != null)
                {
                    consultaEN = null;
                }

                if (consultaEN == null)
                {
                    consultaEN = new ConsultaEN();
                }

                consultaEN.Mascota = mascota;
                form.box_combo_mascotas.SelectedItem = consultaEN.Mascota.Nombre;
            }
        }
        public void cargarConsultasAnimal()
        {
            if (consultas_animal != null)
            {
                consultas_animal.Clear();
            }

            if (mascotaEN == null)
            {
                String nameMsc = form.combo_nombreAnimal.SelectedItem.ToString();

                for (int i = 0; i < list_mascotas_clientes.Count; i++)
                {
                    if (list_mascotas_clientes[i].Nombre == nameMsc)
                    {
                        mascotaEN = list_mascotas_clientes[i];
                        break;
                    }
                }
            }

            consultas_animal             = Utils._IConsultaCAD.DameConsultaPorAnimal(mascotaEN.IdMascota);
            form.dataGridView.DataSource = null;
            form.dataGridView.Refresh();
            if (form.dataGridView.Rows.Count > 0)
            {
                form.dataGridView.Rows.Clear();
            }

            if (consultas_animal != null && consultas_animal.Count > 0)
            {
                for (int i = 0; i < consultas_animal.Count; i++)
                {
                    consultas_animal[i].Veterinario = Utils._IVeterinarioCAD.DameVetarinarioPorOID(consultas_animal[i].Veterinario.DNI);

                    if (consultas_animal[i].Veterinario != null)
                    {
                        string vet = consultas_animal[i].Veterinario.Nombre + " " + consultas_animal[i].Veterinario.Apellidos;
                        form.dataGridView.Rows.Add(consultas_animal[i].IdConsulta, consultas_animal[i].Fecha.Value.ToString(), consultas_animal[i].MotivoConsulta, consultas_animal[i].Lugar, vet);
                    }
                }
            }
        }
        public void changeState(Utils.State st, MascotaEN msc)
        {
            state = st;

            if (state == Utils.State.NEW)
            {
                btn_add_NombreMascota_Click(new object(), new EventArgs());
            }

            if (msc != null)
            {
                controller.cargarDatosMascota(msc);
            }

            if (state == Utils.State.DESTROY)
            {
                btn_eliminar_Click(new object(), new EventArgs());
            }
        }
Exemple #13
0
        private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            Utils.State aux_state   = Utils.State.NONE;
            ClienteEN   aux_cliente = null;
            MascotaEN   msc         = controller.getDataGridViewState(e, ref aux_state, ref aux_cliente);

            if (aux_cliente != null)
            {
                menu.CargarClienteCompartido(aux_cliente);
            }

            if (msc != null)
            {
                if (menu.LaunchMascotaScreen(aux_state, msc))
                {
                    DesactivateForm();
                }
            }
        }
Exemple #14
0
        override public bool LaunchMascotaScreen(Utils.State st, MascotaEN mascota)
        {
            bool ret = false;

            if (FormActual != f_mascota.ID)
            {
                ret        = true;
                FormActual = f_mascota.ID;

                if (mascota == null && f_mascota.state == Utils.State.NONE)
                {
                    st = Utils.State.NONE;
                }

                f_mascota.changeState(st, mascota);
                f_mascota.Show();
            }
            return(ret);
        }
        public void cargarDatosMascotaConsulta(MascotaEN mascota, ConsultaEN consulta)
        {
            if (mascota != null && consulta != null)
            {
                form.listBox_addTratamiento.Items.Clear();
                this.consulta             = consulta;
                consulta.Tratamiento      = Utils._ITratamientoCAD.DameTratamientosPorConsulta(consulta.IdConsulta);
                form.label_doc.Text       = "Consulta realizada por " + form.menu.sessionData.name;
                form.textBox_mascota.Text = mascota.Nombre;
                form.textBox_color.Text   = mascota.Color;
                form.textBox_especie.Text = mascota.Especie;
                form.textBox_fn.Text      = mascota.FNacimiento.Value.Day.ToString() + "/" + mascota.FNacimiento.Value.Month.ToString() + "/" + mascota.FNacimiento.Value.Year.ToString();
                form.textBox_sexo.Text    = mascota.Sexo.ToString();
                form.textBox_peso.Text    = mascota.Peso.ToString();
                form.textBox_tam.Text     = mascota.Tamanyo.ToString();
                form.textBox_raza.Text    = mascota.Raza;
                form.textBox_cliente.Text = "" + mascota.Cliente.DNI.ToString();
                form.text_hora.Text       = DateTime.Now.Hour + ":" + DateTime.Now.Minute.ToString();
                form.text_fecha.Text      = form.textBox_fn.Text = DateTime.Now.Day.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Year.ToString();

                form.text_lugar.Text  = consulta.Lugar;
                form.text_motivo.Text = consulta.MotivoConsulta;

                form.text_diagnostico.Text = consulta.Diagnostico;

                if (mascota.Microchip)
                {
                    form.textBox_chip.Text = "Sí";
                }
                else
                {
                    form.textBox_chip.Text = "No";
                }

                //añadimos al listbox los tratamientos que ya tenga asociado.
                IList <TratamientoEN> tratamientos = Utils._ITratamientoCAD.DameTratamientosPorConsulta(consulta.IdConsulta);
                for (int x = 0; x < tratamientos.Count; x++)
                {
                    form.listBox_addTratamiento.Items.Add(tratamientos[x].Nombre);
                }
            }
        }
Exemple #16
0
        public void Modify(int p_Mascota_OID, string p_nombre, string p_raza, GestionVeterinariaGenNHibernate.Enumerated.GestionVeterinaria.SexoEnum p_sexo, float p_peso, string p_especie, Nullable <DateTime> p_fNacimiento, GestionVeterinariaGenNHibernate.Enumerated.GestionVeterinaria.TamanyoMascotaEnum p_tamanyo, string p_color, bool p_microchip)
        {
            MascotaEN mascotaEN = null;

            //Initialized MascotaEN
            mascotaEN             = new MascotaEN();
            mascotaEN.IdMascota   = p_Mascota_OID;
            mascotaEN.Nombre      = p_nombre;
            mascotaEN.Raza        = p_raza;
            mascotaEN.Sexo        = p_sexo;
            mascotaEN.Peso        = p_peso;
            mascotaEN.Especie     = p_especie;
            mascotaEN.FNacimiento = p_fNacimiento;
            mascotaEN.Tamanyo     = p_tamanyo;
            mascotaEN.Color       = p_color;
            mascotaEN.Microchip   = p_microchip;
            //Call to MascotaCAD

            _IMascotaCAD.Modify(mascotaEN);
        }
Exemple #17
0
        public int New_(string p_nombre, string p_raza, GestionVeterinariaGenNHibernate.Enumerated.GestionVeterinaria.SexoEnum p_sexo, float p_peso, string p_especie, Nullable <DateTime> p_fNacimiento, GestionVeterinariaGenNHibernate.Enumerated.GestionVeterinaria.TamanyoMascotaEnum p_tamanyo, string p_cliente, string p_color, bool p_microchip)
        {
            MascotaEN mascotaEN = null;
            int       oid;

            //Initialized MascotaEN
            mascotaEN        = new MascotaEN();
            mascotaEN.Nombre = p_nombre;

            mascotaEN.Raza = p_raza;

            mascotaEN.Sexo = p_sexo;

            mascotaEN.Peso = p_peso;

            mascotaEN.Especie = p_especie;

            mascotaEN.FNacimiento = p_fNacimiento;

            mascotaEN.Tamanyo = p_tamanyo;


            if (p_cliente != null)
            {
                mascotaEN.Cliente     = new GestionVeterinariaGenNHibernate.EN.GestionVeterinaria.ClienteEN();
                mascotaEN.Cliente.DNI = p_cliente;
            }

            mascotaEN.Color = p_color;

            mascotaEN.Microchip = p_microchip;

            //Call to MascotaCAD

            oid = _IMascotaCAD.New_(mascotaEN);
            return(oid);
        }
Exemple #18
0
 public abstract bool LaunchMascotaScreen(Utils.State s, MascotaEN m);
        public void ProcesarInformacion()
        {
            ocultarErroresProcesarInformacion();
            Boolean fail = false;

            if (mascotaEN == null)
            {
                mascotaEN  = new MascotaEN();
                form.state = Utils.State.NEW;
            }
            else
            {
                mascotaEN.Cliente = clienteEN;
            }

            if (form.combo_nombreAnimal.Text != "")
            {
                mascotaEN.Nombre = form.combo_nombreAnimal.Text;
            }
            else
            {
                fail = true;
                form.error_nombre.Visible = true;
            }

            if (form.text_raza.Text != "")         //raza
            {
                mascotaEN.Raza = form.text_raza.Text;
            }
            else
            {
                fail = true;
                form.error_raza.Visible = true;
            }

            if (form.text_especie.Text != "")          //especie
            {
                mascotaEN.Especie = form.text_especie.Text;
            }
            else
            {
                fail = true;
                form.error_especie.Visible = true;
            }

            if (form.dateTime_fnac.Value != null)          //fecha_nac
            {
                mascotaEN.FNacimiento = form.dateTime_fnac.Value;
            }
            else
            {
                fail = true;
                form.error_fechanac.Visible = true;
            }

            if (form.combo_sexo.SelectedItem != null)         //sexo
            {
                if (form.combo_sexo.SelectedItem.ToString() == "Macho")
                {
                    mascotaEN.Sexo = SexoEnum.Macho;
                }
                else
                {
                    mascotaEN.Sexo = SexoEnum.Hembra;
                }
            }
            else
            {
                fail = true;
                form.error_sexo.Visible = true;
            }

            if (form.combo_tamanyo.SelectedItem != null)
            {
                if (form.combo_tamanyo.SelectedItem.ToString() == "L")
                {
                    mascotaEN.Tamanyo = TamanyoMascotaEnum.L;
                }
                else if (form.combo_tamanyo.SelectedItem.ToString() == "M")
                {
                    mascotaEN.Tamanyo = TamanyoMascotaEnum.M;
                }
                else if (form.combo_tamanyo.SelectedItem.ToString() == "S")
                {
                    mascotaEN.Tamanyo = TamanyoMascotaEnum.S;
                }
                else if (form.combo_tamanyo.SelectedItem.ToString() == "XS")
                {
                    mascotaEN.Tamanyo = TamanyoMascotaEnum.XS;
                }
                else
                {
                    mascotaEN.Tamanyo = TamanyoMascotaEnum.XL;
                }
            }
            else
            {
                fail = true;
                form.error_tamanyo.Visible = true;
            }

            //Adquiere el peso
            int i = 0;

            if (form.text_peso.Text != "" && int.TryParse(form.text_peso.Text.ToString(), out i))
            {
                mascotaEN.Peso = Convert.ToInt32(form.text_peso.Text);
            }
            else
            {
                fail = true;
                form.error_peso.Visible = true;
            }

            //Adquiere el color
            if (form.text_color.Text != "")
            {
                mascotaEN.Color = form.text_color.Text;
            }


            //Adquiere si tiene microchip o no
            if (form.combo_microchip.SelectedItem != null)
            {
                mascotaEN.Microchip = Convert.ToBoolean(form.combo_microchip.SelectedItem);
            }



            if (!fail)
            {
                switch (form.state)
                {
                case Utils.State.NEW:
                    mascotaEN.Cliente   = clienteEN;
                    mascotaEN.IdMascota = Utils._MascotaCEN.New_(mascotaEN.Nombre, mascotaEN.Raza, mascotaEN.Sexo, mascotaEN.Peso, mascotaEN.Especie, mascotaEN.FNacimiento, mascotaEN.Tamanyo, mascotaEN.Cliente.DNI, mascotaEN.Color, mascotaEN.Microchip);
                    MessageBox.Show("Mascota creada con exito");
                    if (form.log_photo.Image != null)
                    {
                        list_mascotas_clientes.Add(mascotaEN);
                    }
                    form.log_photo.Image.Save(Environment.CurrentDirectory + @"\" + mascotaEN.IdMascota + ".png");
                    break;

                case Utils.State.MODIFY:
                    list_mascotas_clientes.Remove(mascotaEN);
                    Utils._MascotaCEN.Modify(mascotaEN.IdMascota, mascotaEN.Nombre, mascotaEN.Raza, mascotaEN.Sexo, mascotaEN.Peso, mascotaEN.Especie, mascotaEN.FNacimiento, mascotaEN.Tamanyo, mascotaEN.Color, mascotaEN.Microchip);
                    MessageBox.Show("Mascota modiificada con exito");
                    if (form.log_photo.Image != null)
                    {
                        list_mascotas_clientes.Add(mascotaEN);
                    }
                    form.log_photo.Image.Save(Environment.CurrentDirectory + @"\" + mascotaEN.IdMascota + ".png");
                    break;

                case Utils.State.DESTROY:
                    Utils._MascotaCEN.Destroy(mascotaEN.IdMascota);
                    MessageBox.Show("Mascota eliminado con exito");
                    list_mascotas_clientes.Remove(mascotaEN);
                    if (form.log_photo.Image != null)
                    {
                        form.log_photo.Image.Save(Environment.CurrentDirectory + @"\" + mascotaEN.IdMascota + ".png");
                    }
                    break;
                }

                form.combo_nombreAnimal.Refresh();
                ClearForm();
            }
            else
            {
                MessageBox.Show("Revisa los campos");
            }
        }
Exemple #20
0
 override public bool LaunchMascotaScreen(Utils.State s, MascotaEN m)
 {
     throw new NotImplementedException();
 }
 public void changeState(MascotaEN mascota, ConsultaEN consulta)
 {
     controller.cargarDatosMascotaConsulta(mascota, consulta);
 }
Exemple #22
0
 override public bool LaunchConsultaScreenVeterinario(MascotaEN mascota, ConsultaEN consulta)
 {
     throw new NotImplementedException();
 }
Exemple #23
0
 public abstract bool LaunchConsultaScreenVeterinario(MascotaEN m, ConsultaEN c);