RelationClass.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using MySystem.Models;
  5. namespace MySystem
  6. {
  7. public class RelationClass
  8. {
  9. public static string GetColInfo(string key)
  10. {
  11. using (Models.WebCMSEntities db = new Models.WebCMSEntities())
  12. {
  13. Models.Col item = db.Col.FirstOrDefault(m => m.ColId == key);
  14. if (item != null)
  15. {
  16. return item.ColName;
  17. }
  18. }
  19. return "";
  20. }
  21. public static string GetColInfo(int key)
  22. {
  23. using (BsModels.WebCMSEntities db = new BsModels.WebCMSEntities())
  24. {
  25. BsModels.Col item = db.Col.FirstOrDefault(m => m.Id == key);
  26. if (item != null)
  27. {
  28. return item.ColName;
  29. }
  30. }
  31. return "";
  32. }
  33. public static string GetMsgTemplateInfo(int key)
  34. {
  35. using (Models.WebCMSEntities db = new Models.WebCMSEntities())
  36. {
  37. MsgTemplate item = db.MsgTemplate.FirstOrDefault(m => m.Id == key);
  38. if (item != null)
  39. {
  40. return item.Title;
  41. }
  42. }
  43. return "";
  44. }
  45. public static string GetMsgPlacardInfo(int key)
  46. {
  47. using (Models.WebCMSEntities db = new Models.WebCMSEntities())
  48. {
  49. MsgPlacard item = db.MsgPlacard.FirstOrDefault(m => m.Id == key);
  50. if (item != null)
  51. {
  52. return item.Title;
  53. }
  54. }
  55. return "";
  56. }
  57. public static string GetUserLevelSetInfo(int key)
  58. {
  59. using (WebCMSEntities db = new WebCMSEntities())
  60. {
  61. UserLevelSet item = db.UserLevelSet.FirstOrDefault(m => m.Id == key);
  62. if (item != null)
  63. {
  64. return item.Name;
  65. }
  66. }
  67. return "";
  68. }
  69. public static string GetUserGroupList(string keys)
  70. {
  71. string[] IdList = keys.Split(',');
  72. List<int> List = new List<int>();
  73. foreach (string key in IdList)
  74. {
  75. List.Add(int.Parse(key));
  76. }
  77. string result = "";
  78. using (WebCMSEntities db = new WebCMSEntities())
  79. {
  80. var items = db.UserGroup.Select(m => new { m.Id, m.Name }).Where(m => List.Contains(m.Id));
  81. foreach (var item in items)
  82. {
  83. result += item.Name + ",";
  84. }
  85. }
  86. return result.TrimEnd(',');
  87. }
  88. public static string GetColList(string keys)
  89. {
  90. string[] IdList = keys.Split(',');
  91. List<int> List = new List<int>();
  92. foreach (string key in IdList)
  93. {
  94. List.Add(int.Parse(key));
  95. }
  96. string result = "";
  97. using (WebCMSEntities db = new WebCMSEntities())
  98. {
  99. var items = db.Col.Select(m => new { m.Id, m.ColName }).Where(m => List.Contains(m.Id));
  100. foreach (var item in items)
  101. {
  102. result += item.ColName + ",";
  103. }
  104. }
  105. return result.TrimEnd(',');
  106. }
  107. public static string GetProductFareTempInfo(int key)
  108. {
  109. using (WebCMSEntities db = new WebCMSEntities())
  110. {
  111. ProductFareTemp item = db.ProductFareTemp.FirstOrDefault(m => m.Id == key);
  112. if (item != null)
  113. {
  114. return item.Name;
  115. }
  116. }
  117. return "";
  118. }
  119. public static string GetMerchantClassInfo(int key)
  120. {
  121. using (WebCMSEntities db = new WebCMSEntities())
  122. {
  123. MerchantClass item = db.MerchantClass.FirstOrDefault(m => m.Id == key);
  124. if (item != null)
  125. {
  126. return item.ColName;
  127. }
  128. }
  129. return "";
  130. }
  131. public static string GetMerchantColInfo(string key)
  132. {
  133. using (WebCMSEntities db = new WebCMSEntities())
  134. {
  135. MerchantCol item = db.MerchantCol.FirstOrDefault(m => m.ColId == key);
  136. if (item != null)
  137. {
  138. return item.ColName;
  139. }
  140. }
  141. return "";
  142. }
  143. public static string GetErpCompanysInfo(string key)
  144. {
  145. using (WebCMSEntities db = new WebCMSEntities())
  146. {
  147. ErpCompanys item = db.ErpCompanys.FirstOrDefault(m => m.Name == key);
  148. if (item != null)
  149. {
  150. return item.Name;
  151. }
  152. }
  153. return "";
  154. }
  155. public static string GetMerchantsInfo(int key)
  156. {
  157. using (WebCMSEntities db = new WebCMSEntities())
  158. {
  159. Merchants item = db.Merchants.FirstOrDefault(m => m.Id == key);
  160. if (item != null)
  161. {
  162. return item.Name;
  163. }
  164. }
  165. return "";
  166. }
  167. public static string GetOrderRefundReasonInfo(int key)
  168. {
  169. using (WebCMSEntities db = new WebCMSEntities())
  170. {
  171. OrderRefundReason item = db.OrderRefundReason.FirstOrDefault(m => m.Id == key);
  172. if (item != null)
  173. {
  174. return item.Name;
  175. }
  176. }
  177. return "";
  178. }
  179. public static string GetMerchantsList(string keys)
  180. {
  181. string[] IdList = keys.Split(',');
  182. List<int> List = new List<int>();
  183. foreach (string key in IdList)
  184. {
  185. List.Add(int.Parse(key));
  186. }
  187. string result = "";
  188. using (WebCMSEntities db = new WebCMSEntities())
  189. {
  190. var items = db.Merchants.Select(m => new { m.Id, m.Name }).Where(m => List.Contains(m.Id));
  191. foreach (var item in items)
  192. {
  193. result += item.Name + ",";
  194. }
  195. }
  196. return result.TrimEnd(',');
  197. }
  198. public static string GetProductsList(string keys)
  199. {
  200. string[] IdList = keys.Split(',');
  201. List<int> List = new List<int>();
  202. foreach (string key in IdList)
  203. {
  204. List.Add(int.Parse(key));
  205. }
  206. string result = "";
  207. using (WebCMSEntities db = new WebCMSEntities())
  208. {
  209. var items = db.Products.Select(m => new { m.Id, m.ProductName }).Where(m => List.Contains(m.Id));
  210. foreach (var item in items)
  211. {
  212. result += item.ProductName + ",";
  213. }
  214. }
  215. return result.TrimEnd(',');
  216. }
  217. public static string GetCouponsList(string keys)
  218. {
  219. string[] IdList = keys.Split(',');
  220. List<int> List = new List<int>();
  221. foreach (string key in IdList)
  222. {
  223. List.Add(int.Parse(key));
  224. }
  225. string result = "";
  226. using (WebCMSEntities db = new WebCMSEntities())
  227. {
  228. var items = db.Coupons.Select(m => new { m.Id, m.Name }).Where(m => List.Contains(m.Id));
  229. foreach (var item in items)
  230. {
  231. result += item.Name + ",";
  232. }
  233. }
  234. return result.TrimEnd(',');
  235. }
  236. public static string GetKqProductBrandInfo(int key)
  237. {
  238. using (WebCMSEntities db = new WebCMSEntities())
  239. {
  240. KqProducts item = db.KqProducts.FirstOrDefault(m => m.Id == key);
  241. if (item != null)
  242. {
  243. return item.Name;
  244. }
  245. }
  246. return "";
  247. }
  248. public static string GetUsersInfo(int key)
  249. {
  250. using (WebCMSEntities db = new WebCMSEntities())
  251. {
  252. Users item = db.Users.FirstOrDefault(m => m.Id == key);
  253. if (item != null)
  254. {
  255. return item.RealName;
  256. }
  257. }
  258. return "";
  259. }
  260. public static string GetMerchantInfoInfo(int key)
  261. {
  262. using (WebCMSEntities db = new WebCMSEntities())
  263. {
  264. MerchantInfo item = db.MerchantInfo.FirstOrDefault(m => m.Id == key);
  265. if (item != null)
  266. {
  267. return item.Name;
  268. }
  269. }
  270. return "";
  271. }
  272. public static string GetKqProductBrandList(string keys)
  273. {
  274. if (string.IsNullOrEmpty(keys))
  275. {
  276. return "";
  277. }
  278. string[] IdList = keys.Split(',');
  279. List<int> List = new List<int>();
  280. foreach (string key in IdList)
  281. {
  282. List.Add(int.Parse(key));
  283. }
  284. string result = "";
  285. using (WebCMSEntities db = new WebCMSEntities())
  286. {
  287. var items = db.KqProducts.Select(m => new { m.Id, m.Name }).Where(m => List.Contains(m.Id));
  288. foreach (var item in items)
  289. {
  290. result += item.Name + ",";
  291. }
  292. }
  293. return result.TrimEnd(',');
  294. }
  295. public static string GetActivityInfoInfo(int key)
  296. {
  297. using (WebCMSEntities db = new WebCMSEntities())
  298. {
  299. ActivityInfo item = db.ActivityInfo.FirstOrDefault(m => m.Id == key);
  300. if (item != null)
  301. {
  302. return item.ActName;
  303. }
  304. }
  305. return "";
  306. }
  307. public static string GetStoreHouseInfo(int key)
  308. {
  309. using (WebCMSEntities db = new WebCMSEntities())
  310. {
  311. StoreHouse item = db.StoreHouse.FirstOrDefault(m => m.Id == key);
  312. if (item != null)
  313. {
  314. return item.StoreName;
  315. }
  316. }
  317. return "";
  318. }
  319. public static string GetUserBackKindInfo(int key)
  320. {
  321. using (WebCMSEntities db = new WebCMSEntities())
  322. {
  323. UserBackKind item = db.UserBackKind.FirstOrDefault(m => m.Id == key);
  324. if (item != null)
  325. {
  326. return item.Name;
  327. }
  328. }
  329. return "";
  330. }
  331. public static string GetPageUpdateInfoList(string keys)
  332. {
  333. string[] ModulePathList = keys.Split(',');
  334. List<string> List = new List<string>();
  335. foreach (string key in ModulePathList)
  336. {
  337. List.Add(key);
  338. }
  339. string result = "";
  340. using (WebCMSEntities db = new WebCMSEntities())
  341. {
  342. var items = db.PageUpdateInfo.Select(m => new { m.ModulePath, m.Title }).Where(m => List.Contains(m.ModulePath));
  343. foreach (var item in items)
  344. {
  345. result += item.Title + ",";
  346. }
  347. }
  348. return result.TrimEnd(',');
  349. }
  350. public static string GetTeamApplyInfo(int key)
  351. {
  352. using (WebCMSEntities db = new WebCMSEntities())
  353. {
  354. TeamApply item = db.TeamApply.FirstOrDefault(m => m.Id == key);
  355. if (item != null)
  356. {
  357. return item.TeamName;
  358. }
  359. }
  360. return "";
  361. }
  362. public static string GetProfitObjectsActivesInfo(int key)
  363. {
  364. using (WebCMSEntities db = new WebCMSEntities())
  365. {
  366. ProfitObjectsActives item = db.ProfitObjectsActives.FirstOrDefault(m => m.Id == key);
  367. if (item != null)
  368. {
  369. return item.Name;
  370. }
  371. }
  372. return "";
  373. }
  374. public static string GetProfitObjectsActivesList(string keys)
  375. {
  376. if(string.IsNullOrEmpty(keys)) return "";
  377. string[] IdList = keys.Split(',');
  378. List<int> List = new List<int>();
  379. foreach (string key in IdList)
  380. {
  381. List.Add(int.Parse(key));
  382. }
  383. string result = "";
  384. using (WebCMSEntities db = new WebCMSEntities())
  385. {
  386. var items = db.ProfitObjectsActives.Select(m => new { m.Id, m.Name }).Where(m => List.Contains(m.Id));
  387. foreach (var item in items)
  388. {
  389. result += item.Name + ",";
  390. }
  391. }
  392. return result.TrimEnd(',');
  393. }
  394. public static string GetSysAdminRoleInfo(int key)
  395. {
  396. using (BsModels.WebCMSEntities db = new BsModels.WebCMSEntities())
  397. {
  398. BsModels.SysAdminRole item = db.SysAdminRole.FirstOrDefault(m => m.Id == key);
  399. if (item != null)
  400. {
  401. return item.Name;
  402. }
  403. }
  404. return "";
  405. }
  406. public static string GetProductsInfo(int key)
  407. {
  408. using (WebCMSEntities db = new WebCMSEntities())
  409. {
  410. Products item = db.Products.FirstOrDefault(m => m.Id == key);
  411. if (item != null)
  412. {
  413. return item.ProductName;
  414. }
  415. }
  416. return "";
  417. }
  418. public static string GetAppVideoInfo(int key)
  419. {
  420. using (WebCMSEntities db = new WebCMSEntities())
  421. {
  422. AppVideo item = db.AppVideo.FirstOrDefault(m => m.Id == key);
  423. if (item != null)
  424. {
  425. return item.Name;
  426. }
  427. }
  428. return "";
  429. }
  430. public static string GetPosCouponsInfo(int key)
  431. {
  432. using (WebCMSEntities db = new WebCMSEntities())
  433. {
  434. PosCoupons item = db.PosCoupons.FirstOrDefault(m => m.Id == key);
  435. if (item != null)
  436. {
  437. return item.ExchangeCode;
  438. }
  439. }
  440. return "";
  441. }
  442. public static string GetPosMachinesTwoInfo(int key)
  443. {
  444. using (WebCMSEntities db = new WebCMSEntities())
  445. {
  446. PosMachinesTwo item = db.PosMachinesTwo.FirstOrDefault(m => m.Id == key);
  447. if (item != null)
  448. {
  449. return item.PosSn;
  450. }
  451. }
  452. return "";
  453. }
  454. public static string GetStoreMachineApplyInfo(int key)
  455. {
  456. using (WebCMSEntities db = new WebCMSEntities())
  457. {
  458. StoreMachineApply item = db.StoreMachineApply.FirstOrDefault(m => m.Id == key);
  459. if (item != null)
  460. {
  461. return item.ApplyNo;
  462. }
  463. }
  464. return "";
  465. }
  466. public static string GetKqProductsInfo(int key)
  467. {
  468. using (WebCMSEntities db = new WebCMSEntities())
  469. {
  470. KqProducts item = db.KqProducts.FirstOrDefault(m => m.Id == key);
  471. if (item != null)
  472. {
  473. return item.Name;
  474. }
  475. }
  476. return "";
  477. }
  478. public static string GetSchoolSignInTaskInfo(int key)
  479. {
  480. using (WebCMSEntities db = new WebCMSEntities())
  481. {
  482. SchoolSignInTask item = db.SchoolSignInTask.FirstOrDefault(m => m.Id == key);
  483. if (item != null)
  484. {
  485. return item.TaskName;
  486. }
  487. }
  488. return "";
  489. }
  490. }
  491. }