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

764 lines
36 KiB
C#

This file contains ambiguous Unicode characters!

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

using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.Areas.Account.DAL.Chfee_Invoiceapplication;
using DSWeb.Areas.Account.Models.Chfee_Invoiceapplication;
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.MvcShipping.DAL.MsSysParamSet;
using System.Data;
using DSWeb.MvcShipping.DAL.MsCodeGoodInv;
using DSWeb.MvcShipping.DAL.MsChFeeDAL;
namespace DSWeb.Areas.Account.Controllers
{
[JsonRequestBehavior]
public class Chfee_invoiceapplicationController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
public ActionResult TruckIndex()
{
return View();
}
//
// GET: /
public ActionResult Edit()
{
return View();
}
public ActionResult BLEdit()
{
return View();
}
public ActionResult TruckBLEdit()
{
return View();
}
//付费申请审核
public ActionResult Audit()
{
return View();
}
public ActionResult Index_Hangxin()
{
return View();
}
//
// GET
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
int totel = 0;
var dataList = ChinvoiceapplicationDAL.GetDataList(start, limit,condition,out totel,Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = totel, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetAuditDataList(int start, int limit, string sort, string condition, string isaudit)
{
var dataList = ChinvoiceapplicationDAL.GetAuditDataList(condition, Convert.ToString(Session["USERID"]), isaudit, 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 GetData(string handle, string condition)
{
ChInvoiceapplication head = null;
if (handle == "edit")
{
var list = ChinvoiceapplicationDAL.GetDataListAll(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]));
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new ChInvoiceapplication();
}
if (handle == "add")
{
head.APPLICANT = CookieConfig.GetCookie_CompanyId(Request);
head.APPLICANTNAME =CookieConfig.GetCookie_UserName(Request);
head.CURRENCY = "RMB";//20191024 币别固化为RMB
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetDetailList(string condition,string sort)
{
var dataList = ChinvoiceapplicationDAL.GetDetailList(condition,sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetBillList(string condition,string sort)
{
var dataList = ChinvoiceapplicationDAL.GetBodyList(condition,sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetTruckBillList(string condition, string sort)
{
var dataList = ChinvoiceapplicationDAL.GetTruckBodyList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetBillDataList(int start, int limit, string sort, string condition)
{
var dataList = ChinvoiceapplicationDAL.GetAddBillList(start, limit,condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
int count = ChinvoiceapplicationDAL.getAddBillTotalCount(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", totalCount = count, data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetTruckBillDataList(int start, int limit, string sort, string condition)
{
var dataList = ChinvoiceapplicationDAL.GetAddTruckBillList(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
int count = ChinvoiceapplicationDAL.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)
{
var dataList = ChinvoiceapplicationDAL.GetFeeDetailList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetBillSum(string condition)
{
var dataList = ChinvoiceapplicationDAL.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)
{
var dataList = ChinvoiceapplicationDAL.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 GetAddSum(string condition)
{
var dataList = ChinvoiceapplicationDAL.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, string body,bool issubmit=false)
{
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<ChInvoiceapplication>(data);
var bodyList = JsonConvert.Deserialize<List<ChInvoiceDetail>>(body);
if (opstatus == "add")
{
headData.GID = Guid.NewGuid().ToString();
//headData.BILLNO = PubSysDAL.GetBillNo("0306");
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='发票申请'", CookieConfig.GetCookie_CompanyId(Request));
if (billnoset.BILLTYPE != "")
headData.BILLNO = MsSysBillNoSetDAL.GetBillNo(billnoset, headData.APPLYTIME.ToString().Trim(), headData.ENTERTIME.ToString());
else
headData.BILLNO = PubSysDAL.GetBillNo("0306");
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
var ct = ChinvoiceapplicationDAL.GetRdCount("GID<>'" + headData.GID + "' AND BILLNO='" + headData.BILLNO + "' ");
if (ct != 0)
{
var jsonRespose0 = new JsonResponse
{
Success = false,
Message = "发票申请重复,不允许保存!"
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose0) };
}
headData.OPERATETIME = DateTime.Now;
T_ALL_DA T_ALL_DA = new T_ALL_DA();
DataSet dsHSCODE = T_ALL_DA.GetAllSQL("SELECT Gid,CODENAME as CustCode,SHORTNAME as CustName,CODENAME+'-'+SHORTNAME as CodeAndName,BillRises1,INVADDRTEL,[DESCRIPTION],RmbBillRises,(select top 1 BANKNAME+' '+ACCOUNT FROM info_client_bank WHERE CURRENCY='RMB' AND LINKID=info_client.GID) Rmbbank,Rmbaccount,usdBillRises,(select top 1 BANKNAME+' '+ACCOUNT FROM info_client_bank WHERE CURRENCY='USD' AND LINKID=info_client.GID) usdbank,usdaccount,TaxNo,Addr,Tel from info_client WHERE SHORTNAME='" + headData.CUSTOMERNAME + "'");
if (dsHSCODE != null)
{
if (dsHSCODE.Tables[0].Rows.Count > 0)
{
if (headData.INVOICECUSTNAME == "")
{
if (dsHSCODE.Tables[0].Rows[0]["BillRises1"].ToString() != "")
headData.INVOICECUSTNAME = dsHSCODE.Tables[0].Rows[0]["BillRises1"].ToString();
else headData.INVOICECUSTNAME = dsHSCODE.Tables[0].Rows[0]["DESCRIPTION"].ToString();
}
if (headData.CUSTRATENO == "") headData.CUSTRATENO = dsHSCODE.Tables[0].Rows[0]["TaxNo"].ToString();
if (headData.CUSTADDRTEL == "") {
if (dsHSCODE.Tables[0].Rows[0]["INVADDRTEL"].ToString() != "")
headData.CUSTADDRTEL = dsHSCODE.Tables[0].Rows[0]["INVADDRTEL"].ToString();
else headData.CUSTADDRTEL = dsHSCODE.Tables[0].Rows[0]["Addr"].ToString() + " " + dsHSCODE.Tables[0].Rows[0]["Tel"].ToString();
}
if (headData.CUSTBANK == "")
{
if (headData.RECVCURR == "USD")
{
headData.CUSTBANK = dsHSCODE.Tables[0].Rows[0]["usdbank"].ToString();
}
else headData.CUSTBANK = dsHSCODE.Tables[0].Rows[0]["rmbbank"].ToString();
}
}
}
var BILLNO = headData.BILLNO;
var GID = headData.GID;
var modb = new ModelObjectDB();
DBResult result = ChinvoiceapplicationDAL.SaveInvDetail(headData.GID,bodyList);
if (result.Success==true){
result= modb.Save(headData);
};
if (result.Success == true) { }
else
{
MsSysBillNoSetDAL.DeleteBsNo(headData.BILLNO);
}
if ((result.Success == true)&&(issubmit==true)) {
//系统参数如果设置为【开票分部与业务分部相同则不需要审核】则做判断是否进行审核
var dataList = ChinvoiceapplicationDAL.GetBodyList("BILLNO='" + BILLNO + "'", "");
if (dataList == null || dataList.Count == 0)
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "无费用明细不能提交审核!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
decimal invamount = 0;
var invitems = ChinvoiceapplicationDAL.GetDetailList("PID='" + headData.GID + "'", "");
foreach (var invitem in invitems)
{
invamount = invamount + invitem.AMOUNT + invitem.TAX;
}
if (invamount != headData.INVAMOUNT)
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "开票明细与开票金额不一致,请检查!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
var flag = MsSysParamSetDAL.GetData("PARAMNAME='InvoiceSameComSkipAudit'");
if (flag.PARAMVALUE == "1")
{
if (headData.COMPANYID == headData.PAYCOMPANYID && ((headData.ACTUALCUSTOMERNAME != "" && headData.ACTUALCUSTOMERNAME == headData.CUSTOMERNAME) || headData.ACTUALCUSTOMERNAME == ""))
{
result = ChinvoiceapplicationDAL.PASSAUDITWithGID(headData.GID);
}
else
{
result = ChinvoiceapplicationDAL.SubmitAudit("InvAudit", CookieConfig.GetCookie_UserId(Request), headData.BILLNO, CookieConfig.GetCookie_CompanyId(Request));
}
}
else
{
result = ChinvoiceapplicationDAL.SubmitAudit("InvAudit", CookieConfig.GetCookie_UserId(Request), headData.BILLNO, CookieConfig.GetCookie_CompanyId(Request));
}
}
// if (result.Success) { ChinvoiceapplicationDAL.p_update_Amount(BILLNO, GID); }
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = ChinvoiceapplicationDAL.GetData(" BILLNO='" + BILLNO + "'", CookieConfig.GetCookie_UserId(Request), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_CompanyId(Request))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult AddDetail(string bill, string data, string curr, bool islist, string GID, bool custgroup = false)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
var bodyList = JsonConvert.Deserialize<List<BillChfeeDetail>>(data);
var headData = ChinvoiceapplicationDAL.GetData(" BILLNO='" + bill + "'", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]));
var BLCOUNT="0";
var FEENOAUDITCANTSHENINV = MsSysParamSetDAL.GetData("PARAMNAME='FEENOAUDITCANTSHENINV'");
if (FEENOAUDITCANTSHENINV.PARAMVALUE == "1")
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select COUNT(*) BLCOUNT from ch_fee where FEETYPE=1 and (FEESTATUS=1 OR FEESTATUS=2 ) and BSNO='" + bodyList[0].BSNO + "'");
}
if (BLCOUNT != "0")
{
var jsonRespose = new JsonResponse { Success = false, Message = "此票存在未审核的应收费用,不允许申请发票!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var modb = new ModelObjectDB();
DBResult result = ChinvoiceapplicationDAL.AddDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]), islist, GID, headData);
if (result.Success) { ChinvoiceapplicationDAL.p_update_Amount(bill, GID); }
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 islist, string GID,bool custgroup = false)
{
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 exrateList = JsonConvert.Deserialize<List<ChFeeExrate>>(storeCurrExrate);
if (islist) {
var bodylist = ChinvoiceapplicationDAL.GetFeeDetailList(feesql + " and '代理'+FEENAME NOT IN (Select GOODNAME from code_goods_inv) ", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]));
if (bodylist.Count != 0) {
var feenamelist = "";
if (bodylist != null)
{
foreach (var enumValue in bodylist)
{
feenamelist = feenamelist + enumValue.FeeName+",";
}
}
if (feenamelist != "") {
var jsonRespose = new JsonResponse { Success = false, Message = "费用名称:"+feenamelist+"不在发票商品明细中,请先维护发票商品明细!"};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
}
var headData = ChinvoiceapplicationDAL.GetData(" BILLNO='" + billno + "'", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]));
if ((exrateList == null) || (exrateList.Count == 0))
{
exrateList = ChinvoiceapplicationDAL.GetCurrExrateData(billcust, billcurr, feesql, custgroup);
if (exrateList.Count == 0)
{
var modb = new ModelObjectDB();
DBResult result = ChinvoiceapplicationDAL.AddBill(billno, billcust, billcurr, feesql, exrateList, Convert.ToString(Session["COMPANYID"]), islist, GID,headData, custgroup, Convert.ToString(Session["USERID"]));
if (result.Success) { ChinvoiceapplicationDAL.p_update_Amount(billno, GID); }
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var INVGETNOWEXCHANGE = MsSysParamSetDAL.GetData("PARAMNAME='INVGETNOWEXCHANGE'").PARAMVALUE;
if (INVGETNOWEXCHANGE == "1")
{
var invratelist = MsChFeeDAL.GetFeeNowInvCurrList(headData.APPLYTIME);
if (invratelist != null)
{
foreach (var exrate in exrateList)
{
foreach (var invrate in invratelist)
{
if (invrate.CURR == exrate.CURR)
{
exrate.DFEXRATE = invrate.DEFRATE;
}
}
}
}
}
var jsonRespose = new JsonResponse { Success = true, Message = "查询成功", Data = exrateList.ToList() };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
else
{
var modb = new ModelObjectDB();
DBResult result = ChinvoiceapplicationDAL.AddBill(billno, billcust, billcurr, feesql, exrateList, Convert.ToString(Session["COMPANYID"]), islist, GID, headData,false,Convert.ToString(Session["USERID"]));
if (result.Success) { ChinvoiceapplicationDAL.p_update_Amount(billno, GID); }
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult DelBill(string data, string billno,string GID)
{
var bodyList = JsonConvert.Deserialize<List<Chfee_do_detail>>(data);
DBResult result = ChinvoiceapplicationDAL.DelFeeDo(bodyList,GID);
if (result.Success) { ChinvoiceapplicationDAL.p_update_Amount(billno,GID); }
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetIsAdd(string data)
{
var bodyList = JsonConvert.Deserialize<List<ChInvoiceapplication>>(data);
var StrGid = "";
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
if (StrGid == "")
StrGid = "'" + enumValue.GID + "'";
else
StrGid = StrGid + ",'" + enumValue.GID + "'";
}
}
if (StrGid != "")
{
StrGid = "(" + StrGid + ")";
var dataList = ChinvoiceapplicationDAL.GetDataListAll(" BILLSTATUS=0 and GID IN " + StrGid, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]));
if (dataList != null && dataList.Count != 0)
{
var jsonRespose = new JsonResponse { Success =true, Message ="可以生成!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = "发票申请已生成发票,请刷新!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = "无需要添加的发票申请!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
//
public ContentResult Delete(string data)
{
var headData = JsonConvert.Deserialize<ChInvoiceapplication>(data);
var dataList = ChinvoiceapplicationDAL.GetBodyList("BILLNO='" + headData.BILLNO + "'");
DBResult result = ChinvoiceapplicationDAL.DelFeeDo(dataList,headData.GID);
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 DelInvDetail(string billno, string body, string GID)
{
var bodyList = JsonConvert.Deserialize<List<ChInvoiceDetail>>(body);
DBResult result = ChinvoiceapplicationDAL.DelInvDetail(bodyList);
if (result.Success) { ChinvoiceapplicationDAL.p_update_Amount(billno, GID); }
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 = ChinvoiceapplicationDAL.GetData("BILLNO='"+bill+"'");
var INVAPPMAXPARAM = MsSysParamSetDAL.GetData("PARAMNAME='INVAPPMAX'");
var INVAPPMAX = false;
if (INVAPPMAXPARAM.PARAMVALUE == "1")
{
INVAPPMAX = true;
}
decimal invamount = 0;
var invitems=ChinvoiceapplicationDAL.GetDetailList("PID='"+headdata.GID+"'", "");
var dataList = ChinvoiceapplicationDAL.GetBodyList("BILLNO='" + bill + "'", "");
if (dataList == null|| dataList.Count == 0) {
var jsonRespose = new JsonResponse { Success = false, Message = "无费用明细不能提交审核!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
foreach (var invitem in invitems) {
invamount = invamount + invitem.AMOUNT+invitem.TAX;
}
if (invamount != headdata.INVAMOUNT) {
var jsonRespose = new JsonResponse { Success = false, Message = "开票明细与开票金额不一致,请检查!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
if (INVAPPMAX&&(headdata.INVAMOUNT >= 100000 || headdata.APPLYAMOUNT >= 100000)) {
var jsonRespose = new JsonResponse { Success =false, Message ="申请开票金额,不能超过十万元!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
//DBResult result = ChinvoiceapplicationDAL.SubmitAudit("InvAudit", Convert.ToString(Session["DEPTGID"]), Convert.ToString(Session["USERID"]), bill);
DBResult result = ChinvoiceapplicationDAL.SubmitAudit("InvAudit", Convert.ToString(Session["USERID"]), bill, CookieConfig.GetCookie_CompanyId(Request));
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult SubmitAuditBack(string bill)
{
DBResult result = ChinvoiceapplicationDAL.SubmitAuditBack("InvAudit", Convert.ToString(Session["USERID"]), bill);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult SubmitAuditList(string bills)
{
var INVAPPMAXPARAM = MsSysParamSetDAL.GetData("PARAMNAME='INVAPPMAX'");
var INVAPPMAX = false;
if (INVAPPMAXPARAM.PARAMVALUE == "1")
{
INVAPPMAX = true;
}
var billList = bills.Split(',');
foreach (var bill in billList)
{
var headdata = ChinvoiceapplicationDAL.GetData("BILLNO='" + bill + "'");
decimal invamount = 0;
var invitems = ChinvoiceapplicationDAL.GetDetailList("PID='" + headdata.GID + "'", "");
var dataList = ChinvoiceapplicationDAL.GetBodyList("BILLNO='" + bill + "'", "");
if (dataList == null || dataList.Count == 0)
{
var jsonRespose = new JsonResponse { Success = false, Message = "无费用明细不能提交审核!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
foreach (var invitem in invitems)
{
invamount = invamount + invitem.AMOUNT + invitem.TAX;
}
if (invamount != headdata.INVAMOUNT)
{
var jsonRespose = new JsonResponse { Success = false, Message = "开票明细与开票金额不一致,请检查!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
if (INVAPPMAX && (headdata.INVAMOUNT >= 100000 || headdata.APPLYAMOUNT >= 100000))
{
var jsonRespose = new JsonResponse { Success = false, Message = "申请开票金额,不能超过十万元!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
DBResult result = ChinvoiceapplicationDAL.SubmitAuditList("InvAudit", Convert.ToString(Session["USERID"]), bills);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult SubmitAuditBackList(string bills)
{
DBResult result = ChinvoiceapplicationDAL.SubmitAuditBackList("InvAudit", Convert.ToString(Session["USERID"]), bills);
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
public ContentResult AuditList(string data, string PAYCOMPANYID)
{
var bodyList = JsonConvert.Deserialize<List<ChInvoiceapplication>>(data);
DBResult result = ChinvoiceapplicationDAL.AuditList(bodyList,PAYCOMPANYID,Convert.ToString(Session["USERID"]));
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<List<ChInvoiceapplication>>(data);
DBResult result = ChinvoiceapplicationDAL.AuditBackList(bodyList, Convert.ToString(Session["USERID"]), reason);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
public ContentResult GetPrint(string billno)
{
DBResult result = ChinvoiceapplicationDAL.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_invoiceapplication set ISPRINT='1',PRINTCOUNT=ISNULL(PRINTCOUNT,0)+1 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_invoiceapplication set ISPRINT='0' 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) };
}
#region 参照部分
#endregion
}
}