Example #1
0
        private void llenarCheckBoxListTamano()
        {
            idPanel = 1;
            int contador = 0;
            clsNegocioTamano objTamano = new clsNegocioTamano();
            DataTable dtTamano = objTamano.consultarTodosTamanos().Tables[0];
            chkLista.DataSource = null;
            if (operacion == 1)
            {
                int idProducto = int.Parse(lbProducto.SelectedValue.ToString());
                DataTable dtTamanoProducto = objTamano.consultarTamanoProducto(idProducto).Tables[0];

                chkLista.DataSource = dtTamano;
                chkLista.DisplayMember = "nombre_tamano";
                chkLista.ValueMember = "id_tamano";

                foreach (DataRow filaTamano in dtTamano.Rows)
                {
                    foreach (DataRow filaTamanoProducto in dtTamanoProducto.Rows)
                    {
                        if (filaTamano[0].ToString() == filaTamanoProducto[1].ToString())
                        {
                            chkLista.SetItemCheckState(contador, CheckState.Checked);
                        }
                    }
                    contador++;
                }
            }
            if (operacion == 0)
            {
                chkLista.DataSource = dtTamano;
                chkLista.DisplayMember = "nombre_tamano";
                chkLista.ValueMember = "id_tamano";
            }
        }
Example #2
0
        private void btnNuevo_Click(object sender, EventArgs e)
        {
            try
            {
                listaColores = new List<int>();
                listaTamanos = new List<int>();
                clsNegocioColor objNegocioColor = new clsNegocioColor();
                clsNegocioTamano objNegocioTamano = new clsNegocioTamano();
                clsNegocioCategoria objNegocioCategoria = new clsNegocioCategoria(); 

                operacion = 0;
                if (flagBloqueado == true)
                {
                    limpiarPantalla();
                    desbloquear();
                    if (objNegocioCategoria.consultarCategoria("").Tables[0].Rows.Count == 0)
                    {
                        MessageBox.Show("No se puede crear productos porque no existe categorias creadas");
                        bloquear();
                    }
                    else
                    {
                        cbCategoriaProducto.SelectedIndex = 0;
                    }
                    if (cbMarcaProducto.Items.Count == 0)
                    {
                        MessageBox.Show("No se puede crear productos porque no existe marcas creadas creadas");
                        bloquear();
                    }
                    if (objNegocioColor.consultarTodosColores().Tables[0].Rows.Count == 0)
                    {
                        MessageBox.Show("No se puede crear productos porque no existen colores creados");
                        bloquear();
                    }
                    if (objNegocioTamano.consultarTodosTamanos().Tables[0].Rows.Count == 0)
                    {
                        MessageBox.Show("No se puede crear productos porque no existen tamaños creados");
                        bloquear();
                    }
                }
                else
                {
                    bloquear();
                    int idProduto = int.Parse(lbProducto.SelectedValue.ToString());
                    llenarProducto();
                }
            }
            catch (Exception)
            {
            }
        }
