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.

1146 lines
46 KiB
C#

This file contains ambiguous Unicode characters!

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

using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.Models.MsInfoClient;
using DSWeb.MvcShipping.Models.MsInfoClientContact;
using DSWeb.MvcShipping.Models.MsInfoContract;
using DSWeb.MvcShipping.Models.MsInfoShipper;
using DSWeb.MvcShipping.Models.MsCompanysAccount;
using DSWeb.MvcShipping.DAL.MsInfoClient;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using System.Collections.Generic;
using HcUtility.Comm;
using HcUtility.Core;
using DSWeb.TruckMng.Helper.Repository;
using System.IO;
using DSWeb.EntityDA;
using DSWeb.MvcShipping.DAL.MsOpSeaeDAL;
using DSWeb.MvcShipping.DAL.MsOpAirnDAL;
using DSWeb.MvcShipping.Models.MsOpSeae;
using DSWeb.MvcShipping.Models.MsOpAirn;
using DSWeb.SoftMng.DAL.SoftSysTable;
using System.Drawing;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsInfoClientController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
//
// GET: /
public ActionResult Edit()
{
return View();
}
//
// GET
public ActionResult ContactIndex()
{
return View();
}
public ActionResult ContactEdit()
{
return View();
}
public ActionResult ContractIndex()
{
return View();
}
public ActionResult ContractEdit()
{
return View();
}
public ActionResult ShipperIndex()
{
return View();
}
public ActionResult ShipperEdit()
{
return View();
}
public ActionResult ClientView()
{
return View();
}
public ActionResult InfoShipperIndex()
{
return View();
}
public ActionResult InfoShipperEdit()
{
return View();
}
/// <summary>
/// 东胜自用的客户管理系统
/// </summary>
/// <returns></returns>
public ActionResult DsIndex()
{
return View();
}
/// <summary>
/// 东胜自用的客户管理系统
/// </summary>
/// <returns></returns>
public ActionResult DsEdit()
{
return View();
}
public ContentResult GetDataList(int start, int limit, string condition, string sort)
{
var dataList = MsInfoClientDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetDataListAll(string condition, string sort)
{
var dataList = MsInfoClientDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetDataListStr(string sort, string condition)
{
var dataListStr = MsInfoClientDAL.GetDataListStr(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
//
// GET/TruckMng/MsWlTyreAcc/GetData/
public ContentResult GetData(string handle, string condition)
{
MsClient head = null;
if (handle == "edit")
{
var list = MsInfoClientDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new MsClient();
head.OPNAME = Convert.ToString(Session["SHOWNAME"]);
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult Save(string opstatus, string data, string data2, string body, string ACCDATEbody)
{
data = data.Replace("❥", "<");
var headData = JsonConvert.Deserialize<MsClient>(data.Replace("}", ",") + data2.Replace("{", ""));
var bodyList = JsonConvert.Deserialize<List<MsClientAccount>>(body);
var bodyListDel = JsonConvert.Deserialize<List<MsClientAccount>>("");
var ACCDATEbodyList = JsonConvert.Deserialize<List<Info_Client_ACCDATEmb>>(ACCDATEbody);
var ACCDATEbodyListDel = JsonConvert.Deserialize<List<Info_Client_ACCDATEmb>>("");
if (!string.IsNullOrEmpty(ACCDATEbody))
{
if (ACCDATEbodyList.Count > 0)
{
foreach (var _b in ACCDATEbodyList)
{
_b.MODIFIEDUSER = Session["SHOWNAME"].ToString();
_b.MODIFIEDTIME = System.DateTime.Now.ToString();
if (_b.BGNDATE != "") { _b.BGNDATE = _b.BGNDATE.Replace("T", " ").Replace("08:00:00", "00:00:00"); }
if (_b.ENDDATE != "") { _b.ENDDATE = _b.ENDDATE.Replace("T", " ").Replace("08:00:00", "23:59:59"); }
}
}
}
var isPost = true;
var errorstr = "";
var ct = MsInfoClientDAL.GetRdCount("GID<>'" + headData.GID + "' AND SHORTNAME='" + headData.SHORTNAME + "'");
if (ct != 0)
{
isPost = false;
errorstr = "客户简称";
}
ct = MsInfoClientDAL.GetRdCount("GID<>'" + headData.GID + "' AND DESCRIPTION='" + headData.DESCRIPTION + "'");
if (ct != 0)
{
isPost = false;
errorstr = "客户全称";
}
if (headData.BILLRISES1 == "")
headData.BILLRISES1 = headData.DESCRIPTION;
if (headData.RMBBILLRISES == "")
headData.RMBBILLRISES = headData.DESCRIPTION;
if (headData.USDBILLRISES == "")
headData.USDBILLRISES = headData.DESCRIPTION;
#region 判断字段长度
if (isPost)
{
var seaefield = MsSoftSysTableDAL.GetDefTableDetailList("info_client");
foreach (var enumValue in seaefield)
{
if (enumValue.FIELDNAME == "CODENAME" && headData.CODENAME.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "客户代码超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "SHORTNAME" && headData.SHORTNAME.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "客户简称超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "DESCRIPTION" && headData.DESCRIPTION.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "客户全称超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "ENFULLNAME" && headData.ENFULLNAME.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "英文全称超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "ADDR" && headData.ADDR.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "地址超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "EMAIL" && headData.EMAIL.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "邮件地址超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "WEB" && headData.WEB.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "网址超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "TEL" && headData.TEL.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "TEL超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "FAX" && headData.FAX.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "FAX超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "CHIEF" && headData.CHIEF.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "负责人超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "OP" && headData.OP.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "操作字段超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "COUNTRY" && headData.COUNTRY.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "国家超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "PROVINCE" && headData.PROVINCE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "省超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "CITY" && headData.CITY.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "城市超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "BLCONTENT" && headData.BLCONTENT.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "提单信息超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "BILLRISES1" && headData.BILLRISES1.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "发票抬头超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "RMBBILLRISES" && headData.RMBBILLRISES.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "人民币支票抬头超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "USDBILLRISES" && headData.USDBILLRISES.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "美元支票抬头超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "REMARK" && headData.REMARK.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "备注超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "LOGINNAME" && headData.LOGINNAME.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "登陆名超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "LOGINPASSWORD" && headData.LOGINPASSWORD.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "登陆密码超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "QQ" && headData.QQ.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "QQ超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "FARCODE" && headData.FARCODE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "财务应收账款代码超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "FAPCODE" && headData.FAPCODE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "财务应付账款代码超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "REGISTRATIONNO" && headData.REGISTRATIONNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "企业备案号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "TAXNO" && headData.TAXNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "税号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "INSPECTIONNO" && headData.InspectionNo.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "商检备案号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "EDICODE" && headData.EDICODE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "EDI代码超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "EDICODE2" && headData.EDICODE2.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "EDI代码2超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "EDICODE3" && headData.EDICODE3.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "EDI代码3超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "ORGANIZATIONCODE" && headData.ORGANIZATIONCODE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "组织机构代码超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "ORDERNO" && headData.ORDERNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "财务序号超长,字段长度限制" + enumValue.FIELDLEN; }
}
}
#endregion
if (isPost)
{
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
headData.OPNAME = Convert.ToString(Session["SHOWNAME"]);
headData.CORPID = Convert.ToString(Session["COMPANYID"]);
headData.ModelUIStatus = "I";
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
headData.ModelUIStatus = "D";
}
var modb = new ModelObjectRepository();
var GID = headData.GID;
DBResult result = modb.Save(headData
, ModelObjectConvert<MsClientAccount>.ToModelObjectList(bodyList)
, ModelObjectConvert<MsClientAccount>.ToModelObjectList(bodyListDel)
, ModelObjectConvert<Info_Client_ACCDATEmb>.ToModelObjectList(ACCDATEbodyList)
, ModelObjectConvert<Info_Client_ACCDATEmb>.ToModelObjectList(ACCDATEbodyListDel)
);
//DBResult result2 = MsInfoClientDAL.UpdateEmail(headData.LOGINNAME, headData.EMAIL);
IC_Start(Session["USERID"].ToString(), "[" + data + "]");
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsInfoClientDAL.GetData("GID='" + GID + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = errorstr + "重复,不允许保存!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult Delete(string data)
{
var headData = JsonConvert.Deserialize<MsClient>(data);
var isnotDelete = true;
isnotDelete = MsInfoClientDAL.ISCUSTUSE(headData.SHORTNAME);
if (!isnotDelete)
{
var modb = new ModelObjectDB();
DBResult result = modb.Delete(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = "此客户已被使用,不允许删除此客户!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult ISUSE(string cust)
{
var isnotDelete = true;
isnotDelete = MsInfoClientDAL.ISCUSTUSE(cust);
if (!isnotDelete)
{
var jsonRespose = new JsonResponse { Success = true, Message = "" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = "此客户已被使用,不允许修改此客户简称!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult UpdateCustBl(string cust, string Blcontext)
{
var result = new DBResult();
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
string blUpSQL = " update info_client set BLCONTENT='" + Blcontext + "' where SHORTNAME='" + cust + "' ";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
string blUpSQL2 = " update info_shipper set shipperdetail='" + Blcontext + "' where SHORTNAME='" + cust + "' ";
bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL2);
result.Success = true;
result.Message = "更新成功!";
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
// Data = MsChFeeDAL.GetDataList(headData.BillNo, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 联系人
public ContentResult GetContactDataList(string condition, string sort)
{
var dataList = MsInfoClientDAL.GetContactDataList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetContactData(string handle, string condition)
{
MsClientContact head = null;
if (handle == "edit")
{
var list = MsInfoClientDAL.GetContactDataList(condition);
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new MsClientContact();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult SaveContact(string opstatus, string data)
{
var headData = JsonConvert.Deserialize<MsClientContact>(data);
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
var modb = new ModelObjectDB();
var GID = headData.GID;
DBResult result = modb.Save(headData);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsInfoClientDAL.GetContactData("GID='" + GID + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteContact(string data)
{
var headData = JsonConvert.Deserialize<MsClientContact>(data);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 合同
public ContentResult GetContractDataList(string condition, string sort)
{
var dataList = MsInfoClientDAL.GetContractDataList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetContractData(string handle, string condition)
{
MsInfoContract head = null;
if (handle == "edit")
{
var list = MsInfoClientDAL.GetContractDataList(condition);
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new MsInfoContract();
head.CREATEUSER = Convert.ToString(Session["USERID"]);
head.CREATEUSERREF = Convert.ToString(Session["SHOWNAME"]);
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult SaveContract(string opstatus, string data)
{
var headData = JsonConvert.Deserialize<MsInfoContract>(data);
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
if (headData.SIGNINGDATE == "") headData.SIGNINGDATE = null;
if (headData.STARTDATE == "") headData.STARTDATE = null;
if (headData.CANCELDATE == "") headData.CANCELDATE = null;
var modb = new ModelObjectDB();
var GID = headData.GID;
DBResult result = modb.Save(headData);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsInfoClientDAL.GetContractData("GID='" + GID + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteContract(string data)
{
var headData = JsonConvert.Deserialize<MsInfoContract>(data);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 银行
public ContentResult GetBankList(string condition, string isedit, string sort)
{
var dataList = MsInfoClientDAL.GetBankList(condition, isedit, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult DeleteBank(string data)
{
var headData = JsonConvert.Deserialize<MsClientAccount>(data);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 账期
public ContentResult GetACCDATEList(string sort, string condition)
{
var dataList = MsInfoClientDAL.GetACCDATEList(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList });
return new ContentResult() { Content = json };
}
public ContentResult DeleteACCDATE(string data)
{
var headData = JsonConvert.Deserialize<Info_Client_ACCDATEmb>(data);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SetACCDATE(string data)
{
var headData = JsonConvert.Deserialize<Info_Client_ACCDATEmb>(data);
headData.BGNDATE = headData.BGNDATE.Replace("T", " ").Replace("08:00:00", "00:00:00");
headData.ENDDATE = headData.ENDDATE.Replace("T", " ").Replace("08:00:00", "23:59:59");
var condition = " CUSTOMERNAME=(select shortname from info_client where gid= '" + headData.LINKGID + "') and ETD between Convert(datetime,'" + headData.BGNDATE + "') and convert(datetime,'" + headData.ENDDATE + "') ";
if (headData.SALE != "")
{
condition = condition + " and SALE='" + headData.SALE + "' ";
}
else
{
//排除掉有销售员账期的业务
var condition2 = " LINKGID='" + headData.LINKGID + "' and (bgndate between convert(datetime,'" + headData.BGNDATE + "') and convert(datetime,'" + headData.ENDDATE + "') or enddate between convert(datetime,'" + headData.BGNDATE + "') and convert(datetime,'" + headData.ENDDATE + "')) and isnull(sale,'')<>'' and sale<>'" + headData.SALE + "' ";
var SaleAccDateList = MsInfoClientDAL.GetACCDATEList(condition2);
if (SaleAccDateList.Count > 0)
{
foreach (var _sa in SaleAccDateList)
{
condition = condition + " and not (customername=(select shortname from info_client where gid='" + _sa.LINKGID + "') and sale='" + _sa.SALE + "' and etd between convert(datetime,'" + headData.BGNDATE + "') and convert(datetime,'" + headData.ENDDATE + "') ";
}
}
}
var AirnCondition = " B.CUSTOMERNAME=(select shortname from info_client where gid= '" + headData.LINKGID + "') and ETD between Convert(datetime,'" + headData.BGNDATE + "') and convert(datetime,'" + headData.ENDDATE + "') ";
var OpSeaeList = MsOpSeaeDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), "", "");
var OpAirnList = MsOpAirnDAL.GetDataList(AirnCondition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), "", "");
var result = new DBResult();
foreach (var _op in OpSeaeList)
{
_op.DbOperationType = DbOperationType.DbotUpd;
_op.ModelUIStatus = "E";
var _dmb = MsInfoClientDAL.GetSTLDATE(_op.CUSTOMERNAME, "海运出口", _op.ETD, _op.SALE);
_op.STLNAME = _dmb.STLNAME;
if (_dmb.STLDATE != _op.ETD)
{
_op.STLDATE = _dmb.STLDATE;
}
}
var _L = ModelObjectConvert<MsOpSeae>.ToModelObjectList(OpSeaeList);
var modb = new ModelObjectRepository();
result = modb.SaveHead(_L);
foreach (var _op in OpAirnList)
{
_op.DbOperationType = DbOperationType.DbotUpd;
_op.ModelUIStatus = "E";
var _dmb = MsInfoClientDAL.GetSTLDATE(_op.CUSTOMERNAME, "国内空运", _op.ETD, _op.SALE);
_op.STLNAME = _dmb.STLNAME;
if (_dmb.STLDATE != _op.ETD)
{
_op.STLDATE = _dmb.STLDATE;
}
}
var _L2 = ModelObjectConvert<MsOpAirn>.ToModelObjectList(OpAirnList);
result = modb.SaveHead(_L2);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 收发通信息
public ContentResult GetShipperDataList(int start, int limit, string condition)
{
var dataList = MsInfoClientDAL.GetShipperDataList(condition);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetShipperData(string handle, string condition)
{
MsInfoShipper head = null;
if (handle == "edit")
{
var list = MsInfoClientDAL.GetShipperDataList(condition);
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new MsInfoShipper();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult SaveShipper(string opstatus, string data)
{
var headData = JsonConvert.Deserialize<MsInfoShipper>(data);
var errorstr = "";
if (headData.COUNTRY.Length > 2) { errorstr = "国家代码不能超过2位"; }
//headData.CODENAME = codename;
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
if (errorstr == "")
{
var modb = new ModelObjectDB();
var GID = headData.SHIPPERID;
DBResult result = modb.Save(headData);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsInfoClientDAL.GetShipperData("SHIPPERID='" + GID + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse
{
Success = false,
Message = errorstr
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult DeleteShipper(string data)
{
var headData = JsonConvert.Deserialize<MsInfoShipper>(data);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
public ContentResult GetDeptList(string condition, string sort)
{
var dataList = MsInfoClientDAL.GetDeptList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
//
// GET/TruckMng/MsWlTyreAcc/GetData/
public ContentResult DeleteBillType(string data)
{
var headData = JsonConvert.Deserialize<MsClientContact>(data);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveBillTypeDetail(string gid, string body)
{
var bodyList = JsonConvert.Deserialize<List<MsClientContact>>(body);
DBResult result = MsInfoClientDAL.SaveContactDetail(gid, bodyList, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 参照部分
#endregion
#region
[HttpPost]
public ContentResult UploadFile()
{
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["LoadImage"];
var ContactGID = Request.Form["ContactGID"];
var SHOWNAME = Request.Form["SHOWNAME"];
var OLDURL = Request.Form["OLDURL"];
if (OLDURL.Trim() != "")
{
var oldpath = Server.MapPath(OLDURL);
if (System.IO.File.Exists(oldpath))
{
/*
FileInfo fi = new FileInfo(OLDURL);
if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
fi.Attributes = FileAttributes.Normal;*/
System.IO.File.Delete(oldpath);
}
}
var Contact = MsInfoClientDAL.GetData("GID=(select linkid from info_client_contact where gid='" + ContactGID + "')"
);
var _filename = Contact.SHORTNAME + "_" + SHOWNAME;
if (file == null)
{
jsonRespose.Success = false;
jsonRespose.Message = "上传文件发生未知错误,请重新上传";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var path = Server.MapPath("../../UploadFiles/InfoClient");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var size = file.ContentLength;
var name = Path.GetFileName(file.FileName);
byte[] buffer = new byte[size];
file.InputStream.Read(buffer, 0, buffer.Length);
//处理漏洞:检测是否真的图片
try
{
MemoryStream ms = new MemoryStream(buffer);
var img = Image.FromStream(ms);
ms.Close();
}
catch
{
//有异常,图片有问题
jsonRespose.Success = false;
jsonRespose.Message = "非图片文件";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var usercode = CookieConfig.GetCookie_UserCode(Request);
string filename = path + "\\" + _filename + "_" + name;
if (System.IO.File.Exists(filename))
{
System.IO.File.Delete(filename);
}
//file.SaveAs(filename);
System.IO.File.WriteAllBytes(filename, buffer);
if (!System.IO.File.Exists(filename))
{
jsonRespose.Success = false;
jsonRespose.Message = "上传文件发生未知错误,请重新上传";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
try
{
var message = string.Empty;
var isSucess = MsInfoClientDAL.UpdateFileData(Request, filename, "../../UploadFiles/InfoClient/" + _filename + "_" + name, ContactGID, out message);
if (!isSucess)
{
jsonRespose.Success = false;
jsonRespose.Message = message;
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var json = JsonConvert.Serialize(new { success = true, Message = "上传成功!", data = filename });
return new ContentResult() { Content = json };
}
catch (Exception)
{
jsonRespose.Success = false;
jsonRespose.Message = "上传文件出错,请确认文件正确性";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult DeleteUploadFile(string data)
{
int iResult = 0;
var bodyList = data;
var result = new DBResult();
if (bodyList != "" || bodyList != null)
{
iResult = MsInfoClientDAL.DeleteUploadFile(bodyList);
}
if (iResult == 1)
{
result.Success = true;
result.Message = "删除成功!";
}
else if (iResult == 0)
{
result.Success = false;
result.Message = "出现错误,未删除!";
}
else if (iResult == -1)
{
result.Success = false;
result.Message = "有异常,删除失败!";
}
else if (iResult == -2)
{
result.Success = false;
result.Message = "删除异常,事务已回滚成功!";
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
// Data = MsChFeeDAL.GetDataList(headData.BillNo, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
public ContentResult GetClientGroupList(string condition)
{
var dataList = MsInfoClientDAL.GetClientGroupList(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
#region 往来单位审批
public ContentResult IC_Start(string USERID, string data) //提交审核
{
var dataList = JsonConvert.Deserialize<List<MsClient>>(data);
var _L = new List<MsClient>();
var result = new DBResult();
foreach (var _p in dataList)
{
if (_p.BLSTATUSREF == "录入状态" || _p.BLSTATUSREF == "驳回提交" || _p.BLSTATUSREF == "" || _p.BLSTATUSREF == null)
{
_L.Add(_p);
}
else
{
}
}
var jsonRespose = new JsonResponse();
//var USERID=Convert.ToString(Session["USERID"]);
if (_L.Count > 0)
{
result = MsInfoClientDAL.IC_Start(_L, USERID);
jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
}
else
{
result.Success = false;
result.Message = "没有可以提交的提单";
jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = null
};
}
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult IC_Back(string USERID, string data) //申请签入_撤回
{
var dataList = JsonConvert.Deserialize<List<MsClient>>(data);
var _L = new List<MsClient>();
var result = new DBResult();
foreach (var _p in dataList)
{
if (_p.BLSTATUSREF != "提交审核")
{
}
else
{
_L.Add(_p);
}
}
var jsonRespose = new JsonResponse();
//var USERID=Convert.ToString(Session["USERID"]);
if (_L.Count > 0)
{
result = MsInfoClientDAL.IC_back(_L, USERID);
jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
}
else
{
result.Success = false;
result.Message = "没有可以撤回的往来单位";
jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = null
};
}
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult IC_AuditBack(string USERID, string data) //申请签入_驳回
{
var dataList = JsonConvert.Deserialize<List<MsClient>>(data);
var _L = new List<MsClient>();
var result = new DBResult();
foreach (var _p in dataList)
{
if (_p.BLSTATUSREF == "审核通过" || _p.BLSTATUSREF == "提交审核")
{
_L.Add(_p);
}
else
{
//_L.Add(_p);
}
}
var jsonRespose = new JsonResponse();
//var USERID=Convert.ToString(Session["USERID"]);
if (_L.Count > 0)
{
result = MsInfoClientDAL.IC_Auditback(_L, USERID);
jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
}
else
{
result.Success = false;
result.Message = "没有可以撤回的提单";
jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = null
};
}
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult IC_Audit(string USERID, string data) //申请签入_准许签入
{
var dataList = JsonConvert.Deserialize<List<MsClient>>(data);
var _L = new List<MsClient>();
var result = new DBResult();
foreach (var _p in dataList)
{
if (_p.BLSTATUSREF != "提交审核")
{
}
else
{
_L.Add(_p);
}
}
var jsonRespose = new JsonResponse();
//var USERID=Convert.ToString(Session["USERID"]);
if (_L.Count > 0)
{
result = MsInfoClientDAL.IC_Audit(_L, USERID);
jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
}
else
{
result.Success = false;
result.Message = "没有可以提交的提单";
jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = null
};
}
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
}
}