You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/MvcShipping/Controllers/MsChFeeController.cs

1846 lines
80 KiB
C#

2 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DSWeb.MvcShipping.DAL.MsChFeeDAL;
using DSWeb.MvcShipping.Models.MsChFee;
using DSWeb.MvcShipping.Models.MsOpAmend;
using DSWeb.MvcShipping.Helper;
using HcUtility.Comm;
using HcUtility.Core;
using DSWeb.TruckMng.Comm.Cookie;
using DSWeb.TruckMng.Helper.Repository;
using DSWeb.EntityDA;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
using DSWeb.MvcShipping.DAL.ChMonthCloseDAL;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
using System.IO;
using System.Data.OleDb;
using System.Data;
using System.Data.Odbc;
using DSWeb.TruckMng.DAL.MsOpTruckBulkDAL;
using System.Web.Configuration;
using DSWeb.Areas.Account.Models.MsOpBill;
using DSWeb.MvcShipping.DAL.Chfee_AuditDAL;
using DSWeb.Areas.MvcShipping.DAL;
using DSWeb.MvcShipping.Models.MsOpBill;
using MsOpBill = DSWeb.Areas.Account.Models.MsOpBill.MsOpBill;
using DSWeb.MvcShipping.DAL.MsOpSeaeDAL;
using DSWeb.Areas.Account.Models.BSNOLB;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsChFeeController : Controller
{
//
// GET: /MvcShipping/MsChFee/GetDataList
public ActionResult TemplateAddIndex()
{
return View();
}
public ActionResult YJFeeEditIndex()
{
return View();
}
public ActionResult HistryIndex()
{
return View();
}
public ActionResult QuotationList()
{
return View();
}
public ActionResult MsFeeSortEdit()
{
return View();
}
/*
public ContentResult GetDataList(string billno, int type, string optype)
{
var dataList = MsChFeeDAL.GetDataList("BsNo='" + billno + "' and FeeType=" + type,type,optype, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}*/
public ContentResult GetDataList(string billno, int type, string optype, string condition, string SaleFee="")
{
var fieldcomm = "";
if (condition != null && condition.Trim() != "")
{
var dataList = MsChFeeDAL.GetDataList(condition, type, optype, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
else
{
var dataList = MsChFeeDAL.GetDataList("BsNo='" + billno + "' and FeeType=" + type + fieldcomm, type, optype, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var YJFADDTOHYFOP = MsSysParamSetDAL.GetData("PARAMNAME='YJFADDTOHYFOP'");
if (type == 2 && (SaleFee=="1"|| YJFADDTOHYFOP.PARAMVALUE == "1"))
{
if (YJFADDTOHYFOP.PARAMVALUE == "1" && SaleFee != "1")
{
var YJFEENAME = MsSysParamSetDAL.GetData("PARAMNAME='YJFEENAME'");
dataList = MsChFeeDAL.SetYjData(dataList, YJFEENAME.PARAMVALUE);
}
else
{
var YJFADDTOHYF = MsSysParamSetDAL.GetData("PARAMNAME='YJFADDTOHYF'");
if (YJFADDTOHYF.PARAMVALUE == "1")
{
var YJFEENAME = MsSysParamSetDAL.GetData("PARAMNAME='YJFEENAME'");
dataList = MsChFeeDAL.SetYjData(dataList, YJFEENAME.PARAMVALUE);
}
}
}
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
}
public ContentResult GetDataListStr(string billno, int type, string optype, string condition, string SaleFee = "")
{
var fieldcomm = "";
if (condition != null && condition.Trim() != "")
{
var dataListStr = MsChFeeDAL.GetDataListStr(condition, type, optype, 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 };
}
else
{
var dataListStr = MsChFeeDAL.GetDataListStr("BsNo='" + billno + "' and FeeType=" + type + fieldcomm, type, optype, 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 };
}
}
public ContentResult GetRangDAStr(int type, string optype)
{
var rangstr = MsChFeeDAL.GetFeeRangeSqlStr(type, optype, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
//var isopen = MsBaseInfoDAL.GetUserModuleEnable("modFeenotopen", Convert.ToString(Session["USERID"]));
// var isopenstr = "";
// if (isopen == false)
// {
// isopenstr = " ( ENTEROPERATOR='" + Convert.ToString(Session["USERID"]) + "' OR ( ENTEROPERATOR<>'" + Convert.ToString(Session["USERID"]) + "' AND (ISOPEN=0 OR ISOPEN IS NULL))) ";
// if (!string.IsNullOrEmpty(rangstr))
// rangstr = rangstr + " and " + isopenstr;
// else
// rangstr = isopenstr;
// }
// var isacc = MsBaseInfoDAL.GetUserModuleEnable("modISWACC", Convert.ToString(Session["USERID"]));
// var isaccstr = "";
// if (isacc == false)
// {
// isaccstr = " ISNULL(ISACC,0)=0 ";
// if (!string.IsNullOrEmpty(rangstr))
// rangstr = rangstr + " and " + isaccstr;
// else
// rangstr = isaccstr;
// }
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = rangstr });
return new ContentResult() { Content = json };
}
public ContentResult GetSaleDataList(string billno, int type, string optype, string condition)
{
var fieldcomm = "";
if (condition != null && condition.Trim() != "")
{
var dataList = MsChFeeDAL.GetDataList(condition, type, optype, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var YJFADDTOHYF = MsSysParamSetDAL.GetData("PARAMNAME='YJFADDTOHYF'");
if (YJFADDTOHYF.PARAMVALUE == "1") {
var YJFEENAME = MsSysParamSetDAL.GetData("PARAMNAME='YJFEENAME'");
dataList = MsChFeeDAL.SetYjData(dataList, YJFEENAME.PARAMVALUE);
}
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
else
{
var dataList = MsChFeeDAL.GetDataList("BsNo='" + billno + "' and FeeType=" + type + fieldcomm, type, optype, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var YJFADDTOHYF = MsSysParamSetDAL.GetData("PARAMNAME='YJFADDTOHYF'");
if (YJFADDTOHYF.PARAMVALUE == "1")
{
var YJFEENAME = MsSysParamSetDAL.GetData("PARAMNAME='YJFEENAME'");
dataList = MsChFeeDAL.SetYjData(dataList, YJFEENAME.PARAMVALUE);
}
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
}
public ContentResult GetImportDataList ( string billno, int type, string optype, List<string> Fields, List<string> Values )
{
var fieldcomm = "";
if (Fields != null)
{
if (Fields.Count != Values.Count)
{
var json2 = JsonConvert.Serialize(new { Success = false, Message = "错误,字段和数值数量不相等", totalCount = 0, data = "" });
return new ContentResult() { Content = json2 };
}
else
for (int _i = 0; _i < Fields.Count; _i++)
{
fieldcomm += " and " + Fields[_i] + " = '" + Values[_i] + "' ";
}
}
var dataList = MsChFeeDAL.GetImportDataList("BsNo='" + billno + "' and FeeType=" + type + fieldcomm, type, optype, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetGainData(string bsno,string bltype="",string optype="")
{
var dataList = new List<MsChFeeGain>();
var FEEEDITTOTALADDAMEND = MsSysParamSetDAL.GetData("PARAMNAME='FEEEDITTOTALADDAMEND'");
if (FEEEDITTOTALADDAMEND.PARAMVALUE != "1")
{
if (bltype == "合票主票" || bltype == "拼箱主票")
dataList = MsChFeeDAL.GetDataGainList("BsNo in (select bsno from v_op_bill where MASTERNO='" + bsno + "')", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]),optype);
else
dataList = MsChFeeDAL.GetDataGainList("BsNo='" + bsno + "'", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), optype);
}
else {
dataList = MsChFeeDAL.GetDataGainTTLList("B.PARENTID='" + bsno + "'", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), optype);
}
if (dataList.Count == 0) {
var bodyList = new List<MsChFeeGain>();
MsChFeeGain data = new MsChFeeGain();
bodyList.Add(data);
dataList = bodyList;
}
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetFeeLock(string bsno)
{
var result = MsChFeeDAL.GetFeeLock(bsno);
var json = JsonConvert.Serialize(new { Success = result.Success});
return new ContentResult() { Content = json };
}
public ContentResult GetAmendGainData(string bsno,string bltype="")
{
var dataList = new List<MsChFeeGain>();
if (bltype == "合票主票" || bltype == "拼箱主票")
dataList = MsChFeeDAL.GetDataAmendGainList("B.MASTERNO='" + bsno + "'", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
else
dataList = MsChFeeDAL.GetDataAmendGainList("B.PARENTID='" + bsno + "'", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
if (dataList.Count == 0)
{
var bodyList = new List<MsChFeeGain>();
MsChFeeGain data = new MsChFeeGain();
bodyList.Add(data);
dataList = bodyList;
}
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetMasterGainData(string bsno)
{
var dataList = MsChFeeDAL.GetDataMasterGainList("B.MASTERNO='" + bsno + "'", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
if (dataList.Count == 0)
{
var bodyList = new List<MsChFeeGain>();
MsChFeeGain data = new MsChFeeGain();
bodyList.Add(data);
dataList = bodyList;
}
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetBLFeeList(string bsno,string bltype,string optype)
{
var dataList = new List<MsBLChFee>();
if ((bltype=="合票主票"|| bltype == "拼箱主票")&&(optype!="更改单"))
dataList = MsChFeeDAL.GetBLMasterFeeList(bsno);
else
dataList = MsChFeeDAL.GetBLFeeList(bsno);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetModifyData(string FeeID, string ApplyType)
{
var dataList = MsChFeeDAL.GetModifyData(FeeID,ApplyType);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetModifyList(string FeeID)
{
var dataList = MsChFeeDAL.GetModifyData(FeeID);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetModifyAllData(string FeeID, string ApplyType)
{
var dataList = MsChFeeDAL.GetModifyAllData(FeeID, ApplyType);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetOPGainList(string bsno, string bltype="",string optype="普通货",string oplb="")
{
var LOCALCURR = CookieConfig.GetCookie_LocalCurr(Request);
var dataList = new List<MsOpGain>();
var FEEEDITTOTALADDAMEND = MsSysParamSetDAL.GetData("PARAMNAME='FEEEDITTOTALADDAMEND'");
if (FEEEDITTOTALADDAMEND.PARAMVALUE == "1")
{
dataList = MsChFeeDAL.GetOPGainAMENDList("B.PARENTID in (select '" + bsno + "' union all select PARENTID from v_op_bill where bsno='" + bsno + "')", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), LOCALCURR);
}
else {
if ((bltype == "合票主票" || bltype == "拼箱主票")&&(optype== "普通货"))
dataList = MsChFeeDAL.GetOPGainList("BsNo in (select bsno from v_op_bill where MASTERNO='" + bsno + "') ", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), LOCALCURR,oplb);
else
dataList = MsChFeeDAL.GetOPGainList("BsNo='" + bsno + "'", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), LOCALCURR, oplb);
}
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetMBLGainList(string condition)
{
var dataList = MsChFeeDAL.GetMBLGainList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetAmendList(string billno,string bstype)
{
var dataList = MsChFeeDAL.GetAmendList("PARENTID='" + billno + "'", bstype, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult Save(string bsno, string chfeebody,string isyj="0")
{
int iResult = 0;
var bodyList = JsonConvert.Deserialize<List<MsChFee>>(chfeebody);
var result =new DBResult();
T_ALL_DA T_ALL_DA = new T_ALL_DA();
var custstr = "";
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
var BLCOUNT2 = T_ALL_DA.GetStrSQL("BLCOUNT", "select count(*) BLCOUNT from info_client WHERE ISNULL(ISSTOP,0)=0 AND SHORTNAME='" + enumValue.CustomerName + "'");
if (BLCOUNT2 == "0")
{
if (custstr == "") custstr = enumValue.CustomerName;
else custstr = custstr + "," + enumValue.CustomerName;
}
}
}
if (custstr != "") {
var jsonRespose2 = new JsonResponse
{
Success =false,
Message ="客户名称:"+custstr+" ,系统中不存在,请检查!",
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
if (isyj == "1")
{
var YJMUSTBEFEECLOSE = MsSysParamSetDAL.GetData("PARAMNAME='YJMUSTBEFEECLOSE'");
if (YJMUSTBEFEECLOSE.PARAMVALUE == "1")
{
var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select count(*) BLCOUNT from v_op_bill WHERE FEESTATUS=1 AND BSNO='" + bsno + "'");
if (BLCOUNT == "1")
{
var jsonRespose2 = new JsonResponse
{
Success = false,
Message = "已费用锁定,不允许添加修改费用!",
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
}
else {
var nowperiod = ChMonthCloseDAL.GetData("", Convert.ToString(Session["COMPANYID"]));
var ACCDATE = T_ALL_DA.GetStrSQL("ACCDATE", "select ACCDATE from v_op_bill WHERE BSNO='" + bsno + "'");
if (Convert.ToDateTime(nowperiod.PERIOD + "-01") > Convert.ToDateTime(ACCDATE + "-01")) {
var jsonRespose2 = new JsonResponse
{
Success = false,
Message = "已月末结转,不允许添加修改费用!",
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
}
}
else
{
var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select count(*) BLCOUNT from v_op_bill WHERE FEESTATUS=1 AND BSNO='" + bsno + "'");
if (BLCOUNT == "1")
{
var jsonRespose2 = new JsonResponse
{
Success = false,
Message = "已费用锁定,不允许添加修改费用!",
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
}
if (bodyList != null)
{
var type = bodyList[0].FeeType;
var BLCOUNT = "";
if (type == 1)
BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select count(*) BLCOUNT from op_close WHERE DRCLOSE=1 AND BSNO='" + bsno + "'");
else BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select count(*) BLCOUNT from op_close WHERE CRCLOSE=1 AND BSNO='" + bsno + "'");
if (BLCOUNT == "1")
{
if (type == 1) {
var jsonRespose2 = new JsonResponse
{
Success = false,
Message = "应收费用已锁定,不允许添加修改费用!",
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
else {
var jsonRespose2 = new JsonResponse
{
Success = false,
Message = "应付费用已锁定,不允许添加修改费用!",
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
}
iResult = MsChFeeDAL.SaveUpdateFee(bodyList, bsno, CookieConfig.GetCookie_UserId(Request));
}
if (iResult == 1) {
result.Success=true;
result.Message = "更新成功!";
MsChFeeDAL.p_op_gain(bsno, CookieConfig.GetCookie_UserId(Request));//Convert.ToString(Session["USERID"]));
}
else if (iResult == 0)
{
result.Success = true;
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) };
}
public ContentResult SavePiLiang(string bslist, string chfeebody, string optype)
{
int iResult = 0;
var bodyList = new List<MsChFee>();
var bsList = JsonConvert.Deserialize<List<MsOpBill>>(bslist);
var fee = JsonConvert.Deserialize<MsChFee>(chfeebody);
bodyList.Add(fee);
var result = new DBResult();
T_ALL_DA T_ALL_DA = new T_ALL_DA();
var custstr = "";
if (bsList != null)
{
foreach (var enumValue in bsList)
{
var BLCOUNT = T_ALL_DA.GetStrSQL("FEESTATUS", "select FEESTATUS from v_op_bill WHERE BSNO='" + enumValue.BSNO+ "'");
if (BLCOUNT != "0")
{
if (custstr == "") custstr = enumValue.MBLNO;
else custstr = custstr + "," + enumValue.MBLNO;
}
}
}
if (custstr != "")
{
var jsonRespose2 = new JsonResponse
{
Success = false,
Message = "提单号:" + custstr + " ,系统已费用锁定,不允许添加费用!",
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
if (bsList != null)
{
foreach (var enumValue in bsList)
{
if (bodyList != null)
{
foreach (var enumValueFEE in bodyList)
{
enumValueFEE.GId = Guid.NewGuid().ToString();
enumValueFEE.BsNo ="*";
if (enumValueFEE.MANAGER == null) enumValueFEE.MANAGER = "";
if (enumValueFEE.SALECORP == null) enumValueFEE.SALECORP = "";
enumValueFEE.EnteroPerator = Convert.ToString(Session["USERID"]);
enumValueFEE.EnterDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
if (enumValueFEE.ISCTN=="1") {
var ctnlist = MsOpSeaeDAL.GetBodyListSum("BSNO='"+ enumValue.BSNO + "'");
var isfind = false;
ctnlist.ForEach(i =>
{
if (i.CTNALL == enumValueFEE.Unit)
{
isfind = true;
enumValueFEE.Quantity = i.CTNNUM;
var taxrate = enumValueFEE.TaxRate;
var taxrateb = Math.Round(1 + (taxrate / 100), 4, MidpointRounding.AwayFromZero);
enumValueFEE.TaxUnitPrice = Math.Round(enumValueFEE.UnitPrice * taxrateb, 4, MidpointRounding.AwayFromZero);
enumValueFEE.Amount = Math.Round(enumValueFEE.TaxUnitPrice * enumValueFEE.Quantity, 2, MidpointRounding.AwayFromZero);
decimal notaxamount = 0;
if (enumValueFEE.Amount > 0)
{
enumValueFEE.NoTaxAmount= Math.Round(enumValueFEE.Amount / taxrateb, 2, MidpointRounding.AwayFromZero);
}
else
{
enumValueFEE.NoTaxAmount = -Math.Round(Math.Abs(enumValueFEE.Amount) / taxrateb, 2, MidpointRounding.AwayFromZero);
}
}
});
if (!isfind) {
enumValueFEE.BsNo = "1111";
}
}
if (string.IsNullOrEmpty(enumValueFEE.CustomerName)) {
if (enumValueFEE.CustomerType == "CUSTOMERNAME") enumValueFEE.CustomerName = enumValue.CUSTOMERNAME;
if (enumValueFEE.CustomerType == "CARRIER") enumValueFEE.CustomerName = enumValue.CARRIER;
if (enumValueFEE.CustomerType == "FORWARDER") enumValueFEE.CustomerName = enumValue.FORWARDER;
if (enumValueFEE.CustomerType == "YARD") enumValueFEE.CustomerName = enumValue.YARD;
if (enumValueFEE.CustomerType == "AGENTID") enumValueFEE.CustomerName = enumValue.AGENTID;
if (enumValueFEE.CustomerType == "CUSTOMSER") enumValueFEE.CustomerName = enumValue.CUSTOMSER;
if (enumValueFEE.CustomerType == "SHIPAGENCY") enumValueFEE.CustomerName = enumValue.SHIPAGENCY;
}
}
iResult = MsChFeeDAL.SaveUpdateFee(bodyList, enumValue.BSNO, CookieConfig.GetCookie_UserId(Request));
}
if (fee.FeeStatus == 2)
{
foreach (var enumValueFEE in bodyList)
{
enumValueFEE.BsNo = enumValue.BSNO;
}
var ISSALEWORK = CookieConfig.GetCookie_ISSALEWORK(Request);
Chfee_AuditDAL.SubmitAuditNew(optype, Convert.ToString(Session["USERID"]), bodyList, false, "", ISSALEWORK, Convert.ToString(Session["COMPANYID"]));
}
if (iResult == 1)
{
MsChFeeDAL.p_op_gain(enumValue.BSNO, CookieConfig.GetCookie_UserId(Request));//Convert.ToString(Session["USERID"]));
}
}
result.Success = true;
result.Message = "更新成功!";
}
else if (iResult == 0)
{
result.Success = true;
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) };
}
public ContentResult Delete(string bsno,string data)
{
int iResult = 0;
var bodyList = data;
var result = new DBResult();
if (bodyList !="" ||bodyList != null)
{
iResult = MsChFeeDAL.DeleteFee(bodyList);
MsChFeeDAL.p_op_gain(bsno, Convert.ToString(Session["USERID"]));
}
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) };
}
public ContentResult DeleteCtn(string bsno, string data)
{
int iResult = 0;
var bodyList = data;
var result = new DBResult();
if (bodyList != "" || bodyList != null)
{
iResult = MsChFeeDAL.DeleteFee(bodyList);
MsChFeeDAL.p_op_gain(bsno, Convert.ToString(Session["USERID"]));
}
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) };
}
public ContentResult DeleteAmend(string data)
{
var head = JsonConvert.Deserialize<MsOpAmend>(data);
T_ALL_DA T_ALL_DA = new T_ALL_DA();
var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select count(*) BLCOUNT from ch_fee WHERE BSNO='" + head.BSNO + "'");
if (BLCOUNT == "0")
{
var modb = new ModelObjectDB();
DBResult result = modb.Delete(head);
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 GetAmendData(string handle, string condition)
{
MsOpAmend head = null;
if (handle == "edit" || handle == "copyadd")
{
var headlist = MsChFeeDAL.GetAmendList(condition);
if (headlist.Count > 0)
head=headlist[0];
else
head = new MsOpAmend();
}
if (head == null)
{
head = new MsOpAmend();
head.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
head.CREATEUSER = Convert.ToString(Session["SHOWNAME"]);
var period = ChMonthCloseDAL.GetData("", Convert.ToString(Session["COMPANYID"]));
if (Convert.ToDateTime(period.FDAY) > DateTime.Now)
{
head.ACCDATE = period.PERIOD;
}
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult SaveAmendData(string opstatus,string data,string bsno)
{
var head = JsonConvert.Deserialize<MsOpAmend>(data);
head.PARENTID = bsno;
var modb = new ModelObjectDB();
head.ACCDATE = head.ACCDATE.Substring(0, 7);
var bsclose = ChMonthCloseDAL.GetData("", Convert.ToString(Session["COMPANYID"]));
if (Convert.ToDateTime(head.ACCDATE + "-01") < Convert.ToDateTime(bsclose.PERIOD + "-01"))
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "会计期间" + head.ACCDATE + "已结转,不允许修改添加更改单!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
if (opstatus == "add")
{
head.GID = Guid.NewGuid().ToString();
head.BSNO = Guid.NewGuid().ToString();
head.PARENTID = bsno;
head.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
head.CREATEUSER = Convert.ToString(Session["SHOWNAME"]);
head.DbOperationType = DbOperationType.DbotIns;
if (string.IsNullOrEmpty(head.AMENDNO))
{
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='更改单'", Convert.ToString(Session["COMPANYID"]));
if (billnoset.BILLTYPE != "")
head.AMENDNO = MsSysBillNoSetDAL.GetBillNo(billnoset, DateTime.Now.ToString("yyyy-MM-dd"), head.ACCDATE.ToString().Trim(),"", head.CREATEUSER);
}
}
else
{
head.DbOperationType = DbOperationType.DbotUpd;
}
if (head.SALE == "") {
var opbill= MsOpBillDAL.GetData("BSNO='"+ bsno + "'");
head.SALE = opbill.SALE;
}
DBResult result = modb.Save(head);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsChFeeDAL.GetAmendData("BSNO='" + head.BSNO + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveAmend(string bsno, string data, string chdrfeebody, string chcrfeebody)
{
int iResult = 1;
var head = JsonConvert.Deserialize<MsOpAmend>(data);
var bodyListdr = JsonConvert.Deserialize<List<MsChFee>>(chdrfeebody);
var bodyListcr = JsonConvert.Deserialize<List<MsChFee>>(chcrfeebody);
var result = new DBResult();
var billno = head.BSNO;
var modb = new ModelObjectDB();
head.ACCDATE = head.ACCDATE.Substring(0, 7);
var bsclose = ChMonthCloseDAL.GetData("", Convert.ToString(Session["COMPANYID"]));
if (Convert.ToDateTime(head.ACCDATE + "-01") < Convert.ToDateTime(bsclose.PERIOD + "-01"))
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "会计期间" + head.ACCDATE + "已结转,不允许添加更改单!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
if (head.CREATETIME == "")
{
head.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
head.CREATEUSER = Convert.ToString(Session["SHOWNAME"]);
head.DbOperationType = DbOperationType.DbotIns;
if (string.IsNullOrEmpty(head.AMENDNO))
{
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='更改单'", Convert.ToString(Session["COMPANYID"]));
if (billnoset.BILLTYPE != "")
head.AMENDNO = MsSysBillNoSetDAL.GetBillNo(billnoset, DateTime.Now.ToString("yyyy-MM-dd"), head.ACCDATE.ToString().Trim(), "", head.CREATEUSER);
}
}
else
{
head.DbOperationType = DbOperationType.DbotUpd;
}
modb.Save(head);
if (head.FEESTATUS) {
var jsonRespose2 = new JsonResponse { Success = false, Message = "已费用锁定不允许在此更改单添加修改费用!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
if (bodyListdr != null)
{
iResult = MsChFeeDAL.SaveUpdateFee(bodyListdr, bsno, Convert.ToString(Session["USERID"]));
}
if (bodyListcr != null)
{
iResult = MsChFeeDAL.SaveUpdateFee(bodyListcr, bsno, Convert.ToString(Session["USERID"]));
}
if (iResult == 1)
{
result.Success = true;
result.Message = "更新成功!";
MsChFeeDAL.p_op_gain(bsno, Convert.ToString(Session["USERID"]));
}
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.GetAmendList("BSNO='" + billno + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteAmendList(string data)
{
var headData = JsonConvert.Deserialize<List<MsOpAmend>>(data);
var errstr = "";
if (headData != null)
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
foreach (var enumValue in headData)
{
var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select count(*) BLCOUNT from ch_fee WHERE BSNO='" + enumValue.BSNO + "'");
if (BLCOUNT == "0"){
string blUpSQL = "delete from op_amend where BSNO='" + enumValue.BSNO + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
else
{
if (errstr == "")
errstr = enumValue.BSNO;
else
errstr = errstr + "," + enumValue.BSNO;
}
}
}
if (errstr == "") errstr = "删除成功!";
else errstr = "存在费用,请先删除费用才能删除此票更改单!";
var jsonRespose = new JsonResponse { Success = true, Message = errstr };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
/*
public ContentResult GetAuditDataList(string billno)
{
var dataList = MsChFeeDAL.GetDataList("BsNo='" + billno + "' and (FeeStatus<>1 and FeeStatus<>6)");
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
*/
public ContentResult Audit(int newStatus, string list)
{
var chfeeList = JsonConvert.Deserialize<List<MsChFee>>(list);
DBResult result = MsChFeeDAL.Audit(newStatus, chfeeList);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult GetCtnUnitList(string bsno,string bstype)
{
var list = MsChFeeDAL.GetCtnUnitList(bsno,bstype);
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = list.ToList() });
return new ContentResult() { Content = json };
}
/// <summary>
/// 币别和默认汇率
/// </summary>
/// <param name="condition"></param>
/// <returns></returns>
public ContentResult GetFeeCurrList(string condition)
{
var list = MsChFeeDAL.GetFeeCurrList();
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = list.ToList() });
return new ContentResult() { Content = json };
}
public JsonResult GetFeeTypeRefList(string condition)
{
List<FeeTypeRefModel> evList = MsChFeeDAL.GetFeeTypeRefList(condition);
if (evList.Count == 0)
{
return Json(new { success = false });
}
else
{
return Json(new { success = true, data = evList.ToList() });
}
}
public JsonResult GetFeeTypeRefListNew(string Name)
{
var condition = "";
if (Name== "")
{
}
else
condition = " (FeeCode like '%" + Name + "%' or Name like '%" + Name + "%' or DESCRIPTION like '%"+ Name + "%') ";
List<FeeTypeRefModel> evList = MsChFeeDAL.GetFeeTypeRefList(condition);
if (evList.Count == 0)
{
return Json(new { success = false });
}
else
{
return Json(new { success = true, data = evList.ToList() });
}
}
public ContentResult GetFeeOpRang(string optype)
{
var list = MsChFeeDAL.GetFeeOpRang(optype, Convert.ToString(Session["USERID"]));
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetFeeDateCurrList(string optype,string bsno)
{
var list = MsChFeeDAL.GetFeeDateCurrList(optype, bsno, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetFeeNowCurrList()
{
var COMPANYID = Convert.ToString(Session["COMPANYID"]);
var list = MsChFeeDAL.GetFeeNowCurrList(COMPANYID);
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetFeeNowInvCurrList()
{
var COMPANYID = Convert.ToString(Session["COMPANYID"]);
var list = MsChFeeDAL.GetFeeNowInvCurrList();
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = list.ToList() });
return new ContentResult() { Content = json };
}
/// <summary>
/// 根据Session的分公司 和 当前时间 查询日期区间汇率
/// </summary>
/// <returns></returns>
public ContentResult GetCurrList()
{
var COMPANYID = Convert.ToString(Session["COMPANYID"]);
var list = MsChFeeDAL.GetFeeNowCurrList2(COMPANYID);
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetFeeDefaultUnit( string BSNO,string FEENAME)
{
FeeDefaultUnitmb head = null;
var list = MsChFeeDAL.GetFeeDefaultUnitList(BSNO, FEENAME);
if (list.Count > 0)
head = list[0];
if (head == null)
{ head = new FeeDefaultUnitmb(); }
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetGainPrint(string bsno, string oplb)
{
DBResult result = MsChFeeDAL.GetGainPrint(bsno, oplb);
if (result.Success) {
var isopen = MsBaseInfoDAL.GetUserModuleEnable("modFeenotopen", Convert.ToString(Session["USERID"]));
result.Data = MsChFeeDAL.GetFeeSumRangeSqlStr(isopen,Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
result.Message = MsChFeeDAL.GetFeeDrCrRangeSqlStr(1,oplb,isopen,Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
result.Message2 = MsChFeeDAL.GetFeeDrCrRangeSqlStr(2, oplb, isopen, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Message2 = result.Message2, Data = result.Data };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetCarrierInv(string bsno)
{
DBResult result = MsChFeeDAL.GetCarrierInvInterfaceList(bsno, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = result.Data };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult UpdateFeeCustNo(string body, string custno)
{
var bodyList = JsonConvert.Deserialize<List<MsChFee>>(body);
var result = new DBResult();
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
if (bodyList != null)
{
foreach (var bill in bodyList)
{
string blUpSQL = " update ch_fee set WMSOUTBSNO='" + custno + "' where GID='"+bill.GId+"'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
}
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) };
}
public ContentResult GetFeeBalAmount(string condition)
{
var feeBal = MsChFeeDAL.GetFeeBalAmount(condition);
var jsonRespose = new JsonResponse { Success = true, Message = "", Data = feeBal };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 销售订舱费用
public ContentResult GetOrderDataList(string billno, int type, string optype)
{
var dataList = MsChFeeDAL.GetOrderDataList("BsNo='" + billno + "' and FeeType=" + type);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetOrderFeeList(string condition)
{
var dataList = MsChFeeDAL.GetOrderDataList(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult OrderDelete(string bsno, string data)
{
int iResult = 0;
var bodyList = data;
var result = new DBResult();
if (bodyList != "" || bodyList != null)
{
iResult = MsChFeeDAL.DeleteOrderFee(bodyList);
// MsChFeeDAL.p_op_gain(bsno, Convert.ToString(Session["USERID"]));
}
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) };
}
public ContentResult GetOrderGainList(string bsno)
{
var dataList = MsChFeeDAL.GetOrderGainList("BsNo='" + bsno + "'");
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult SaveOrderFee ( string bsno, string type, string OrderFeeBody )
{
var chfeeBodyList = JsonConvert.Deserialize<List<MsOrderFee>>(OrderFeeBody);
var chfeeDelBodyList = JsonConvert.Deserialize<List<MsOrderFee>>("");
var modb = new ModelObjectRepository();
DBResult result = modb.SaveComm("BsNo", bsno,
ModelObjectConvert<MsOrderFee>.ToModelObjectList(chfeeBodyList),
ModelObjectConvert<MsOrderFee>.ToModelObjectList(chfeeDelBodyList)
);
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
public ContentResult ShenNewSaleCorp(String data, string SaleCorp)
{
var billData = JsonConvert.Deserialize<List<MsChFee>>(data);
DBResult result = MsChFeeDAL.ShenNewSALECORP(billData, SaleCorp, Convert.ToString(Session["USERID"]));
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult CreateDui(string list)
{
var chfeeList = JsonConvert.Deserialize<List<MsChFee>>(list);
var duino = "";
var gidstr = "";
if (chfeeList != null)
{
foreach (var enumValue in chfeeList)
{
//if (enumValue.DebitNo!=""&& enumValue.DebitNo!=null)
// duino = enumValue.DebitNo;
if (gidstr == "")
gidstr = "'" + enumValue.GId + "'";
else gidstr = gidstr + ",'" + enumValue.GId + "'";
}
}
if (gidstr != "") {
gidstr = "(" + gidstr + ")";
T_ALL_DA T_ALL_DA = new T_ALL_DA();
var STATEMENTNO = T_ALL_DA.GetStrSQL("STATEMENTNO", "select top 1 STATEMENTNO from CH_FEE where STATEMENTNO<>'' AND GID IN "+ gidstr);
if (!string.IsNullOrEmpty(STATEMENTNO)) {
duino = STATEMENTNO;
}
}
if (duino != "") {
var jsonRespose = new JsonResponse { Success =true,Data=duino,Message = "已存在账单号!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var FEEDEBITINVISMUST = MsSysParamSetDAL.GetData("PARAMNAME='FEEDEBITINVISMUST'");
if (FEEDEBITINVISMUST.PARAMVALUE == "1")
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
var INVNO = T_ALL_DA.GetStrSQL("INVNO", "select top 1 INVNO from v_op_bs where BSNO='" + chfeeList[0].BsNo + "'");
if (INVNO == "")
{
var billnoset2 = MsSysBillNoSetDAL.GetData("OPLBNAME='费用单票账单'", Convert.ToString(Session["COMPANYID"]));
duino = MsSysBillNoSetDAL.GetBillNo(billnoset2, DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.ToString("yyyy-MM"));
MsChFeeDAL.CreateDui(duino, chfeeList);
var jsonRespose = new JsonResponse { Success = false, Message = "发票号空!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='费用单票账单'", Convert.ToString(Session["COMPANYID"]));
duino = MsSysBillNoSetDAL.GetBillNo(billnoset, DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.ToString("yyyy-MM"));
if (duino=="")
{
var jsonRespose = new JsonResponse { Success = false, Message = "账单号规则未设置,无法生存账单!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
DBResult result = MsChFeeDAL.CreateDui(duino,chfeeList);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult SaveSort(string chfeebody,string bsno)
{
var chfeeList = JsonConvert.Deserialize<List<MsChFee>>(chfeebody);
DBResult result = MsChFeeDAL.SaveFeeSort(chfeeList);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult CreateDjyInvFee(string bsno, string feebody)
{
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) };
}
var bodyList = JsonConvert.Deserialize<List<MsChFee>>(feebody);
var result = new DBResult();
if (bodyList == null || bodyList.Count == 0)
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "没有要生成的费用明细!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
var bsnolist = new List<BSNOLB>();
var bsnols = new BSNOLB();
bsnols.BSNO = bsno;
bsnolist.Add(bsnols);
result = MsChFeeDAL.SendToDJYINV(bsnolist, bodyList, Convert.ToString(Session["COMPANYID"]).ToString().Trim(), Convert.ToString(Session["USERID"]).ToString().Trim());
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data=result.Data
// Data = MsChFeeDAL.GetDataList(headData.BillNo, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult CancelCreateDjyInvFee(string bsno, string feebody)
{
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) };
}
var bodyList = JsonConvert.Deserialize<List<MsChFee>>(feebody);
var result = new DBResult();
if (bodyList == null || bodyList.Count == 0)
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "没有要生成的费用明细!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
try
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
foreach (var item in bodyList)
{
var blUpSQL = "update ch_fee set INVLINKGID='' where GID='" + item.GId + "' ";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
result.Success = true;
}
catch (Exception e){
result.Success = false;
result.Message = e.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) };
}
public ContentResult CreateDjyFee(string bsno, string feebody)
{
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) };
}
var bodyList = JsonConvert.Deserialize<List<MsChFee>>(feebody);
var result = new DBResult();
if (bodyList == null || bodyList.Count == 0) {
var jsonRespose2 = new JsonResponse { Success = false, Message = "没有要生成的费用明细!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
result = MsChFeeDAL.SendToDJY(bsno, bodyList, Convert.ToString(Session["COMPANYID"]).ToString().Trim(), Convert.ToString(Session["USERID"]).ToString().Trim());
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
if (result.Success) {
foreach (var item in bodyList) {
var blUpSQL = "update ch_fee set ISDJY=1 where GID='" + item.GId+"' ";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
}
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) };
}
public ContentResult CreateTruckOrderFee(string bsno, string feebody)
{
int iResult = 0;
var bodyList = JsonConvert.Deserialize<List<MsChFee>>(feebody);
var result = new DBResult();
var truckbsno = "";
var TRUCKBULK = MsOpTruckBulkDAL.GetData(" isnull(op_truck_bulk.FEESTATUS,0)=0 and op_truck_bulk.bsno in (select linkbsno from op_truck_bulk_pc_detail where bsno='" + bsno + "')");
truckbsno = TRUCKBULK.BSNO;
if (truckbsno == "")
{
result.Success = false;
result.Message = "没有符合要生成费用的订单!";
var jsonRespose2 = new JsonResponse
{
Success = result.Success,
Message = result.Message,
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
if (bodyList != null)
{
var newfeelist = new List<MsChFee>();
foreach (var enumValueBody in bodyList)
{
enumValueBody.GId = Guid.NewGuid().ToString();
enumValueBody.BsNo = "*";
enumValueBody.CustomerName = TRUCKBULK.CUSTOMERNAME;
enumValueBody.CustomerType = "委托单位";
enumValueBody.FeeStatus = 1;
enumValueBody.FeeType = 1;
newfeelist.Add(enumValueBody);
}
iResult = MsChFeeDAL.SaveUpdateFee(newfeelist, truckbsno, CookieConfig.GetCookie_UserId(Request));
}
if (iResult == 1)
{
result.Success = true;
result.Message = "更新成功!";
MsChFeeDAL.p_op_gain(truckbsno, CookieConfig.GetCookie_UserId(Request));//Convert.ToString(Session["USERID"]));
}
else if (iResult == 0)
{
result.Success = true;
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) };
}
#region
[HttpPost]
public ContentResult ImportFee()
{
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 = "File is Error,Pls Upload Again";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var path = Server.MapPath("../../UploadFiles/SeaFee");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var size = file.ContentLength;
var name = Path.GetFileName(file.FileName);
var bsno = Request.Form["bsno"];
var usercode = CookieConfig.GetCookie_UserCode(Request);
string csvfilename = usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
string filename = path + "\\" + csvfilename;
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) };
}
filename = filename.Replace("//", "/");
var ExcelExt = "";
try
{
ExcelExt = WebConfigurationManager.AppSettings["ExcelExt"].ToString();
}
catch
{
}
if (ExcelExt == "" || ExcelExt == null) ExcelExt = "Excel 8.0;HDR=Yes;IMEX=1";
try
{
string excelConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename +
";Extended Properties="+ ExcelExt;
if (filename.ToLower().IndexOf(".xlsx") > 0)
{
excelConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filename +
";Extended Properties='Excel 12.0 Xml;HDR=Yes;IMEX=1'";
}
DataSet ds = new DataSet();
if (filename.ToLower().IndexOf(".csv") > 0)
{
excelConn = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + path + ";Extensions=asc,csv,tab,txt";
using (OdbcConnection odbccon = new OdbcConnection(excelConn)) { odbccon.Open(); OdbcCommand odbccom = new OdbcCommand(); odbccom.Connection = odbccon; odbccom.CommandText = "select * from [" + csvfilename + "]"; OdbcDataAdapter odbcda = new OdbcDataAdapter(odbccom); odbcda.Fill(ds); odbccon.Close(); }
}
else
{
List<string> sheets = ExcelSheetName(filename, ExcelExt);
var sheetname = sheets[0];
OleDbDataAdapter oada = new OleDbDataAdapter("select * from [" + sheetname + "A1:N]", excelConn);
oada.Fill(ds);
}
if (ds.Tables.Count == 0)
{
jsonRespose.Success = false;
jsonRespose.Message = "上传的Excel不包含数据03";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var table = ds.Tables[0];
//if (table.Rows.Count == 0 || table.Rows.Count == 1)
//{
// jsonRespose.Success = false;
// jsonRespose.Message = "上传的Excel不包含数据04";
// return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
//}
var updatetype = "";
var message = string.Empty;
bool isSucess = true;
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var i = 0;
foreach (DataRow row in table.Rows)
{
var MBLNO = Convert.ToString(row["主提单号"]);
if (MBLNO != "")
{
var BSNO = T_ALL_DA.GetStrSQL("BSNO", "select BSNO from V_OP_BS where FEESTATUS=0 AND MBLNO='" + MBLNO + "'");
if (BSNO == "") {
isSucess = false;
if (i != 0) message = "已导入"+i.ToString()+"条费用。";
message = message+" 提单号:"+MBLNO+" 无法导入,请确认提单号正确并未费用封账!";
break;
}
var CUSTNAME = Convert.ToString(row["结算对象"]).Trim();
var FEENAME = Convert.ToString(row["费用名称"]).Trim();
var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select COUNT(*) BLCOUNT from code_fee where [NAME]='" + FEENAME + "'");
if (BLCOUNT == "0")
{
isSucess = false;
if (i != 0) message = "已导入" + i.ToString() + "条费用。";
message = message + " 提单号:" + MBLNO + " 无法导入,请确认费用名称:" + FEENAME+",是否正确!";
break;
}
BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select COUNT(*) BLCOUNT from info_client where SHORTNAME='" + CUSTNAME + "'");
if (BLCOUNT == "0")
{
isSucess = false;
if (i != 0) message = "已导入" + i.ToString() + "条费用。";
message = message + " 提单号:" + MBLNO + " 无法导入,请确认客户名称:" + CUSTNAME + ",是否正确!";
break;
}
var DRCR = Convert.ToString(row["收/付"]);
var AMOUNTSTR = Convert.ToString(row["金额"]);
var EXRATESTR = Convert.ToString(row["汇率"]);
var CURR = Convert.ToString(row["币种"]);
var ISOPEN = Convert.ToString(row["是否机密"]);
if (DRCR == "付") DRCR = "2"; else DRCR = "1";
if (ISOPEN == "是") ISOPEN = "1"; else ISOPEN = "0";
if (CURR == "RMB") EXRATESTR = "1";
try
{
var amount = Convert.ToDecimal(AMOUNTSTR);
if (CURR != "RMB")
{
var exrate = Convert.ToDecimal(EXRATESTR);
}
}
catch (Exception exception)
{
isSucess = false;
if (i != 0) message = "已导入" + i.ToString() + "条费用。";
message = message + " 提单号:" + MBLNO + " 无法导入,请确认金额是否正确!";
break;
}
var userid = CookieConfig.GetCookie_UserId(Request);
var datestr = DateTime.Now.ToString();
#region 托单数据生成
var blUpSQL = " INSERT INTO ch_fee(GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
+ " EXCHANGERATE, REASON, REMARK, COMMISSIONRATE,ENTEROPERATOR, ENTERDATE,ISOPEN, ISADVANCEDPAY, SORT, FEESTATUS, FEEFRT, "
+ " TAXRATE,NOTAXAMOUNT,ACCTAXRATE,LINENUM,TAXUNITPRICE,MODIFIEDUSER,MODIFIEDTIME,WMSOUTBSNO,PREAMOUNT,ISINVOICE,INPUTMODE,LOCALCURR,MANAGER,ISACC) "
+ " VALUES "
+ " (NEWID(),'" + BSNO + "'," + DRCR + ",'" + FEENAME + "','','','" + CUSTNAME + "','票'," + AMOUNTSTR + ",1," + AMOUNTSTR + ",'" + CURR + "', "
+ EXRATESTR + " ,'','',0,'" + userid + "','" + datestr + "'," + ISOPEN + ",0,50,0,'PP', "
+ " 0," + AMOUNTSTR + ",0,50," + AMOUNTSTR + ",'" + userid + "','" + datestr + "','',0,0,'','RMB','',0)";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
#endregion
}
i = i + 1;
}
if (!isSucess)
{
jsonRespose.Success = false;
jsonRespose.Message = message;
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var json = JsonConvert.Serialize(new { Success = true, Message = "上传成功,共生成"+i.ToString()+"条费用!" });
return new ContentResult() { Content = json };
}
catch (Exception e)
{
jsonRespose.Success = false;
jsonRespose.Message = e.Message;
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public List<string> ExcelSheetName(string filepath,string ExcelExt)
{
var al = new List<string>();
//try
//{
string strConn;
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath + ";Extended Properties="+ ExcelExt;
if (filepath.ToLower().IndexOf(".xlsx") > 0)
{
strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filepath +
";Extended Properties=\"Excel 12.0 Xml;HDR=Yes\"";
}
if (filepath.ToLower().IndexOf(".csv") > 0)
{
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath + ";Extended Properties==\"text;HDR=Yes;FMT=Delimited\"";
}
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
DataTable sheetNames = conn.GetOleDbSchemaTable
(System.Data.OleDb.OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
conn.Close();
foreach (DataRow dr in sheetNames.Rows)
{
al.Add(dr[2].ToString());
}
//}
//catch (Exception)
//{
// return new List<string>();
//}
return al;
}
public ContentResult GetEdiDataList(string condition)
{
var dataList = MsChFeeDAL.GetEdiDataList(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult CreateZnj(string data,string FeeName,string ZNJ)
{
var bodyList = JsonConvert.Deserialize<List<MsOpBillZnj>>(data);
if (bodyList != null && bodyList.Count > 0)
{
foreach (var enumValue in bodyList)
{
MsChFeeDAL.CreateZnjFee(enumValue,FeeName,ZNJ,Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
}
}
var jsonRespose = new JsonResponse { Success = true, Message = "查询成功", Data = "" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult CreateDzlxFee(string data, string FeeName, string ZNJ,string FeeType)
{
var bodyList = JsonConvert.Deserialize<List<MsOpBillZnj>>(data);
DBResult result = new DBResult();
if (bodyList != null && bodyList.Count > 0)
{
foreach (var enumValue in bodyList)
{
result=MsChFeeDAL.CreateDzlxFee(enumValue, FeeName, ZNJ, FeeType, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
}
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = "" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
}
}