CodeAreaController.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using Ant.Service.Common;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.Mvc;
  7. using MES.Production.Service.IService;
  8. using ChangFa.Machinery.WebPage.Controllers;
  9. using Ant.ORM;
  10. using Ant.Data;
  11. using MES.Production.Entity;
  12. using JsonHelper = Ant.Service.Common.JsonHelper;
  13. namespace ChangFa.Machinery.WebPage.Areas.SysManage.Controllers
  14. {
  15. /// <summary>
  16. /// 省市县镇级联控制器
  17. /// add 作者: 季健国 QQ:181589805 by 2016-06-16
  18. /// </summary>
  19. public class CodeAreaController : BaseController
  20. {
  21. ICodeAreaManage CodeAreaManage { get; set; }
  22. /// <summary>
  23. /// 获取省份
  24. /// </summary>
  25. public ActionResult Prov()
  26. {
  27. var json = new JsonHelper() { Status = "y", Msg = "Success" };
  28. using (AntORM orm = new AntORM())
  29. {
  30. orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
  31. RequestModel res = new RequestModel
  32. {
  33. newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
  34. };
  35. var reslut = orm.Queryable<BaseProvince>().Where(p => p.Id > 0).ToList(res);
  36. if (reslut.IsSuccess)
  37. {
  38. var data = reslut.ResultModel;
  39. json.Data = JsonConverter.Serialize(data);
  40. }
  41. }
  42. return Json(json);
  43. }
  44. /// <summary>
  45. /// 根据省份获取城市信息
  46. /// </summary>
  47. /// <param name="id">省份ID</param>
  48. /// <returns></returns>
  49. public ActionResult City(string id)
  50. {
  51. var json = new JsonHelper() { Status = "y", Msg = "Success" };
  52. if (string.IsNullOrEmpty(id))
  53. {
  54. json.Msg = "Error";
  55. json.Status = "n";
  56. }
  57. else
  58. {
  59. using (AntORM orm = new AntORM())
  60. {
  61. orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
  62. RequestModel res = new RequestModel
  63. {
  64. newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
  65. };
  66. var reslut = orm.Queryable<BaseArea>().Where(p => p.ParentCode == id).ToList(res);
  67. if (reslut.IsSuccess)
  68. {
  69. var data = reslut.ResultModel;
  70. json.Data = JsonConverter.Serialize(data);
  71. }
  72. }
  73. }
  74. return Json(json);
  75. }
  76. /// <summary>
  77. /// 根据城市获取县级市信息
  78. /// </summary>
  79. /// <param name="id">城市ID</param>
  80. /// <returns></returns>
  81. public ActionResult Country(string id)
  82. {
  83. var json = new JsonHelper() { Status = "y", Msg = "Success" };
  84. if (string.IsNullOrEmpty(id))
  85. {
  86. json.Msg = "Error";
  87. json.Status = "n";
  88. }
  89. else
  90. {
  91. using (AntORM orm = new AntORM())
  92. {
  93. orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
  94. RequestModel res = new RequestModel
  95. {
  96. newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
  97. };
  98. var reslut = orm.Queryable<BaseArea>().Where(p => p.ParentCode == id).ToList(res);
  99. if (reslut.IsSuccess)
  100. {
  101. var data = reslut.ResultModel;
  102. json.Data = JsonConverter.Serialize(data);
  103. }
  104. }
  105. }
  106. return Json(json);
  107. }
  108. }
  109. }