using System; using System.Linq; using System.Web.Mvc; using DSWeb.Areas.Account.DAL.Chfee_Payapplication; using DSWeb.Areas.Account.Models.Chfee_Payapplication; using DSWeb.Areas.Account.Models.Chfee_do_detail; using DSWeb.Areas.Account.Models.BillChfeeDetail; using DSWeb.MvcShipping.Helper; using DSWeb.MvcShipping.Comm.Cookie; using DSWeb.Areas.CommMng.DAL; using System.Collections.Generic; using HcUtility.Comm; using HcUtility.Core; using DSWeb.EntityDA; using DSWeb.Areas.Account.Models.Chfee_Exrate; using DSWeb.MvcShipping.DAL.MsSysBillNoSet; using DSWeb.MvcShipping.Models.MsSysBillNoSet; using DSWeb.Areas.Account.Models.Chfee_Invoicehexiao; using DSWeb.Areas.MvcShipping.DAL; using DSWeb.Areas.Account.DAL.Chfee_payapplication; using DSWeb.Areas.Account.Models.Chfee_payapplication; using System.IO; using System.Globalization; using System.Web.Script.Serialization; using DSWeb.MvcShipping.DAL.MsSysParamSet; using DSWeb.Areas.Account.Models.ChfeeDetail; using DSWeb.Areas.Account.Models.BSNOLB; using System.Text; using DSWeb.Areas.CommMng.Models; using System.Data; using DSWeb.Areas.RptMng.Comm; using static DSWeb.Areas.CommMng.DAL.PublicAPIDAL; using System.Configuration; using DSWeb.MvcShipping.DAL.MsCodeDingTalkSet; using DSWeb.Areas.Dispatch.Helper; using DSWeb.MvcShipping.DAL.MsCompanysDAL; using DSWeb.MvcShipping.DAL.MsInfoClient; using DSWeb.Common.DB; using System.Web.UI.WebControls; using static java.security.cert.CertPathValidatorException; using DSWeb.Areas.MvcShipping.Helper; namespace DSWeb.Areas.Account.Controllers { [JsonRequestBehavior] public class Chfee_payapplicationController : Controller { // // GET: public ActionResult Index() { return View(); } public ActionResult TruckIndex() { return View(); } public ActionResult WorkIndex() { return View(); } public ActionResult TruckModifyIndex() { return View(); } // // GET: / public ActionResult Edit() { return View(); } public ActionResult BLEdit() { return View(); } public ActionResult WorkEdit() { return View(); } public ActionResult TruckBLEdit() { return View(); } //付费申请审核 public ActionResult Audit() { return View(); } public ActionResult BalEdit() { return View(); } /// /// 流程图 /// /// public ActionResult Map ( ) { return View(); } public ActionResult FileView ( ) { return View(); } // // GET: //private static string CHPAYMSG = MsSysParamSetDAL.GetData("PARAMNAME='CHPAYMSG'").PARAMVALUE; public ContentResult GetDataList(int start, int limit, string sort, string condition) { if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "") { var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } string LAN = Convert.ToString(Session["LANGUAGES"]); var dataList = ChpayapplicationDAL.GetDataList(start, limit,condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), sort,LAN); int count = ChpayapplicationDAL.getTotalCount(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetAuditDataList(int start, int limit, string sort, string condition, string isaudit) { if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "") { var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } string LAN = Convert.ToString(Session["LANGUAGES"]); var dataList = ChpayapplicationDAL.GetAuditDataList(condition, Convert.ToString(Session["USERID"]), isaudit, CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]),sort,LAN); 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 GetData(string handle, string condition) { 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) }; } ChPayapplication head = null; string LAN = Convert.ToString(Session["LANGUAGES"]); if (handle == "edit") { var list = ChpayapplicationDAL.GetDataList(0,1,condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]),null, LAN); if (list.Count > 0) head = list[0]; } if (head == null) { head = new ChPayapplication(); } if (handle == "add") { head.APPLICANT = Convert.ToString(Session["USERID"]); head.APPLICANTNAME = Convert.ToString(Session["SHOWNAME"]); // head.CURR = Convert.ToString(Session["LOCALCURR"]); head.SETTLETYPE = 7; } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult GetBillList(int start, int limit, string condition, string sort) { 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 dataList = ChpayapplicationDAL.GetBodyList(start,limit,condition,sort); int count = ChpayapplicationDAL.getbodyTotalCount(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetBillListPrint(string condition, string sort) { 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 dataListStr = ChpayapplicationDAL.GetBodyAllListStr(condition, sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", Data = dataListStr }); return new ContentResult() { Content = json }; } public ContentResult GetTruckBillList(int start, int limit, string condition, string sort) { 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 dataList = ChpayapplicationDAL.GetTruckBodyList(start, limit, condition, sort); int count = ChpayapplicationDAL.getTruckbodyTotalCount(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetBillAuditList(int start, int limit, string condition, string sort) { 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 dataList = ChpayapplicationDAL.GetBodyAuditList(start, limit, condition, sort); int count = ChpayapplicationDAL.getbodyTotalCount(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetBillSum(string condition) { var dataList = ChpayapplicationDAL.GetBodySumList(condition); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetFeeDataList(int start, int limit, string sort, string condition) { 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 dataList = ChpayapplicationDAL.GetFeeDataList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort); var list = dataList.Skip(start).Take(limit); var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetBillDataList(int start, int limit, string sort, string condition) { 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 dataList = ChpayapplicationDAL.GetAddBillList(start, limit,condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort); int count= ChpayapplicationDAL.getAddBillTotalCount(condition, Convert.ToString(Session["USERID"]), 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 }; } public ContentResult GetTruckBillDataList(int start, int limit, string sort, string condition) { 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 dataList = ChpayapplicationDAL.GetAddTruckBillList(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort); int count = ChpayapplicationDAL.getAddTruckBillTotalCount(condition, Convert.ToString(Session["USERID"]), 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 }; } public ContentResult GetFeeDetailList(string sort, string condition) { if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "") { var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } string LAN = Convert.ToString(Session["LANGUAGES"]); var dataList = ChpayapplicationDAL.GetFeeDetailList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort, LAN); var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetAddSum(string condition) { 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 dataList = ChpayapplicationDAL.GetAddSum(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 Save(string opstatus, string data) { 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 headData = JsonConvert.Deserialize(data); if (opstatus == "add") { headData.GID = Guid.NewGuid().ToString(); headData.COMPANYID = CookieConfig.GetCookie_CompanyId(Request); headData.APPLICANT = CookieConfig.GetCookie_UserId(Request); headData.APPLYTIME = DateTime.Now; headData.ENTERTIME = DateTime.Now; headData.DbOperationType = DbOperationType.DbotIns; var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='付费申请'", Convert.ToString(Session["COMPANYID"])); if (billnoset.BILLTYPE != "") headData.BILLNO = MsSysBillNoSetDAL.GetBillNo(billnoset, headData.PAYABLETIME.ToString().Trim(), headData.APPLYTIME.ToString()); else headData.BILLNO = PubSysDAL.GetBillNo("0303"); } else if (opstatus == "edit") { headData.DbOperationType = DbOperationType.DbotUpd; headData.ModelUIStatus = "E"; } else { headData.DbOperationType = DbOperationType.DbotDel; } var ct = ChpayapplicationDAL.GetPayRdCount("GID<>'" + headData.GID + "' AND BILLNO='" + headData.BILLNO + "' "); if (ct != 0) { var jsonRespose0 = new JsonResponse { Success = false, Message = "付费申请编号重复,不允许保存!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose0) }; } if (string.IsNullOrEmpty(headData.CHEQUEPAYABLE)&&!string.IsNullOrEmpty(headData.CUSTOMERNAME)) { var cust = MsInfoClientDAL.GetData(" SHORTNAME='"+headData.CUSTOMERNAME+"'"); if (!string.IsNullOrEmpty(cust.DESCRIPTION)) { headData.CHEQUEPAYABLE = cust.DESCRIPTION; } } var BILLNO = headData.BILLNO; if (headData.INVDATE == "") headData.INVDATE = null; var modb = new ModelObjectDB(); DBResult result = modb.Save(headData); if (result.Success == true) { ChpayapplicationDAL.p_update_Amount(headData.BILLNO); } else { MsSysBillNoSetDAL.DeleteBsNo(headData.BILLNO); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = ChpayapplicationDAL.GetData(" BILLNO='" + BILLNO + "'", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])) }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult AddDetail(string bill, string data, string curr, string storeCurrExrate,string salecorp) { if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "") { var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } string LAN = Convert.ToString(Session["LANGUAGES"]); var tianjiachenggong = "添加成功"; var tianjiachenggong2 = "添加成功 注意:此票存在未结算的应收费用"; if (LAN == "en-us") { tianjiachenggong = "Added successfully"; tianjiachenggong2 = "Added successfully Attention:There are unsettled receivables for this"; } var bodyList = JsonConvert.Deserialize>(data); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); var exrateList = JsonConvert.Deserialize>(storeCurrExrate); var CHPAYMSG = MsSysParamSetDAL.GetData("PARAMNAME='CHPAYMSG'").PARAMVALUE; var modb = new ModelObjectDB(); DBResult result = ChpayapplicationDAL.AddDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]), salecorp); if (result.Success) { ChpayapplicationDAL.p_update_Amount(bill); if (CHPAYMSG == "1") { var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select COUNT(*) BLCOUNT from ch_fee where FEETYPE=1 and (AMOUNT<>SETTLEMENT) and BSNO='" + bodyList[0].BSNO + "'"); if (BLCOUNT != "0") result.Message = tianjiachenggong2; else result.Message = tianjiachenggong; } else { result.Message = tianjiachenggong; } } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult AddBill(string billno, string billcust, string billcurr, string feesql, string storeCurrExrate, bool custgroup = false,string salecorp="") { if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "") { var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } string LAN = Convert.ToString(Session["LANGUAGES"]); var tianjiachenggong = "添加成功"; var tianjiachenggong2 = "此票存在未结算的应收费用"; var tianjiachenggong3= ",注意:主提单号"; if (LAN == "en-us") { tianjiachenggong = "Added successfully"; tianjiachenggong2 = "There are unsettled receivables for this"; tianjiachenggong3 = ",Attention:Mblno:"; } var exrateList = JsonConvert.Deserialize>(storeCurrExrate); var CHPAYMSG = MsSysParamSetDAL.GetData("PARAMNAME='CHPAYMSG'").PARAMVALUE; if ((exrateList == null) || (exrateList.Count == 0)) { if (billcurr!="") exrateList = ChpayapplicationDAL.GetCurrExrateData(billcust, billcurr, feesql, custgroup); if ((exrateList == null) ||(exrateList.Count == 0)) { var STLONESALECORP = MsSysParamSetDAL.GetData("PARAMNAME='STLONESALECORP'"); if (STLONESALECORP.PARAMVALUE == "1"&& salecorp!="") { feesql = feesql + " AND SALECORP='" + salecorp + "'"; } var modb = new ModelObjectDB(); DBResult result = ChpayapplicationDAL.AddBill(billno, billcust, billcurr, feesql, exrateList, Convert.ToString(Session["COMPANYID"]),Convert.ToString(Session["USERID"]),custgroup); if (result.Success) { ChpayapplicationDAL.p_update_Amount(billno); if (CHPAYMSG == "1") { if (!custgroup) feesql = feesql + " AND CUSTOMERNAME='" + billcust + "'"; var billnoinvlist = MsOpBillDAL.GetDataList(" BSNO IN (select DISTINCT BSNO from ch_fee (NOLOCK) where FEETYPE=1 and (AMOUNT<>SETTLEMENT) AND BSNO IN (SELECT DISTINCT BSNO FROM CH_FEE f WHERE f.ISINVOICE<>1 and f.FEESTATUS IN (0,8,9) and (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) AND " + feesql + " ))", "", "", ""); var MBLNOSTR = ""; if (billnoinvlist != null) { foreach (var billnoinv in billnoinvlist) { MBLNOSTR = MBLNOSTR + billnoinv.MBLNO + ","; } } if (MBLNOSTR != "") MBLNOSTR = tianjiachenggong3 + MBLNOSTR + tianjiachenggong2; result.Message = tianjiachenggong + MBLNOSTR; } else result.Message = tianjiachenggong; } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var jsonRespose = new JsonResponse { Success = true, Message = "查询成功", Data = exrateList.ToList() }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } else { var modb = new ModelObjectDB(); DBResult result = ChpayapplicationDAL.AddBill(billno, billcust, billcurr, feesql, exrateList, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"])); if (result.Success) { ChpayapplicationDAL.p_update_Amount(billno); if (!custgroup) feesql = feesql + " AND CUSTOMERNAME='" + billcust + "'"; var billnoinvlist = MsOpBillDAL.GetDataList(" BSNO IN (select DISTINCT BSNO from ch_fee (NOLOCK) where FEETYPE=1 and (AMOUNT<>SETTLEMENT) AND BSNO IN (SELECT DISTINCT BSNO FROM CH_FEE f WHERE f.ISINVOICE<>1 and f.FEESTATUS IN (0,8,9) and (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) AND " + feesql + " ))", "", "", ""); var MBLNOSTR = ""; if (billnoinvlist != null) { foreach (var billnoinv in billnoinvlist) { MBLNOSTR = MBLNOSTR + billnoinv.MBLNO + ","; } } if (MBLNOSTR != "") MBLNOSTR = tianjiachenggong3 + MBLNOSTR + tianjiachenggong2; result.Message = tianjiachenggong + MBLNOSTR; } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } public ContentResult DelBill(string data, string billno) { var bodyList = JsonConvert.Deserialize>(data); DBResult result = ChpayapplicationDAL.DelFeeDo(bodyList); if (result.Success) { ChpayapplicationDAL.p_update_Amount(billno); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } // public ContentResult Delete(string data) { var headData = JsonConvert.Deserialize(data); var dataList = ChpayapplicationDAL.GetBodyAllList("BILLNO='" + headData.BILLNO + "'"); DBResult result = ChpayapplicationDAL.DelFeeDo(dataList); if (result.Success == true) { var modb = new ModelObjectDB(); modb.Delete(headData); MsSysBillNoSetDAL.DeleteBsNo(headData.BILLNO); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); var blUpSQL = " insert into sys_log(GID,NAME,LOGTYPE,LOGTIME,LOGCONTENT,CREATEUSER) values(NEWID(),'" + headData.BILLNO + "','删除付费申请','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + headData.BILLNO+'('+headData.CUSTOMERNAME+')'+ "','" + 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) }; } public ContentResult modify(string data, string custname,string taxrate) { var headData = JsonConvert.Deserialize(data); DBResult result = ChpayapplicationDAL.DoModify(headData, custname,taxrate); if (result.Success == true) { ChpayapplicationDAL.p_update_Amount(headData.BILLNO); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #region 提交和撤销审核 public ContentResult SubmitAudit(string bill) { var headdata = ChpayapplicationDAL.GetData(" BILLNO='" + bill + "'", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])); //var _rr= ChpayapplicationDAL.FanWeiOA_Submit(bill, Convert.ToString(Session["USERID"]), Convert.ToString(Session["CODENAME"]), Convert.ToString(Session["COMPANYID"])); //var json2 = JsonConvert.Serialize(_rr); //return new ContentResult() { Content = json2 }; if (headdata.BILLSTATUS == 1||headdata.BILLSTATUS == 6) { DBResult result = ChpayapplicationDAL.SubmitAudit("FeeSettleAudit", Convert.ToString(Session["USERID"]), bill, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["CODENAME"])); if (result.Success == true) { ChpayapplicationDAL.p_update_Amount(bill); if (result.Message2 == "1") { var PAYAUDITAUTOCLOSEDR = MsSysParamSetDAL.GetData("PARAMNAME='PAYAUDITAUTOCLOSEDR'"); if (PAYAUDITAUTOCLOSEDR.PARAMVALUE == "1") { var bsnolist = new List(); var dataList = ChpayapplicationDAL.GetBodyAllList("BILLNO='" + bill + "'"); if (dataList != null) { foreach (var enumValue in dataList) { if (bsnolist.FindAll(x => x.BSNO == enumValue.BSNO).Count == 0) { if (enumValue.BSTYPE == "海运出口") { var bsnoitem = new BSNOLB(); bsnoitem.BSNO = enumValue.BSNO; bsnolist.Add(bsnoitem); } } } } ChpayapplicationDAL.SelBsLock(bsnolist, "应收"); } } } var FEECLOSEPAYAUTOAUDIT = MsSysParamSetDAL.GetData("PARAMNAME='FEECLOSEPAYAUTOAUDIT'"); if (FEECLOSEPAYAUTOAUDIT.PARAMVALUE == "1") { var dataList = ChpayapplicationDAL.GetBodyAllList("BILLNO='" + bill + "'"); if (dataList != null) { var isclose = true; foreach (var enumValue in dataList) { if (enumValue.FEESTATUSREF != "锁定") isclose = false; } if (isclose) { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); var blUpSQL = " update ch_fee_payapplication set BILLSTATUS=0,AUDITUSER='" + Convert.ToString(Session["USERID"]) + "',AUDITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where BILLNO='"+bill+"'"; bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL); } } } var DingTalkSet = MsCodeDingTalkSetDAL.GetData("(MODULENAME='付款申请' or MODULENAME='付费申请')", Convert.ToString(Session["COMPANYID"])); if (DingTalkSet != null && DingTalkSet.ISENABLE) { var DingTalkSetDetail = MsCodeDingTalkSetDAL.GetBodyList("MODULEID='"+ DingTalkSet.GID + "'"); var bodyList = ChpayapplicationDAL.GetBodyAllList("BILLNO='"+ headdata.BILLNO + "'"); foreach (var body in bodyList) { if (body.CURRENCY == "RMB") body.RMBAMOUNT = body.AMOUNT; else if (body.CURRENCY == "USD") body.USDAMOUNT = body.AMOUNT; } long deptid = 0; if (!string.IsNullOrEmpty(headdata.SALECORPID)) { var company = MsCompanysDAL.GetNoPicData("GID='" + headdata.SALECORPID + "'"); if (!string.IsNullOrEmpty(company.DTALKDEPTID)) deptid = Convert.ToInt64(company.DTALKDEPTID); } headdata.CUSTBANKNAME = headdata.CUSTBANKNAME + "(" + headdata.CUSTACCOUNT + ")"; var cust = MsInfoClientDAL.GetData("SHORTNAME='" + headdata.CUSTOMERNAME + "'"); headdata.CUSTFULLNAME = cust.DESCRIPTION; if (headdata.AMOUNTRMB != 0) { headdata.AMOUNTSTR = headdata.AMOUNTSTR + " RMB:" + headdata.AMOUNTRMB.ToString("0.00").Trim(); } if (headdata.AMOUNTUSD != 0) { headdata.AMOUNTSTR = headdata.AMOUNTSTR + " USD:" + headdata.AMOUNTUSD.ToString("0.00").Trim(); } result = Dispatch.Helper.DingTalkHelper.Send_SubmitAudit(DingTalkSet, DingTalkSetDetail, headdata.BILLNO, headdata, ModelObjectConvert.ToModelObjectList(bodyList), Convert.ToString(Session["USERID"]), deptid); } var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } else{ var jsonRespose = new JsonResponse { Success =false, Message ="当前状态不允许提交!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } public ContentResult SubmitAuditBack(string bill) { var headdata = ChpayapplicationDAL.GetData(" BILLNO='" + bill + "'", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])); if (headdata.BILLSTATUS == 2) { var DingTalkSet = MsCodeDingTalkSetDAL.GetData("(MODULENAME='付款申请' or MODULENAME='付费申请')", Convert.ToString(Session["COMPANYID"])); if (DingTalkSet != null && DingTalkSet.ISENABLE) { Dispatch.Helper.DingTalkHelper.SubmitBack(DingTalkSet, headdata.BILLNO, Convert.ToString(Session["USERID"])); } DBResult result = ChpayapplicationDAL.SubmitAuditBack("FeeSettleAudit", Convert.ToString(Session["USERID"]), bill); var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } else { var jsonRespose = new JsonResponse { Success =false, Message ="当前状态不允许,撤销提交!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } public ContentResult SubmitAuditList(string bills) { DBResult result = ChpayapplicationDAL.SubmitAuditList("FeeSettleAudit", bills, Convert.ToString(Session["USERID"]), Convert.ToString(Session["CODENAME"]), Convert.ToString(Session["COMPANYID"])); if (result.Message2 == "1") { var PAYAUDITAUTOCLOSEDR = MsSysParamSetDAL.GetData("PARAMNAME='PAYAUDITAUTOCLOSEDR'"); if (PAYAUDITAUTOCLOSEDR.PARAMVALUE == "1") { var bsnolist = new List(); var billList = bills.Split(','); foreach (var bill in billList) { var dataList = ChpayapplicationDAL.GetBodyAllList("BILLNO='" + bill + "'"); if (dataList != null) { foreach (var enumValue in dataList) { if (bsnolist.FindAll(x => x.BSNO == enumValue.BSNO).Count == 0) { var bsnoitem = new BSNOLB(); bsnoitem.BSNO = enumValue.BSNO; bsnolist.Add(bsnoitem); } } } } ChpayapplicationDAL.SelBsLock(bsnolist, "应收"); } } if (result.Success) { var DingTalkSet = MsCodeDingTalkSetDAL.GetData("(MODULENAME='付款申请' or MODULENAME='付费申请')", Convert.ToString(Session["COMPANYID"])); if (DingTalkSet != null && DingTalkSet.ISENABLE) { var DingTalkSetDetail = MsCodeDingTalkSetDAL.GetBodyList("MODULEID='" + DingTalkSet.GID + "'"); var billList = bills.Split(','); foreach (var bill in billList) { var headdata = ChpayapplicationDAL.GetData("BILLNO='" + bill + "'", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])); var bodyList = ChpayapplicationDAL.GetBodyAllList("BILLNO='" + headdata.BILLNO + "'"); foreach (var body in bodyList) { if (body.CURRENCY == "RMB") body.RMBAMOUNT = body.AMOUNT; else if (body.CURRENCY == "USD") body.USDAMOUNT = body.AMOUNT; } long deptid = 0; if (!string.IsNullOrEmpty(headdata.SALECORPID)) { var company = MsCompanysDAL.GetNoPicData("GID='" + headdata.SALECORPID + "'"); if (!string.IsNullOrEmpty(company.DTALKDEPTID)) deptid = Convert.ToInt64(company.DTALKDEPTID); } headdata.CUSTBANKNAME = headdata.CUSTBANKNAME + "(" +headdata.CUSTACCOUNT +")"; var cust = MsInfoClientDAL.GetData("SHORTNAME='"+headdata.CUSTOMERNAME+"'"); headdata.CUSTFULLNAME = cust.DESCRIPTION; if (headdata.AMOUNTRMB != 0) { headdata.AMOUNTSTR = headdata.AMOUNTSTR + " RMB:" + headdata.AMOUNTRMB.ToString("0.00").Trim(); } if (headdata.AMOUNTUSD != 0) { headdata.AMOUNTSTR = headdata.AMOUNTSTR + " USD:" + headdata.AMOUNTUSD.ToString("0.00").Trim(); } result = Dispatch.Helper.DingTalkHelper.Send_SubmitAudit(DingTalkSet, DingTalkSetDetail, headdata.BILLNO, headdata, ModelObjectConvert.ToModelObjectList(bodyList), Convert.ToString(Session["USERID"]), deptid); } } } var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } public ContentResult SubmitAuditBackList(string bills) { var paylist = ChpayapplicationDAL.GetDataList(0, 1000, "BILLNO IN ('" + bills.Replace(",", "','") + "')", Convert.ToString(Session["USERID"]), Convert.ToString(Session["CODENAME"]), Convert.ToString(Session["COMPANYID"])); DBResult result = new DBResult(); var DingTalkSet = MsCodeDingTalkSetDAL.GetData("(MODULENAME='付款申请' or MODULENAME='付费申请')", Convert.ToString(Session["COMPANYID"])); if (DingTalkSet != null && DingTalkSet.ISENABLE) { var billList = bills.Split(','); foreach (var bill in billList) { result = Dispatch.Helper.DingTalkHelper.SubmitBack(DingTalkSet, bill, Convert.ToString(Session["USERID"])); if (result.Success) { // var headdata = ChpayapplicationDAL.GetData(" BILLNO='" + bill + "'", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])); var headdata = paylist.Find(x => x.BILLNO == bill); if (headdata.BILLSTATUS == 2) { result = ChpayapplicationDAL.SubmitAuditBack("FeeSettleAudit", Convert.ToString(Session["USERID"]), bill); var json2 = JsonConvert.Serialize(result); return new ContentResult() { Content = json2 }; } else { var jsonRespose = new JsonResponse { Success = false, Message = "当前状态不允许,撤销提交!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } } } else { result = ChpayapplicationDAL.SubmitAuditBackList("FeeSettleAudit", Convert.ToString(Session["USERID"]), paylist, CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])); } var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } public ContentResult UpdateApp(string bills, string type) { DBResult result = ChpayapplicationDAL.UpdateApp(bills,type); var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } public ContentResult UpdateISREVINV(string bills, string type) { DBResult result = ChpayapplicationDAL.UpdateISREVINV(bills, type); var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } public ContentResult AuditList(string data) { var bodyList = JsonConvert.Deserialize>(data); DBResult result = ChpayapplicationDAL.AuditList(bodyList, Convert.ToString(Session["USERID"])); var DingTalkSet = MsCodeDingTalkSetDAL.GetData("(MODULENAME='付款申请' or MODULENAME='付费申请')", Convert.ToString(Session["COMPANYID"])); if (DingTalkSet != null && DingTalkSet.ISENABLE) { if (bodyList != null && bodyList.Count != 0) { foreach (var body in bodyList) { Dispatch.Helper.DingTalkHelper.Audit(DingTalkSet, body.BILLNO, Convert.ToString(Session["USERID"])); } } } //if (result.Message2 == "1") //{ // var PAYAUDITAUTOCLOSEDR = MsSysParamSetDAL.GetData("PARAMNAME='PAYAUDITAUTOCLOSEDR'"); // if (PAYAUDITAUTOCLOSEDR.PARAMVALUE == "1") // { // var bsnolist = new List(); // foreach (var bill in bodyList) // { // var dataList = ChpayapplicationDAL.GetBodyAllList("BILLNO='" + bill.BILLNO + "'"); // if (dataList != null) // { // foreach (var enumValue in dataList) // { // if (bsnolist.FindAll(x => x.BSNO == enumValue.BSNO).Count == 0) // { // var bsnoitem = new BSNOLB(); // bsnoitem.BSNO = enumValue.BSNO; // bsnolist.Add(bsnoitem); // } // } // } // } // ChpayapplicationDAL.SelBsLock(bsnolist, "应收"); // } //} var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult AuditListAcceptOA(string requestid,string userid) { //var gidlist = GidList.Split(',').ToList(); //var gidstr="'"+string.Join("','", gidlist)+ "'"; var bodyList = ChpayapplicationDAL.GetDataList(0, 9999, " cm.payappid in("+ requestid + ")", userid); if (bodyList == null || bodyList.Count == 0) { var jsonRespose0 = new JsonResponse { Success = false, Message = "无法查询到业务,请核实审核人的权限范围" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose0) }; } DBResult result = ChpayapplicationDAL.AuditList(bodyList, userid); if (result.Message2 == "1") { var PAYAUDITAUTOCLOSEDR = MsSysParamSetDAL.GetData("PARAMNAME='PAYAUDITAUTOCLOSEDR'"); if (PAYAUDITAUTOCLOSEDR.PARAMVALUE == "1") { var bsnolist = new List(); foreach (var bill in bodyList) { var dataList = ChpayapplicationDAL.GetBodyAllList("BILLNO='" + bill.BILLNO + "'"); if (dataList != null) { foreach (var enumValue in dataList) { if (bsnolist.FindAll(x => x.BSNO == enumValue.BSNO).Count == 0) { var bsnoitem = new BSNOLB(); bsnoitem.BSNO = enumValue.BSNO; bsnolist.Add(bsnoitem); } } } } ChpayapplicationDAL.SelBsLock(bsnolist, "应收"); } } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult AuditBackList(string data,string reason) { var bodyList = JsonConvert.Deserialize>(data); DBResult result = ChpayapplicationDAL.AuditBackList(bodyList, Convert.ToString(Session["USERID"]),reason); var DingTalkSet = MsCodeDingTalkSetDAL.GetData("(MODULENAME='付款申请' or MODULENAME='付费申请')", Convert.ToString(Session["COMPANYID"])); if (DingTalkSet != null && DingTalkSet.ISENABLE) { if (bodyList != null && bodyList.Count != 0) { foreach (var body in bodyList) { Dispatch.Helper.DingTalkHelper.SubmitAuditBack(DingTalkSet, body.BILLNO, Convert.ToString(Session["USERID"])); } } } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult AllAudit(string condition) { var dataList = ChpayapplicationDAL.GetAuditDataList(condition, Convert.ToString(Session["USERID"]),"3", CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])); DBResult result = ChpayapplicationDAL.AuditList(dataList, Convert.ToString(Session["USERID"])); //if (result.Message2 == "1") //{ // var PAYAUDITAUTOCLOSEDR = MsSysParamSetDAL.GetData("PARAMNAME='PAYAUDITAUTOCLOSEDR'"); // if (PAYAUDITAUTOCLOSEDR.PARAMVALUE == "1") // { // var bsnolist = new List(); // foreach (var bill in dataList) // { // var dataList2 = ChpayapplicationDAL.GetBodyAllList("BILLNO='" + bill.BILLNO + "'"); // if (dataList2 != null) // { // foreach (var enumValue in dataList2) // { // if (bsnolist.FindAll(x => x.BSNO == enumValue.BSNO).Count == 0) // { // var bsnoitem = new BSNOLB(); // bsnoitem.BSNO = enumValue.BSNO; // bsnolist.Add(bsnoitem); // } // } // } // } // ChpayapplicationDAL.SelBsLock(bsnolist, "应收"); // } //} var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #region 派工单 public ContentResult GetWorkData(string handle, string condition) { ChWork head = null; if (handle == "edit") { head = ChpayapplicationDAL.GetWorkData(condition); } if (head == null) { head = new ChWork(); } if (handle == "add") { head.APPLICANT = Convert.ToString(Session["USERID"]); head.APPLICANTREF = Convert.ToString(Session["SHOWNAME"]); // head.CURR = Convert.ToString(Session["LOCALCURR"]); head.SETTLETIME =DateTime.Now.ToString("yyyy-MM-dd"); } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult GetWorkList(int start, int limit, string condition,string sort) { var dataList = ChpayapplicationDAL.GetWorkList(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), sort); var list = dataList.Skip(start).Take(limit); var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult SaveWork(string opstatus, string data) { var headData = JsonConvert.Deserialize(data); if (opstatus == "add") { headData.GID = Guid.NewGuid().ToString(); headData.COMPANYID = CookieConfig.GetCookie_CompanyId(Request); headData.APPLICANT = CookieConfig.GetCookie_UserId(Request); headData.APPLYTIME = DateTime.Now.ToString(); headData.BILLSTATUS = "新建"; headData.DbOperationType = DbOperationType.DbotIns; var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='派工单'", Convert.ToString(Session["COMPANYID"])); if (billnoset.BILLTYPE != "") headData.BILLNO = MsSysBillNoSetDAL.GetBillNo(billnoset, headData.APPLYTIME.ToString().Trim(), headData.APPLYTIME.ToString()); else headData.BILLNO = PubSysDAL.GetBillNo("0303"); } else if (opstatus == "edit") { headData.DbOperationType = DbOperationType.DbotUpd; headData.ModelUIStatus = "E"; } else { headData.DbOperationType = DbOperationType.DbotDel; } var BILLNO = headData.BILLNO; var modb = new ModelObjectDB(); DBResult result = modb.Save(headData); if (result.Success == true) { } else { MsSysBillNoSetDAL.DeleteBsNo(headData.BILLNO); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = ChpayapplicationDAL.GetWorkData(" BILLNO='" + BILLNO + "'") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult DeleteWork(string data) { var headData = JsonConvert.Deserialize(data); var modb = new ModelObjectDB(); modb.Delete(headData); MsSysBillNoSetDAL.DeleteBsNo(headData.BILLNO); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); var blUpSQL1 = " update ch_fee_payapplication SET WORKBILLNO='' WHERE WORKBILLNO='"+headData.BILLNO+"'"; bool bl1 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL1); //var blUpSQL = " insert into sys_log(GID,NAME,LOGTYPE,LOGTIME,LOGCONTENT,CREATEUSER) values(NEWID(),'" + headData.BILLNO + "','删除付费申请','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + headData.BILLNO + '(' + headData.CUSTOMERNAME + ')' + "','" + Convert.ToString(Session["USERID"]) + "')"; // bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL); var jsonRespose = new JsonResponse { Success =true, Message ="删除成功!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult AddWorkList(string head, string data, string reason) { var headdata= JsonConvert.Deserialize(head); var bodyList = JsonConvert.Deserialize>(data); DBResult result = ChpayapplicationDAL.AddWorkList(headdata,bodyList, Convert.ToString(Session["USERID"])); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult DelWorkList(string head, string data, string reason) { var headdata = JsonConvert.Deserialize(head); var bodyList = JsonConvert.Deserialize>(data); DBResult result = ChpayapplicationDAL.DelWorkList(headdata, bodyList, Convert.ToString(Session["USERID"])); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SubmitAuditWork(string bill) { var headdata = ChpayapplicationDAL.GetWorkData(" BILLNO='" + bill + "'"); if (headdata.BILLSTATUS =="新建") { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); var blUpSQL1 = " update ch_fee_work SET BILLSTATUS='提交审核' WHERE BILLNO='" + bill+ "'"; bool bl1 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL1); var json = JsonConvert.Serialize(new JsonResponse { Success = true, Message = "修改成功!" }); return new ContentResult() { Content = json }; } else { var jsonRespose = new JsonResponse { Success = false, Message = "当前状态不允许提交!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } public ContentResult SubmitAuditBackWork(string bill) { var headdata = ChpayapplicationDAL.GetWorkData(" BILLNO='" + bill + "'"); if (headdata.BILLSTATUS == "提交审核") { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); var blUpSQL1 = " update ch_fee_work SET BILLSTATUS='新建' WHERE BILLNO='" + bill + "'"; bool bl1 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL1); var json = JsonConvert.Serialize(new JsonResponse { Success = true, Message = "修改成功!" }); return new ContentResult() { Content = json }; } else { var jsonRespose = new JsonResponse { Success = false, Message = "当前状态不允许,撤销提交!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } public ContentResult SubmitAuditWorkList(string bills) { var bodyList = JsonConvert.Deserialize>(bills); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); foreach (var bill in bodyList) { var blUpSQL1 = " update ch_fee_work SET BILLSTATUS='提交审核' WHERE BILLNO='" + bill.BILLNO + "'"; bool bl1 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL1); } var json = JsonConvert.Serialize(new JsonResponse { Success = true, Message = "修改成功!" }); return new ContentResult() { Content = json }; } public ContentResult SubmitAuditBackWorkList(string bills) { var bodyList = JsonConvert.Deserialize>(bills); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); foreach (var bill in bodyList) { var blUpSQL1 = " update ch_fee_work SET BILLSTATUS='新建' WHERE BILLNO='" + bill.BILLNO+ "'"; bool bl1 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL1); } var json = JsonConvert.Serialize(new JsonResponse { Success = true, Message = "修改成功!" }); return new ContentResult() { Content = json }; } #endregion public ContentResult GetPrint(string billno) { DBResult result = ChpayapplicationDAL.GetPrint(billno, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult UpdatePrint(string billnos) { var result = new DBResult(); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string blUpSQL = " update ch_fee_payapplication set ISPRINT='1',PRINTCOUNT=ISNULL(PRINTCOUNT,0)+1,PRINTTIME=GETDATE() where BILLNO IN (" + billnos + ")"; 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 UpdateNoPrint(string billnos) { var result = new DBResult(); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string blUpSQL = " update ch_fee_payapplication set ISPRINT='0',PRINTTIME=NULL where BILLNO IN (" + billnos + ")"; 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) }; } #endregion #region 入账申请生成付费申请 public ContentResult GetBalList(string billno) { var dataList = ChpayapplicationDAL.GetBalList(billno); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetBalAddList(int start, int limit, string sort, string condition) { var dataList = ChpayapplicationDAL.GetBalAddList(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), sort); var list = dataList.Skip(start).Take(limit); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetBalFeeDetailList(string sort, string condition) { var dataList = ChpayapplicationDAL.GetBalFeeDetailList(condition); var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult AddBalDetail(string billno, string data) { var bodyList = JsonConvert.Deserialize>(data); var modb = new ModelObjectDB(); DBResult result = ChpayapplicationDAL.AddBalDetail(billno, bodyList, Convert.ToString(Session["COMPANYID"])); if (result.Success) { ChpayapplicationDAL.p_update_Amount(billno); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult DelAppBill(string data, string billno) { var bodyList = JsonConvert.Deserialize>(data); DBResult result = ChpayapplicationDAL.DelBalApp(bodyList, billno); if (result.Success) { ChpayapplicationDAL.p_update_Amount(billno); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion /// /// 获取工作流当前状态值 /// /// /// /// public ContentResult GetMapData ( string BSNO,string NAME ) { var mapList = FlowMapDal.GetMap(BSNO,NAME); var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", totalCount = 1, data = mapList }); return new ContentResult() { Content = json }; } /// /// 获取车辆证件信息 /// /// /// public ContentResult GetFileList ( string BillNo ) { var dataList = ChfeeFileDal.GetFileList(BillNo); //var list = dataList.Skip(start).Take(limit); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } /// /// 上传证件照片 /// /// public ContentResult FileUpload ( ) { 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 jsonRespose = new JsonResponse { Success = false, Message = "" }; if (Request.Files.Count != 1) { jsonRespose.Success = false; jsonRespose.Message = "请选择上传的文件"; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } var imgFile = Request.Files["file"]; var BillNo = Request.Form["BillNo"].ToString().Trim(); String strPath = "/Areas/Account/Files/" + BillNo + "/"; String dirPath = System.Web.HttpContext.Current.Server.MapPath(strPath); if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } string fileOriginalName = Path.GetFileNameWithoutExtension(imgFile.FileName); String fileExt = Path.GetExtension(imgFile.FileName).ToLower(); if (fileExt == ".asp" || fileExt == ".aspx") { jsonRespose.Success = false; jsonRespose.Message = "不允许上传ASP或ASPX文件"; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } String newFileName = fileOriginalName+DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + fileExt; String filePath = dirPath + newFileName; imgFile.SaveAs(filePath); //写入数据库 ChfeeFile model = new ChfeeFile(); model.GID = Guid.NewGuid().ToString(); model.BillNo = BillNo; model.File_Type = 0; model.File_Name = newFileName; model.File_Path = filePath; model.CreateTime = DateTime.Now.ToShortDateString(); model.Operator = Session["USERID"] != null ? Session["USERID"].ToString() : ""; model.File_OriginalName = fileOriginalName; model.File_DocNo = Request.Form["File_DocNo"]; model.File_DocType= Request.Form["File_DocType"]; string msg = ""; bool success = ChfeeFileDal.SaveFile(model, 0, out msg); jsonRespose.Success = success; jsonRespose.Message = msg; var json = JsonConvert.Serialize(new { success = success, Message = "上传成功", filePath = filePath }); return new ContentResult() { Content = json }; } [HttpPost] public ActionResult FileUpload_PL() { 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 imgFile = Request.Files["file"]; var BillNo = Request.Form["BillNo"].ToString().Trim(); for (int idx = 0; idx < Request.Files.Count; idx++) { var imgFile = Request.Files.Get(idx); String strPath = "/Areas/Account/Files/" + BillNo + "/"; String dirPath = System.Web.HttpContext.Current.Server.MapPath(strPath); if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } string fileOriginalName = Path.GetFileNameWithoutExtension(imgFile.FileName); String fileExt = Path.GetExtension(imgFile.FileName).ToLower(); String newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + fileExt; String filePath = dirPath + newFileName; imgFile.SaveAs(filePath); var webpath = strPath + newFileName; // //写入数据库 ChfeeFile model = new ChfeeFile(); model.GID = Guid.NewGuid().ToString(); model.BillNo = BillNo; model.File_Type = 0; model.File_Name = newFileName; model.File_Path = webpath;//由物理路径改为相对路径 model.CreateTime = DateTime.Now.ToShortDateString(); model.Operator = Session["USERID"] != null ? Session["USERID"].ToString() : ""; model.File_OriginalName = fileOriginalName; model.File_DocNo = Request.Form["File_DocNo"]; model.File_DocType = Request.Form["File_DocType"]; string msg = ""; bool success = ChfeeFileDal.SaveFile(model, 0, out msg); } //jsonRespose.Success = success; //jsonRespose.Message = msg; //var json = JsonConvert.Serialize(new { success = true, Message = "上传成功", filePath = "" }); //return new ContentResult() { Content = json }; var result = new DBResult(); result.OK("上传成功", BillNo); return Json(result); } public ContentResult CertDel ( string TruckNo ) { var data = Request["data"]; JavaScriptSerializer json = new JavaScriptSerializer(); List file = json.Deserialize>(data); string msg = ""; bool rst = false; if (file != null) { rst = ChfeeFileDal.DelFile(file, out msg); } var jsonstr = JsonConvert.Serialize(new { Success = rst, Message = rst ? "删除成功" : msg }); return new ContentResult() { Content = jsonstr }; } public ContentResult BsListData(int start, int limit, string condition,string sort) { 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 PROFITRATEDR = MsSysParamSetDAL.GetData("PARAMNAME='PROFITRATEDR'"); var strSql = new StringBuilder(); strSql.Append("SELECT B.BSNO, B.OPLB,B.OPTYPE,B.OPLBNAME, B.BSTYPE,B.BLTYPE,B.BLFRT,B.CUSTOMERNAME, B.CUSTNO, B.MBLNO, B.HBLNO,B.VESSEL, B.VOYNO, B.INPUTBY, B.CREATETIME, B.BSSTATUS, B.SALE, B.OP, B.DOC,B.YARD,B.CONTRACTNO,B.ORDERNO,"); strSql.Append("B.ETD,B.PKGS,B.CBM,B.CNTRSEALNO,B.TRUCKER"); strSql.Append(",B.OPDATE,B.ENTERP,B.REMARK,B.REMARK2,B.AGENTID,B.ETA,B.SALEDEPT,B.ISSUETYPE,B.ISCANCEL,B.ATD,B.CUSTOMSER,B.CLOSINGDATE,B.KINDPKGS,B.BSSOURCEDETAIL"); strSql.Append(",case B.CUSTOMDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.CUSTOMDATE,23) end as CUSTOMDATE"); strSql.Append(",case B.FEESTATUS when 1 then '锁定' else '未锁定' end as FEESTATUSREF"); strSql.Append(",B.CUSTSERVICE,B.FRCUSTSERVICE, B.PORTLOAD, B.PORTDISCHARGE,B.DESTINATION, B.CUSTOMNO, B.ACCDATE,B.CARRIER, B.BSSOURCE, B.LANE, B.FORWARDER,B.CNTRTOTAL,B.CORPID"); strSql.Append(",B.TRADETYPE,B.GOODSNAME,B.FEESTATUS"); strSql.Append(",SUM(G.RMBDR) RMBDR,SUM(G.RMBCR) RMBCR,SUM(G.STLRMBDR) STLRMBDR,SUM(G.STLRMBCR) STLRMBCR,SUM(G.USDDR) USDDR,SUM(G.USDCR) USDCR,"); strSql.Append("SUM(G.STLUSDDR) STLUSDDR,SUM(G.STLUSDCR) STLUSDCR,SUM(G.OTDR) OTDR,SUM(G.OTCR) OTCR,SUM(G.STLOTDR) STLOTDR,SUM(G.STLOTCR) STLOTCR,SUM(ISNULL(G.TTLDR,0)) TTLDR,"); strSql.Append("SUM(ISNULL(G.TTLCR,0)) TTLCR,SUM(G.STLTTLDR) STLTTLDR,SUM(G.STLTTLCR) STLTTLCR"); strSql.Append(",SUM(ISNULL(G.USDDR-G.USDCR,0)) AS USDPROFIT,SUM(ISNULL(G.RMBDR-G.RMBCR,0)) AS RMBPROFIT,SUM(ISNULL(G.OTDR-G.OTCR,0)) AS OTPROFIT,SUM(ISNULL(G.TTLDR-G.TTLCR,0)) AS TTLPROFIT "); if (PROFITRATEDR.PARAMVALUE != "1") { strSql.Append(", (CASE WHEN (SUM(G.TTLDR))= 0 THEN 0 ELSE CONVERT(NUMERIC(18,2),ltrim(str((SUM(G.TTLDR-G.TTLCR)) / (SUM(G.TTLDR)) * 100, 10, 2))) END) AS PROFITRATE"); } else strSql.Append(", (CASE WHEN (SUM(G.TTLCR))= 0 THEN 0 ELSE CONVERT(NUMERIC(18,2),ltrim(str((SUM(G.TTLDR-G.TTLCR)) / (SUM(G.TTLCR)) * 100, 10, 2))) END) AS PROFITRATE"); strSql.Append(",SUM(ISNULL(G.RMBDR-G.STLRMBDR,0)) AS RMBNODR,SUM(ISNULL(G.USDDR-G.STLUSDDR,0)) AS USDNODR,SUM(ISNULL(G.OTDR-G.STLOTDR,0)) AS OTNODR,SUM(ISNULL(G.TTLDR-G.STLTTLDR,0)) AS TTLNODR"); strSql.Append(",SUM(ISNULL(G.RMBCR-G.STLRMBCR,0)) AS RMBNOCR,SUM(ISNULL(G.USDCR-G.STLUSDCR,0)) AS USDNOCR,SUM(ISNULL(G.OTCR-G.STLOTCR,0)) AS OTNOCR,SUM(ISNULL(G.TTLCR-G.STLTTLCR,0)) AS TTLNOCR"); strSql.Append(" FROM V_OP_BILL B "); strSql.Append("LEFT JOIN v_op_gain_sum G ON (G.BSNO=B.BSNO) "); strSql.Append(" WHERE 1=1 "); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" and " + condition); } strSql.Append(" GROUP BY B.BSNO, B.OPLB,B.OPTYPE,B.OPLBNAME, B.BSTYPE,B.BLTYPE,B.BLFRT,B.CUSTOMERNAME, B.CUSTNO, B.MBLNO, B.HBLNO,B.VESSEL, B.VOYNO, B.INPUTBY, B.CREATETIME, B.BSSTATUS, B.SALE, B.OP, B.DOC,B.YARD,B.CONTRACTNO,B.ORDERNO,"); strSql.Append("B.ETD,B.PKGS,B.CBM,B.CNTRSEALNO,B.TRUCKER"); strSql.Append(",B.OPDATE,B.ENTERP,B.REMARK,B.REMARK2,B.AGENTID,B.ETA,B.SALEDEPT,B.ISSUETYPE,B.ISCANCEL,B.ATD,B.CUSTOMSER,B.CLOSINGDATE,B.KINDPKGS,B.BSSOURCEDETAIL"); strSql.Append(",B.CUSTOMDATE"); strSql.Append(",B.FEESTATUS,B.SALECORPID"); strSql.Append(",B.CUSTSERVICE,B.FRCUSTSERVICE, B.PORTLOAD, B.PORTDISCHARGE,B.DESTINATION, B.CUSTOMNO, B.ACCDATE,B.CARRIER, B.BSSOURCE, B.LANE, B.FORWARDER,B.NETWEIGHT,B.KGS,B.TEU,B.CNTRTOTAL,B.CORPID"); strSql.Append(",B.TRADETYPE,B.GOODSNAME,B.FEESTATUS"); var sortstring = DatasetSort.Getsortstring(sort); if (!string.IsNullOrEmpty(sortstring)) { strSql.Append(" order by " + sortstring); } else { strSql.Append(" order by B.ETD DESC,B.MBLNO"); } 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 }; } #region 参照部分 #endregion } }