app.dic.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. using BizCom;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. namespace SiteCore.Handler
  8. {
  9. public partial class app
  10. {
  11. #region dic
  12. private string getDicClassName(string pType)
  13. {
  14. //转成大小写
  15. switch (pType)
  16. {
  17. case "modular":
  18. {
  19. return "XModular";
  20. }
  21. }
  22. return pType;
  23. }
  24. public void get_dic_item()
  25. {
  26. if (UrlParmsCheck("class,mId"))
  27. {
  28. string c = GetString("class");
  29. string mId = GetString("mId");
  30. DicSysBase sysBase = GetReflectionObject(c) as DicSysBase;
  31. DataTable dt = sysBase.GetDataTable("ID=" + mId);
  32. if (dt != null && dt.Rows.Count > 0)
  33. {
  34. returnSuccess(Utils.Serialization.JsonString.DataTable2AjaxJson(dt));
  35. }
  36. }
  37. }
  38. public void del_dic_item()
  39. {
  40. if (UrlParmsCheck("class,mId"))
  41. {
  42. string c = GetString("class");
  43. string mId = GetString("mId");
  44. DicSysBase sysBase = GetReflectionObject(c) as DicSysBase;
  45. DicSysBase entity = sysBase.GetEntity(mId) as DicSysBase;
  46. if (entity != null)
  47. {
  48. entity.DelChild(entity.ID);
  49. entity.Delete();
  50. returnSuccessMsg(entity.ParentID + "|删除成功!");
  51. }
  52. }
  53. }
  54. public void build_dic_item()
  55. {
  56. if (UrlParmsCheck("mId"))
  57. {
  58. string mId = GetString("mId");
  59. XModular.BuilderOperate(mId);
  60. returnSuccessMsg(mId + "|生成成功!");
  61. }
  62. }
  63. public void transfer_dic_item()
  64. {
  65. if (UrlParmsCheck("mId,pId,sort"))
  66. {
  67. string mId = GetString("mId");
  68. int pId = GetInt("pId");
  69. int sort = GetInt("sort");
  70. string c = GetString("class");
  71. DicSysBase sysBase = GetReflectionObject(getDicClassName(c)) as DicSysBase;
  72. sysBase.TransModular(mId, pId, sort, sysBase.tableName);
  73. returnSuccessMsg(mId + "|转移成功!");
  74. }
  75. }
  76. public void line_dic_item()
  77. {
  78. if (UrlParmsCheck("mId,st,et"))
  79. {
  80. string mId = GetString("mId");
  81. string prev = GetString("prev");
  82. int st = GetInt("st");
  83. int et = GetInt("et");
  84. string c = GetString("class");
  85. DicSysBase sysBase = GetReflectionObject(getDicClassName(c)) as DicSysBase;
  86. sysBase.SaveLine(mId, prev, st, et, sysBase.tableName);
  87. returnSuccessMsg(mId + "|生成成功!");
  88. }
  89. }
  90. public void save_dic_item()
  91. {
  92. if (UrlParmsCheck("id,pid,name,class"))
  93. {
  94. string c = GetString("class");
  95. int id = GetInt("id");
  96. int pid = GetInt("pid");
  97. string name = GetString("name");
  98. string code = GetString("code");
  99. int sort = GetInt("sort");
  100. int del = GetInt("del");
  101. string memo = GetString("memo");
  102. string url = GetString("url");
  103. string tag = GetString("tag");
  104. string icon = GetString("icon");
  105. int operate = GetInt("operate");
  106. string cName = c;// getDicClassName(c);
  107. if (cName == "")
  108. {
  109. return;
  110. }
  111. DicSysBase sysBase = GetReflectionObject(cName) as DicSysBase;
  112. DicSysBase entity = null;
  113. if (id > 0)
  114. {
  115. entity = sysBase.GetEntity(id) as DicSysBase;
  116. }
  117. else
  118. {
  119. entity = sysBase;
  120. }
  121. entity.ParentID = pid;
  122. entity.Name = name;
  123. entity.Code = code;
  124. entity.Sort = sort;
  125. entity.IsDel = (del == 1 ? true : false);
  126. entity.Memo = memo;
  127. switch (c)
  128. {
  129. case "XModular":
  130. {
  131. entity.Url = url;
  132. entity.Tag = tag;
  133. entity.Icon = icon;
  134. entity.isOperate = (operate == 1 ? true : false);
  135. break;
  136. }
  137. case "hoststation":
  138. {
  139. entity.HostFieldName = GetString("hostfield");
  140. entity.HostName = GetString("hostname");
  141. entity.MaxStock = GetDouble("maxstock");
  142. entity.WarningStock = GetDouble("warningstock");
  143. break;
  144. }
  145. }
  146. if (entity.ParentID > 0)
  147. {
  148. DataRow dr = sysBase.GetParentFields("Path,Code", entity.ParentID);
  149. string parentPath = dr["Path"].ToString();
  150. entity.Path = parentPath == "" ? "|" + entity.ParentID + "|" : parentPath + entity.ParentID + "|";
  151. if (c == "opt")
  152. {
  153. entity.PCode = dr["Code"].ToString();
  154. }
  155. }
  156. if (id > 0) entity.Update();
  157. else entity.Create();
  158. switch (c)
  159. {
  160. case "XModular":
  161. {
  162. //去除己保存的所有权限
  163. //WebUser.ClearPermissionCache();
  164. break;
  165. }
  166. }
  167. returnSuccessMsg(entity.ID + "|保存成功");
  168. }
  169. }
  170. #endregion
  171. #region category
  172. private string getCTable(string t)
  173. {
  174. switch (t)
  175. {
  176. case "utype":
  177. {
  178. return "ce_erpunittype";
  179. }
  180. case "cartype":
  181. {
  182. return "ce_erpcartype";
  183. }
  184. case "paymenttype":
  185. {
  186. return "ce_erppaymenttype";
  187. }
  188. case "transgrade":
  189. {
  190. return "ce_erptransgrade";
  191. }
  192. }
  193. return "";
  194. }
  195. public void get_category()
  196. {
  197. string cate = GetPostString("cate");
  198. if (cate != "")
  199. {
  200. DataTable dt = null;
  201. dt = CategoryService.GetCategory(getCTable(cate), "");
  202. writeGridJson(dt.Rows.Count, Utils.Serialization.JsonString.DataTable2AjaxJson(dt));
  203. }
  204. }
  205. public void del_category()
  206. {
  207. if (UrlParmsCheck("sId,cate"))
  208. {
  209. int sId = GetInt("sId");
  210. string cate = GetString("cate");
  211. CategoryService.DelCategory(getCTable(cate), sId);
  212. returnSuccessMsg("己删除");
  213. }
  214. }
  215. public void save_category()
  216. {
  217. if (UrlParmsCheck("name,cate"))
  218. {
  219. int sId = GetInt("sId");
  220. string name = GetString("name");
  221. string cate = GetString("cate");
  222. CategoryService.SaveCategory(getCTable(cate), name, sId);
  223. returnSuccessMsg("保存成功!");
  224. }
  225. }
  226. #endregion
  227. }
  228. }