Пример #1
0
        //Método Buscar

        public static DataTable Buscar(string textobuscar)
        {
            DInventario Obj = new DInventario();

            Obj.TextoBuscar = textobuscar;

            return(Obj.Buscar(Obj));
        }
Пример #2
0
        //Método Eliminar
        public static string Eliminar(int idinventario)
        {
            DInventario Obj = new DInventario();

            Obj.Idinventario = idinventario;

            return(Obj.Eliminar(Obj));
        }
Пример #3
0
        //Método Editar
        public static string Editar(int idinventario, int cantidad)
        {
            DInventario Obj = new DInventario();

            Obj.Idinventario = idinventario;
            Obj.Cantidad     = cantidad;

            return(Obj.Editar(Obj));
        }
Пример #4
0
        //Método Insertar
        public static string Insertar(int cantidad, int idvehiculo)
        {
            DInventario Obj = new DInventario();

            Obj.Cantidad   = cantidad;
            Obj.Idvehiculo = idvehiculo;

            return(Obj.Insertar(Obj));
        }
Пример #5
0
 private void BtnSeleccionar_Click(object sender, EventArgs e)
 {
     if (DgvProducto.SelectedRows.Count > 0)
     {
         int rowindex = DgvProducto.CurrentRow.Index;
         if (rowindex != -1)
         {
             try
             {
                 FrmVenta frm            = Owner as FrmVenta;
                 string   codigoproducto = DgvProducto.CurrentRow.Cells[3].Value.ToString();
                 frm.TxtProducto.Text = codigoproducto;
                 DProducto boProducto = new DProducto();
                 Producto  producto   = boProducto.Seleccionar(codigoproducto);
                 if (string.IsNullOrEmpty(producto.Codigo))
                 {
                     MessageBox.Show("No Existe Producto", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 }
                 else
                 {
                     DInventario boInventario = new DInventario();
                     Inventario  inventario   = boInventario.Seleccionar(producto.Codigo);
                     if (!string.IsNullOrEmpty(inventario.Producto))
                     {
                         if (inventario.Existencias > 0)
                         {
                             double utilidad    = FrmPrincipal.ValorUtilidad;
                             double precioventa = Math.Round((inventario.ValorUnitario * utilidad), 2);
                             frm.AddItems(producto, 1, precioventa);
                             //Mostrar imagen
                             if (!string.IsNullOrEmpty(producto.Imagen))
                             {
                                 frm.PbxImgProducto.Image = Image.FromFile(CarpetaImagen + "/" + producto.Imagen);
                             }
                         }
                         else
                         {
                             MessageBox.Show("No hay Cantidad Suficiente");
                         }
                     }
                 }
                 Close();
             }
             catch
             {
                 //
             }
         }
     }
     else
     {
         MessageBox.Show("Seleccione un registro");
     }
 }
Пример #6
0
 private void ActualizarCantidad(string operation, int quantity = 1)
 {
     if (MLVDetalle.SelectedItems.Count > 0)
     {
         string      codigoproducto = MLVDetalle.SelectedItems[0].SubItems[0].Text;
         DInventario boInventario   = new DInventario();
         Inventario  inventario     = boInventario.Seleccionar(codigoproducto);
         //Datos
         double precio   = Convert.ToDouble(MLVDetalle.SelectedItems[0].SubItems[3].Text);
         int    cantidad = Convert.ToInt32(MLVDetalle.SelectedItems[0].SubItems[4].Text);
         if (operation.Equals("Aumentar"))
         {
             if (cantidad < inventario.Existencias)
             {
                 cantidad += quantity;
             }
             else
             {
                 MessageBox.Show("No hay mas productos");
             }
         }
         else if (operation.Equals("Disminuir"))
         {
             cantidad -= quantity;
         }
         else if (operation.Equals("Nueva"))
         {
             if (quantity <= inventario.Existencias)
             {
                 cantidad = quantity;
             }
             else
             {
                 MessageBox.Show("No hay mas productos");
             }
         }
         double importe = precio * cantidad;
         MLVDetalle.SelectedItems[0].SubItems[4].Text = cantidad.ToString();
         MLVDetalle.SelectedItems[0].SubItems[5].Text = importe.ToString();
         TxtCantidadItem.Text = cantidad.ToString();
         ActualizarResumen();
     }
     else
     {
         MessageBox.Show("Seleccione Item");
     }
 }
Пример #7
0
 private void CargarDatosProducto()
 {
     try
     {
         string      codigoproducto = DgvProducto.CurrentRow.Cells[3].Value.ToString();
         DInventario boInventario   = new DInventario();
         Inventario  inventario     = boInventario.Seleccionar(codigoproducto);
         TxtProducto.Text     = DgvProducto.CurrentRow.Cells[4].Value.ToString();
         TxtExistencias.Text  = inventario.Existencias.ToString();
         txtPrecioCompra.Text = inventario.ValorUnitario.ToString("N2");
         double precioventa = Math.Round((inventario.ValorUnitario * FrmPrincipal.ValorUtilidad), 2);
         TxtPrecioVenta.Text = precioventa.ToString("N2");
     }
     catch
     {
         //
     }
 }
Пример #8
0
 private void TxtProducto_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == Convert.ToChar(Keys.Enter))
     {
         if (string.IsNullOrEmpty(TxtProducto.Text))
         {
             MessageBox.Show("Ingrese Código del Producto", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             DProducto boProducto = new DProducto();
             Producto  producto   = boProducto.Seleccionar(TxtProducto.Text);
             if (string.IsNullOrEmpty(producto.Codigo))
             {
                 MessageBox.Show("No Existe Producto", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
             else
             {
                 DInventario boInventario = new DInventario();
                 Inventario  inventario   = boInventario.Seleccionar(producto.Codigo);
                 if (!string.IsNullOrEmpty(inventario.Producto))
                 {
                     if (inventario.Existencias > 0)
                     {
                         double utilidad    = FrmPrincipal.ValorUtilidad;
                         double precioventa = Math.Round((inventario.ValorUnitario * utilidad), 2);
                         AddItems(producto, 1, precioventa);
                         //Mostrar imagen
                         if (!string.IsNullOrEmpty(producto.Imagen))
                         {
                             PbxImgProducto.Image = Image.FromFile(CarpetaImagen + "/" + producto.Imagen);
                         }
                     }
                     else
                     {
                         MessageBox.Show("No hay Cantidad Suficiente");
                     }
                 }
             }
         }
     }
 }
Пример #9
0
        private void Buscar(string KeyWords)
        {
            DInventario bo = new DInventario();

            DgvInventarioSingle.DataSource = bo.Buscar(KeyWords);
        }
Пример #10
0
        private void Listar()
        {
            DInventario bo = new DInventario();

            DgvInventarioSingle.DataSource = bo.Listar();
        }
Пример #11
0
        private void GuardarVenta()
        {
            string tipocomprobante  = CbxTipoComprobante.SelectedValue.ToString();
            string ventaserie       = "####";
            string ventacorrelativo = "########";
            DVenta venta            = new DVenta();

            if (venta.ObtenerSerieCorrelativo(tipocomprobante) != null)
            {
                DataRow row = venta.ObtenerSerieCorrelativo(tipocomprobante);
                ventaserie       = row["Serie"].ToString();
                ventacorrelativo = row["Correlativo"].ToString();
            }
            Venta beVenta = new Venta
            {
                Cliente         = Convert.ToInt32(LblIDCliente.Text),
                Empleado        = FrmPrincipal.AccesoUsernameID,
                TipoComprobante = tipocomprobante,
                Serie           = ventaserie,
                Numero          = ventacorrelativo,
                Fecha           = Convert.ToDateTime(DateTime.Now),
                Hora            = Convert.ToDateTime(DateTime.Now),
                SubTotal        = Venta_SubTotal,
                Igv             = Venta_Igv,
                Total           = Venta_Total,
                Estado          = 1
            };
            DVenta boVenta = new DVenta();

            if (boVenta.Agregar(beVenta) == true)
            {
                if (MLVDetalle.Items.Count > 0)
                {
                    DDetalleVenta boDetalleVenta = new DDetalleVenta();
                    foreach (ListViewItem items in MLVDetalle.Items)
                    {
                        DetalleVenta beDetalleVenta = new DetalleVenta
                        {
                            Serie    = beVenta.Serie,
                            Numero   = beVenta.Numero,
                            Producto = items.SubItems[0].Text,
                            Precio   = Convert.ToDouble(items.SubItems[3].Text),
                            Cantidad = Convert.ToInt32(items.SubItems[4].Text),
                            Importe  = Convert.ToDouble(items.SubItems[5].Text)
                        };
                        //Agregar dettalle compra
                        if (boDetalleVenta.Agregar(beDetalleVenta) == true)
                        {
                            int    cantidadfinal      = 0;
                            double costounitariofinal = 0;
                            double costototalfinal    = 0;
                            //Obteniendo Ultimo Movimiento
                            DMovimiento boM   = new DMovimiento();
                            Movimiento  datos = boM.SeleccionarUltimoMovimientoProducto(beDetalleVenta.Producto);
                            if (!string.IsNullOrEmpty(datos.Producto))
                            {
                                //Si hay datos
                                cantidadfinal      = datos.CantidadFinal - beDetalleVenta.Cantidad;
                                costounitariofinal = datos.CostoUnitarioFinal;
                                double costofinaly = Math.Round((costounitariofinal * beDetalleVenta.Cantidad), 2);
                                costototalfinal = datos.CostoTotalFinal - costofinaly;
                                //Movimiento
                                Movimiento beMovimiento = new Movimiento
                                {
                                    Fecha                = DateTime.Now,
                                    TipoComprobante      = beVenta.TipoComprobante,
                                    Serie                = beVenta.Serie,
                                    Numero               = beVenta.Numero,
                                    TipoOperacion        = "01",
                                    Producto             = beDetalleVenta.Producto,
                                    CantidadEntrada      = 0,
                                    CostoUnitarioEntrada = 0,
                                    CostoTotalEntrada    = 0,

                                    CantidadSalida      = beDetalleVenta.Cantidad,
                                    CostoUnitarioSalida = costounitariofinal,
                                    CostoTotalSalida    = costofinaly,

                                    CantidadFinal      = cantidadfinal,
                                    CostoUnitarioFinal = costounitariofinal,
                                    CostoTotalFinal    = costototalfinal
                                };
                                DMovimiento boMovimiento = new DMovimiento();
                                if (boMovimiento.Agregar(beMovimiento) == true)
                                {
                                    Inventario beInventario = new Inventario
                                    {
                                        Producto        = beMovimiento.Producto,
                                        ValorUnitario   = beMovimiento.CostoUnitarioFinal,
                                        Existencias     = beMovimiento.CantidadFinal,
                                        ValorInventario = beMovimiento.CostoTotalFinal
                                    };
                                    DInventario boInventario = new DInventario();
                                    boInventario.Modificar(beInventario);
                                }
                            }
                        }
                    }
                }
                //message
                FrmVentas frm = Owner as FrmVentas;
                frm.Listar();
                Close();
                FrmPrincipal.Main.ChangeMessage("La Venta se ingreso correctamente", "Success");
            }
            else
            {
                FrmPrincipal.Main.ChangeMessage("Algo salio mal", "Failed");
            }
        }
Пример #12
0
        private void GuardarCompra()
        {
            Compra beCompra = new Compra
            {
                Proveedor       = Convert.ToInt32(LblIDProveedor.Text),
                Empleado        = FrmPrincipal.AccesoUsernameID,
                TipoComprobante = CbxTipoComprobante.SelectedValue.ToString(),
                Serie           = TxtSerie.Text,
                Numero          = TxtNumero.Text,
                Fecha           = Convert.ToDateTime(DtpFecha.Text),
                SubTotal        = Compra_SubTotal,
                Igv             = Compra_Igv,
                Total           = Compra_Total,
                Estado          = 1
            };
            DCompra boCompra = new DCompra();

            if (boCompra.Agregar(beCompra) == true)
            {
                if (MLVDetalle.Items.Count > 0)
                {
                    DDetalleCompra boDetalleCompra = new DDetalleCompra();
                    foreach (ListViewItem items in MLVDetalle.Items)
                    {
                        DetalleCompra beDetalleCompra = new DetalleCompra
                        {
                            Serie          = beCompra.Serie,
                            Numero         = beCompra.Numero,
                            Producto       = items.SubItems[0].Text,
                            PrecioUnitario = Convert.ToDouble(items.SubItems[3].Text),
                            Cantidad       = Convert.ToInt32(items.SubItems[4].Text),
                            PrecioTotal    = Convert.ToDouble(items.SubItems[5].Text)
                        };
                        //Agregar dettalle compra
                        if (boDetalleCompra.Agregar(beDetalleCompra) == true)
                        {
                            int    cantidadfinal      = 0;
                            double costounitariofinal = 0;
                            double costototalfinal    = 0;
                            //Obteniendo Ultimo Movimiento
                            DMovimiento boM   = new DMovimiento();
                            Movimiento  datos = boM.SeleccionarUltimoMovimientoProducto(beDetalleCompra.Producto);
                            if (string.IsNullOrEmpty(datos.Producto))
                            {
                                cantidadfinal      = beDetalleCompra.Cantidad;
                                costounitariofinal = beDetalleCompra.PrecioUnitario;
                                costototalfinal    = beDetalleCompra.PrecioTotal;
                            }
                            else
                            {
                                //Si hay datos
                                cantidadfinal      = datos.CantidadFinal + beDetalleCompra.Cantidad;
                                costototalfinal    = datos.CostoTotalFinal + beDetalleCompra.PrecioTotal;
                                costounitariofinal = Math.Round((costototalfinal / cantidadfinal), 2);
                            }
                            Movimiento beMovimiento = new Movimiento
                            {
                                Fecha                = DateTime.Now,
                                TipoComprobante      = beCompra.TipoComprobante,
                                Serie                = beCompra.Serie,
                                Numero               = beCompra.Numero,
                                TipoOperacion        = "02",
                                Producto             = beDetalleCompra.Producto,
                                CantidadEntrada      = beDetalleCompra.Cantidad,
                                CostoUnitarioEntrada = beDetalleCompra.PrecioUnitario,
                                CostoTotalEntrada    = beDetalleCompra.PrecioTotal,
                                CantidadSalida       = 0,
                                CostoUnitarioSalida  = 0,
                                CostoTotalSalida     = 0,
                                CantidadFinal        = cantidadfinal,
                                CostoUnitarioFinal   = costounitariofinal,
                                CostoTotalFinal      = costototalfinal
                            };
                            DMovimiento boMovimiento = new DMovimiento();
                            if (boMovimiento.Agregar(beMovimiento) == true)
                            {
                                Inventario beInventario = new Inventario
                                {
                                    Producto        = beMovimiento.Producto,
                                    ValorUnitario   = beMovimiento.CostoUnitarioFinal,
                                    Existencias     = beMovimiento.CantidadFinal,
                                    ValorInventario = beMovimiento.CostoTotalFinal
                                };
                                DInventario boInventario = new DInventario();
                                boInventario.Modificar(beInventario);
                            }
                        }
                    }
                }
                //message
                FrmCompras frm = Owner as FrmCompras;
                frm.Listar();
                Close();
                FrmPrincipal.Main.ChangeMessage("La Compra se ingreso correctamente", "Success");
            }
            else
            {
                FrmPrincipal.Main.ChangeMessage("Algo salio mal", "Failed");
            }
        }