MicroWin10-1604\Administrator лет назад: 8
Родитель
Сommit
495787bd7f

+ 153 - 149
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/quality/IndexBaseController.cs

@@ -1,4 +1,5 @@
1 1
 using CallCenter.Utility;
2
+using CallCenterApi.DB;
2 3
 using CallCenterApi.Interface.Controllers.Base;
3 4
 using System;
4 5
 using System.Collections.Generic;
@@ -18,61 +19,61 @@ namespace CallCenterApi.Interface.Controllers.quality
18 19
             string sql = "";
19 20
             DataTable dt = new DataTable();
20 21
 
21
-                string categoryid = RequestString.GetQueryString("categoryid");
22
-                string key = WebHelper.UrlDecode(RequestString.GetQueryString("key"));
22
+            string categoryid = RequestString.GetQueryString("categoryid");
23
+            string key = WebHelper.UrlDecode(RequestString.GetQueryString("key"));
23 24
 
24
-                string strpageindex = RequestString.GetQueryString("page");
25
-                int pageindex = 1;
26
-                string strpagesize = RequestString.GetQueryString("pagesize");
27
-                int pagesize = 10;
28
-                if (categoryid.Trim() != "")
29
-                {
30
-                    sql += " and (F_CategoryId=" + categoryid + " or F_CategoryId in (select F_CategoryId from T_QC_IndexCategory where F_ParentId=" + categoryid + " )) ";
31
-                }
25
+            string strpageindex = RequestString.GetQueryString("page");
26
+            int pageindex = 1;
27
+            string strpagesize = RequestString.GetQueryString("pagesize");
28
+            int pagesize = 10;
29
+            if (categoryid.Trim() != "")
30
+            {
31
+                sql += " and (F_CategoryId=" + categoryid + " or F_CategoryId in (select F_CategoryId from T_QC_IndexCategory where F_ParentId=" + categoryid + " )) ";
32
+            }
32 33
 
33
-                if (key.Trim() != "")
34
-                {
35
-                    sql += " and (F_Title like '%" + key.Trim() + "%' or F_Content like '%" + key.Trim() + "%') ";
36
-                }
37
-                if (strpageindex.Trim() != "")
38
-                {
39
-                    pageindex = Convert.ToInt32(strpageindex);
40
-                }
34
+            if (key.Trim() != "")
35
+            {
36
+                sql += " and (F_Title like '%" + key.Trim() + "%' or F_Content like '%" + key.Trim() + "%') ";
37
+            }
38
+            if (strpageindex.Trim() != "")
39
+            {
40
+                pageindex = Convert.ToInt32(strpageindex);
41
+            }
41 42
 
42
-                if (strpagesize.Trim() != "")
43
-                {
44
-                    pagesize = Convert.ToInt32(strpagesize);
45
-                }
46
-                int recordCount = 0;
47
-                dt = BLL.PagerBLL.GetListPager(
48
-                    "vw_QC_IndexBase",
49
-                    "F_IndexId",
50
-                    "*",
51
-                    " and F_DeleteFlag=0 " + sql,
52
-                    "ORDER BY F_Sort",
53
-                    pagesize,
54
-                    pageindex,
55
-                    true,
56
-                    out recordCount);
43
+            if (strpagesize.Trim() != "")
44
+            {
45
+                pagesize = Convert.ToInt32(strpagesize);
46
+            }
47
+            int recordCount = 0;
48
+            dt = BLL.PagerBLL.GetListPager(
49
+                "vw_QC_IndexBase",
50
+                "F_IndexId",
51
+                "*",
52
+                " and F_DeleteFlag=0 " + sql,
53
+                "ORDER BY F_Sort",
54
+                pagesize,
55
+                pageindex,
56
+                true,
57
+                out recordCount);
57 58
 
