using BLL; using Common; using Model; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; using System.Web.Script.Serialization; using wms; using Json; using Lib; using System.Data; using Commom.BarCodePrint; namespace WMS.Areas.BasicInfo.Controllers { public class StorageAjaxController : AjaxPage { // GET: BasicInfo/StorageAjax public ActionResult GetStorageList() { var dd = Request["ajaxdata"]; var models = new JavaScriptSerializer().Deserialize<AjaxAreaList>(dd); if (models != null) { PageInfo pageInfo = new PageInfo() { PageIndex = models.pageIndex, PageSize = models.pageSize }; IDALArea provider = new DALArea(); List<Area> entity = provider.GetList(models, ref pageInfo).ToList(); string json = JsonHelper.IListToJson<Area>(entity, "List"); string pjson = ConvertJson.Serializer(pageInfo); ReturnJson.AddProperty("Result", new JsonObject(json)); ReturnJson.AddProperty("PageInfo", new JsonObject(pjson)); ReturnJson.AddProperty("Code", 1); ReturnJson.AddProperty("Message", "å“应æˆåŠŸ"); ReturnJson.AddProperty("SubCode", 0); ReturnJson.AddProperty("SubMessage", ""); return Content(this.ReturnJson.ToString()); } return Content(null); } // GET: BasicInfo/StorageAjax public ActionResult AddStorage() { var dd = Request["ajaxdata"]; var models = new JavaScriptSerializer().Deserialize<AjaxAreaInfo>(dd); string Operation = models.Operation; if (models != null) { IDALArea provider = new DALArea(); if (Operation == "Add") { //models.CreateUser = this.LoginUserCode; if (!provider.IsExist(nameof(models.StorageNo), models.StorageNo) && !provider.IsExist(nameof(models.StorageName), models.StorageName)) { bool value = provider.Add(models); if (value) { ReturnJson.AddProperty("Code", 1); ReturnJson.AddProperty("Message", "æ·»åŠ åº“åŒºæˆåŠŸ"); ReturnJson.AddProperty("SubCode", 0); ReturnJson.AddProperty("SubMessage", ""); } else { ReturnJson.AddProperty("Code", -1); ReturnJson.AddProperty("Message", "æ·»åŠ åº“åŒºå¤±è´¥"); ReturnJson.AddProperty("SubCode", 0); ReturnJson.AddProperty("SubMessage", ""); } } else { ReturnJson.AddProperty("Code", -1); ReturnJson.AddProperty("Message", "该库区已å˜åœ¨ï¼ï¼ï¼"); ReturnJson.AddProperty("SubCode", 0); ReturnJson.AddProperty("SubMessage", ""); } } else if (Operation == "Edit") { //models.UpdateUser = this.LoginUserCode; bool value = provider.Update(models); if (value) { ReturnJson.AddProperty("Code", 1); ReturnJson.AddProperty("Message", "ç¼–è¾‘åº“åŒºä¿¡æ¯æˆåŠŸ"); ReturnJson.AddProperty("SubCode", 0); ReturnJson.AddProperty("SubMessage", ""); } else { ReturnJson.AddProperty("Code", -1); ReturnJson.AddProperty("Message", "编辑库区信æ¯å¤±è´¥"); ReturnJson.AddProperty("SubCode", 0); ReturnJson.AddProperty("SubMessage", ""); } } } else { ReturnJson.AddProperty("Code", -1); ReturnJson.AddProperty("Message", "åº“åŒºä¿¡æ¯æœ‰è¯¯ï¼ï¼ï¼"); ReturnJson.AddProperty("SubCode", 0); ReturnJson.AddProperty("SubMessage", ""); } return Content(this.ReturnJson.ToString()); } public ActionResult DelStorage() { string dd = Request["list"]; ArrayList models = new JavaScriptSerializer().Deserialize<ArrayList>(dd); string[] list = (string[])models.ToArray(typeof(string)); if (models != null) { IDALArea provider = new DALArea(); bool value = provider.BatchDelete(list); if (value) { ReturnJson.AddProperty("Code", 1); ReturnJson.AddProperty("Message", "åˆ é™¤åº“åŒºæˆåŠŸ"); ReturnJson.AddProperty("SubCode", 0); ReturnJson.AddProperty("SubMessage", ""); } else { ReturnJson.AddProperty("Code", -1); ReturnJson.AddProperty("Message", "åˆ é™¤åº“åŒºå¤±è´¥"); ReturnJson.AddProperty("SubCode", 0); ReturnJson.AddProperty("SubMessage", ""); } return Content(this.ReturnJson.ToString()); } return Content(null); } /// <summary> /// æ ¹æ®åº“区信æ¯,生æˆåº“ä½ã€‚ /// </summary> /// <returns></returns> public ActionResult Createlocation() { ReturnJson.AddProperty("SubCode", 0); ReturnJson.AddProperty("SubMessage", ""); try { var dd = Request["list"]; ArrayList models = new JavaScriptSerializer().Deserialize<ArrayList>(dd); string[] list = (string[])models.ToArray(typeof(string)); if (models != null) { string StorageNo = list[0]; IDALArea provider = new DALArea(); // éªŒè¯æ˜¯å¦å·²ç”Ÿæˆåº“ä½ if (provider.IsCreateLocation(StorageNo)) { ReturnJson.AddProperty("Code", -1); ReturnJson.AddProperty("Message", "已生æˆåº“ä½ï¼"); } else { if (provider.Createlocation(StorageNo)) { ReturnJson.AddProperty("Code", 1); ReturnJson.AddProperty("Message", "生æˆåº“使ˆåŠŸï¼"); } else { ReturnJson.AddProperty("Code", -1); ReturnJson.AddProperty("Message", "生æˆåº“ä½å¤±è´¥ï¼"); } } } return Content(this.ReturnJson.ToString()); } catch (System.Exception ex) { ReturnJson.AddProperty("Code", -1); ReturnJson.AddProperty("Message", ex.Message); return Content(this.ReturnJson.ToString()); } } /// <summary> /// æ‰“å°æ¡å½¢ç /// </summary> /// <returns></returns> public ActionResult PrintBarCode() { ReturnJson.AddProperty("SubCode", 0); ReturnJson.AddProperty("SubMessage", ""); try { var dd = Request["list"]; ArrayList models = new JavaScriptSerializer().Deserialize<ArrayList>(dd); string[] list = (string[])models.ToArray(typeof(string)); if (models != null) { string StorageNo = list[0]; string StorageName = list[1]; DALTray provider = new DALTray(); DataTable GoodsPosDt = provider.GetGoodsPosPrint(StorageNo); foreach (DataRow row in GoodsPosDt.Rows) { string addre = row["addre"].ToString(); TSC1.TSCPrint(StorageName, addre); } ReturnJson.AddProperty("Code", 1); ReturnJson.AddProperty("Message", "æ¡ç 打å°å®Œæˆï¼"); } return Content(this.ReturnJson.ToString()); } catch (System.Exception ex) { ReturnJson.AddProperty("Code", -1); ReturnJson.AddProperty("Message","æ¡ç 打å°å¤±è´¥ï¼ " + ex.Message); return Content(this.ReturnJson.ToString()); } } public ActionResult BindOption() { string StorageNO = Request["ajaxdata"]; try { ReturnJson.AddProperty("Addreid", LocalHelper.GetAddreList(StorageNO, string.Empty)); return Content(this.ReturnJson.ToString()); } catch (System.Exception) { return Content(null); } } } }