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.

386 lines
15 KiB
C#

using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.Helper;
using HcUtility.Comm;
using HcUtility.Core;
using DSWeb.Areas.MvcShipping.Models.MsOpSeaeTD;
using DSWeb.MvcShipping.DAL.MsOpSeaeTD;
using System.Collections.Generic;
using DSWeb.Areas.MvcShipping.DAL.MsOpSeaeTDSFTTemplate;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsOpSeaeTDController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
public ActionResult Xj()
{
return View();
}
public ActionResult test()
{
return View();
}
public ActionResult BJReciveIndex()
{
return View();
}
public ActionResult test2()
{
return View();
}
public ContentResult Save(string opstatus, string data,string data2)
{
string userid = Convert.ToString(Session["USERID"]);
var headData = JsonConvert.Deserialize<MsOpSeaeTDModel>(data);
List<MsOpSeaeTDFee> feeData = JsonConvert.Deserialize<List<MsOpSeaeTDFee>>(data2);
headData.ETD = headData.ETD == "" ? null : headData.ETD;
headData.JieGangShiJian = headData.JieGangShiJian == "" ? null : headData.JieGangShiJian;
headData.JieDanShiJian = headData.JieDanShiJian == "" ? null : headData.JieDanShiJian;
headData.YOUXIAOQI = headData.YOUXIAOQI == "" ? null : headData.YOUXIAOQI;
if (opstatus == "a")
{
headData.INPUTBY = MsOpSeaeTDDAL.GetShowNameWithUserid(userid);
headData.INPUTBYID = userid;
headData.XJNO = MsOpSeaeTDDAL.CreateXJNO(userid);
headData.INPUTDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
headData.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
headData.DbOperationType = DbOperationType.DbotIns;
}
else if (opstatus == "e")
{
headData.INPUTBY = MsOpSeaeTDDAL.GetShowNameWithUserid(userid);
headData.INPUTBYID = userid;
headData.DbOperationType = DbOperationType.DbotUpd;
}
else if (opstatus=="copy")
{
headData.INPUTBY = MsOpSeaeTDDAL.GetShowNameWithUserid(userid);
headData.INPUTBYID = userid;
headData.XJNO = MsOpSeaeTDDAL.CreateXJNO(userid);
headData.INPUTDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
headData.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
headData.DbOperationType = DbOperationType.DbotIns;
}
var modb = new ModelObjectDB();
DBResult result = modb.Save(headData);
foreach (var item in feeData)
{
if (item.GID=="*")
{
item.GID = Guid.NewGuid().ToString();
item.DbOperationType = DbOperationType.DbotIns;
}
item.TID = headData.GID;
DBResult rst = modb.Save(item);
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = null
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetDataList(string condition, int currPage, int limit, string sort)
{
string userid = Convert.ToString(Session["USERID"]);
int start = (currPage - 1) * limit + 1;
int totalCount = 0;
var dataList = MsOpSeaeTDDAL.GetDataList(condition, userid, start, limit, out totalCount);
//分页信息
var pager = MsOpSeaeTDDAL.GetPagerHTML(totalCount, currPage, limit);
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = dataList, pager = pager });
return new ContentResult() { Content = json };
}
public ContentResult GetData(string handle, string condition)
{
string userid = Convert.ToString(Session["USERID"]);
if (userid == "" || userid == null)
{
var jsonRespose = new JsonResponse { Success = false, Message = "登陆状态失效,请重新登陆进行操作!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
string INPUTBY = Convert.ToString(Session["SHOWNAME"]);
MsOpSeaeTDModel head = null;
if (handle == "e")
{
head = MsOpSeaeTDDAL.GetData(condition, userid);
}
if (handle == "copy")
{
head = MsOpSeaeTDDAL.GetData(condition, userid);
head.GID = Guid.NewGuid().ToString();
head.INPUTBY = INPUTBY;
head.INPUTBYID = userid;
head.XJNO = "";
head.INPUTDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
head.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
if (handle == "addFen")
{
}
if (handle == "a")
{
head = new MsOpSeaeTDModel();
head.GID = Guid.NewGuid().ToString();
head.PORTLOAD = "QINGDAO,CHINA";
head.INPUTDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
head.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
head.PLACEDELIVERY = "QINGDAO,CHINA";
head.TiDanFenShu = "THREE";
head.YunShuTiaoKuan = "CY-CY";
head.FuFeiFangShi = "191A7500-680D-42FC-8712-74D9C7967BE8";//FREIGHT PREPAID
head.GP20 = 0;
head.GP40 = 0;
head.HC40 = 0;
head.MARKS = "N/M";
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
//下拉框
public ContentResult GetSelDataWithName(string name, string condition = "")
{
string userid = Convert.ToString(Session["USERID"]);
var dataList = MsOpSeaeTDDAL.GetSelDataWithName(name, userid, condition);
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = dataList });
return new ContentResult() { Content = json };
}
public ContentResult GetData_XJ(string tid)
{
string userid = Convert.ToString(Session["USERID"]);
string condition = "t.tid = '" + tid + "'";
if (userid == "" || userid == null)
{
var jsonRespose = new JsonResponse { Success = false, Message = "登陆状态失效,请重新登陆进行操作!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
string INPUTBY = Convert.ToString(Session["SHOWNAME"]);
MsOpSeaeTDXJModel head = MsOpSeaeTDDAL.GetData_XJ(condition, userid);
List<MsOpSeaeTDXJHDModel> bodyList =null;
if (head==null)
{
head = new MsOpSeaeTDXJModel();
head.GID = "*";
}
else
{
bodyList = MsOpSeaeTDDAL.GetDataList_XJ_HD("t.xjid = '"+head.GID+"'",userid);
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data1 = head,data2=bodyList });
return new ContentResult() { Content = json };
}
public ContentResult SendXJ(string data1, string data2)
{
var headData = JsonConvert.Deserialize<MsOpSeaeTDXJModel>(data1);
headData.YOUXIAOQI = headData.YOUXIAOQI == "" ? null : headData.YOUXIAOQI;
headData.ETD = headData.ETD == "" ? null : headData.ETD;
List<MsOpSeaeTDXJHDModel> hdData = JsonConvert.Deserialize<List<MsOpSeaeTDXJHDModel>>(data2);
headData.SENDDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
if (headData.GID=="*")
{
headData.DbOperationType = DbOperationType.DbotIns;
headData.GID = Guid.NewGuid().ToString();
}
else if(headData.GID!="*")
{
headData.DbOperationType = DbOperationType.DbotUpd;
}
var modb = new ModelObjectDB();
DBResult result = modb.Save(headData);
if (result.Success)
{
result = MsOpSeaeTDDAL.SaveTDXJDetail(headData,hdData);
if (result.Success)
{
MsOpSeaeTDDAL.InsertHDBJ(headData, hdData);
MsOpSeaeTDDAL.SendXJMail(headData,hdData);
//MsOpSeaeTDDAL.UpdateBSStatus(headData.GID, 2);
}
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = null
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
//获取报价列表
public ContentResult GetBJList(string condition, int currPage, int limit, string sort)
{
string userid = Convert.ToString(Session["USERID"]);
int start = (currPage - 1) * limit + 1;
int totalCount = 0;
var dataList = MsOpSeaeTDDAL.GetBJList(condition, userid, start, limit, out totalCount);
//分页信息
var pager = MsOpSeaeTDDAL.GetPagerHTML(totalCount, currPage, limit);
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = dataList, pager = pager });
return new ContentResult() { Content = json };
}
//获取费用列表
public ContentResult GetFeeList(string condition, int currPage, int limit, string sort,string tid)
{
string userid = Convert.ToString(Session["USERID"]);
int start = (currPage - 1) * limit + 1;
int totalCount = 0;
List<MsOpSeaeTDFee> dataList = MsOpSeaeTDDAL.GetFeeList(condition, userid, 1, 100, out totalCount);
//分页信息
if (dataList.Count==0)
{
MsOpSeaeTDFee f = new MsOpSeaeTDFee();
f.GID = "*";
f.TID = tid;
f.FNAME = "海运费";
f.FBIBIE = "USD";
f.FBIAOZHUN = "票";
f.FDANJIA = "0";
f.FSHULIANG = "0";
f.FJINE = "0";
f.FHUILV = "1";
MsOpSeaeTDFee f2 = new MsOpSeaeTDFee();
f2.GID = "*";
f2.TID = tid;
f2.FNAME = "箱使费";
f2.FBIBIE = "RMB";
f2.FBIAOZHUN = "天";
f2.FDANJIA = "0";
f2.FSHULIANG = "0";
f2.FJINE = "0";
f2.FHUILV = "1";
dataList.Add(f);
dataList.Add(f2);
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = dataList });
return new ContentResult() { Content = json };
}
//费用中标
public ContentResult ApplyFee(string gid,string tid,string op)
{
string userid = Convert.ToString(Session["USERID"]);
string msg = "";
bool rst = MsOpSeaeTDDAL.ApplyFee(gid, userid,tid,op,out msg);
var json = JsonConvert.Serialize(
new { Success = rst, Message = msg, data = "" });
return new ContentResult() { Content = json };
}
//费用删除
public ContentResult DelFee(string gid)
{
string userid = Convert.ToString(Session["USERID"]);
DBResult rst = MsOpSeaeTDDAL.DelFee(userid,gid);
var json = JsonConvert.Serialize(
new { Success = rst.Success, Message = rst.Message, data = "" });
return new ContentResult() { Content = json };
}
//费用删除
public ContentResult DelTD(string gids)
{
string userid = Convert.ToString(Session["USERID"]);
DBResult rst = MsOpSeaeTDDAL.DelTD(userid, gids);
var json = JsonConvert.Serialize(
new { Success = rst.Success, Message = rst.Message, data = "" });
return new ContentResult() { Content = json };
}
//保存收发通模板
public ContentResult SaveSFT(string name,string text,string type,string optype)
{
string userid = Convert.ToString(Session["USERID"]);
bool has = MsOpSeaeTDSFTTemplateDAL.GetIsExist(name, userid);
if (has)
{
var json = JsonConvert.Serialize(new { Success = false, Message = "已存在此模板名!", Data ="" });
return new ContentResult() { Content = json };
}
else
{
DBResult rst = MsOpSeaeTDDAL.SaveSFT(name, text, type, userid);
var json = JsonConvert.Serialize( new { Success = rst.Success, Message = rst.Message, data = "" });
return new ContentResult() { Content = json };
}
}
//获取收发通模板
public ContentResult GetSFTWithGID(string gid)
{
string userid = Convert.ToString(Session["USERID"]);
MsOpSeaeTMB mb = MsOpSeaeTDDAL.GetMBWithGID(gid,userid);
var json = JsonConvert.Serialize(
new { Success = mb.GID==null?false:true, Message = "", data = mb });
return new ContentResult() { Content = json };
}
//获取收发通模板
public ContentResult GetBJDetailsList(string gid)
{
string userid = Convert.ToString(Session["USERID"]);
List<MsOpSeaeHDBJFFee> dataList = MsOpSeaeTDDAL.GetBJDetailsList(gid, userid);
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = dataList });
return new ContentResult() { Content = json };
}
//根据供应商关系分组获取货代及联系人列表
public ContentResult GetHDListWithTCustID(string gid)
{
List<MsOpSeaeTDXJHDModel> bodyList = null;
bodyList = MsOpSeaeTDDAL.GetHDListWithTCustID( gid);
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = bodyList });
return new ContentResult() { Content = json };
}
}
}