Beispiel #1
0
        private void FrmProducto_Load(object sender, EventArgs e)
        {
            try
            {
                DataSet ds = FProductos.GetAll();
                dt = ds.Tables[0];
                dgvProductos.DataSource = dt;


                if (dt.Rows.Count > 0)
                {
                    dgvProductos.Columns["Imagen"].Visible = false;
                    lblNoSeEncontraronDatos.Visible        = false;
                    dgvProductos_CellClick(null, null);
                }
                else
                {
                    lblNoSeEncontraronDatos.Visible = true;
                }

                MostrarGuardarCancelar(false);
            }


            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Beispiel #2
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("Realmente desea eliminar los Productos seleccionados?",
                                    "Eliminacion de Productos", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    foreach (DataGridViewRow row in dgvProductos.Rows)
                    {
                        if (Convert.ToBoolean(row.Cells["Eliminar"].Value))
                        {
                            Producto producto = new Producto();
                            producto.Id = Convert.ToInt32(row.Cells["Id"].Value);
                            if (FProductos.Eliminar(producto) != 1)
                            {
                                MessageBox.Show("El PRoducto no pudo ser eliminado",
                                                "Eliminacion de Producto", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                    }

                    FrmProducto_Load(null, null);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            FProductos f = new FProductos();

            f.StartPosition = FormStartPosition.CenterParent;
            f.Text          = "Administración de productos";
            f.ShowDialog();

            if (radioButtonTodos.Checked)
            {
                cargarDetalle(0);
            }
            if (radioButtonPropio.Checked)
            {
                cargarDetalle(1);
            }
            if (radioButtonConsignacion.Checked)
            {
                cargarDetalle(2);
            }
        }
Beispiel #4
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string sResultado = ValidarDatos();

                if (sResultado == "")
                {
                    if (txtId.Text == "")
                    {
                        Producto producto = new Producto();
                        producto.Categoria.Id     = Convert.ToInt32(txtCategoriaId.Text);
                        producto.Nombre           = txtNombre.Text;
                        producto.Descripcion      = txtDescripcion.Text;
                        producto.Stock            = Convert.ToDouble(txtStock.Text);
                        producto.PrecioCompra     = Convert.ToDouble(txtPrecioCompra.Text);
                        producto.PrecioVenta      = Convert.ToDouble(txtPrecioVenta.Text);
                        producto.FechaVencimiento = txtFechaVencimiento.Value;

                        MemoryStream ms = new MemoryStream();

                        if (Imagen.Image != null)
                        {
                            Imagen.Image.Save(ms, Imagen.Image.RawFormat);
                        }
                        else
                        {
                            Imagen.Image = Resources.Imagen_Transparente;
                            Imagen.Image.Save(ms, Imagen.Image.RawFormat);
                        }

                        producto.Imagen = ms.GetBuffer();


                        if (FProductos.Insertar(producto) > 0)
                        {
                            MessageBox.Show("Datos Insertados Correctamente");
                            FrmProducto_Load(null, null);
                        }
                    }

                    else
                    {
                        Producto producto = new Producto();
                        producto.Id               = Convert.ToInt32(txtId.Text);
                        producto.Categoria.Id     = Convert.ToInt32(txtCategoriaId.Text);
                        producto.Nombre           = txtNombre.Text;
                        producto.Descripcion      = txtDescripcion.Text;
                        producto.Stock            = Convert.ToDouble(txtStock.Text);
                        producto.PrecioCompra     = Convert.ToDouble(txtPrecioCompra.Text);
                        producto.PrecioVenta      = Convert.ToDouble(txtPrecioVenta.Text);
                        producto.FechaVencimiento = txtFechaVencimiento.Value;

                        MemoryStream ms = new MemoryStream();

                        if (Imagen.Image != null)
                        {
                            Imagen.Image.Save(ms, Imagen.Image.RawFormat);
                        }
                        else
                        {
                            Imagen.Image = Resources.Imagen_Transparente;
                            Imagen.Image.Save(ms, Imagen.Image.RawFormat);
                        }

                        producto.Imagen = ms.GetBuffer();


                        if (FProductos.Actualizar(producto) == 1)
                        {
                            MessageBox.Show("Datos Insertados Correctamente");
                            FrmProducto_Load(null, null);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Faltan cargar Datos: " + sResultado);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }