コード例 #1
0
        public ActionResult ListaPlantilla([Bind(Include = "PC_Id,PC_Nom")] planillascontratos planillascontratos, HttpPostedFileBase plantilla)
        {
            if (plantilla != null && plantilla.ContentLength > 0)
            {
                var length = plantilla.InputStream.Length;



                byte[] datoplantilla = null;

                using (var binarydoc = new BinaryReader(plantilla.InputStream))
                {
                    datoplantilla = binarydoc.ReadBytes(plantilla.ContentLength);
                }
                planillascontratos.PC_Binario = datoplantilla;
                planillascontratos.PC_Ext     = Path.GetExtension(plantilla.FileName);
            }



            if (ModelState.IsValid)
            {
                //planillascontratos.PC_Ext =".docx";
                db.planillascontratos.Add(planillascontratos);


                db.SaveChanges();
                return(RedirectToAction("Index"));
            }


            return(View(planillascontratos));
        }
コード例 #2
0
        public ActionResult Index([Bind(Include = "PC_Id,PC_Nom,empcar_id")] planillascontratos planillascontratos, HttpPostedFileBase plantilla)
        {
            if (plantilla != null && plantilla.ContentLength > 0)
            {
                var length = plantilla.InputStream.Length; //Length: 103050706


                byte[] datoplantilla = null;
                using (var binarydoc = new BinaryReader(plantilla.InputStream))
                {
                    datoplantilla = binarydoc.ReadBytes(plantilla.ContentLength);
                }
                planillascontratos.PC_Binario = datoplantilla;
                planillascontratos.PC_Ext     = Path.GetExtension(plantilla.FileName);
            }

            var empresa_Cargo = db.empresa_cargo.Find(planillascontratos.empcar_id);

            if (ModelState.IsValid)
            {
                //planillascontratos.PC_Ext =".docx";
                db.planillascontratos.Add(planillascontratos);

                empresa_Cargo.PC_Id           = planillascontratos.PC_Id;
                db.Entry(empresa_Cargo).State = EntityState.Modified;

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }


            return(View(planillascontratos));
        }
コード例 #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            planillascontratos planillascontratos = db.planillascontratos.Find(id);

            db.planillascontratos.Remove(planillascontratos);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #4
0
 public ActionResult Edit([Bind(Include = "PC_Id,PC_Nom,PC_Ext,PC_Binario")] planillascontratos planillascontratos)
 {
     if (ModelState.IsValid)
     {
         db.Entry(planillascontratos).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(planillascontratos));
 }
コード例 #5
0
        // GET: planillascontratos/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            planillascontratos planillascontratos = db.planillascontratos.Find(id);

            if (planillascontratos == null)
            {
                return(HttpNotFound());
            }
            return(View(planillascontratos));
        }
コード例 #6
0
        public ActionResult Create([Bind(Include = "PC_Id,PC_Nom")] planillascontratos planillascontratos, HttpPostedFileBase plantilla)
        {
            if (plantilla != null && plantilla.ContentLength > 0)
            {
                var length = plantilla.InputStream.Length; //Length: 103050706


                byte[] datoplantilla = null;
                using (var binarydoc = new BinaryReader(plantilla.InputStream))
                {
                    datoplantilla = binarydoc.ReadBytes(plantilla.ContentLength);
                }
                planillascontratos.PC_Binario = datoplantilla;
                planillascontratos.PC_Ext     = Path.GetExtension(plantilla.FileName);
            }

            if (ModelState.IsValid)
            {
                //planillascontratos.PC_Ext =".docx";


                try
                {
                    db.planillascontratos.Add(planillascontratos);
                    db.SaveChanges();

                    TempData["sms"] = "Se guardo la plantilla";
                    ViewBag.sms     = TempData["sms"];
                    return(RedirectToAction("Index"));
                }
                catch
                {
                    TempData["smserror"] = "No se pudo guardar la plantilla";
                    ViewBag.smserror     = TempData["smserror"];
                    return(RedirectToAction("Index"));
                }
            }

            return(View(planillascontratos));
        }
コード例 #7
0
        public ActionResult Create([Bind(Include = "PC_Id,PC_Nom")] planillascontratos planillascontratos, HttpPostedFileBase plantilla)
        {
            if (plantilla != null && plantilla.ContentLength > 0)
            {
                var length = plantilla.InputStream.Length; //Length: 103050706

                byte[] datoplantilla = null;
                using (var binaryImage = new BinaryReader(plantilla.InputStream))
                {
                    datoplantilla = binaryImage.ReadBytes(plantilla.ContentLength);
                }
                planillascontratos.PC_Binario = datoplantilla;
            }

            if (ModelState.IsValid)
            {
                planillascontratos.PC_Ext = ".docx";
                db.planillascontratos.Add(planillascontratos);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(planillascontratos));
        }