Esempio n. 1
0
        internal void MtdAgregarProducto(Cls_E_Producto objE)
        {
            ClsConexionSQL objConexion = new ClsConexionSQL();
            SqlCommand     objComando  = new SqlCommand();

            objComando.Connection  = objConexion.conectar();
            objComando.CommandText = "USP_I_AgregarProducto";
            objComando.CommandType = CommandType.StoredProcedure;
            objComando.Parameters.Add(new SqlParameter("id", SqlDbType.Int));
            objComando.Parameters.Add(new SqlParameter("descripcion", SqlDbType.VarChar));
            objComando.Parameters.Add(new SqlParameter("precios", SqlDbType.Decimal));
            objComando.Parameters.Add(new SqlParameter("precioc", SqlDbType.Decimal));
            objComando.Parameters.Add(new SqlParameter("stock", SqlDbType.Int));
            objComando.Parameters.Add(new SqlParameter("idt", SqlDbType.Int));
            objComando.Parameters.Add(new SqlParameter("estado", SqlDbType.VarChar));
            objComando.Parameters["id"].Value          = objE.Idproducto;
            objComando.Parameters["descripcion"].Value = objE.Descripcion.ToUpper();
            objComando.Parameters["precios"].Value     = objE.Precio_salida;
            objComando.Parameters["precioc"].Value     = objE.Precio_compra;
            objComando.Parameters["stock"].Value       = objE.Cantidad;
            objComando.Parameters["idt"].Value         = objE.Idtipo;
            objComando.Parameters["estado"].Value      = objE.Estado;
            objComando.Connection = objConexion.conectar();
            objComando.ExecuteNonQuery();
        }
