using System; using System.Linq; using System.Web.Mvc; using DSWeb.MvcShipping.DAL.MsOpSocCtnDAL; using DSWeb.MvcShipping.Models.MsOpSocCtn; 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.Models; using DSWeb.Attributes; using DSWeb.MvcShipping.Models.MsSysBillNoSet; using DSWeb.MvcShipping.DAL.MsSysBillNoSet; using DSWeb.MvcShipping.Models.MsCodeServiceFeeTemplate; using System.IO; using System.Data; using System.Data.OleDb; using DSWeb.MvcShipping.DAL.MsInfoClient; using DSWeb.MvcShipping.DAL.MsSysParamSet; using System.Web.Configuration; using DSWeb.SoftMng.DAL.SoftSysTable; using DSWeb.Areas.CommMng.DAL; using DSWeb.SoftMng.Filter; namespace DSWeb.MvcShipping.Controllers { [JsonRequestBehavior] public class MsOpSocCtnController : Controller { public ActionResult Index() { return View(); } public ActionResult Edit() { return View(); } public ActionResult CtnIndex() { return View(); } public ActionResult CtnEdit() { return View(); } public ActionResult BsIndex() { return View(); } public ActionResult BsEdit() { return View(); } [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetDataList(int start, int limit, string sort, string condition) { int total = 0; var dataList = MsOpSocCtnDAL.GetDataList(start, limit, out total, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = total, data = dataList.ToList() }); return new ContentResult() { Content = json }; } [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetDataListStr(string sort, string condition) { var dataListStr = MsOpSocCtnDAL.GetDataListStr(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr }); return new ContentResult() { Content = json }; } [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetBsDataList(int start, int limit, string sort, string condition) { int total = 0; var dataList = MsOpSocCtnDAL.GetBsDataList(start, limit, out total, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = total, data = dataList.ToList() }); return new ContentResult() { Content = json }; } [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetBsDataListStr(string sort, string condition) { var dataListStr = MsOpSocCtnDAL.GetBsDataListStr(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr }); return new ContentResult() { Content = json }; } [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetData(string handle, string condition) { MsOpSocCtnContract head = null; if (handle == "edit") { head = MsOpSocCtnDAL.GetData(condition); } if (head == null) { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string rq = T_ALL_DA.GetStrSQL("rq", "select getdate() as rq"); head = new MsOpSocCtnContract(); head.BSSTATUS = "新建"; head.CREATEUSER = Convert.ToString(Session["USERID"]); head.CREATEUSERREF = Convert.ToString(Session["SHOWNAME"]); head.CREATETIME = DateTime.Parse(rq).ToString("yyyy-MM-dd HH:mm:ss");//创建时间 } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult Save(string opstatus, string data,string body) { if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "") { var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } // T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); var headData = JsonConvert.Deserialize(data); var ctnlist= JsonConvert.Deserialize>(body); //分公司代码 if (headData.CORPID == "" || headData.CORPID == null) { headData.CORPID = Convert.ToString(Session["COMPANYID"]); } //分公司代码 if (headData.BSNO == "" || headData.BSNO == null) { headData.BSNO = "topsocctn" + Guid.NewGuid().ToString().Replace("-",""); } var isPost = true; var errorstr = ""; // if (headData.CLOSEDOCDATE == "") headData.CLOSEDOCDATE = null; if (headData.CLOSEFEEDATE == "") headData.CLOSEFEEDATE = null; if (headData.CONTRACTDATE == "") headData.CONTRACTDATE = null; if (headData.RETURNDEPOSITDATE == "") headData.RETURNDEPOSITDATE = null; string rq = T_ALL_DA.GetStrSQL("rq", "select getdate() as rq"); // if (opstatus == "add") { headData.DbOperationType = DbOperationType.DbotIns; // headData.BSSTATUS = "新建"; headData.CREATEUSER = Convert.ToString(Session["USERID"]);//创建人 headData.CREATETIME = DateTime.Parse(rq).ToString("yyyy-MM-dd HH:mm:ss");//创建时间 headData.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//最后一次操作人 headData.MODIFIEDTIME = DateTime.Parse(rq).ToString("yyyy-MM-dd HH:mm:ss");//最后一次操作时间 } else if (opstatus == "edit") { headData.DbOperationType = DbOperationType.DbotUpd; headData.ModelUIStatus = "E"; // headData.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//最后一次操作人 headData.MODIFIEDTIME = DateTime.Parse(rq).ToString("yyyy-MM-dd HH:mm:ss");//最后一次操作时间 } else { headData.DbOperationType = DbOperationType.DbotDel; } if (isPost) { var modb = new ModelObjectDB(); DBResult result = modb.Save(headData); var BSNO = headData.BSNO; if (result.Success == true) { result = MsOpSocCtnDAL.SaveOpSocCtnCtn(ctnlist, headData.BSNO,Convert.ToString(Session["USERID"])); } else { } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsOpSocCtnDAL.GetData("BSNO='" + BSNO + "'") }; 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"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "") { var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } var errstr = ""; var headList = JsonConvert.Deserialize>(data); foreach (var head in headList) { var isfee = MsOpSocCtnDAL.GetRdCount("BSNO='" + head.BSNO + "'"); if (isfee > 0) { if (errstr == "") errstr = head.CONTRACTNO+ "此票业务存在集装箱明细已配箱不允许删除!"; else errstr = errstr + "," + head.CONTRACTNO+ "此票业务存在集装箱明细已配箱不允许删除!"; } else { var BSNO = head.BSNO; var modb = new ModelObjectDB(); DBResult result = modb.Delete(head); if (result.Success == true) { MsOpSocCtnDAL.DeleteOpSocContract(head); DBResult result2 = MsOpSocCtnDAL.setLog(head, Convert.ToString(Session["USERID"])); } } } var jsonRespose = new JsonResponse { Success = true, Message = errstr }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult LockList(string data,string type) { if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "") { var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } var errstr = ""; var headList = JsonConvert.Deserialize>(data); foreach (var head in headList) { var BSNO = head.BSNO; var modb = new ModelObjectDB(); DBResult result = MsOpSocCtnDAL.LockOpSocContract(head, type,Convert.ToString(Session["USERID"])); } var jsonRespose = new JsonResponse { Success = true, Message = errstr }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult LockBsList(string data, string type) { if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "") { var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } var errstr = ""; var headList = JsonConvert.Deserialize>(data); foreach (var head in headList) { var BSNO = head.BSNO; var modb = new ModelObjectDB(); DBResult result = MsOpSocCtnDAL.LockOpSocBs(head, type, Convert.ToString(Session["USERID"])); } var jsonRespose = new JsonResponse { Success = true, Message = errstr }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } // [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetBsData(string handle, string condition) { MsOpSocCtnBs head = null; if (handle == "edit") { head = MsOpSocCtnDAL.GetBsData(condition); } if (head == null) { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string rq = T_ALL_DA.GetStrSQL("rq", "select getdate() as rq"); head = new MsOpSocCtnBs(); head.BSSTATUS = "新建"; head.CREATEUSER = Convert.ToString(Session["USERID"]); head.CREATEUSERREF = Convert.ToString(Session["SHOWNAME"]); head.CREATETIME = DateTime.Parse(rq).ToString("yyyy-MM-dd HH:mm:ss");//创建时间 } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult SaveBs(string opstatus, string data,string body) { if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "") { var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } // T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); var headData = JsonConvert.Deserialize(data); var ctnlist = JsonConvert.Deserialize>(body); //分公司代码 if (headData.CORPID == "" || headData.CORPID == null) { headData.CORPID = Convert.ToString(Session["COMPANYID"]); } //分公司代码 if (headData.BSNO == "" || headData.BSNO == null) { headData.BSNO = "topsocctn" + Guid.NewGuid().ToString().Replace("-", ""); } var isPost = true; var errorstr = ""; // if (headData.ETD == "") headData.ETD = null; if (headData.ETA== "") headData.ETA = null; if (headData.RTCTNDATE == "") headData.RTCTNDATE = null; string rq = T_ALL_DA.GetStrSQL("rq", "select getdate() as rq"); // if (opstatus == "add") { headData.DbOperationType = DbOperationType.DbotIns; // headData.BSSTATUS = "新建"; headData.CREATEUSER = Convert.ToString(Session["USERID"]);//创建人 headData.CREATETIME = DateTime.Parse(rq).ToString("yyyy-MM-dd HH:mm:ss");//创建时间 headData.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//最后一次操作人 headData.MODIFIEDTIME = DateTime.Parse(rq).ToString("yyyy-MM-dd HH:mm:ss");//最后一次操作时间 } else if (opstatus == "edit") { headData.DbOperationType = DbOperationType.DbotUpd; headData.ModelUIStatus = "E"; // headData.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//最后一次操作人 headData.MODIFIEDTIME = DateTime.Parse(rq).ToString("yyyy-MM-dd HH:mm:ss");//最后一次操作时间 } else { headData.DbOperationType = DbOperationType.DbotDel; } if (isPost) { var modb = new ModelObjectDB(); DBResult result = modb.Save(headData); var BSNO = headData.BSNO; if (result.Success == true) { result = MsOpSocCtnDAL.SaveOpSocCtnCtnDetail(ctnlist, headData.BSNO, Convert.ToString(Session["USERID"])); } else { } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsOpSocCtnDAL.GetBsData("BSNO='" + BSNO + "'") }; 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 DeleteBs(string data) { if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "") { var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } // var head = JsonConvert.Deserialize(data); var isfee = MsOpSocCtnDAL.GetRdCount("BS_BSNO='" + head.BSNO + "'"); if (isfee > 0) { var jsonRespose = new JsonResponse { Success = false, Message = "此票业务存在集装箱明细,请先删除集装箱明细才能删除此票合同!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var BSNO = head.BSNO; var modb = new ModelObjectDB(); DBResult result = modb.Delete(head); if (result.Success == true) { //MsOpOtherDAL.DeleteDetail(head); // DBResult result2 = MsOpSocCtnDAL.setLog(head, Convert.ToString(Session["USERID"])); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetOpSocCtnCtnList(int start, int limit, string condition, string sort) { var dataList = MsOpSocCtnDAL.GetOpSocCtnCtnList(condition, sort); var list = dataList.Skip(start).Take(limit); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetOpSocCtnCtnListStr(string condition, string sort) { var dataListStr = MsOpSocCtnDAL.GetOpSocCtnCtnListStr(condition, sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr }); return new ContentResult() { Content = json }; } public ContentResult SaveOpSocCtnCtn(string body, string bsno) { // var bodyList = JsonConvert.Deserialize>(body); DBResult result = MsOpSocCtnDAL.SaveOpSocCtnCtn(bodyList, bsno, Convert.ToString(Session["USERID"])); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult DeleteOpSocCtnCtn(string data) { var headData = JsonConvert.Deserialize>(data); DBResult result = MsOpSocCtnDAL.DeleteOpSocCtnCtn(headData); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult CreateOpSocCtnCtn(string data) { var headData = JsonConvert.Deserialize>(data); DBResult result = MsOpSocCtnDAL.CreateOpSocCtnCtn(headData); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult GetOpSocCtnCtnDetailList(int start, int limit, string condition, string sort) { var dataList = MsOpSocCtnDAL.GetOpSocCtnCtnDetailList(condition, sort); var list = dataList.Skip(start).Take(limit); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetOpSocCtnCtnDetailListStr(string condition, string sort) { var dataListStr = MsOpSocCtnDAL.GetOpSocCtnCtnDetailListStr(condition, sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr }); return new ContentResult() { Content = json }; } public ContentResult SaveOpSocCtnCtnDetail(string body, string bsno) { // var bodyList = JsonConvert.Deserialize>(body); DBResult result = MsOpSocCtnDAL.SaveOpSocCtnCtnDetail(bodyList, bsno, Convert.ToString(Session["USERID"])); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult ModifyCtnDetail(string data, string modifydata) { var bodyList = JsonConvert.Deserialize>(data); var amodifydata = JsonConvert.Deserialize(modifydata); var result = new DBResult(); if (bodyList != null) { result = MsOpSocCtnDAL.ModifyCtnDetail(bodyList, amodifydata, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"])); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } [HttpPost] public ContentResult ImportCtnDetail() { var jsonRespose = new JsonResponse { Success = false, Message = "" }; var dt = new DataTable(); var _r = BasicDataRefDAL.RequestExceltoDatatable(Request, out dt); if (_r.Success) { var _rn = MsOpSocCtnDAL.InsertCtn(dt, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"])); jsonRespose.Success = true; jsonRespose.Message = _rn.Message; } else { jsonRespose = new JsonResponse(_r); } return jsonRespose.getContentReult(); } [HttpPost] public ContentResult ImportCtnDetailYard() { var jsonRespose = new JsonResponse { Success = false, Message = "" }; var dt = new DataTable(); var _r = BasicDataRefDAL.RequestExceltoDatatable(Request, out dt); if (_r.Success) { var _rn = MsOpSocCtnDAL.InsertCtnYard(dt, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"])); jsonRespose.Success = true; jsonRespose.Message = _rn.Message; } else { jsonRespose = new JsonResponse(_r); } return jsonRespose.getContentReult(); } public ContentResult DeleteOpSocCtnCtnDetail(string data) { var headData = JsonConvert.Deserialize>(data); DBResult result = MsOpSocCtnDAL.DeleteOpSocCtnCtnDetail(headData); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult UpdateOpSocCtnBsCtn(string data,string bsno,string type) { var headData = JsonConvert.Deserialize>(data); DBResult result = MsOpSocCtnDAL.UpdateOpSocCtnBsCtn(headData,bsno,type, Convert.ToString(Session["USERID"])); if (result.Success) { MsOpSocCtnDAL.UpdateOpSocCtnBs(bsno); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } }