You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/MvcShipping/Controllers/MsOpCtnrController.cs

1380 lines
61 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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.MvcShipping.DAL.MsOpCtnrDAL;
using DSWeb.MvcShipping.Models.MsOpCtnr;
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
using System.Text;
using DSWeb.Areas.RptMng.Comm;
using DSWeb.MvcShipping.DAL.MsContainerSetCtn;
using DSWeb.SoftMng.Filter;
namespace DSWeb.MvcShipping.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();
}
//
// GET: /
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
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 };
}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetCtnrList(int start, int limit, string sort, string condition)
{
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 };
}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
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 };
}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
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 };
}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
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 };
}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
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 };
}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
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 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)
{
var head = JsonConvert.Deserialize<CtnrList>(data);
var DetailBodyList = JsonConvert.Deserialize<List<CtnrDetail>>(CtnrInBody);
var DetailBodyListAX = JsonConvert.Deserialize<List<CtnrDetailAX>>(CtnrInBody);
var DetailBodyDelList = JsonConvert.Deserialize<List<CtnrDetail>>(CtnrInBodyDel);
List<CtnrMngDetail> MngDetailList = new List<CtnrMngDetail>();
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;
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='租买箱'", Convert.ToString(Session["COMPANYID"]));
head.BILLNO= MsSysBillNoSetDAL.GetBillNo(billnoset, head.BSDATE.ToString().Trim(), head.ACCDATE.ToString().Trim());
List<CNTRSUM> cntrsumlist = new List<CNTRSUM>();
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;
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<CtnrDetail>();
}
result = modb.Save(head,
ModelObjectConvert<CtnrMngDetail>.ToModelObjectList(MngDetailList),
ModelObjectConvert<CtnrMngDetail>.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;
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.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);
}
}
}
}
}
else if (opstatus == "edit")
{
if (MsOpCtnrDAL.DeleteAll(head.BSNO,true))
{
head.DbOperationType = DbOperationType.DbotIns;
head.ModelUIStatus = "I";
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;
List<CNTRSUM> cntrsumlist = new List<CNTRSUM>();
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;
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<CtnrDetail>();
}
result = modb.Save(head,
ModelObjectConvert<CtnrMngDetail>.ToModelObjectList(MngDetailList),
ModelObjectConvert<CtnrMngDetail>.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;
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.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);
}
}
}
}
}
}
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<CtnrDetailAX>();
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<CtnrList>(data);
var DetailBodyList = JsonConvert.Deserialize<List<CtnrDetail>>(CtnrInBody);
var DetailBodyListAX = JsonConvert.Deserialize<List<CtnrDetailAX>>(CtnrInBody);
var DetailBodyDelList = JsonConvert.Deserialize<List<CtnrDetail>>(CtnrInBodyDel);
List<CtnrMngDetail> MngDetailList = new List<CtnrMngDetail>();
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<CNTRSUM> cntrsumlist = new List<CNTRSUM>();
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;
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<CtnrDetail>();
}
result = modb.Save(head,
ModelObjectConvert<CtnrMngDetail>.ToModelObjectList(MngDetailList),
ModelObjectConvert<CtnrMngDetail>.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.DbotIns;
head.ModelUIStatus = "I";
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;
List<CNTRSUM> cntrsumlist = new List<CNTRSUM>();
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;
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<CtnrDetail>();
}
result = modb.Save(head,
ModelObjectConvert<CtnrMngDetail>.ToModelObjectList(MngDetailList),
ModelObjectConvert<CtnrMngDetail>.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)
{
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)
{
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<CtnrList>(headdata);
var ctndetail = JsonConvert.Deserialize<List<CtnrDetail>>(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 head = JsonConvert.Deserialize<CtnrDetail>(data);
DBResult result = new DBResult(false, "", null);
head.DbOperationType = DbOperationType.DbotUpd;
head.ModelUIStatus = "E";
var modb = new ModelObjectDB();
result = modb.Save(head);
if (result.Success && opstatus == "add")
{
CtnrDyDetail dyDetail = new CtnrDyDetail();
dyDetail.DbOperationType = DbOperationType.DbotIns;
dyDetail.ModelUIStatus = "I";
dyDetail.GID = Guid.NewGuid().ToString().Replace("-", "");
dyDetail.CNTRNO = head.CNTRNO;
dyDetail.CREATETIME = DateTime.Now.ToString("yyyy - MM - dd HH: mm:ss");
dyDetail.CREATEUSER = CookieConfig.GetCookie_UserId(Request);
dyDetail.CTNEF = head.CTNEF;
dyDetail.CTNGID = head.CTNGID;
dyDetail.CTNSTATUS = head.CTNSTATUS;
dyDetail.CTNSTATUSTIME = head.CTNSTATUSTIME;
dyDetail.MBLNO = head.MBLNO;
dyDetail.YARD = head.YARD;
dyDetail.PORT = head.PORT;
dyDetail.CUSTNO = head.CUSTNO;
dyDetail.REMARK = head.REMARK;
var modbDy = new ModelObjectDB();
result = modbDy.Save(dyDetail);
}
var jsonRespose = new JsonResponse();
jsonRespose.Success = result.Success;
jsonRespose.Message = result.Message;
jsonRespose.Data = MsOpCtnrDAL.GetDynaList(" CTNGID='" + head.CTNGID + "'", "");
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult PLCntrStatus(string data, string modifydata)
{
var DetailBodyList = JsonConvert.Deserialize<List<CtnrDetail>>(data);
var CtnrDyDetail = JsonConvert.Deserialize<CtnrDyDetail>(modifydata);
DBResult result = null;
if (DetailBodyList != null) {
foreach (CtnrDetail item in DetailBodyList)
{
CtnrDyDetail dyDetail = new CtnrDyDetail();
dyDetail.DbOperationType = DbOperationType.DbotIns;
dyDetail.ModelUIStatus = "I";
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 = CtnrDyDetail.CTNEF;
dyDetail.CTNGID = item.CTNGID;
dyDetail.CTNSTATUS = CtnrDyDetail.CTNSTATUS;
dyDetail.CTNSTATUSTIME = CtnrDyDetail.CTNSTATUSTIME;
dyDetail.MBLNO = CtnrDyDetail.MBLNO;
dyDetail.YARD = CtnrDyDetail.YARD;
dyDetail.PORT = CtnrDyDetail.PORT;
dyDetail.CUSTNO = CtnrDyDetail.CUSTNO;
dyDetail.REMARK = CtnrDyDetail.REMARK;
var modbDy = new ModelObjectDB();
result = modbDy.Save(dyDetail);
}
}
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<CtnrDetailAX>();
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 CTNGID = T_ALL_DA.GetStrSQL("CTNGID", "select top 1 CTNGID from op_ctnmng_ctndetail where CNTRNO='" + dyDetail.CNTRNO + "'");
dyDetail.CTNGID = 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<CtnrList>(data);
var DetailBodyListAX = JsonConvert.Deserialize<List<CtnrDetailAX>>(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<List<CtnrList>>(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<List<CtnrList>>(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 <List<CtnrDetail>>(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<CtnrList>(headdata);
var ctndetail = JsonConvert.Deserialize<List<CtnrDetail>>(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 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<CustomDbParamter>();
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<CustomDbParamter>();
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 };
}
}
}