58
-                var obj = new
59
-                {
60
-                    rows = dt,
61
-                    total = recordCount
62
-                };
59
+            var obj = new
60
+            {
61
+                rows = dt,
62
+                total = recordCount
63
+            };
63 64
 
64
-                res = Content(obj.ToJson());
65
+            res = Content(obj.ToJson());
65 66
 
66
-                //System.Collections.Generic.List<Model.T_QC_IndexBase> modelList = new BLL.T_QC_IndexBase().DataTableToList(dt);
67
+            //System.Collections.Generic.List<Model.T_QC_IndexBase> modelList = new BLL.T_QC_IndexBase().DataTableToList(dt);
67 68
 
68
-                //if (modelList.Count > 0)
69
-                //{
70
-                //    res = Success("指标列表加载成功", modelList);
71
-                //}
72
-                //else
73
-                //{
74
-                //    res = Error("指标列表加载失败");
75
-                //}
69
+            //if (modelList.Count > 0)
70
+            //{
71
+            //    res = Success("指标列表加载成功", modelList);
72
+            //}
73
+            //else
74
+            //{
75
+            //    res = Error("指标列表加载失败");
76
+            //}
76 77
 
77 78
             return res;
78 79
         }
@@ -81,71 +82,73 @@ namespace CallCenterApi.Interface.Controllers.quality
81 82
         public ActionResult GetIndexBase(string id)
82 83
         {
83 84
             ActionResult res = NoToken("未知错误,请重新登录");
84
-    
85
-                if (id.Trim() != "")
85
+
86
+            if (id.Trim() != "")
87
+            {
88
+                BLL.T_QC_IndexBase dBLL = new BLL.T_QC_IndexBase();
89
+                Model.T_QC_IndexBase dModel = dBLL.GetModel(int.Parse(id.Trim()));
90
+                if (dModel != null)
86 91
                 {
87
-                    BLL.T_QC_IndexBase dBLL = new BLL.T_QC_IndexBase();
88
-                    Model.T_QC_IndexBase dModel = dBLL.GetModel(int.Parse(id.Trim()));
89
-                    if (dModel != null)
90
-                    {
91
-                        res = Success("获取指标成功", dModel);
92
-                    }
93
-                    else
94
-                    {
95
-                        res = Error("获取指标失败");
96
-                    }
92
+                    res = Success("获取指标成功", dModel);
97 93
                 }
98 94
                 else
99 95
                 {
100
-                    res = Error("获取参数失败");
96
+                    res = Error("获取指标失败");
101 97
                 }
98
+            }
99
+            else
100
+            {
101
+                res = Error("获取参数失败");
102
+            }
102 103
 
103 104
             return res;
104 105
         }
105 106
 
106 107
         //添加指标
