bklLiudl
2024-07-23 277bbae216debe7e6c04e8cc6ee6e1ba9763e14b
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
using BLL.DAL;
using Common;
using Json;
using Lib;
using Model;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using System.Web.Script.Serialization;
 
namespace wms.Areas.BasicInfo.Controllers
{
    public class DictionaryController : MasterPage
    {
        // GET: BasicInfo/Dictionary
        public ActionResult Index()
        {
            ViewBag.Title = "数据字典";
            ViewBag.TopCode = LocalHelper.GetDictionarysHtml();
            return View();
        }
 
        public ActionResult AddEdit()
        {
            try
            {
                string Guid = Request.QueryString.Get("Guid");
                DALDictionary dALDictionary = new DALDictionary();
 
                if (Guid != null)
                {
                    Dictionarys modelItems = new Dictionarys();
                    modelItems.Guid = Guid;
                    PageInfo pageInfo = new PageInfo()
                    {
                        PageIndex = 1,
                        PageSize = 1
                    };
                    List<Dictionarys> entity = dALDictionary.GetDictionaryItems(modelItems, ref pageInfo).ToList();
                    ViewBag.TypeName = entity[0].TypeName;
                    ViewBag.TopCode = LocalHelper.GetDictionarysHtml(entity[0].TopCode);
                }
                else
                {
                    ViewBag.TopCode = LocalHelper.GetDictionarysHtml();
                }
 
                return View();
            }
            catch (System.Exception)
            {
                return View();
            }
        }
    }
 
    public class DictionaryAjaxController : AjaxPage
    {
        public ActionResult GetDictionaryItems() 
        {
            try
            {
                var dd = Request["ajaxdata"];
                var modelItems = new JavaScriptSerializer().Deserialize<Dictionarys>(dd);
                if (modelItems != null)
                {
                    // 实例化分页信息
                    PageInfo pageInfo = new PageInfo()
                    {
                        PageIndex = modelItems.PageIndex,
                        PageSize = modelItems.PageSize
                    };
 
                    // 数据库交互,获取库区集合and分页信息。
                    DALDictionary provider = new DALDictionary();
                    List<Dictionarys> entity = provider.GetDictionaryItems(modelItems, ref pageInfo).ToList();
 
                    // Data =》json
                    string json = JsonHelper.IListToJson<Dictionarys>(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 SetDictionarys() 
        {
            try
            {
                var dd = Request["ajaxdata"];
                var depotsItems = new JavaScriptSerializer().Deserialize<Dictionarys>(dd);
                if (depotsItems != null)
                {
                    // 数据库交互
                    DALDictionary provider = new DALDictionary();
                    if (provider.SetDictionarys(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 IsExist()
        {
            var dd = Request["ajaxdata"];
            var model = new JavaScriptSerializer().Deserialize<Dictionarys>(dd);
            DALDictionary provider = new DALDictionary();
            bool bl = provider.IsExist(model);
 
            ReturnJson.AddProperty("Result", bl.ToString());
 
            return Content(this.ReturnJson.ToString());
        }
 
        public ActionResult DelDictionarys()
        {
            try
            {
                string dd = Request["list"];
                ArrayList models = new JavaScriptSerializer().Deserialize<ArrayList>(dd);
                string[] list = (string[])models.ToArray(typeof(string));
 
                if (models != null)
                {
                    // 数据库交互
                    DALDictionary provider = new DALDictionary();
                    if (provider.DelDictionarys(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);
            }
        }
    }
}