using System; using System.Linq; using System.Web.Mvc; using DSWeb.Areas.Account.DAL.Chfee_Settlement; using DSWeb.Areas.Import.DAL.CW; using DSWeb.Areas.Account.Models.Chfee_Payapplication; using DSWeb.Areas.Account.Models.Chfee_Settlement; using DSWeb.Areas.Account.Models.Chfee_do_detail; using DSWeb.Areas.Account.Models.BillChfeeDetail; using DSWeb.Areas.Import.Models.CWAdvancePayment; using DSWeb.Areas.Account.Models.Chfee_Invoice; using DSWeb.Areas.Account.Models.Chfee_Invoicehexiao; using DSWeb.Areas.Account.Models.MsCwVouchersGl3; 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.MvcShipping.DAL.ChMonthCloseDAL; using DSWeb.TruckMng.Helper.Repository; using System.Text; using DSWeb.Areas.CommMng.Models; using DSWeb.MvcShipping.DAL.MsSysParamSet; using DSWeb.Areas.Account.Models.ChfeeDetail; namespace DSWeb.Areas.Account.Controllers { [JsonRequestBehavior] public class Chfee_settlementController : Controller { // // GET: public ActionResult PayIndex() { return View(); } // // GET: / public ActionResult PayEdit() { return View(); } public ActionResult PayBLEdit() { return View(); } public ActionResult PayAppEdit() { return View(); } // GET: public ActionResult RecvIndex() { return View(); } // // GET: / public ActionResult RecvEdit() { return View(); } public ActionResult RecvBLEdit() { return View(); } public ActionResult RecvAppEdit() { return View(); } public ActionResult RecvInvEdit() { return View(); } public ActionResult PayInvEdit() { return View(); } public ActionResult SettementView() { return View(); } public ActionResult RptStlRemitIndex() { return View(); } // GET: public ActionResult HexiaoIndex() { return View(); } // GET: public ActionResult HexiaoEdit() { return View(); } // // GET: public ContentResult GetDataList(int start, int limit, string sort, string condition,int billtype,string isload="0") { int total=0; string sortStr=""; if (sort != null) { sortStr = sort.Replace("SETTLEMODEREF", "SETTLEMODE"); sortStr = sortStr.Replace("SETTLETYPEREF", "SETTLETYPE"); sortStr = sortStr.Replace("ACCOUNTREF", "ACCOUNTRMB"); sortStr = sortStr.Replace("SETTLEUSERREF", "SETTLEUSER"); } var dataList = ChsettlementDAL.GetDataList(condition, start, limit, out total, CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), sortStr, billtype, isload); //var list = dataList.Skip(start).Take(limit); //var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = total, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetDataListStr(int start, int limit, string sort, string condition, int billtype) { var dataListStr = ChsettlementDAL.GetDataListStr(condition, CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), sort, billtype); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr }); return new ContentResult() { Content = json }; } public ContentResult GetData(string handle, string condition) { ChSettlement head = null; int total = 0; if (handle == "edit") { var list = ChsettlementDAL.GetDataList(condition,0,10,out total, CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])); if (list.Count > 0) head = list[0]; } if (head == null) { head = new ChSettlement(); } if (handle == "add") { head.SETTLEUSER = CookieConfig.GetCookie_UserId(Request); head.SETTLEUSERREF = Convert.ToString(Session["SHOWNAME"]); var period = ChMonthCloseDAL.GetData("", Convert.ToString(Session["COMPANYID"])); if (Convert.ToDateTime(period.FDAY) > DateTime.Now) { head.SETTLETIME = period.FDAY; } else head.SETTLETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); head.CURR = Convert.ToString(Session["LOCALCURR"]); head.SETTLETYPE = 7; head.RATE = 1; } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult GetBillList(string condition,string sort) { var dataList = ChsettlementDAL.GetBodyList(condition, sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetBillListStr(string condition, string sort) { var dataListStr = ChsettlementDAL.GetBodyListStr(condition, sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr }); return new ContentResult() { Content = json }; } public ContentResult GetBillListPage(int start, int limit, string condition, string sort) { var dataList = ChsettlementDAL.GetBodyList(start, limit, condition, sort); int count = ChsettlementDAL.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 = ChsettlementDAL.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, int billtype) { var dataList = ChsettlementDAL.GetFeeDataList(condition, CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort, billtype); 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, int billtype) { var dataList = ChsettlementDAL.GetAddBillList(condition, CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort, billtype); // 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 GetFeeDetailList(string sort, string condition) { var dataList = ChsettlementDAL.GetFeeDetailList(condition, CookieConfig.GetCookie_UserId(Request), 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 = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetAddSum(string condition, int billtype) { var dataList = ChsettlementDAL.GetAddSum(condition, CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]),billtype); 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, string accountsdata, string prepaydata, string ahsrdata, string financialdata, string advancedata, int billtype,string prepaychange) { 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.Replace("}", ",") + accountsdata.Replace("{", "").Replace("}", ",") + prepaydata.Replace("{", "").Replace("}", ",") + ahsrdata.Replace("{", "").Replace("}", ",") + financialdata.Replace("{", "").Replace("}", ",") + advancedata.Replace("{", "")); if (opstatus == "add"&& (headData.BILLNO == "" || headData.BILLNO == "*")) { headData.GID = Guid.NewGuid().ToString(); headData.BILLDATE = DateTime.Now; if (headData.BILLNO == "" || headData.BILLNO == "*") { if (billtype == 2) { var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='付费结算'", Convert.ToString(Session["COMPANYID"])); if (billnoset.BILLTYPE != "") headData.BILLNO = MsSysBillNoSetDAL.GetBillNo(billnoset, headData.SETTLETIME.ToString().Trim(), headData.BILLDATE.ToString().Trim()); else headData.BILLNO = PubSysDAL.GetBillNo("0304"); } else if (billtype == 1) { var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='收费结算'", Convert.ToString(Session["COMPANYID"])); if (billnoset.BILLTYPE != "") headData.BILLNO = MsSysBillNoSetDAL.GetBillNo(billnoset, headData.SETTLETIME.ToString().Trim(), headData.BILLDATE.ToString().Trim()); else headData.BILLNO = PubSysDAL.GetBillNo("0305"); } } headData.COMPANYID = Convert.ToString(Session["COMPANYID"]); headData.DbOperationType = DbOperationType.DbotIns; } else { headData.DbOperationType = DbOperationType.DbotUpd; headData.ModelUIStatus = "E"; //SR2020020600001 var IsAdvancePaymentChanged = ChsettlementDAL.IsAdvancePaymentChanged(headData); var AdvancePaymentHaveBeenUsed = ChsettlementDAL.AdvancePaymentHaveBeenUsed(headData); if (AdvancePaymentHaveBeenUsed) { if (IsAdvancePaymentChanged) { var jsonRespose0 = new JsonResponse { Success = false, Message = "该结算单产生的预收/预付已被引用,不能修改其:结算对象名、币别、金额;", Data = headData }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose0) }; } } bool updatepayment = ChsettlementDAL.updatePayment(headData, CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["COMPANYID"])); if (!updatepayment) { var jsonRespose0 = new JsonResponse { Success = false, Message = "结算单产生的预收/预付时发生错误,请重新执行保存或联系管理员", Data = headData }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose0) }; } } var ct = ChsettlementDAL.GetRdCount("GID<>'" + headData.GID + "' AND BILLNO='" + headData.BILLNO + "' "); if (ct != 0) { var jsonRespose0 = new JsonResponse { Success = false, Message = "结算编号重复,不允许保存!", Data = headData }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose0) }; } var BILLNO = headData.BILLNO; if (headData.CURR == "RMB") { headData.AMOUNTRMB = headData.AMOUNT; headData.ACCOUNTRMB = headData.ACCOUNT; headData.AMOUNTUSD = 0; headData.ACCOUNTUSD = ""; } else { headData.AMOUNTUSD = headData.AMOUNT; headData.ACCOUNTUSD = headData.ACCOUNT; headData.ACCOUNTRMB = ""; headData.AMOUNTRMB = 0; } if (headData.SETTLETIME == "") headData.SETTLETIME = null; if (headData.REMITTANCEAMOUNT == "") headData.REMITTANCEAMOUNT = "0"; if (headData.BUYRATE == "") headData.BUYRATE = "0"; if (headData.SELLRATE == "") headData.SELLRATE = "0"; if (headData.SETTLRATE == "") headData.SETTLRATE = "0"; if (headData.ACCOUNTS_CURRENCY ==""|| headData.ACCOUNTS_CURRENCY ==null) headData.ACCOUNTS_CURRENCY = headData.CURR;// if (headData.PREPAY_CURRENCY == "" || headData.PREPAY_CURRENCY == null) headData.PREPAY_CURRENCY = headData.CURR;// if (headData.AHSR_CURRENCY == "" || headData.AHSR_CURRENCY == null) headData.AHSR_CURRENCY = headData.CURR;// if (headData.FINANCIAL_CURRENCY == "" || headData.FINANCIAL_CURRENCY == null) headData.FINANCIAL_CURRENCY = headData.CURR;// if (headData.ADVANCE_CURRENCY == "" || headData.ADVANCE_CURRENCY == null) headData.ADVANCE_CURRENCY = headData.CURR;// var modb = new ModelObjectDB(); DBResult result = modb.Save(headData); if ((result.Success) &&(prepaychange == "true")) { bool updatepayment=ChsettlementDAL.updatePayment(headData, CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["COMPANYID"])); if (!updatepayment) { result.Message="已保存成功,但预收付更新时发生错误,请检查预收付单据是否已生成凭证或有其他错误!";} } if (result.Success == true) { } else { MsSysBillNoSetDAL.DeleteBsNo(headData.BILLNO); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = ChsettlementDAL.GetData(" BILLNO='" + BILLNO + "'", CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])) }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult AddDetail(string bill, string data, string curr,int billtype) { var bodyList = JsonConvert.Deserialize>(data); var modb = new ModelObjectDB(); DBResult result = ChsettlementDAL.AddDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"])); if (result.Success) { ChsettlementDAL.p_update_Amount(bill,billtype); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult AddDetailStl(string bill, string data, string curr, int billtype,string ShenNo) { var bodyList = JsonConvert.Deserialize>(data); var headdata = ChsettlementDAL.GetData(" BILLNO='" + bill + "'", CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])); var modb = new ModelObjectDB(); DBResult result = ChsettlementDAL.AddDetailStl(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]), headdata,ShenNo); if (result.Success) { ChsettlementDAL.p_update_Amount(bill, billtype); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult AddBillStl(string billno, string billcust, string billcurr, string feesql, string storeCurrExrate, int billtype, bool custgroup = false,string ShenNo="") { var exrateList = JsonConvert.Deserialize>(storeCurrExrate); if ((exrateList == null) || (exrateList.Count == 0)) { var exratestr = feesql; if (ShenNo != "") exratestr = exratestr + " and f.GID IN (SELECT FEEID FROM CH_FEE_DO WHERE BILLNO='" + ShenNo + "')"; exrateList = ChsettlementDAL.GetCurrExrateData(billcust, billcurr, exratestr, custgroup); if (exrateList.Count == 0) { var modb = new ModelObjectDB(); var headdata = ChsettlementDAL.GetData(" BILLNO='" + billno + "'", CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])); DBResult result = ChsettlementDAL.AddBillStl(billno, billcust, billcurr, feesql, exrateList, Convert.ToString(Session["COMPANYID"]),headdata,custgroup,ShenNo); if (result.Success) { ChsettlementDAL.p_update_Amount(billno, billtype); } 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(); var headdata = ChsettlementDAL.GetData(" BILLNO='" + billno + "'", CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])); DBResult result = ChsettlementDAL.AddBillStl(billno, billcust, billcurr, feesql, exrateList, Convert.ToString(Session["COMPANYID"]), headdata, custgroup, ShenNo); if (result.Success) { ChsettlementDAL.p_update_Amount(billno, billtype); } 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, int billtype, bool custgroup = false) { var exrateList = JsonConvert.Deserialize>(storeCurrExrate); if ((exrateList == null) || (exrateList.Count == 0)) { exrateList = ChsettlementDAL.GetCurrExrateData(billcust, billcurr, feesql, custgroup); if (exrateList.Count == 0) { var modb = new ModelObjectDB(); DBResult result = ChsettlementDAL.AddBill(billno, billcust, billcurr, feesql, exrateList, CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), custgroup); if (result.Success) { ChsettlementDAL.p_update_Amount(billno, billtype); } 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 = ChsettlementDAL.AddBill(billno, billcust, billcurr, feesql, exrateList, CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])); if (result.Success) { ChsettlementDAL.p_update_Amount(billno,billtype); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } public ContentResult DelBill(string data, string billno,int billtype) { var bodyList = JsonConvert.Deserialize>(data); DBResult result = ChsettlementDAL.DelFeeDo(bodyList); ChsettlementDAL.p_update_Amount(billno, billtype); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } // public ContentResult Delete(string data, int settlemode) { var headData = JsonConvert.Deserialize(data); var result = new DBResult(); var period = ChMonthCloseDAL.GetData("", Convert.ToString(Session["COMPANYID"])); if (Convert.ToDateTime(period.FDAY) > Convert.ToDateTime(headData.SETTLETIME)) { result.Success = false; result.Message = "本期已月末结账,无法删除此单据!"; } else result.Success = true; T_ALL_DA T_ALL_DA = new T_ALL_DA(); var strCT = T_ALL_DA.GetStrSQL("CT", "select COUNT(*) CT from cw_vouno_bs_gl where BSGID='" + headData.GID + "'"); if (strCT != "0" && strCT != "") { result.Success = false; result.Message = "已生成凭证,无法删除此单据!"; } if (result.Success == true) { if (settlemode == 3) { var dataList = ChsettlementDAL.GetPayInvDetailList(headData.BILLNO); result = ChsettlementDAL.DelPayInvAppStl(dataList, headData.BILLNO); } else { var dataList = ChsettlementDAL.GetPayDetailList(headData.BILLNO); result = ChsettlementDAL.DelAppStl(dataList, headData.BILLNO); } var dataList2 = ChsettlementDAL.GetBodyList("BILLNO='" + headData.BILLNO + "'"); result = ChsettlementDAL.DelFeeDo(dataList2); } if (result.Success == true) { var APDList = CWAdvancePaymentDAL.GetBodyList2(" SETTLEBILLNO='"+headData.BILLNO+"'"); result = ChsettlementDAL.DelPaymentDo(APDList); } if (result.Success == true) { var modb = new ModelObjectDB(); modb.Delete(headData); MsSysBillNoSetDAL.DeleteBsNo(headData.BILLNO); ChsettlementDAL.DelRemit(headData.BILLNO); 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 DeleteRecv(string data, int settlemode) { var headData = JsonConvert.Deserialize(data); var result = new DBResult(); var period = ChMonthCloseDAL.GetData("", Convert.ToString(Session["COMPANYID"])); if (Convert.ToDateTime(period.FDAY) > Convert.ToDateTime(headData.SETTLETIME)) { result.Success = false; result.Message = "本期已月末结账,无法删除此单据!"; } else result.Success = true; T_ALL_DA T_ALL_DA = new T_ALL_DA(); var strCT = T_ALL_DA.GetStrSQL("CT", "select COUNT(*) CT from cw_vouno_bs_gl where BSGID='" + headData.GID + "'"); if (strCT != "0" && strCT != "") { result.Success = false; result.Message = "已生成凭证,无法删除此单据!"; } if (result.Success == true) { if (settlemode == 1) { var dataList = ChsettlementDAL.GetRecvDetailList(headData.BILLNO); result = ChsettlementDAL.DelRecvAppStl(dataList, headData.BILLNO); } else if (settlemode == 3) { var dataList = ChsettlementDAL.GetRecvInvDetailList(headData.BILLNO); result = ChsettlementDAL.DelRecvInvAppStl(dataList, headData.BILLNO); } else { var dataList = ChsettlementDAL.GetBodyList("BILLNO='" + headData.BILLNO + "'"); result = ChsettlementDAL.DelFeeDo(dataList); } } if (result.Success == true) { var APDList = CWAdvancePaymentDAL.GetBodyList2(" SETTLEBILLNO='" + headData.BILLNO + "'"); result = ChsettlementDAL.DelPaymentDo(APDList); } if (result.Success == true) { var modb = new ModelObjectDB(); modb.Delete(headData); 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) }; } #region 锁定和撤销锁定 public ContentResult Lock(string bill, string remark) { DBResult result = ChsettlementDAL.Lock(bill,remark); var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } public ContentResult UnLock(string bill) { var result = new DBResult(); T_ALL_DA T_ALL_DA = new T_ALL_DA(); var strCT = T_ALL_DA.GetStrSQL("CT", "select COUNT(*) CT from cw_vouno_bs_gl where BSGID in (SELECT GID FROM ch_fee_settlement WHERE BILLNO='" + bill + "')"); if (strCT != "0" && strCT != "") { result.Success = false; result.Message = "已生成凭证,无法解锁此单据!"; } var strCT2 = T_ALL_DA.GetStrSQL("CT", "select COUNT(*) CT from op_sale_tc where BSNO in (SELECT BSNO FROM ch_fee_do WHERE BILLNO='" + bill + "')"); if (strCT2 != "0" && strCT2 != "") { result.Success = false; result.Message = "相关业务已发放提成,无法解锁此单据!"; } result = ChsettlementDAL.UnLock(bill); var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } public ContentResult LockList(string bills) { DBResult result = ChsettlementDAL.LockList(bills); var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } public ContentResult UnLockList(string bills) { DBResult result = ChsettlementDAL.UnLockList(bills); var json = JsonConvert.Serialize(result); return new ContentResult() { Content = json }; } #endregion #region 付费申请结算 public ContentResult GetPayList(int start, int limit, string sort, string condition) { var dataList = ChsettlementDAL.GetPayDataList(condition,CookieConfig.GetCookie_UserId(Request), 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 GetPayDCList(int start, int limit, string sort, string condition) { var dataList = ChsettlementDAL.GetPayDCDataList(condition, CookieConfig.GetCookie_UserId(Request), 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 GetPaydetailList(string billno) { var dataList = ChsettlementDAL.GetPayDetailList(billno); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetAppBodyList(string condition, string sort) { var dataList = ChsettlementDAL.GetAppBodyList(condition,sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult AddAppDetail(string bill, string data, string curr, int billtype) { var bodyList = JsonConvert.Deserialize>(data); var modb = new ModelObjectDB(); DBResult result = ChsettlementDAL.AddAppDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"])); if (result.Success) { ChsettlementDAL.p_update_Amount(bill, billtype); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult AddAppDCDetail(string bill, string data, string curr, string storeCurrExrate, int billtype, string addcurr) { var exrateList = JsonConvert.Deserialize>(storeCurrExrate); var bodyList = JsonConvert.Deserialize>(data); var isAuditExrate = false; var PAYAUDITEXRATE = MsSysParamSetDAL.GetData("PARAMNAME='PAYAUDITEXRATE'"); if (PAYAUDITEXRATE.PARAMVALUE == "1") isAuditExrate = true; if (((exrateList == null) || (exrateList.Count == 0)) && (addcurr !=curr)) { exrateList = ChsettlementDAL.GetAppCurrExrateData(bodyList, curr, addcurr, isAuditExrate); if (exrateList.Count == 0) { var modb = new ModelObjectDB(); DBResult result = ChsettlementDAL.AddAppDCDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]), addcurr, exrateList, isAuditExrate); if (result.Success) { ChsettlementDAL.p_update_Amount(bill, billtype); } if (isAuditExrate) { decimal stlamount = 0; decimal stlrate = 0; string stlcurr = ""; if (bodyList != null) { foreach (var enumValue in bodyList) { stlamount = stlamount + enumValue.AUDITSTLAMOUNT; stlcurr = enumValue.AUDITSTLCURR; stlrate = enumValue.AUDITSTLRATE; } } if (stlamount != 0) { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); if (stlamount > 0) { var blUpSQL1 = " update ch_fee_settlement set AHSR_CURRENCY='" + stlcurr + "',AHSR_RATE=" + stlrate.ToString() + ",AHSR_MONEY=" + stlamount.ToString() + ",FINANCIAL_MONEY=ACCOUNTS_MONEY-" + stlamount.ToString() + " where BILLNO='" + bill + "' "; bool bl1 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL1); } else { var blUpSQL1 = " update ch_fee_settlement set AHSR_CURRENCY='" + stlcurr + "',AHSR_RATE=" + stlrate.ToString() + ",AHSR_MONEY=" + stlamount.ToString() + ",FINANCIAL_MONEY=ACCOUNTS_MONEY+" +Math.Abs(stlamount).ToString() + " where BILLNO='" + bill + "' "; bool bl1 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL1); } } } 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 = ChsettlementDAL.AddAppDCDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]), addcurr, exrateList, isAuditExrate); if (result.Success) { ChsettlementDAL.p_update_Amount(bill, billtype); } if (isAuditExrate) { decimal stlamount = 0; decimal stlrate = 0; string stlcurr = ""; if (bodyList != null) { foreach (var enumValue in bodyList) { stlamount = stlamount + enumValue.AUDITSTLAMOUNT; stlcurr = enumValue.AUDITSTLCURR; stlrate = enumValue.AUDITSTLRATE; } } if (stlamount != 0) { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); if (stlamount > 0) { var blUpSQL1 = " update ch_fee_settlement set AHSR_CURRENCY='" + stlcurr + "',AHSR_RATE=" + stlrate.ToString() + ",AHSR_MONEY=" + stlamount.ToString() + ",FINANCIAL_MONEY=ACCOUNTS_MONEY-" + stlamount.ToString() + " where BILLNO='" + bill + "' "; bool bl1 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL1); } else { var blUpSQL1 = " update ch_fee_settlement set AHSR_CURRENCY='" + stlcurr + "',AHSR_RATE=" + stlrate.ToString() + ",AHSR_MONEY=" + stlamount.ToString() + ",FINANCIAL_MONEY=ACCOUNTS_MONEY+" + Math.Abs(stlamount).ToString() + " where BILLNO='" + bill + "' "; bool bl1 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL1); } } } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } public ContentResult DelAppBill(string data, string billno, int billtype) { var bodyList = JsonConvert.Deserialize>(data); DBResult result = ChsettlementDAL.DelAppStl(bodyList,billno); if (result.Success) { ChsettlementDAL.p_update_Amount(billno, billtype); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion #region 收费申请结算 public ContentResult GetRecvList(int start, int limit, string sort, string condition) { var dataList = ChsettlementDAL.GetRecvDataList(condition, CookieConfig.GetCookie_UserId(Request), 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 GetRecvDCList(int start, int limit, string sort, string condition) { var dataList = ChsettlementDAL.GetRecvDCDataList(condition, CookieConfig.GetCookie_UserId(Request), 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 GetRecvdetailList(string billno) { var dataList = ChsettlementDAL.GetRecvDetailList(billno); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult AddRecvAppDetail(string bill, string data, string curr, int billtype) { var bodyList = JsonConvert.Deserialize>(data); var modb = new ModelObjectDB(); DBResult result = ChsettlementDAL.RecvAddAppDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"])); if (result.Success) { ChsettlementDAL.p_update_Amount(bill, billtype); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult AddRecvAppDCDetail(string bill, string data, string curr, string storeCurrExrate, int billtype, string addcurr) { var exrateList = JsonConvert.Deserialize>(storeCurrExrate); var bodyList = JsonConvert.Deserialize>(data); if (((exrateList == null) || (exrateList.Count == 0))&& (addcurr != curr)) { exrateList = ChsettlementDAL.GetAppCurrExrateData(bodyList, curr, addcurr); if (exrateList.Count == 0) { var modb = new ModelObjectDB(); DBResult result = ChsettlementDAL.AddRecvAppDCDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]), addcurr, exrateList); if (result.Success) { ChsettlementDAL.p_update_Amount(bill, billtype); } 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 = ChsettlementDAL.AddRecvAppDCDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]), addcurr, exrateList); if (result.Success) { ChsettlementDAL.p_update_Amount(bill, billtype); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } public ContentResult DelRecvAppBill(string data, string billno, int billtype) { var bodyList = JsonConvert.Deserialize>(data); DBResult result = ChsettlementDAL.DelRecvAppStl(bodyList, billno); if (result.Success) { ChsettlementDAL.p_update_Amount(billno, billtype); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion #region 付费发票结算 public ContentResult GetPayInvList(int start, int limit, string sort, string condition) { var dataList = ChsettlementDAL.GetPayInvDataList(condition, CookieConfig.GetCookie_UserId(Request), 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 GetPayInvdetailList(string billno) { var dataList = ChsettlementDAL.GetPayInvDetailList(billno); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult AddPayInvAppDetail(string bill, string data, string curr, int billtype) { var bodyList = JsonConvert.Deserialize>(data); var modb = new ModelObjectDB(); DBResult result = ChsettlementDAL.PayInvAddAppDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"])); if (result.Success) { ChsettlementDAL.p_update_Amount(bill, billtype); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult DelPayInvAppBill(string data, string billno, int billtype) { var bodyList = JsonConvert.Deserialize>(data); DBResult result = ChsettlementDAL.DelPayInvAppStl(bodyList, billno); if (result.Success) { ChsettlementDAL.p_update_Amount(billno, billtype); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion #region 收费发票结算 public ContentResult GetRecvInvList(int start, int limit, string sort, string condition) { var dataList = ChsettlementDAL.GetRecvInvDataList(condition, CookieConfig.GetCookie_UserId(Request), 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 GetRecvInvdetailList(string billno) { var dataList = ChsettlementDAL.GetRecvInvDetailList(billno); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult AddRecvInvAppDetail(string bill, string data, string curr, string storeCurrExrate, int billtype) { var bodyList = JsonConvert.Deserialize>(data); var exrateList = JsonConvert.Deserialize>(storeCurrExrate); var result = new DBResult(); if (((exrateList == null) || (exrateList.Count == 0))) { exrateList = ChsettlementDAL.GetInvCurrExrateData(bodyList, curr); if (exrateList.Count == 0) { var modb = new ModelObjectDB(); var STLINVPART = MsSysParamSetDAL.GetData("PARAMNAME='STLINVPART'"); if (STLINVPART.PARAMVALUE == "1") { result = ChsettlementDAL.NewRecvInvAddAppDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]), exrateList); } else result = ChsettlementDAL.RecvInvAddAppDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]), exrateList); if (result.Success) { ChsettlementDAL.p_update_Amount(bill, billtype); } 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(); var STLINVPART = MsSysParamSetDAL.GetData("PARAMNAME='STLINVPART'"); if (STLINVPART.PARAMVALUE == "1") { result = ChsettlementDAL.NewRecvInvAddAppDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]), exrateList); } else result = ChsettlementDAL.RecvInvAddAppDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]), exrateList); if (result.Success) { ChsettlementDAL.p_update_Amount(bill, billtype); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } public ContentResult DelRecvInvAppBill(string data, string billno, int billtype) { var bodyList = JsonConvert.Deserialize>(data); DBResult result = ChsettlementDAL.DelRecvInvAppStl(bodyList, billno); if (result.Success) { ChsettlementDAL.p_update_Amount(billno, billtype); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion #region 预收预付 public ContentResult GetAdvancePayment(int start, int limit, string sort, string condition) { var dataList = ChsettlementDAL.GetAPDataList(condition); var list = dataList.Skip(start).Take(limit); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetAPBodyList(string condition) { var dataList = ChsettlementDAL.GetAPBodyList(condition); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult AddAPDetail(string billno, string data, string stlnogid, int feetype) { var bodyList = JsonConvert.Deserialize>(data); var modb = new ModelObjectDB(); DBResult result = ChsettlementDAL.AddAPDetail(billno, bodyList, stlnogid, feetype, CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["COMPANYID"])); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult DelAPBill(string data) { var bodyList = JsonConvert.Deserialize>(data); DBResult result = ChsettlementDAL.DelPaymentDo(bodyList); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion #region 汇兑损益 public ContentResult GetRemitList(string condition, string sort, string printstr) { if ((!string.IsNullOrEmpty(printstr)) && (printstr == "true")) { var strSql = new StringBuilder(); strSql.Append("SELECT r.GID,r.BILLNO,r.BSNO,r.CUSTNO,r.MBLNO,r.HBLNO,r.CUSTOMERNAME,r.SALE"); strSql.Append(",r.REMITTANCE,r.REMITTANCEAMOUNT,r.BUYRATE,r.SELLRATE,r.SETTLRATE,r.FEEID,r.FEENAME"); strSql.Append(",r.CURRENCY,r.AMOUNT,r.BILLSTATUS,r.REMARK,r.CREATETIME,r.COMPANYID,r.FEETYPE"); strSql.Append(",CASE r.FEETYPE WHEN 1 THEN '收' ELSE '付' END FEETYPEREF,s.SETTLETIME,s.CUSTOMERNAME CUSTNAME "); strSql.Append(" from ch_fee_settlement_remittance r left join ch_fee_settlement s on (s.BILLNO=r.BILLNO) "); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" WHERE " + condition); } var sortstring = DatasetSort.Getsortstring(sort); if (!string.IsNullOrEmpty(sortstring)) { strSql.Append(" order by " + sortstring); } else { strSql.Append(" order by r.BILLNO,r.CUSTNO "); } var jsonRespose = new JsonResponse { Success = true, Message = "完成", Data = strSql.ToString() }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var dataList = ChsettlementDAL.GetRemitList(condition, sort); var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } } public ContentResult DeleteRemit(string data) { var headData = JsonConvert.Deserialize < List>(data); DBResult result; var billno = ""; if (headData != null) { foreach (var enumValue in headData) { var modb = new ModelObjectDB(); result = modb.Delete(enumValue); billno = enumValue.BILLNO; } } ChsettlementDAL.p_update_Remit(billno); var jsonRespose = new JsonResponse { Success =true, Message ="删除成功!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SaveRemit(string billno,string body) { var chfeeBodyList = JsonConvert.Deserialize>(body); var chfeeDelBodyList = JsonConvert.Deserialize>(""); var modb = new ModelObjectRepository(); DBResult result = modb.SaveComm("BILLNO", billno, ModelObjectConvert.ToModelObjectList(chfeeBodyList), ModelObjectConvert.ToModelObjectList(chfeeDelBodyList) ); if (result.Success) { ChsettlementDAL.p_update_Remit(billno); } //刷新父窗口上的父节点 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 UpdateNotVou(string data, bool isnot) { var headList = JsonConvert.Deserialize>(data); var result = ChsettlementDAL.UpdateNotVou(headList, isnot); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult GetDefaulExrate(string billno,string curr) { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); var EXCHANGERATE = T_ALL_DA.GetStrSQL("EXCHANGERATE", "select top 1 EXCHANGERATE FROM CH_FEE WHERE CURRENCY='" + curr + "' AND GID IN (SELECT FEEID FROM CH_FEE_DO WHERE BILLNO='" + billno + "')"); var jsonRespose = new JsonResponse { Success = true, Message = "", Data = EXCHANGERATE }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #region 参照部分 #endregion #region 生成总账凭证 public ContentResult GetCodeCurrencyList(string strGids) { var dataList = ChsettlementDAL.GetCodeCurrencyList(strGids, Convert.ToString(Session["COMPANYID"]), CookieConfig.GetCookie_UserId(Request)); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult onAddCwVouchers(string strGids, string dataDiv, string jsonBody) { var headData = JsonConvert.Deserialize(dataDiv); List bodyList = new List(); if (jsonBody != null) { bodyList = JsonConvert.Deserialize>(jsonBody); } if (bodyList == null && headData.ISRATE == false) { headData.ISRATE = true; } // DBResult result2 = ChsettlementDAL.GetIsVoucher(strGids, CookieConfig.GetCookie_UserId(Request)); if (!result2.Success) { var jsonRespose2 = new JsonResponse { Success = result2.Success, Message = result2.Message, Data = "" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } // DBResult result = ChsettlementDAL.onAddCwVouchers(strGids, headData, bodyList, CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); // string sGids = "'" + strGids.Trim().Replace(",", "','") + "'"; T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(CookieConfig.GetCookie_UserId(Request)); string sVOUCHERNO = T_ALL_DA.GetStrSQL("ORDNO", "select top 1 ORDNO from cw_vouno_bs_gl where bsgid in (" + sGids + ") and STARTGID='" + strCwSTARTGID + "'"); // var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = sVOUCHERNO }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult GetIsVoucher(string strGids) { DBResult result = ChsettlementDAL.GetIsVoucher(strGids, CookieConfig.GetCookie_UserId(Request)); var jsonRespose = new JsonResponse{ Success = result.Success, Message = result.Message, Data = "" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } /// /// 是否自动弹出结算总账凭证 /// /// public ContentResult onIsSettlementsopen() { DBResult result = ChsettlementDAL.onIsSettlementsopen(CookieConfig.GetCookie_UserId(Request)); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = "" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion #region 生成接口凭证 public ContentResult onAddCwVouchersJK(string strGids, string dataDiv, string jsonBody) { DBResult result2 = ChsettlementDAL.GetIsVoucherJK(strGids); if (!result2.Success) { var jsonRespose2 = new JsonResponse { Success = result2.Success, Message = result2.Message, Data = "" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; } // var headData = JsonConvert.Deserialize(dataDiv); DBResult result = ChsettlementDAL.onAddCwVouchersJK(strGids, headData, CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); // string sGids = "'" + strGids.Trim().Replace(",", "','") + "'"; T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string sVOUNO = T_ALL_DA.GetStrSQL("VOUNO", "select top 1 VOUNO from ch_fee_settlement where gid in (" + sGids + ")"); // var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = sVOUNO }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult GetIsVoucherJK(string strGids) { DBResult result = ChsettlementDAL.GetIsVoucherJK(strGids); var jsonRespose = new JsonResponse{ Success = result.Success, Message = result.Message, Data = "" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult GetCodeCurrencyListJK(string sVOUDATE) { var dataList = ChsettlementDAL.GetCodeCurrencyListJK(sVOUDATE, 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 onIsSettlementsopenJK() { DBResult result = ChsettlementDAL.onIsSettlementsopenJK(); var jsonRespose = new JsonResponse{ Success = result.Success, Message = result.Message, Data = "" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion } }