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/MsPriceController.cs

1694 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.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.MsPrice;
using DSWeb.MvcShipping.Models.MsPrice;
using DSWeb.Areas.OA.Models.WorkFlow;
using DSWeb.EntityDA;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
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.Models.MsCrmPriceCarrier;
using DSWeb.MvcShipping.DAL.MsCrmPriceCarrierDAL;
using DSWeb.MvcShipping.DAL.MsCrmPriceCarrierListDAL;
using DSWeb.Areas.Dispatch.DB;
using System.Data.Entity;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.Areas.MvcShipping.Helper;
namespace DSWeb.MvcShipping.Controllers
{
/// <summary>
/// 运价合约/报价管理 邓羽 20200410
/// 需求编号 张工
/// </summary>
[JsonRequestBehavior]
public class MsPriceController : Controller
{
//
// GET: /RptMng/MsRptPcHeadQry
public ActionResult ContractIndex()
{
return View();
}
public ActionResult ContractEdit()
{
return View();
}
public ActionResult QuotationIndex()
{
return View();
}
public ActionResult QuotationEdit()
{
return View();
}
#region 运价合约 头表/明细表
//public ContentResult GetSqlStr(string YXNOList) {
// string sql = MsOp_YAXIANGDAL.gethea;
//}
public ContentResult GetContractList(int start, int limit, string condition, string sort="")
{
var canlogin = BasicDataRefDAL.CheckLogin(Session);
if (!canlogin.Success)
{
return (ContentResult)canlogin.Data;
}
var _count = 0;
var dataList = MsPriceContractDAL.GetDataList(start,limit,condition, Session["USERID"].ToString(),out _count, sort);
var list_2 = ModelObjectBill.getDicList(ModelObjectConvert<MsPrice_Contract_mb>.ToModelObjectList(dataList));
var json = JsonConvert.Serialize(new
{
Success = true,
Message = "查询成功",
totalCount = _count,
data = list_2.ToList()
});
return new ContentResult() { Content = json };
}
public ContentResult GetContractData(string handle, string condition)
{
var result = new MsPrice_Contract_mb();
if (handle == "add") {
result.getDef(Session["USERID"].ToString());
}else
result = MsPriceContractDAL.GetData(condition, Session["USERID"].ToString());
var json = JsonConvert.Serialize(new
{
Success = true,
Message = "查询成功",
//totalCount = 1,
data = result.ExtendDic
//,fieldlist = fieldlist.ToList()
});
return new ContentResult() { Content = json };
}
public ContentResult GetContractDetailList( string condition )
{
var dataList = MsPriceContractDAL.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 };
}
public ContentResult GetContractWayList(int start, int limit, string condition, string sort = "")
{
var canlogin = BasicDataRefDAL.CheckLogin(Session);
if (!canlogin.Success)
{
return (ContentResult)canlogin.Data;
}
var dataList = MsPriceContractDAL.GetWayList( condition, sort);
var list_1 = ModelObjectBill.getDicList(ModelObjectConvert<MsPrice_Contract_Waymb>.ToModelObjectList(dataList));
var list_2 = list_1.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new
{
Success = true,
Message = "查询成功",
totalCount = list_1.Count(),
data = list_2.ToList()
});
return new ContentResult() { Content = json };
}
public ContentResult GetContractPortDetentionList(int start, int limit, string condition, string sort = "")
{
var canlogin = BasicDataRefDAL.CheckLogin(Session);
if (!canlogin.Success)
{
return (ContentResult)canlogin.Data;
}
var dataList = MsPriceContractDAL.GetPortDetentionList(condition, sort);
var list_1 = ModelObjectBill.getDicList(ModelObjectConvert<MsPrice_Contract_PortDetentionmb>.ToModelObjectList(dataList));
//var list_2 = list_1.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new
{
Success = true,
Message = "查询成功",
totalCount = list_1.Count(),
data = list_1.ToList()
});
return new ContentResult() { Content = json };
}
#endregion
#region 运价合约 保存/删除/删除明细
public ContentResult SaveContract(string opstatus, string data, string Body, string Way,string PORTDETENTION)//
{
var canlogin = BasicDataRefDAL.CheckLogin(Session);
if (!canlogin.Success)
{
return (ContentResult)canlogin.Data;
}
//BasicDataRefDAL.SaveLog("1保存开始", "", "运价合约管理", "保存");
DateTime dt1 = DateTime.Now;
while ((DateTime.Now - dt1).TotalMilliseconds < 1)
{
continue;
};
var modb = new ModelObjectRepository();
var db = DatabaseFactory.CreateDatabase();
var _date = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
var head = new MsPrice_Contract_mb();
head.SetValue(db, data);
//head.GetTableField(db);
var basebody = new MsPrice_Contract_Detailmb();
basebody.GetTableField(db);
var BodyList = new List<MsPrice_Contract_Detailmb>();
var DelBodyList = new List<MsPrice_Contract_Detailmb>();
if (Body != "")
{
var savedl = JsonConvert.Deserialize<List<Dictionary<string, string>>>(Body);
foreach (var sdl in savedl)
{
var body = new MsPrice_Contract_Detailmb();
basebody.Copy(body);
body.SetValue(sdl);
BodyList.Add(body);
}
}
var waybody = new MsPrice_Contract_Waymb();
waybody.GetTableField(db);
var WayList = new List<MsPrice_Contract_Waymb>();
var DelWayList = new List<MsPrice_Contract_Waymb>();
if (Way != "")
{
var savedl = JsonConvert.Deserialize<List<Dictionary<string, string>>>(Way);
foreach (var sdl in savedl)
{
var body = new MsPrice_Contract_Waymb();
waybody.Copy(body);
body.SetValue(sdl);
WayList.Add(body);
}
}
var PortDetentionBody = new MsPrice_Contract_PortDetentionmb();
PortDetentionBody.GetTableField(db);
var PortDetentionList = new List<MsPrice_Contract_PortDetentionmb>();
var DelPortDetentionList = new List<MsPrice_Contract_PortDetentionmb>();
if (!string.IsNullOrWhiteSpace( PORTDETENTION))
{
var savedl = JsonConvert.Deserialize<List<Dictionary<string, string>>>(PORTDETENTION);
foreach (var sdl in savedl)
{
var body = new MsPrice_Contract_PortDetentionmb();
PortDetentionBody.Copy(body);
body.SetValue(sdl);
PortDetentionList.Add(body);
}
}
//BasicDataRefDAL.SaveLog("2数据组织完毕", "", "运价合约管理", "保存");
dt1 = DateTime.Now;
while ((DateTime.Now - dt1).TotalMilliseconds < 1)
{
continue;
};
if (string.IsNullOrWhiteSpace(head.GetValue("BSNO"))) {
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='运价合约业务' AND RULEBLNO='委托编号' ", Convert.ToString(Session["COMPANYID"]));
var BSNO = MsSysBillNoSetDAL.GetBillNo(billnoset, _date, _date, "", Session["USERID"].ToString(), Session["COMPANYID"].ToString());
if (string.IsNullOrWhiteSpace(BSNO))
{
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("BSNO", BSNO);
}
//BasicDataRefDAL.SaveLog("3编码规则", "", "运价合约管理", "保存");
dt1 = DateTime.Now;
while ((DateTime.Now - dt1).TotalMilliseconds < 1)
{
continue;
};
}
if (opstatus == "add")
{
head.DbOperationType = DbOperationType.DbotIns;
head.ModelUIStatus = "I";
head.SetValue("CREATOR", Session["SHOWNAME"].ToString());
head.SetValue("CREATETIME", _date);
}
else if (opstatus == "edit")
{
head.DbOperationType = DbOperationType.DbotUpd;
head.ModelUIStatus = "E";
}
else
{
head.DbOperationType = DbOperationType.DbotDel;
}
//BasicDataRefDAL.SaveLog("4保存开始", "", "运价合约管理", "保存");
dt1 = DateTime.Now;
while ((DateTime.Now - dt1).TotalMilliseconds < 1)
{
continue;
};
DBResult result = modb.Save(head,
ModelObjectConvert<MsPrice_Contract_Detailmb>.ToModelObjectList(BodyList),
ModelObjectConvert<MsPrice_Contract_Detailmb>.ToModelObjectList(DelBodyList),
ModelObjectConvert<MsPrice_Contract_Waymb>.ToModelObjectList(WayList),
ModelObjectConvert<MsPrice_Contract_Waymb>.ToModelObjectList(DelWayList),
ModelObjectConvert<MsPrice_Contract_PortDetentionmb>.ToModelObjectList(PortDetentionList),
ModelObjectConvert<MsPrice_Contract_PortDetentionmb>.ToModelObjectList(DelPortDetentionList)
);
//BasicDataRefDAL.SaveLog("5保存结束", result.Success.ToString()+";"+ result.Message, "运价合约管理", "保存");
dt1 = DateTime.Now;
while ((DateTime.Now - dt1).TotalMilliseconds < 1)
{
continue;
};
var bsnovalue = head.GetBillNoValue();
var bsnoname = head.GetBillNoFieldName();
var _Data = MsPriceContractDAL.GetData(head.GetBillNoFieldName() + " = '" + head.GetBillNoValue() + "'", Session["USERID"].ToString()).ExtendDic;
//BasicDataRefDAL.SaveLog("6获取返回的数据", _Data.ToString(), "运价合约管理", "保存");
dt1 = DateTime.Now;
while ((DateTime.Now - dt1).TotalMilliseconds < 1)
{
continue;
};
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = _Data//fieldlist
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveContract_ef(string opstatus, string data, string Body, string Way, string PORTDETENTION)//
{
DBResult result = new DBResult();
result.Success = true;
result.Message = "";
var canlogin = BasicDataRefDAL.CheckLogin(Session);
if (!canlogin.Success)
{
return (ContentResult)canlogin.Data;
}
try
{
DataContext dc = new DataContext();
Op_SeaPrice_Contract headData = JsonConvert.Deserialize<Op_SeaPrice_Contract>(data);
var WayList = JsonConvert.Deserialize<List<Op_SeaPrice_Contract_Way>>(Way);
var BodyList = JsonConvert.Deserialize<List<Op_SeaPrice_Contract_Detail>>(Body);
var PortDetentionList = JsonConvert.Deserialize<List<Op_SeaPrice_Contract_PortDetention>>(PORTDETENTION);
var BSNO = "";
if (opstatus == "edit")
{
var oldhead = dc.Op_SeaPrice_Contract.First(x => x.BSNO == headData.BSNO);
oldhead.savecopy(headData);
BSNO = headData.BSNO;
}
else
{
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='运价合约业务' AND RULEBLNO='委托编号' ", Convert.ToString(Session["COMPANYID"]));
var _date = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
BSNO = MsSysBillNoSetDAL.GetBillNo(billnoset, _date, _date, "", Session["USERID"].ToString(), Session["COMPANYID"].ToString());
if (string.IsNullOrWhiteSpace(BSNO))
{
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
{
headData.BSNO = BSNO;
dc.Op_SeaPrice_Contract.Add(headData);
}
}
result.Data = headData;
if (WayList != null)
{
var oldwaylist = dc.Op_SeaPrice_Contract_Way.Where(x => x.BSNO == BSNO).ToList();
foreach (var way in WayList)
{
if (string.IsNullOrWhiteSpace(way.BSNO))
{
way.BSNO = BSNO;
dc.Op_SeaPrice_Contract_Way.Add(way);
}
else
{
var oldway = oldwaylist.First(x => x.ID == way.ID);
oldway.savecopy(way);
}
}
}
if (BodyList != null)
{
var oldBodyList = dc.Op_SeaPrice_Contract_Detail.Where(x => x.BSNO == BSNO).ToList();
foreach (var body in BodyList)
{
if (string.IsNullOrWhiteSpace(body.BSNO))
{
body.BSNO = BSNO;
dc.Op_SeaPrice_Contract_Detail.Add(body);
}
else
{
var oldBody = oldBodyList.First(x => x.GID == body.GID);
oldBody.savecopy(body);
}
}
}
if (PortDetentionList != null)
{
var oldPortdetentionList = dc.Op_SeaPrice_Contract_PortDetention.Where(x => x.BSNO == BSNO).ToList();
foreach (var pd in PortDetentionList)
{
if (string.IsNullOrWhiteSpace(pd.BSNO))
{
pd.BSNO = BSNO;
dc.Op_SeaPrice_Contract_PortDetention.Add(pd);
}
else
{
var oldpd = oldPortdetentionList.First(x => x.ID == pd.ID);
oldpd.savecopy(pd);
}
}
}
dc.SaveChanges();
}
catch (Exception e) {
result.Success = false;
result.Message = e.Message;
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = result.Data
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveContract_Detail(string opstatus, string data, string Body, string Way, string Type="")//
{
var canlogin = BasicDataRefDAL.CheckLogin(Session);
if (!canlogin.Success)
{
return (ContentResult)canlogin.Data;
}
if (opstatus != "edit")
{
var _r = new DBResult();
_r.SetErrorInfo("请先保存本业务");
var jsonRespose3 = new JsonResponse
{
Success = _r.Success,
Message = _r.Message,
Data = ""
};
return jsonRespose3.getContentReult();
}
DataContext dc = new DataContext();
Op_SeaPrice_Contract headData = JsonConvert.Deserialize<Op_SeaPrice_Contract>(data);
var NewWay = JsonConvert.Deserialize<Op_SeaPrice_Contract_Way>(Way);
var BodyList = JsonConvert.Deserialize<List<Op_SeaPrice_Contract_Detail>>(Body);
var OLDBodyList = dc.Op_SeaPrice_Contract_Detail.Where(x => x.BSNO == headData.BSNO).ToList();
if (string.IsNullOrWhiteSpace(NewWay.BSNO)&&Type=="4")
{
NewWay.BSNO = headData.BSNO;
dc.Op_SeaPrice_Contract_Way.Add(NewWay);
}
else {
if (dc.Op_SeaPrice_Contract_Way.Where(x => x.ID == NewWay.ID).ToList().Count > 0)
{
var oldway = dc.Op_SeaPrice_Contract_Way.First(x => x.ID == NewWay.ID);
oldway.savecopy(NewWay);
}
}
if (Type == "4" && !string.IsNullOrWhiteSpace( NewWay.PODLOAD)) {
Op_SeaPrice_Contract_Way addway = new Op_SeaPrice_Contract_Way();
addway.BSNO = headData.BSNO;
if (!string.IsNullOrWhiteSpace(NewWay.PODLOAD))
{
addway.PODLOAD = NewWay.PODLOAD;
}
dc.Op_SeaPrice_Contract_Way.Add(addway);
//同时复制模板费用
var List = dc.Op_SeaPrice_Contract_Detail.Where(x => x.BSNO == headData.BSNO && (x.PODLOAD == null||x.PODLOAD.Trim()=="")).ToList();
if (List != null) {
foreach (var item in List) {
var newfee = new Op_SeaPrice_Contract_Detail();
newfee.savecopy(item);
newfee.PODLOAD = addway.PODLOAD;
dc.Op_SeaPrice_Contract_Detail.Add(newfee);
}
}
}
if (BodyList != null)
{
for (var _i = 0; _i < BodyList.Count(); _i++)
{
var upd = false;
for (var _j = 0; _j < OLDBodyList.Count(); _j++)
{
if (BodyList[_i].GID == OLDBodyList[_j].GID)
{
OLDBodyList[_j].savecopy(BodyList[_i]);
upd = true;
break;
}
}
if (!upd)
{
BodyList[_i].BSNO = headData.BSNO;
dc.Op_SeaPrice_Contract_Detail.Add(BodyList[_i]);
}
}
}
dc.SaveChanges();
var jsonRespose = new JsonResponse
{
Success = true,
Message = "",
Data = ""
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteContract(string data)
{
var db = DatabaseFactory.CreateDatabase();
var head = new MsPrice_Contract_mb();
head.SetValue(db, data);
var canbedel = SysTaskDAL.TaskGetWord(head.GetValue("CSTATUS"), "candelete");
//var canbedel = true;
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_SeaPrice_Contract_Detail where BSNO='" + head.GetValue("BSNO") + "'"
, "delete from op_SeaPrice_Contract_Way where BSNO='" + head.GetValue("BSNO") + "'"
, "delete from op_SeaPrice_Contract_PortDetention 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 CopyNew_Contract(string OLDBSNO)//
{
var canlogin = BasicDataRefDAL.CheckLogin(Session);
if (!canlogin.Success)
{
return (ContentResult)canlogin.Data;
}
var condition = "BSNO='" + OLDBSNO + "'";
var oldhead = MsPriceContractDAL.GetData(condition, Session["USERID"].ToString());
var oldwaylist = MsPriceContractDAL.GetWayList(condition, "");
var oldbodylist = MsPriceContractDAL.GetBodyList(condition, "");
var oldPortDetentionlist = MsPriceContractDAL.GetPortDetentionList(condition, "");
var modb = new ModelObjectRepository();
var db = DatabaseFactory.CreateDatabase();
var _date = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
var head = new MsPrice_Contract_mb();
head.GetTableField(db);
head.SetValue(oldhead.ExtendDic);
#region 获取新的序列号
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='运价合约业务' AND RULEBLNO='委托编号' ", Convert.ToString(Session["COMPANYID"]));
var BSNO = MsSysBillNoSetDAL.GetBillNo(billnoset, _date, _date, "", Session["USERID"].ToString(), Session["COMPANYID"].ToString());
head.SetValue("BSNO", BSNO);
head.DbOperationType = DbOperationType.DbotIns;
head.ModelUIStatus = "I";
head.SetValue("CREATOR", Session["SHOWNAME"].ToString());
head.SetValue("CREATETIME", _date);
#endregion
var basebody = new MsPrice_Contract_Detailmb();
basebody.GetTableField(db);
var BodyList = new List<MsPrice_Contract_Detailmb>();
var DelBodyList = new List<MsPrice_Contract_Detailmb>();
foreach (var oldbody in oldbodylist)
{
var body = new MsPrice_Contract_Detailmb();
basebody.Copy(body);
body.SetValue(oldbody.ExtendDic);
body.SetValue("GID", Guid.NewGuid().ToString());
body.SetValue("BSNO", "");
BodyList.Add(body);
}
var baseway = new MsPrice_Contract_Waymb();
baseway.GetTableField(db);
var WayList = new List<MsPrice_Contract_Waymb>();
var DelWayList = new List<MsPrice_Contract_Waymb>();
foreach (var oldway in oldwaylist)
{
var way = new MsPrice_Contract_Waymb();
baseway.Copy(way);
way.SetValue(oldway.ExtendDic);
way.SetValue("GID", Guid.NewGuid().ToString());
way.SetValue("BSNO", "");
WayList.Add(way);
}
var basePD = new MsPrice_Contract_PortDetentionmb();
basePD.GetTableField(db);
var PDList = new List<MsPrice_Contract_PortDetentionmb>();
var DelPDList = new List<MsPrice_Contract_PortDetentionmb>();
foreach (var oldPD in oldPortDetentionlist)
{
var PD = new MsPrice_Contract_PortDetentionmb();
basePD.Copy(PD);
PD.SetValue(oldPD.ExtendDic);
//PD.SetValue("GID", Guid.NewGuid().ToString());
PD.SetValue("BSNO", "");
PDList.Add(PD);
}
DBResult result = modb.Save(head,
ModelObjectConvert<MsPrice_Contract_Detailmb>.ToModelObjectList(BodyList),
ModelObjectConvert<MsPrice_Contract_Detailmb>.ToModelObjectList(DelBodyList),
ModelObjectConvert<MsPrice_Contract_Waymb>.ToModelObjectList(WayList),
ModelObjectConvert<MsPrice_Contract_Waymb>.ToModelObjectList(DelWayList),
ModelObjectConvert<MsPrice_Contract_PortDetentionmb>.ToModelObjectList(PDList),
ModelObjectConvert<MsPrice_Contract_PortDetentionmb>.ToModelObjectList(DelPDList)
);
var bsnovalue = head.GetBillNoValue();
var bsnoname = head.GetBillNoFieldName();
var _Data = MsPriceContractDAL.GetData(head.GetBillNoFieldName() + " = '" + head.GetBillNoValue() + "'", Session["USERID"].ToString()).ExtendDic;
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = _Data//fieldlist
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DelContractDetail(string data,string GID)
{
var db = DatabaseFactory.CreateDatabase();
var head = new MsPrice_Contract_mb();
head.SetValue(db, data);
var canbedel = SysTaskDAL.TaskGetWord(head.GetValue("CSTATUS"), "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 op_SeaPrice_Contract_Detail where GID in (" + GID + ")");
try
{
var _r = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
}
catch (Exception ee)
{
jsonRespose.Success = false;
jsonRespose.Message = ee.Message;
}
jsonRespose.Success = true;
jsonRespose.Message = "明细删除成功";
jsonRespose.Data = "";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult DelContractWay(string data, string ID)
{
var db = DatabaseFactory.CreateDatabase();
var head = new MsPrice_Contract_mb();
head.SetValue(db, data);
var canbedel = SysTaskDAL.TaskGetWord(head.GetValue("CSTATUS"), "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 op_SeaPrice_Contract_Way where ID in (" + ID + ")");
strSql.Append(" delete from op_SeaPrice_Contract_Detail where not exists(select 1 from op_SeaPrice_Contract_Way where bsno=op_SeaPrice_Contract_Detail.BSNO and PODLOAD=op_SeaPrice_Contract_Detail.PODLOAD and PORTDISCHARGE=op_SeaPrice_Contract_Detail.PORTDISCHARGE and VIA=op_SeaPrice_Contract_Detail.VIA) and isnull(PODLOAD,'')<>'' ");
try
{
var _r = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
}
catch (Exception ee)
{
jsonRespose.Success = false;
jsonRespose.Message = ee.Message;
}
jsonRespose.Success = true;
jsonRespose.Message = "明细删除成功";
jsonRespose.Data = "";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult DelContractPORTDETENTION(string data, string ID)
{
var db = DatabaseFactory.CreateDatabase();
var head = new MsPrice_Contract_mb();
head.SetValue(db, data);
var canbedel = SysTaskDAL.TaskGetWord(head.GetValue("CSTATUS"), "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 op_SeaPrice_Contract_PortDetention where ID in (" + ID + ")");
try
{
var _r = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
}
catch (Exception ee)
{
jsonRespose.Success = false;
jsonRespose.Message = ee.Message;
}
jsonRespose.Success = true;
jsonRespose.Message = "明细删除成功";
jsonRespose.Data = "";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
#endregion
#region 运价单 状态变更
public ContentResult PushState(string data, string Execution)
{
var db = DatabaseFactory.CreateDatabase();
var head = new MsPrice_Contract_mb();
head.SetValue(db, data);
return doPushState(head, Execution);
}
private ContentResult doPushState(MsPrice_Contract_mb head, string Execution)
{
var statusfield = "CSTATUS";
var modb = new ModelObjectRepository();
JsonResponse result = new JsonResponse();
var STATE = head.GetValue(statusfield);
var newState = SysTaskDAL.DoExecution(STATE, Execution);
if (newState.STATEKEY == "0000")
{
result.Success = false;
result.Message = head.GetValue("CSTATUSREF") + "状态下的业务不能进行此操作";
}
else
{
head.SetValue(statusfield, newState.STATEKEY);
head.DbOperationType = DbOperationType.DbotUpd;
head.ModelUIStatus = "E";
var _r = modb.Save(head);
result.Success = _r.Success;
result.Message = _r.Message;
}
return new ContentResult() { Content = JsonConvert.Serialize(result) };
}
#endregion
/// <summary>
/// 由合约生成运价
/// </summary>
/// <param name="Head"></param>
/// <param name="Body"></param>
/// <returns></returns>
public ContentResult MakePrice(string BSNOList)
{
DelPrice(BSNOList);
var _count = 0;
var HeadList = MsPriceContractDAL.GetDataList(0, 9999, " BSNO in(" + BSNOList + ")", Session["USERID"].ToString(),out _count);
var _r = new JsonResponse();
_r.Success = true;
var saveresult = new DBResult();
var modb = new ModelObjectRepository();
foreach (var in HeadList)
{
if (string.IsNullOrWhiteSpace(.GetValue("EFFECTIVEDATE")) || string.IsNullOrWhiteSpace(.GetValue("VALIDDATE"))) {
_r.Success = false;
_r.Message += "没有有效的生效日期 和/或 失效日期;";
}
if (string.IsNullOrWhiteSpace(.GetValue("CARRIER")) )
{
_r.Success = false;
_r.Message += "请选择船公司;";
}
if (!_r.Success) {
return _r.getContentReult();
}
var crmpricelist = MsCrmPriceCarrierDAL.getNewWithContractValue(, Session["USERID"].ToString());
if (crmpricelist.Count > 0) {
saveresult = modb.SaveHead(
ModelObjectConvert<MsCrmPriceCarrier>.ToModelObjectList(crmpricelist)
);
}
if (!_r.Success) break;
}
_r.Success = true;
_r.Message = "所有费用目前均已生成";
return _r.getContentReult();
}
//删除由合约而生成的运价 通常在生成前执行
private void DelPrice(string BSNOList) {
var _c = BasicDataRefDAL.ExecSql("delete from crm_price_carrier_2 where CONTRACTBSNO in(" + BSNOList + ")");
}
#region 运价合约 获取打印的sql文本
public ContentResult GetContractPrintSql(string printname,string BSNOList)
{
var jsonRespose = new JsonResponse { Success = false, Message = "" };
if (printname == "Print1")
{
var result = new PrintSql();
result.sql1 = MsPriceContractDAL.getHeadListStr(" and BSNO in(" + BSNOList + ")");
result.sql2 = MsPriceContractDAL.getBodyListStr(" and BSNO in(" + BSNOList + ")");
jsonRespose.Success = true;
jsonRespose.Message = "查询成功";
jsonRespose.Data = result;
}
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 报价单 头表 / 明细表 查询
public ContentResult GetQuotationList(int start, int limit, string condition, string sort = "")
{
var _count = 0;
var dataList = MsQuotationDAL.GetDataList(start, limit, condition, Session["USERID"].ToString(), sort);
var list_2 = ModelObjectBill.getDicList(ModelObjectConvert<MsQuotationmb>.ToModelObjectList(dataList));
var json = JsonConvert.Serialize(new
{
Success = true,
Message = "查询成功",
totalCount = _count,
data = list_2.ToList()
});
return new ContentResult() { Content = json };
}
public ContentResult GetQuotationData(string handle, string condition)
{
var result = new MsQuotationmb();
if (handle == "add")
{
result.getDef(Session["USERID"].ToString());
}
else
result = MsQuotationDAL.GetData(condition, Session["USERID"].ToString());
var json = JsonConvert.Serialize(new
{
Success = true,
Message = "查询成功",
//totalCount = 1,
data = result.ExtendDic
//,fieldlist = fieldlist.ToList()
});
return new ContentResult() { Content = json };
}
public ContentResult GetQuotationDetailList(string condition)
{
var dataList = MsQuotationDAL.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 };
}
public ContentResult GetQuotationAddList(int start,int limit,string condition,string sort="")
{
var canlogin = BasicDataRefDAL.CheckLogin(Session);
if (!canlogin.Success)
{
return (ContentResult)canlogin.Data;
}
if (!string.IsNullOrWhiteSpace(condition)) condition += " and ";
condition += " LOCKFLAG='true' and ISISSUE='true' ";
var dataList = MsCrmPriceCarrierListDAL.GetDataList(condition, start, limit, Session["USERID"].ToString(), Session["CODENAME"].ToString(), Session["COMPANYID"].ToString(), sort);
int count = MsCrmPriceCarrierListDAL.getTotalCount(condition, CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
/// <summary>
/// 用于费用列表内的关联报价单列表
/// </summary>
/// <param name="condition"></param>
/// <param name="mblno"></param>
/// <returns></returns>
public ContentResult GetSmallQuotationList(string condition, string mblno) {
var _count = 0;
var dataList = MsQuotationDAL.GetSmallDataList(0, 10, condition, mblno, Session["USERID"].ToString(), "CREATETIME DESC");
var list_2 = ModelObjectBill.getDicList(ModelObjectConvert<MsQuotationmb>.ToModelObjectList(dataList));
var json = JsonConvert.Serialize(new
{
Success = true,
Message = "查询成功",
totalCount = _count,
data = list_2.ToList()
});
return new ContentResult() { Content = json };
}
public ContentResult GetZaFeiList(string condition)
{
var _count = 0;
var dataList = MsQuotationDAL.GetZaFeiDataList(condition);
var list_2 = ModelObjectBill.getDicList(ModelObjectConvert<MsQuotation_ZaFeiListmb>.ToModelObjectList(dataList));
var json = JsonConvert.Serialize(new
{
Success = true,
Message = "查询成功",
totalCount = _count,
data = list_2.ToList()
});
return new ContentResult() { Content = json };
}
#endregion
#region 查询 指定报价的箱型的底价费用明细
public ContentResult GetFeeDetail(string fieldname,string CONTRACTBSNO,string PODLOAD,string PORTDISCHARGEID,string VIA, string VIA2)
{
var result = new JsonResponse();
var _fieldname = fieldname.Substring(0, fieldname.Length - 1);
var rdlist = BasicDataRefDAL.GeneralSelect($"select '' GID,dbo.F_ContractPriceStr_{_fieldname}('{CONTRACTBSNO}','{PODLOAD}','{PORTDISCHARGEID}','{VIA}','{VIA2}') GVALUE ");
if (rdlist.Count > 0)
{
var rd = rdlist[0];
result.Success = true;
result.Message = "";
result.Data = rd.GVALUE;
}
else {
result.Success = false;
result.Message = "";
result.Data = "";
}
return new ContentResult() { Content = JsonConvert.Serialize(result) };
}
#endregion
#region 报价单 保存/删除/删除明细
public ContentResult SaveQuotation_old(string opstatus, string data, string Body, string ZaFei)//
{
var modb = new ModelObjectRepository();
var db = DatabaseFactory.CreateDatabase();
var _date = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
var head = new MsQuotationmb();
head.SetValue(db, data);
head.GetTableField(db);
var basebody = new MsQuotation_Detailmb();
basebody.GetTableField(db);
var BodyList = new List<MsQuotation_Detailmb>();
var DelBodyList = new List<MsQuotation_Detailmb>();
if (Body != "")
{
var savedl = JsonConvert.Deserialize<List<Dictionary<string, string>>>(Body);
foreach (var sdl in savedl)
{
var body = new MsQuotation_Detailmb();
basebody.Copy(body);
body.SetValue(sdl);
BodyList.Add(body);
}
}
var base_ZaFeibody = new MsQuotation_ZaFeiListmb();
base_ZaFeibody.GetTableField(db);
var ZaFeiList = new List<MsQuotation_ZaFeiListmb>();
var DelZaFeiList = new List<MsQuotation_ZaFeiListmb>();
if (ZaFei != "")
{
var savedl = JsonConvert.Deserialize<List<Dictionary<string, string>>>(ZaFei);
foreach (var sdl in savedl)
{
var body = new MsQuotation_ZaFeiListmb();
base_ZaFeibody.Copy(body);
body.SetValue(sdl);
ZaFeiList.Add(body);
}
}
if (string.IsNullOrWhiteSpace(head.GetValue("BSNO")))
{
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='运价报价业务' AND RULEBLNO='委托编号' ", Convert.ToString(Session["COMPANYID"]));
var BSNO = MsSysBillNoSetDAL.GetBillNo(billnoset, _date, _date, "", Session["USERID"].ToString(), Session["COMPANYID"].ToString());
if (string.IsNullOrWhiteSpace(BSNO))
{
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("BSNO", BSNO);
}
}
if (opstatus == "add")
{
head.DbOperationType = DbOperationType.DbotIns;
head.ModelUIStatus = "I";
head.SetValue("CREATOR", Session["SHOWNAME"].ToString());
head.SetValue("CREATETIME", _date);
}
else if (opstatus == "edit")
{
head.DbOperationType = DbOperationType.DbotUpd;
head.ModelUIStatus = "E";
}
else
{
head.DbOperationType = DbOperationType.DbotDel;
}
DBResult result = modb.Save(head,
ModelObjectConvert<MsQuotation_Detailmb>.ToModelObjectList(BodyList),
ModelObjectConvert<MsQuotation_Detailmb>.ToModelObjectList(DelBodyList),
ModelObjectConvert<MsQuotation_ZaFeiListmb>.ToModelObjectList(ZaFeiList),
ModelObjectConvert<MsQuotation_ZaFeiListmb>.ToModelObjectList(DelZaFeiList)
);
var bsnovalue = head.GetBillNoValue();
var bsnoname = head.GetBillNoFieldName();
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsQuotationDAL.GetData(head.GetBillNoFieldName() + " = '" + head.GetBillNoValue() + "'", Session["USERID"].ToString()).ExtendDic//fieldlist
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveQuotation(string opstatus, string data, string Body, string ZaFei)//
{
DBResult result = new DBResult();
result.Success = true;
result.Message = "";
var canlogin = BasicDataRefDAL.CheckLogin(Session);
if (!canlogin.Success)
{
return (ContentResult)canlogin.Data;
}
var _date = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
try
{
DataContext dc = new DataContext();
Op_SeaPrice_Quotation headData = JsonConvert.Deserialize<Op_SeaPrice_Quotation>(data);
var BodyList = JsonConvert.Deserialize<List<Op_SeaPrice_Quotation_Detail>>(Body);
var ZaFeiList = JsonConvert.Deserialize<List<Op_SeaPrice_Quotation_ZaFeiList>>(ZaFei);
var BSNO = "";
if (opstatus == "edit")
{
var oldhead = dc.Op_SeaPrice_Quotation.First(x => x.BSNO == headData.BSNO);
oldhead.savecopy(headData);
BSNO = headData.BSNO;
}
else
{
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='运价报价业务' AND RULEBLNO='委托编号' ", Convert.ToString(Session["COMPANYID"]));
BSNO = MsSysBillNoSetDAL.GetBillNo(billnoset, _date, _date, "", Session["USERID"].ToString(), Session["COMPANYID"].ToString());
if (string.IsNullOrWhiteSpace(BSNO))
{
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
{
headData.BSNO = BSNO;
}
}
result.Data = headData;
if (BodyList != null)
{
var oldBodyList = dc.Op_SeaPrice_Quotation_Detail.Where(x => x.BSNO == BSNO).ToList();
foreach (var body in BodyList)
{
if (string.IsNullOrWhiteSpace(body.BSNO))
{
body.BSNO = BSNO;
dc.Op_SeaPrice_Quotation_Detail.Add(body);
}
else
{
var oldBody = oldBodyList.First(x => x.GID == body.GID);
dc.Op_SeaPrice_Quotation_Detail.Remove(oldBody);
dc.Op_SeaPrice_Quotation_Detail.Add(body);
}
}
}
if (ZaFeiList != null)
{
var oldPortdetentionList = dc.Op_SeaPrice_Quotation_ZaFeiList.Where(x => x.BSNO == BSNO).ToList();
foreach (var pd in ZaFeiList)
{
if (string.IsNullOrWhiteSpace(pd.BSNO))
{
pd.BSNO = BSNO;
dc.Op_SeaPrice_Quotation_ZaFeiList.Add(pd);
}
else
{
var oldpd = oldPortdetentionList.First(x => x.ID == pd.ID);
dc.Op_SeaPrice_Quotation_ZaFeiList.Remove(oldpd);
dc.Op_SeaPrice_Quotation_ZaFeiList.Add(pd);
}
}
}
dc.SaveChanges();
}
catch (Exception e)
{
result.Success = false;
result.Message = e.Message;
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = result.Data
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteQuotation(string data)
{
var db = DatabaseFactory.CreateDatabase();
var head = new MsQuotationmb();
head.SetValue(db, data);
//var canbedel = SysTaskDAL.TaskGetWord(head.GetValue("CSTATUS"), "candelete");
var canbedel = true;
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_SeaPrice_Quotation_Detail where BSNO='" + head.GetValue("BSNO") + "'"
, "delete from Op_SeaPrice_Quotation_ZaFeiList 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 DelQuotationDetail(string data, string GID)
{
var db = DatabaseFactory.CreateDatabase();
var head = new MsPrice_Contract_mb();
head.SetValue(db, data);
//var canbedel = SysTaskDAL.TaskGetWord(head.GetValue("CSTATUS"), "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 op_SeaPrice_Quotation_Detail where GID in (" + GID + ")");
try
{
var _r = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
}
catch (Exception ee)
{
jsonRespose.Success = false;
jsonRespose.Message = ee.Message;
}
jsonRespose.Success = true;
jsonRespose.Message = "明细删除成功";
jsonRespose.Data = "";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult DelZaFeiDetail(string data, string GID)
{
var db = DatabaseFactory.CreateDatabase();
var head = new MsPrice_Contract_mb();
head.SetValue(db, data);
//var canbedel = SysTaskDAL.TaskGetWord(head.GetValue("CSTATUS"), "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 Op_SeaPrice_Quotation_ZaFeiList where ID in (" + GID + ")");
try
{
var _r = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
}
catch (Exception ee)
{
jsonRespose.Success = false;
jsonRespose.Message = ee.Message;
}
jsonRespose.Success = true;
jsonRespose.Message = "明细删除成功";
jsonRespose.Data = "";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
#endregion
#region 报价单 提单号关联表//该表只有单个添加/删除 操作 不与其他操作联动
public ContentResult GetQuotationMblnoList(string condition)
{
var _count = 0;
var dataList = MsQuotationDAL.GetMblnoList(condition);
var list_2 = ModelObjectBill.getDicList(ModelObjectConvert<MsQuotation_MblnoListmb>.ToModelObjectList(dataList));
var json = JsonConvert.Serialize(new
{
Success = true,
Message = "查询成功",
totalCount = _count,
data = list_2.ToList()
});
return new ContentResult() { Content = json };
}
public ContentResult QuotationAddMblno(string BSNO, string MBLNO) {
var db = DatabaseFactory.CreateDatabase();
MsQuotation_MblnoListmb ml = new MsQuotation_MblnoListmb();
ml.GetTableField(db);
ml.DbOperationType = DbOperationType.DbotIns;
ml.SetValue("MBLNO", MBLNO);
ml.SetValue("CREATOR", Session["SHOWNAME"].ToString());
ml.SetValue("CREATETIME", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
var modb = new ModelObjectRepository();
var savelist = new List<MsQuotation_MblnoListmb>();
savelist.Add(ml);
var result = modb.SaveComm("BSNO", BSNO, ModelObjectConvert<MsQuotation_MblnoListmb>.ToModelObjectList(savelist), null);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = null
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult QuotationDelMblno(string BSNO, string MBLNO)
{
var _r = BasicDataRefDAL.ExecSql($" Delete from Op_SeaPrice_Quotation_MblnoList where BSNO='{BSNO}' and MBLNO='{MBLNO}' ");
//return _r;
var jsonRespose = new JsonResponse
{
Success = true,
Message = "",
Data = null
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 从运价中生成报价
public ContentResult AddQuotationDetail(string data, string GID)
{
var db = DatabaseFactory.CreateDatabase();
var head = new MsPrice_Contract_mb();
head.SetValue(db, data);
var currQuoList = MsQuotationDAL.GetBodyList(" BSNO='"+ head.GetValue("BSNO") + "' ");
string condition = " GID in (" + GID + ") ";
var CRMPriceList = MsCrmPriceCarrierListDAL.GetDataList(condition, 0, 9999, Session["USERID"].ToString(), Session["CODENAME"].ToString(), Session["COMPANYID"].ToString(), "");
if (CRMPriceList.Count == 0) {
var jsonRespose2 = new JsonResponse { Success = false, Message = "没有要添加的运价" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
var newquolist = new List<MsQuotation_Detailmb>();
var _tabquo = new MsQuotation_Detailmb();
_tabquo.GetTableField(db);
foreach (var item in CRMPriceList) {
var newquo = new MsQuotation_Detailmb();
_tabquo.Copy(newquo);
newquo.SetValue("BSNO", head.GetValue("BSNO"));
if (currQuoList.Count > 0) {
var _curr = currQuoList.Find(o => o.Issame(item));
//如果能找到一条 船公司 起运港 目的港 中转港 信息完全一致的 则不添加此条
if (_curr!=null) {
continue;
}
}
newquo.setCrmValue(item);
newquolist.Add(newquo);
}
var modb = new ModelObjectDBBill();
var dbresult = modb.Save(ModelObjectConvert<MsQuotation_Detailmb>.ToModelObjectList(newquolist));
var jsonRespose = new JsonResponse { Success = dbresult.Success, Message = dbresult.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 报价单 获取打印的sql文本
public ContentResult GetQuotationPrintSql(string printname, string BSNOList)
{
var jsonRespose = new JsonResponse { Success = false, Message = "" };
var result = new PrintSql();
result.sql1 = MsQuotationDAL.getHeadListStr(" BSNO in(" + BSNOList + ")");
result.sql2 = MsQuotationDAL.getBodyListStr(" and BSNO in(" + BSNOList + ")");
jsonRespose.Success = true;
jsonRespose.Message = "查询成功";
jsonRespose.Data = result;
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetQuotationPrintSql_Fen(string printname, string BSNOList,string[] ctntype)
{
var jsonRespose = new JsonResponse { Success = false, Message = "" };
var result = new PrintSql();
result.sql1 = MsQuotationDAL.getHeadListStr(" BSNO in(" + BSNOList + ")");
result.sql2 = MsQuotationDAL.getBodyListStr_Fen(" and BSNO in(" + BSNOList + ")", ctntype);
jsonRespose.Success = true;
jsonRespose.Message = "查询成功";
jsonRespose.Data = result;
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
}
}