Пример #1
0
 private bool UpdateDatos(int pId)
 {
     try
     {
         using (var db = new PosDbEntities())
         {
             var buscaObjeto = db.SERVICIOS.FirstOrDefault(c => c.ID == pId);
             if (buscaObjeto == null)
             {
                 return(false);
             }
             buscaObjeto.CODIGO      = Codigo;// Convert.ToDateTime(txtfechanacimiento.Text);
             buscaObjeto.NOMBRE      = Nombre;
             buscaObjeto.DESCRIPCION = Descripcion;
             // buscaObjeto.PRECIO = Convert.ToDecimal( txtPrecio.Text);
             buscaObjeto.NOTAS = Notas;
             // buscaObjeto.COSTO = Convert.ToDecimal(txtCosto.Text);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #2
0
        public DataTable DevuelveCarritoArreglado(int id, int pCantidad, DataTable carrito)
        {
            DataTable table;
            var       cantidad = 0;

            if (carrito == null)
            {
                table = new DataTable();
                table.Columns.AddRange(new [] {
                    new DataColumn("ID"),
                    new DataColumn("Codigo"),
                    new DataColumn("Nombre"),
                    new DataColumn("Descripcion"),
                    new DataColumn("Precio")
                    {
                        DataType = Type.GetType("System.Decimal")
                    },
                    new DataColumn("Cantidad"),
                    new DataColumn("Subtotal")
                    {
                        DataType = Type.GetType("System.Decimal")
                    }
                });
            }
            else
            {
                table = carrito;

                var productoExiste = table.AsEnumerable().FirstOrDefault(r => r.Field <string>("ID") == id.ToString());
                if (productoExiste != null)
                {
                    cantidad = Convert.ToInt32(productoExiste["Cantidad"]);
                    productoExiste.Delete();
                }
            }
            cantidad += pCantidad;

            if ((CantidadDisponible(id) - cantidad) < 0)
            {
                return(null);
            }

            var db       = new PosDbEntities();
            var producto = db.SERVICIOS.FirstOrDefault(p => p.ID == id);

            if (producto == null)
            {
                return(null);
            }
            {
                var subTotal = (decimal)(Convert.ToDouble(producto.PRECIO) * cantidad);
                table.Rows.Add(id, producto.CODIGO, producto.NOMBRE, producto.DESCRIPCION, producto.PRECIO, cantidad, subTotal);
            }

            return(table);
        }
Пример #3
0
        public int CantidadDisponible(int productoId)
        {
            var db       = new PosDbEntities();
            var producto = db.SERVICIOS.FirstOrDefault(p => p.ID == productoId);

            if (producto == null)
            {
                return(0);
            }
            {
                return(producto.STOCK != null?Convert.ToInt32(producto.STOCK.Value) : 0);
            }
        }
Пример #4
0
        private bool InsertDatos(int pId)
        {
            //UploadFile(fuImagen);
            // int autor = Convert.ToInt32(Session["userAutor"]);
            //   int userID = Convert.ToInt32(Session["userId"]);

            //  int sucursal = Convert.ToInt32(Session["usrSucursal"]);
            //Creando los datos generales del socio en la tabla personas
            try
            {
                using (var db = new PosDbEntities())
                {
                    var datosObjeto = new SERVICIOS
                    {
                        CODIGO      = Codigo,
                        BARCODE     = BarCode,
                        CATEGORIAID = Categoriaid,
                        NOMBRE      = Nombre,
                        DESCRIPCION = Descripcion,
                        NOTAS       = Notas,
                        AUTORID     = Autorid,
                        SUCURSALID  = Sucursalid
                    };
                    // IMAGEN = fuImagen.FileName
                    //  PRECIO = Convert.ToDecimal(txtPrecio.Text),
                    //
                    //   COSTO = Convert.ToDecimal(txtCosto.Text),
                    // STOCK = Convert.ToInt32(txtStock.Text),
                    db.SERVICIOS.Add(datosObjeto);
                    db.SaveChanges();
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }