public ActionResult generarCotizacionTBL(int id = 0)
        {
            DataTableModels dataTable = new DataTableModels();

            dataTable.draw = 1;
            var reader = BaseController.ObtenerDatos("CalculoCotizacion " + id.ToString());
            List <CotizacionModels> listaProductos = new List <CotizacionModels>();

            while (reader.Read())
            {
                CotizacionModels c = new CotizacionModels
                {
                    Proveedor   = reader["PROVEEDOR"].ToString(),
                    Producto    = reader["NombreProducto"].ToString(),
                    ValorPesos  = (int)(Int64)reader["VALOR_PESOS"],
                    ValorCambio = Convert.ToDateTime(reader["FechaCambio"]).ToString("dd-MM-yyyy")
                };
                listaProductos.Add(c);
            }

            dataTable.data            = listaProductos.ToArray();
            dataTable.recordsTotal    = listaProductos.Count;
            dataTable.recordsFiltered = listaProductos.Count();
            return(Json(dataTable, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public ActionResult CotizacionesTBL()
        {
            var             Rangofechas    = Request.Form[29];
            string          IDsProveedores = Request.Form[30];
            DataTableModels dataTable      = new DataTableModels
            {
                draw = 1
            };
            var reader = BaseController.ObtenerDatos("SP_MasCotizados '" + Rangofechas.ToString() + "','" + IDsProveedores.ToString() + "'");
            List <CotizacionModels> listaProductos = new List <CotizacionModels>();

            while (reader.Read())
            {
                CotizacionModels c = new CotizacionModels
                {
                    Proveedor  = reader["PROVEEDOR"].ToString(),
                    Producto   = reader["NombreProducto"].ToString(),
                    ValorPesos = (int)(Int64)reader["VALOR_PESOS"],
                    Total      = Convert.ToInt32(reader["TOTAL"]),
                };
                listaProductos.Add(c);
            }
            Conexion.Cerrar();
            dataTable.data            = listaProductos.ToArray();
            dataTable.recordsTotal    = listaProductos.Count;
            dataTable.recordsFiltered = listaProductos.Count();
            return(Json(dataTable, JsonRequestBehavior.AllowGet));
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            CotizacionModels CotizacionModels = await db.CotizacionModels.FindAsync(id);

            db.CotizacionModels.Remove(CotizacionModels);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,UsuarioId,ClienteId,ValorTotal")] CotizacionModels CotizacionModels)
        {
            CotizacionModels.UsuarioId  = User.Identity.GetUserId();
            CotizacionModels.ValorTotal = 0;

            db.CotizacionModels.Add(CotizacionModels);
            await db.SaveChangesAsync();

            return(RedirectToAction("Edit/" + CotizacionModels.Id));
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,UsuarioId,ClienteId,ValorTotal")] CotizacionModels CotizacionModels)
        {
            if (ModelState.IsValid)
            {
                db.Entry(CotizacionModels).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.ClienteId = new SelectList(db.ClienteModels, "ClienteId", "Nombre", CotizacionModels.ClienteId);
            return(View(CotizacionModels));
        }
        // GET: Cotizacion/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CotizacionModels CotizacionModels = await db.CotizacionModels.FindAsync(id);

            if (CotizacionModels == null)
            {
                return(HttpNotFound());
            }
            return(View(CotizacionModels));
        }
        // GET: Cotizacion/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CotizacionModels CotizacionModels = await db.CotizacionModels.FindAsync(id);

            if (CotizacionModels == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ClienteId = new SelectList(db.ClienteModels, "ClienteId", "Nombre", CotizacionModels.ClienteId);
            return(View(CotizacionModels));
        }