Ejemplo n.º 1
0
 private void toolStripButton2_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("¿Esta Seguro que desea Eliminar este registro?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             CLS.DetalleMovimiento oDMovimiento = new CLS.DetalleMovimiento();
             if (!lblTransaccion.Text.Equals("Cotizacion"))
             {
                 CLS.Inventario oInventario = new CLS.Inventario();
                 Double         suma        = 0.00;
                 Double         inventario  = Convert.ToDouble(dtgDetalle.CurrentRow.Cells["exi"].Value);
                 Double         entrada     = Convert.ToDouble(dtgDetalle.CurrentRow.Cells["cantitadsalida"].Value);
                 suma = inventario + entrada;
                 oInventario.IdProducto  = dtgDetalle.CurrentRow.Cells["idp"].Value.ToString();
                 oInventario.Existencias = Convert.ToString(suma);
                 oInventario.Actualizar_Existencias();
                 Cargar();
             }
             // sincronizar
             oDMovimiento.IDDetalle = dtgDetalle.CurrentRow.Cells["iddetalle"].Value.ToString();
             oDMovimiento.Eliminar();
             CargarDetalle();
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 2
0
        private void dtgDetalle_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs e)
        {
            Double total = 0.00;
            Double iva   = 0.00;

            CLS.Inventario oInventario = new CLS.Inventario();

            foreach (DataGridViewRow row in dtgDetalle.Rows)
            {
                iva   += Convert.ToDouble(row.Cells["MontoIVA"].Value);
                total += Convert.ToDouble(row.Cells["subtotal"].Value);
            }
            txbIDProducto.Text = "";
            lblIDDetalle.Text  = "";
            txbProducto.Text   = "";
            txbPrecio.Text     = "";
            txbSubtotal.Text   = "";
            txbIVA.Text        = "";
            txbCantidad.Text   = "";
            lblUnidad.Text     = "";

            lblIVAsuma.Text      = Convert.ToString(iva);
            lblsubtotalSuma.Text = Convert.ToString(total);
            Cargar();
        }