107
-        public ActionResult AddIndexBase(string cid, string score, string sort, string title,string remark)
108
+        public ActionResult AddIndexBase(string cid, string score, string sort, string title, string remark)
108 109
         {
109 110
             ActionResult res = NoToken("未知错误,请重新登录");
110 111
             if (Request.IsAuthenticated)
111 112
             {
112
-               
113
-                    Model.T_QC_IndexBase dModel = new Model.T_QC_IndexBase();
114 113
 
115
-                    if (!string.IsNullOrWhiteSpace(cid.Trim()))
116
-                    {
117
-                        dModel.F_CategoryId = int.Parse(cid.Trim());
118
-                    }
119
-                    if (!string.IsNullOrWhiteSpace(sort.Trim()))
120
-                    {
121
-                        dModel.F_Sort = Convert.ToInt32(sort.Trim());
122
-                    }
123
-                    if (!string.IsNullOrWhiteSpace(score.Trim()))
124
-                    {
125
-                        dModel.F_Score = Convert.ToInt32(score.Trim());
126
-                    }
127
-                    if (!string.IsNullOrWhiteSpace(title.Trim()))
128
-                    {
129
-                        dModel.F_Title = WebHelper.UrlDecode(title.Trim());
130
-                    }
131
-                    if (!string.IsNullOrWhiteSpace(remark.Trim()))
132
-                    {
133
-                        dModel.F_Remark = WebHelper.UrlDecode(remark.Trim());
134
-                    }
114
+                Model.T_QC_IndexBase dModel = new Model.T_QC_IndexBase();
115
+
116
+                if (!string.IsNullOrWhiteSpace(cid.Trim()))
117
+                {
118
+                    dModel.F_CategoryId = int.Parse(cid.Trim());
119
+                }
120
+                if (!string.IsNullOrWhiteSpace(sort.Trim()))
121
+                {
122
+                    dModel.F_Sort = Convert.ToInt32(sort.Trim());
123
+                }
124
+                if (!string.IsNullOrWhiteSpace(score.Trim()))
125
+                {
126
+                    dModel.F_Score = Convert.ToInt32(score.Trim());
127
+                }
128
+                if (!string.IsNullOrWhiteSpace(title.Trim()))
129
+                {
130
+                    dModel.F_Title = WebHelper.UrlDecode(title.Trim());
131
+                }
132
+                if (!string.IsNullOrWhiteSpace(remark.Trim()))
133
+                {
134
+                    dModel.F_Remark = WebHelper.UrlDecode(remark.Trim());
135
+                }
135 136
 
136
-                    dModel.F_CreateOn = DateTime.Now;
137
-                    dModel.F_CreateBy = CurrentUser.UserData.F_UserId;
138
-                    dModel.F_DeleteFlag = 0;
137
+                dModel.F_CreateOn = DateTime.Now;
138
+                dModel.F_CreateBy = CurrentUser.UserData.F_UserId;
139
+                dModel.F_DeleteFlag = 0;
139 140
 
140
-                    bool b = new BLL.T_QC_IndexBase().Add(dModel) > 0;
141
-                    if (b)
142
-                    {
143
-                        res = Success("添加成功");
144
-                    }
145
-                    else
146
-                    {
147
-                        res = Success("添加失败");
148
-                    }
141
+                bool b = new BLL.T_QC_IndexBase().Add(dModel) > 0;
142
+                if (b)
143
+                {
144
+                    //添加成功后要将对应父级的分值增加上
145
+                    SetScoreByCategory(dModel.F_CategoryId.ToString());
146
+                    res = Success("添加成功");
147
+                }
148
+                else
149
+                {
150
+                    res = Success("添加失败");
151
+                }
149 152
 
150 153
             }
151 154
             return res;
@@ -157,79 +160,80 @@ namespace CallCenterApi.Interface.Controllers.quality
157 160
             ActionResult res = NoToken("未知错误,请重新登录");
158 161
             if (Request.IsAuthenticated)
159 162
             {
160
-                
161
-                    if (cid.Trim() != "")
163
+
164
+                if (cid.Trim() != "")
165
+                {
166
+                    BLL.T_QC_IndexBase dBLL = new BLL.T_QC_IndexBase();
167
+                    Model.T_QC_IndexBase dModel = dBLL.GetModel(int.Parse(id.Trim()));
168
+                    if (dModel != null)
162 169
                     {
163
-                        BLL.T_QC_IndexBase dBLL = new BLL.T_QC_IndexBase();
164
-                        Model.T_QC_IndexBase dModel = dBLL.GetModel(int.Parse(id.Trim()));
165
-                        if (dModel != null)
170
+                        if (!string.IsNullOrWhiteSpace(cid.Trim()))
171
+                        {
172
+                            dModel.F_CategoryId = int.Parse(cid.Trim());
173
+                        }
174
+                        if (!string.IsNullOrWhiteSpace(sort.Trim()))
175
+                        {
176
+                            dModel.F_Sort = Convert.ToInt32(sort.Trim());
177
+                        }
178
+                        if (!string.IsNullOrWhiteSpace(score.Trim()))
166 179
                         {
167
-                            if (!string.IsNullOrWhiteSpace(cid.Trim()))
168
-                            {
169
-                                dModel.F_CategoryId = int.Parse(cid.Trim());
170
-                            }
171
-                            if (!string.IsNullOrWhiteSpace(sort.Trim()))
172
-                            {
173
-                                dModel.F_Sort = Convert.ToInt32(sort.Trim());
174
-                            }
175
-                            if (!string.IsNullOrWhiteSpace(score.Trim()))
176
-                            {
177
-                                dModel.F_Score = Convert.ToInt32(score.Trim());
178
-                            }
179
-                            if (!string.IsNullOrWhiteSpace(title.Trim()))
180
-                            {
181
-                                dModel.F_Title = WebHelper.UrlDecode(title.Trim());
182
-                            }
183
-                            if (!string.IsNullOrWhiteSpace(remark.Trim()))
184
-                            {
185
-                                dModel.F_Remark = WebHelper.UrlDecode(remark.Trim());
186
-                            }
187
-                            bool b = dBLL.Update(dModel);
188
-                            if (b)
189
-                            {
190
-                                res = Success("编辑成功");
191
-                            }
192
-                            else
193
-                            {
194
-                                res = Success("编辑失败");
195
-                            }
180
+                            dModel.F_Score = Convert.ToInt32(score.Trim());
181
+                        }
182
+                        if (!string.IsNullOrWhiteSpace(title.Trim()))
183
+                        {
184
+                            dModel.F_Title = WebHelper.UrlDecode(title.Trim());
185
+                        }
186
+                        if (!string.IsNullOrWhiteSpace(remark.Trim()))
187
+                        {
188
+                            dModel.F_Remark = WebHelper.UrlDecode(remark.Trim());
189
+                        }
190
+                        bool b = dBLL.Update(dModel);
191
+                        if (b)
192
+                        {
193
+                            SetScoreByCategory(dModel.F_CategoryId.ToString());
194
+                            res = Success("编辑成功");
196 195
                         }
197 196
                         else
198
-                            res = Error("获取信息失败");
197
+                        {
198
+                            res = Success("编辑失败");
199
+                        }
199 200
                     }
200 201
                     else
201
-                    {
202
-                        res = Error("请选择要编辑的指标");
203
-                    }
204
-     
202
+                        res = Error("获取信息失败");
203
+                }
204
+                else
205
+                {
206
+                    res = Error("请选择要编辑的指标");
207
+                }
208
+
205 209
             }
206 210
             return res;
207 211
         }
