LawAndRuleController.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. using SysBaseLibs;
  2. using SysDataLibs;
  3. using SysDataLibs.TableClass;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Web;
  10. using System.Web.Mvc;
  11. namespace GSMarketSys.Controllers
  12. {
  13. public class LawAndRuleController : BaseController
  14. {
  15. // GET: RowAndRule
  16. public ActionResult ShowLawAndRule()
  17. {
  18. ViewBag.RuleType = Request["RuleType"];
  19. return View();
  20. }
  21. /// <summary>
  22. /// 获取法律法规信息
  23. /// </summary>
  24. /// <returns></returns>
  25. public ActionResult GetLawAndRules()
  26. {
  27. string RuleType = Request["RuleType"];
  28. string lcSql = "select * from LawRule where LawRuleTypeId='" + RuleType + "'";
  29. rsQuery loQuery = UserSessionInfo.DBConn.OpenQuery(lcSql);
  30. System.Text.StringBuilder sb = new System.Text.StringBuilder();
  31. sb.Append("{\"total\":" + loQuery.RecCount + ",\"rows\":");
  32. if (loQuery.IsOpened && loQuery.RecCount > 0)
  33. {
  34. loQuery.CurrentTable.Columns.Add("Operation", typeof(string));
  35. loQuery.MoveFirst();
  36. for (int i = 0; i < loQuery.RecCount; i++)
  37. {
  38. string lcImg = "RICON100.GIF";
  39. string lcDownUrl = loQuery.GetString(LawRule_info.cDownUrl);
  40. string lcOperation = "";
  41. if (!string.IsNullOrWhiteSpace(lcDownUrl))
  42. {
  43. string ext = lcDownUrl.Substring(lcDownUrl.LastIndexOf(".") + 1, lcDownUrl.Length - lcDownUrl.LastIndexOf(".") - 1);
  44. ext = UtilStr.UAndT(ext);
  45. if (ext == "DOC" || ext == "DOCS" || ext == "DOCX")
  46. {
  47. lcImg = "ICON-WORD.GIF";
  48. }
  49. else if (ext == "XLS" || ext == "XLSX")
  50. {
  51. lcImg = "ICON-EXCEL.GIF";
  52. }
  53. else if (ext == "TXT")
  54. {
  55. lcImg = "ftv2doc_3.gif";
  56. }else
  57. {
  58. lcImg = "showtoc.gif";
  59. }
  60. lcDownUrl = "../" + SysDataLibs.AppEnv.SysSetObj.GetString("UPLOADPATH") + "/" + SysDataLibs.AppEnv.SysSetObj.GetString("LawRuleDown") + "/" + lcDownUrl;
  61. if(System.IO.File.Exists(Server.MapPath(lcDownUrl)))
  62. {
  63. lcOperation = string.Format(" <a href =\"{0}\" download=\"\"> <IMG style=\"CURSOR: hand\" title=\"下载\" src=\"../Images/{1}\"></a>", lcDownUrl, lcImg);
  64. }else
  65. {
  66. lcOperation = "无";
  67. }
  68. }
  69. loQuery.SetField("Operation", lcOperation);
  70. loQuery.MoveNext();
  71. }
  72. sb.Append(loQuery.CurrentTable.ToJson("yyyy-MM-dd"));
  73. }
  74. else
  75. {
  76. sb.Append("[]");
  77. }
  78. sb.Append("}");
  79. return Content(sb.ToString());
  80. }
  81. #region LawRuleList法律法规维护
  82. /// <summary>
  83. /// 法律法规维护
  84. /// </summary>
  85. /// <returns></returns>
  86. public ActionResult LawRuleList()
  87. {
  88. ViewBag.SelLawRuleType = GetData.Instance.GetSelStr(LawRuleType_info.clawruleTypeId, LawRuleType_info.clawruleType, Tn.LawRuleType,"", UserSessionInfo.DBConn);
  89. ViewBag.IsAdd = UserSessionInfo.CheckPowerNotRe(SysDataLibs.PowerType.IsAdd) ? "Y" : "N";
  90. ViewBag.IsUpdate = UserSessionInfo.CheckPowerNotRe(SysDataLibs.PowerType.IsUpdate) ? "Y" : "N";
  91. ViewBag.IsDelete = UserSessionInfo.CheckPowerNotRe(SysDataLibs.PowerType.IsDelete) ? "Y" : "N";
  92. return View();
  93. }
  94. public ActionResult GetLawRuleList()
  95. {
  96. string lcSql = " select * from "+Tn.LawRule ;
  97. rsQuery loQuery = UserSessionInfo.DBConn.OpenQuery(lcSql);//
  98. StringBuilder sb = new StringBuilder();
  99. sb.Append("{\"total\":" + loQuery.RecCount + ",\"rows\":");
  100. if (loQuery.IsOpened && loQuery.RecCount > 0)
  101. {
  102. loQuery.CurrentTable.Columns.Add("lawruleType", typeof(string));
  103. Dictionary<string,string> LawRuleTypeDic = SysDataLibs.AppEnv.GetKeyValueByTable(Tn.LawRuleType, LawRuleType_info.clawruleType, LawRuleType_info.clawruleTypeId, UserSessionInfo.DBConn);
  104. loQuery.MoveFirst();
  105. for (int i = 0; i < loQuery.RecCount; i++)
  106. {
  107. loQuery.SetField("lawruleType", LawRuleTypeDic[loQuery.GetString(LawRule_info.cLawRuleTypeId)]);
  108. loQuery.MoveNext();
  109. }
  110. sb.Append(loQuery.CurrentTable.ToJson("yyyy-MM-dd"));
  111. }
  112. else
  113. {
  114. sb.Append("[]");
  115. }
  116. sb.Append("}");
  117. return Content(sb.ToString());
  118. }
  119. [ValidateInput(false)]
  120. [CheckPowerFilter]
  121. public ActionResult RowAndRuleListOper()
  122. {
  123. string lcRetval = "false";
  124. string Type = Request["Type"];
  125. string LawRuleId = Request["LawRuleId"];
  126. LawRule_info lTbl = Type == "Add" ? new LawRule_info() : new LawRule_info(LawRuleId, UserSessionInfo.DBConn);
  127. if (Type == "Del" || Type == "ReDel")
  128. {
  129. if (UserSessionInfo.DBConn.ExecuteSql(lTbl.DeleteSql()))
  130. {
  131. lcRetval = SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Success");
  132. }
  133. else
  134. {
  135. lcRetval = SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_DBError");
  136. }
  137. return Content(lcRetval);
  138. }
  139. try
  140. {
  141. HttpFileCollection attachFile = System.Web.HttpContext.Current.Request.Files;
  142. if (attachFile.Count > 0&&!string.IsNullOrEmpty(attachFile[0].FileName))
  143. {
  144. string lcFileAllName = attachFile[0].FileName;
  145. if (MyUtils.IsValidFileType(lcFileAllName, "doc,xls,txt,docx,xlsx"))
  146. {
  147. ////string lcFileName =
  148. //imgPath = "/" + SysDataLibs.AppEnv.SysSetObj.GetString("UPLOADPATH") + "/" + SysDataLibs.AppEnv.SysSetObj.GetString("LawRuleDown") + "/" + lcFileAllName;
  149. //lTbl.DownUrl = lcFileAllName;
  150. //string PhysicalPath = Server.MapPath(imgPath);
  151. //attachFile[0].SaveAs(PhysicalPath);
  152. string lcPath = SysDataLibs.AppEnv.SysSetObj.GetString("LawRuleDown"); //'SysBaseLibs.AppConfig.ReadString("UpLoadPath")
  153. string lcUrl = MyUtils.UploadFile(attachFile, lcPath);
  154. if (lcUrl.Trim().Length > 0) {
  155. lTbl.DownUrl = lcUrl;
  156. }
  157. }
  158. else
  159. {
  160. return Content(ErrorRebackInfo.GetErrorBackInfo(false, "0", "只支持Word,Excel,TXT文件上传!"));
  161. }
  162. }
  163. }
  164. catch (Exception err)
  165. {
  166. ThreadLog.LogException(err);
  167. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_IsUploadFileError"));
  168. }
  169. string LawRuleName = Utils.AreaToSQLcs(Request["LawRuleName"]).Trim();
  170. string Contents = Utils.AreaToSQLcs(Request["Content"]).Trim();
  171. string LawRuleTypeId = Utils.AreaToSQLcs(Request["LawRuleTypeId"]).Trim();
  172. string promulgator = Utils.AreaToSQLcs(Request["promulgator"]).Trim();
  173. string promulgateDate = Utils.AreaToSQLcs(Request["promulgateDate"]).Trim();
  174. if (string.IsNullOrEmpty(LawRuleName))
  175. {
  176. return Content(ErrorRebackInfo.GetErrorBackInfo(false, "0", "标题名称不能为空!"));
  177. }
  178. if (string.IsNullOrEmpty(promulgateDate))
  179. {
  180. return Content(ErrorRebackInfo.GetErrorBackInfo(false, "0", "发布日期不能为空!"));
  181. }
  182. lTbl.LawRuleName = LawRuleName;
  183. lTbl.LawRuleTypeId = LawRuleTypeId;
  184. lTbl.promulgateDate = promulgateDate;
  185. lTbl.promulgator = promulgator;
  186. lTbl.Content = Contents;
  187. lTbl.UpdateTime = DateTime.Now.ToString();
  188. string lcSql = "";
  189. if (Type == "Edit")
  190. {
  191. lcSql = lTbl.UpdateSql();
  192. }
  193. else
  194. {
  195. lTbl.UserId = UserSessionInfo.UserInfo.UserID;
  196. lcSql = lTbl.InsertSql();
  197. }
  198. if (UserSessionInfo.DBConn.ExecuteSql(lcSql))
  199. {
  200. lcRetval = SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Success");
  201. }
  202. else
  203. {
  204. lcRetval = SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_DBError");
  205. }
  206. return Content(lcRetval);
  207. }
  208. #endregion
  209. private bool CheckFileType(string FileName,string pcType)
  210. {
  211. bool lbRetval = false;
  212. if (!string.IsNullOrEmpty(pcType))
  213. {
  214. string[] strArr = pcType.Split(',');
  215. FileName = FileName.Substring(FileName.LastIndexOf("\\", StringComparison.Ordinal) + 1);
  216. string FileExt = FileName.Substring(FileName.LastIndexOf(".") + 1, FileName.Length - FileName.LastIndexOf(".") - 1);
  217. FileExt = UtilStr.UAndT(FileExt);
  218. if (strArr.Contains(FileExt))
  219. {
  220. lbRetval = true;
  221. }
  222. }
  223. return lbRetval;
  224. }
  225. }
  226. }