|
|
|
|
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.MvcShipping.DAL.MsChFeeDAL;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 内贸业务 邓羽 20200311
|
|
|
|
|
/// 需求编号 张工
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonRequestBehavior]
|
|
|
|
|
public class MsOp_InternalTradeController : Controller
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
// GET: /RptMng/MsRptPcHeadQry
|
|
|
|
|
public ActionResult Index()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult Edit()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult FeeEdit()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult FeeAmendEdit()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult ReceiptEdit()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
#region 内贸业务 头表/明细表
|
|
|
|
|
|
|
|
|
|
//public ContentResult GetSqlStr(string YXNOList) {
|
|
|
|
|
|
|
|
|
|
// string sql = MsOp_YAXIANGDAL.gethea;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
public ContentResult GetDataList(int start, int limit, string condition, string sort="")
|
|
|
|
|
{
|
|
|
|
|
var _count = 0;
|
|
|
|
|
var dataList = MsOp_InternalTradeDAL.GetDataList(start,limit,condition, Session["USERID"].ToString(),out _count, sort);
|
|
|
|
|
|
|
|
|
|
//var list = new List<Dictionary<string, string>>();
|
|
|
|
|
|
|
|
|
|
var list_2 = ModelObjectBill.getDicList(ModelObjectConvert<MsOp_INTERNALTRADEmb>.ToModelObjectList(dataList));
|
|
|
|
|
|
|
|
|
|
var json = JsonConvert.Serialize(new
|
|
|
|
|
{
|
|
|
|
|
Success = true,
|
|
|
|
|
Message = "查询成功",
|
|
|
|
|
totalCount = _count,
|
|
|
|
|
data = list_2.ToList()
|
|
|
|
|
|
|
|
|
|
//totalCount = dataList.Count,
|
|
|
|
|
//data = list.ToList()
|
|
|
|
|
|
|
|
|
|
//,fieldlist = fieldlist.ToList()
|
|
|
|
|
});
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
public ContentResult GetDataListStr(string condition, string sort = "")
|
|
|
|
|
{
|
|
|
|
|
var _count = 0;
|
|
|
|
|
var dataListStr = MsOp_InternalTradeDAL.GetDataListStr(condition, Session["USERID"].ToString(), out _count, sort);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var json = JsonConvert.Serialize(new
|
|
|
|
|
{
|
|
|
|
|
Success = true,
|
|
|
|
|
Message = "查询成功",
|
|
|
|
|
totalCount = _count,
|
|
|
|
|
data = dataListStr
|
|
|
|
|
|
|
|
|
|
//totalCount = dataList.Count,
|
|
|
|
|
//data = list.ToList()
|
|
|
|
|
|
|
|
|
|
//,fieldlist = fieldlist.ToList()
|
|
|
|
|
});
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
public ContentResult GetData(string handle, string condition)
|
|
|
|
|
{
|
|
|
|
|
var result = new MsOp_INTERNALTRADEmb();
|
|
|
|
|
|
|
|
|
|
if (handle == "add") {
|
|
|
|
|
result.getDef(Session["USERID"].ToString());
|
|
|
|
|
}else
|
|
|
|
|
result = MsOp_InternalTradeDAL.GetData(condition, Session["USERID"].ToString());
|
|
|
|
|
if (handle == "copyadd")
|
|
|
|
|
{
|
|
|
|
|
var BSNO = System.Guid.NewGuid().ToString();
|
|
|
|
|
result.SetValue("BSNO", BSNO);
|
|
|
|
|
var feelist = MsChFeeDAL.GetAllDataList(condition);
|
|
|
|
|
if (feelist != null)
|
|
|
|
|
{
|
|
|
|
|
for (int _i = 0; _i < feelist.Count; _i++)
|
|
|
|
|
{
|
|
|
|
|
feelist[_i].BsNo = "*";
|
|
|
|
|
}
|
|
|
|
|
MsChFeeDAL.SaveFee(feelist, BSNO, CookieConfig.GetCookie_UserId(Request));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var json = JsonConvert.Serialize(new
|
|
|
|
|
{
|
|
|
|
|
Success = true,
|
|
|
|
|
Message = "查询成功",
|
|
|
|
|
//totalCount = 1,
|
|
|
|
|
data = result.ExtendDic
|
|
|
|
|
//,fieldlist = fieldlist.ToList()
|
|
|
|
|
});
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult GetBodyList( string condition )
|
|
|
|
|
{
|
|
|
|
|
var dataList = MsOp_InternalTradeDAL.GetBodyList(condition);
|
|
|
|
|
|
|
|
|
|
var list = new List<Dictionary<string, string>>();
|
|
|
|
|
|
|
|
|
|
if (dataList.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var data in dataList)
|
|
|
|
|
{
|
|
|
|
|
list.Add(data.ExtendDic);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var json = JsonConvert.Serialize(new
|
|
|
|
|
{
|
|
|
|
|
Success = true,
|
|
|
|
|
Message = "查询成功",
|
|
|
|
|
totalCount = list.Count,
|
|
|
|
|
data = list.ToList()
|
|
|
|
|
});
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 判断是否允许保存
|
|
|
|
|
/// 目前只判断重复 且受参数设置影响
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="opstatus"></param>
|
|
|
|
|
/// <param name="data"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private JsonResponse CanSave(string opstatus, MsOp_INTERNALTRADEmb head) {
|
|
|
|
|
|
|
|
|
|
var result = new JsonResponse();
|
|
|
|
|
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "";
|
|
|
|
|
|
|
|
|
|
if (!提单号允许重复()) {
|
|
|
|
|
//
|
|
|
|
|
if (提单号是否重复(opstatus, head)) {
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message += "此类业务的提单号不允许重复!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//增加判断 费用锁定 业务锁定
|
|
|
|
|
if (!业务锁定(opstatus, head)) {
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message += "该业务已经业务锁定 不允许执行保存!";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 如未设定则允许重复
|
|
|
|
|
/// 如设定了该参数则value=1时允许重复
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private bool 提单号允许重复() {
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
|
|
|
|
var 系统参数_允许提单号重复List = cdc.sys_param_set.Where(x => x.GID == "14C5A14E-E5E8-4AF0-AEF5-F9D70A68DF54").ToList();
|
|
|
|
|
|
|
|
|
|
var result = new JsonResponse();
|
|
|
|
|
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "";
|
|
|
|
|
|
|
|
|
|
if (系统参数_允许提单号重复List != null && 系统参数_允许提单号重复List.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
if (系统参数_允许提单号重复List[0].PARAMVALUE == "1")
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool 提单号是否重复(string opstatus, MsOp_INTERNALTRADEmb head) {
|
|
|
|
|
//如果是新增 则只看是否有主题单号重复
|
|
|
|
|
|
|
|
|
|
var _mblno = head.GetValue("MBLNO");
|
|
|
|
|
var _bsno = head.GetValue("BSNO");
|
|
|
|
|
|
|
|
|
|
if (opstatus == "add") {
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
|
|
|
|
var dataList = cdc.Op_INTERNALTRADE.Where(x=>x.MBLNO== _mblno).ToList();
|
|
|
|
|
|
|
|
|
|
if (dataList != null && dataList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//如为保存 则看是否有主提单号重复且BSNO不重复的
|
|
|
|
|
if (opstatus == "edit")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dataList = cdc.Op_INTERNALTRADE.Where(x => x.MBLNO == _mblno && x.BSNO!= _bsno).ToList();
|
|
|
|
|
|
|
|
|
|
if (dataList != null && dataList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool 业务锁定(string opstatus, MsOp_INTERNALTRADEmb head) {
|
|
|
|
|
|
|
|
|
|
var _mblno = head.GetValue("MBLNO");
|
|
|
|
|
var _bsno = head.GetValue("BSNO");
|
|
|
|
|
|
|
|
|
|
if (opstatus == "edit")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dataList = cdc.Op_INTERNALTRADE.Where(x => x.BSNO == _bsno).ToList();
|
|
|
|
|
|
|
|
|
|
if (dataList != null && dataList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
if (dataList[0].BSSTATUS == true )
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool 费用锁定(string opstatus, MsOp_INTERNALTRADEmb head)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var _mblno = head.GetValue("MBLNO");
|
|
|
|
|
var _bsno = head.GetValue("BSNO");
|
|
|
|
|
|
|
|
|
|
if (opstatus == "edit")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dataList = cdc.Op_INTERNALTRADE.Where(x => x.BSNO == _bsno).ToList();
|
|
|
|
|
|
|
|
|
|
if (dataList != null && dataList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
if (dataList[0].FEESTATUS == true)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public ContentResult Save(string opstatus, string data, string Body, string DelBody)//
|
|
|
|
|
{
|
|
|
|
|
var modb = new ModelObjectRepository();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
|
|
|
|
var _date = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
var head = new MsOp_INTERNALTRADEmb();
|
|
|
|
|
head.SetValue(db, data);
|
|
|
|
|
head.GetTableField(db);
|
|
|
|
|
|
|
|
|
|
var cansave = CanSave(opstatus, head);
|
|
|
|
|
|
|
|
|
|
if (!cansave.Success) {
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(cansave) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var basebody = new MsOp_INTERNALTRADE_Detailmb();
|
|
|
|
|
basebody.GetTableField(db);
|
|
|
|
|
var BodyList = new List<MsOp_INTERNALTRADE_Detailmb>();
|
|
|
|
|
var DelBodyList = new List<MsOp_INTERNALTRADE_Detailmb>();
|
|
|
|
|
|
|
|
|
|
if (Body != "" )
|
|
|
|
|
{
|
|
|
|
|
var savedl = JsonConvert.Deserialize<List<Dictionary<string, string>>>(Body);
|
|
|
|
|
foreach (var sdl in savedl)
|
|
|
|
|
{
|
|
|
|
|
var body = new MsOp_INTERNALTRADE_Detailmb();
|
|
|
|
|
basebody.Copy(body);
|
|
|
|
|
body.SetValue(sdl);
|
|
|
|
|
if (opstatus == "add")
|
|
|
|
|
{
|
|
|
|
|
body.SetValue("GID", System.Guid.NewGuid().ToString());
|
|
|
|
|
body.SetValue("BSNO", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BodyList.Add(body);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(head.GetValue("CUSTNO"))) {
|
|
|
|
|
|
|
|
|
|
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='内贸海运业务' AND RULEBLNO='委托编号' ", Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var CUSTNO = MsSysBillNoSetDAL.GetBillNo(billnoset, _date, _date, "", Session["USERID"].ToString(), Session["COMPANYID"].ToString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(CUSTNO))
|
|
|
|
|
{
|
|
|
|
|
var _r = new DBResult();
|
|
|
|
|
|
|
|
|
|
_r.SetErrorInfo("请检查【编码规则】设置,【内贸海运业务-委托编号】");
|
|
|
|
|
var jsonRespose2 = new JsonResponse
|
|
|
|
|
{
|
|
|
|
|
Success = _r.Success,
|
|
|
|
|
Message = _r.Message,
|
|
|
|
|
Data = ""
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
head.SetValue("CUSTNO", CUSTNO);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (head.GetValue("ETD") != "" && head.GetValue("CUSTOMERNAME") != "")// headData.STLDATE == "" &&
|
|
|
|
|
{
|
|
|
|
|
//根据客户、开船日计算账期
|
|
|
|
|
|
|
|
|
|
var _dmb = MsInfoClientDAL.GetSTLDATE(head.GetValue("CUSTOMERNAME"), "内贸海运", head.GetValue("ETD"), head.GetValue("SALE"));
|
|
|
|
|
head.SetValue("STLNAME",_dmb.STLNAME);
|
|
|
|
|
head.SetValue("STLDATE",_dmb.STLDATE);
|
|
|
|
|
|
|
|
|
|
if (_dmb.STLNAME == "")
|
|
|
|
|
{
|
|
|
|
|
head.SetValue("STLNAME","现结买单");
|
|
|
|
|
head.SetValue("STLDATE",head.GetValue("ETD"));
|
|
|
|
|
}
|
|
|
|
|
if (_dmb.BSSOURCE != "") head.SetValue("BSSOURCE",_dmb.BSSOURCE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (opstatus == "add")
|
|
|
|
|
{
|
|
|
|
|
head.DbOperationType = DbOperationType.DbotIns;
|
|
|
|
|
head.ModelUIStatus = "I";
|
|
|
|
|
if (string.IsNullOrEmpty(head.GetValue("BSNO")))
|
|
|
|
|
{
|
|
|
|
|
var _bsno = System.Guid.NewGuid().ToString();
|
|
|
|
|
head.SetValue("BSNO", _bsno);
|
|
|
|
|
}
|
|
|
|
|
head.SetValue("BSDATE", _date);
|
|
|
|
|
head.SetValue("CREATOR", Session["SHOWNAME"].ToString());
|
|
|
|
|
}
|
|
|
|
|
else if (opstatus == "edit")
|
|
|
|
|
{
|
|
|
|
|
head.DbOperationType = DbOperationType.DbotUpd;
|
|
|
|
|
head.ModelUIStatus = "E";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
head.DbOperationType = DbOperationType.DbotDel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DBResult result = modb.Save(head,
|
|
|
|
|
ModelObjectConvert<MsOp_INTERNALTRADE_Detailmb>.ToModelObjectList(BodyList),
|
|
|
|
|
ModelObjectConvert<MsOp_INTERNALTRADE_Detailmb>.ToModelObjectList(DelBodyList)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
var bsnovalue = head.GetBillNoValue();
|
|
|
|
|
var bsnoname = head.GetBillNoFieldName();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
|
|
{
|
|
|
|
|
Success = result.Success,
|
|
|
|
|
Message = result.Message,
|
|
|
|
|
Data = MsOp_InternalTradeDAL.GetData(head.GetBillNoFieldName() + " = '" + head.GetBillNoValue() + "'",Session["USERID"].ToString()).ExtendDic//fieldlist
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult Delete(string data)
|
|
|
|
|
{
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
var head = new MsOp_INTERNALTRADEmb();
|
|
|
|
|
head.SetValue(db, data);
|
|
|
|
|
|
|
|
|
|
var canbedel = true;
|
|
|
|
|
|
|
|
|
|
var isfee = MsOpSeaeDAL.GetFeeCount(head.GetValue("BSNO"));
|
|
|
|
|
if (isfee)
|
|
|
|
|
{
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "此票业务存在费用,请先删除费用才能删除此票业务!" };
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
|
|
var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select count(*) BLCOUNT from op_letter_truck WHERE TRUCKSTATUS in ('已接单','已派车','已发单','提交派车') and BSNO='" + head.GetValue("BSNO") + "'");
|
|
|
|
|
if (BLCOUNT != "0")
|
|
|
|
|
{
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "此票业务存在派车信息,请先删除派车信息!" };
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (canbedel == false)
|
|
|
|
|
{
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "此状态下的内贸业务不能进行删除!" };
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var modb = new ModelObjectDBBill();
|
|
|
|
|
DBResult result = modb.Delete(head,
|
|
|
|
|
"delete from Op_InternalTrade_DETAIL where BSNO='" + head.GetValue("BSNO") + "'");
|
|
|
|
|
//MsSysBillNoSetDAL.DeleteBsNo(head.BillNo);
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ContentResult DelDetail(string data,string GID)
|
|
|
|
|
{
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
|
|
|
|
var head = new MsOp_INTERNALTRADEmb();
|
|
|
|
|
head.SetValue(db, data);
|
|
|
|
|
|
|
|
|
|
//var canbedel = SysTaskDAL.TaskGetWord(head.GetValue("YXSTATE"), "candelete");
|
|
|
|
|
var canbedel = true;
|
|
|
|
|
if (canbedel == false)
|
|
|
|
|
{
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "此状态下的内贸业务不能进行删除!" };
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "" };
|
|
|
|
|
|
|
|
|
|
strSql.Append(" delete from MsOp_InternalTrade_DETAIL where GID in (" + GID + ")");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var _r = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
|
|
|
|
|
|
|
|
|
|
//MsOp_YAXIANGDAL.ReCount(head);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ee)
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = ee.Message;
|
|
|
|
|
}
|
|
|
|
|
jsonRespose.Success = true;
|
|
|
|
|
jsonRespose.Message = "明细删除成功";
|
|
|
|
|
jsonRespose.Data = "";
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 获取打印的sql文本
|
|
|
|
|
public ContentResult GetPrintSql(string printname,string BSNOList)
|
|
|
|
|
{
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "" };
|
|
|
|
|
|
|
|
|
|
if (printname == "Print1")
|
|
|
|
|
{
|
|
|
|
|
var result = new PrintSql();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.sql1 = MsOp_InternalTradeDAL.getHeadListStr(" Op_INTERNALTRADE.BSNO in(" + BSNOList + ")");
|
|
|
|
|
result.sql2 = MsOp_InternalTradeDAL.getBodyListStr(" and d.BSNO in(" + BSNOList + ")");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jsonRespose.Success = true;
|
|
|
|
|
jsonRespose.Message = "查询成功";
|
|
|
|
|
jsonRespose.Data = result;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ContentResult ImpExcel()
|
|
|
|
|
{
|
|
|
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
|
|
|
{
|
|
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
|
|
}
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "" };
|
|
|
|
|
|
|
|
|
|
if (Request.Files.Count != 1)
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "请选择上传的文件";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var file = Request.Files["DsLoadExcel"];
|
|
|
|
|
|
|
|
|
|
if (file == null)
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "上传文件发生未知错误,请重新上传";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
|
|
|
|
|
{
|
|
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
|
|
}
|
|
|
|
|
string ext = Path.GetExtension(file.FileName).ToLower();
|
|
|
|
|
if (ext == ".asp" || ext == ".aspx")
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "不允许上传ASP或ASPX文件";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var path = Server.MapPath("../../UploadFiles/ImpBsExcel");
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(path))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(path);
|
|
|
|
|
}
|
|
|
|
|
var imptype = Request.Form["imptype"];
|
|
|
|
|
var size = file.ContentLength;
|
|
|
|
|
var name = Path.GetFileName(file.FileName);
|
|
|
|
|
|
|
|
|
|
var usercode = CookieConfig.GetCookie_UserCode(Request);
|
|
|
|
|
string filename = path + "\\" + usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
|
|
|
|
|
|
|
|
|
|
if (System.IO.File.Exists(filename))
|
|
|
|
|
{
|
|
|
|
|
System.IO.File.Delete(filename);
|
|
|
|
|
}
|
|
|
|
|
file.SaveAs(filename);
|
|
|
|
|
|
|
|
|
|
if (!System.IO.File.Exists(filename))
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "上传的Excel不包含数据01";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (ext != ".xls" && ext != ".xlsx")
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "上传的文件不是Excel文件";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
var strMsg = "";
|
|
|
|
|
System.Data.DataTable table = ExcelHelper.ReadStreamToDataTable(file.InputStream, out strMsg);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strMsg))
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = strMsg;
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (table.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "excel无数据!";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
//if (customerFieldName == "委托单位")
|
|
|
|
|
//{
|
|
|
|
|
var userid = Session["USERID"].ToString();
|
|
|
|
|
var username = Session["SHOWNAME"].ToString();
|
|
|
|
|
var companyid = Session["COMPANYID"].ToString();
|
|
|
|
|
if (imptype == "2")
|
|
|
|
|
{
|
|
|
|
|
result = MsOp_InternalTradeDAL.UpdateOpInternalTrade(table, userid, username, companyid);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result = MsOp_InternalTradeDAL.ImpOpInternalTrade(table, userid, username, companyid);
|
|
|
|
|
}
|
|
|
|
|
var json = JsonConvert.Serialize(new
|
|
|
|
|
{
|
|
|
|
|
success = result.Success,
|
|
|
|
|
Message = result.Message
|
|
|
|
|
});
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "读取Excel文件出错,请确认文件正确性" + e.Message;
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public ContentResult SaveList(string BSNOList, string headdata)//
|
|
|
|
|
{
|
|
|
|
|
var modb = new ModelObjectRepository();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
|
|
|
|
var Updhead = new MsOp_INTERNALTRADEmb();
|
|
|
|
|
Updhead.SetValue(db, headdata);
|
|
|
|
|
|
|
|
|
|
//找到所有相关业务
|
|
|
|
|
var count = 0;
|
|
|
|
|
var headList = MsOp_InternalTradeDAL.GetDataList(0, 9999, " BSNO in (" + BSNOList + ") and (bsstatus=0 and feestatus=0)", Session["USERID"].ToString(),out count, "");
|
|
|
|
|
|
|
|
|
|
DBResult result = new DBResult();
|
|
|
|
|
var savehead = new MsOp_INTERNALTRADEmb();
|
|
|
|
|
savehead.GetTableField(db);
|
|
|
|
|
var basebody = new MsOp_INTERNALTRADE_Detailmb();
|
|
|
|
|
basebody.GetTableField(db);
|
|
|
|
|
|
|
|
|
|
foreach (var _head in headList)
|
|
|
|
|
{
|
|
|
|
|
var head = new MsOp_INTERNALTRADEmb();
|
|
|
|
|
savehead.Copy(head);
|
|
|
|
|
head.SetValue(_head.ExtendDic);
|
|
|
|
|
|
|
|
|
|
head.DbOperationType = DbOperationType.DbotUpd;
|
|
|
|
|
head.ModelUIStatus = "E";
|
|
|
|
|
//更新哪些字段
|
|
|
|
|
|
|
|
|
|
head.setValue_NoNull("ACCDATE", Updhead.GetValue("ACCDATE"));
|
|
|
|
|
head.setValue_NoNull("ETD", Updhead.GetValue("ETD"));
|
|
|
|
|
head.setValue_NoNull("VOYNO", Updhead.GetValue("VOYNO"));
|
|
|
|
|
head.setValue_NoNull("VESSEL", Updhead.GetValue("VESSEL"));
|
|
|
|
|
head.setValue_NoNull("ETA", Updhead.GetValue("ETA"));
|
|
|
|
|
head.setValue_NoNull("CTNALL", Updhead.GetValue("CTNALL"));
|
|
|
|
|
|
|
|
|
|
var BodyList = new List<MsOp_INTERNALTRADE_Detailmb>();
|
|
|
|
|
var SaveBodyList = new List<MsOp_INTERNALTRADE_Detailmb>();
|
|
|
|
|
var DelList = new List<MsOp_INTERNALTRADE_Detailmb>();
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(Updhead.GetValue("LOADADDR")) || !string.IsNullOrWhiteSpace(Updhead.GetValue("LOADADDR"))) {
|
|
|
|
|
BodyList = MsOp_InternalTradeDAL.GetBodyList(" D.BSNO='" + head.GetValue("BSNO") + "'");
|
|
|
|
|
|
|
|
|
|
foreach (var body in BodyList) {
|
|
|
|
|
var savebody = new MsOp_INTERNALTRADE_Detailmb();
|
|
|
|
|
basebody.Copy(savebody);
|
|
|
|
|
savebody.SetValue(body.ExtendDic);
|
|
|
|
|
|
|
|
|
|
savebody.setValue_NoNull("LOADADDR", Updhead.GetValue("LOADADDR"));
|
|
|
|
|
savebody.setValue_NoNull("ACCDATE", Updhead.GetValue("LOADDATE"));
|
|
|
|
|
SaveBodyList.Add(savebody);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = modb.Save(head,
|
|
|
|
|
ModelObjectConvert<MsOp_INTERNALTRADE_Detailmb>.ToModelObjectList(SaveBodyList),
|
|
|
|
|
ModelObjectConvert<MsOp_INTERNALTRADE_Detailmb>.ToModelObjectList(DelList)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!result.Success) break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
|
|
{
|
|
|
|
|
Success = result.Success,
|
|
|
|
|
Message = result.Message,
|
|
|
|
|
Data = null
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|