public int Load(string file) { int rows = 0; EProductType eProductType = null; BProductType bProductType = new BProductType(); List <string> columns = new List <string>(); DataTable table = Epplus.ToDataTable(file); if (table != null) { table.Columns["Código"].ColumnName = "CodeProductType"; table.Columns["Descripción"].ColumnName = "Description"; table.Columns["Código Sunat"].ColumnName = "CodeSunatExistence"; table.Columns["Estado"].ColumnName = "State"; columns = table.GetColumns(); using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required)) { foreach (DataRow datarow in table.Rows) { eProductType = new EProductType(datarow, columns); eProductType.Audit.UserRegister = "User Load"; bProductType.Insert(eProductType); rows++; } ts.Complete(); } } return(rows); }
public async Task <IActionResult> PutBProductType([FromRoute] int id, [FromBody] BProductType bProductType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != bProductType.TypeId) { return(BadRequest()); } _context.Entry(bProductType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BProductTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostBProductType([FromBody] BProductType bProductType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.BProductType.Add(bProductType); await _context.SaveChangesAsync(); return(CreatedAtAction("GetBProductType", new { id = bProductType.TypeId }, bProductType)); }
// // GET: /Admin/KaMi/ public ActionResult Index() { if (Session["admin_User"] == null) { return(RedirectToRoute(new { controller = "Account", action = "Login", area = "" })); } List <ProductTypeViewModel> lstRes = BProductType.SearchAll(); ViewBag.option = lstRes; ViewBag.title = "卡密管理"; return(View()); }
public JsonResult GetProductTypes(int limit, int offset, string departmentname) { List <ProductTypeViewModel> lstRes = null; if (!string.IsNullOrEmpty(departmentname)) { lstRes = BProductType.SearchBysql(departmentname); } else { lstRes = BProductType.SearchAll(); } var total = lstRes.Count; var rows = lstRes.Skip(offset).Take(limit).ToList(); return(Json(new { total = total, rows = rows }, JsonRequestBehavior.AllowGet)); }
public ActionResult Delete() { string name = Request.Form["pId"]; List <DeleteId> models = LitJson.JsonMapper.ToObject <List <DeleteId> >(name); if (models == null) { return(Content(ReturnMsg.fail.ToString())); } bool isSucc = BProductType.Delete(models.Select(_ => _.Id).ToList()); if (isSucc) { return(Content(ReturnMsg.success.ToString())); } else { return(Content(ReturnMsg.fail.ToString())); } }
public ActionResult Add() { string name = Request.Form["proT"]; if (string.IsNullOrEmpty(name)) { return(Content(ReturnMsg.empty.ToString())); } ProductTypeViewModel model = new ProductTypeViewModel(); model.ProductName = name; model.UpdateTime = DateTime.Now; bool isSucc = BProductType.Insert(model); if (isSucc) { return(Content(ReturnMsg.success.ToString())); } else { return(Content(ReturnMsg.fail.ToString())); } }
public ActionResult Update() { string newName = Request.Form["proM"]; ProductTypeViewModel model = LitJson.JsonMapper.ToObject <ProductTypeViewModel>(newName); model.UpdateTime = DateTime.Now; if (model == null) { return(Content(ReturnMsg.fail.ToString())); } if (string.IsNullOrEmpty(model.ProductName)) { return(Content(ReturnMsg.empty.ToString())); } if (BProductType.Update(model)) { return(Content(ReturnMsg.success.ToString())); } else { return(Content(ReturnMsg.fail.ToString())); } }