208 212
 
209 213
         //删除指标记录
210
-        public ActionResult DelIndexBase(string id,string cid)
214
+        public ActionResult DelIndexBase(string id, string cid)
211 215
         {
212 216
             ActionResult res = NoToken("未知错误,请重新登录");
213 217
             DataTable dt = new DataTable();
214
-       
215
-                if (!string.IsNullOrEmpty(id.Trim()))
216
-                {
217
-                    if (new BLL.T_QC_IndexBase().Delete(Convert.ToInt32(id)))
218
-                    {
219
-                        SetScoreByCategory(cid);
220
-                        res = Success("删除成功");
221
-                    }
222
-                    else
223
-                    {
224
-                        res = Error("删除失败");
225
-                    }
226 218
 
219
+            if (!string.IsNullOrEmpty(id.Trim()))
220
+            {
221
+                if (new BLL.T_QC_IndexBase().Delete(Convert.ToInt32(id)))
222
+                {
223
+                    SetScoreByCategory(cid);
224
+                    res = Success("删除成功");
227 225
                 }
228 226
                 else
229 227
                 {
230
-                    res = Error("请选择要删除的记录");
228
+                    res = Error("删除失败");
231 229
                 }
232 230
 
231
+            }
232
+            else
233
+            {
234
+                res = Error("请选择要删除的记录");
235
+            }
236
+
233 237
             return res;
234 238
         }
235 239