using System; using System.Linq; using System.Web.Mvc; using System.Collections.Generic; using System.Data; using System.IO; using HcUtility.Comm; using DSWeb.Areas.MvcShipping.DAL.Message; using DSWeb.TruckMng.Comm.Cookie; using DSWeb.TruckMng.Helper; using DSWeb.TruckMng.Helper.Repository; using System.Web.Script.Serialization; using System.Collections; using System.Data.OleDb; using DSWeb.Areas.CommMng.DAL; using JsonHelper; using DSWeb.EntityDA; using HcUtility.Core; using DSWeb.MvcContainer.DAL.MsOpCtnrDAL; using DSWeb.MvcContainer.Models.MsOpCtnr; using DSWeb.MvcShipping.DAL.MsSysBillNoSet; using System.Text; using DSWeb.Areas.RptMng.Comm; using DSWeb.MvcShipping.DAL.MsContainerSetCtn; using DSWeb.MvcShipping.DAL.ChMonthCloseDAL; using DSWeb.MvcShipping.DAL.MsChFeeDAL; namespace DSWeb.MvcContainer.Controllers { public class MsOpCtnrController : Controller { // // GET: public ActionResult Index ( ) { return View(); } public ActionResult InEdit() { return View(); } public ActionResult SellIndex() { return View(); } public ActionResult SellEdit() { return View(); } public ActionResult DynaIndex() { return View(); } public ActionResult DynaEdit() { return View(); } public ActionResult RptIndex() { return View(); } public ActionResult CodeIndex() { return View(); } public ActionResult CodeEdit() { return View(); } public ActionResult AddOpCtnrIndex() { return View(); } // // GET: / public ContentResult GetDataList ( int start, int limit, string sort, string condition ) { int count = 0; var dataList = MsOpCtnrDAL.GetDataList(condition, start, limit, CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), out count, sort); var timeStamp = DateTime.Now.ToShortDateString(); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList(), timeStamp = timeStamp }); return new ContentResult() { Content = json }; } public ContentResult GetCtnrList(int start, int limit, string sort, string condition,string isdata="0",string CNTRNO="") { if (isdata == "1") { if (string.IsNullOrEmpty(condition)) condition = " ISNULL(c.ISSTOP, '') <> '1' "; else { condition = condition + " and ISNULL(c.ISSTOP, '') <> '1' "; } if (!string.IsNullOrEmpty(CNTRNO)) { condition = condition + " and c.CNTRNO like '%"+ CNTRNO + "%' "; } } var dataList = MsOpCtnrDAL.GetCtnrList(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 GetCtnr(string handle, string condition) { CtnrDetail head = null; if (handle == "edit") { var list = MsOpCtnrDAL.GetCtnrList(condition,""); if (list.Count > 0) head = list[0]; } if (head == null) { head = new CtnrDetail(); } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult SaveCtn(string opstatus, string data, string body) { var headData = JsonConvert.Deserialize(data); var CtnrReturnList = JsonConvert.Deserialize>(body); if (opstatus == "add") { headData.DbOperationType = DbOperationType.DbotIns; } else if (opstatus == "edit") { headData.DbOperationType = DbOperationType.DbotUpd; headData.ModelUIStatus = "E"; } else { headData.DbOperationType = DbOperationType.DbotDel; } var modb = new ModelObjectDB(); DBResult result = modb.Save(headData); var GID = headData.CTNGID; if (result.Success) { if (CtnrReturnList != null) { var modbDetail = new ModelObjectRepository(); foreach (var item in CtnrReturnList) { if (item.BSNO == "*") { item.DbOperationType = DbOperationType.DbotIns; item.ModelUIStatus = "I"; } else { item.DbOperationType = DbOperationType.DbotUpd; item.ModelUIStatus = "E"; } item.BSNO = headData.CTNGID; item.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); item.CREATEUSER = CookieConfig.GetCookie_UserId(Request); result = modbDetail.Save(item); } } } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsOpCtnrDAL.GetCtnData("c.CTNGID='" + GID + "'") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult LockCtn(string body,string islock) { var CtnrList = JsonConvert.Deserialize>(body); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); if (CtnrList != null) { var modbDetail = new ModelObjectRepository(); foreach (var item in CtnrList) { string blUpSQL = " update op_ctnmng_ctndetail set ISLOCK='"+ islock + "' where CTNGID='" + item.CTNGID + "'"; bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL); } } var jsonRespose = new JsonResponse { Success =true, Message ="已更新完毕" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult GetDynaList(int start, int limit, string sort, string condition) { var dataList = MsOpCtnrDAL.GetDynaList(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 GetCtnrDetailList(int start, int limit, string sort, string condition) { var dataList = MsOpCtnrDAL.GetDetailList(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 GetCtnrSellDetail(int start, int limit, string sort, string condition) { var dataList = MsOpCtnrDAL.GetDetailList(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 GetCtnrSearchList(int start, int limit, string sort, string condition) { var dataList = MsOpCtnrDAL.GetSearchDetailList(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 GetData(string handle, string condition) { CtnrList head = null; var timeStamp = DateTime.Now.ToShortDateString(); if (handle == "edit") { head = MsOpCtnrDAL.GetData(condition, CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); } else { head = new CtnrList(); head.BSNO = Guid.NewGuid().ToString(); head.BSDATE = DateTime.Now.ToString("yyyy-MM-dd"); head.ACCDATE= DateTime.Now.ToString("yyyy-MM"); head.CREATETIME = DateTime.Now.ToString("yyyy - MM - dd HH: mm:ss"); head.CREATEUSER = CookieConfig.GetCookie_UserId(Request); head.MODIFIEDTIME = head.CREATETIME; head.MODIFIEDUSER = head.CREATEUSER; head.FEESTATUS = false; } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head, timeStamp = timeStamp }); return new ContentResult() { Content = json }; } public ContentResult GetCtnReturnList(int start, int limit, string sort, string condition) { var dataList = MsOpCtnrDAL.GetCtnReturnList(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 GetCodeCtnList() { int count = 0; var dataList = MsOpCtnrDAL.GetCodeCtnList(); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult Save(string opstatus, string data, string CtnrInBody, string CtnrInBodyDel,string CtnReturn="") { var head = JsonConvert.Deserialize(data); var DetailBodyList = JsonConvert.Deserialize>(CtnrInBody); var DetailBodyListAX = JsonConvert.Deserialize>(CtnrInBody); var DetailBodyDelList = JsonConvert.Deserialize>(CtnrInBodyDel); var CtnrReturnList = JsonConvert.Deserialize>(CtnReturn); List MngDetailList = new List(); DBResult result = new DBResult(false,"",null); bool bSell = head.BLTYPE == "卖箱" ? true : false; if (opstatus == "add") { head.DbOperationType = DbOperationType.DbotIns; head.ModelUIStatus = "I"; head.CORPID = Convert.ToString(Session["COMPANYID"]).Trim(); if (string.IsNullOrEmpty(head.BSNO)) head.BSNO =Guid.NewGuid().ToString().Replace("-", ""); ; head.CREATETIME = DateTime.Now.ToString("yyyy - MM - dd HH: mm:ss"); head.CREATEUSER = CookieConfig.GetCookie_UserId(Request); head.MODIFIEDTIME = head.CREATETIME; head.MODIFIEDUSER = head.CREATEUSER; if (head.ETD == "") head.ETD = null; if (head.RETURNDATE == "") head.RETURNDATE = null; if (head.ENDRENTDATE == "") head.ENDRENTDATE = null; var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='租买箱'", Convert.ToString(Session["COMPANYID"])); head.BILLNO= MsSysBillNoSetDAL.GetBillNo(billnoset, head.BSDATE.ToString().Trim(), head.ACCDATE.ToString().Trim()); List cntrsumlist = new List(); if (DetailBodyListAX != null) { foreach (CtnrDetailAX item in DetailBodyListAX) { CtnrMngDetail MngDetail = new CtnrMngDetail(); MngDetail.GID = Guid.NewGuid().ToString().Replace("-", ""); //MngDetail.BSNO = head.BSNO;//关联不需要 MngDetail.CTNGID = item.CTNGID; MngDetail.DRFEENAME = item.DRFEENAME; MngDetail.CRFEENAME = item.CRFEENAME; MngDetail.CR = item.CR; MngDetail.DR = item.DR; MngDetail.CURR = item.CURR; MngDetailList.Add(MngDetail); var isfind = false; cntrsumlist.ForEach(i => { if (i.CTNALL == item.CTNALL) { i.CTNNUM = i.CTNNUM + 1; isfind = true; } }); if (!isfind) { var cntrsum = new CNTRSUM(); cntrsum.CTNALL = item.CTNALL; cntrsum.CTNNUM = 1; cntrsumlist.Add(cntrsum); } } } var cntrsumstr = ""; var cntrnumsql = "update op_ctnmng set MBLNO=MBLNO "; var codectndisp = MsContainerSetCtnDAL.GetData(""); var iteu = 0; foreach (var item in cntrsumlist) { cntrsumstr = cntrsumstr + " " + item.CTNALL.ToString() + "*" + item.CTNNUM.ToString(); if (codectndisp.CNT1 != "" && codectndisp.CNT1 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR1=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT2 != "" && codectndisp.CNT2 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR2=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT3 != "" && codectndisp.CNT3 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR3=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT4 != "" && codectndisp.CNT4 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR4=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT5 != "" && codectndisp.CNT5 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR5=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT6 != "" && codectndisp.CNT6 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR6=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT7 != "" && codectndisp.CNT7 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR7=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT8 != "" && codectndisp.CNT8 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR8=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT9 != "" && codectndisp.CNT9 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR9=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT10 != "" && codectndisp.CNT10 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR10=" + item.CTNNUM.ToString(); } else { cntrnumsql = cntrnumsql + ",OTCNTR=" + item.CTNNUM.ToString(); } if (item.CTNALL.IndexOf("40") > 0 || item.CTNALL.IndexOf("45") > 0) { iteu = iteu + item.CTNNUM * 2; } else iteu = iteu + item.CTNNUM; } cntrnumsql = cntrnumsql + ",TEU=" + iteu.ToString() + " where BSNO='" + head.BSNO + "'"; cntrsumstr = cntrsumstr.TrimStart(); head.CNTRTOTAL = cntrsumstr; var modb = new ModelObjectRepository(); if (DetailBodyList == null) { DetailBodyList = new List(); } result = modb.Save(head, ModelObjectConvert.ToModelObjectList(MngDetailList), ModelObjectConvert.ToModelObjectList(null) ); if (result.Success) { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); bool bl = T_ALL_DA.GetExecuteSqlCommand(cntrnumsql); if (DetailBodyList != null) { var modbDetail = new ModelObjectRepository(); foreach (CtnrDetail item in DetailBodyList) { item.DbOperationType = DbOperationType.DbotIns; item.ModelUIStatus = "I"; item.BSNO = head.BSNO; item.CTNSTATUS = "可用"; result = modbDetail.Save(item); if (result.Success) { CtnrDyDetail dyDetail = new CtnrDyDetail(); dyDetail.GID = Guid.NewGuid().ToString().Replace("-", ""); dyDetail.CNTRNO = item.CNTRNO; dyDetail.CREATETIME = DateTime.Now.ToString("yyyy - MM - dd HH: mm:ss"); dyDetail.CREATEUSER = CookieConfig.GetCookie_UserId(Request); dyDetail.CTNEF = item.CTNEF; dyDetail.CTNGID = item.CTNGID; dyDetail.CTNSTATUS =head.BLTYPE; dyDetail.CTNSTATUSTIME = item.CTNSTATUSTIME; dyDetail.ACCDATE = DateTime.Now.ToString("yyyy-MM"); dyDetail.MBLNO = item.MBLNO; dyDetail.YARD = item.YARD; dyDetail.PORT = item.PORT; dyDetail.CUSTNO = item.CUSTNO; dyDetail.REMARK = item.REMARK; dyDetail.BSNO = head.BSNO; var modbDy = new ModelObjectRepository(); dyDetail.ModelUIStatus = "I"; dyDetail.DbOperationType = DbOperationType.DbotIns; result = modbDy.Save(dyDetail); } } } if (CtnrReturnList != null) { var modbDetail = new ModelObjectRepository(); foreach (var item in CtnrReturnList) { item.DbOperationType = DbOperationType.DbotIns; item.ModelUIStatus = "I"; item.BSNO = head.BSNO; item.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); item.CREATEUSER = CookieConfig.GetCookie_UserId(Request); result = modbDetail.Save(item); } } } } else if (opstatus == "edit") { //if (MsOpCtnrDAL.DeleteAll(head.BSNO,true)) //{ head.DbOperationType = DbOperationType.DbotUpd; head.ModelUIStatus = "E"; head.CREATETIME = DateTime.Now.ToString("yyyy - MM - dd HH: mm:ss"); head.CREATEUSER = CookieConfig.GetCookie_UserId(Request); head.CORPID = Convert.ToString(Session["COMPANYID"]).Trim(); head.MODIFIEDTIME = head.CREATETIME; head.MODIFIEDUSER = head.CREATEUSER; if (head.ETD == "") head.ETD = null; if (head.RETURNDATE == "") head.RETURNDATE = null; if (head.ENDRENTDATE == "") head.ENDRENTDATE = null; List cntrsumlist = new List(); if (DetailBodyListAX != null) { foreach (CtnrDetailAX item in DetailBodyListAX) { CtnrMngDetail MngDetail = new CtnrMngDetail(); MngDetail.BSNO = item.BSNO;//关联不需要 if (MngDetail.BSNO == "*") { MngDetail.GID = Guid.NewGuid().ToString().Replace("-", ""); MngDetail.DbOperationType = DbOperationType.DbotIns; item.GID = MngDetail.GID; MngDetail.BSNO = head.BSNO; } else { MngDetail.DbOperationType = DbOperationType.DbotUpd; MngDetail.GID = item.GID; } MngDetail.CTNGID = item.CTNGID; MngDetail.DRFEENAME = item.DRFEENAME; MngDetail.CRFEENAME = item.CRFEENAME; MngDetail.CR = item.CR; MngDetail.DR = item.DR; MngDetail.CURR = item.CURR; var modbDy = new ModelObjectRepository(); modbDy.Save(MngDetail); MngDetailList.Add(MngDetail); var isfind = false; cntrsumlist.ForEach(i => { if (i.CTNALL == item.CTNALL) { i.CTNNUM = i.CTNNUM + 1; isfind = true; } }); if (!isfind) { var cntrsum = new CNTRSUM(); cntrsum.CTNALL = item.CTNALL; cntrsum.CTNNUM = 1; cntrsumlist.Add(cntrsum); } } } var cntrsumstr = ""; var codectndisp = MsContainerSetCtnDAL.GetData(""); var cntrnumsql = "update op_ctnmng set MBLNO=MBLNO"; var iteu = 0; foreach (var item in cntrsumlist) { cntrsumstr = cntrsumstr + " " + item.CTNALL.ToString() + "*" + item.CTNNUM.ToString(); if (codectndisp.CNT1 != "" && codectndisp.CNT1 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR1=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT2 != "" && codectndisp.CNT2 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR2=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT3 != "" && codectndisp.CNT3 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR3=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT4 != "" && codectndisp.CNT4 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR4=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT5 != "" && codectndisp.CNT5 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR5=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT6 != "" && codectndisp.CNT6 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR6=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT7 != "" && codectndisp.CNT7 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR7=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT8 != "" && codectndisp.CNT8 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR8=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT9 != "" && codectndisp.CNT9 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR9=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT10 != "" && codectndisp.CNT10 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR10=" + item.CTNNUM.ToString(); } else { cntrnumsql = cntrnumsql + ",OTCNTR=" + item.CTNNUM.ToString(); } if (item.CTNALL.IndexOf("40") > 0 || item.CTNALL.IndexOf("45") > 0) { iteu = iteu + item.CTNNUM * 2; } else iteu = iteu + item.CTNNUM; } cntrnumsql = cntrnumsql + ",TEU="+iteu.ToString()+" where BSNO='"+head.BSNO+"'"; cntrsumstr = cntrsumstr.TrimStart(); head.CNTRTOTAL = cntrsumstr; var modb = new ModelObjectRepository(); if (DetailBodyList == null) { DetailBodyList = new List(); } result = modb.Save(head); if (result.Success ) { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); bool bl = T_ALL_DA.GetExecuteSqlCommand(cntrnumsql); if (DetailBodyList != null) { var modbDetail = new ModelObjectRepository(); foreach (CtnrDetail item in DetailBodyList) { if (item.BSNO == "*") { item.DbOperationType = DbOperationType.DbotIns; item.ModelUIStatus = "I"; } else { item.DbOperationType = DbOperationType.DbotUpd; item.ModelUIStatus = "E"; } item.BSNO = head.BSNO; item.CTNSTATUS = "可用"; result = modbDetail.Save(item); if (result.Success) { } } } if (DetailBodyListAX != null) { foreach (CtnrDetailAX item in DetailBodyListAX) { CtnrDyDetail dyDetail = new CtnrDyDetail(); dyDetail.GID = item.GID; dyDetail.CNTRNO = item.CNTRNO; dyDetail.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); dyDetail.CREATEUSER = CookieConfig.GetCookie_UserId(Request); dyDetail.CTNEF = item.CTNEF; dyDetail.CTNGID = item.CTNGID; dyDetail.ACCDATE = DateTime.Now.ToString("yyyy-MM"); dyDetail.CTNSTATUS = head.BLTYPE; dyDetail.CTNSTATUSTIME = item.CTNSTATUSTIME; dyDetail.MBLNO = item.MBLNO; dyDetail.YARD = item.YARD; dyDetail.PORT = item.PORT; dyDetail.CUSTNO = item.CUSTNO; dyDetail.REMARK = item.REMARK; dyDetail.BSNO = head.BSNO; var modbDy = new ModelObjectRepository(); if (item.BSNO == "*") { dyDetail.DbOperationType = DbOperationType.DbotIns; dyDetail.ModelUIStatus = "I"; } else { dyDetail.DbOperationType = DbOperationType.DbotUpd; dyDetail.ModelUIStatus = "E"; } result = modbDy.Save(dyDetail); } } if (CtnrReturnList != null) { var modbDetail = new ModelObjectRepository(); foreach (var item in CtnrReturnList) { if (item.BSNO == "*") { item.DbOperationType = DbOperationType.DbotIns; item.ModelUIStatus = "I"; } else { item.DbOperationType = DbOperationType.DbotUpd; item.ModelUIStatus = "E"; } item.BSNO = head.BSNO; item.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); item.CREATEUSER = CookieConfig.GetCookie_UserId(Request); result = modbDetail.Save(item); } } } //} } var jsonRespose = new JsonResponse(); jsonRespose.Success = result.Success; jsonRespose.Message = result.Message; jsonRespose.Data = MsOpCtnrDAL.GetData(" BSNO='" + head.BSNO + "'", CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } [HttpPost] public ActionResult CtrnFromExcel() { DBResult result = new DBResult(); if (Request.Files.Count == 0) { result.Success = false; result.Message = "参数错误"; return Json(result); } try { var excelfile = Request.Files[0]; string strMsg; string ext = Path.GetExtension(excelfile.FileName).ToLower(); if (ext != ".xls" && ext != ".xlsx") { result.Success = false; result.Message ="文件必须为EXCEL格式!"; return Json(result); } // var bsno = Request.Form["bsno"]; // var head = MsOpCtnrDAL.GetData("BSNO='"+bsno+"'", CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); DataTable dt = BasicDataRefDAL.ExcelToDatatable(excelfile.InputStream, ext, out strMsg); if (!string.IsNullOrEmpty(strMsg)) { result.Success = false; result.Message = strMsg; return Json(result); } if (dt.Rows.Count > 0) { var ctnlist=new List(); foreach (DataRow row in dt.Rows) { CtnrDetailAX item = new CtnrDetailAX(); item.CTNALL = row["箱型"].ToString(); item.CNTRNO = row["箱号"].ToString(); item.CTNEFREF = row["空重"].ToString(); item.CNTRSOURCE = row["箱源"].ToString(); item.PORT = row["当前地点"].ToString(); item.YARD = row["当前场站"].ToString(); item.CRFEENAME = row["应付费用名称"].ToString(); item.CR = row["应付费用"].ToString(); if (item.CTNEFREF == "重") item.CTNEF = "F"; else item.CTNEF = "E"; if (item.CTNEFREF.Length > 50) item.CTNEFREF = ""; if (item.CNTRSOURCE.Length > 50) item.CNTRSOURCE = ""; if (item.PORT.Length > 50) item.PORT = ""; if (item.YARD.Length > 50) item.YARD = ""; if (item.CRFEENAME.Length > 50) item.CRFEENAME = ""; if (item.CR.Length > 50) item.CR = "0"; ctnlist.Add(item); } var json = JsonConvert.Serialize(new { success = true, Message = "查询成功", totalCount = ctnlist.Count, data = ctnlist.ToList()}); return new ContentResult() { Content = json }; } else { result.Success = false; result.Message = "excel无数据!"; } } catch (Exception ex) { result.Success = false; result.Message = ex.Message; } return Json(result); } public ContentResult SaveSell(string opstatus, string data, string CtnrInBody, string CtnrInBodyDel) { var head = JsonConvert.Deserialize(data); var DetailBodyList = JsonConvert.Deserialize>(CtnrInBody); var DetailBodyListAX = JsonConvert.Deserialize>(CtnrInBody); var DetailBodyDelList = JsonConvert.Deserialize>(CtnrInBodyDel); List MngDetailList = new List(); DBResult result = new DBResult(false, "", null); bool bSell = (head.BLTYPE == "卖箱"|| head.BLTYPE == "退租") ? true : false; if (opstatus == "add") { head.DbOperationType = DbOperationType.DbotIns; head.ModelUIStatus = "I"; head.CORPID = Convert.ToString(Session["COMPANYID"]).Trim(); head.BSNO = Guid.NewGuid().ToString().Replace("-", ""); ; head.CREATETIME = DateTime.Now.ToString("yyyy - MM - dd HH: mm:ss"); head.CREATEUSER = CookieConfig.GetCookie_UserId(Request); head.MODIFIEDTIME = head.CREATETIME; head.MODIFIEDUSER = head.CREATEUSER; if (head.ETD == "") head.ETD = null; if (head.RETURNDATE == "") head.RETURNDATE = null; var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='租买箱'", Convert.ToString(Session["COMPANYID"])); head.BILLNO = MsSysBillNoSetDAL.GetBillNo(billnoset, head.BSDATE.ToString().Trim(), head.ACCDATE.ToString().Trim()); List cntrsumlist = new List(); if (DetailBodyListAX != null) { foreach (CtnrDetailAX item in DetailBodyListAX) { CtnrMngDetail MngDetail = new CtnrMngDetail(); MngDetail.GID = Guid.NewGuid().ToString().Replace("-", ""); //MngDetail.BSNO = head.BSNO;//关联不需要 MngDetail.CTNGID = item.CTNGID; MngDetail.DRFEENAME = item.DRFEENAME; MngDetail.CRFEENAME = item.CRFEENAME; MngDetail.CR ="0"; MngDetail.DR = item.DR; MngDetail.CURR = item.CURR; MngDetailList.Add(MngDetail); var isfind = false; cntrsumlist.ForEach(i => { if (i.CTNALL == item.CTNALL) { i.CTNNUM = i.CTNNUM + 1; isfind = true; } }); if (!isfind) { var cntrsum = new CNTRSUM(); cntrsum.CTNALL = item.CTNALL; cntrsum.CTNNUM = 1; cntrsumlist.Add(cntrsum); } } } var cntrsumstr = ""; var cntrnumsql = "update op_ctnmng set MBLNO=MBLNO "; var codectndisp = MsContainerSetCtnDAL.GetData(""); var iteu = 0; foreach (var item in cntrsumlist) { cntrsumstr = cntrsumstr + " " + item.CTNALL.ToString() + "*" + item.CTNNUM.ToString(); if (codectndisp.CNT1 != "" && codectndisp.CNT1 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR1=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT2 != "" && codectndisp.CNT2 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR2=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT3 != "" && codectndisp.CNT3 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR3=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT4 != "" && codectndisp.CNT4 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR4=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT5 != "" && codectndisp.CNT5 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR5=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT6 != "" && codectndisp.CNT6 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR6=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT7 != "" && codectndisp.CNT7 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR7=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT8 != "" && codectndisp.CNT8 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR8=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT9 != "" && codectndisp.CNT9 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR9=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT10 != "" && codectndisp.CNT10 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR5=" + item.CTNNUM.ToString(); } else { cntrnumsql = cntrnumsql + ",OTCNTR=" + item.CTNNUM.ToString(); } if (item.CTNALL.IndexOf("40") > 0 || item.CTNALL.IndexOf("45") > 0) { iteu = iteu + item.CTNNUM * 2; } else iteu = iteu + item.CTNNUM; } cntrnumsql = cntrnumsql + ",TEU=" + iteu.ToString() + " where BSNO='" + head.BSNO + "'"; cntrsumstr = cntrsumstr.TrimStart(); head.CNTRTOTAL = cntrsumstr; var modb = new ModelObjectRepository(); if (DetailBodyList == null) { DetailBodyList = new List(); } result = modb.Save(head, ModelObjectConvert.ToModelObjectList(MngDetailList), ModelObjectConvert.ToModelObjectList(null) ); if (result.Success) { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); bool bl = T_ALL_DA.GetExecuteSqlCommand(cntrnumsql); if (DetailBodyList != null) { foreach (CtnrDetail item in DetailBodyList) { if (result.Success) { CtnrDyDetail dyDetail = new CtnrDyDetail(); dyDetail.GID = Guid.NewGuid().ToString().Replace("-", ""); dyDetail.CNTRNO = item.CNTRNO; dyDetail.CREATETIME = DateTime.Now.ToString("yyyy - MM - dd HH: mm:ss"); dyDetail.CREATEUSER = CookieConfig.GetCookie_UserId(Request); dyDetail.CTNEF = item.CTNEF; dyDetail.CTNGID = item.CTNGID; dyDetail.CTNSTATUS =head.BLTYPE; dyDetail.CTNSTATUSTIME = item.CTNSTATUSTIME; dyDetail.MBLNO = item.MBLNO; dyDetail.YARD = item.YARD; dyDetail.PORT = item.PORT; dyDetail.CUSTNO = item.CUSTNO; dyDetail.REMARK = item.REMARK; dyDetail.BSNO = head.BSNO; var modbDy = new ModelObjectRepository(); dyDetail.ModelUIStatus = "I"; dyDetail.DbOperationType = DbOperationType.DbotIns; result = modbDy.Save(dyDetail); } } if (bSell || head.RETURNTYPE == "卖箱") { MsOpCtnrDAL.UpCtnStop(head.BSNO, DetailBodyList); } if (head.BLTYPE == "租出" && head.RETURNTYPE == "返箱") { MsOpCtnrDAL.UpCtnIsReturn(head.BSNO, DetailBodyList); } if (head.BLTYPE == "返箱") { MsOpCtnrDAL.UpCtnIsReturn(head.BSNO, DetailBodyList, "0"); } } } } else if (opstatus == "edit") { //if (MsOpCtnrDAL.DeleteAll(head)) //{ head.DbOperationType = DbOperationType.DbotUpd; head.ModelUIStatus = "E"; head.CREATETIME = DateTime.Now.ToString("yyyy - MM - dd HH: mm:ss"); head.CREATEUSER = CookieConfig.GetCookie_UserId(Request); head.CORPID = Convert.ToString(Session["COMPANYID"]).Trim(); head.MODIFIEDTIME = head.CREATETIME; head.MODIFIEDUSER = head.CREATEUSER; if (head.ETD == "") head.ETD = null; if (head.RETURNDATE == "") head.RETURNDATE = null; if (head.ENDRENTDATE == "") head.ENDRENTDATE = null; List cntrsumlist = new List(); if (DetailBodyListAX != null) { foreach (CtnrDetailAX item in DetailBodyListAX) { CtnrMngDetail MngDetail = new CtnrMngDetail(); MngDetail.BSNO = item.BSNO;//关联不需要 if (MngDetail.BSNO == "*") { MngDetail.GID = Guid.NewGuid().ToString().Replace("-", ""); MngDetail.DbOperationType = DbOperationType.DbotIns; item.GID = MngDetail.GID; MngDetail.BSNO = head.BSNO; } else { MngDetail.DbOperationType = DbOperationType.DbotUpd; MngDetail.GID = item.GID; } MngDetail.CTNGID = item.CTNGID; MngDetail.DRFEENAME = item.DRFEENAME; MngDetail.CRFEENAME = item.CRFEENAME; MngDetail.CR = item.CR; MngDetail.DR = item.DR; MngDetail.CURR = item.CURR; var modbDy = new ModelObjectRepository(); modbDy.Save(MngDetail); MngDetailList.Add(MngDetail); var isfind = false; cntrsumlist.ForEach(i => { if (i.CTNALL == item.CTNALL) { i.CTNNUM = i.CTNNUM + 1; isfind = true; } }); if (!isfind) { var cntrsum = new CNTRSUM(); cntrsum.CTNALL = item.CTNALL; cntrsum.CTNNUM = 1; cntrsumlist.Add(cntrsum); } } } var cntrsumstr = ""; var cntrnumsql = "update op_ctnmng set MBLNO=MBLNO "; var codectndisp = MsContainerSetCtnDAL.GetData(""); var iteu = 0; foreach (var item in cntrsumlist) { cntrsumstr = cntrsumstr + " " + item.CTNALL.ToString() + "*" + item.CTNNUM.ToString(); if (codectndisp.CNT1 != "" && codectndisp.CNT1 == item.CTNALL) { cntrnumsql = cntrnumsql+ ",CNTR1=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT2 != "" && codectndisp.CNT2 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR2=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT3 != "" && codectndisp.CNT3 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR3=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT4 != "" && codectndisp.CNT4 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR4=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT5 != "" && codectndisp.CNT5 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR5=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT6 != "" && codectndisp.CNT6 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR6=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT7 != "" && codectndisp.CNT7 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR7=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT8 != "" && codectndisp.CNT8 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR8=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT9 != "" && codectndisp.CNT9 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR9=" + item.CTNNUM.ToString(); } else if (codectndisp.CNT10 != "" && codectndisp.CNT10 == item.CTNALL) { cntrnumsql = cntrnumsql + ",CNTR10=" + item.CTNNUM.ToString(); } else { cntrnumsql = cntrnumsql + ",OTCNTR=" + item.CTNNUM.ToString(); } if (item.CTNALL.IndexOf("40") > 0 || item.CTNALL.IndexOf("45") > 0) { iteu = iteu + item.CTNNUM * 2; } else iteu = iteu + item.CTNNUM; } cntrnumsql = cntrnumsql + ",TEU=" + iteu.ToString() + " where BSNO='" + head.BSNO + "'"; cntrsumstr = cntrsumstr.TrimStart(); head.CNTRTOTAL = cntrsumstr; var modb = new ModelObjectRepository(); if (DetailBodyList == null) { DetailBodyList = new List(); } result = modb.Save(head); if (result.Success) { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); bool bl = T_ALL_DA.GetExecuteSqlCommand(cntrnumsql); if (DetailBodyList != null) { var modbDetail = new ModelObjectRepository(); foreach (CtnrDetail item in DetailBodyList) { if (result.Success) { CtnrDyDetail dyDetail = new CtnrDyDetail(); dyDetail.GID = Guid.NewGuid().ToString().Replace("-", ""); dyDetail.CNTRNO = item.CNTRNO; dyDetail.CREATETIME = DateTime.Now.ToString("yyyy - MM - dd HH: mm:ss"); dyDetail.CREATEUSER = CookieConfig.GetCookie_UserId(Request); dyDetail.CTNEF = item.CTNEF; dyDetail.CTNGID = item.CTNGID; dyDetail.CTNSTATUS =head.BLTYPE; dyDetail.CTNSTATUSTIME = item.CTNSTATUSTIME; dyDetail.MBLNO = item.MBLNO; dyDetail.YARD = item.YARD; dyDetail.PORT = item.PORT; dyDetail.CUSTNO = item.CUSTNO; dyDetail.REMARK = item.REMARK; dyDetail.BSNO = head.BSNO; var modbDy = new ModelObjectRepository(); if (item.BSNO == "*") { dyDetail.DbOperationType = DbOperationType.DbotIns; dyDetail.ModelUIStatus = "I"; } else { dyDetail.DbOperationType = DbOperationType.DbotUpd; dyDetail.ModelUIStatus = "E"; } result = modbDy.Save(dyDetail); } } if (bSell) { MsOpCtnrDAL.UpCtnStop(head.BSNO, DetailBodyList); } if (head.BLTYPE == "租出" && head.RETURNTYPE == "返箱") { MsOpCtnrDAL.UpCtnIsReturn(head.BSNO, DetailBodyList); } if (head.BLTYPE == "返箱") { MsOpCtnrDAL.UpCtnIsReturn(head.BSNO, DetailBodyList,"0"); } } } //} } var jsonRespose = new JsonResponse(); jsonRespose.Success = result.Success; jsonRespose.Message = result.Message; jsonRespose.Data = MsOpCtnrDAL.GetData(" BSNO='" + head.BSNO + "'", CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SaveSellDetail(string headdata, string data, string bsno) { var head = JsonConvert.Deserialize(headdata); var ctndetail = JsonConvert.Deserialize>(data); DBResult result = MsOpCtnrDAL.SaveSellDetail(head, ctndetail, head.BSNO, CookieConfig.GetCookie_UserId(Request)); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SaveDyna(string opstatus, string data) { var headData = JsonConvert.Deserialize(data); if (opstatus == "add") { headData.DbOperationType = DbOperationType.DbotIns; headData.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); headData.CREATEUSER = CookieConfig.GetCookie_UserId(Request); } else if (opstatus == "edit") { headData.DbOperationType = DbOperationType.DbotUpd; headData.ModelUIStatus = "E"; } else { headData.DbOperationType = DbOperationType.DbotDel; } headData.MODIFYTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); headData.MODIFYUSER = CookieConfig.GetCookie_UserId(Request); if (headData.ETA == "") headData.ETA = null; if (headData.ETD == "") headData.ETD = null; if (headData.PORTLOAD_CNT_TIME == "") headData.PORTLOAD_CNT_TIME = null; if (headData.DEST_CNT_TIME == "") headData.DEST_CNT_TIME = null; if (headData.DEST_RTCNT_TIME == "") headData.DEST_RTCNT_TIME = null; var modb = new ModelObjectDB(); headData = MsOpCtnrDAL.SetDynaStatus(headData); var result=modb.Save(headData); var jsonRespose = new JsonResponse(); if (result.Success) { jsonRespose.Success = result.Success; jsonRespose.Message = result.Message; jsonRespose.Data = MsOpCtnrDAL.GetDyna(" GID='" + headData.GID + "'"); } return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult DeleteDyna(string data) { var headList = JsonConvert.Deserialize>(data); DBResult result = null; var errstr = ""; if (headList != null) { foreach (CtnrDyDetail item in headList) { var isfee = MsOpCtnrDAL.GetFeeCount(item.GID); if (isfee) { if (errstr == "") errstr = item.CNTRNO; else errstr = errstr + "," + item.CNTRNO; } else { item.DbOperationType = DbOperationType.DbotDel; var modb = new ModelObjectDB(); result = modb.Save(item); } } } if (errstr != "") { var jsonRespose2 = new JsonResponse { Success = false, Message = errstr + " 已存在费用,不允许删除!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } var jsonRespose = new JsonResponse(); jsonRespose.Success = result.Success; jsonRespose.Message = result.Message; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult GetDyna(string handle, string condition) { CtnrDyDetail head = null; if (handle == "edit") { var list = MsOpCtnrDAL.GetDynaList(condition, ""); if (list.Count > 0) head = list[0]; } if (head == null) { head = new CtnrDyDetail(); head.ACCDATE = DateTime.Now.ToString("yyyy-MM"); } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult GetCopyDynaData(string handle, string condition, string copyfee = "false") { CtnrDyDetail head = null; var oldhead = MsOpCtnrDAL.GetDyna(condition); var BSNO = oldhead.GID; head = oldhead; head.GID = Guid.NewGuid().ToString(); var period = ChMonthCloseDAL.GetData("", Convert.ToString(Session["COMPANYID"])); if (Convert.ToDateTime(period.FDAY) > DateTime.Now) { head.ACCDATE = period.PERIOD; } else { head.ACCDATE = DateTime.Now.ToString("yyyy-MM"); } head.BSSTATUS = false; head.FEESTATUS = false; head.BSSTATUSREF = "未锁定"; head.FEESTATUSREF = "未锁定"; if (copyfee == "true") { var feelist = MsChFeeDAL.GetAllDataList("BSNO='"+ BSNO + "'"); if (feelist != null) { for (int _i = 0; _i < feelist.Count; _i++) { feelist[_i].BsNo = "*"; } MsChFeeDAL.SaveFee(feelist, head.GID, CookieConfig.GetCookie_UserId(Request)); } } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult InsertCtn(string data, string BSNO) { var CtnrList = JsonConvert.Deserialize>(data); var result = MsOpCtnrDAL.CtnAdd(BSNO,CtnrList, CookieConfig.GetCookie_UserId(Request)); var json = JsonConvert.Serialize( new { Success = result.Success, Message = result.Message}); return new ContentResult() { Content = json }; } public ContentResult PLCntrStatus(string data, string modifydata) { var DetailBodyList = JsonConvert.Deserialize>(data); var CtnrDyDetail = JsonConvert.Deserialize(modifydata); DBResult result = null; result = MsOpCtnrDAL.Modify(DetailBodyList, CtnrDyDetail, CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["COMPANYID"])); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } [HttpPost] public ActionResult CtrnStatusFromExcel() { DBResult result = new DBResult(); if (Request.Files.Count == 0) { result.Success = false; result.Message = "参数错误"; return Json(result); } try { var excelfile = Request.Files[0]; string strMsg; string ext = Path.GetExtension(excelfile.FileName).ToLower(); if (ext != ".xls" && ext != ".xlsx") { result.Success = false; result.Message = "文件必须为EXCEL格式!"; return Json(result); } // var bsno = Request.Form["bsno"]; // var head = MsOpCtnrDAL.GetData("BSNO='"+bsno+"'", CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); DataTable dt = BasicDataRefDAL.ExcelToDatatable(excelfile.InputStream, ext, out strMsg); if (!string.IsNullOrEmpty(strMsg)) { result.Success = false; result.Message = strMsg; return Json(result); } T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); if (dt.Rows.Count > 0) { var ctnlist = new List(); foreach (DataRow row in dt.Rows) { CtnrDyDetail dyDetail = new CtnrDyDetail(); dyDetail.DbOperationType = DbOperationType.DbotIns; dyDetail.ModelUIStatus = "I"; dyDetail.GID = Guid.NewGuid().ToString().Replace("-", ""); dyDetail.CNTRNO = row["箱号"].ToString(); dyDetail.CREATETIME = DateTime.Now.ToString("yyyy - MM - dd HH: mm:ss"); dyDetail.CREATEUSER = CookieConfig.GetCookie_UserId(Request); var CTNEFREF = row["空重"].ToString(); if (CTNEFREF == "重") dyDetail.CTNEF = "F"; else dyDetail.CTNEF = "E"; var ctncode = MsOpCtnrDAL.GetCtnData("CNTRNO='"+ dyDetail.CNTRNO + "'"); dyDetail.CTNGID = ctncode.CTNGID; dyDetail.CTNSTATUS = row["当前动态"].ToString(); var cntrstatustime = row["动态时间"].ToString(); try { dyDetail.CTNSTATUSTIME =Convert.ToDateTime(cntrstatustime).ToString("yyyy-MM-dd"); } catch (Exception) { dyDetail.CTNSTATUSTIME = DateTime.Now.ToString("yyyy - MM - dd"); } dyDetail.MBLNO = row["主提单号"].ToString(); dyDetail.YARD = row["场站"].ToString(); dyDetail.PORT = row["地点"].ToString(); dyDetail.CUSTNO =""; var remark= row["动态备注"].ToString(); if (remark.Length == 36) remark = ""; dyDetail.REMARK = remark; var modbDy = new ModelObjectDB(); result = modbDy.Save(dyDetail); } var json = JsonConvert.Serialize(new { success = true, Message = "查询成功", totalCount = ctnlist.Count, data = ctnlist.ToList() }); return new ContentResult() { Content = json }; } else { result.Success = false; result.Message = "excel无数据!"; } } catch (Exception ex) { result.Success = false; result.Message = ex.Message; } return Json(result); } public ContentResult CreateCost(string data, string CtnrInBody,string flag) { var head = JsonConvert.Deserialize(data); var DetailBodyListAX = JsonConvert.Deserialize>(CtnrInBody); string msg = ""; bool rst = false; string userid = Session["USERID"] == null ? "" : Session["USERID"].ToString(); if (flag == "0") rst = MsOpCtnrDAL.CreateCost(head, DetailBodyListAX, userid, out msg); else if (flag == "1") rst = MsOpCtnrDAL.CancelCost(head, userid, out msg); var json = JsonConvert.Serialize(new { Success = rst, Message = msg, totalCount = 1 }); return new ContentResult() { Content = json }; } public ContentResult Delete(string data, string USERID) { var CtnrList = JsonConvert.Deserialize>(data); var errstr = ""; foreach (var enumValue in CtnrList) { var isfee = MsOpCtnrDAL.GetFeeCount(enumValue.BSNO); if (isfee) { if (errstr == "") errstr = enumValue.BILLNO; else errstr = errstr + "," + enumValue.BILLNO; } else { } } string msg = ""; if (errstr != "") { var jsonRespose2 = new JsonResponse { Success =false, Message = errstr+" 已存在费用,不允许删除!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } bool success = MsOpCtnrDAL.Delete(CtnrList,out msg); var jsonRespose = new JsonResponse { Success = success, Message = msg }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult DeleteSell(string data, string USERID) { var CtnrList = JsonConvert.Deserialize>(data); var errstr = ""; foreach (var enumValue in CtnrList) { var isfee = MsOpCtnrDAL.GetFeeCount(enumValue.BSNO); if (isfee) { if (errstr == "") errstr = enumValue.BILLNO; else errstr = errstr + "," + enumValue.BILLNO; } else { } } string msg = ""; if (errstr != "") { var jsonRespose2 = new JsonResponse { Success = false, Message = errstr + " 已存在费用,不允许删除!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } bool success = MsOpCtnrDAL.Delete(CtnrList, out msg); var jsonRespose = new JsonResponse { Success = success, Message = msg }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult DeleteDetail(string data,string bsno) { var head = JsonConvert.Deserialize >(data); DBResult result = MsOpCtnrDAL.DeleteCtnDetail(head, bsno,true); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult DeleteSellDetail(string headdata,string data, string bsno) { var head = JsonConvert.Deserialize(headdata); var ctndetail = JsonConvert.Deserialize>(data); DBResult result = MsOpCtnrDAL.DeleteCtnDetail(head, ctndetail, head.BSNO, false); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult DeleteReturnDetail(string data, string bsno) { var head = JsonConvert.Deserialize>(data); DBResult result = MsOpCtnrDAL.DeleteCtnReturnDetail(head, bsno); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult GetCtnSum(string condition) { condition = condition.Replace("'", "''"); var strSql = new StringBuilder(); strSql.Append(" declare @sql NVARCHAR(max) "); strSql.Append(" set @sql='select b.PORT,b.YARD,b.CTNSTATUS' "); strSql.Append(" select @sql=@sql+',sum(case when b.CTNALL='''+t.CTNALL+''' then 1 else 0 end) as C'+t.CTNALL "); strSql.Append(" from (select distinct CTNALL from op_ctnmng_ctndetail) as t"); strSql.Append(" set @sql=@sql+' from v_op_ctnmng_ctndetail b "); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" Where 1=1 AND " + condition); } else { strSql.Append(" Where 1=1 "); } strSql.Append(" group by b.port,b.yard,b.CTNSTATUS ' "); strSql.Append(" exec(@sql) "); var dbparams = new List(); var paramps_sSQL = new CustomDbParamter(); paramps_sSQL.ParameterName = "@sSQL"; paramps_sSQL.DbType = DbType.String; paramps_sSQL.Direction = ParameterDirection.Input; paramps_sSQL.Value = strSql.ToString(); dbparams.Add(paramps_sSQL); var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set"); var json = RptHelper.GetRptJsonResult(0, 100, dbRptResult, "Result_Set", true); return new ContentResult() { Content = json }; } public ContentResult GetCtnList(string condition) { var strSql = new StringBuilder(); strSql.Append(" select distinct CTNALL from op_ctnmng_ctndetail "); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" Where " + condition); } var dbparams = new List(); var paramps_sSQL = new CustomDbParamter(); paramps_sSQL.ParameterName = "@sSQL"; paramps_sSQL.DbType = DbType.String; paramps_sSQL.Direction = ParameterDirection.Input; paramps_sSQL.Value = strSql.ToString(); dbparams.Add(paramps_sSQL); var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set"); var json = RptHelper.GetRptJsonResult(0, 20, dbRptResult, "Result_Set", true); return new ContentResult() { Content = json }; } public ContentResult CreateBsFee(string data) { var CtnrList = JsonConvert.Deserialize>(data); var result = MsOpCtnrDAL.CreateBsFee(CtnrList, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult CreateCtnBsFee(string data) { var CtnrList = JsonConvert.Deserialize>(data); var result = MsOpCtnrDAL.CreateCtnBsFee(CtnrList, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } }