public ActionResult Create([Bind(Include = "idBranch,BranchNumber")] Branches branches) { if (ModelState.IsValid) { db.Branches.Add(branches); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(branches)); }
public ActionResult Create([Bind(Include = "idMachinist,FIO,DateBirth,Address,Category,Telephone")] Machinist machinist) { if (ModelState.IsValid) { db.Machinist.Add(machinist); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(machinist)); }
public ActionResult Create([Bind(Include = "idShipment,ShipmentName,Sender")] Shipment shipment) { if (ModelState.IsValid) { db.Shipment.Add(shipment); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(shipment)); }
public ActionResult Create([Bind(Include = "idLoco,LocoName,State")] Locos locos) { if (ModelState.IsValid) { db.Locos.Add(locos); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(locos)); }
public ActionResult Create([Bind(Include = "idMaterial,NameMaterial")] RawMaterials rawMaterials) { if (ModelState.IsValid) { db.RawMaterials.Add(rawMaterials); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(rawMaterials)); }
public ActionResult Create([Bind(Include = "idRailway,RailwayType,RailwayName")] Railway railway) { if (ModelState.IsValid) { db.Railway.Add(railway); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(railway)); }
public ActionResult Create([Bind(Include = "UserId,RoleId,UserRoleId")] AspNetUserRoles aspNetUserRoles) { if (ModelState.IsValid) { db.AspNetUserRoles.Add(aspNetUserRoles); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RoleId = new SelectList(db.AspNetRoles, "Id", "Name", aspNetUserRoles.RoleId); ViewBag.UserId = new SelectList(db.AspNetUsers, "Id", "Email", aspNetUserRoles.UserId); return(View(aspNetUserRoles)); }
public ActionResult Create([Bind(Include = "idCargo,idShipment,Number,Weight,State,idRawMaterial")] Cargo cargo) { if (ModelState.IsValid) { db.Cargo.Add(cargo); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.idRawMaterial = new SelectList(db.RawMaterials, "idMaterial", "NameMaterial", cargo.idRawMaterial); ViewBag.idShipment = new SelectList(db.Shipment, "idShipment", "Sender", cargo.idShipment); return(View(cargo)); }
public ActionResult Create([Bind(Include = "idSupply,idRailway,idShipment,idMachinist,DateofDelivery,idLoco,DateofDeparture,idBranch")] Supply supply) { if (ModelState.IsValid) { db.Supply.Add(supply); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.idLoco = new SelectList(db.Locos, "idLoco", "LocoName", supply.idLoco); ViewBag.idRailway = new SelectList(db.Railway, "idRailway", "RailwayType", supply.idRailway); ViewBag.idShipment = new SelectList(db.Shipment, "idShipment", "ShipmentName", supply.idShipment); ViewBag.idMachinist = new SelectList(db.Machinist, "idMachinist", "FIO", supply.idMachinist); return(View(supply)); }
public ActionResult Import(HttpPostedFileBase excelfile) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); if (excelfile == null || excelfile.ContentLength == 0) { ViewBag.Error = "Файл не выбран! <br>"; return(View("Index", db.AspNetUsers.ToList())); } else { if (excelfile.FileName.EndsWith("xls") || excelfile.FileName.EndsWith("xlsx")) { db = new TTCEntities(); string path = Server.MapPath("~/Import/" + excelfile.FileName); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } excelfile.SaveAs(path); //Читаем из файла // Excel.Application ap = new Excel.Application(); Excel.Application application = new Excel.Application(); Excel.Workbook workbook = application.Workbooks.Open(path); Excel.Worksheet worksheet = workbook.ActiveSheet; Excel.Range range = worksheet.UsedRange; List <Machinist> listUsers = new List <Machinist>(); for (int row = 2; row <= range.Rows.Count; row++) { Machinist user = new Machinist(); user.FIO = ((Excel.Range)range.Cells[row, 1]).Text; user.Address = ((Excel.Range)range.Cells[row, 2]).Text; user.Telephone = ((Excel.Range)range.Cells[row, 3]).Text; db.Machinist.Add(user); db.SaveChanges(); } workbook.Close(); ViewBag.Error = "Данные загружены <br>"; return(View("Index", db.Machinist.ToList())); } else { ViewBag.Error = "Это не Excel! <br>"; return(View("Index", db.Machinist.ToList())); } } }