Example #3
0
        private void cargarComboTamano(int id)
        {
            clsNegocioTamano objNegocioTamano = new clsNegocioTamano();
            DataSet dsTamanoCombo = new DataSet();
            try
            {
                dsTamanoCombo = objNegocioTamano.consultarTamanoProducto(id);

                cbTamanoProducto.DataSource = dsTamanoCombo.Tables[0];
                cbTamanoProducto.DisplayMember = "nombre_tamano";
                cbTamanoProducto.ValueMember = "id_tamano";
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }
Example #4
0
        private void btnGuardarPanel_Click(object sender, EventArgs e)
        {
            //listaColores = new List<int>();
            //listaTamanos = new List<int>();
            clsNegocioColor objNegocioColor = new clsNegocioColor();
            clsNegocioTamano objNegocioTamano = new clsNegocioTamano();

            if (operacion == 1)
            {
                int idProducto = int.Parse(lbProducto.SelectedValue.ToString());

                if (idPanel == 0)
                {
                    DataTable dtColor = objNegocioColor.consultarTodosColores().Tables[0];
                    objNegocioColor.eliminarColorProducto(idProducto);
                    for (int i = 0; i < chkLista.Items.Count; i++)
                    {
                        if (chkLista.GetItemChecked(i))
                        {
                            int idColor = int.Parse(dtColor.Rows[i][0].ToString());
                            objNegocioColor.insertarColorProducto(idProducto, idColor);
                        }
                    }
                }
                if (idPanel == 1)
                {
                    DataTable dtTamano = objNegocioTamano.consultarTodosTamanos().Tables[0];
                    objNegocioTamano.eliminarTamanoProducto(idProducto);
                    for (int i = 0; i < chkLista.Items.Count; i++)
                    {
                        if (chkLista.GetItemChecked(i))
                        {
                            int idTamano = int.Parse(dtTamano.Rows[i][0].ToString());
                            objNegocioTamano.insertarTamanoProducto(idProducto, idTamano);
                        }
                    }
                }
            }

            if (operacion == 0)
            {
                if (idPanel == 0)
                {
                    DataTable dtColor = objNegocioColor.consultarTodosColores().Tables[0];
                    for (int i = 0; i < chkLista.Items.Count; i++)
                    {
                        if (chkLista.GetItemChecked(i))
                        {
                            int idColor = int.Parse(dtColor.Rows[i][0].ToString());
                            listaColores.Add(idColor);
                        }
                    }
                }
                if (idPanel == 1)
                {
                    DataTable dtTamano = objNegocioTamano.consultarTodosTamanos().Tables[0];
                    for (int i = 0; i < chkLista.Items.Count; i++)
                    {
                        if (chkLista.GetItemChecked(i))
                        {
                            int idTamano = int.Parse(dtTamano.Rows[i][0].ToString());
                            listaTamanos.Add(idTamano);
                        }
                    }
                }
            }

            panelSeleccion.Visible = false;

        }
Example #5
0
        private void btnGuardarProducto_Click(object sender, EventArgs e)
        {
            try
            {
                if (operacion == 0)
                {
                    clsProducto objProducto = new clsProducto();
                    clsNegocioColor objNegocioColor = new clsNegocioColor();
                    clsNegocioTamano objNegocioTamano = new clsNegocioTamano();

                    objProducto.nombre_producto = txtNombreProducto.Text;
                    objProducto.id_categoria = int.Parse(cbCategoriaProducto.SelectedValue.ToString());
                    objProducto.id_marca = int.Parse(cbMarcaProducto.SelectedValue.ToString());
                    if (txtPrecio.Text == "")
                        txtPrecio.Text = "0";
                    else
                    objProducto.precio_producto = double.Parse(txtPrecio.Text);
                    objProducto.cantidad = int.Parse(cantidadProducto.Value.ToString());
                    objProducto.descripcion = txtDescripcion.Text;
                    if (rbActivo.Checked)
                        objProducto.estado_producto = true;
                    if (rbInactivo.Checked)
                        objProducto.estado_producto = false;
                    if(listaColores.Count == 0)
                    {
                        MessageBox.Show("Por favor seleccione un color para este producto");
                        return;
                    }

                    if (listaTamanos.Count == 0)
                    {
                        MessageBox.Show("Por favor seleccione un tamaño para este producto");
                        return;
                    }
                    if (objNegocioProducto.insertarProducto(objProducto))
                    {
                        int idUltimoProducto = objNegocioProducto.consultarUltimoProducto();
                        
                        if(listaColores.Count > 0)
                        {
                            foreach (int color in listaColores)
                            {
                                objNegocioColor.insertarColorProducto(idUltimoProducto, color);
                            }
                        }
                        

                        if (listaTamanos.Count > 0)
                        {
                            foreach (int tamano in listaTamanos)
                            {
                                objNegocioTamano.insertarTamanoProducto(idUltimoProducto, tamano);
                            }
                        }
                        
                        MessageBox.Show("Producto creado con exito");
                    }
                    else
                    {
                        MessageBox.Show("Error al crear la producto");
                        return;
                    }
                    dsProducto = objNegocioProducto.consultarProducto("");
                    cargarProducto(dsProducto);
                }
                if (operacion == 1)
                {
                    clsProducto objProducto = new clsProducto();
                    objProducto.id_producto = int.Parse(lbProducto.SelectedValue.ToString());
                    objProducto.nombre_producto = txtNombreProducto.Text;
                    objProducto.id_categoria = int.Parse(cbCategoriaProducto.SelectedValue.ToString());
                    objProducto.id_marca = int.Parse(cbMarcaProducto.SelectedValue.ToString());
                    objProducto.precio_producto = double.Parse(txtPrecio.Text);
                    objProducto.cantidad = int.Parse(cantidadProducto.Value.ToString());
                    objProducto.descripcion = txtDescripcion.Text;
                    if (rbActivo.Checked)
                        objProducto.estado_producto = true;
                    if (rbInactivo.Checked)
                        objProducto.estado_producto = false;

                    if (objNegocioProducto.actualizarProducto(objProducto))
                    {
                        MessageBox.Show("Producto actualizado con exito");
                    }
                    else
                    {
                        MessageBox.Show("Error al actualizar la producto");
                        return;
                    }
                    
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
                return;
            }
            limpiarPantalla();
            bloquear();
            dsProducto = objNegocioProducto.consultarProducto("");
            cargarProducto(dsProducto);
        }
Example #6
0
        public void actualizareDetalle()
        {
            int                index              = lista.Count - 1;
            DataSet            dsProducto         = new DataSet();
            DataSet            dsColor            = new DataSet();
            DataSet            dsTamano           = new DataSet();
            clsNegocioProducto objNegocioProducto = new clsNegocioProducto();
            clsNegocioColor    objNegocioColor    = new clsNegocioColor();
            clsNegocioTamano   objNegocioTamano   = new clsNegocioTamano();

            try
            {
                if (index >= 0)
                {
                    int idProducto = lista[index].id_producto;
                    int idColor    = lista[index].id_color;
                    int idTamano   = lista[index].id_tamano;

                    dsProducto = objNegocioProducto.consultarProductoId(idProducto);
                    dsColor    = objNegocioColor.consultarColorId(idColor);
                    dsTamano   = objNegocioTamano.consultarTamanoId(idTamano);

                    string producto    = dsProducto.Tables[0].Rows[0][1].ToString();
                    string color       = dsColor.Tables[0].Rows[0][1].ToString();
                    string tamano      = dsTamano.Tables[0].Rows[0][1].ToString();
                    double precio      = double.Parse(dsProducto.Tables[0].Rows[0][2].ToString());
                    int    cantidad    = lista[index].cantidad;
                    double total       = lista[index].cantidad * precio;
                    bool   estado      = lista[index].estado_detalle;
                    string observacion = lista[index].observacion_detalle_paquete;


                    if (objNegocioProducto.disminuirCantidad(idProducto, cantidad))
                    {
                        DataRow fila = dtDetallePaquete.NewRow();
                        fila[0] = producto;
                        fila[1] = color;
                        fila[2] = tamano;
                        fila[3] = lista[index].cantidad;
                        fila[4] = precio;
                        fila[5] = total;
                        fila[6] = estado;
                        dtDetallePaquete.Rows.Add(fila);

                        DataRow filaLogica = dtDetallePaqueteLogico.NewRow();

                        filaLogica[0] = 0;
                        filaLogica[1] = idProducto;
                        filaLogica[2] = idColor;
                        filaLogica[3] = idTamano;
                        filaLogica[4] = lista[index].cantidad;
                        filaLogica[5] = total;
                        filaLogica[6] = estado;
                        filaLogica[7] = observacion;

                        dtDetallePaqueteLogico.Rows.Add(filaLogica);

                        dgDetallePaquete.DataSource = dtDetallePaquete;

                        darFormatoDetalle();
                        ajustarTamanioColumna();
                    }
                    else
                    {
                        MessageBox.Show("Cantidad no disponible en el producto");
                    }
                    sumarPaquete();
                }
            }
            catch (Exception)
            {
            }
        }