using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using DSWeb.EntityDA; using DSWeb.Models; using DSWeb.TruckMng.Comm.Cookie; using DSWeb.TruckMng.Helper; using WebSqlHelper; using System.Web.Configuration; using System.IO; using DSWeb.SysMng.DAL.SysRoleTaskQuery; using DSWeb.Areas.MvcShipping.Helper; using DSWeb.Common.DB; using DSWeb.Areas.CommMng.Models; using DSWeb.SoftMng.DAL.SoftSysTable; using DSWeb.Areas.CommMng.DAL; namespace DSWeb.Areas.SysMng.Controllers { /// /// 首页工作台 后台 /// [JsonRequestBehavior] public class SysRoleTaskQueryController : Controller { // // GET: /CommMng/Print/ public ActionResult Index() { return View(); } public ActionResult Edit() { return View(); } public ContentResult GetDataList(int start, int limit, string sort, string condition, string CODENAME = "") { var count = 0; //var userid = Convert.ToString(Session["USERID"]); //var uid = Session["USERID"].ToString(); //var corpid = Session["COMPANYID"].ToString(); var dataList = SysRoleTaskQueryDAL.GetDataList(start, limit, sort, condition, ref count); //var dataList = MsChDuiDAL.GetDataList(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request), sort); //int count = MsChDuiDAL.getTotalCount(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request)); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetData( string GID) { if ( GID == "*" || string.IsNullOrWhiteSpace( GID)) { var nulllist = new List(); var newrec = new Sys_Role_Task_Query_md(); //nulllist.Add(newrec); var jsonnull = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = 1, data = newrec }); return new ContentResult() { Content = jsonnull }; } var count = 0; //var userid = Convert.ToString(Session["USERID"]); //var uid = Session["USERID"].ToString(); //var corpid = Session["COMPANYID"].ToString(); var dataList = SysRoleTaskQueryDAL.GetDataList(0, 1, "", "{GID:\""+ GID + "\"}", ref count); //var dataList = MsChDuiDAL.GetDataList(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request), sort); //int count = MsChDuiDAL.getTotalCount(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), CookieConfig.GetCookie_OrgCode(Request)); if (dataList.Count == 0 || GID=="*") { var newrec = new Sys_Role_Task_Query_md(); dataList.Add(newrec); } var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList[0] }); return new ContentResult() { Content = json }; } public ContentResult GetRoleTaskQuery(string GID) { var count = 0; var dataList = SysRoleTaskQueryDAL.GetDataList(0, 1, "", "{GID:\"" + GID + "\"}", ref count); if (dataList.Count == 0) { var newrec = new Sys_Role_Task_Query_md(); dataList.Add(newrec); } var USERID = Session["USERID"].ToString(); foreach (var item in dataList) { item.SQLCONTEXT = item.GetCondition(USERID); } var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList[0] }); return new ContentResult() { Content = json }; } public ContentResult Save(string opstatus, string data, string data2, string body) { var canlogin = BasicDataRefDAL.CheckLogin(Session); if (!canlogin.Success) { return (ContentResult)canlogin.Data; } data = data.Replace("❥", "<"); var headData = JsonConvert.Deserialize(data);//(data.Replace("}", ",") + data2.Replace("{", "") var isPost = true; var errorstr = ""; #region 判断字段长度 if (isPost) { var seaefield = MsSoftSysTableDAL.GetDefTableDetailList("info_client"); foreach (var enumValue in seaefield) { //if (enumValue.FIELDNAME == "CODENAME" && headData.CODENAME.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "客户代码超长,字段长度限制" + enumValue.FIELDLEN; } //if (enumValue.FIELDNAME == "SHORTNAME" && headData.SHORTNAME.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "客户简称超长,字段长度限制" + enumValue.FIELDLEN; } //if (enumValue.FIELDNAME == "DESCRIPTION" && headData.DESCRIPTION.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "客户全称超长,字段长度限制" + enumValue.FIELDLEN; } //if (enumValue.FIELDNAME == "ENFULLNAME" && headData.EnFullName.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "英文全称超长,字段长度限制" + enumValue.FIELDLEN; } //if (enumValue.FIELDNAME == "ADDR" && headData.ADDR.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "地址超长,字段长度限制" + enumValue.FIELDLEN; } //if (enumValue.FIELDNAME == "EMAIL" && headData.EMAIL.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "邮件地址超长,字段长度限制" + enumValue.FIELDLEN; } //if (enumValue.FIELDNAME == "WEB" && headData.WEB.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "网址超长,字段长度限制" + enumValue.FIELDLEN; } //if (enumValue.FIELDNAME == "TEL" && headData.TEL.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "TEL超长,字段长度限制" + enumValue.FIELDLEN; } //if (enumValue.FIELDNAME == "ADDR" && headData.NAME.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "英文地址超长,字段长度限制" + enumValue.FIELDLEN; } //if (enumValue.FIELDNAME == "CHIEF" && headData.CHIEF.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "负责人超长,字段长度限制" + enumValue.FIELDLEN; } //if (enumValue.FIELDNAME == "PROVINCE" && headData.PROVINCE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "省超长,字段长度限制" + enumValue.FIELDLEN; } //if (enumValue.FIELDNAME == "CITY" && headData.CITY.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "城市超长,字段长度限制" + enumValue.FIELDLEN; } //if (enumValue.FIELDNAME == "BILLRISES1" && headData.BillRises1.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "发票抬头超长,字段长度限制" + enumValue.FIELDLEN; } //if (enumValue.FIELDNAME == "RMBBILLRISES" && headData.RMBBillRises.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "人民币支票抬头超长,字段长度限制" + enumValue.FIELDLEN; } //if (enumValue.FIELDNAME == "USDBILLRISES" && headData.USDBillRises.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "美元支票抬头超长,字段长度限制" + enumValue.FIELDLEN; } //if (enumValue.FIELDNAME == "REMARK" && headData.REMARK.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "备注超长,字段长度限制" + enumValue.FIELDLEN; } //if (enumValue.FIELDNAME == "QQ" && headData.QQ.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "QQ超长,字段长度限制" + enumValue.FIELDLEN; } //if (enumValue.FIELDNAME == "TAXNO" && headData.TAXNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "税号超长,字段长度限制" + enumValue.FIELDLEN; } } } #endregion var cdc = new CommonDataContext(); if (isPost) { if (opstatus == "add") { var uid = Session["USERID"].ToString(); //var compid = cdc.VW_user.AsNoTracking().FirstOrDefault(u => u.USERID == uid).COMPANYID; headData.GID = Guid.NewGuid(); //headData.COMPANYID = compid; cdc.Sys_Role_Task_Query.Add(headData); } else if (opstatus == "edit") { var oldheaddata = cdc.Sys_Role_Task_Query.First(x => x.GID == headData.GID); oldheaddata.SaveCopy(headData); } cdc.SaveChanges(); var jsonRespose = new JsonResponse { Success = true, Message = "", Data = headData }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var jsonRespose = new JsonResponse { Success = false, Message = errorstr }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } //public ContentResult DelDetail(string GID) //{ // var bd = new BookingDB(); // var GIDList = GID.Split(',').ToList(); // var olddetail = bd.Contacts.Where(x => GIDList.Contains(x.GID)).ToList(); // var jsonRespose = new JsonResponse // { // Success = true, // Message = "", // Data = "" // }; // if (olddetail != null) // { // bd.Contacts.RemoveRange(olddetail); // bd.SaveChanges(); // } // return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; //} public ContentResult DelHead(string GID) { var cdc = new CommonDataContext(); var oldhead = cdc.Sys_Role_Task_Query.Where(x => x.GID == new Guid( GID)).ToList(); var jsonRespose = new JsonResponse { Success = true, Message = "删除成功!", Data = "" }; if (oldhead != null) { cdc.Sys_Role_Task_Query.RemoveRange(oldhead); cdc.SaveChanges(); } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } }