Ejemplo n.º 1
0
        private void btnRegistrar_Click(object sender, EventArgs e)
        {
            Unidad uni = new Unidad();

            Int32 num = Convert.ToInt32(txtCodigo.Text);

            double metros = Convert.ToDouble(txtMetro.Text);

            uni.cod_propiedad = num;
            uni.m2            = metros;
            uni.estado        = "habilitado";
            uni.descripcion   = txtDescripcion.Text;

            UnidadLogic unLog = new UnidadLogic();

            unLog.AltaUnidad(uni);



            Foto fotoUno    = new Foto();
            Foto fotoDos    = new Foto();
            Foto fotoTres   = new Foto();
            Foto fotoCuatro = new Foto();


            Foto [] fotos = new Foto[4];


            UltimoNumeroLogic ulNum = new UltimoNumeroLogic();



            if (foto1.Image != null)
            {
                fotoUno.cod_unidad = uni.cod_unidad;


                int nu = ulNum.BuscaUltimoNumero();

                string numer = ulNum.BuscaUltimoNumero().ToString();

                ulNum.IncrementaUltimoNumero(nu);

                string dir = "C:\\Fotos_inmobiliaria\\" + numer;

                foto1.Image.Save(dir, System.Drawing.Imaging.ImageFormat.Jpeg);

                fotoUno.ruta_foto = dir;
            }


            if (foto2.Image != null)
            {
                fotoDos.cod_unidad = uni.cod_unidad;


                int nu = ulNum.BuscaUltimoNumero();

                string numer = ulNum.BuscaUltimoNumero().ToString();

                ulNum.IncrementaUltimoNumero(nu);

                string dir = "C:\\Fotos_inmobiliaria\\" + numer;

                foto2.Image.Save(dir, System.Drawing.Imaging.ImageFormat.Jpeg);

                fotoDos.ruta_foto = dir;
            }

            if (foto3.Image != null)
            {
                fotoTres.cod_unidad = uni.cod_unidad;

                int nu = ulNum.BuscaUltimoNumero();

                string numer = ulNum.BuscaUltimoNumero().ToString();

                ulNum.IncrementaUltimoNumero(nu);

                string dir = "C:\\Fotos_inmobiliaria\\" + numer;

                foto3.Image.Save(dir, System.Drawing.Imaging.ImageFormat.Jpeg);

                fotoTres.ruta_foto = dir;
            }



            if (foto4.Image != null)
            {
                fotoCuatro.cod_unidad = uni.cod_unidad;

                int nu = ulNum.BuscaUltimoNumero();

                string numer = ulNum.BuscaUltimoNumero().ToString();

                ulNum.IncrementaUltimoNumero(nu);

                string dir = "C:\\Fotos_inmobiliaria\\" + numer;

                foto4.Image.Save(dir, System.Drawing.Imaging.ImageFormat.Jpeg);

                fotoCuatro.ruta_foto = dir;
            }


            FotoLogic foLog = new FotoLogic();

            fotos[0] = fotoUno;
            fotos[1] = fotoDos;
            fotos[2] = fotoTres;
            fotos[3] = fotoCuatro;



            foLog.AltaFotos(fotos);

            MessageBox.Show("La unidad fue dada de alta con exito", "Alta Unidad");

            if (MessageBox.Show("¿Desea agregar otra unidad?. Confirme", "Otra unidad", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                txtCodigo.Clear();
                txtDescripcion.Clear();
                txtMetro.Clear();
                foto1.InitialImage   = null;
                foto2.InitialImage   = null;
                foto3.InitialImage   = null;
                foto4.InitialImage   = null;
                groupBox2.Enabled    = false;
                groupBox3.Enabled    = false;
                btnRegistrar.Enabled = false;
            }
            else
            {
                this.Dispose();
            }
        }
Ejemplo n.º 2
0
        private void btnModificarUni_Click(object sender, EventArgs e)
        {
            Int32 cantidadFilasSeleccionadas = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected);

            if (cantidadFilasSeleccionadas > 0)
            {
                groupDatosUni.Enabled = true;

                DataGridViewRow fila = dataGridView2.CurrentRow; //devuelve la fila que esta siendo seleccionada

                string codUni = fila.Cells[0].Value.ToString();

                UnidadLogic unLog = new UnidadLogic();

                Unidad uni = unLog.BuscaUnidad(codUni);



                txtCodigo.Text = uni.cod_unidad.ToString();

                txtDescripcion.Text = uni.descripcion;
                txtMetro.Text       = uni.m2.ToString();


                FotoLogic foLog = new FotoLogic();
                fotos = foLog.BuscaFoto(uni.cod_unidad.ToString());

                if (fotos.Count() == 1)
                {
                    foto1.Load(fotos[0].ruta_foto);
                    foto1.SizeMode = PictureBoxSizeMode.StretchImage;
                }
                if (fotos.Count() == 2)
                {
                    foto1.Load(fotos[0].ruta_foto);
                    foto2.Load(fotos[1].ruta_foto);
                    foto1.SizeMode = PictureBoxSizeMode.StretchImage;
                    foto2.SizeMode = PictureBoxSizeMode.StretchImage;
                }
                if (fotos.Count() == 3)
                {
                    foto1.Load(fotos[0].ruta_foto);
                    foto2.Load(fotos[1].ruta_foto);
                    foto3.Load(fotos[2].ruta_foto);
                    foto1.SizeMode = PictureBoxSizeMode.StretchImage;
                    foto2.SizeMode = PictureBoxSizeMode.StretchImage;
                    foto3.SizeMode = PictureBoxSizeMode.StretchImage;
                }

                if (fotos.Count() == 4)
                {
                    foto1.Load(fotos[0].ruta_foto);
                    foto2.Load(fotos[1].ruta_foto);
                    foto3.Load(fotos[2].ruta_foto);
                    foto4.Load(fotos[3].ruta_foto);

                    foto1.SizeMode = PictureBoxSizeMode.StretchImage;
                    foto2.SizeMode = PictureBoxSizeMode.StretchImage;
                    foto3.SizeMode = PictureBoxSizeMode.StretchImage;
                    foto4.SizeMode = PictureBoxSizeMode.StretchImage;
                }
            }
        }