Esempio n. 2
0
        internal bool MtdActualizarEmpleado(Cls_E_Producto objE)
        {
            try
            {
                ClsConexionSQL objConexion = new ClsConexionSQL();
                SqlCommand     objComando  = new SqlCommand();
                objComando.Connection  = objConexion.conectar();
                objComando.CommandText = "USP_U_ActualizarProducto";
                objComando.CommandType = CommandType.StoredProcedure;
                objComando.Parameters.Add(new SqlParameter("id", SqlDbType.Int));
                objComando.Parameters.Add(new SqlParameter("des", SqlDbType.VarChar));
                objComando.Parameters.Add(new SqlParameter("pres", SqlDbType.Decimal));
                objComando.Parameters.Add(new SqlParameter("prec", SqlDbType.Decimal));
                objComando.Parameters.Add(new SqlParameter("sto", SqlDbType.Int));
                objComando.Parameters.Add(new SqlParameter("idt", SqlDbType.Int));
                objComando.Parameters.Add(new SqlParameter("est", SqlDbType.VarChar));
                objComando.Parameters["id"].Value   = objE.Idproducto;
                objComando.Parameters["des"].Value  = objE.Descripcion.ToUpper();
                objComando.Parameters["pres"].Value = objE.Precio_salida;
                objComando.Parameters["prec"].Value = objE.Precio_compra;
                objComando.Parameters["sto"].Value  = objE.Cantidad;
                objComando.Parameters["idt"].Value  = objE.Idtipo;
                objComando.Parameters["est"].Value  = objE.Estado;
                objComando.Connection = objConexion.conectar();
                objComando.ExecuteNonQuery();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
Esempio n. 3
0
 private void BtnAceptar_Click(object sender, EventArgs e)
 {
     if (txtDescripcion.Text == "")
     {
         MessageBox.Show("Agregue descripcion", "Alerta");
         return;
     }
     if (txtPrecio.Text == "")
     {
         MessageBox.Show("Agruegue Precio", "Alerta");
         return;
     }
     if (MessageBox.Show("¿Desea agregar nuevo producto?", "Alerta", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
     {
         Cls_E_Producto objProducto = new Cls_E_Producto();
         Cls_N_Compras  objNCompras = new Cls_N_Compras();
         objProducto.Idproducto    = int.Parse(txtCodigo.Text);
         objProducto.Descripcion   = txtDescripcion.Text;
         objProducto.Cantidad      = 0;
         objProducto.Precio_compra = double.Parse(txtPrecio.Text);
         objProducto.Precio_salida = ((Convert.ToDouble(txtPrecio.Text)) + ((Convert.ToDouble(txtPrecio.Text)) / 2));
         objProducto.Idtipo        = cbTipo.SelectedIndex + 1;
         objProducto.Estado        = "1";
         objNCompras.MtdAgregarProducto(objProducto);
     }
     this.Close();
 }
Esempio n. 4
0
        internal void MtdIncrementarProductos(Cls_E_Producto objE)
        {
            ClsConexionSQL objConexion = new ClsConexionSQL();
            SqlCommand     objComando  = new SqlCommand();

            objComando.Connection  = objConexion.conectar();
            objComando.CommandText = "USP_U_DecrementarProducto";
            objComando.CommandType = CommandType.StoredProcedure;
            objComando.Parameters.Add(new SqlParameter("cant", SqlDbType.Int));
            objComando.Parameters.Add(new SqlParameter("cod", SqlDbType.Int));
            objComando.Parameters["cod"].Value  = objE.Idproducto;
            objComando.Parameters["cant"].Value = objE.Cantidad;
            objComando.Connection = objConexion.conectar();
            objComando.ExecuteNonQuery();
        }
Esempio n. 5
0
 private void DgInventario_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (this.dgInventario.Columns[e.ColumnIndex].Name == "Deshabilitar")
         {
             dgInventario.CurrentRow.Cells[6].Value = "0";
             mtdPintar();
         }
         else if ((this.dgInventario.Columns[e.ColumnIndex].Name == "Modificar"))
         {
             if (MessageBox.Show("¿Seguro que desea Modificar?", "Alerta", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
             {
                 modificar = true;
                 bool           existir = false;
                 Cls_E_Producto objE    = new Cls_E_Producto();
                 objE.Idproducto    = int.Parse(dgInventario.CurrentRow.Cells[0].Value.ToString());
                 objE.Descripcion   = dgInventario.CurrentRow.Cells[1].Value.ToString();
                 objE.Precio_salida = double.Parse(dgInventario.CurrentRow.Cells[2].Value.ToString());
                 objE.Precio_compra = double.Parse(dgInventario.CurrentRow.Cells[3].Value.ToString());
                 objE.Cantidad      = int.Parse(dgInventario.CurrentRow.Cells[4].Value.ToString());
                 objE.Idtipo        = int.Parse(dgInventario.CurrentRow.Cells[5].Value.ToString());
                 objE.Estado        = dgInventario.CurrentRow.Cells[6].Value.ToString();
                 Cls_N_Productos objN = new Cls_N_Productos();
                 existir = objN.MtdActualizarEmpleado(objE);
                 if (existir == true)
                 {
                     MessageBox.Show("Modificado exitosamente");
                     btnRefrescar.PerformClick();
                     dgInventario.Columns[0].ReadOnly = true;
                 }
             }
         }
     }
     catch
     {
         //nada
     }
 }
Esempio n. 6
0
        private void PicGuardar_Click(object sender, EventArgs e)
        {
            if (dgvCompra.Rows.Count == 0 || cbTipoPago.SelectedIndex == -1)
            {
                MessageBox.Show("INGRESE PRODUCTOS/seleccione metodo de pago");
                return;
            }
            else
            {
                if (MessageBox.Show("¿Registrar Venta?", "Alerta", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                {
                    bool                comprobar2        = false;
                    Cls_E_Boleta        objEBoleta        = new Cls_E_Boleta();
                    Cls_E_DetalleBoleta objEDetalleBoelta = new Cls_E_DetalleBoleta();
                    Cls_N_Compras       objN = new Cls_N_Compras();
                    objEBoleta.Serie    = lblSerie.Text;
                    objEBoleta.Numero   = lblNumeroBoleta.Text;
                    objEBoleta.Estado   = "1";
                    objEBoleta.Cliente  = lblProveedor.Text;
                    objEBoleta.Empleado = lblDNIEMP.Text;
                    objEBoleta.Fecha    = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                    objEBoleta.Subtotal = double.Parse(txtSubTotal.Text);
                    objEBoleta.Igv      = double.Parse(txtIgv.Text);
                    objEBoleta.Total    = double.Parse(txtTotal.Text);
                    objEBoleta.Tipopago = cbTipoPago.SelectedItem.ToString();
                    bool comprobar = objN.MtdAgregarABoleta(objEBoleta);
                    foreach (DataGridViewRow fila in dgvCompra.Rows)
                    {
                        objEDetalleBoelta.Serie           = lblSerie.Text;
                        objEDetalleBoelta.Numero          = lblNumeroBoleta.Text;
                        objEDetalleBoelta.Codigo          = int.Parse(fila.Cells[0].Value.ToString());
                        objEDetalleBoelta.Cantidad        = int.Parse(fila.Cells[1].Value.ToString());
                        objEDetalleBoelta.Importe         = double.Parse(fila.Cells[2].Value.ToString());
                        objEDetalleBoelta.Precio_unitario = double.Parse(fila.Cells[3].Value.ToString());
                        comprobar2 = objN.MtdAgregarDetalleBoleta(objEDetalleBoelta);
                    }

                    if (comprobar == true && comprobar2 == true)
                    {
                        int cantidad = 0;
                        foreach (DataGridViewRow fila in dgvCompra.Rows)
                        {
                            Cls_E_Producto objE = new Cls_E_Producto();
                            objE.Idproducto = int.Parse(fila.Cells[0].Value.ToString());
                            foreach (DataRow filas in productos.Rows)
                            {
                                if (filas[0].ToString() == fila.Cells[0].Value.ToString())
                                {
                                    cantidad = int.Parse(filas[4].ToString());
                                    break;
                                }
                            }
                            objE.Cantidad = cantidad + int.Parse(fila.Cells[1].Value.ToString());
                            objN.MtdIncrementarProductos(objE);
                        }
                        MessageBox.Show("Compra Registrada");
                        cbProveedor.Enabled = true;

                        boleta.Rows.Clear();
                        boleta = objN.MtdListarBoletas();
                        int numeroboletas = boleta.Rows.Count;
                        lblNumeroBoleta.Text = objN.MtdCalcularNumeroBoleta(numeroboletas);
                        dgvCompra.Rows.Clear();
                        cbProductos.SelectedIndex = -1;
                        cbProveedor.SelectedIndex = -1;

                        txtCantidadProducto.Clear();
                        txtPrecioUnitario.Clear();
                        lblProducto.Text  = "";
                        lblProveedor.Text = "";
                        txtIgv.Clear();
                        txtSubTotal.Clear();
                        txtTotal.Clear();
                        txtMonedaEnLEtras.Clear();
                    }
                    else
                    {
                        MessageBox.Show("Ingrese datos validos");
                    }
                }
            }
        }