using System; using System.Linq; using System.Web.Mvc; using DSWeb.MvcShipping.DAL.MsCtExplanDAL; using DSWeb.MvcShipping.Models.MsCtExplan; using DSWeb.MvcShipping.Helper; using DSWeb.MvcShipping.Comm.Cookie; using HcUtility.Comm; using HcUtility.Core; using System.Collections.Generic; using DSWeb.MvcShipping.DAL.MsBaseInfoDAL; using DSWeb.EntityDA; using DSWeb.Areas.CommMng.DAL; using DSWeb.SoftMng.Filter; namespace DSWeb.MvcShipping.Controllers { [JsonRequestBehavior] public class MsCtExplanController : Controller { public ActionResult Index() { return View(); } public ActionResult Edit() { return View(); } #region 主表 [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetDataList(string condition) { var dataList = MsCtExplanDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetData(string handle, string condition) { MsCtExplan head = new MsCtExplan(); head.MODIFIEDUSER = Convert.ToString(Session["USERID"]); head.MODIFIEDTIME = DateTime.Now; head.CORPID = Convert.ToString(Session["COMPANYID"]); if (handle == "edit") { head = MsCtExplanDAL.GetData(condition, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"])); } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult Save(string data) { if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "") { var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } // string errorstr = ""; var isPost = true; var enumValue = JsonConvert.Deserialize(data); // if (isPost) { var modb = new ModelObjectDB(); DBResult result = null; if (enumValue != null) { #region 默认值 MsCtExplan headRow = new MsCtExplan(); headRow.EXPLANTYPE = enumValue.EXPLANTYPE == null ? "" : enumValue.EXPLANTYPE.ToString().Trim();//摘要类别 headRow.MODULETYPE = enumValue.MODULETYPE == null ? "" : enumValue.MODULETYPE.ToString().Trim();//财务/出纳模块 if(headRow.MODULETYPE.ToString()=="出纳") { headRow.STARTGID = BasicDataRefDAL.GetCtSTARTGID(Convert.ToString(Session["USERID"]));//出纳账套启用GID } else { headRow.STARTGID = BasicDataRefDAL.GetCwSTARTGID(Convert.ToString(Session["USERID"]));//财务账套启用GID } headRow.CORPID = Convert.ToString(Session["COMPANYID"]);//分公司代码 headRow.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//更改操作人gid headRow.MODIFIEDTIME = DateTime.Now;//更改操作时间 // if (enumValue.GID.ToString().Trim() == "*") { headRow.GID = Guid.NewGuid().ToString();//唯一编码 headRow.DbOperationType = DbOperationType.DbotIns; } else//"edit" { headRow.GID = enumValue.GID.ToString().Trim();//唯一编码 headRow.DbOperationType = DbOperationType.DbotUpd; headRow.ModelUIStatus = "E"; } #endregion modb = new ModelObjectDB(); result = modb.Save(headRow); if (result.Message.ToString().IndexOf("插入重复键") > -1) { errorstr += "重复数据不再重复插入!"; } } // var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsCtExplanDAL.GetData("", Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"])) }; 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 Delete(string data) { if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "") { var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } // var modb = new ModelObjectDB(); var head = JsonConvert.Deserialize(data); //DBResult result = modb.Delete(head); DBResult result = MsCtExplanDAL.Delete(head, Convert.ToString(Session["USERID"])); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion #region 明细表 [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetDataListDetail(string condition) { var dataList = MsCtExplanDAL.GetDataListDetail(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetDataDetail(string handle, string condition) { MsCtExplanDetail head = new MsCtExplanDetail(); head.MODIFIEDUSER = Convert.ToString(Session["USERID"]); head.MODIFIEDTIME = DateTime.Now; if (handle == "edit") { head = MsCtExplanDAL.GetDataDetail(condition, Convert.ToString(Session["COMPANYID"])); } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult SaveDetail(string data,string sLINKGID) { if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "") { var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } // string errorstr = ""; var isPost = true; var enumValue = JsonConvert.Deserialize(data); // if (isPost) { var modb = new ModelObjectDB(); DBResult result = null; if (enumValue != null) { #region 默认值 MsCtExplanDetail headRow = new MsCtExplanDetail(); headRow.LINKGID = sLINKGID; headRow.EXPLAN = enumValue.EXPLAN == null ? "" : enumValue.EXPLAN.ToString().Trim();//摘要 headRow.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//更改操作人gid headRow.MODIFIEDTIME = DateTime.Now;//更改操作时间 // if (enumValue.GID.ToString().Trim() == "*") { headRow.GID = Guid.NewGuid().ToString();//唯一编码 headRow.DbOperationType = DbOperationType.DbotIns; } else//"edit" { headRow.GID = enumValue.GID.ToString().Trim();//唯一编码 headRow.DbOperationType = DbOperationType.DbotUpd; headRow.ModelUIStatus = "E"; } #endregion modb = new ModelObjectDB(); result = modb.Save(headRow); if (result.Message.ToString().IndexOf("插入重复键") > -1) { errorstr += "重复数据不再重复插入!"; } } // var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsCtExplanDAL.GetDataDetail("LINKGID='" + sLINKGID + "'", Convert.ToString(Session["COMPANYID"])) }; 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 DeleteDetail(string data) { if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "") { var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } // var modb = new ModelObjectDB(); var head = JsonConvert.Deserialize(data); DBResult result = modb.Delete(head); //DBResult result = MsCtExplanDAL.DeleteDetail(head, Convert.ToString(Session["USERID"])); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion } }