using Lib; using System.Web.Mvc; using System.Web.Script.Serialization; using Model; using BLL.DAL; using System.Linq; using System.Collections.Generic; using Common; using Json; using System.Collections; using System; namespace wms.Areas.BasicInfo.Controllers { public class DepotsLocationController : MasterPage { // GET: BasicInfo/DepotsLocation [LoginFilter] public ActionResult Index() { ViewBag.Title = "库位管理"; ViewBag.DepotsArea = LocalHelper.GetDepotsAreaHtml(); ViewBag.DepotsRow = LocalHelper.GetDepotsNumHtml("DepotsRow"); ViewBag.DepotsColumn = LocalHelper.GetDepotsNumHtml("DepotsColumn"); ViewBag.DepotsLayer = LocalHelper.GetDepotsNumHtml("DepotsLayer"); ViewBag.Property = LocalHelper.GetDictionaryCodeHtml("Property"); ViewBag.TurnoverDemand = LocalHelper.GetDictionaryCodeHtml("TurnoveDemand","-03"); ViewBag.Type = LocalHelper.GetDictionaryCodeHtml("Type"); return View(); } [LoginFilter] public ActionResult AddEdit() { try { string Guid = Request.QueryString.Get("Guid"); DALDepotsLocation depotsLocation = new DALDepotsLocation(); if (Guid != null && Guid != "") { DepotsLocation dLocation = depotsLocation.GetDepotsLocationItems(Guid)[0]; ViewBag.LocationCode = dLocation.LocationCode; ViewBag.DepotsArea = LocalHelper.GetDepotsAreaHtml(dLocation.DepotsAreaID); ViewBag.LRow = LocalHelper.GetDepotsNumHtml("DepotsRow", dLocation.DepotsAreaID, dLocation.LRow); ViewBag.LColumn = LocalHelper.GetDepotsNumHtml("DepotsColumn", dLocation.DepotsAreaID, dLocation.LColumn); ViewBag.LLayer = LocalHelper.GetDepotsNumHtml("DepotsLayer", dLocation.DepotsAreaID, dLocation.LLayer); ViewBag.Type = LocalHelper.GetDictionaryCodeHtml("Type", dLocation.TypeID); ViewBag.Property = LocalHelper.GetDictionaryCodeHtml("Property", dLocation.PropertyID); ViewBag.TurnoverDemand = LocalHelper.GetDictionaryCodeHtml("TurnoveDemand", dLocation.TurnoverDemandID); ViewBag.Weight = dLocation.Weight; ViewBag.Volume = dLocation.Volume; ViewBag.Long = dLocation.Long; ViewBag.Width = dLocation.Width; ViewBag.Height = dLocation.Height; ViewBag.NumPlies = dLocation.NumPlies; ViewBag.IsBatch = "name='IsBatch'"; if (dLocation.IsBatch == 0) { ViewBag.IsBatch = "name='IsBatch' checked='checked'"; } ViewBag.IsProduct = "name='IsProduct'"; if (dLocation.IsProduct == 0) { ViewBag.IsProduct = "name='IsProduct' checked='checked'"; } ViewBag.Demo = dLocation.Demo; } else { ViewBag.LocationCode = ""; ViewBag.DepotsArea = LocalHelper.GetDepotsAreaHtml(); ViewBag.LRow = LocalHelper.GetDepotsNumHtml("DepotsRow"); ViewBag.LColumn = LocalHelper.GetDepotsNumHtml("DepotsColumn"); ViewBag.LLayer = LocalHelper.GetDepotsNumHtml("DepotsLayer"); ViewBag.Type = LocalHelper.GetDictionaryCodeHtml("Type"); ViewBag.Property = LocalHelper.GetDictionaryCodeHtml("Property"); ViewBag.TurnoverDemand = LocalHelper.GetDictionaryCodeHtml("TurnoveDemand"); ViewBag.IsBatch = "name='IsBatch'"; ViewBag.IsProduct = "name='IsProduct'"; } return View(); } catch (System.Exception) { return View(); } } } public class DLocationAjaxController : AjaxPage { /// /// 下拉框联动 /// /// public ActionResult BindOption() { try { string Guid = Request["ajaxdata"]; string OperType = Request["opertype"]; if (OperType == "Region") { ReturnJson.AddProperty("DepotsArea", LocalHelper.GetDepotsAreaHtml(Guid)); } else { ReturnJson.AddProperty("DepotsRow", LocalHelper.GetDepotsNumHtml("DepotsRow", Guid)); ReturnJson.AddProperty("DepotsColumn", LocalHelper.GetDepotsNumHtml("DepotsColumn", Guid)); ReturnJson.AddProperty("DepotsLayer", LocalHelper.GetDepotsNumHtml("DepotsLayer", Guid)); } return Content(this.ReturnJson.ToString()); } catch (System.Exception ex) { WriteFileLog(ex.Message.ToString(), System.Reflection.MethodBase.GetCurrentMethod()); return Content(null); } } /// /// 获取库位信息集合 /// /// public ActionResult GetDLocationItems() { try { var dd = Request["ajaxdata"]; var modelItems = new JavaScriptSerializer().Deserialize(dd); if (modelItems != null) { // 实例化分页信息 PageInfo pageInfo = new PageInfo() { PageIndex = modelItems.PageIndex, PageSize = modelItems.PageSize }; // 数据库交互,获取库区集合and分页信息。 DALDepotsLocation provider = new DALDepotsLocation(); List entity = provider.GetDepotsLocationItems(modelItems, ref pageInfo).ToList(); // Data =》json string json = JsonHelper.IListToJson(entity, "List"); string pjson = ConvertJson.Serializer(pageInfo); // controller => view ReturnJson.AddProperty("Result", new JsonObject(json)); ReturnJson.AddProperty("PageInfo", new JsonObject(pjson)); ReturnJson.AddProperty("Code", 1); ReturnJson.AddProperty("Message", "加载库位集合成功!"); return Content(this.ReturnJson.ToString()); } return Content(null); } catch (Exception ex) { WriteFileLog(ex.Message.ToString(), System.Reflection.MethodBase.GetCurrentMethod()); return Content(null); } } /// /// 编辑库位信息 /// /// public ActionResult SetDLocations() { try { var dd = Request["ajaxdata"]; var Items = new JavaScriptSerializer().Deserialize(dd); if (Items != null) { // 数据库交互 DALDepotsLocation provider = new DALDepotsLocation(); if (provider.SetDLocations(Items, this.LoginUserCode)) { // 批量更新库位信息 if (Session["Locations"] != null) { ArrayList list = (ArrayList)Session["Locations"]; foreach (string guid in list) { Items.Guid = guid; provider.SetDLocations(Items, this.LoginUserCode); } } Session["Locations"] = null; ReturnJson.AddProperty("Code", 1); ReturnJson.AddProperty("Message", "保存成功!"); } else { ReturnJson.AddProperty("Code", 1); ReturnJson.AddProperty("Message", "保存失败!"); } } return Content(this.ReturnJson.ToString()); } catch (System.Exception ex) { WriteFileLog(ex.Message.ToString(), System.Reflection.MethodBase.GetCurrentMethod()); return Content(null); } } /// /// 将选择的库位暂存在缓存内 /// /// public ActionResult SetLocationsSeession() { Session["Locations"] = null; var dd = Request["list"]; Session["Locations"] = new JavaScriptSerializer().Deserialize(dd); ReturnJson.AddProperty("Code", 1); return Content(this.ReturnJson.ToString()); } public ActionResult DelLocations() { try { string dd = Request["list"]; ArrayList models = new JavaScriptSerializer().Deserialize(dd); string[] list = (string[])models.ToArray(typeof(string)); if (models != null) { // 数据库交互 DALDepotsLocation provider = new DALDepotsLocation(); if (provider.DelLocations(list, this.LoginUserCode)) { ReturnJson.AddProperty("Code", 1); ReturnJson.AddProperty("Message", "删除成功!"); } else { ReturnJson.AddProperty("Code", 1); ReturnJson.AddProperty("Message", "删除失败!"); } } return Content(this.ReturnJson.ToString()); } catch (System.Exception ex) { WriteFileLog(ex.Message.ToString(), System.Reflection.MethodBase.GetCurrentMethod()); return Content(null); } } /// /// 验证库位是否操作员所属部门占用 /// /// public ActionResult CheckDepartment() { try { string dd = Request["ajaxdata"]; if (dd != "") { // 数据库交互 DALDepotsLocation provider = new DALDepotsLocation(); if (!provider.CheckDepartment(dd, this.LoginDepartNum)) { ReturnJson.AddProperty("Code", 1); ReturnJson.AddProperty("Message", "其他部门占用的库位,不允许修改!"); } else { ReturnJson.AddProperty("Code", 0); ReturnJson.AddProperty("Message", "允许修改!"); } } return Content(this.ReturnJson.ToString()); } catch (System.Exception ex) { WriteFileLog(ex.Message.ToString(), System.Reflection.MethodBase.GetCurrentMethod()); return Content(null); } } } }