From 054f85de36d20ccc436da53892198673518c5dcd Mon Sep 17 00:00:00 2001 From: hogan Date: Sat, 26 Jan 2019 01:10:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=A3=E7=B1=BB=E5=9E=8B=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Examples/website/FreeSql.Site.DAL/BaseDAL.cs | 3 +- .../Admin/Controllers/DocumentController.cs | 38 ++-- .../Admin/Views/Document/DocContent.cshtml | 12 +- .../Areas/Admin/Views/Document/DocType.cshtml | 188 ++++++++++++------ .../Views/Document/DocTypeEditModule.cshtml | 39 ++++ .../Areas/Admin/Views/Document/Index.cshtml | 28 +-- .../FreeSql.Site.UI/wwwroot/css/admin.css | 15 +- .../FreeSql.Site.UI/wwwroot/js/common.js | 38 +++- 8 files changed, 249 insertions(+), 112 deletions(-) create mode 100644 Examples/website/FreeSql.Site.UI/Areas/Admin/Views/Document/DocTypeEditModule.cshtml diff --git a/Examples/website/FreeSql.Site.DAL/BaseDAL.cs b/Examples/website/FreeSql.Site.DAL/BaseDAL.cs index 8b335872..0b22d21d 100644 --- a/Examples/website/FreeSql.Site.DAL/BaseDAL.cs +++ b/Examples/website/FreeSql.Site.DAL/BaseDAL.cs @@ -27,7 +27,8 @@ namespace FreeSql.Site.DAL /// public virtual bool Update(T model) { - return DataBaseType.MySql.DB().Update(model.ID).ExecuteUpdated().Count > 0; + var runsql = DataBaseType.MySql.DB().Update().SetSource(model); + return runsql.ExecuteAffrows() > 0; } /// diff --git a/Examples/website/FreeSql.Site.UI/Areas/Admin/Controllers/DocumentController.cs b/Examples/website/FreeSql.Site.UI/Areas/Admin/Controllers/DocumentController.cs index 8704242d..b1cee18f 100644 --- a/Examples/website/FreeSql.Site.UI/Areas/Admin/Controllers/DocumentController.cs +++ b/Examples/website/FreeSql.Site.UI/Areas/Admin/Controllers/DocumentController.cs @@ -118,7 +118,7 @@ namespace FreeSql.Site.UI.Areas.Admin.Controllers } [HttpPost] - [ValidateAntiForgeryToken] + //[ValidateAntiForgeryToken] public ActionResult DocContentDelete(int id, IFormCollection collection) { var resdata = AutoException.Excute((result) => @@ -175,13 +175,25 @@ namespace FreeSql.Site.UI.Areas.Admin.Controllers }); } - public ActionResult DocTypeEditModule(string id) + public ActionResult DocTypeEditModule(string id, bool ischildren) { + ViewBag.DocumentTypeList = DocumentTypeDAL.Query(w => w.Status == 1).list.Select(s => new SelectListItem { Text = s.TypeName, Value = s.ID.ToString() }).ToList(); + DocumentType model = new DocumentType(); - if (!string.IsNullOrEmpty(id)) + if (ischildren) { - int _id = Convert.ToInt32(id); - model = DocumentTypeDAL.GetByOne(w => w.ID == _id); + if (!string.IsNullOrEmpty(id)) + { + model.UpID = Convert.ToInt32(id); + } + } + else + { + if (!string.IsNullOrEmpty(id)) + { + int _id = Convert.ToInt32(id); + model = DocumentTypeDAL.GetByOne(w => w.ID == _id); + } } return View(model); } @@ -189,11 +201,13 @@ namespace FreeSql.Site.UI.Areas.Admin.Controllers // POST: Documents/Create [HttpPost] //[ValidateAntiForgeryToken] - public ActionResult DocTypeCreate([FromBody]DocumentContent model) + public ActionResult DocTypeCreate([FromBody]DocumentType model) { var resdata = AutoException.Excute((result) => { - result.Data = DocumentContentDAL.Insert(model); + model.CreateBy = "admin"; + model.CreateDt = DateTime.Now; + result.Data = DocumentTypeDAL.Insert(model); if (result.Data == 0) { throw new Exception("数据新增异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model)); @@ -205,13 +219,13 @@ namespace FreeSql.Site.UI.Areas.Admin.Controllers // POST: Documents/Create [HttpPost] //[ValidateAntiForgeryToken] - public ActionResult DocTypeUpdate([FromBody]DocumentContent model) + public ActionResult DocTypeUpdate([FromBody]DocumentType model) { var resdata = AutoException.Excute((result) => { model.UpdateBy = "admin"; model.UpdateDt = DateTime.Now; - result.Data = DocumentContentDAL.Update(model); + result.Data = DocumentTypeDAL.Update(model); if (result.Data == false) { throw new Exception("数据新增异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model)); @@ -220,13 +234,13 @@ namespace FreeSql.Site.UI.Areas.Admin.Controllers return Json(resdata); } - [HttpPost] - [ValidateAntiForgeryToken] + [HttpPost] + //[ValidateAntiForgeryToken] public ActionResult DocTypeDelete(int id, IFormCollection collection) { var resdata = AutoException.Excute((result) => { - if (!DocumentContentDAL.Delete(id)) + if (!DocumentTypeDAL.Delete(id)) { throw new Exception("数据删除异常,ID:" + id); } diff --git a/Examples/website/FreeSql.Site.UI/Areas/Admin/Views/Document/DocContent.cshtml b/Examples/website/FreeSql.Site.UI/Areas/Admin/Views/Document/DocContent.cshtml index e2ff0029..5f068d35 100644 --- a/Examples/website/FreeSql.Site.UI/Areas/Admin/Views/Document/DocContent.cshtml +++ b/Examples/website/FreeSql.Site.UI/Areas/Admin/Views/Document/DocContent.cshtml @@ -6,7 +6,11 @@ - +
+ +
+ + +