From ee15dec5d91adbd1bdf15b26915b79751c17e481 Mon Sep 17 00:00:00 2001 From: wangsheng <123456> Date: 星期二, 22 三月 2022 09:39:17 +0800 Subject: [PATCH] 解决冲突 --- web/web/GwProduct.ashx | 752 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 752 insertions(+), 0 deletions(-) diff --git a/web/web/GwProduct.ashx b/web/web/GwProduct.ashx new file mode 100644 index 0000000..8134fa4 --- /dev/null +++ b/web/web/GwProduct.ashx @@ -0,0 +1,752 @@ +锘�<%@ WebHandler Language="C#" Class="GwProductHandler" %> +using Dao; +using Model; +// using Newtonsoft.Json; +//using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using System.Web; +using System.IO; +using System.Diagnostics; + +public class GwProductHandler : PageHandler<SysUser> +{ + private GwProductDao _Dao = new GwProductDao(); + private GwSpDao _GwSpDao = new GwSpDao(); + private GwOpGroupDao _GwOpGroupDao = new GwOpGroupDao(); + private SysXhDao _SysXhDao = new SysXhDao(); + + private List<GwOp> _OpList; + private List<GwOpGroup> _GroupList; + private List<GwProduct> _ProductList; //浜у搧鍙婁骇鍝佸垎绫� + //private List<GwProduct> _ProductClassList; //浜у搧鍒嗙被 + + public override JsonPageResult ProcessRequestInternal(PageContext<SysUser> context) + { + string @string = context.GetString("action"); + switch (@string) + { + case "delete": + return this.Delete(context); //鍒犻櫎 + case "update": + return this.Update(context); //淇敼 + case "add": + return this.Add(context); //娣诲姞 + case "list": + return this.List(context); //鏌ヨ + case "get": + return this.Get(context); //鑾峰彇璁板綍淇℃伅 + case "updateStatus": + return this.UpdateStatus(context); //鍚敤鎴栧仠鐢� + case "upLoad": + return this.UpLoad(context); //鍥炬爣鏂囦欢涓婁紶 + + default: + throw new Exception("Invalid Action=" + @string); + } + } + + //鍔犺浇浜у搧鍙婁骇鍝佸垎绫讳俊鎭� + private JsonPageResult List(PageContext<SysUser> context) + { + //Console.WriteLine("List.............[" + context.GetInt("name") + "][" + context.GetInt("classes") + "]"); + int classes = context.GetInt("classes"); + string name = context.GetString("name"); + + int recordCount = 0; + int pageSize = context.GetInt("pageSize", 50); + int pageIndex = context.GetInt("pageIndex", 1); + + List<GwProduct> list = _Dao.LoadInfoList(classes, name, pageSize, pageIndex, out recordCount); + + string str1 = ""; + if (list != null && list.Count > 0) + { + + int num = 0; + foreach (GwProduct bean in list) + { + ++num; + //str1 = str1 + (object) "<tr><td>" + "<img src=\"../static/images/productIcon/" + (object) bean.Icon + "\" >"; + if (bean.Classes == 1 && !string.IsNullOrEmpty(bean.Icon)) + { + str1 += "<tr><td>" + "<img src=\"../static/images/productIcon/" + (object)bean.Icon + "\" >" + "</td>"; + } + else + { + str1 += "<tr><td>" + (object)bean.Icon + "</td>"; + } + + str1 += "<td>" + bean.Name + "</td>"; + str1 = string.Concat(new object[4] + { + str1, + "<td>", + bean.Instructions, + "</td>" + }); + str1 = str1 + "<td>" + (object)this.ClassesToName(bean.Classes) + "</td>"; + if (bean.RouterType == 1) + { + str1 += "<td rowspan=\"1\"><div class=\"btn btn-primary btn-xs\">鐐硅矾鐢�</div>"; + str1 += string.Format("<div>绉诲姩锛歿0}</div><div>鐢典俊锛歿1}</div><div>鑱旈�氾細{2}</div>", (object)this.GetOpName(bean.CmOpId), (object)this.GetOpName(bean.CtOpId), (object)this.GetOpName(bean.CuOpId)); + } + else if (bean.RouterType == 3) + { + str1 += "<td rowspan=\"1\"><div class=\"btn btn-success btn-xs\">缁勮矾鐢�</div>"; + str1 += string.Format("<div>绉诲姩锛歿0}</div><div>鐢典俊锛歿1}</div><div>鑱旈�氾細{2}</div>", (object)this.GetGroupName(bean.CmGroupid), (object)this.GetGroupName(bean.CtGroupid), (object)this.GetGroupName(bean.CuGroupid)); + } + else + { + str1 += "<td rowspan=\"1\"></td>"; + } + str1 = str1 + "<td>" + ProductToName(bean.ParentId) + "</td>"; + str1 = str1 + "<td>" + IsDefaultToName(bean.IsDefault) + "</td>"; + str1 = str1 + "<td>" + IsEnableToName(bean.IsEnable) + "</td>"; + str1 = string.Concat(new object[4] + { + str1, + "<td>", + bean.Sort, + "</td>" + }); + str1 = string.Concat(new object[4] + { + str1, + "<td>", + bean.GivingNum, //榛樿璧犻�佹潯鏁� + "</td>" + }); + + str1 += string.Format("<td>{0}鍏�/鏉�</td>", (object)(Convert.ToDecimal(bean.Price) / new Decimal(1000))); + str1 = str1 + "<td>" + bean.CreateTime + "</td>"; + str1 += "<td class=\"text-right\">"; + str1 = bean.IsEnable != 0 ? str1 + string.Format("<a href=\"javascript:;\" data-id=\"{0}\" data-is_enable=\"0\" class=\"action-update-status btn btn-primary btn-xs\"><i class=\"fa fa-toggle-off\"></i> 鍋滅敤</a> ", (object) bean.Id ) : str1 + string.Format("<a href=\"javascript:;\" data-id=\"{0}\" data-is_enable=\"1\" class=\"action-update-status btn btn-default btn-xs\"><i class=\"fa fa-toggle-on\"/></i> 鍚敤</a> ", (object) bean.Id ); + str1 += string.Format("<a href=\"javascript:;\" data-id=\"{0}\" class=\"action-modal-edit btn btn-success btn-xs\"><i class=\"fa fa-edit\"></i> 缂栬緫</a> ", (object) bean.Id); + str1 += string.Format("<a href=\"javascript:;\" data-id=\"{0}\" class=\"action-delete btn btn-default btn-xs\"><i class=\"fa fa-trash\"></i> 鍒犻櫎</a> ", (object) bean.Id); + str1 += "</td>"; + str1 += "</tr>"; + } + } + else + str1 += "<tr><td colspan=\"13\" style=\"padding-left:5px; text-align: center;\">鏆傛棤淇℃伅</td></tr>"; + + return new JsonPageResult(true, new + { + Table = str1.ToString(), + TotalCount = recordCount + }); + } + + //閫氶亾杩愯鐘舵�佹垨閿欒淇℃伅 + private string FormatOpError(int opStatus, int opError, string remark) + { + StringBuilder stringBuilder = new StringBuilder(); + if (opStatus == 0) + { + stringBuilder.Append("<span class=\"label label-default\">宸插仠鐢�</span>"); + } + else + { + stringBuilder.Append("<a data-html=\"true\" data-content=\"<pre style='width:200px;height:160px;'>" + HttpUtility.HtmlEncode(remark) + "</pre>\" type=\"button\" class=\"btn-xs\" data-trigger=\"click\" data-toggle=\"popover\" data-placement=\"left\">"); + if (opError == 0) + stringBuilder.Append("<span class=\"label label-primary\">姝e父</span>"); + else if (opError == 5) + stringBuilder.Append("<span class=\"label label-danger\">寮傚父</span>"); + else + stringBuilder.Append("NA"); + stringBuilder.Append("</a>"); + } + return stringBuilder.ToString(); + } + + public bool IsInt(string input) + { + for (int index = 0; index < input.Length; ++index) + { + if (!char.IsNumber(input, index)) + return false; + } + return true; + } + + + //鍒犻櫎浜у搧鎴栦骇鍝佸垎绫� + private JsonPageResult Delete(PageContext<SysUser> context) + { + string ID = context.GetString("id"); + + if (this._Dao.GwProductUseCount(ID) > 0) + throw new ArgumentException("褰撳墠浜у搧鍒嗙被宸插湪浜у搧淇℃伅浣跨敤涓�,鏃犳硶鍒犻櫎锛�"); + if (this._Dao.GwSpUseCount(ID) > 0) + throw new ArgumentException("褰撳墠浜у搧鍦ㄥ鎴疯处鍙蜂俊鎭腑浣跨敤,鏃犳硶鍒犻櫎锛�"); + this._Dao.Delete(ID); + return new JsonPageResult(true, "鍒犻櫎淇℃伅鎴愬姛锛�"); + + } + + //娣诲姞浜у搧鎴栦骇鍝佸垎绫� + private JsonPageResult Add(PageContext<SysUser> context) + { + + string id = _SysXhDao.getXh("GW_PRODUCT"); //鑾峰彇鐢熸垚浜у搧ID + string name = context.GetString("name"); + int classes = context.GetInt("classes", -1); + string icon = ""; + string instructions = ""; + int isDefault = 0; + int sort = 0; + + int routerType = 0; + int cmOpId = 0; + int cuOpId = 0; + int ctOpId = 0; + string cmExtParams = ""; + string cuExtParams = ""; + string ctExtParams = ""; + int cmGroupid = 0; + int cuGroupid = 0; + int ctGroupid = 0; + int price = 0; + int givingNum = 0; + + string info = "" ; + if (classes == -1) { + throw new ArgumentException("璇烽�夋嫨绫诲埆锛�"); + } + else + { + if(classes == 1) + { + info = "浜у搧"; + if (string.IsNullOrEmpty(name)) + { + throw new ArgumentException(info + "鍚嶇О涓嶈兘涓虹┖锛�"); + } + + } + else if (classes == 0) + { + info = "浜у搧鍒嗙被"; + if (string.IsNullOrEmpty(name)) + { + throw new ArgumentException(info + "鍚嶇О涓嶈兘涓虹┖锛�"); + } + + } + + } + + //1-浜у搧锛�0-鍒嗙被 + if (classes==1) + { + icon = context.GetString("icon"); + instructions = context.GetString("instructions"); + isDefault = context.GetInt("isDefault", 0); + + int num = Math.Max((int) (context.GetDecimal("price", new Decimal(4, 0, 0, false, (byte) 2)) * new Decimal(1000)), 1); + price = num; + givingNum = context.GetInt("givingNum", 0); + sort = context.GetInt("sort", 0); + + routerType = context.GetInt("routerType", 1); + //璺敱绫诲瀷锛�1-閫氶亾璺敱锛�3-閫氶亾缁勮矾鐢便�� + if (routerType==1) + { + cmOpId = context.GetInt("cmOpId", 0); + cuOpId = context.GetInt("cuOpId", 0); + ctOpId = context.GetInt("ctOpId", 0); + cmExtParams = context.GetString("cmExtParams"); + cuExtParams = context.GetString("cuExtParams"); + ctExtParams = context.GetString("ctExtParams"); + + } + else if (routerType==3) + { + cmGroupid = context.GetInt("cmGroupid", 0); + cuGroupid = context.GetInt("cuGroupid", 0); + ctGroupid = context.GetInt("ctGroupid", 0); + + } + + } + string parentId = context.GetString("parentId", "0"); + string path = ""; + if (parentId.Equals("0")) + { + path = "0"; + } + else + { + GwProduct newProduct = _Dao.Get(parentId); + if(newProduct!=null) + { + path = newProduct.Path=="" ? "0" : newProduct.Path + "," + newProduct.Id ; + } + else + { + path = "0"; + } + + } + int isEnable = context.GetInt("isEnable", 0); + + //int price = context.GetInt("price", 0); + //int givingNum = context.GetInt("givingNum", 0); + string remark = context.GetString("remark", ""); + DateTime createTime = DateTime.Now; + string creator = context.OperatorID; + //DateTime update_time = context.GetDateTime("update_time"); + //string updateor = context.GetString("updateor", ""); + + //鏍¢獙 + if (classes == -1) { + throw new ArgumentException("璇烽�夋嫨绫诲埆锛�"); + } + else + { + if(string.IsNullOrEmpty(name)) + { + throw new ArgumentException("璇疯緭鍏ュ悕绉帮紒"); + } + //浜у搧鐩稿叧椤规牎楠� + if (classes == 1) + { + if (routerType==0 ) + throw new ArgumentException("璇烽�夋嫨璺敱绫诲瀷锛�"); + if (cmGroupid == 0 && cuGroupid == 0 && ctGroupid == 0 && routerType == 3 && classes==1) + throw new ArgumentException("鑷冲皯鎸囧畾涓�涓�氶亾缁勶紒"); + if (cmOpId == 0 && cuOpId == 0 && ctOpId == 0 && routerType == 1 && classes==1) + throw new ArgumentException("鑷冲皯鎸囧畾涓�涓�氶亾锛�"); + if (!string.IsNullOrEmpty(context.GetString("sort")) && !Regex.IsMatch(context.GetString("sort"), "^[0-9]*$")) + throw new Exception("搴忓彿蹇呴』涓烘暟瀛�"); + if (!string.IsNullOrEmpty(context.GetString("price")) && !Regex.IsMatch(context.GetString("price"), "^[0-9]*$") && price<=0 ) + throw new Exception("鍙傝�冨崟浠蜂笉鑳藉皬浜庣瓑浜�0"); + if (!string.IsNullOrEmpty(context.GetString("givingNum")) && !Regex.IsMatch(context.GetString("givingNum"), "^[0-9]*$")) + throw new Exception("榛樿璧犻�佹潯鏁板繀椤讳负鏁存暟"); + } + //浜у搧鐩稿叧椤规牎楠� + else if (classes == 0) + { + + } + + } + + this._Dao.Add(new GwProduct() + { + Id = id, + Name = name, + Icon = icon, + Instructions = instructions, + Classes = classes, + ParentId = parentId, + Path = path, + IsDefault = isDefault, + IsEnable = isEnable, + Sort = sort, + RouterType = routerType, + CmOpId = cmOpId, + CuOpId = cuOpId, + CtOpId = ctOpId, + CmGroupid = cmGroupid, + CuGroupid = cuGroupid, + CtGroupid = ctGroupid, + CmExtParams = cmExtParams, + CuExtParams = cuExtParams, + CtExtParams = ctExtParams, + Price = price, //鍗曚环鎹㈢畻 + GivingNum = givingNum, + Remark = remark, + CreateTime = createTime, + Creator = creator + //UpdateTime = update_time, + //Updateor = updateor + + }); + return new JsonPageResult(true, info + "淇℃伅娣诲姞鎴愬姛锛�"); + } + + //鏇存柊浜у搧鎴栦骇鍝佸垎绫� + private JsonPageResult Update(PageContext<SysUser> context) + { + string id = context.GetString("id"); + string name = context.GetString("name"); + int classes = context.GetInt("classes", -1); + string icon = ""; + string instructions = ""; + int isDefault = 0; + int sort = 0; + + int routerType = 0; + int cmOpId = 0; + int cuOpId = 0; + int ctOpId = 0; + string cmExtParams = ""; + string cuExtParams = ""; + string ctExtParams = ""; + int cmGroupid = 0; + int cuGroupid = 0; + int ctGroupid = 0; + int price = 0; + int givingNum = 0; + + string info = "" ; + if (classes == -1) { + throw new ArgumentException("璇烽�夋嫨绫诲埆锛�"); + } + else + { + if(classes == 1) + { + info = "浜у搧"; + if (string.IsNullOrEmpty(name)) + { + throw new ArgumentException(info + "鍚嶇О涓嶈兘涓虹┖锛�"); + } + + } + else if (classes == 0) + { + info = "浜у搧鍒嗙被"; + if (string.IsNullOrEmpty(name)) + { + throw new ArgumentException(info + "鍚嶇О涓嶈兘涓虹┖锛�"); + } + + } + + } + + + //1-浜у搧锛�0-鍒嗙被 + if (classes==1) + { + icon = context.GetString("icon"); + instructions = context.GetString("instructions"); + isDefault = context.GetInt("isDefault", 0); + + int num = Math.Max((int) (context.GetDecimal("price", new Decimal(4, 0, 0, false, (byte) 2)) * new Decimal(1000)), 1); + price = num; + givingNum = context.GetInt("givingNum", 0); + sort = context.GetInt("sort", 0); + + routerType = context.GetInt("routerType", 1); + //璺敱绫诲瀷锛�1-閫氶亾璺敱锛�3-閫氶亾缁勮矾鐢便�� + if (routerType==1) + { + cmOpId = context.GetInt("cmOpId", 0); + cuOpId = context.GetInt("cuOpId", 0); + ctOpId = context.GetInt("ctOpId", 0); + cmExtParams = context.GetString("cmExtParams"); + cuExtParams = context.GetString("cuExtParams"); + ctExtParams = context.GetString("ctExtParams"); + + } + else if (routerType==3) + { + cmGroupid = context.GetInt("cmGroupid", 0); + cuGroupid = context.GetInt("cuGroupid", 0); + ctGroupid = context.GetInt("ctGroupid", 0); + + } + + } + string parentId = context.GetString("parentId", "0"); + string path = ""; + if (parentId.Equals("0")) + { + path = "0"; + } + else + { + GwProduct newProduct = _Dao.Get(parentId); + if(newProduct!=null) + { + path = newProduct.Path=="" ? "0" : newProduct.Path + "," + newProduct.Id ; + } + else + { + path = "0"; + } + + } + int isEnable = context.GetInt("isEnable", 0); + + string remark = context.GetString("remark", ""); + //DateTime createTime = context.GetDateTime("createTime"); + //int creator = context.GetInt("creator", 0); + //DateTime updateTime = context.GetDateTime("updateTime"); + DateTime updateTime = DateTime.Now; + string updateor = context.OperatorID; + + //鏍¢獙 + if (classes == -1) { + throw new ArgumentException("璇烽�夋嫨绫诲埆锛�"); + } + else + { + if(string.IsNullOrEmpty(name)) + { + throw new ArgumentException("璇疯緭鍏ュ悕绉帮紒"); + } + //浜у搧鐩稿叧椤规牎楠� + if (classes == 1) + { + if (routerType==0 ) + throw new ArgumentException("璇烽�夋嫨璺敱绫诲瀷锛�"); + if (cmGroupid == 0 && cuGroupid == 0 && ctGroupid == 0 && routerType == 3 && classes==1) + throw new ArgumentException("鑷冲皯鎸囧畾涓�涓�氶亾缁勶紒"); + if (cmOpId == 0 && cuOpId == 0 && ctOpId == 0 && routerType == 1 && classes==1) + throw new ArgumentException("鑷冲皯鎸囧畾涓�涓�氶亾锛�"); + if (!string.IsNullOrEmpty(context.GetString("sort")) && !Regex.IsMatch(context.GetString("sort"), "^[0-9]*$")) + throw new Exception("搴忓彿蹇呴』涓烘暟瀛�"); + if (!string.IsNullOrEmpty(context.GetString("price")) && !Regex.IsMatch(context.GetString("price"), "^[0-9]*$") && price<=0 ) + throw new Exception("鍙傝�冨崟浠蜂笉鑳藉皬浜庣瓑浜�0"); + if (!string.IsNullOrEmpty(context.GetString("givingNum")) && !Regex.IsMatch(context.GetString("givingNum"), "^[0-9]*$")) + throw new Exception("榛樿璧犻�佹潯鏁板繀椤讳负鏁存暟"); + } + //浜у搧鐩稿叧椤规牎楠� + else if (classes == 0) + { + + } + + } + + this._Dao.Update(new GwProduct() + { + Id = id, + Name = name, + Icon = icon, + Instructions = instructions, + Classes = classes, + ParentId = parentId, + Path = path, + IsDefault = isDefault, + IsEnable = isEnable, + Sort = sort, + RouterType = routerType, + CmOpId = cmOpId, + CuOpId = cuOpId, + CtOpId = ctOpId, + CmGroupid = cmGroupid, + CuGroupid = cuGroupid, + CtGroupid = ctGroupid, + CmExtParams = cmExtParams, + CuExtParams = cuExtParams, + CtExtParams = ctExtParams, + Price = price, //鍗曚环鎹㈢畻 + GivingNum = givingNum, + Remark = remark, + //CreateTime = createTime, + //Creator = creator, + UpdateTime = updateTime, + Updateor = updateor + + }); + + //鏇存柊鍏宠仈鐨勪骇鍝佽矾寰凱ATH + _Dao.UpdatePath(id, path); + + + return new JsonPageResult(true, info + "淇℃伅鏇存柊鎴愬姛锛�"); + } + + //鏍规嵁涓婚敭鑾峰彇浜у搧鎴栦骇鍝佸垎绫讳俊鎭� + private JsonPageResult Get(PageContext<SysUser> context) + { + return new JsonPageResult(true, this._Dao.Get(context.GetString("id"))); + } + + //鍥炬爣鏂囦欢涓婁紶 + private JsonPageResult UpLoad(PageContext<SysUser> context) + { + Stopwatch stopwatch = new Stopwatch(); + stopwatch.Start(); + HttpPostedFile httpPostedFile = context.Files["certPath"]; + if (httpPostedFile == null || httpPostedFile.FileName == "") + throw new Exception("璇烽�夋嫨瑕佷笂浼犵殑BMP锛堜綅鍥撅級銆丣PG銆丣PEG銆丳NG銆丟IF鏂囦欢,骞舵鏌ユ枃浠跺ぇ灏忥紒"); + string extension = Path.GetExtension(httpPostedFile.FileName); + if (!extension.Equals(".jpg", StringComparison.OrdinalIgnoreCase) + && !extension.Equals(".jpeg", StringComparison.OrdinalIgnoreCase) + && !extension.Equals(".png", StringComparison.OrdinalIgnoreCase) + && !extension.Equals(".gif", StringComparison.OrdinalIgnoreCase) + && !extension.Equals(".bmp", StringComparison.OrdinalIgnoreCase)) + throw new Exception("涓婁紶鏂囦欢鏍煎紡涓嶆纭紝鍙厑璁镐笂浼燘MP锛堜綅鍥撅級銆丣PG銆丣PEG銆丳NG銆丟IF鏂囦欢!"); + if (httpPostedFile.ContentLength > 5242880 ) + throw new Exception("鏂囦欢涓婁紶涓嶈兘瓒呰繃5M锛岃妫�鏌ユ枃浠跺ぇ灏忥紝鏄惁鏈夊啓鏉冮檺锛�"); + + //string @string = context.GetString("ablackpool"); + //if (string.IsNullOrEmpty(@string)) + // throw new Exception("璇烽�夋嫨榛戝悕鍗曟睜锛�"); + + List<Stream> outputStreamList = new List<Stream>(); + if (extension.Equals(".jpg", StringComparison.OrdinalIgnoreCase) + && extension.Equals(".jpeg", StringComparison.OrdinalIgnoreCase) + && extension.Equals(".png", StringComparison.OrdinalIgnoreCase) + && extension.Equals(".gif", StringComparison.OrdinalIgnoreCase) + && extension.Equals(".bmp", StringComparison.OrdinalIgnoreCase)) + outputStreamList.Add(httpPostedFile.InputStream); + //else if (extension.Equals(".zip", StringComparison.OrdinalIgnoreCase)) + // ZipUtils.Decompression(httpPostedFile.InputStream, ref outputStreamList, true); + + //string fieldName = "c:/AYZH"; + //HttpContext httpContext = new HttpContext(); + //WebTool.SaveUploadFile(httpContext, fieldName); + + stopwatch.Stop(); + string str = "涓婁紶鑰楁椂锛�" + (object) stopwatch.ElapsedMilliseconds + "ms"; + return new JsonPageResult(true, (object) new + { + Message = "鏂囦欢涓婁紶鎴愬姛锛�", + Msg = str + }); + } + + //鑾峰彇閫氶亾鍒楄〃 + private List<GwOp> OpList + { + get + { + if (this._OpList == null) + { + using (GwOpDao gwOpDao = new GwOpDao()) + this._OpList = gwOpDao.LoadInfoList(); + } + return this._OpList; + } + } + + //鍔犺浇浜у搧鍙婁骇鍝佸垎绫讳俊鎭� + private List<GwProduct> ProductAllList() + { + GwProduct bean = new GwProduct(); + bean.Classes = -1; + bean.IsDefault = -1; + bean.IsEnable = -1; + + List<GwProduct> list = _Dao.getAllList(bean); + + return list; + } + + //鑾峰彇浜у搧鎴栦骇鍝佸垎绫诲垪琛� + private List<GwProduct> ProductList + { + get + { + if (this._ProductList == null) + { + this._ProductList = this.ProductAllList(); + } + return this._ProductList; + } + } + + //浜у搧鎴栦骇鍝佸垎绫籌D杞崲鍚嶇О + private string ProductToName(string productId) + { + if (this.ProductList == null) + return string.Empty; + GwProduct bean = this.ProductList.Find((Predicate<GwProduct>)(product => product.Id == productId)); + if (bean != null) + //return string.Format("{0}-{1}", (object)bean.Id, (object)bean.Name); + return string.Format("{0}", (object)bean.Name); + return string.Empty; + } + + //鏇存柊淇℃伅鍚敤鎴栧仠鐢� + private JsonPageResult UpdateStatus(PageContext<SysUser> context) + { + string id = context.GetString("id"); + string isEnable = context.GetString("isEnable"); + + if(isEnable=="0") { + if (this._Dao.GwProductUseCount(id) > 0) + throw new ArgumentException("褰撳墠浜у搧鍒嗙被宸插湪浜у搧淇℃伅浣跨敤涓�,鏃犳硶鍋滅敤锛�"); + if (this._Dao.GwSpUseCount(id) > 0) + throw new ArgumentException("褰撳墠浜у搧鍦ㄥ鎴疯处鍙蜂俊鎭腑浣跨敤,鏃犳硶鍋滅敤锛�"); + } + this._Dao.UpdateStatus(id, isEnable); + return new JsonPageResult(true, "鏇存柊淇℃伅鐘舵�佹垚鍔燂紒"); + + } + + //鑾峰彇閫氶亾缁勫垪琛� + private List<GwOpGroup> GroupList + { + get + { + if (this._GroupList == null) + { + using (GwOpGroupDao gwOpGroupDao = new GwOpGroupDao()) + this._GroupList = gwOpGroupDao.GetGroupList(); + } + return this._GroupList; + } + } + + //閫氶亾ID杞崲鍚嶇О + private string GetOpName(int opID) + { + if (this.OpList == null) + return string.Empty; + GwOp gwOp = this.OpList.Find((Predicate<GwOp>)(op => op.OpID == opID)); + if (gwOp != null) + return string.Format("{0}-{1}", (object)gwOp.OpID, (object)gwOp.OpName); + return string.Empty; + } + + //浜у搧绫诲埆杞崲鍚嶇О + private string ClassesToName(int classes) + { + if (classes == -1) + return string.Empty; + else if(classes == 0) + return "0-浜у搧鍒嗙被"; + else if(classes == 1) + return "1-浜у搧"; + + return string.Empty; + } + + //浜у搧鏄惁榛樿杞崲鍚嶇О + private string IsDefaultToName(int isDefault) + { + if (isDefault == -1) + return string.Empty; + else if(isDefault == 0) + return "0-涓�у寲"; + else if(isDefault == 1) + return "1-绯荤粺榛樿"; + + return string.Empty; + } + + //鍚敤鍋滅敤杞崲鍚嶇О + private string IsEnableToName(int isEnable) + { + if (isEnable == -1) + return string.Empty; + else if(isEnable == 0) + return "0-鍋滅敤"; + else if(isEnable == 1) + return "1-鍚敤"; + + return string.Empty; + } + + //閫氶亾缁処D杞崲鍚嶇О + private string GetGroupName(int groupID) + { + if (this.GroupList == null) + return string.Empty; + GwOpGroup gwOpGroup = this.GroupList.Find((Predicate<GwOpGroup>)(group => group.GroupID == groupID)); + if (gwOpGroup != null) + return string.Format("{0}-{1}", (object)gwOpGroup.GroupID, (object)gwOpGroup.GroupName); + return string.Empty; + } +} \ No newline at end of file -- Gitblit v1.9.1