chengsc
2024-07-23 f575652587d4160ab42e75acb2bc26b4f60fb7c3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
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;
 
namespace wms.Areas.BasicInfo.Controllers
{
    public class DepotsAreaController : MasterPage
    {
        // GET: BasicInfo/DepotsArea
        [LoginFilter]
        public ActionResult Index()
        {
            //ViewBag.Region = LocalHelper.GetRegionItemsHtml();
            ViewBag.Title = "库区管理";
            return View();
        }
 
        [LoginFilter]
        public ActionResult AddEdit()
        {
            try
            {
                string Guid = Request.QueryString.Get("Guid");
                DALDepotsArea dALDepotsArea = new DALDepotsArea();
 
                if (Guid != null)
                {
                    DepotsArea depotsArea = dALDepotsArea.GetDepotsAreaItems(Guid)[0];
 
                    ViewBag.DepotsCode = depotsArea.DepotsCode;
                    ViewBag.DepotsName = depotsArea.DepotsName;
                    //ViewBag.RegionId = LocalHelper.GetRegionItemsHtml(depotsArea.RegionID);
                    ViewBag.DepotsRow = depotsArea.DepotsRow;
                    ViewBag.DepotsColumn = depotsArea.DepotsColumn;
                    ViewBag.DepotsLayer = depotsArea.DepotsLayer;
                    ViewBag.Demo = depotsArea.Demo;
                    //ViewBag.InStorageLocation = depotsArea.InStorageLocation;       // 下拉框待完善
                    //ViewBag.OutStorageLocation = depotsArea.OutStorageLocation;     // 下拉框待完善
                }
                else
                {
                    ViewBag.DepotsCode = "";
                    ViewBag.DepotsName = "";
                    //ViewBag.RegionId = LocalHelper.GetRegionItemsHtml();
                    ViewBag.Demo = "";
                    //ViewBag.InStorageLocation = "";       // 下拉框待完善
                    //ViewBag.OutStorageLocation = "";     // 下拉框待完善
                }
 
                return View();
            }
            catch (System.Exception)
            {
                return View();
            }
        }
    }
 
    public class DepotsAreaAjaxController : AjaxPage 
    {
        public ActionResult GetDepotsAreaItems()
        {
            try
            {
                var dd = Request["ajaxdata"];
                var modelItems = new JavaScriptSerializer().Deserialize<QueryDepotsArea>(dd);
                if (modelItems != null)
                {
                    // 实例化分页信息
                    PageInfo pageInfo = new PageInfo()
                    {
                        PageIndex = modelItems.pageIndex,
                        PageSize = modelItems.pageSize
                    };
 
                    // 数据库交互,获取库区集合and分页信息。
                    DALDepotsArea provider = new DALDepotsArea();
                    List<DepotsArea> entity = provider.GetDepotsAreaItems(modelItems, ref pageInfo).ToList();
 
                    // Data =》json
                    string json = JsonHelper.IListToJson<DepotsArea>(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 (System.Exception)
            {
                return Content(null);
            }
        }
 
        public ActionResult SetDepotsAreas()
        {
            try
            {
                var dd = Request["ajaxdata"];
                var depotsItems = new JavaScriptSerializer().Deserialize<SetDepotsArea>(dd);
                if (depotsItems != null)
                {
                    // 数据库交互
                    DALDepotsArea provider = new DALDepotsArea();
                    if (provider.SetDepotsAreas(depotsItems, 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)
            {
                return Content(null);
            }
        }
 
        public ActionResult DelDepotsAreas()
        {
            try
            {
                string dd = Request["list"];
                ArrayList models = new JavaScriptSerializer().Deserialize<ArrayList>(dd);
                string[] list = (string[])models.ToArray(typeof(string));
 
                if (models != null)
                {
                    // 数据库交互
                    DALDepotsArea provider = new DALDepotsArea();
                    if (provider.DelDepotsAreas(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)
            {
                return Content(null);
            }
        }
 
        public ActionResult IsExist()
        {
            var dd = Request["ajaxdata"];
            var depotsItems = new JavaScriptSerializer().Deserialize<SetDepotsArea>(dd);
            DALDepotsArea provider = new DALDepotsArea();
            bool bl = provider.IsExist(depotsItems);
 
            ReturnJson.AddProperty("Result", bl.ToString());
 
            return Content(this.ReturnJson.ToString());
        }
    }
}