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
175
176
177
178
179
180
181
182
183
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web.Mvc;
using System.Web.Script.Serialization;
using BLL;
using Common;
using Json;
using Model;
using Lib;
 
 
namespace wms.Areas.SyetemSet.Controllers
{
    public class ResAjaxController : AjaxPage
    {
        public ActionResult GetResMenuList()
        {
 
            var dd = Request["ajaxdata"];
            var models = new JavaScriptSerializer().Deserialize<AjaxResMenuList>(dd);
 
            if (models != null)
            {
                PageInfo pageInfo = new PageInfo() { PageIndex = models.pageIndex, PageSize = models.pageSize };
 
                IDALResMenu provider = new DALResMenu();
                List<ResMenu> entity = provider.GetList(models, ref pageInfo).ToList();
 
                string json = JsonHelper.IListToJson(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);
        }
 
        public ActionResult AddResMenu()
        {
            try
            {
                var list = Request["ajaxdata"];
                var models = new JavaScriptSerializer().Deserialize<AjaxResMenuInfo>(list);
                if (models != null)
                {
                    IDALResMenu provider = new DALResMenu();
                    if (models.Operation == "Add")
                    {
                        models.CreatUser = this.LoginUserCode;
 
                        if (!provider.IsExist(nameof(models.ResNum), models.ResNum))
                        {
                            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 (models.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", "");
                        }
                    }
 
                    return Content(this.ReturnJson.ToString());
 
                }
                return Content(null);
            }
            catch
            {
                return Content(null);
            }
        }
        public ActionResult DeleteResMenu()
        {
            string dd = Request["list"];
            ArrayList models = new JavaScriptSerializer().Deserialize<ArrayList>(dd);
            string[] list = (string[])models.ToArray(typeof(string));
            if (models != null)
            {
                IDALResMenu provider = new DALResMenu();
                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);
        }
        public ActionResult ToExcel()
        {
            string dd = Request["list"];
            if (dd != null)
            {
                ArrayList models = new JavaScriptSerializer().Deserialize<ArrayList>(dd);
                string[] list = (string[])models.ToArray(typeof(string));
 
                IDALResMenu provider = new DALResMenu();
                DataTable dt = provider.GetDataTable(list);
 
 
 
                string filePath = Server.MapPath("~/UploadFiles/");
                if (!System.IO.Directory.Exists(filePath))
                {
                    System.IO.Directory.CreateDirectory(filePath);
                }
                string filename = string.Format("菜单管理{0}.xls", DateTime.Now.ToString("YYYYMMddHHmmss"));
                NPOIExcel excel = new NPOIExcel("菜单管理", "菜单", System.IO.Path.Combine(filePath, filename));
                excel.ToExcel(dt);
 
                ReturnJson.AddProperty("Code", 1000);
                ReturnJson.AddProperty("Message", Microsoft.JScript.GlobalObject.escape((object)("/UploadFiles/" + filename)));
 
            }
            else
            {
                ReturnJson.AddProperty("Code", -1);
                ReturnJson.AddProperty("Message", "没有选择要导出的数据!!");
            }
            return Content(this.ReturnJson.ToString());
        }
 
       
    }
}