using System; using System.Linq; using System.Text; using System.Web.Mvc; using DSWeb.MvcShipping.Helper; using DSWeb.MvcShipping.Comm.Cookie; using HcUtility.Comm; using HcUtility.Core; using System.Collections.Generic; using System.IO; using System.Data; using DSWeb.Areas.CommMng.DAL; using DSWeb.TruckMng.Helper.Repository; using DSWeb.Areas.MvcShipping.DAL.MsOp_InternalTrade; using DSWeb.MvcShipping.Models.MsOp_InternalTrade; using DSWeb.Areas.OA.Models.WorkFlow; using DSWeb.EntityDA; using DSWeb.MvcShipping.DAL.MsSysParamSet; using Microsoft.Practices.EnterpriseLibrary.Data; using DSWeb.MvcShipping.DAL.MsSysBillNoSet;//编码规则 using DSWeb.Areas.SysMng.DAL.SysTask; using DSWeb.MvcShipping.DAL.MsOpSeaiDAL; using DSWeb.MvcShipping.Models.MsOpSeai;//海运进口业务 using DSWeb.Areas.Import.Models.Comm;//用于生成费用 using DSWeb.Areas.CommMng.Models; using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;//查询OP权限 using DSWeb.MvcShipping.DAL.MsCodeOpDef; using DSWeb.MvcShipping.DAL.MsInfoClient; using DSWeb.MvcShipping.DAL.MsOpSeaeDAL; using DSWeb.Common.DB; using DSWeb.SoftMng.DAL.SoftSysTable; using Newtonsoft.Json.Linq; using System.Data.Entity.Migrations; using DSWeb.Areas.MvcShipping.DAL.DJYORDER_CONTRACTNO; namespace DSWeb.MvcShipping.Controllers { /// /// 大简云订舱相关信息 合约信息 /// 20240419 /// [JsonRequestBehavior] public class DJYORDER_CONTRACTNOController : Controller { public ActionResult Index() { return View(); } public ActionResult Edit() { return View(); } public ContentResult GetDataList(int start, int limit, string sort, string condition) { var count = 0; var uid = Session["USERID"].ToString(); CommonDataContext cdc = new CommonDataContext(); var _user = cdc.VW_user.AsNoTracking().FirstOrDefault(u => u.USERID == uid); //if (userid != "1BEC90E1-9780-472F-90C2-0C6390C044A4") { //} var dataList = DJYORDER_CONTRACTNODAL.GetDataList(start, limit, sort, condition, _user, 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 GetDataListStr(string condition) { var count = 0; var uid = Session["USERID"].ToString(); CommonDataContext cdc = new CommonDataContext(); var _user = cdc.VW_user.AsNoTracking().FirstOrDefault(u => u.USERID == uid); //if (userid != "1BEC90E1-9780-472F-90C2-0C6390C044A4") { //} var SqlStr = DJYORDER_CONTRACTNODAL.GetDataListStr(condition, _user); //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 = SqlStr }); return new ContentResult() { Content = json }; } public ContentResult GetEditData(string handle, string condition) { var result = new DJYORDER_CONTRACTNO_md(); var userid = Session["USERID"].ToString(); CommonDataContext cdc = new CommonDataContext(); var _user = cdc.VW_user.AsNoTracking().FirstOrDefault(u => u.USERID == userid); var count = 0; if (handle == "add") { //新建 返回默认值 } else { var resultlist = DJYORDER_CONTRACTNODAL.GetDataList(0, 1, "", condition, _user, ref count); if (resultlist != null && resultlist.Count > 0) { result = resultlist[0]; } } var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = result }); return new ContentResult() { Content = json }; } public ContentResult GetData(string BSNO) { var result = new DJYORDER_CONTRACTNO_md(); var userid = Session["USERID"].ToString(); CommonDataContext cdc = new CommonDataContext(); var _user = cdc.VW_user.AsNoTracking().FirstOrDefault(u => u.USERID == userid); var count = 0; if (string.IsNullOrWhiteSpace(BSNO)) { //新建 返回默认值 } else { var resultlist = DJYORDER_CONTRACTNODAL.GetDataList(0, 1, "", $" BSNO='{BSNO}'", _user, ref count); if (resultlist != null && resultlist.Count > 0) { result = resultlist[0]; } } var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = result }); return new ContentResult() { Content = json }; } public ContentResult Save(string opstatus, string data) { var result = new DBResult(); JObject ParamObject = JsonConvert.Deserialize(data); data = data.Replace("❥", "<"); //var headData = JsonConvert.Deserialize(data.Replace("}", ",") + data2.Replace("{", "")); var headData = JsonConvert.Deserialize(data); //var bodyList = JsonConvert.Deserialize>(body); var oldheaddata = new DJYORDER_CONTRACTNO_md(); //var checksettinginfo = DJYORDER_CONTRACTNODAL.CheckSetting(headData); //if (!checksettinginfo.Success) //{ // return BasicDataRefDAL.GetContentResult(checksettinginfo); //} var isPost = true; var errorstr = ""; var userid = Session["USERID"].ToString(); CommonDataContext cdc = new CommonDataContext(); var _user = cdc.VW_user.AsNoTracking().FirstOrDefault(u => u.USERID == userid); //20240411 判断 #region 判断字段长度 if (isPost) { var seaefield = MsSoftSysTableDAL.GetDefTableDetailList("info_client"); foreach (var enumValue in seaefield) { if (enumValue.FIELDNAME == "CARRIER" && headData.CARRIER.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "船公司超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "CONTRACTNO" && headData.CONTRACTNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "合约号超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "ShipperName" && headData.ShipperName.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "发货人名称超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "ShipperAddress" && headData.ShipperAddress.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "发货人地址超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "ShipperCountry" && headData.ShipperCountry.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "国家超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "ShipperProvince" && headData.ShipperProvince.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "省超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "ShipperCity" && headData.ShipperCity.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "市超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "ShipperCounty" && headData.ShipperCounty.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "区超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "ShipperPostCode" && headData.ShipperPostCode.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "邮编超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "ShipperFirstName" && headData.ShipperFirstName.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "姓超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "ShipperLastName" && headData.ShipperLastName.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = " 名超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "ShipperPhoneCountryCode" && headData.ShipperPhoneCountryCode.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "国家区号超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "ShipperPhoneCode" && headData.ShipperPhoneCode.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "市区号超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "ShipperPhone" && headData.ShipperPhone.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; } } } #endregion if (isPost) { try { if (opstatus == "add" || string.IsNullOrWhiteSpace(headData.GID)) { var uid = Session["USERID"].ToString(); headData.GID = Guid.NewGuid().ToString(); cdc.DJYORDER_CONTRACTNO.Add(headData); cdc.SaveChanges(); result.OK("保存成功", headData); } else { oldheaddata = cdc.DJYORDER_CONTRACTNO.First(x => x.GID == headData.GID); //var canchange = CanChange(oldheaddata); //if (!canchange.Success) { // return BasicDataRefDAL.GetContentResult(canchange); //} BasicDataRefDAL.CopyProperties(headData, oldheaddata); cdc.DJYORDER_CONTRACTNO.AddOrUpdate(oldheaddata); cdc.SaveChanges(); result.OK("保存成功", oldheaddata); } } catch (Exception e) { result.SetErrorInfo(JsonConvert.Serialize(e)); } return BasicDataRefDAL.GetContentResult(result); } else { var jsonRespose = new JsonResponse { Success = false, Message = errorstr }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } public JsonResult GetCarrierContractnoStore(string CARRIER) { //select distinct bankname2 as GVALUE,'' as GID from sys_bank var cdc = new Common.DB.CommonDataContext(); var USERID = Convert.ToString(Session["USERID"]); //var condition = $" CARRIER='{CARRIER}' "; //var evList = BasicDataRefDAL.GeneralSelect("DJYORDER_CONTRACTNO", "CONTRACTNO", "CONTRACTNO", condition); var evList = cdc.DJYORDER_CONTRACTNO.Where(x => x.CARRIER == CARRIER).ToList(); if (evList.Count == 0) { return Json(new { success = false }); } else { var blankrec = new DJYORDER_CONTRACTNO_md(); evList.Add(blankrec); return Json(new { success = true, data = evList.ToList() }); } } } /// /// 大简云订舱相关信息 合约信息 /// 20240419 /// [JsonRequestBehavior] public class DJYORDER_ACCOUNTINFOController : Controller { public ActionResult Index() { return View(); } public ActionResult Edit() { return View(); } public ContentResult GetDataList(int start, int limit, string sort, string condition) { var count = 0; var uid = Session["USERID"].ToString(); CommonDataContext cdc = new CommonDataContext(); var _user = cdc.VW_user.AsNoTracking().FirstOrDefault(u => u.USERID == uid); //if (userid != "1BEC90E1-9780-472F-90C2-0C6390C044A4") { //} var dataList = DJYORDER_ACCOUNTINFODAL.GetDataList(start, limit, sort, condition, _user, 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 GetDataListStr(string condition) { var count = 0; var uid = Session["USERID"].ToString(); CommonDataContext cdc = new CommonDataContext(); var _user = cdc.VW_user.AsNoTracking().FirstOrDefault(u => u.USERID == uid); //if (userid != "1BEC90E1-9780-472F-90C2-0C6390C044A4") { //} var SqlStr = DJYORDER_ACCOUNTINFODAL.GetDataListStr(condition, _user); //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 = SqlStr }); return new ContentResult() { Content = json }; } public ContentResult GetEditData(string handle, string condition) { var result = new DJYORDER_ACCOUNTINFO_md(); var userid = Session["USERID"].ToString(); CommonDataContext cdc = new CommonDataContext(); var _user = cdc.VW_user.AsNoTracking().FirstOrDefault(u => u.USERID == userid); var count = 0; if (handle == "add") { //新建 返回默认值 } else { var resultlist = DJYORDER_ACCOUNTINFODAL.GetDataList(0, 1, "", condition, _user, ref count); if (resultlist != null && resultlist.Count > 0) { result = resultlist[0]; } } var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = result }); return new ContentResult() { Content = json }; } public ContentResult GetData(string BSNO) { var result = new DJYORDER_ACCOUNTINFO_md(); var userid = Session["USERID"].ToString(); CommonDataContext cdc = new CommonDataContext(); var _user = cdc.VW_user.AsNoTracking().FirstOrDefault(u => u.USERID == userid); var count = 0; if (string.IsNullOrWhiteSpace(BSNO)) { //新建 返回默认值 } else { var resultlist = DJYORDER_ACCOUNTINFODAL.GetDataList(0, 1, "", $" BSNO='{BSNO}'", _user, ref count); if (resultlist != null && resultlist.Count > 0) { result = resultlist[0]; } } var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = result }); return new ContentResult() { Content = json }; } public ContentResult Save(string opstatus, string data) { var result = new DBResult(); JObject ParamObject = JsonConvert.Deserialize(data); data = data.Replace("❥", "<"); //var headData = JsonConvert.Deserialize(data.Replace("}", ",") + data2.Replace("{", "")); var headData = JsonConvert.Deserialize(data); //var bodyList = JsonConvert.Deserialize>(body); var oldheaddata = new DJYORDER_ACCOUNTINFO_md(); //var checksettinginfo = DJYORDER_CONTRACTNODAL.CheckSetting(headData); //if (!checksettinginfo.Success) //{ // return BasicDataRefDAL.GetContentResult(checksettinginfo); //} var isPost = true; var errorstr = ""; var userid = Session["USERID"].ToString(); CommonDataContext cdc = new CommonDataContext(); var _user = cdc.VW_user.AsNoTracking().FirstOrDefault(u => u.USERID == userid); //20240411 判断 #region 判断字段长度 if (isPost) { var seaefield = MsSoftSysTableDAL.GetDefTableDetailList("info_client"); foreach (var enumValue in seaefield) { if (enumValue.FIELDNAME == "CARRIER" && headData.CARRIER.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "船公司超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "ACCOUNT" && headData.ACCOUNT.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "账号超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "ACCOUNTPSW" && headData.ACCOUNTPSW.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "密码超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "BookingName" && headData.BookingName.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "订舱方名称超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "BookingAddress" && headData.BookingAddress.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "订舱方地址超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "BookingCountry" && headData.BookingCountry.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "国家超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "BookingProvince" && headData.BookingProvince.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "省超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "BookingCity" && headData.BookingCity.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "市超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "BookingCounty" && headData.BookingCounty.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "区超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "BookingPostCode" && headData.BookingPostCode.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "邮编超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "BookingFirstName" && headData.BookingFirstName.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "姓超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "BookingLastName" && headData.BookingLastName.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = " 名超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "BookingPhoneCountryCode" && headData.BookingPhoneCountryCode.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "国家区号超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "BookingPhoneCode" && headData.BookingPhoneCode.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "市区号超长,字段长度限制" + enumValue.FIELDLEN; } if (enumValue.FIELDNAME == "BookingPhone" && headData.BookingPhone.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; } } } #endregion if (isPost) { try { if (opstatus == "add" || string.IsNullOrWhiteSpace(headData.GID)) { var uid = Session["USERID"].ToString(); headData.GID = Guid.NewGuid().ToString(); cdc.DJYORDER_ACCOUNTINFO.Add(headData); cdc.SaveChanges(); result.OK("保存成功", headData); } else { oldheaddata = cdc.DJYORDER_ACCOUNTINFO.First(x => x.GID == headData.GID); //var canchange = CanChange(oldheaddata); //if (!canchange.Success) { // return BasicDataRefDAL.GetContentResult(canchange); //} BasicDataRefDAL.CopyProperties(headData, oldheaddata); cdc.DJYORDER_ACCOUNTINFO.AddOrUpdate(oldheaddata); cdc.SaveChanges(); result.OK("保存成功", oldheaddata); } } catch (Exception e) { result.SetErrorInfo(JsonConvert.Serialize(e)); } return BasicDataRefDAL.GetContentResult(result); } else { var jsonRespose = new JsonResponse { Success = false, Message = errorstr }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } public JsonResult GetAccStore(string CARRIER) { //select distinct bankname2 as GVALUE,'' as GID from sys_bank var cdc = new Common.DB.CommonDataContext(); var USERID = Convert.ToString(Session["USERID"]); //var condition = $" CARRIER='{CARRIER}' "; var evList = cdc.DJYORDER_ACCOUNTINFO.Where(x => x.CARRIER == CARRIER).ToList(); if (evList.Count == 0) { return Json(new { success = false }); } else { var blankrec = new DJYORDER_ACCOUNTINFO_md(); evList.Add(blankrec); return Json(new { success = true, data = evList.ToList() }); } } } }