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 Microsoft.Practices.EnterpriseLibrary.Data;
//以下为调用文件操纵类使用
using DSWeb.Areas.CommMng.Models;
using DSWeb.Areas.CommMng.DAL;
using System.Text;
using System.Data;
using DSWeb.Areas.RptMng.Comm;
using DSWeb.SoftMng.Filter;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
using DSWeb.MvcShipping.DAL.MsOpRailwayDAL;
using DSWeb.MvcShipping.Models.MsOpRailway;
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 ContractDsIndex()
{
return View();
}
public ActionResult ContractDsEdit()
{
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();
}
public ActionResult OpIndex()
{
return View();
}
public ActionResult ClientRang()
{
return View();
}
public ActionResult ImgIndex()
{
return View();
}
///
/// 东胜自用的客户管理系统
///
///
public ActionResult DsIndex()
{
return View();
}
///
/// 东胜自用的客户管理系统
///
///
public ActionResult DsEdit()
{
return View();
}
public ActionResult HangXinCustIndex()
{
return View();
}
public ActionResult SaleIndex()
{
return View();
}
//[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetDataList ( int start, int limit, string condition, string sort )
{
var dataList = MsInfoClientDAL.GetDataList(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
int count = MsInfoClientDAL.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 };
}
//[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetDataListAll(string condition, string sort)
{
var dataList = MsInfoClientDAL.GetDataListAll(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/
//[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetData ( string handle, string condition )
{
MsClient head = null;
if (handle == "edit")
{
head = MsInfoClientDAL.GetData(condition);
}
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 InCustRange(string cust, string op,string seltype)
{
var bodyList = JsonConvert.Deserialize>(cust);
var result = MsInfoClientDAL.InsertClientRange(bodyList, op, seltype, Convert.ToString(Session["USERID"]));
var json = JsonConvert.Serialize(
new { Success = result.Success, Message = result.Message });
return new ContentResult() { Content = json };
}
public ContentResult DelCustRange(string cust, string op, string seltype)
{
var bodyList = JsonConvert.Deserialize>(cust);
var result = MsInfoClientDAL.DelClientRange(bodyList, op, seltype, Convert.ToString(Session["USERID"]));
var json = JsonConvert.Serialize(
new { Success = result.Success, Message = result.Message });
return new ContentResult() { Content = json };
}
public ContentResult Save ( string opstatus, string data, string data2, string body, string ACCDATEbody, string GDFYWHbody,string issale="0")
{
data = data.Replace("❥", "<");
var headData = JsonConvert.Deserialize(data.Replace("}", ",") + data2.Replace("{", ""));
var bodyList = JsonConvert.Deserialize>(body);
var bodyListDel = JsonConvert.Deserialize>("");
var ACCDATEbodyList = JsonConvert.Deserialize>(ACCDATEbody);
var ACCDATEbodyListDel = JsonConvert.Deserialize>("");
var GDFYWHbodyList = JsonConvert.Deserialize>(GDFYWHbody);
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 = "";
headData.SHORTNAME = headData.SHORTNAME.Trim();
headData.CODENAME = headData.CODENAME.Trim();
var ct = MsInfoClientDAL.GetRdCount("GID<>'" + headData.GID + "' AND SHORTNAME='" + headData.SHORTNAME.Replace("'","''") + "'");
if (ct != 0)
{
isPost = false;
errorstr = "客户简称重复";
}
ct = MsInfoClientDAL.GetRdCount("GID<>'" + headData.GID + "' AND DESCRIPTION='" + headData.DESCRIPTION.Replace("'", "''") + "'");
if (ct != 0)
{
isPost = false;
errorstr = "客户全称重复";
}
if (!string.IsNullOrEmpty(headData.LOGINNAME)) {
ct = MsInfoClientDAL.GetRdCount("GID<>'" + headData.GID + "' AND LOGINNAME='" + headData.LOGINNAME.Replace("'", "''") + "'");
if (ct != 0)
{
isPost = false;
errorstr = "登陆名重复";
}
}
if (headData.SHORTNAME.IndexOf("'") > 0) {
isPost = false;
errorstr = "简称含有'等特殊字符";
}
//if (headData.DESCRIPTION.IndexOf("'") > 0)
//{
// isPost = false;
// errorstr = "全称含有'等特殊字符";
//}
if (headData.CUSTNUM == "") {
headData.CUSTNUM= MsInfoClientDAL.GetMaxNum();
}
if (headData.BILLRISES1 == "")
headData.BILLRISES1 = headData.DESCRIPTION;
if (headData.RMBBILLRISES == "")
headData.RMBBILLRISES = headData.DESCRIPTION;
if (headData.USDBILLRISES == "")
headData.USDBILLRISES = headData.DESCRIPTION;
if (headData.TICHENG == "") headData.TICHENG = "0";
if (headData.FENCHENG == "") headData.FENCHENG = "0";
#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";
}
headData.MODIFIEDUSER = Convert.ToString(Session["USERID"]);
headData.MODIFIEDTIME = System.DateTime.Now.ToString();
var modb = new ModelObjectRepository();
var GID = headData.GID;
DBResult result = modb.Save(headData
, ModelObjectConvert.ToModelObjectList(bodyList)
, ModelObjectConvert.ToModelObjectList(bodyListDel)
, ModelObjectConvert.ToModelObjectList(ACCDATEbodyList)
, ModelObjectConvert.ToModelObjectList(ACCDATEbodyListDel)
);
if (result.Success) {
MsInfoClientDAL.SaveCustFee(headData, GDFYWHbodyList, Convert.ToString(Session["USERID"]));
BasicDataRefDAL.PubStore_SetNew("INFO_CLIENT");
if (headData.ISSTOP) {
T_ALL_DA T_ALL_DA = new T_ALL_DA();
var blUpSQL = " insert into sys_log(GID,NAME,LOGTYPE,LOGTIME,LOGCONTENT,CREATEUSER) values(NEWID(),'" + headData.SHORTNAME + "','停用客户','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + headData.SHORTNAME + '(' + headData.DESCRIPTION + ')' + "','" + Convert.ToString(Session["USERID"]) + "')";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
}
//DBResult result2 = MsInfoClientDAL.UpdateEmail(headData.LOGINNAME, headData.EMAIL);
var modCrmClientVisible =MsBaseInfoDAL.GetUserModuleEnable("modCrmClientVisible", Convert.ToString(Session["USERID"]));
if (issale!="1"&& !modCrmClientVisible)
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(data);
var isnotDelete = true;
isnotDelete = MsInfoClientDAL.ISCUSTUSE(headData.SHORTNAME);
if (!isnotDelete)
{
var modb = new ModelObjectDB();
DBResult result = modb.Delete(headData);
if (result.Success) {
T_ALL_DA T_ALL_DA = new T_ALL_DA();
var blUpSQL = " insert into sys_log(GID,NAME,LOGTYPE,LOGTIME,LOGCONTENT,CREATEUSER) values(NEWID(),'" + headData.SHORTNAME + "','删除客户','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + headData.SHORTNAME + '(' + headData.DESCRIPTION + ')' + "','" + Convert.ToString(Session["USERID"]) + "')";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
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 ISREPEAT(string cust,string codename,string draccid,string craccid)
{
var errorstr = "";
var isreapeat = false;
if (codename != "")
{
var ct = MsInfoClientDAL.GetRdCount(" SHORTNAME<>'" + cust + "' and CODENAME='" + codename + "'");
if (ct != 0)
{
isreapeat = true;
errorstr = "客户代码重复";
}
}
if (draccid != "")
{
var ct = MsInfoClientDAL.GetRdCount(" SHORTNAME<>'" + cust + "' and FARCODE='" + draccid + "'");
if (ct != 0)
{
isreapeat = true;
errorstr = errorstr+ " 财务应收账款代码重复 ";
}
}
if (craccid != "")
{
var ct = MsInfoClientDAL.GetRdCount(" SHORTNAME<>'" + cust + "' and FAPCODE='" + craccid + "'");
if (ct != 0)
{
isreapeat = true;
errorstr = " 财务应付账款代码重复 ";
}
}
if (!isreapeat)
{
var jsonRespose = new JsonResponse { Success = true, Message = "" };
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 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,Session["USERID"].ToString());
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, "", Session["USERID"].ToString());
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(data);
if (opstatus == "add")
{
headData.CREATEUSER = Session["USERID"].ToString();
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 + "'", Session["USERID"].ToString())
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteContact ( string data )
{
var headData = JsonConvert.Deserialize(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,Session["USERID"].ToString());
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,"", Session["USERID"].ToString());
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(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 + "'",Session["USERID"].ToString())
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveContractAll(string opstatus, string data,string body)
{
var headData = JsonConvert.Deserialize(data);
var bodyList = JsonConvert.Deserialize>(body);
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);
if(result.Success==true) {
result = MsInfoClientDAL.SaveAccDateDetail(headData, bodyList, Convert.ToString(Session["USERID"]));
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsInfoClientDAL.GetContractData("GID='" + GID + "'", Session["USERID"].ToString())
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteContract ( string data )
{
var headData = JsonConvert.Deserialize(data);
var isPost = true;
var ct = MsInfoClientDAL.GetFeeTemplateCount(" CONTRACTNO='" + headData.CONTRACTNO + "'");
if (ct != 0)
{
isPost = false;
}
if (!isPost)
{
var jsonRespose = new JsonResponse { Success =false, Message ="此合同存在费用方案,不允许删除!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
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(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(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(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 railwayCondition = " B.CUSTOMERNAME=(select shortname from info_client where gid= '" + headData.LINKGID + "') and SETOUTDATE 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 OpRailWayList = MsOpRailwayDAL.GetDataList(railwayCondition, 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.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.ToModelObjectList(OpAirnList);
result = modb.SaveHead(_L2);
foreach (var _op in OpRailWayList)
{
_op.DbOperationType = DbOperationType.DbotUpd;
_op.ModelUIStatus = "E";
var _dmb = MsInfoClientDAL.GetSTLDATE(_op.CUSTOMERNAME, "铁路运输", _op.SETOUTDATE, _op.SALE);
_op.STLNAME = _dmb.STLNAME;
if (_dmb.STLDATE != _op.SETOUTDATE)
{
_op.STLDATE = _dmb.STLDATE;
}
}
var _L3 = ModelObjectConvert.ToModelObjectList(OpRailWayList);
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 GetGDFYWHList(string sort, string condition)
{
var dataList = MsInfoClientDAL.GetGDFYWHList(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList });
return new ContentResult() { Content = json };
}
#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(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(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(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>(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);
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);
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 航天资料引入
[HttpPost]
public ContentResult ImportHangXinCust()
{
var jsonRespose = new JsonResponse { Success = false, Message = "" };
if (Request.Files.Count != 1)
{
var json = JsonConvert.Serialize(new { success = false, Message = "请选择上传的文件" });
return new ContentResult() { Content = json };
}
var file = Request.Files["file"];
if (file == null)
{
var json = JsonConvert.Serialize(new { success = false, Message = "上传文件发生未知错误,请重新上传" });
return new ContentResult() { Content = json };
}
var path = Server.MapPath("../../UploadFiles/Edi");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var size = file.ContentLength;
var name = Path.GetFileName(file.FileName);
var usercode = CookieConfig.GetCookie_UserCode(Request);
string filename = path + "\\" + usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
if (System.IO.File.Exists(filename))
{
System.IO.File.Delete(filename);
}
file.SaveAs(filename);
try
{
DBResult result = MsInfoClientDAL.CreateHangXinCust(filename);
// jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = result.Data };
var json = JsonConvert.Serialize(new { success = true, Message = result.Message, data = result.Data });
return new ContentResult() { Content = json };
//return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
catch (Exception)
{
var json = JsonConvert.Serialize(new { success = false, Message = "读取文件出错,请确认文件正确性" });
return new ContentResult() { Content = json };
}
}
public ContentResult GetHangXinCust(int start, int limit,string condition,string sort)
{
var strSql = new StringBuilder();
strSql.Append("SELECT GID,NO,CASE WHEN ISNULL(SHORTNAME,'')='' THEN (SELECT top 1 SHORTNAME FROM INFO_CLIENT WHERE [DESCRIPTION]=tmp_hangxincust.CUSTNAME) ELSE SHORTNAME END SHORTNAME,CUSTNAME,TAXNO,ADDRTEL,BANK ");
strSql.Append(", (SELECT top 1 GID FROM INFO_CLIENT WHERE SHORTNAME=tmp_hangxincust.SHORTNAME) CUSTGID ");
strSql.Append("FROM tmp_hangxincust ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where " + condition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" ORDER BY SORT");
}
var dbparams = new List();
var paramps_sSQL = new CustomDbParamter();
paramps_sSQL.ParameterName = "@sSQL";
paramps_sSQL.DbType = DbType.String;
paramps_sSQL.Direction = ParameterDirection.Input;
paramps_sSQL.Value = strSql.ToString();
dbparams.Add(paramps_sSQL);
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
var json = RptHelper.GetRptJsonResult(start, limit, dbRptResult, "Result_Set", true);
return new ContentResult() { Content = json };
}
public ContentResult SaveHangXinCust(string data)
{
var bodyList = JsonConvert.Deserialize>(data);
DBResult result = MsInfoClientDAL.SaveHangXinCust(bodyList, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult UpdateHangXinCust(string data)
{
var bodyList = JsonConvert.Deserialize>(data);
DBResult result = MsInfoClientDAL.UpdateHangXinCust(bodyList, 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 IC_Start ( string USERID, string data ) //提交审核
{
var dataList = JsonConvert.Deserialize>(data);
var _L = new List();
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>(data);
var _L = new List();
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>(data);
var _L = new List();
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 AuditCust(string data, string codename, string shortname) //提交审核
{
var headData = JsonConvert.Deserialize(data);
var ct = MsInfoClientDAL.GetRdCount("GID<>'" + headData.GID + "' AND SHORTNAME='" + shortname + "'");
if (ct != 0)
{
var jsonRespose2 = new JsonResponse
{
Success = false,
Message = "客户简称重复!不能审核通过!",
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
else MsInfoClientDAL.UpdateCust(headData.GID,shortname,codename);
var _L = new List();
var result = new DBResult();
if (headData.BLSTATUSREF == "提交审核")
{
_L.Add(headData);
}
var jsonRespose = new JsonResponse();
//var USERID=Convert.ToString(Session["USERID"]);
if (_L.Count > 0)
{
result = MsInfoClientDAL.IC_Audit(_L, Convert.ToString(Session["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>(data);
var _L = new List();
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
#region 往来单位图片列表
public ContentResult GetImgList(string condition, string sort = null)
{
var dataList = MsInfoClientDAL.GetImgList(condition, sort,Session["USERID"].ToString());
var list = new List>();
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 SaveImgList(string LINKGID,string ImgList) {
var modb = new ModelObjectRepository();
Database db = DatabaseFactory.CreateDatabase();
var result = new DBResult();
var basebody = new MsInfoClientImgmb();
basebody.GetTableField(db);
var BodyList = new List();
var DelBodyList = new List();
if (!string.IsNullOrEmpty(ImgList))
{
var savedl = JsonConvert.Deserialize>>(ImgList);
foreach (var sdl in savedl)
{
var body = new MsInfoClientImgmb();
basebody.Copy(body);
body.SetValue(sdl);
BodyList.Add(body);
}
}
foreach (var Item in BodyList) {
var billno = Item.GetBillNoValue().ToString();
if (string.IsNullOrEmpty(billno) )
{
Item.DbOperationType = DbOperationType.DbotIns;
Item.SetValue(Item.GetBillNoFieldName(), LINKGID);
Item.SetValue("CREATEUSER", Session["USERID"].ToString());
}
else {
Item.DbOperationType = DbOperationType.DbotUpd;
}
result = modb.Save(Item);
//如果 INDATABASE_OLD与原值不同 则进行处理
var INDATABASE_OLD = Item.GetValue("INDATABASE_OLD");
var INDATABASE = Item.GetValue("INDATABASE");
if (INDATABASE_OLD != INDATABASE)
{//如新值为True则写入数据库 否则删除
FileUrlModel fileinfo = new FileUrlModel();
fileinfo.TableName = "info_client_img";
fileinfo.KeyName = "GID";
fileinfo.KeyValue = Item.GetValue("GID");
fileinfo.ImgName = "IMG";
var filename = Item.GetValue("IMGURL");
if (INDATABASE == "true") {
BasicDataRefDAL.SaveFileIntoDB(fileinfo, filename);
}
if (INDATABASE == "false") {
BasicDataRefDAL.DelFileFromDB(fileinfo);
}
}
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = ""
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DelImgList(string Img) {
var head = new MsInfoClientImgmb();
Database db = DatabaseFactory.CreateDatabase();
head.SetValue(db, Img);
var modb = new ModelObjectDBBill();
DBResult result = modb.Delete(head);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
}
}