Ejemplo n.º 3
0
        private void Procesar()
        {
            try
            {
                if (VerificarDatos())
                {
                    CLS.Producto oProducto = new CLS.Producto();
                    oProducto.IDProducto  = lblIDProducto.Text;
                    oProducto.Nombre      = txbNombre.Text;
                    oProducto.IDCategoria = cbbCategoria.SelectedValue.ToString();
                    oProducto.IDMarca     = txbMarca.Text;
                    oProducto.IDUnidad    = cbbUnidad.SelectedValue.ToString();
                    oProducto.Codigo      = txbCodigo.Text;
                    oProducto.Descripcion = txbDescripcion.Text;

                    if (lblIDProducto.Text.Length > 0)
                    {
                        oProducto.Actualizar();
                    }
                    else
                    {
                        oProducto.Guardar();
                    }

                    if (oProducto != null && !oProducto.ObtenerID(txbCodigo.Text).Equals("0"))
                    {
                        CLS.Inventario oInventario = new CLS.Inventario();
                        oInventario.IDInventario   = lblIDInventario.Text;
                        oInventario.PrecioUnitario = txbPrecio.Text;
                        oInventario.Existencias    = txbExistencias.Text;
                        oInventario.IDUnidades     = cbbUnidad.SelectedValue.ToString();
                        oInventario.IdProducto     = oProducto.ObtenerID(txbCodigo.Text);

                        if (lblIDInventario.Text.Length > 0)
                        {
                            oInventario.Actualizar();
                            Close();
                        }
                        else
                        {
                            oInventario.IdProducto = oProducto.ObtenerID(txbCodigo.Text);
                            oInventario.Guardar();
                            Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("No se ha podido agregar al inventario, debe de verifiar bien los valores", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 4
0
        private void actualilzar_existencias()
        {
            CLS.Inventario oInventario = new CLS.Inventario();
            try
            {
                if (lblIDDetalle.Text.Length > 0)
                {
                    double valorAnterior = Convert.ToDouble(dtgDetalle.Rows[dtgDetalle.CurrentRow.Index].Cells["cantidadEntrada"].Value);
                    double nuevoValor    = Convert.ToDouble(txbCantidad.Text);
                    double Existencias   = Convert.ToDouble(dtgDetalle.Rows[dtgDetalle.CurrentRow.Index].Cells["exi"].Value);

                    oInventario.IDInventario = dtgDetalle.Rows[dtgDetalle.CurrentRow.Index].Cells["inventario"].Value.ToString();
                    oInventario.IdProducto   = txbIDProducto.Text;
                    double aux = 0.00;
                    if (nuevoValor < valorAnterior)
                    {
                        aux = Existencias - (valorAnterior - nuevoValor);
                    }
                    else if (nuevoValor > valorAnterior)
                    {
                        aux = Existencias + (nuevoValor - valorAnterior);
                    }
                    else if (nuevoValor == valorAnterior)
                    {
                        aux = Existencias;
                    }
                    oInventario.Existencias = Convert.ToString(aux);
                }
                else if (lblIDDetalle.Text.Length == 0)
                {
                    oInventario.IDInventario = dtgProductos.Rows[dtgProductos.CurrentRow.Index].Cells["IDINVENTARIO"].Value.ToString();
                    oInventario.IdProducto   = txbIDProducto.Text;
                    double cantidad   = 0.00;
                    double inventario = 0.00;
                    double aux        = 0.00;
                    cantidad   = Convert.ToDouble(txbCantidad.Text);
                    inventario = Convert.ToDouble(dtgProductos.Rows[dtgProductos.CurrentRow.Index].Cells["Existencias"].Value);
                    aux        = inventario + cantidad;
                    oInventario.Existencias = Convert.ToString(aux);
                }

                if (oInventario.Actualizar_Existencias())
                {
                    Cargar();
                    CargarDetalle();
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 5
0
        private void actualizar_anulacion()
        {
            DataTable dtgAnulados = new DataTable();
            //Lista de auxiliares
            List <int>    auxIDDetalle    = new List <int>();
            List <int>    auxIDProducto   = new List <int>();
            List <int>    auxIDInventario = new List <int>();
            List <double> auxExistencias  = new List <double>();
            List <double> auxCantidad     = new List <double>();

            //Lista de nuevo inventario
            List <double> nuevoInventario = new List <double>();

            double auxValores = 0.00;

            //Clase de Inventario
            CLS.Inventario oInventario = new CLS.Inventario();
            try
            {
                String idmovi = dtgMovimiento.CurrentRow.Cells["idmovimiento"].Value.ToString();
                dtgAnulados = CacheManager.CLS.Cache.OBTENER_ELEMENTOS_DETALLEMOV_POR_IDMOV(idmovi);

                //agregar por separado cada id en cada lista de elementos que viene del dtg
                foreach (DataRow row in dtgAnulados.Rows)
                {
                    auxIDDetalle.Add(Convert.ToInt32(row["iddetalle"]));
                    auxIDProducto.Add(Convert.ToInt32(row["idproducto"]));
                    auxIDInventario.Add(Convert.ToInt32(row["idinventario"]));

                    auxCantidad.Add(Convert.ToDouble(row["cantidad"]));
                    auxExistencias.Add(Convert.ToDouble(row["existencias"]));
                }
                for (int i = 0; i < auxIDDetalle.Count; i++)
                {
                    auxValores = auxExistencias.ElementAt(i) + auxCantidad.ElementAt(i);
                    nuevoInventario.Add(auxValores);


                    //actualizar cada uno con id
                    oInventario              = new CLS.Inventario();
                    oInventario.IdProducto   = Convert.ToString(auxIDProducto.ElementAt(i));
                    oInventario.IDInventario = Convert.ToString(auxIDInventario.ElementAt(i));
                    oInventario.Existencias  = Convert.ToString(nuevoInventario.ElementAt(i));

                    oInventario.Actualizar_Existencias();
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 6
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                Double total = 0.00;
                Double iva   = 0.00;

                if (MessageBox.Show("¿Esta Seguro que desea Eliminar este registro?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    CLS.DetalleMovimiento oDMovimiento = new CLS.DetalleMovimiento();
                    CLS.Inventario        oInventario  = new CLS.Inventario();
                    Double resta      = 0.00;
                    Double inventario = Convert.ToDouble(dtgDetalle.CurrentRow.Cells["exi"].Value);
                    Double entrada    = Convert.ToDouble(dtgDetalle.CurrentRow.Cells["cantidadentrada"].Value);
                    // sincronizar

                    oDMovimiento.IDDetalle = dtgDetalle.CurrentRow.Cells["iddetalle"].Value.ToString();
                    oInventario.IdProducto = dtgDetalle.CurrentRow.Cells["idp"].Value.ToString();
                    resta = inventario - entrada;
                    oInventario.Existencias = Convert.ToString(resta);
                    oInventario.Actualizar_Existencias();
                    oDMovimiento.Eliminar();

                    foreach (DataGridViewRow row in dtgDetalle.Rows)
                    {
                        iva   += Convert.ToDouble(row.Cells["MontoIVA"].Value);
                        total += Convert.ToDouble(row.Cells["subtotal"].Value);
                    }
                    lblIVAsuma.Text      = Convert.ToString(iva);
                    lblsubtotalSuma.Text = Convert.ToString(total);

                    Cargar();
                    CargarDetalle();
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 7
0
 private void btnEliminar_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("¿Realmente desea ELIMINAR el producto seleccionado?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             CLS.Producto   oProducto   = new CLS.Producto();
             CLS.Inventario oInventario = new CLS.Inventario();
             // sincronizar
             oProducto.IDProducto     = dtgProductos.CurrentRow.Cells["idproducto"].Value.ToString();
             oInventario.IDInventario = dtgProductos.CurrentRow.Cells["idinventario"].Value.ToString();
             if (oInventario.Eliminar())
             {
                 oProducto.Eliminar();
                 Cargar();
             }
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 8
0
        private void concluirDevoluciones()
        {
            DataTable dtInventarios = new DataTable();

            CLS.Inventario oInventario = new CLS.Inventario();
            try
            {
                foreach (DataGridViewRow dtgR in dtgDevoluciones.Rows)
                {
                    String idDetalle = dtgR.Cells["idd"].Value.ToString();
                    Double numNuevo  = Convert.ToDouble(dtgR.Cells["cSalida"].Value);
                    dtInventarios = CacheManager.CLS.Cache.INFORMACION_INVENTARIO_PARA_DEVOLUCION(idDetalle);

                    Double inventarioActual = 0.00;
                    Double nuevoInventario  = 0.00;

                    foreach (DataRow ROW in dtInventarios.Rows)
                    {
                        oInventario.IDInventario = ROW["idinventario"].ToString();
                        oInventario.IdProducto   = ROW["idproducto"].ToString();

                        inventarioActual = Convert.ToDouble(ROW["existencias"]);

                        nuevoInventario         = inventarioActual - numNuevo;
                        oInventario.Existencias = nuevoInventario.ToString();

                        if (oInventario.Actualizar_Existencias())
                        {
                            this.Close();
                        }
                    }
                }
            }
            catch
            {
            }
        }