Ejemplo n.º 1
0
        public bool registrarBienOServicio(BienOServicio bienOServicio)
        {
            Conexion con = new Conexion();

            con.agregarBienOServicio("BienOServicio", bienOServicio);
            return(true);
        }
Ejemplo n.º 2
0
        public VerProducto(string user, int idProducto, int tipoUsuario)
        {
            InitializeComponent();

            b = new BienOServicio();
            Conexion cn = new Conexion();

            b = cn.verProducto(idProducto);

            lbnombre.Text       = b.Nombre;
            txbdescripcion.Text = b.Descripcion;
            lbvendendor.Text    = cn.nombre(b.User.IDusuario);

            if (b.Cantidad == -1)
            {
                label2.Text   = "En Servicio";
                lbstock.Text  = "";
                ncant.Enabled = false;
            }
            else
            {
                label2.Text    = "Stock: ";
                lbstock.Text   = b.Cantidad.ToString();
                globalCantidad = b.Cantidad;
                ncant.Enabled  = true;
            }

            if (tipoUsuario == 0)
            {
                btncontactar.Visible = false;
                btncarrito.Text      = "Comprar ahora";
            }

            lbcategoria.Text = b.Cat.Nombre;

            iduser = user;

            System.IO.MemoryStream ms = new System.IO.MemoryStream(b.Imagen);
            pbimagen.Image = Image.FromStream(ms);

            this.ActiveControl = btncarrito;
        }
Ejemplo n.º 3
0
        private void btnGUARDAR_Click(object sender, EventArgs e)
        {
            if (rbtnBIEN.Checked == true)
            {
                if (txtnombre.Text != "" && cmbcategoria.SelectedIndex != -1 &&
                    txtprecio.Text != "" && txtcantidad.Text != "" && txtdescripcion.Text != "")
                {
                    if (pictureBox1.Image != null)
                    {
                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
                        pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);


                        BienOServicio b = new BienOServicio();

                        b.Nombre      = txtnombre.Text;
                        b.Descripcion = txtdescripcion.Text;
                        b.Precio      = float.Parse(txtprecio.Text);

                        if (txtcantidad.Text.Trim() != "")
                        {
                            b.Cantidad = int.Parse(txtcantidad.Text);
                        }
                        else
                        {
                            if (rbtnSERVICIO.Checked)
                            {
                                b.Cantidad = -1;
                            }
                            else
                            {
                                MessageBox.Show("Debe ingresar una cantidad", "Aviso",
                                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            }
                        }

                        b.Imagen          = ms.GetBuffer();
                        b.User            = new Usuario();
                        b.User.IDusuario  = idUsuario;
                        b.Cat             = new Categoria();
                        b.Cat.Idcategoria = Convert.ToInt32(cmbcategoria.SelectedValue.ToString());

                        b.registrarBienOServicio(b);

                        MessageBox.Show("Producto registrado y publicado exitosamente", "E-Market", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        Conexion cn = new Conexion();

                        dtvpublicaciones.DataSource         = null;
                        dtvpublicaciones.DataSource         = cn.VerMisProductos(idUsuario).Tables["productos"];
                        dtvpublicaciones.Columns[0].Visible = false;
                        dtvpublicaciones.Columns[5].Visible = false;

                        dtvpublicaciones.ClearSelection();

                        limpiar();
                    }
                    else
                    {
                        MessageBox.Show("Debe asignar una imagen al producto", "Aviso",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Debe rellenar todos los campos", "Aviso",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else if (rbtnSERVICIO.Checked == true)
            {
                if (txtnombre.Text != "" && cmbcategoria.SelectedIndex != -1 &&
                    txtprecio.Text != "" && txtdescripcion.Text != "")
                {
                    if (pictureBox1.Image != null)
                    {
                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
                        pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);


                        BienOServicio b = new BienOServicio();

                        b.Nombre      = txtnombre.Text;
                        b.Descripcion = txtdescripcion.Text;
                        b.Precio      = float.Parse(txtprecio.Text);

                        if (txtcantidad.Text.Trim() != "")
                        {
                            b.Cantidad = int.Parse(txtcantidad.Text);
                        }
                        else
                        {
                            if (rbtnSERVICIO.Checked)
                            {
                                b.Cantidad = -1;
                            }
                            else
                            {
                                MessageBox.Show("Debe ingresar una cantidad", "Aviso",
                                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            }
                        }

                        b.Imagen          = ms.GetBuffer();
                        b.User            = new Usuario();
                        b.User.IDusuario  = idUsuario;
                        b.Cat             = new Categoria();
                        b.Cat.Idcategoria = Convert.ToInt32(cmbcategoria.SelectedValue.ToString());

                        b.registrarBienOServicio(b);

                        MessageBox.Show("Producto registrado y publicado exitosamente", "E-Market", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        Conexion cn = new Conexion();

                        dtvpublicaciones.DataSource         = null;
                        dtvpublicaciones.DataSource         = cn.VerMisProductos(idUsuario).Tables["productos"];
                        dtvpublicaciones.Columns[0].Visible = false;
                        dtvpublicaciones.Columns[5].Visible = false;

                        dtvpublicaciones.ClearSelection();

                        limpiar();
                    }
                    else
                    {
                        MessageBox.Show("Debe asignar una imagen al producto", "Aviso",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Debe rellenar todos los campos", "Aviso",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("Elija un tipo de publicación", "Aviso",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }