|
|
using System;
|
|
|
using System.IO;
|
|
|
using System.Text;
|
|
|
using System.Data;
|
|
|
using System.Data.OleDb;
|
|
|
using System.Linq;
|
|
|
using System.Web;
|
|
|
using System.Web.Mvc;
|
|
|
using System.Web.Script.Serialization;
|
|
|
using System.Web.Configuration;
|
|
|
using System.Web.Routing;
|
|
|
using System.Configuration;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Security.Principal;
|
|
|
|
|
|
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
|
|
|
using DSWeb.MvcShipping.DAL.MsCrmPriceCarrierDAL;
|
|
|
using DSWeb.MvcShipping.Models.MsCrmPriceCarrier;
|
|
|
using DSWeb.MvcShipping.Helper;
|
|
|
using DSWeb.MvcShipping.Comm.Cookie;
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
using DSWeb.Areas.RptMng.Comm;
|
|
|
using DSWeb.EntityDA;
|
|
|
using HcUtility.Comm;
|
|
|
using HcUtility.Core;
|
|
|
|
|
|
using Microsoft.Office.Interop.Excel;
|
|
|
using System.Web.Configuration;
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
|
|
|
|
|
|
//需求编号:SR2017091200003
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
|
{
|
|
|
[JsonRequestBehavior]
|
|
|
public class MsCrmPriceCarrierController : Controller
|
|
|
{
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
#region 查询
|
|
|
public ContentResult GetDataList(int start, int limit, string sort, string condition)
|
|
|
{
|
|
|
var canlogin = BasicDataRefDAL.CheckLogin(Session);
|
|
|
if (!canlogin.Success)
|
|
|
{
|
|
|
return (ContentResult)canlogin.Data;
|
|
|
}
|
|
|
|
|
|
var dataList = MsCrmPriceCarrierDAL.GetDataList(condition, start, limit, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
|
|
|
int count = MsCrmPriceCarrierDAL.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 };
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 打印
|
|
|
public ContentResult GetDataListStr(string condition)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
//
|
|
|
var dataListStr = MsCrmPriceCarrierDAL.GetDataListStr(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出
|
|
|
public ContentResult GetDataListSQL(string condition)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
//
|
|
|
var dataListStr = MsCrmPriceCarrierDAL.GetDataListStr(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
//dataListStr = "select " + dataListStr + "";
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 引入 EXCEL
|
|
|
[HttpPost]
|
|
|
public ContentResult onImportClick()
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
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["LoadExcel"];
|
|
|
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/YunJia");
|
|
|
if (!Directory.Exists(path))
|
|
|
{
|
|
|
Directory.CreateDirectory(path);
|
|
|
}
|
|
|
var name = Path.GetFileName(file.FileName);
|
|
|
var usercode = CookieConfig.GetCookie_UserCode(Request);
|
|
|
string filenamepath = usercode + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + "_" + name;
|
|
|
string fileName = path + "\\" + filenamepath;
|
|
|
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) };
|
|
|
}
|
|
|
|
|
|
|
|
|
string sError = ""; //失败提示信息
|
|
|
int InsertCount = 0; //新增条数
|
|
|
int UpdateCount = 0; //失败(更新)条数
|
|
|
int iError = 0; //失败(更新)条数
|
|
|
int iheadList = 0; //执行条数
|
|
|
|
|
|
//string strOldDb = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;HDR=Yes;IMEX=1;Data Source=";
|
|
|
//if (fileName.ToLower().IndexOf(".xlsx") > 0)
|
|
|
//{
|
|
|
// strOldDb = "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=\"Excel 12.0 Xml;HDR=Yes\";Data Source=";
|
|
|
//}
|
|
|
//OleDbConnection OleCon = new OleDbConnection(strOldDb + fileName);
|
|
|
//OleDbDataAdapter OleDAp = new OleDbDataAdapter("SELECT [航线],[装货港],[卸货港],[卸货港中文],[船公司],[小柜],[小柜报价],[大柜],[大柜报价],[超高],[超高报价],[小冻],[小冻报价],[超冻],[超冻报价],[中转港],[船期],[航程],[开始日期],[结束日期],[特殊商品],[附加费],[备注] FROM [Sheet1$]", OleCon);
|
|
|
//DataSet ds = new DataSet();
|
|
|
//OleDAp.Fill(ds);
|
|
|
var strMsg = "";
|
|
|
System.Data.DataTable table = ExcelHelper.ExcelToDatatable(file.InputStream, ext, out strMsg);
|
|
|
if (!string.IsNullOrEmpty(strMsg))
|
|
|
{
|
|
|
jsonRespose.Success = false;
|
|
|
jsonRespose.Message = strMsg;
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(table.Rows.Count>0)
|
|
|
{
|
|
|
iheadList = table.Rows.Count; //执行条数
|
|
|
|
|
|
#region 获取动态 集装箱列名
|
|
|
List<XiaLaKuangModel> ctnList = MsCrmPriceCarrierDAL.GetCtn();
|
|
|
string sXG = "";
|
|
|
string sDG = "";
|
|
|
string sCG = "";
|
|
|
string sXD = "";
|
|
|
string sCD = "";
|
|
|
string sXGBJ = "";
|
|
|
string sDGBJ = "";
|
|
|
string sCGBJ = "";
|
|
|
string sXDBJ = "";
|
|
|
string sCDBJ = "";
|
|
|
foreach (var enumValue in ctnList)
|
|
|
{
|
|
|
if (enumValue.NAME.ToString().Trim() == "小柜")
|
|
|
{
|
|
|
sXG = enumValue.VALUE.ToString().Trim() + "0";
|
|
|
sXGBJ = enumValue.VALUE.ToString().Trim() + "2";
|
|
|
}
|
|
|
else if (enumValue.NAME.ToString().Trim() == "大柜")
|
|
|
{
|
|
|
sDG = enumValue.VALUE.ToString().Trim() + "0";
|
|
|
sDGBJ = enumValue.VALUE.ToString().Trim() + "2";
|
|
|
}
|
|
|
else if (enumValue.NAME.ToString().Trim() == "超高")
|
|
|
{
|
|
|
sCG = enumValue.VALUE.ToString().Trim() + "0";
|
|
|
sCGBJ = enumValue.VALUE.ToString().Trim() + "2";
|
|
|
}
|
|
|
else if (enumValue.NAME.ToString().Trim() == "小冻")
|
|
|
{
|
|
|
sXD = enumValue.VALUE.ToString().Trim() + "0";
|
|
|
sXDBJ = enumValue.VALUE.ToString().Trim() + "2";
|
|
|
}
|
|
|
else if (enumValue.NAME.ToString().Trim() == "超冻")
|
|
|
{
|
|
|
sCD = enumValue.VALUE.ToString().Trim() + "0";
|
|
|
sCDBJ = enumValue.VALUE.ToString().Trim() + "2";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取动态 费用列名
|
|
|
List<XiaLaKuangModel> feeList = MsCrmPriceCarrierDAL.GetFeeName();
|
|
|
string sFJF = "";
|
|
|
foreach (var enumValue in feeList)
|
|
|
{
|
|
|
if (enumValue.NAME.ToString().Trim() == "附加费")
|
|
|
{
|
|
|
sFJF = enumValue.VALUE.ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//
|
|
|
string sGID = "";
|
|
|
sError = "";
|
|
|
for(int i=0;i< table.Rows.Count;i++)
|
|
|
{
|
|
|
bool isAdd = false;
|
|
|
|
|
|
#region 获取是否有重复数据
|
|
|
string condition = "[LANE]='" + table.Rows[i]["航线"].ToString() + "' and [PODLOAD]='" + table.Rows[i]["装货港"].ToString() + "' and [PORTDISCHARGEID]='" + table.Rows[i]["卸货港"].ToString() + "' and [PORTDISCHARGE]='" + table.Rows[i]["卸货港中文"].ToString() + "' and [CARRIER]='" + table.Rows[i]["船公司"].ToString() + "' and [VIA]='" + table.Rows[i]["中转港"].ToString() + "' and [ETD]='" + table.Rows[i]["船期"].ToString() + "' and [TT]='" + table.Rows[i]["航程"].ToString() + "' and [EFFECTIVEDATE]='" + table.Rows[i]["开始日期"].ToString() + "' and [VALIDDATE]='" + table.Rows[i]["结束日期"].ToString() + "' and [COMMODITY]='" + table.Rows[i]["特殊商品"].ToString() + "'";
|
|
|
List<MsCrmPriceCarrier> dataList = MsCrmPriceCarrierDAL.GetDataList(condition,0,1000, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), null);
|
|
|
#endregion
|
|
|
|
|
|
if (dataList != null)//edit
|
|
|
{
|
|
|
if (dataList.Count > 0)
|
|
|
{
|
|
|
MsCrmPriceCarrier headRow = dataList[0];
|
|
|
if (!headRow.LOCKFLAG && !headRow.ISISSUE)//判断是否锁定或发布的数据,不是则覆盖数据
|
|
|
{
|
|
|
sGID = headRow.GID.ToString();
|
|
|
UpdateCount++; //更新条数
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iError++; //失败(更新)条数
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
else//add
|
|
|
{
|
|
|
isAdd = true;
|
|
|
}
|
|
|
}
|
|
|
else//add
|
|
|
{
|
|
|
isAdd = true;
|
|
|
}
|
|
|
if (isAdd)//add
|
|
|
{
|
|
|
MsCrmPriceCarrier headRow = new MsCrmPriceCarrier();
|
|
|
#region 默认值
|
|
|
headRow.LANE = table.Rows[i]["航线"].ToString();//航线
|
|
|
headRow.PODLOAD = table.Rows[i]["装货港"].ToString();//装货港
|
|
|
headRow.PORTDISCHARGEID = table.Rows[i]["卸货港"].ToString();//卸货港ID
|
|
|
headRow.PORTDISCHARGE = table.Rows[i]["卸货港中文"].ToString();//卸货港中文
|
|
|
headRow.CARRIER = table.Rows[i]["船公司"].ToString();//船公司
|
|
|
headRow.VIA = table.Rows[i]["中转港"].ToString();//中转港
|
|
|
headRow.ETD = table.Rows[i]["船期"].ToString();//开航日/船期
|
|
|
headRow.TT = table.Rows[i]["航程"].ToString();//航程
|
|
|
headRow.REMARK = table.Rows[i]["备注"].ToString();//备注
|
|
|
if (table.Rows[i]["开始日期"].ToString() != "")
|
|
|
{
|
|
|
headRow.EFFECTIVEDATE = DateTime.Parse(table.Rows[i]["开始日期"].ToString());//生效期/开始日期
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (sError.IndexOf("不能导入“开始日期”为空的数据!") < 0)
|
|
|
{
|
|
|
sError += "不能导入“开始日期”为空的数据!";
|
|
|
}
|
|
|
}
|
|
|
if (table.Rows[i]["结束日期"].ToString() != "")
|
|
|
{
|
|
|
headRow.VALIDDATE = DateTime.Parse(table.Rows[i]["结束日期"].ToString());//有效期/结束日期
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (sError.IndexOf("不能导入“结束日期”为空的数据!") < 0)
|
|
|
{
|
|
|
sError += "不能导入“结束日期”为空的数据!";
|
|
|
}
|
|
|
}
|
|
|
headRow.COMMODITY = table.Rows[i]["特殊商品"].ToString();//品名/特殊商品
|
|
|
|
|
|
headRow.LOCKFLAG = false;
|
|
|
headRow.ISISSUE = false;
|
|
|
headRow.INPUTBY = Convert.ToString(Session["USERID"]);//制单人GID
|
|
|
headRow.INPUTTIME = DateTime.Now;//创建时间
|
|
|
headRow.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//最后一次更改操作人GID
|
|
|
headRow.MODIFYTIME = DateTime.Now;//最后一次更改操作时间
|
|
|
headRow.GID = Guid.NewGuid().ToString();
|
|
|
sGID = headRow.GID.ToString();
|
|
|
headRow.DbOperationType = DbOperationType.DbotIns;
|
|
|
#endregion
|
|
|
var modb = new ModelObjectDB();
|
|
|
DBResult result = modb.Save(headRow);
|
|
|
if (!result.Success)
|
|
|
{
|
|
|
iError++; //失败(更新)条数
|
|
|
continue;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
InsertCount++; //新增条数
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var XGYJ = table.Rows[i]["小柜"].ToString();
|
|
|
if (XGYJ == "") XGYJ = "0";
|
|
|
var DGYJ = table.Rows[i]["大柜"].ToString();
|
|
|
if (DGYJ == "") DGYJ = "0";
|
|
|
var CGYJ = table.Rows[i]["超高"].ToString();
|
|
|
if (CGYJ == "") CGYJ = "0";
|
|
|
var XDYJ = table.Rows[i]["小冻"].ToString();
|
|
|
if (XDYJ == "") XDYJ = "0";
|
|
|
var CDYJ = table.Rows[i]["超冻"].ToString();
|
|
|
if (CDYJ == "") CDYJ = "0";
|
|
|
var XGYJBJ = table.Rows[i]["小柜报价"].ToString();
|
|
|
if (XGYJBJ == "") XGYJBJ = "0";
|
|
|
var DGYJBJ = table.Rows[i]["大柜报价"].ToString();
|
|
|
if (DGYJBJ == "") DGYJBJ = "0";
|
|
|
var CGYJBJ = table.Rows[i]["超高报价"].ToString();
|
|
|
if (CGYJBJ == "") CGYJBJ = "0";
|
|
|
var XDYJBJ = table.Rows[i]["小冻报价"].ToString();
|
|
|
if (XDYJBJ == "") XDYJBJ = "0";
|
|
|
var CDYJBJ = table.Rows[i]["超冻报价"].ToString();
|
|
|
if (CDYJBJ == "") CDYJBJ = "0";
|
|
|
|
|
|
|
|
|
#region 根据动态字段名,更新集装箱与费用信息
|
|
|
string sSQL = "update crm_price_carrier_2 set [" + sXG + "]='" + XGYJ + "',[" + sDG + "]='" + DGYJ + "',[" + sCG + "]='" + CGYJ + "',[" + sXD + "]='"
|
|
|
+ XDYJ + "',[" + sCD + "]='" + CDYJ + "',[" + sXGBJ + "]='" + XGYJBJ + "',[" + sDGBJ + "]='" + DGYJBJ + "',[" + sCGBJ + "]='" + CGYJBJ + "',[" + sXDBJ + "]='"
|
|
|
+ XDYJBJ + "',[" + sCDBJ + "]='" + CDYJBJ + "',[" + sFJF + "]='" + table.Rows[i]["附加费"].ToString() + "' where gid='" + sGID + "'";
|
|
|
// string sSQL = "update crm_price_carrier_2 set [" + sXG + "]='" + ds.Tables[0].Rows[i]["小柜"].ToString() + "',[" + sDG + "]='" + ds.Tables[0].Rows[i]["大柜"].ToString() + "',[" + sCG + "]='" + ds.Tables[0].Rows[i]["超高"].ToString() + "',[" + sFJF + "]='" + ds.Tables[0].Rows[i]["附加费"].ToString() + "' where gid='" + sGID + "'";
|
|
|
#endregion
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
|
|
|
if (!bl)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
if (System.IO.File.Exists(fileName))
|
|
|
{
|
|
|
System.IO.File.Delete(fileName);
|
|
|
}
|
|
|
|
|
|
if (sError.Trim() != "")
|
|
|
{
|
|
|
jsonRespose.Success = false;
|
|
|
jsonRespose.Message = "操作完成,共处理" + Convert.ToString(iheadList) + "条数据,其中新增" + Convert.ToString(InsertCount) + "条,覆盖" + Convert.ToString(UpdateCount) + "条,出错" + Convert.ToString(iError) + "条!错误原因:" + sError;
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
jsonRespose.Success = true;
|
|
|
jsonRespose.Message = "操作完成,共处理" + Convert.ToString(iheadList) + "条数据,其中新增" + Convert.ToString(InsertCount) + "条,覆盖" + Convert.ToString(UpdateCount) + "条,出错" + Convert.ToString(iError) + "条!";
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 保存
|
|
|
public ContentResult Save(string body)
|
|
|
{
|
|
|
var canlogin = BasicDataRefDAL.CheckLogin(Session);
|
|
|
if (!canlogin.Success) {
|
|
|
return (ContentResult)canlogin.Data;
|
|
|
}
|
|
|
|
|
|
DBResult result = new DBResult();
|
|
|
var errorstr = "";
|
|
|
var bodyList = JsonConvert.Deserialize<List<MsCrmPriceCarrier>>(body.Replace("T00:00:00", ""));
|
|
|
if (bodyList != null)
|
|
|
{
|
|
|
foreach (var enumValue in bodyList)
|
|
|
{
|
|
|
MsCrmPriceCarrier headRow = new MsCrmPriceCarrier();
|
|
|
headRow = enumValue;
|
|
|
|
|
|
#region 默认值
|
|
|
headRow.LOCKFLAG = false;
|
|
|
headRow.ISISSUE = false;
|
|
|
headRow.INPUTBY = Convert.ToString(Session["USERID"]);//制单人GID
|
|
|
headRow.INPUTTIME = DateTime.Now;//创建时间
|
|
|
headRow.MODIFIEDUSER = Convert.ToString(Session["USERID"]);//最后一次更改操作人GID
|
|
|
headRow.MODIFYTIME = DateTime.Now;//最后一次更改操作时间
|
|
|
#endregion
|
|
|
|
|
|
if (enumValue.GID.ToString().Trim() == "*")//"add"
|
|
|
{
|
|
|
headRow.GID = Guid.NewGuid().ToString();
|
|
|
headRow.DbOperationType = DbOperationType.DbotIns;
|
|
|
}
|
|
|
else//"edit"
|
|
|
{
|
|
|
headRow.GID = enumValue.GID.ToString().Trim();//唯一编码
|
|
|
headRow.DbOperationType = DbOperationType.DbotUpd;
|
|
|
headRow.ModelUIStatus = "E";
|
|
|
}
|
|
|
var modb = new ModelObjectDB();
|
|
|
result = modb.Save(headRow);
|
|
|
if (result.Message.ToString().IndexOf("插入重复键") > -1)
|
|
|
{
|
|
|
errorstr += "重复数据不再重复插入!";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if(errorstr.Trim()!="")
|
|
|
{
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = errorstr + "重复,不允许保存!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = "" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 删除
|
|
|
public ContentResult Delete(string gids)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
//
|
|
|
DBResult result = MsCrmPriceCarrierDAL.Delete(gids, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 批量修改
|
|
|
public ContentResult onAlterClick(string sEFFECTIVEDATE, string sVALIDDATE, string sYJJB, string sFee0, string sFee1, string sFee2, string sFee3, string sFee4, string VIA3,string VIA4, string gids,string psc,string psc_zh,string crr,string lane)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
string[] sfeeArr = { sFee0, sFee1, sFee2, sFee3, sFee4 };
|
|
|
DBResult result = MsCrmPriceCarrierDAL.onAlterClick(sEFFECTIVEDATE, sVALIDDATE, sYJJB,VIA3,VIA4, sfeeArr, gids, Convert.ToString(Session["USERID"]),psc, psc_zh,crr, lane);
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 复制
|
|
|
public ContentResult onCopyClick(string sEFFECTIVEDATE, string sVALIDDATE, string gids, string ISCOPYYJ)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
//
|
|
|
DBResult result = MsCrmPriceCarrierDAL.onCopyClick(sEFFECTIVEDATE, sVALIDDATE, gids,ISCOPYYJ,Convert.ToString(Session["USERID"]));
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 选择锁定
|
|
|
public ContentResult onLockflagClick(string gids)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
//
|
|
|
DBResult result = MsCrmPriceCarrierDAL.onLockflagClick(gids, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 取消选择锁定
|
|
|
public ContentResult onNotLockflagClick(string gids)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
//
|
|
|
DBResult result = MsCrmPriceCarrierDAL.onNotLockflagClick(gids, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 全部锁定
|
|
|
public ContentResult onAllLockflagClick()
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
//
|
|
|
DBResult result = MsCrmPriceCarrierDAL.onAllLockflagClick(Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 取消全部锁定
|
|
|
public ContentResult onNotAllLockflagClick()
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
//
|
|
|
DBResult result = MsCrmPriceCarrierDAL.onNotAllLockflagClick(Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 选择发布
|
|
|
public ContentResult onIsissueClick(string gids)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
//
|
|
|
DBResult result = MsCrmPriceCarrierDAL.onIsissueClick(gids, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 取消选择发布
|
|
|
public ContentResult onNotIsissueClick(string gids)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
//
|
|
|
DBResult result = MsCrmPriceCarrierDAL.onNotIsissueClick(gids, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 全部发布
|
|
|
public ContentResult onAllIsissueClick()
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
//
|
|
|
DBResult result = MsCrmPriceCarrierDAL.onAllIsissueClick(Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 取消全部发布
|
|
|
public ContentResult onNotAllIsissueClick()
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
//
|
|
|
DBResult result = MsCrmPriceCarrierDAL.onNotAllIsissueClick(Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 设置运价标识
|
|
|
public ContentResult onYunJiaBiaoShiClick(string gids, string sFIELDNAME, int iFIELDTYPE, string sFIELDCONTENT)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
//
|
|
|
DBResult result = MsCrmPriceCarrierDAL.onYunJiaBiaoShiClick(gids, sFIELDNAME, iFIELDTYPE, sFIELDCONTENT, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]));
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 查询运价标识
|
|
|
public ContentResult GetDataListBiaoShi(string condition, string condition2)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
//
|
|
|
var dataList = MsCrmPriceCarrierDAL.GetDataListBiaoShi(condition, condition2, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
var list = dataList;
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 查询修改次数
|
|
|
public ContentResult GetDataListXGCS(string condition)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
//
|
|
|
var dataList = MsCrmPriceCarrierDAL.GetDataListXGCS(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
var list = dataList;
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 取其他费用权限_循环列
|
|
|
public JsonResult GetFeeName()
|
|
|
{
|
|
|
var evList = MsCrmPriceCarrierDAL.GetFeeName();
|
|
|
if (evList.Count == 0)
|
|
|
{
|
|
|
return Json(new { success = false });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return Json(new { success = true, data = evList.ToList() });
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 取集装箱权限_循环列
|
|
|
public JsonResult GetCtn()
|
|
|
{
|
|
|
var evList = MsCrmPriceCarrierDAL.GetCtn();
|
|
|
if (evList.Count == 0)
|
|
|
{
|
|
|
return Json(new { success = false });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return Json(new { success = true, data = evList.ToList() });
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 取报价权限_循环列
|
|
|
public JsonResult GetBaoJia()
|
|
|
{
|
|
|
var evList = MsCrmPriceCarrierDAL.GetBaoJia();
|
|
|
if (evList.Count == 0)
|
|
|
{
|
|
|
return Json(new { success = false });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return Json(new { success = true, data = evList.ToList() });
|
|
|
}
|
|
|
}
|
|
|
public JsonResult GetBaoJiaChaXun()
|
|
|
{
|
|
|
var evList = MsCrmPriceCarrierDAL.GetBaoJiaChaXun();
|
|
|
if (evList.Count == 0)
|
|
|
{
|
|
|
return Json(new { success = false });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return Json(new { success = true, data = evList.ToList() });
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 启运港,国内港口_下拉框
|
|
|
public JsonResult GetPODLOADList()
|
|
|
{
|
|
|
var evList = MsCrmPriceCarrierDAL.GetPODLOADList();
|
|
|
if (evList.Count == 0)
|
|
|
{
|
|
|
return Json(new { success = true, data = new XiaLaKuangModel() });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return Json(new { success = true, data = evList.ToList() });
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 目的港,国外港口_下拉框
|
|
|
public JsonResult GetPORTDISCHARGEList(string CODENAME)
|
|
|
{
|
|
|
var evList = MsCrmPriceCarrierDAL.GetPORTDISCHARGEList(CODENAME);
|
|
|
if (evList.Count == 0)
|
|
|
{
|
|
|
return Json(new { success = true, data = new XiaLaKuangModel() });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var ss = Json(new { success = true, data = evList.ToList() });
|
|
|
return ss;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 中转港,国外港口_下拉框
|
|
|
public JsonResult GetVIAList()
|
|
|
{
|
|
|
var evList = MsCrmPriceCarrierDAL.GetVIAList();
|
|
|
if (evList.Count == 0)
|
|
|
{
|
|
|
return Json(new { success = true, data = new XiaLaKuangModel() });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var ss = Json(new { success = true, data = evList.ToList() });
|
|
|
return ss;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 船公司_下拉框
|
|
|
public JsonResult GetCARRIERList()
|
|
|
{
|
|
|
var evList = MsCrmPriceCarrierDAL.GetCARRIERList();
|
|
|
if (evList.Count == 0)
|
|
|
{
|
|
|
return Json(new { success = true, data = new XiaLaKuangModel() });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return Json(new { success = true, data = evList.ToList() });
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 航线_下拉框
|
|
|
public JsonResult GetLANEList()
|
|
|
{
|
|
|
var evList = MsCrmPriceCarrierDAL.GetLANEList();
|
|
|
if (evList.Count == 0)
|
|
|
{
|
|
|
return Json(new { success = true, data = new XiaLaKuangModel() });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return Json(new { success = true, data = evList.ToList() });
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
}
|
|
|
|