123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- using SysBaseLibs;
- using SysDataLibs;
- using SysDataLibs.TableClass;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Web;
- using System.Web.Mvc;
- namespace GSMarketSys.Controllers
- {
- public class LawAndRuleController : BaseController
- {
- // GET: RowAndRule
- public ActionResult ShowLawAndRule()
- {
- ViewBag.RuleType = Request["RuleType"];
- return View();
- }
- /// <summary>
- /// 获取法律法规信息
- /// </summary>
- /// <returns></returns>
- public ActionResult GetLawAndRules()
- {
- string RuleType = Request["RuleType"];
- string lcSql = "select * from LawRule where LawRuleTypeId='" + RuleType + "'";
- rsQuery loQuery = UserSessionInfo.DBConn.OpenQuery(lcSql);
- System.Text.StringBuilder sb = new System.Text.StringBuilder();
- sb.Append("{\"total\":" + loQuery.RecCount + ",\"rows\":");
- if (loQuery.IsOpened && loQuery.RecCount > 0)
- {
- loQuery.CurrentTable.Columns.Add("Operation", typeof(string));
- loQuery.MoveFirst();
-
- for (int i = 0; i < loQuery.RecCount; i++)
- {
- string lcImg = "RICON100.GIF";
- string lcDownUrl = loQuery.GetString(LawRule_info.cDownUrl);
- string lcOperation = "";
- if (!string.IsNullOrWhiteSpace(lcDownUrl))
- {
- string ext = lcDownUrl.Substring(lcDownUrl.LastIndexOf(".") + 1, lcDownUrl.Length - lcDownUrl.LastIndexOf(".") - 1);
- ext = UtilStr.UAndT(ext);
-
- if (ext == "DOC" || ext == "DOCS" || ext == "DOCX")
- {
- lcImg = "ICON-WORD.GIF";
- }
- else if (ext == "XLS" || ext == "XLSX")
- {
- lcImg = "ICON-EXCEL.GIF";
- }
- else if (ext == "TXT")
- {
- lcImg = "ftv2doc_3.gif";
- }else
- {
- lcImg = "showtoc.gif";
- }
- lcDownUrl = "../" + SysDataLibs.AppEnv.SysSetObj.GetString("UPLOADPATH") + "/" + SysDataLibs.AppEnv.SysSetObj.GetString("LawRuleDown") + "/" + lcDownUrl;
- if(System.IO.File.Exists(Server.MapPath(lcDownUrl)))
- {
- lcOperation = string.Format(" <a href =\"{0}\" download=\"\"> <IMG style=\"CURSOR: hand\" title=\"下载\" src=\"../Images/{1}\"></a>", lcDownUrl, lcImg);
- }else
- {
- lcOperation = "无";
- }
-
- }
- loQuery.SetField("Operation", lcOperation);
- loQuery.MoveNext();
- }
- sb.Append(loQuery.CurrentTable.ToJson("yyyy-MM-dd"));
- }
- else
- {
- sb.Append("[]");
- }
- sb.Append("}");
- return Content(sb.ToString());
- }
- #region LawRuleList法律法规维护
- /// <summary>
- /// 法律法规维护
- /// </summary>
- /// <returns></returns>
- public ActionResult LawRuleList()
- {
- ViewBag.SelLawRuleType = GetData.Instance.GetSelStr(LawRuleType_info.clawruleTypeId, LawRuleType_info.clawruleType, Tn.LawRuleType,"", UserSessionInfo.DBConn);
- ViewBag.IsAdd = UserSessionInfo.CheckPowerNotRe(SysDataLibs.PowerType.IsAdd) ? "Y" : "N";
- ViewBag.IsUpdate = UserSessionInfo.CheckPowerNotRe(SysDataLibs.PowerType.IsUpdate) ? "Y" : "N";
- ViewBag.IsDelete = UserSessionInfo.CheckPowerNotRe(SysDataLibs.PowerType.IsDelete) ? "Y" : "N";
-
- return View();
- }
- public ActionResult GetLawRuleList()
- {
- string lcSql = " select * from "+Tn.LawRule ;
- rsQuery loQuery = UserSessionInfo.DBConn.OpenQuery(lcSql);//
- StringBuilder sb = new StringBuilder();
- sb.Append("{\"total\":" + loQuery.RecCount + ",\"rows\":");
- if (loQuery.IsOpened && loQuery.RecCount > 0)
- {
- loQuery.CurrentTable.Columns.Add("lawruleType", typeof(string));
- Dictionary<string,string> LawRuleTypeDic = SysDataLibs.AppEnv.GetKeyValueByTable(Tn.LawRuleType, LawRuleType_info.clawruleType, LawRuleType_info.clawruleTypeId, UserSessionInfo.DBConn);
- loQuery.MoveFirst();
- for (int i = 0; i < loQuery.RecCount; i++)
- {
- loQuery.SetField("lawruleType", LawRuleTypeDic[loQuery.GetString(LawRule_info.cLawRuleTypeId)]);
- loQuery.MoveNext();
- }
- sb.Append(loQuery.CurrentTable.ToJson("yyyy-MM-dd"));
- }
- else
- {
- sb.Append("[]");
- }
- sb.Append("}");
- return Content(sb.ToString());
-
- }
- [ValidateInput(false)]
- [CheckPowerFilter]
- public ActionResult RowAndRuleListOper()
- {
- string lcRetval = "false";
- string Type = Request["Type"];
- string LawRuleId = Request["LawRuleId"];
- LawRule_info lTbl = Type == "Add" ? new LawRule_info() : new LawRule_info(LawRuleId, UserSessionInfo.DBConn);
- if (Type == "Del" || Type == "ReDel")
- {
- if (UserSessionInfo.DBConn.ExecuteSql(lTbl.DeleteSql()))
- {
- lcRetval = SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Success");
- }
- else
- {
- lcRetval = SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_DBError");
- }
- return Content(lcRetval);
- }
- try
- {
- HttpFileCollection attachFile = System.Web.HttpContext.Current.Request.Files;
-
- if (attachFile.Count > 0&&!string.IsNullOrEmpty(attachFile[0].FileName))
- {
- string lcFileAllName = attachFile[0].FileName;
- if (MyUtils.IsValidFileType(lcFileAllName, "doc,xls,txt,docx,xlsx"))
- {
- ////string lcFileName =
- //imgPath = "/" + SysDataLibs.AppEnv.SysSetObj.GetString("UPLOADPATH") + "/" + SysDataLibs.AppEnv.SysSetObj.GetString("LawRuleDown") + "/" + lcFileAllName;
- //lTbl.DownUrl = lcFileAllName;
- //string PhysicalPath = Server.MapPath(imgPath);
- //attachFile[0].SaveAs(PhysicalPath);
- string lcPath = SysDataLibs.AppEnv.SysSetObj.GetString("LawRuleDown"); //'SysBaseLibs.AppConfig.ReadString("UpLoadPath")
- string lcUrl = MyUtils.UploadFile(attachFile, lcPath);
- if (lcUrl.Trim().Length > 0) {
- lTbl.DownUrl = lcUrl;
- }
- }
- else
- {
- return Content(ErrorRebackInfo.GetErrorBackInfo(false, "0", "只支持Word,Excel,TXT文件上传!"));
- }
- }
- }
- catch (Exception err)
- {
- ThreadLog.LogException(err);
- return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_IsUploadFileError"));
- }
- string LawRuleName = Utils.AreaToSQLcs(Request["LawRuleName"]).Trim();
- string Contents = Utils.AreaToSQLcs(Request["Content"]).Trim();
- string LawRuleTypeId = Utils.AreaToSQLcs(Request["LawRuleTypeId"]).Trim();
- string promulgator = Utils.AreaToSQLcs(Request["promulgator"]).Trim();
- string promulgateDate = Utils.AreaToSQLcs(Request["promulgateDate"]).Trim();
- if (string.IsNullOrEmpty(LawRuleName))
- {
- return Content(ErrorRebackInfo.GetErrorBackInfo(false, "0", "标题名称不能为空!"));
- }
- if (string.IsNullOrEmpty(promulgateDate))
- {
- return Content(ErrorRebackInfo.GetErrorBackInfo(false, "0", "发布日期不能为空!"));
- }
- lTbl.LawRuleName = LawRuleName;
- lTbl.LawRuleTypeId = LawRuleTypeId;
- lTbl.promulgateDate = promulgateDate;
- lTbl.promulgator = promulgator;
- lTbl.Content = Contents;
- lTbl.UpdateTime = DateTime.Now.ToString();
-
- string lcSql = "";
- if (Type == "Edit")
- {
- lcSql = lTbl.UpdateSql();
- }
- else
- {
- lTbl.UserId = UserSessionInfo.UserInfo.UserID;
- lcSql = lTbl.InsertSql();
- }
- if (UserSessionInfo.DBConn.ExecuteSql(lcSql))
- {
- lcRetval = SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Success");
- }
- else
- {
- lcRetval = SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_DBError");
- }
- return Content(lcRetval);
- }
- #endregion
-
- private bool CheckFileType(string FileName,string pcType)
- {
- bool lbRetval = false;
- if (!string.IsNullOrEmpty(pcType))
- {
- string[] strArr = pcType.Split(',');
- FileName = FileName.Substring(FileName.LastIndexOf("\\", StringComparison.Ordinal) + 1);
- string FileExt = FileName.Substring(FileName.LastIndexOf(".") + 1, FileName.Length - FileName.LastIndexOf(".") - 1);
- FileExt = UtilStr.UAndT(FileExt);
- if (strArr.Contains(FileExt))
- {
- lbRetval = true;
- }
- }
- return lbRetval;
- }
- }
- }
|