using BizCom; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; namespace SiteCore.Handler { public partial class app { #region dic private string getDicClassName(string pType) { //转成大小写 switch (pType) { case "modular": { return "XModular"; } } return pType; } public void get_dic_item() { if (UrlParmsCheck("class,mId")) { string c = GetString("class"); string mId = GetString("mId"); DicSysBase sysBase = GetReflectionObject(c) as DicSysBase; DataTable dt = sysBase.GetDataTable("ID=" + mId); if (dt != null && dt.Rows.Count > 0) { returnSuccess(Utils.Serialization.JsonString.DataTable2AjaxJson(dt)); } } } public void del_dic_item() { if (UrlParmsCheck("class,mId")) { string c = GetString("class"); string mId = GetString("mId"); DicSysBase sysBase = GetReflectionObject(c) as DicSysBase; DicSysBase entity = sysBase.GetEntity(mId) as DicSysBase; if (entity != null) { entity.DelChild(entity.ID); entity.Delete(); returnSuccessMsg(entity.ParentID + "|删除成功!"); } } } public void build_dic_item() { if (UrlParmsCheck("mId")) { string mId = GetString("mId"); XModular.BuilderOperate(mId); returnSuccessMsg(mId + "|生成成功!"); } } public void transfer_dic_item() { if (UrlParmsCheck("mId,pId,sort")) { string mId = GetString("mId"); int pId = GetInt("pId"); int sort = GetInt("sort"); string c = GetString("class"); DicSysBase sysBase = GetReflectionObject(getDicClassName(c)) as DicSysBase; sysBase.TransModular(mId, pId, sort, sysBase.tableName); returnSuccessMsg(mId + "|转移成功!"); } } public void line_dic_item() { if (UrlParmsCheck("mId,st,et")) { string mId = GetString("mId"); string prev = GetString("prev"); int st = GetInt("st"); int et = GetInt("et"); string c = GetString("class"); DicSysBase sysBase = GetReflectionObject(getDicClassName(c)) as DicSysBase; sysBase.SaveLine(mId, prev, st, et, sysBase.tableName); returnSuccessMsg(mId + "|生成成功!"); } } public void save_dic_item() { if (UrlParmsCheck("id,pid,name,class")) { string c = GetString("class"); int id = GetInt("id"); int pid = GetInt("pid"); string name = GetString("name"); string code = GetString("code"); int sort = GetInt("sort"); int del = GetInt("del"); string memo = GetString("memo"); string url = GetString("url"); string tag = GetString("tag"); string icon = GetString("icon"); int operate = GetInt("operate"); string cName = c;// getDicClassName(c); if (cName == "") { return; } DicSysBase sysBase = GetReflectionObject(cName) as DicSysBase; DicSysBase entity = null; if (id > 0) { entity = sysBase.GetEntity(id) as DicSysBase; } else { entity = sysBase; } entity.ParentID = pid; entity.Name = name; entity.Code = code; entity.Sort = sort; entity.IsDel = (del == 1 ? true : false); entity.Memo = memo; switch (c) { case "XModular": { entity.Url = url; entity.Tag = tag; entity.Icon = icon; entity.isOperate = (operate == 1 ? true : false); break; } case "hoststation": { entity.HostFieldName = GetString("hostfield"); entity.HostName = GetString("hostname"); entity.MaxStock = GetDouble("maxstock"); entity.WarningStock = GetDouble("warningstock"); break; } } if (entity.ParentID > 0) { DataRow dr = sysBase.GetParentFields("Path,Code", entity.ParentID); string parentPath = dr["Path"].ToString(); entity.Path = parentPath == "" ? "|" + entity.ParentID + "|" : parentPath + entity.ParentID + "|"; if (c == "opt") { entity.PCode = dr["Code"].ToString(); } } if (id > 0) entity.Update(); else entity.Create(); switch (c) { case "XModular": { //去除己保存的所有权限 //WebUser.ClearPermissionCache(); break; } } returnSuccessMsg(entity.ID + "|保存成功"); } } #endregion #region category private string getCTable(string t) { switch (t) { case "utype": { return "ce_erpunittype"; } case "cartype": { return "ce_erpcartype"; } case "paymenttype": { return "ce_erppaymenttype"; } case "transgrade": { return "ce_erptransgrade"; } } return ""; } public void get_category() { string cate = GetPostString("cate"); if (cate != "") { DataTable dt = null; dt = CategoryService.GetCategory(getCTable(cate), ""); writeGridJson(dt.Rows.Count, Utils.Serialization.JsonString.DataTable2AjaxJson(dt)); } } public void del_category() { if (UrlParmsCheck("sId,cate")) { int sId = GetInt("sId"); string cate = GetString("cate"); CategoryService.DelCategory(getCTable(cate), sId); returnSuccessMsg("己删除"); } } public void save_category() { if (UrlParmsCheck("name,cate")) { int sId = GetInt("sId"); string name = GetString("name"); string cate = GetString("cate"); CategoryService.SaveCategory(getCTable(cate), name, sId); returnSuccessMsg("保存成功!"); } } #endregion } }