using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Linq ;
using System.Text ;
using System.Web ;
using System.Web.Mvc ;
using DSWeb.MvcShipping.Helper ;
using DSWeb.MvcShipping.Comm.Cookie ;
using DSWeb.Areas.CommMng.DAL ;
using DSWeb.Areas.RptMng.Comm ;
using HcUtility.Comm ;
using HcUtility.Core ;
using Microsoft.Practices.EnterpriseLibrary.Data ;
using DSWeb.EntityDA ;
using DSWeb.Areas.CommMng.Models ;
using DSWeb.Areas.Account.Models.BSNOLB ;
using DSWeb.Areas.Account.Models.MsOpBill ;
using DSWeb.MvcShipping.DAL.ChMonthCloseDAL ;
using DSWeb.TruckMng.Comm.Cookie ;
using DSWeb.MvcShipping.DAL.MsSysParamSet ;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL ;
using DSWeb.Models ;
using DSWeb.SoftMng.Filter ;
using DSWeb.MvcShipping.Models.MsOpBillYj ;
using DSWeb.MvcShipping.DAL.MsChFeeDAL ;
using DSWeb.MvcShipping.DAL.MsCurrencyExchange ;
namespace DSWeb.Areas.Account.Controllers
{
/// <summary>
/// 业务费用封帐
/// </summary>
[JsonRequestBehavior]
public class Chfee_lockController : Controller
{
/ /
// GET:
//[ModuleAuthFilter(Name = "modBsLockBig")]//权限过滤器
public ActionResult Index ( )
{
return View ( ) ;
}
public ActionResult FeeLockIndex ( )
{
return View ( ) ;
}
public ActionResult Chfee_lockDetail ( )
{
return View ( ) ;
}
public ActionResult BsVoucherIndex ( )
{
return View ( ) ;
}
public ActionResult YjIndex ( )
{
return View ( ) ;
}
/ /
// GET:
public ContentResult BsListData ( int start , int limit , string condition , string sort , string type , string printstr )
{
var strDa = GetRangDAStr ( "index" , type , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
if ( ! string . IsNullOrEmpty ( strDa ) )
{
if ( ! string . IsNullOrEmpty ( condition ) )
{
condition = condition + " and " + strDa ;
}
else
{
condition = strDa ;
}
}
var PROFITRATEDR = MsSysParamSetDAL . GetData ( "PARAMNAME='PROFITRATEDR'" ) ;
var RPTPRNOCANCEL = MsSysParamSetDAL . GetData ( "PARAMNAME='RPTPRNOCANCEL'" ) ;
if ( RPTPRNOCANCEL . PARAMVALUE = = "1" )
{
if ( ! string . IsNullOrEmpty ( condition ) )
{
condition = condition + " and isnull(B.ISCANCEL,0)<>1 " ;
}
else
{
condition = " isnull(B.ISCANCEL,0)<>1 " ;
}
}
var isopenstr = "" ;
var isopen = MsBaseInfoDAL . GetUserModuleEnable ( "modFeenotopen" , Convert . ToString ( Session [ "USERID" ] ) ) ;
if ( isopen = = false )
{
isopenstr = " ( ENTEROPERATOR='" + Convert . ToString ( Session [ "USERID" ] ) + "' OR ( ENTEROPERATOR<>'" + Convert . ToString ( Session [ "USERID" ] ) + "' AND (ISOPEN=0 OR ISOPEN IS NULL))) " ;
}
var isacc = MsBaseInfoDAL . GetUserModuleEnable ( "modISWACC" , Convert . ToString ( Session [ "USERID" ] ) ) ;
var isaccstr = "" ;
if ( isacc = = false )
{
isaccstr = " ISNULL(ISACC,0)=0 " ;
if ( ! string . IsNullOrEmpty ( isopenstr ) )
isopenstr = isopenstr + " and " + isaccstr ;
else
isopenstr = isaccstr ;
}
var strSql = new StringBuilder ( ) ;
strSql . Append ( "SELECT B.BSNO, B.OPLB, B.OPTYPE,B.OPLBNAME,B.BLTYPE, B.BSTYPE,B.CUSTOMERNAME, B.CUSTNO, B.MBLNO, B.HBLNO,B.ORDERNO,B.VESSEL, B.VOYNO, B.INPUTBY, B.CREATETIME, B.BSSTATUS,B.FEESTATUS,B.SALE, B.OP, B.DOC" ) ;
strSql . Append ( ",case B.BSSTATUS when 1 then '已锁定' else '未锁定' end as BSSTATUSREF" ) ;
strSql . Append ( ",case B.FEESTATUS when 1 then '已锁定' else '未锁定' end as FEESTATUSREF" ) ;
strSql . Append ( ",case B.ETD when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.ETD,23) end as ETD,B.ETA" ) ;
strSql . Append ( ",case B.OPDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.OPDATE,23) end as OPDATE,B.ENTERP" ) ;
strSql . Append ( ",case B.CUSTOMDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.CUSTOMDATE,23) end as CUSTOMDATE,B.CARGOID,B.DCLASS" ) ;
strSql . Append ( ",B.CUSTSERVICE,B.FRCUSTSERVICE, B.PORTLOAD, B.PORTDISCHARGE, B.CUSTOMNO, B.ACCDATE,B.CARRIER, B.BSSOURCE,B.BSSOURCEDETAIL, B.LANE, B.FORWARDER,B.NETWEIGHT,B.KGS,B.TEU,B.CNTRTOTAL,B.CORPID" ) ;
strSql . Append ( ",B.CNTR1,B.CNTR2,B.CNTR3,B.CNTR4,B.CNTR5,B.CNTR6,B.CNTR7,B.CNTR8,B.CNTR9,B.CNTR10,B.OTCNTR,B.TRADETYPE,B.GOODSNAME,B.ISPRINTPR,B.REMARK,B.REMARK2,B.YARD,B.SALEDEPT" ) ;
strSql . Append ( ",G.RMBDR,G.RMBCR,G.STLRMBDR,G.STLRMBCR,G.USDDR,G.USDCR,G.STLUSDDR,G.STLUSDCR,G.OTDR,G.OTCR,G.STLOTDR,G.STLOTCR,G.TTLDR,G.TTLCR,G.STLTTLDR,G.STLTTLCR" ) ;
strSql . Append ( ",G.USDDR-G.USDCR AS USDPROFIT,G.RMBDR-G.RMBCR AS RMBPROFIT,G.OTDR-G.OTCR AS OTPROFIT,G.TTLDR-G.TTLCR AS TTLPROFIT,G.TTLINVDR,G.TTLDUIDR " ) ;
if ( PROFITRATEDR . PARAMVALUE ! = "1" )
{
strSql . Append ( ", (CASE WHEN (G.TTLDR)= 0 THEN '无法计算' ELSE ltrim(str((G.TTLDR-G.TTLCR) / (G.TTLDR) * 100, 10, 2)) + '%' END) AS PROFITRATE" ) ;
}
else
strSql . Append ( ", (CASE WHEN (G.TTLCR)= 0 THEN '无法计算' ELSE ltrim(str((G.TTLDR-G.TTLCR) / (G.TTLCR) * 100, 10, 2)) + '%' END) AS PROFITRATE" ) ;
strSql . Append ( ",(SELECT TOP 1 STATUS FROM OP_STATUS WHERE BSNO=B.BSNO ORDER BY COMPTIME DESC,INPUTTIME DESC) as OPSTATUS " ) ;
strSql . Append ( ",dbo.F_GetBillDrFeeStatus(B.BSNO) DRFEESTATUS" ) ;
strSql . Append ( ",dbo.F_GetBillCrFeeStatus(B.BSNO) CRFEESTATUS,B.CONTRACTNO,B.SERVICECONTRACTNO,C.BSCLOSETIME,C.BSCLOSEOP,C.FEECLOSETIME,C.FEECLOSEOP,B.ISVOU,B.VOUNO,B.BillFeeStatus " ) ;
strSql . Append ( ",ISNULL(C.ETDCLOSE,0) ETDCLOSE,ISNULL(C.DRCLOSE,0) DRCLOSE,ISNULL(C.CRCLOSE,0) CRCLOSE" ) ;
strSql . Append ( ",case ISNULL(C.ETDCLOSE,0) when 1 then '已锁定' else '未锁定' end as ETDCLOSEREF" ) ;
strSql . Append ( ",case ISNULL(C.DRCLOSE,0) when 1 then '已锁定' else '未锁定' end as DRCLOSEREF" ) ;
strSql . Append ( ",case ISNULL(C.CRCLOSE,0) when 1 then '已锁定' else '未锁定' end as CRCLOSEREF" ) ;
strSql . Append ( ",(select [NAME] from [company] where GID=B.SALECORPID) as SALECORP" ) ;
strSql . Append ( " FROM V_OP_BILL B " ) ;
strSql . Append ( " LEFT JOIN (SELECT BSNO,isnull(SUM(CASE FEETYPE WHEN 1 THEN(CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT, 0) ELSE 0 END) ELSE 0 END), 0) AS RMBDR," ) ;
strSql . Append ( "isnull(SUM(CASE FEETYPE WHEN 2 THEN(CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT, 0) ELSE 0 END) ELSE 0 END), 0) AS RMBCR," ) ;
strSql . Append ( "isnull(SUM(CASE FEETYPE WHEN 1 THEN(CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT, 0) ELSE 0 END) ELSE 0 END), 0) AS STLRMBDR," ) ;
strSql . Append ( "isnull(SUM(CASE FEETYPE WHEN 2 THEN(CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT, 0) ELSE 0 END) ELSE 0 END), 0) AS STLRMBCR," ) ;
strSql . Append ( "isnull(SUM(CASE FEETYPE WHEN 1 THEN(CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT, 0) ELSE 0 END) ELSE 0 END), 0) AS USDDR," ) ;
strSql . Append ( "isnull(SUM(CASE FEETYPE WHEN 2 THEN(CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT, 0) ELSE 0 END) ELSE 0 END), 0) AS USDCR," ) ;
strSql . Append ( "isnull(SUM(CASE FEETYPE WHEN 1 THEN(CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT, 0) ELSE 0 END) ELSE 0 END), 0) AS STLUSDDR," ) ;
strSql . Append ( "isnull(SUM(CASE FEETYPE WHEN 2 THEN(CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT, 0) ELSE 0 END) ELSE 0 END), 0) AS STLUSDCR," ) ;
strSql . Append ( "isnull(SUM(CASE FEETYPE WHEN 1 THEN(CASE CURRENCY WHEN 'USD' THEN 0 ELSE(CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT, 0) END) END) ELSE 0 END), 0) AS OTDR," ) ;
strSql . Append ( "isnull(SUM(CASE FEETYPE WHEN 2 THEN(CASE CURRENCY WHEN 'USD' THEN 0 ELSE(CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT, 0) END) END) ELSE 0 END), 0) AS OTCR," ) ;
strSql . Append ( "isnull(SUM(CASE FEETYPE WHEN 1 THEN(CASE CURRENCY WHEN 'USD' THEN 0 ELSE(CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT, 0) END) END) ELSE 0 END), 0) AS STLOTDR," ) ;
strSql . Append ( "isnull(SUM(CASE FEETYPE WHEN 2 THEN(CASE CURRENCY WHEN 'USD' THEN 0 ELSE(CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT, 0) END) END) ELSE 0 END), 0) AS STLOTCR," ) ;
strSql . Append ( "cast(round(isnull(SUM(CASE FEETYPE WHEN 1 THEN ISNULL(AMOUNT, 0) * ISNULL(EXCHANGERATE, 0) ELSE 0 END), 0), 2) as numeric(20, 2)) AS TTLDR," ) ;
strSql . Append ( "cast(round(isnull(SUM(CASE FEETYPE WHEN 2 THEN ISNULL(AMOUNT, 0) * ISNULL(EXCHANGERATE, 0) ELSE 0 END), 0), 2) as numeric(20, 2)) AS TTLCR," ) ;
strSql . Append ( "cast(round(isnull(SUM(CASE FEETYPE WHEN 1 THEN ISNULL(TAX, 0) * ISNULL(EXCHANGERATE, 0) ELSE 0 END), 0), 2) as numeric(20, 2)) AS TTLTAXDR," ) ;
strSql . Append ( "cast(round(isnull(SUM(CASE FEETYPE WHEN 2 THEN ISNULL(TAX, 0) * ISNULL(EXCHANGERATE, 0) ELSE 0 END), 0), 2) as numeric(20, 2)) AS TTLTAXCR," ) ;
strSql . Append ( "cast(round(isnull(SUM(CASE FEETYPE WHEN 1 THEN ISNULL(SETTLEMENT, 0) * ISNULL(EXCHANGERATE, 0) ELSE 0 END), 0), 2) as numeric(20, 2)) AS STLTTLDR," ) ;
strSql . Append ( "cast(round(isnull(SUM(CASE FEETYPE WHEN 2 THEN ISNULL(SETTLEMENT, 0) * ISNULL(EXCHANGERATE, 0) ELSE 0 END), 0), 2) as numeric(20, 2)) AS STLTTLCR," ) ;
strSql . Append ( "isnull(SUM(CASE FEETYPE WHEN 1 THEN(CASE CURRENCY WHEN 'RMB' THEN ISNULL(NOTAXAMOUNT, 0) ELSE 0 END) ELSE 0 END), 0) AS NOTAXRMBDR," ) ;
strSql . Append ( "isnull(SUM(CASE FEETYPE WHEN 2 THEN(CASE CURRENCY WHEN 'RMB' THEN ISNULL(NOTAXAMOUNT, 0) ELSE 0 END) ELSE 0 END), 0) AS NOTAXRMBCR," ) ;
strSql . Append ( "isnull(SUM(CASE FEETYPE WHEN 1 THEN(CASE CURRENCY WHEN 'USD' THEN ISNULL(NOTAXAMOUNT, 0) ELSE 0 END) ELSE 0 END), 0) AS NOTAXUSDDR," ) ;
strSql . Append ( "isnull(SUM(CASE FEETYPE WHEN 2 THEN(CASE CURRENCY WHEN 'USD' THEN ISNULL(NOTAXAMOUNT, 0) ELSE 0 END) ELSE 0 END), 0) AS NOTAXUSDCR," ) ;
strSql . Append ( "isnull(SUM(CASE FEETYPE WHEN 1 THEN(CASE CURRENCY WHEN 'USD' THEN 0 ELSE(CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(NOTAXAMOUNT, 0) END) END) ELSE 0 END), 0) AS NOTAXOTDR," ) ;
strSql . Append ( "isnull(SUM(CASE FEETYPE WHEN 2 THEN(CASE CURRENCY WHEN 'USD' THEN 0 ELSE(CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(NOTAXAMOUNT, 0) END) END) ELSE 0 END), 0) AS NOTAXOTCR," ) ;
strSql . Append ( "cast(round(isnull(SUM(CASE FEETYPE WHEN 1 THEN ISNULL(NOTAXAMOUNT, 0) * ISNULL(EXCHANGERATE, 0) ELSE 0 END), 0), 2) as numeric(20, 2)) AS NOTAXTTLDR," ) ;
strSql . Append ( "cast(round(isnull(SUM(CASE FEETYPE WHEN 2 THEN ISNULL(NOTAXAMOUNT, 0) * ISNULL(EXCHANGERATE, 0) ELSE 0 END), 0), 2) as numeric(20, 2)) AS NOTAXTTLCR" ) ;
strSql . Append ( ",isnull(SUM(CASE FEETYPE WHEN 1 THEN ISNULL(INVOICE,0) * ISNULL(EXCHANGERATE,0) ELSE 0 END),0) AS TTLINVDR" ) ;
strSql . Append ( ",cast(round(isnull(SUM(CASE WHEN FEETYPE=1 AND ISNULL(ISDEBIT,0)=1 THEN ISNULL(AMOUNT,0) * ISNULL(EXCHANGERATE,0) ELSE 0 END),0), 2) as numeric(20, 2)) AS TTLDUIDR" ) ;
if ( ! string . IsNullOrEmpty ( isopenstr ) )
strSql . Append ( " FROM ch_fee where FEESTATUS<>1 and " + isopenstr + " GROUP BY BSNO) G ON (G.BSNO=B.BSNO) " ) ;
else strSql . Append ( " FROM ch_fee where FEESTATUS<> 1 GROUP BY BSNO) G ON (G.BSNO=B.BSNO) " ) ;
strSql . Append ( "LEFT JOIN op_close c ON (c.BSNO=B.BSNO) " ) ;
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 B.CUSTOMERNAME,B.OPLB,B.CREATETIME DESC" ) ;
}
if ( ( ! string . IsNullOrEmpty ( printstr ) ) & & ( printstr = = "true" ) )
{
var jsonRespose = new JsonResponse
{
Success = true ,
Message = "完成" ,
Data = strSql . ToString ( )
} ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
else
{
var dbparams = new List < CustomDbParamter > ( ) ;
var paramps_sSQL = new CustomDbParamter ( ) ;
paramps_sSQL . ParameterName = "@sSQL" ;
paramps_sSQL . DbType = DbType . String ;
paramps_sSQL . Direction = ParameterDirection . Input ;
paramps_sSQL . Value = strSql . ToString ( ) ;
dbparams . Add ( paramps_sSQL ) ;
var dbRptResult = PubSysDAL . GetMsSqlPrcDataSet ( "sMsExesqlQry" , dbparams , "Result_Set" ) ;
var json = RptHelper . GetRptJsonResult ( start , limit , dbRptResult , "Result_Set" , true ) ;
return new ContentResult ( ) { Content = json } ;
}
}
public ContentResult BsYjListData ( int start , int limit , string condition , string sort , string type , string printstr )
{
var strDa = GetRangDAStr ( "index" , type , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
if ( ! string . IsNullOrEmpty ( strDa ) )
{
if ( ! string . IsNullOrEmpty ( condition ) )
{
condition = condition + " and " + strDa ;
}
else
{
condition = strDa ;
}
}
var RPTPRNOCANCEL = MsSysParamSetDAL . GetData ( "PARAMNAME='RPTPRNOCANCEL'" ) ;
if ( RPTPRNOCANCEL . PARAMVALUE = = "1" )
{
if ( ! string . IsNullOrEmpty ( condition ) )
{
condition = condition + " and isnull(B.ISCANCEL,0)<>1 " ;
}
else
{
condition = " isnull(B.ISCANCEL,0)<>1 " ;
}
}
var strSql = new StringBuilder ( ) ;
strSql . Append ( "SELECT B.BSNO, B.OPLB, B.OPTYPE,B.OPLBNAME, B.BSTYPE,B.BLTYPE, B.CUSTOMERNAME, B.CUSTNO, B.MBLNO,B.CNTRTOTAL, B.HBLNO,B.VESSEL, B.VOYNO,B.LANE, B.SALE, B.OP, B.DOC" ) ;
strSql . Append ( ",C.YJSALEREMARK REMARK,B.REMARK2 REMARK2,B.BLFRT,B.CARRIER,B.BillFeeStatus" ) ;
strSql . Append ( ",case B.FEESTATUS when 1 then '已锁定' else '未锁定' end as FEESTATUSREF" ) ;
strSql . Append ( ",case B.ETD when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.ETD,23) end as ETD" ) ;
strSql . Append ( ",B.PORTDISCHARGE,B.DESTINATION,B.ACCDATE,B.CARRIER, B.BSSOURCE,B.BSSOURCEDETAIL,G.USDDR,G.USDCR,G.USDPROFIT,CASE WHEN C.YJSTATUS='审核通过' THEN G.USDPROFIT ELSE G.USDPROFIT-C.AMOUNT END AUSDPROFIT" ) ;
strSql . Append ( ",C.YJSTATUS,C.YJREMARK,C.INPUTDATE,C.INPUTBY,C.FCOP,c.AUDITDATE,c.AUDITBY,c.ORDERAMOUNT,c.CUSTOMERNAME CUSTNAME,c.AMOUNT,ISNULL(c.CURRENCY,'USD') CURRENCY,c.CUSTOMERNAME2,c.AMOUNT2,B.STLNAME" ) ;
strSql . Append ( " FROM V_OP_BILL B " ) ;
strSql . Append ( " LEFT JOIN (SELECT BSNO," ) ;
strSql . Append ( "isnull(SUM(CASE FEETYPE WHEN 1 THEN(CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT, 0) ELSE 0 END) ELSE 0 END), 0) AS USDDR," ) ;
strSql . Append ( "isnull(SUM(CASE FEETYPE WHEN 2 THEN(CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT, 0) ELSE 0 END) ELSE 0 END), 0) AS USDCR," ) ;
strSql . Append ( "isnull(SUM(CASE CURRENCY WHEN 'USD' THEN(CASE FEETYPE WHEN 1 THEN ISNULL(AMOUNT, 0) ELSE ISNULL(-AMOUNT, 0) END) ELSE 0 END), 0) AS USDPROFIT" ) ;
strSql . Append ( " FROM ch_fee where FEESTATUS<> 1 GROUP BY BSNO) G ON (G.BSNO=B.BSNO) " ) ;
strSql . Append ( "LEFT JOIN op_yj c ON (c.BSNO=B.BSNO) " ) ;
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 B.CUSTOMERNAME,B.OPLB,B.CREATETIME DESC" ) ;
}
if ( ( ! string . IsNullOrEmpty ( printstr ) ) & & ( printstr = = "true" ) )
{
var jsonRespose = new JsonResponse
{
Success = true ,
Message = "完成" ,
Data = strSql . ToString ( )
} ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
else
{
var dbparams = new List < CustomDbParamter > ( ) ;
var paramps_sSQL = new CustomDbParamter ( ) ;
paramps_sSQL . ParameterName = "@sSQL" ;
paramps_sSQL . DbType = DbType . String ;
paramps_sSQL . Direction = ParameterDirection . Input ;
paramps_sSQL . Value = strSql . ToString ( ) ;
dbparams . Add ( paramps_sSQL ) ;
var dbRptResult = PubSysDAL . GetMsSqlPrcDataSet ( "sMsExesqlQry" , dbparams , "Result_Set" ) ;
var json = RptHelper . GetRptJsonResult ( start , limit , dbRptResult , "Result_Set" , true ) ;
return new ContentResult ( ) { Content = json } ;
}
}
public ContentResult SaveYj ( string data )
{
var bodyList = JsonConvert . Deserialize < List < MsOpBillYj > > ( data ) ;
DBResult result = SaveYj ( bodyList , Convert . ToString ( Session [ "SHOWNAME" ] ) ) ;
var jsonRespose = new JsonResponse { Success = result . Success , Message = result . Message } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
public static DBResult SaveYj ( List < MsOpBillYj > boday , String USERNAME )
{
var result = new DBResult ( ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
if ( boday ! = null )
{
var cmdInsert =
db . GetSqlStringCommand (
@ "insert into op_yj (GID,BSNO,YJSTATUS,YJREMARK,INPUTDATE,INPUTBY,FCOP,ORDERAMOUNT,CUSTOMERNAME,AMOUNT,CURRENCY,CUSTOMERNAME2,AMOUNT2,YJSALEREMARK)
values ( @GID , @BSNO , @YJSTATUS , @YJREMARK , @INPUTDATE , @INPUTBY , @FCOP , @ORDERAMOUNT , @CUSTOMERNAME , @AMOUNT , @CURRENCY , @CUSTOMERNAME2 , @AMOUNT2 , @YJSALEREMARK ) ");
var cmddelete =
db . GetSqlStringCommand (
@"delete from op_yj where BSNO=@BSNO " ) ;
foreach ( var enumValue in boday )
{
cmddelete . Parameters . Clear ( ) ;
db . AddInParameter ( cmddelete , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmddelete , tran ) ;
cmdInsert . Parameters . Clear ( ) ;
if ( enumValue . YJSTATUS = = "" ) enumValue . YJSTATUS = "录入状态" ;
if ( enumValue . AMOUNT = = 0 ) enumValue . AMOUNT = enumValue . ORDERAMOUNT ;
db . AddInParameter ( cmdInsert , "@GID" , DbType . String , Guid . NewGuid ( ) . ToString ( ) ) ;
db . AddInParameter ( cmdInsert , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . AddInParameter ( cmdInsert , "@YJSTATUS" , DbType . String , enumValue . YJSTATUS ) ;
db . AddInParameter ( cmdInsert , "@YJREMARK" , DbType . String , enumValue . YJREMARK ) ;
db . AddInParameter ( cmdInsert , "@FCOP" , DbType . String , enumValue . FCOP ) ;
db . AddInParameter ( cmdInsert , "@ORDERAMOUNT" , DbType . Decimal , enumValue . ORDERAMOUNT ) ;
db . AddInParameter ( cmdInsert , "@CUSTOMERNAME" , DbType . String , enumValue . CUSTNAME ) ;
db . AddInParameter ( cmdInsert , "@AMOUNT" , DbType . Decimal , enumValue . AMOUNT ) ;
db . AddInParameter ( cmdInsert , "@CURRENCY" , DbType . String , enumValue . CURRENCY ) ;
db . AddInParameter ( cmdInsert , "@CUSTOMERNAME2" , DbType . String , enumValue . CUSTOMERNAME2 ) ;
db . AddInParameter ( cmdInsert , "@AMOUNT2" , DbType . Decimal , enumValue . AMOUNT2 ) ;
db . AddInParameter ( cmdInsert , "@INPUTDATE" , DbType . DateTime , DateTime . Now ) ;
db . AddInParameter ( cmdInsert , "@INPUTBY" , DbType . String , USERNAME ) ;
db . AddInParameter ( cmdInsert , "@YJSALEREMARK" , DbType . String , enumValue . REMARK ) ;
db . ExecuteNonQuery ( cmdInsert , tran ) ;
}
}
result = new DBResult ( ) ;
result . Success = true ;
result . Message = "更新完成" ;
tran . Commit ( ) ;
}
catch ( Exception )
{
tran . Rollback ( ) ;
result . Success = false ;
result . Message = "设置出现错误,请重试或联系系统管理员" ;
return result ;
}
}
result . Success = true ;
result . Message = "更新完成" ;
return result ;
}
public ContentResult AuditYj ( string data )
{
var bodyList = JsonConvert . Deserialize < List < MsOpBillYj > > ( data ) ;
DBResult result = AuditYj ( bodyList , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
var jsonRespose = new JsonResponse { Success = result . Success , Message = result . Message } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
public static DBResult AuditYj ( List < MsOpBillYj > boday , String USERNAME , string userid , string companyid )
{
var result = new DBResult ( ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
if ( boday ! = null )
{
var cmdInsert =
db . GetSqlStringCommand (
@"update op_yj set AMOUNT=@AMOUNT,YJSTATUS=@YJSTATUS,AUDITBY=@AUDITBY,AUDITDATE=@AUDITDATE WHERE BSNO=@BSNO " ) ;
var cmdInsertFee =
db . GetSqlStringCommand (
@ "INSERT INTO ch_fee(GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY,
EXCHANGERATE , REASON , REMARK , COMMISSIONRATE , ENTEROPERATOR , ENTERDATE , ISOPEN , ISADVANCEDPAY , SORT , FEESTATUS , FEEFRT , CARGO_GID ,
TAXRATE , NOTAXAMOUNT , ACCTAXRATE , LINENUM , TAXUNITPRICE , MODIFIEDUSER , MODIFIEDTIME , WMSOUTBSNO , PREAMOUNT , ISINVOICE , INPUTMODE , LOCALCURR , MANAGER , ISACC , AUDITOPERATOR , AUDITDATE )
VALUES ( @GID , @BSNO , @FEETYPE , @FEENAME , @FEEDESCRIPTION , @CUSTOMERTYPE , @CUSTOMERNAME , @UNIT , @UNITPRICE , @QUANTITY , @AMOUNT , @CURRENCY ,
@EXCHANGERATE , @REASON , @REMARK , @COMMISSIONRATE , @ENTEROPERATOR , @ENTERDATE , @ISOPEN , @ISADVANCEDPAY , @SORT , @FEESTATUS , @FEEFRT , @CARGO_GID ,
@TAXRATE , @NOTAXAMOUNT , @ACCTAXRATE , @LINENUM , @TAXUNITPRICE , @MODIFIEDUSER , @MODIFIEDTIME , @WMSOUTBSNO , @PREAMOUNT , @ISINVOICE , @INPUTMODE , @LOCALCURR , @MANAGER , @ISACC , @AUDITOPERATOR , @AUDITDATE )
");
var YJFEENAME = MsSysParamSetDAL . GetData ( "PARAMNAME='YJFEENAME'" ) . PARAMVALUE ;
foreach ( var enumValue in boday )
{
db . AddInParameter ( cmdInsert , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . AddInParameter ( cmdInsert , "@AMOUNT" , DbType . Decimal , enumValue . AMOUNT ) ;
db . AddInParameter ( cmdInsert , "@YJSTATUS" , DbType . String , "审核通过" ) ;
db . AddInParameter ( cmdInsert , "@AUDITDATE" , DbType . DateTime , DateTime . Now ) ;
db . AddInParameter ( cmdInsert , "@AUDITBY" , DbType . String , USERNAME ) ;
db . ExecuteNonQuery ( cmdInsert , tran ) ;
cmdInsertFee . Parameters . Clear ( ) ;
db . AddInParameter ( cmdInsertFee , "@GID" , DbType . String , Guid . NewGuid ( ) . ToString ( ) ) ;
db . AddInParameter ( cmdInsertFee , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . AddInParameter ( cmdInsertFee , "@FEETYPE" , DbType . Int16 , 2 ) ;
db . AddInParameter ( cmdInsertFee , "@UNITPRICE" , DbType . Decimal , enumValue . AMOUNT ) ;
db . AddInParameter ( cmdInsertFee , "@AMOUNT" , DbType . Decimal , enumValue . AMOUNT ) ;
db . AddInParameter ( cmdInsertFee , "@NOTAXAMOUNT" , DbType . Decimal , enumValue . AMOUNT ) ;
db . AddInParameter ( cmdInsertFee , "@TAXUNITPRICE" , DbType . Decimal , enumValue . AMOUNT ) ;
db . AddInParameter ( cmdInsertFee , "@FEENAME" , DbType . String , YJFEENAME ) ;
db . AddInParameter ( cmdInsertFee , "@FEEDESCRIPTION" , DbType . String , "" ) ;
db . AddInParameter ( cmdInsertFee , "@CUSTOMERTYPE" , DbType . String , "代理" ) ;
db . AddInParameter ( cmdInsertFee , "@CUSTOMERNAME" , DbType . String , enumValue . CUSTNAME ) ;
db . AddInParameter ( cmdInsertFee , "@UNIT" , DbType . String , "票" ) ;
db . AddInParameter ( cmdInsertFee , "@QUANTITY" , DbType . Decimal , 1 ) ;
db . AddInParameter ( cmdInsertFee , "@CURRENCY" , DbType . String , enumValue . CURRENCY ) ;
if ( enumValue . CURRENCY = = "RMB" )
{
db . AddInParameter ( cmdInsertFee , "@EXCHANGERATE" , DbType . Decimal , 1 ) ;
}
else {
var FeecurrList = MsChFeeDAL . GetFeeDateCurrList ( "" , enumValue . BSNO , userid , companyid ) ;
var feecurr = FeecurrList . Find ( x = > x . CURR = = enumValue . CURRENCY ) ;
if ( feecurr . CRDEFRATE ! = 0 ) db . AddInParameter ( cmdInsertFee , "@EXCHANGERATE" , DbType . Decimal , feecurr . CRDEFRATE ) ;
else db . AddInParameter ( cmdInsertFee , "@EXCHANGERATE" , DbType . Decimal , feecurr . DEFRATE ) ;
}
db . AddInParameter ( cmdInsertFee , "@REASON" , DbType . String , "" ) ;
db . AddInParameter ( cmdInsertFee , "@REMARK" , DbType . String , "" ) ;
db . AddInParameter ( cmdInsertFee , "@COMMISSIONRATE" , DbType . Decimal , 0 ) ;
db . AddInParameter ( cmdInsertFee , "@ENTEROPERATOR" , DbType . String , userid ) ;
db . AddInParameter ( cmdInsertFee , "@ENTERDATE" , DbType . String , DateTime . Now . ToString ( ) ) ;
db . AddInParameter ( cmdInsertFee , "@ISOPEN" , DbType . Boolean , true ) ;
db . AddInParameter ( cmdInsertFee , "@ISADVANCEDPAY" , DbType . Boolean , false ) ;
db . AddInParameter ( cmdInsertFee , "@SORT" , DbType . Int16 , 1 ) ;
db . AddInParameter ( cmdInsertFee , "@FEESTATUS" , DbType . Int16 , 0 ) ;
db . AddInParameter ( cmdInsertFee , "@FEEFRT" , DbType . String , "PP" ) ;
db . AddInParameter ( cmdInsertFee , "@CARGO_GID" , DbType . String , "" ) ;
db . AddInParameter ( cmdInsertFee , "@TAXRATE" , DbType . Decimal , 0 ) ;
db . AddInParameter ( cmdInsertFee , "@ACCTAXRATE" , DbType . Decimal , 0 ) ;
db . AddInParameter ( cmdInsertFee , "@LINENUM" , DbType . Int16 , 1 ) ;
db . AddInParameter ( cmdInsertFee , "@MODIFIEDUSER" , DbType . String , userid ) ;
db . AddInParameter ( cmdInsertFee , "@MODIFIEDTIME" , DbType . String , DateTime . Now . ToString ( ) ) ;
db . AddInParameter ( cmdInsertFee , "@WMSOUTBSNO" , DbType . String , "" ) ;
db . AddInParameter ( cmdInsertFee , "@PREAMOUNT" , DbType . Decimal , 0 ) ;
db . AddInParameter ( cmdInsertFee , "@ISINVOICE" , DbType . Boolean , false ) ;
db . AddInParameter ( cmdInsertFee , "@INPUTMODE" , DbType . String , "" ) ;
db . AddInParameter ( cmdInsertFee , "@LOCALCURR" , DbType . String , "RMB" ) ;
db . AddInParameter ( cmdInsertFee , "@MANAGER" , DbType . String , "" ) ;
db . AddInParameter ( cmdInsertFee , "@ISACC" , DbType . Boolean , false ) ;
db . AddInParameter ( cmdInsertFee , "@AUDITOPERATOR" , DbType . String , userid ) ;
db . AddInParameter ( cmdInsertFee , "@AUDITDATE" , DbType . String , DateTime . Now . ToString ( ) ) ;
db . ExecuteNonQuery ( cmdInsertFee , tran ) ;
}
}
result = new DBResult ( ) ;
result . Success = true ;
result . Message = "审核完成" ;
tran . Commit ( ) ;
}
catch ( Exception e )
{
tran . Rollback ( ) ;
result . Success = false ;
result . Message = "设置出现错误,请重试或联系系统管理员" + e . Message ;
return result ;
}
}
result . Success = true ;
result . Message = "审核完成" ;
return result ;
}
public static string GetRangDAStr ( string tb , string type , string userid , string usercode , string companyid )
{
string str = "" ;
var strSql = new StringBuilder ( ) ;
strSql . Append ( "SELECT " ) ;
strSql . Append ( " VISIBLERANGE,OPERATERANGE,AUTHORITYID,VSSQL " ) ;
strSql . Append ( " from VW_User_Authority " ) ;
//strSql.Append(" where [NAME]='modBlockBSSTATUS' and USERID='" + userid + "' and ISDELETE=0");
if ( type = = "BS" )
{
strSql . Append ( " where [NAME]='modBlockBSSTATUS' and USERID='" + userid + "' and ISDELETE=0" ) ;
}
else if ( type = = "FEE" )
{
strSql . Append ( " where [NAME]='modBlockFEESTATUS' and USERID='" + userid + "' and ISDELETE=0" ) ;
}
else if ( type = = "BSVOUCHER" )
{
strSql . Append ( " where [NAME]='modBSVOUCHER' and USERID='" + userid + "' and ISDELETE=0" ) ;
}
else if ( type = = "YJFEE" )
{
var YJFeeConnectOPSeae = MsSysParamSetDAL . GetData ( "PARAMNAME='YJFeeConnectOPSeae'" ) ;
if ( YJFeeConnectOPSeae . PARAMVALUE = = "0" )
{
strSql . Append ( " where [NAME]='modYJFEE' and USERID='" + userid + "' and ISDELETE=0" ) ;
}
else
{
strSql . Append ( " where [NAME]='modOrderManagement' and USERID='" + userid + "' and ISDELETE=0" ) ;
}
}
string visiblerange = "4" ;
string operaterange = "4" ;
string AUTHORITYID = "" ;
string VSSQL = "" ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
while ( reader . Read ( ) )
{
visiblerange = Convert . ToString ( reader [ "VISIBLERANGE" ] ) ;
operaterange = Convert . ToString ( reader [ "OPERATERANGE" ] ) ;
AUTHORITYID = Convert . ToString ( reader [ "AUTHORITYID" ] ) ;
VSSQL = Convert . ToString ( reader [ "VSSQL" ] ) ;
break ;
}
reader . Close ( ) ;
}
if ( visiblerange = = "4" )
{
str = "1=2" ;
}
else if ( visiblerange = = "3" )
{
// str = " (B.OP='" + usercode + "' OR B.SALE='" + usercode + "')";
str = " (B.OP='" + usercode + "' OR B.SALE='" + usercode + "' OR B.CUSTSERVICE = '" + usercode + "')" ;
}
else if ( visiblerange = = "2" )
{
if ( tb = = "index" )
{
var rangeDa = new RangeDA ( ) ;
var deptname = rangeDa . GetDEPTNAME ( userid ) ;
var userstr = new StringBuilder ( ) ;
userstr . Append ( " select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')" ) ;
Database userdb = DatabaseFactory . CreateDatabase ( ) ;
using ( IDataReader reader = userdb . ExecuteReader ( CommandType . Text , userstr . ToString ( ) ) )
{
str = "" ;
while ( reader . Read ( ) )
{
if ( str = = "" )
{
str = " (B.OP='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "' OR B.SALE='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "'" ;
}
else
{
str = str + " or B.OP='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "' OR B.SALE='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "'" ;
} ;
}
str = str + ")" ;
reader . Close ( ) ;
}
}
else
{
str = " UPPER(B.Corpid)='" + companyid + "'" ;
}
}
else if ( visiblerange = = "5" )
{
var userstr = new StringBuilder ( ) ;
userstr . Append ( " select COMPANYID from user_authority_range_company where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1" ) ;
Database userdb = DatabaseFactory . CreateDatabase ( ) ;
using ( IDataReader reader = userdb . ExecuteReader ( CommandType . Text , userstr . ToString ( ) ) )
{
str = "" ;
while ( reader . Read ( ) )
{
if ( str = = "" )
{
str = " (B.Corpid='" + Convert . ToString ( reader [ "COMPANYID" ] ) + "'" ;
}
else
{
str = str + " or B.Corpid='" + Convert . ToString ( reader [ "COMPANYID" ] ) + "'" ;
} ;
}
str = str + ")" ;
reader . Close ( ) ;
}
}
else if ( visiblerange = = "6" )
{
var userstr = new StringBuilder ( ) ;
userstr . Append ( " select OPID,(select SHOWNAME from [user] where GID=user_authority_range_op.OPID) SHOWNAME from user_authority_range_op where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1" ) ;
Database userdb = DatabaseFactory . CreateDatabase ( ) ;
using ( IDataReader reader = userdb . ExecuteReader ( CommandType . Text , userstr . ToString ( ) ) )
{
str = "" ;
while ( reader . Read ( ) )
{
if ( str = = "" )
{
str = " (B.OP='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "' OR B.SALE='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "' OR B.CUSTSERVICE='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "' OR B.INPUTBY='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "' OR B.DOC='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "'" ;
}
else
{
str = str + " or B.OP='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "' OR B.SALE='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "' OR B.CUSTSERVICE='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "' OR B.INPUTBY='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "' OR B.DOC='" + Convert . ToString ( reader [ "SHOWNAME" ] ) + "'" ;
} ;
}
str = str + ")" ;
reader . Close ( ) ;
}
}
else if ( visiblerange = = "1" )
{
str = " UPPER(B.Corpid)='" + companyid + "'" ;
}
VSSQL = VSSQL . Trim ( ) ;
if ( ! string . IsNullOrEmpty ( VSSQL ) )
{
if ( ! string . IsNullOrEmpty ( str ) )
{
str = str + " and (" + VSSQL + ") " ;
}
else
{
str = " (" + VSSQL + ") " ;
}
}
return str ;
}
#region ETD、应收、应付锁定
public ContentResult SelBsLock ( string data , string type )
{
var billData = JsonConvert . Deserialize < List < BSNOLB > > ( data ) ;
var json = JsonConvert . Serialize ( new { Success = true , Message = "锁定成功" } ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
var i = 0 ;
var j = 0 ;
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
foreach ( var enumValue in billData )
{
if ( type = = "ETD" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"if (select bsno from op_close where bsno='" + enumValue . BSNO + "') is null insert into op_close values(newid(),'" + enumValue . BSNO + "',null,null,null,null,1"
+ ",null,null) else update op_close set ETDCLOSE=1"
+ " where BSNO='" + enumValue . BSNO + "' " ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( type = = "应收" )
{
var FeeCount = db . ExecuteScalar ( CommandType . Text , "SELECT COUNT(GID) as FeeCount from ch_fee where FEETYPE=1 AND FEESTATUS NOT IN (0,8,9) and BSNO='" + enumValue . BSNO + "'" ) ;
var IntFeeCount = Convert . ToInt16 ( FeeCount ) ;
if ( IntFeeCount = = 0 )
{
var cmdUpdate = db . GetSqlStringCommand (
@"if (select bsno from op_close where bsno='" + enumValue . BSNO + "') is null insert into op_close values(newid(),'" + enumValue . BSNO + "',null,null,null,null,null"
+ ",1,null) else update op_close set DRCLOSE=1"
+ " where BSNO='" + enumValue . BSNO + "' " ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
}
else if ( type = = "应付" )
{
var FeeCount = db . ExecuteScalar ( CommandType . Text , "SELECT COUNT(GID) as FeeCount from ch_fee where FEETYPE=2 AND FEESTATUS NOT IN (0,8,9) and BSNO='" + enumValue . BSNO + "'" ) ;
var IntFeeCount = Convert . ToInt16 ( FeeCount ) ;
if ( IntFeeCount = = 0 )
{
var cmdUpdate = db . GetSqlStringCommand (
@"if (select bsno from op_close where bsno='" + enumValue . BSNO + "') is null insert into op_close values(newid(),'" + enumValue . BSNO + "',null,null,null,null,null"
+ ",null,1) else update op_close set CRCLOSE=1"
+ " where BSNO='" + enumValue . BSNO + "' " ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
}
}
var msg = "锁定成功" ;
json = JsonConvert . Serialize ( new { Success = true , Message = msg } ) ;
tran . Commit ( ) ;
}
catch ( Exception )
{
tran . Rollback ( ) ;
json = JsonConvert . Serialize ( new { Success = false , Message = "锁定失败" } ) ;
}
}
return new ContentResult ( ) { Content = json } ;
}
public ContentResult BsLockAll ( string billsql , string type )
{
var billData = GetFeeDataList ( billsql , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) , "BS" ) ;
var json = JsonConvert . Serialize ( new { Success = true , Message = "锁定成功" } ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
var i = 0 ;
var j = 0 ;
var msg = "锁定成功" ;
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
foreach ( var enumValue in billData )
{
if ( type = = "ETD" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"if (select bsno from op_close where bsno='" + enumValue . BSNO + "') is null insert into op_close values(newid(),'" + enumValue . BSNO + "',null,null,null,null,1"
+ ",null,null) else update op_close set ETDCLOSE=1"
+ " where BSNO='" + enumValue . BSNO + "' " ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( type = = "应收" )
{
var FeeCount = db . ExecuteScalar ( CommandType . Text , "SELECT COUNT(GID) as FeeCount from ch_fee where FEETYPE=1 AND FEESTATUS NOT IN (0,8,9) and BSNO='" + enumValue . BSNO + "'" ) ;
var IntFeeCount = Convert . ToInt16 ( FeeCount ) ;
if ( IntFeeCount = = 0 )
{
var cmdUpdate = db . GetSqlStringCommand (
@"if (select bsno from op_close where bsno='" + enumValue . BSNO + "') is null insert into op_close values(newid(),'" + enumValue . BSNO + "',null,null,null,null,null"
+ ",1,null) else update op_close set DRCLOSE=1"
+ " where BSNO='" + enumValue . BSNO + "' " ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
}
else if ( type = = "应付" )
{
var FeeCount = db . ExecuteScalar ( CommandType . Text , "SELECT COUNT(GID) as FeeCount from ch_fee where FEETYPE=2 AND FEESTATUS NOT IN (0,8,9) and BSNO='" + enumValue . BSNO + "'" ) ;
var IntFeeCount = Convert . ToInt16 ( FeeCount ) ;
if ( IntFeeCount = = 0 )
{
var cmdUpdate = db . GetSqlStringCommand (
@"if (select bsno from op_close where bsno='" + enumValue . BSNO + "') is null insert into op_close values(newid(),'" + enumValue . BSNO + "',null,null,null,null,null"
+ ",null,1) else update op_close set CRCLOSE=1"
+ " where BSNO='" + enumValue . BSNO + "' " ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
}
}
json = JsonConvert . Serialize ( new { Success = true , Message = msg } ) ;
tran . Commit ( ) ;
}
catch ( Exception )
{
tran . Rollback ( ) ;
json = JsonConvert . Serialize ( new { Success = false , Message = "锁定失败" } ) ;
}
}
return new ContentResult ( ) { Content = json } ;
}
public ContentResult SelBsUnLock ( string data , string type )
{
var billData = JsonConvert . Deserialize < List < BSNOLB > > ( data ) ;
var json = JsonConvert . Serialize ( new { Success = true , Message = "取消锁定成功" } ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
var i = 0 ;
var j = 0 ;
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
foreach ( var enumValue in billData )
{
if ( type = = "ETD" )
{
var cmdUpdate = db . GetSqlStringCommand (
@" update op_close set ETDCLOSE=0"
+ " where BSNO='" + enumValue . BSNO + "' " ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( type = = "应收" )
{
var cmdUpdate = db . GetSqlStringCommand (
@" update op_close set DRCLOSE=0"
+ " where BSNO='" + enumValue . BSNO + "' " ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( type = = "应付" )
{
var cmdUpdate = db . GetSqlStringCommand (
@" update op_close set CRCLOSE=0"
+ " where BSNO='" + enumValue . BSNO + "' " ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
updateUnclose ( enumValue . BSNO , type ) ;
}
var msg = "" ;
json = JsonConvert . Serialize ( new { Success = true , Message = msg } ) ;
tran . Commit ( ) ;
}
catch ( Exception )
{
tran . Rollback ( ) ;
json = JsonConvert . Serialize ( new { Success = false , Message = "锁定失败" } ) ;
}
}
return new ContentResult ( ) { Content = json } ;
}
public ContentResult BsLockUnAll ( string billsql , string type )
{
var billData = GetFeeDataList ( billsql , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) , "BS" ) ;
var json = JsonConvert . Serialize ( new { Success = true , Message = "锁定成功" } ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
var i = 0 ;
var j = 0 ;
var msg = "" ;
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
foreach ( var enumValue in billData )
{
if ( type = = "ETD" )
{
if ( enumValue . ETDCLOSEREF = = "已锁定" )
{
var cmdUpdate = db . GetSqlStringCommand (
@" update op_close set ETDCLOSE=0"
+ " where BSNO='" + enumValue . BSNO + "' " ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
updateUnclose ( enumValue . BSNO , type . ToString ( ) ) ;
}
}
else if ( type = = "应收" & & enumValue . DRCLOSEREF = = "已锁定" )
{
var cmdUpdate = db . GetSqlStringCommand (
@" update op_close set DRCLOSE=0"
+ " where BSNO='" + enumValue . BSNO + "' " ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
updateUnclose ( enumValue . BSNO , type . ToString ( ) ) ;
}
else if ( type = = "应付" & & enumValue . CRCLOSEREF = = "已锁定" )
{
var cmdUpdate = db . GetSqlStringCommand (
@" update op_close set CRCLOSE=0"
+ " where BSNO='" + enumValue . BSNO + "' " ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
updateUnclose ( enumValue . BSNO , type . ToString ( ) ) ;
}
}
json = JsonConvert . Serialize ( new { Success = true , Message = msg } ) ;
tran . Commit ( ) ;
}
catch ( Exception )
{
tran . Rollback ( ) ;
json = JsonConvert . Serialize ( new { Success = false , Message = "锁定失败" } ) ;
}
}
return new ContentResult ( ) { Content = json } ;
}
# endregion
public ContentResult SelLock ( string data , int type )
{
var FEELOCKUPDATEEXCHANGE = MsSysParamSetDAL . GetData ( "PARAMNAME='FEELOCKUPDATEEXCHANGE'" ) ;
var billData = JsonConvert . Deserialize < List < BSNOLB > > ( data ) ;
var json = JsonConvert . Serialize ( new { Success = true , Message = "锁定成功" } ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
var i = 0 ;
var j = 0 ;
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
foreach ( var enumValue in billData )
{
if ( type = = 2 )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET BSSTATUS=1 WHERE BSNO=@BSNO " ) ;
//2017年4月10日16:50:29 需求编号:SR2017041000009
//Start
if ( enumValue . OPLB . Equals ( "tMsWlPcHead" ) )
{
cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET BillStatus=1 WHERE gid=@BSNO " ) ;
}
//End
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
updateclose ( enumValue . BSNO , type ) ;
i = i + 1 ;
}
else if ( type = = 1 )
{
var FeeCount = db . ExecuteScalar ( CommandType . Text , "SELECT COUNT(GID) as FeeCount from ch_fee where FEESTATUS NOT IN (0,8,9) and BSNO='" + enumValue . BSNO + "'" ) ;
var IntFeeCount = Convert . ToInt16 ( FeeCount ) ;
if ( IntFeeCount = = 0 )
{
if ( enumValue . OPLB = = "tMsWlPcHead" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=1 WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
} else if ( enumValue . OPLB = = "WMS" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=1,ISLOCK2=1 WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( enumValue . OPLB = = "WMS_IN" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE WMS SET FEESTATUS=1,ISLOCK2=1 WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( enumValue . OPLB = = "WMS_OUT" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=1 WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else {
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=1 WHERE BSNO=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
var cmdUpdateamend = db . GetSqlStringCommand (
@"UPDATE OP_AMEND SET FEESTATUS=1 WHERE BSNO=@BSNO " ) ;
cmdUpdateamend . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdateamend , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdateamend , tran ) ;
i = i + 1 ;
updateclose ( enumValue . BSNO , type ) ;
if ( FEELOCKUPDATEEXCHANGE . PARAMVALUE = = "1" ) {
updateexchange ( enumValue . BSNO , enumValue . ACCDATE ) ;
}
}
else { j = j + 1 ; }
}
}
var msg = "" ;
if ( type = = 2 )
{
msg = "成功锁定" + i . ToString ( ) + "票业务!" ;
}
else if ( type = = 1 )
{
msg = "成功锁定" + i . ToString ( ) + "票业务费用锁定," + j . ToString ( ) + "票业务未锁定!" ;
}
json = JsonConvert . Serialize ( new { Success = true , Message = msg } ) ;
tran . Commit ( ) ;
}
catch ( Exception )
{
tran . Rollback ( ) ;
json = JsonConvert . Serialize ( new { Success = false , Message = "锁定失败" } ) ;
}
}
return new ContentResult ( ) { Content = json } ;
}
public ContentResult SelFeeLock ( string data , string isAccDate , string AccDate , string isbslock = "0" )
{
var FEELOCKUPDATEEXCHANGE = MsSysParamSetDAL . GetData ( "PARAMNAME='FEELOCKUPDATEEXCHANGE'" ) ;
var billData = JsonConvert . Deserialize < List < BSNOLB > > ( data ) ;
var json = JsonConvert . Serialize ( new { Success = true , Message = "锁定成功" } ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
var i = 0 ;
var j = 0 ;
var accdatesqlstr = "" ;
var sqlstr = "" ;
var pcsqlstr = "" ;
var wmssqlstr = "" ;
if ( isAccDate = = "1" ) accdatesqlstr = ",ACCDATE='" + AccDate + "'" ;
if ( isbslock = = "1" )
{
pcsqlstr = ",BillStatus=1 " ;
wmssqlstr = ",ISLOCK=1 " ;
sqlstr = ",BSSTATUS=1 " ;
}
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
foreach ( var enumValue in billData )
{
var FeeCount = db . ExecuteScalar ( CommandType . Text , "SELECT COUNT(GID) as FeeCount from ch_fee where FEESTATUS NOT IN (0,8,9) and BSNO='" + enumValue . BSNO + "'" ) ;
var IntFeeCount = Convert . ToInt16 ( FeeCount ) ;
if ( IntFeeCount = = 0 )
{
//if (isAccDate == "1")
//{
// var cmdUpdate = db.GetSqlStringCommand(
// @"UPDATE " + enumValue.OPLB + " SET FEESTATUS=1,ACCDATE=@ACCDATE WHERE BSNO=@BSNO ");
// cmdUpdate.Parameters.Clear();
// db.AddInParameter(cmdUpdate, "@BSNO", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdUpdate, "@ACCDATE", DbType.String,AccDate);
// db.ExecuteNonQuery(cmdUpdate, tran);
// var cmdUpdateamend = db.GetSqlStringCommand(
// @"UPDATE OP_AMEND SET FEESTATUS=1,ACCDATE=@ACCDATE WHERE BSNO=@BSNO ");
// cmdUpdateamend.Parameters.Clear();
// db.AddInParameter(cmdUpdateamend, "@BSNO", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdUpdateamend, "@ACCDATE", DbType.String, AccDate);
// db.ExecuteNonQuery(cmdUpdateamend, tran);
// updateclose(enumValue.BSNO,1);
//}
//else
//{
if ( enumValue . OPLB = = "tMsWlPcHead" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=1 " + accdatesqlstr + pcsqlstr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( enumValue . OPLB = = "WMS" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=1,ISLOCK2=1 " + accdatesqlstr + wmssqlstr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( enumValue . OPLB = = "WMS_IN" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE WMS SET FEESTATUS=1,ISLOCK2=1 " + accdatesqlstr + wmssqlstr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( enumValue . OPLB = = "WMS_OUT" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=1 " + accdatesqlstr + wmssqlstr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=1 " + accdatesqlstr + sqlstr + " WHERE BSNO=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
var cmdUpdateamend = db . GetSqlStringCommand (
@"UPDATE OP_AMEND SET FEESTATUS=1 " + accdatesqlstr + " WHERE BSNO=@BSNO " ) ;
cmdUpdateamend . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdateamend , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdateamend , tran ) ;
if ( isbslock = = "1" )
{
updateclose ( enumValue . BSNO , 3 ) ;
}
else
updateclose ( enumValue . BSNO , 1 ) ;
if ( FEELOCKUPDATEEXCHANGE . PARAMVALUE = = "1" )
{
if ( isAccDate = = "1" )
updateexchange ( enumValue . BSNO , AccDate ) ;
else
updateexchange ( enumValue . BSNO , enumValue . ACCDATE ) ;
}
//}
i = i + 1 ;
}
else { j = j + 1 ; }
}
var msg = "" ;
msg = "成功锁定" + i . ToString ( ) + "票业务费用锁定," + j . ToString ( ) + "票业务未锁定!" ;
json = JsonConvert . Serialize ( new { Success = true , Message = msg } ) ;
tran . Commit ( ) ;
}
catch ( Exception )
{
tran . Rollback ( ) ;
json = JsonConvert . Serialize ( new { Success = false , Message = "锁定失败" } ) ;
}
}
return new ContentResult ( ) { Content = json } ;
}
public ContentResult SelDownMonth ( string data , string AccDate )
{
var newDate = Convert . ToDateTime ( AccDate + "-01" ) ;
var nextmonth = newDate . AddMonths ( 1 ) ;
var newperiod = nextmonth . ToString ( "yyyy-MM" ) ;
var billData = JsonConvert . Deserialize < List < BSNOLB > > ( data ) ;
var json = JsonConvert . Serialize ( new { Success = true , Message = "修改成功" } ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
var i = 0 ;
var j = 0 ;
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
foreach ( var enumValue in billData )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET ACCDATE=@ACCDATE WHERE BSNO=@BSNO " ) ;
if ( enumValue . OPLB . Equals ( "tMsWlPcHead" ) )
{
cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET ACCDATE=@ACCDATE WHERE gid=@BSNO " ) ;
}
if ( enumValue . OPLB = = "WMS" )
{
cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET ACCDATE=@ACCDATE WHERE ASSOCIATEDNO=@BSNO " ) ;
}
else if ( enumValue . OPLB = = "WMS_IN" )
{
cmdUpdate = db . GetSqlStringCommand (
@"UPDATE WMS SET ACCDATE=@ACCDATE WHERE GID=@BSNO " ) ;
}
else if ( enumValue . OPLB = = "WMS_OUT" )
{
cmdUpdate = db . GetSqlStringCommand (
@"UPDATE WMS_OUT SET ACCDATE=@ACCDATE WHERE GID=@BSNO " ) ;
}
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . AddInParameter ( cmdUpdate , "@ACCDATE" , DbType . String , newperiod ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
var cmdUpdateamend = db . GetSqlStringCommand (
@"UPDATE OP_AMEND SET ACCDATE=@ACCDATE WHERE BSNO=@BSNO " ) ;
cmdUpdateamend . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdateamend , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . AddInParameter ( cmdUpdateamend , "@ACCDATE" , DbType . String , newperiod ) ;
db . ExecuteNonQuery ( cmdUpdateamend , tran ) ;
i = i + 1 ;
}
var msg = "" ;
msg = "成功修改" + i . ToString ( ) + "票业务!" ;
json = JsonConvert . Serialize ( new { Success = true , Message = msg } ) ;
tran . Commit ( ) ;
}
catch ( Exception )
{
tran . Rollback ( ) ;
json = JsonConvert . Serialize ( new { Success = false , Message = "锁定失败" } ) ;
}
}
return new ContentResult ( ) { Content = json } ;
}
public ContentResult SelLockBsNo ( string bsno , int type , string oplb )
{
var json = JsonConvert . Serialize ( new { Success = true , Message = "锁定成功" } ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
var i = 0 ;
var j = 0 ;
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
if ( type = = 2 )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + oplb + " SET BSSTATUS=1 WHERE BSNO=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
i = i + 1 ;
updateclose ( bsno , type ) ;
}
else if ( type = = 1 )
{
var FeeCount = db . ExecuteScalar ( CommandType . Text , "SELECT COUNT(GID) as FeeCount from ch_fee where FEESTATUS NOT IN (0,8,9) and BSNO='" + bsno + "'" ) ;
var IntFeeCount = Convert . ToInt16 ( FeeCount ) ;
if ( IntFeeCount = = 0 )
{
if ( oplb = = "tMsWlPcHead" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + oplb + " SET FEESTATUS=1 WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( oplb = = "WMS" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + oplb + " SET FEESTATUS=1,ISLOCK2=1 WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( oplb = = "WMS_IN" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE WMS SET FEESTATUS=1,ISLOCK2=1 WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( oplb = = "WMS_OUT" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + oplb + " SET FEESTATUS=1 WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + oplb + " SET FEESTATUS=1 WHERE BSNO=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
var cmdUpdateamend = db . GetSqlStringCommand (
@"UPDATE OP_AMEND SET FEESTATUS=1 WHERE BSNO=@BSNO " ) ;
cmdUpdateamend . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdateamend , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdateamend , tran ) ;
i = i + 1 ;
updateclose ( bsno , type ) ;
}
else { j = j + 1 ; }
}
var msg = "" ;
if ( type = = 2 )
{
msg = "成功锁定" + i . ToString ( ) + "票业务!" ;
}
else if ( type = = 1 )
{
msg = "成功锁定" + i . ToString ( ) + "票业务费用锁定," + j . ToString ( ) + "票业务未锁定!" ;
}
json = JsonConvert . Serialize ( new { Success = true , Message = msg } ) ;
tran . Commit ( ) ;
}
catch ( Exception )
{
tran . Rollback ( ) ;
json = JsonConvert . Serialize ( new { Success = false , Message = "锁定失败" } ) ;
}
}
return new ContentResult ( ) { Content = json } ;
}
public ContentResult SelFeeLockBsNo ( string bsno , string isAccDate , string AccDate , string oplb , string isbslock = "0" )
{
var json = JsonConvert . Serialize ( new { Success = true , Message = "锁定成功" } ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
var i = 0 ;
var j = 0 ;
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
var accdatesqlstr = "" ;
var sqlstr = "" ;
var pcsqlstr = "" ;
var wmssqlstr = "" ;
if ( isAccDate = = "1" ) accdatesqlstr = ",ACCDATE='" + AccDate + "'" ;
if ( isbslock = = "1" )
{
pcsqlstr = ",BillStatus=1 " ;
wmssqlstr = ",ISLOCK=1 " ;
sqlstr = ",BSSTATUS=1 " ;
}
var FeeCount = db . ExecuteScalar ( CommandType . Text , "SELECT COUNT(GID) as FeeCount from ch_fee where FEESTATUS NOT IN (0,8,9) and BSNO='" + bsno + "'" ) ;
var IntFeeCount = Convert . ToInt16 ( FeeCount ) ;
if ( IntFeeCount = = 0 )
{
//if (isAccDate == "1")
//{
// var cmdUpdate = db.GetSqlStringCommand(
// @"UPDATE " +oplb + " SET FEESTATUS=1,ACCDATE=@ACCDATE WHERE BSNO=@BSNO ");
// cmdUpdate.Parameters.Clear();
// db.AddInParameter(cmdUpdate, "@BSNO", DbType.String, bsno);
// db.AddInParameter(cmdUpdate, "@ACCDATE", DbType.String, AccDate);
// db.ExecuteNonQuery(cmdUpdate, tran);
// var cmdUpdateamend = db.GetSqlStringCommand(
// @"UPDATE OP_AMEND SET FEESTATUS=1,ACCDATE=@ACCDATE WHERE BSNO=@BSNO ");
// cmdUpdateamend.Parameters.Clear();
// db.AddInParameter(cmdUpdateamend, "@BSNO", DbType.String, bsno);
// db.AddInParameter(cmdUpdateamend, "@ACCDATE", DbType.String, AccDate);
// db.ExecuteNonQuery(cmdUpdateamend, tran);
// updateclose(bsno, 1);
//}
//else
//{
if ( oplb = = "tMsWlPcHead" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + oplb + " SET FEESTATUS=1 " + accdatesqlstr + pcsqlstr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( oplb = = "WMS" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + oplb + " SET FEESTATUS=1,ISLOCK2=1 " + accdatesqlstr + wmssqlstr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( oplb = = "WMS_IN" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE WMS SET FEESTATUS=1,ISLOCK2=1" + accdatesqlstr + wmssqlstr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( oplb = = "WMS_OUT" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + oplb + " SET FEESTATUS=1" + accdatesqlstr + wmssqlstr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + oplb + " SET FEESTATUS=1" + accdatesqlstr + sqlstr + " WHERE BSNO=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
var cmdUpdateamend = db . GetSqlStringCommand (
@"UPDATE OP_AMEND SET FEESTATUS=1" + accdatesqlstr + " WHERE BSNO=@BSNO " ) ;
cmdUpdateamend . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdateamend , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdateamend , tran ) ;
if ( isbslock = = "1" )
{
updateclose ( bsno , 3 ) ;
}
else
updateclose ( bsno , 1 ) ;
//}
i = i + 1 ;
}
else { j = j + 1 ; }
var msg = "" ;
msg = "成功锁定" + i . ToString ( ) + "票业务费用锁定," + j . ToString ( ) + "票业务未锁定!" ;
json = JsonConvert . Serialize ( new { Success = true , Message = msg } ) ;
tran . Commit ( ) ;
}
catch ( Exception )
{
tran . Rollback ( ) ;
json = JsonConvert . Serialize ( new { Success = false , Message = "锁定失败" } ) ;
}
}
return new ContentResult ( ) { Content = json } ;
}
public ContentResult AllLock ( string billsql , int type )
{
var FEELOCKUPDATEEXCHANGE = MsSysParamSetDAL . GetData ( "PARAMNAME='FEELOCKUPDATEEXCHANGE'" ) ;
var billData = GetFeeDataList ( billsql , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) , "BS" ) ;
var json = JsonConvert . Serialize ( new { Success = true , Message = "锁定成功" } ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
var i = 0 ;
var j = 0 ;
var msg = "" ;
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
foreach ( var enumValue in billData )
{
if ( type = = 2 & & ! enumValue . BSSTATUS )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET BSSTATUS=1 WHERE BSNO=@BSNO " ) ;
if ( enumValue . OPLB . Equals ( "tMsWlPcHead" ) )
{
cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET BillStatus=1 WHERE gid=@BSNO " ) ;
}
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
//var cmdUpdateamend = db.GetSqlStringCommand(
// @"UPDATE OP_AMEND SET BSSTATUS=1 WHERE BSNO=@BSNO ");
//cmdUpdateamend.Parameters.Clear();
//db.AddInParameter(cmdUpdateamend, "@BSNO", DbType.String, enumValue.BSNO);
//db.ExecuteNonQuery(cmdUpdateamend, tran);
updateclose ( enumValue . BSNO , type ) ;
i = i + 1 ;
}
else if ( type = = 1 & & ! enumValue . FEESTATUS )
{
var FeeCount = db . ExecuteScalar ( CommandType . Text , "SELECT COUNT(GID) as FeeCount from ch_fee where FEESTATUS NOT IN (0,8,9) and BSNO='" + enumValue . BSNO + "'" ) ;
var IntFeeCount = Convert . ToInt16 ( FeeCount ) ;
if ( IntFeeCount = = 0 )
{
if ( enumValue . OPLB = = "tMsWlPcHead" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=1 WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( enumValue . OPLB = = "WMS" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=1,ISLOCK2=1 WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( enumValue . OPLB = = "WMS_IN" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE WMS SET FEESTATUS=1,ISLOCK2=1 WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( enumValue . OPLB = = "WMS_OUT" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=1 WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=1 WHERE BSNO=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
var cmdUpdateamend = db . GetSqlStringCommand (
@"UPDATE OP_AMEND SET FEESTATUS=1 WHERE BSNO=@BSNO " ) ;
cmdUpdateamend . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdateamend , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdateamend , tran ) ;
updateclose ( enumValue . BSNO , type ) ;
if ( FEELOCKUPDATEEXCHANGE . PARAMVALUE = = "1" )
{
updateexchange ( enumValue . BSNO , enumValue . ACCDATE ) ;
}
i = i + 1 ;
}
else { j = j + 1 ; }
}
}
if ( type = = 2 )
{
msg = "成功锁定" + i . ToString ( ) + "票业务!" ;
}
else if ( type = = 1 )
{
msg = "成功锁定" + i . ToString ( ) + "票业务费用锁定," + j . ToString ( ) + "票业务未锁定!" ;
}
json = JsonConvert . Serialize ( new { Success = true , Message = msg } ) ;
tran . Commit ( ) ;
}
catch ( Exception )
{
tran . Rollback ( ) ;
json = JsonConvert . Serialize ( new { Success = false , Message = "锁定失败" } ) ;
}
}
return new ContentResult ( ) { Content = json } ;
}
public ContentResult onFeeLockAll ( string billsql , string isAccDate , string AccDate , string isbslock = "0" )
{
var FEELOCKUPDATEEXCHANGE = MsSysParamSetDAL . GetData ( "PARAMNAME='FEELOCKUPDATEEXCHANGE'" ) ;
var billData = GetFeeDataList ( billsql , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) , "FEE" ) ;
var json = JsonConvert . Serialize ( new { Success = true , Message = "锁定成功" } ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
var i = 0 ;
var j = 0 ;
var msg = "" ;
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
var accdatesqlstr = "" ;
var sqlstr = "" ;
var pcsqlstr = "" ;
var wmssqlstr = "" ;
if ( isAccDate = = "1" ) accdatesqlstr = ",ACCDATE='" + AccDate + "'" ;
if ( isbslock = = "1" )
{
pcsqlstr = ",BillStatus=1 " ;
wmssqlstr = ",ISLOCK=1 " ;
sqlstr = ",BSSTATUS=1 " ;
}
foreach ( var enumValue in billData )
{
if ( ! enumValue . FEESTATUS ) {
var FeeCount = db . ExecuteScalar ( CommandType . Text , "SELECT COUNT(GID) as FeeCount from ch_fee where FEESTATUS NOT IN (0,8,9) and BSNO='" + enumValue . BSNO + "'" ) ;
var IntFeeCount = Convert . ToInt16 ( FeeCount ) ;
if ( IntFeeCount = = 0 )
{
//if (isAccDate == "1")
//{
// var cmdUpdate = db.GetSqlStringCommand(
// @"UPDATE " + enumValue.OPLB + " SET FEESTATUS=1,ACCDATE=@ACCDATE WHERE BSNO=@BSNO ");
// cmdUpdate.Parameters.Clear();
// db.AddInParameter(cmdUpdate, "@BSNO", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdUpdate, "@ACCDATE", DbType.String, AccDate);
// db.ExecuteNonQuery(cmdUpdate, tran);
// var cmdUpdateamend = db.GetSqlStringCommand(
// @"UPDATE OP_AMEND SET FEESTATUS=1,ACCDATE=@ACCDATE WHERE BSNO=@BSNO ");
// cmdUpdateamend.Parameters.Clear();
// db.AddInParameter(cmdUpdateamend, "@BSNO", DbType.String, enumValue.BSNO);
// db.AddInParameter(cmdUpdateamend, "@ACCDATE", DbType.String, AccDate);
// db.ExecuteNonQuery(cmdUpdateamend, tran);
// updateclose(enumValue.BSNO, 1);
//}
//else
//{
if ( enumValue . OPLB = = "tMsWlPcHead" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=1 " + accdatesqlstr + pcsqlstr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( enumValue . OPLB = = "WMS" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=1,ISLOCK2=1 " + accdatesqlstr + wmssqlstr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( enumValue . OPLB = = "WMS_IN" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE WMS SET FEESTATUS=1,ISLOCK2=1" + accdatesqlstr + wmssqlstr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( enumValue . OPLB = = "WMS_OUT" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=1" + accdatesqlstr + wmssqlstr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=1" + accdatesqlstr + sqlstr + " WHERE BSNO=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
var cmdUpdateamend = db . GetSqlStringCommand (
@"UPDATE OP_AMEND SET FEESTATUS=1" + accdatesqlstr + " WHERE BSNO=@BSNO " ) ;
cmdUpdateamend . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdateamend , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdateamend , tran ) ;
if ( isbslock = = "1" )
{
updateclose ( enumValue . BSNO , 3 ) ;
} else
updateclose ( enumValue . BSNO , 1 ) ;
if ( FEELOCKUPDATEEXCHANGE . PARAMVALUE = = "1" )
{
if ( isAccDate = = "1" )
updateexchange ( enumValue . BSNO , AccDate ) ;
else
updateexchange ( enumValue . BSNO , enumValue . ACCDATE ) ;
}
//}
i = i + 1 ;
}
else { j = j + 1 ; }
}
}
msg = "成功锁定" + i . ToString ( ) + "票业务费用锁定," + j . ToString ( ) + "票业务未锁定!" ;
json = JsonConvert . Serialize ( new { Success = true , Message = msg } ) ;
tran . Commit ( ) ;
}
catch ( Exception )
{
tran . Rollback ( ) ;
json = JsonConvert . Serialize ( new { Success = false , Message = "锁定失败" } ) ;
}
}
return new ContentResult ( ) { Content = json } ;
}
public ContentResult SelUnLock ( string data , int type , string bsunclose = "0" )
{
var bsunclosestr = "" ;
var pcunclosestr = "" ;
var wmssqlstr = "" ;
if ( bsunclose = = "1" )
{
bsunclosestr = ",BSSTATUS=0" ;
pcunclosestr = ",BillStatus=0" ;
wmssqlstr = ",ISLOCK=0 " ;
}
var billData = JsonConvert . Deserialize < List < BSNOLB > > ( data ) ;
var json = JsonConvert . Serialize ( new { Success = true , Message = "撤销锁定成功" } ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
foreach ( var enumValue in billData )
{
if ( type = = 2 )
{
updateUnclose ( enumValue . BSNO , type . ToString ( ) ) ;
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET BSSTATUS=0 WHERE BSNO=@BSNO " ) ;
//2017年4月10日17:26:51 需求编号:SR2017041000009
//Start
if ( enumValue . OPLB . Equals ( "tMsWlPcHead" ) )
{
cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET BillStatus=0 WHERE gid=@BSNO " ) ;
}
//End
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( type = = 1 )
{
updateUnclose ( enumValue . BSNO , type . ToString ( ) ) ;
if ( enumValue . OPLB = = "tMsWlPcHead" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=0" + pcunclosestr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( enumValue . OPLB = = "WMS" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=0,ISLOCK2=0" + wmssqlstr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( enumValue . OPLB = = "WMS_IN" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE WMS SET FEESTATUS=0,ISLOCK2=0" + wmssqlstr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( enumValue . OPLB = = "WMS_OUT" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=0" + wmssqlstr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=0" + bsunclosestr + " WHERE BSNO=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
var cmdUpdateamend = db . GetSqlStringCommand (
@"UPDATE OP_AMEND SET FEESTATUS=0 WHERE BSNO=@BSNO " ) ;
cmdUpdateamend . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdateamend , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdateamend , tran ) ;
}
}
tran . Commit ( ) ;
}
catch ( Exception )
{
tran . Rollback ( ) ;
json = JsonConvert . Serialize ( new { Success = false , Message = "撤销锁定失败" } ) ;
}
}
return new ContentResult ( ) { Content = json } ;
}
public ContentResult SelUnLockBsNo ( string bsno , int type , string oplb )
{
var json = JsonConvert . Serialize ( new { Success = true , Message = "撤销锁定成功" } ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
if ( type = = 2 )
{
updateUnclose ( bsno , type . ToString ( ) ) ;
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + oplb + " SET BSSTATUS=0 WHERE BSNO=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( type = = 1 )
{
updateUnclose ( bsno , type . ToString ( ) ) ;
if ( oplb = = "tMsWlPcHead" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + oplb + " SET FEESTATUS=0 WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( oplb = = "WMS" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + oplb + " SET FEESTATUS=0,ISLOCK2=0 WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( oplb = = "WMS_IN" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE WMS SET FEESTATUS=0,ISLOCK2=0 WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( oplb = = "WMS_OUT" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + oplb + " SET FEESTATUS=0 WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + oplb + " SET FEESTATUS=0 WHERE BSNO=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
var cmdUpdateamend = db . GetSqlStringCommand (
@"UPDATE OP_AMEND SET FEESTATUS=0 WHERE BSNO=@BSNO " ) ;
cmdUpdateamend . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdateamend , "@BSNO" , DbType . String , bsno ) ;
db . ExecuteNonQuery ( cmdUpdateamend , tran ) ;
}
tran . Commit ( ) ;
}
catch ( Exception )
{
tran . Rollback ( ) ;
json = JsonConvert . Serialize ( new { Success = false , Message = "撤销锁定失败" } ) ;
}
}
return new ContentResult ( ) { Content = json } ;
}
public ContentResult AllUnLock ( string billsql , int type , string bsunclose = "0" )
{
var period = ChMonthCloseDAL . GetData ( "1=1" , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
var bsunclosestr = "" ;
var pcunclosestr = "" ;
var wmssqlstr = "" ;
if ( bsunclose = = "1" )
{
bsunclosestr = ",BSSTATUS=0" ;
pcunclosestr = ",BillStatus=0" ;
wmssqlstr = ",ISLOCK=0 " ;
}
if ( ! string . IsNullOrEmpty ( billsql ) )
{
billsql = billsql + " and ACCDATE>='" + period . PERIOD + "'" ;
}
else
{
billsql = " and ACCDATE>='" + period . PERIOD + "'" ;
}
var typestr = "BS" ;
if ( type = = 1 ) typestr = "FEE" ;
var billData = GetFeeDataList ( billsql , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) , typestr ) ;
var json = JsonConvert . Serialize ( new { Success = true , Message = "锁定成功" } ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
foreach ( var enumValue in billData )
{
if ( type = = 2 )
{
if ( bsunclose = = "1" )
{
updateUnclose ( enumValue . BSNO , "3" ) ;
}
else updateUnclose ( enumValue . BSNO , type . ToString ( ) ) ;
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET BSSTATUS=0 WHERE BSNO=@BSNO " ) ;
//2017年4月10日16:50:29 需求编号:SR2017041000009
//Start
if ( enumValue . OPLB . Equals ( "tMsWlPcHead" ) )
{
cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET BillStatus=0 WHERE gid=@BSNO " ) ;
}
//End
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( type = = 1 )
{
if ( bsunclose = = "1" )
{
updateUnclose ( enumValue . BSNO , "3" ) ;
}
else updateUnclose ( enumValue . BSNO , type . ToString ( ) ) ;
if ( enumValue . OPLB = = "tMsWlPcHead" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=1" + pcunclosestr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( enumValue . OPLB = = "WMS" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=0,ISLOCK2=0" + wmssqlstr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( enumValue . OPLB = = "WMS_IN" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE WMS SET FEESTATUS=0,ISLOCK2=0" + wmssqlstr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( enumValue . OPLB = = "WMS_OUT" )
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=0" + wmssqlstr + " WHERE GID=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else
{
var cmdUpdate = db . GetSqlStringCommand (
@"UPDATE " + enumValue . OPLB + " SET FEESTATUS=0" + bsunclosestr + " WHERE BSNO=@BSNO " ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
var cmdUpdateamend = db . GetSqlStringCommand (
@"UPDATE OP_AMEND SET FEESTATUS=0 WHERE BSNO=@BSNO " ) ;
cmdUpdateamend . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdateamend , "@BSNO" , DbType . String , enumValue . BSNO ) ;
db . ExecuteNonQuery ( cmdUpdateamend , tran ) ;
}
}
tran . Commit ( ) ;
}
catch ( Exception )
{
tran . Rollback ( ) ;
json = JsonConvert . Serialize ( new { Success = false , Message = "锁定失败" } ) ;
}
}
return new ContentResult ( ) { Content = json } ;
}
public bool updateclose ( string bsno , int type )
{
var result = true ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
if ( type = = 2 )
{
var cmdUpdate = db . GetSqlStringCommand (
@"if (select bsno from op_close where bsno='" + bsno + "') is null insert into op_close values(newid(),'" + bsno + "','" + DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" )
+ "','" + Convert . ToString ( Session [ "SHOWNAME" ] ) + "',null,'',0,0,0) else update op_close set BSCLOSETIME='" + DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" )
+ "',BSCLOSEOP='" + Convert . ToString ( Session [ "SHOWNAME" ] ) + "' where BSNO='" + bsno + "' " ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( type = = 1 )
{
var cmdUpdate = db . GetSqlStringCommand (
@"if (select bsno from op_close where bsno='" + bsno + "') is null insert into op_close values(newid(),'" + bsno + "',null,'','" + DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" )
+ "','" + Convert . ToString ( Session [ "SHOWNAME" ] ) + "',0,0,0) else update op_close set FEECLOSETIME='" + DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" )
+ "',FEECLOSEOP='" + Convert . ToString ( Session [ "SHOWNAME" ] ) + "' where BSNO='" + bsno + "' " ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
else if ( type = = 3 )
{
var cmdUpdate = db . GetSqlStringCommand (
@"if (select bsno from op_close where bsno='" + bsno + "') is null insert into op_close values(newid(),'" + bsno + "','" + DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" ) + "','" + Convert . ToString ( Session [ "SHOWNAME" ] ) + "','" + DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" )
+ "','" + Convert . ToString ( Session [ "SHOWNAME" ] ) + "',0,0,0) else update op_close set BSCLOSETIME='" + DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" ) + "',FEECLOSETIME ='" + DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" )
+ "',BSCLOSEOP='" + Convert . ToString ( Session [ "SHOWNAME" ] ) + "',FEECLOSEOP='" + Convert . ToString ( Session [ "SHOWNAME" ] ) + "' where BSNO='" + bsno + "' " ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
}
tran . Commit ( ) ;
}
catch ( Exception )
{
tran . Rollback ( ) ;
}
}
return result ;
}
public bool updateUnclose ( string bsno , string type )
{
var result = true ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
if ( type = = "2" )
{
var cmdUpdate = db . GetSqlStringCommand (
@" update op_close set BSCLOSETIME=null,BSCLOSEOP='' where BSNO='" + bsno + "' " ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
var cmdUpdate2 = db . GetSqlStringCommand (
@"insert into op_unclose values(newid(),'" + bsno + "','2','" + DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" )
+ "','" + Convert . ToString ( Session [ "SHOWNAME" ] ) + "') " ) ;
db . ExecuteNonQuery ( cmdUpdate2 , tran ) ;
}
else if ( type = = "1" )
{
var cmdUpdate = db . GetSqlStringCommand (
@" update op_close set FEECLOSETIME=null,FEECLOSEOP='' where BSNO='" + bsno + "' " ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
var cmdUpdate2 = db . GetSqlStringCommand (
@"insert into op_unclose values(newid(),'" + bsno + "','1','" + DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" )
+ "','" + Convert . ToString ( Session [ "SHOWNAME" ] ) + "') " ) ;
db . ExecuteNonQuery ( cmdUpdate2 , tran ) ;
}
else if ( type = = "3" )
{
var cmdUpdate = db . GetSqlStringCommand (
@" update op_close set FEECLOSETIME=null,FEECLOSEOP='',BSCLOSETIME=null,BSCLOSEOP='' where BSNO='" + bsno + "' " ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
var cmdUpdate2 = db . GetSqlStringCommand (
@"insert into op_unclose values(newid(),'" + bsno + "','1','" + DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" )
+ "','" + Convert . ToString ( Session [ "SHOWNAME" ] ) + "') " ) ;
db . ExecuteNonQuery ( cmdUpdate2 , tran ) ;
var cmdUpdate3 = db . GetSqlStringCommand (
@"insert into op_unclose values(newid(),'" + bsno + "','2','" + DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" )
+ "','" + Convert . ToString ( Session [ "SHOWNAME" ] ) + "') " ) ;
db . ExecuteNonQuery ( cmdUpdate3 , tran ) ;
}
else {
var cmdUpdate2 = db . GetSqlStringCommand (
@"insert into op_unclose values(newid(),'" + bsno + "','" + type + "','" + DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" )
+ "','" + Convert . ToString ( Session [ "SHOWNAME" ] ) + "') " ) ;
db . ExecuteNonQuery ( cmdUpdate2 , tran ) ;
}
tran . Commit ( ) ;
}
catch ( Exception )
{
tran . Rollback ( ) ;
}
}
return result ;
}
public bool updateexchange ( string bsno , string accdate )
{
var result = true ;
var curexlist = MsCurrencyExchangeDAL . GetDataList ( "STARTTIME<='" + accdate + "-01' and ENDTIME>='" + accdate + "-01'" , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
if ( curexlist ! = null & & curexlist . Count ! = 0 ) {
Database db = DatabaseFactory . CreateDatabase ( ) ;
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
foreach ( var enumValue in curexlist )
{
var cmdUpdate =
db . GetSqlStringCommand (
@"update ch_fee set EXCHANGERATE=@EXCHANGERATE where CURRENCY=@CURRENCY and feetype=1 and BSNO='" + bsno + "'" ) ;
var cmdUpdateCr =
db . GetSqlStringCommand (
@"update ch_fee set EXCHANGERATE=@EXCHANGERATE where CURRENCY=@CURRENCY and feetype=2 and BSNO='" + bsno + "'" ) ;
cmdUpdate . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdate , "@CURRENCY" , DbType . String , enumValue . CURRENCY ) ;
db . AddInParameter ( cmdUpdate , "@EXCHANGERATE" , DbType . String , enumValue . VALUE ) ;
db . ExecuteNonQuery ( cmdUpdate , tran ) ;
cmdUpdateCr . Parameters . Clear ( ) ;
db . AddInParameter ( cmdUpdateCr , "@CURRENCY" , DbType . String , enumValue . CURRENCY ) ;
db . AddInParameter ( cmdUpdateCr , "@EXCHANGERATE" , DbType . String , enumValue . CRVALUE ) ;
db . ExecuteNonQuery ( cmdUpdateCr , tran ) ;
var cmdInsertlog =
db . GetSqlStringCommand (
@ "insert into sys_log (GID,NAME,LOGTYPE,LOGTIME,LOGCONTENT,CREATEUSER)
values ( @GID , @NAME , @LOGTYPE , @LOGTIME , @LOGCONTENT , @CREATEUSER ) ");
cmdInsertlog . Parameters . Clear ( ) ;
db . AddInParameter ( cmdInsertlog , "@GID" , DbType . String , Guid . NewGuid ( ) . ToString ( ) ) ;
db . AddInParameter ( cmdInsertlog , "@NAME" , DbType . String , "同步本期汇率" ) ;
db . AddInParameter ( cmdInsertlog , "@LOGTYPE" , DbType . String , "UPDATE 更新操作" ) ;
db . AddInParameter ( cmdInsertlog , "@LOGTIME" , DbType . String , DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" ) ) ;
db . AddInParameter ( cmdInsertlog , "@LOGCONTENT" , DbType . String , "按照会计期间更新费用汇率,更新条件:BSNO=" + bsno + ";应收汇率更新为:" + enumValue . VALUE . ToString ( ) + ";应付汇率更新为:" + enumValue . CRVALUE . ToString ( ) ) ;
db . AddInParameter ( cmdInsertlog , "@CREATEUSER" , DbType . String , Convert . ToString ( Session [ "USERID" ] ) ) ;
db . ExecuteNonQuery ( cmdInsertlog , tran ) ;
}
tran . Commit ( ) ;
}
catch ( Exception )
{
tran . Rollback ( ) ;
}
}
}
return result ;
}
public ContentResult CreateVouSel ( string data , bool ISRATE , string tbRATE , string strVOUDATE , string strPREPARED )
{
T_ALL_DA T_ALL_DA = new EntityDA . T_ALL_DA ( ) ;
var billData = JsonConvert . Deserialize < List < BSNOLB > > ( data ) ;
var json = JsonConvert . Serialize ( new { Success = true , Message = "锁定成功" } ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
var i = 0 ;
var j = 0 ;
var sSQL = "SELECT top 1 * from cw_design" ;
DataSet ds = T_ALL_DA . GetAllSQL ( sSQL ) ;
if ( ds = = null )
{
json = JsonConvert . Serialize ( new { Success = false , Message = "请先设置帐套信息!" } ) ;
return new ContentResult ( ) { Content = json } ;
}
int iResult = 0 ;
string zt = "" ;
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds . Tables [ 0 ] . Rows [ 0 ] [ "AR" ] . ToString ( ) . Trim ( ) + "'" ;
DataSet ds2 = T_ALL_DA . GetAllSQL ( sSQL ) ;
//其他常用科目设置 应付RMB
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds . Tables [ 0 ] . Rows [ 0 ] [ "AP" ] . ToString ( ) . Trim ( ) + "'" ;
DataSet ds3 = T_ALL_DA . GetAllSQL ( sSQL ) ;
//其他常用科目设置 应收USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds . Tables [ 0 ] . Rows [ 0 ] [ "ARFC" ] . ToString ( ) . Trim ( ) + "'" ;
DataSet ds6 = T_ALL_DA . GetAllSQL ( sSQL ) ;
//其他常用科目设置 应付USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds . Tables [ 0 ] . Rows [ 0 ] [ "APFC" ] . ToString ( ) . Trim ( ) + "'" ;
DataSet ds7 = T_ALL_DA . GetAllSQL ( sSQL ) ;
//其他常用科目设置 收入RMB
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds . Tables [ 0 ] . Rows [ 0 ] [ "MBINCOME" ] . ToString ( ) . Trim ( ) + "'" ;
DataSet ds8 = T_ALL_DA . GetAllSQL ( sSQL ) ;
//其他常用科目设置 支出RMB
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds . Tables [ 0 ] . Rows [ 0 ] [ "MBSPENDING" ] . ToString ( ) . Trim ( ) + "'" ;
DataSet ds9 = T_ALL_DA . GetAllSQL ( sSQL ) ;
//其他常用科目设置 收入USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds . Tables [ 0 ] . Rows [ 0 ] [ "TMFCI" ] . ToString ( ) . Trim ( ) + "'" ;
DataSet ds10 = T_ALL_DA . GetAllSQL ( sSQL ) ;
//其他常用科目设置 支出USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds . Tables [ 0 ] . Rows [ 0 ] [ "TMSFC" ] . ToString ( ) . Trim ( ) + "'" ;
DataSet ds11 = T_ALL_DA . GetAllSQL ( sSQL ) ;
foreach ( var enumValue in billData )
{
var strEXPLAN = "" ;
sSQL = "select *" ;
sSQL + = ", FAPCODE=(select top 1 FAPCODE from info_client where SHORTNAME=v_op_bill.CUSTOMERNAME)" ;
sSQL + = ", FARCODE=(select top 1 FARCODE from info_client where SHORTNAME=v_op_bill.CUSTOMERNAME)" ;
sSQL + = ", DEPTID=(select top 1 FINANCESOFTCODE from sys_dept where DEPTNAME=v_op_bill.SALEDEPT and LINKID='" + Convert . ToString ( Session [ "COMPANYID" ] ) + "')" ;
sSQL + = ", EMPLID=(select top 1 FINANCESOFTCODE from user_baseinfo where USERID in (select gid from [user] where ISDELETED=0 and SHOWNAME=v_op_bill.SALE) and COMPANYNAME=(select [NAME] from [company] where GID='" + Convert . ToString ( Session [ "COMPANYID" ] ) + "'))" ;
sSQL + = " from v_op_bill where ISNULL(ISVOU,0)=0 AND bsno in ('" + enumValue . BSNO + "')" ;
DataSet ds5 = T_ALL_DA . GetAllSQL ( sSQL ) ;
if ( ds5 ! = null )
{
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISCLIENTNAME" ] . ToString ( ) . Trim ( ) = = "True" )
{
strEXPLAN + = " " + ds5 . Tables [ 0 ] . Rows [ 0 ] [ "CUSTOMERNAME" ] . ToString ( ) . Trim ( ) ;
}
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISCUSTNO" ] . ToString ( ) . Trim ( ) = = "True" )
{
strEXPLAN + = " " + ds5 . Tables [ 0 ] . Rows [ 0 ] [ "CUSTNO" ] . ToString ( ) . Trim ( ) ;
}
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISMBLNO" ] . ToString ( ) . Trim ( ) = = "True" )
{
strEXPLAN + = " " + ds5 . Tables [ 0 ] . Rows [ 0 ] [ "MBLNO" ] . ToString ( ) . Trim ( ) ;
}
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISVESSEL" ] . ToString ( ) . Trim ( ) = = "True" )
{
strEXPLAN + = " " + ds5 . Tables [ 0 ] . Rows [ 0 ] [ "VESSEL" ] . ToString ( ) . Trim ( ) ;
}
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISVOYNO" ] . ToString ( ) . Trim ( ) = = "True" )
{
strEXPLAN + = " " + ds5 . Tables [ 0 ] . Rows [ 0 ] [ "VOYNO" ] . ToString ( ) . Trim ( ) ;
}
iResult = getSCHxt ( ds , "'" + enumValue . BSNO + "'" , "" , strEXPLAN , ds5 . Tables [ 0 ] . Rows [ 0 ] [ "DEPTID" ] . ToString ( ) . Trim ( ) , ds5 . Tables [ 0 ] . Rows [ 0 ] [ "EMPLID" ] . ToString ( ) . Trim ( ) , ds5 . Tables [ 0 ] . Rows [ 0 ] [ "SALE" ] . ToString ( ) . Trim ( ) , ds5 . Tables [ 0 ] . Rows [ 0 ] [ "MBLNO" ] . ToString ( ) . Trim ( ) , ds2 , ds3 , ds6 , ds7 , ds8 , ds9 , ds10 , ds11 , Convert . ToString ( Session [ "USERID" ] ) , ISRATE , tbRATE , strVOUDATE , strPREPARED ) ;
}
}
var msg = "" ;
msg = "成功生成凭证" + i . ToString ( ) + "票业务!" ;
json = JsonConvert . Serialize ( new { Success = true , Message = msg } ) ;
return new ContentResult ( ) { Content = json } ;
}
public ContentResult CreateVouAll ( string billsql , bool ISRATE , string tbRATE , string strVOUDATE , string strPREPARED )
{
T_ALL_DA T_ALL_DA = new EntityDA . T_ALL_DA ( ) ;
//var billData = JsonConvert.Deserialize<List<BSNOLB>>(data);
var billData = GetVouDataList ( billsql , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
var json = JsonConvert . Serialize ( new { Success = true , Message = "锁定成功" } ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
var i = 0 ;
var j = 0 ;
var sSQL = "SELECT top 1 * from cw_design" ;
DataSet ds = T_ALL_DA . GetAllSQL ( sSQL ) ;
if ( ds = = null )
{
json = JsonConvert . Serialize ( new { Success = false , Message = "请先设置帐套信息!" } ) ;
return new ContentResult ( ) { Content = json } ;
}
int iResult = 0 ;
string zt = "" ;
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds . Tables [ 0 ] . Rows [ 0 ] [ "AR" ] . ToString ( ) . Trim ( ) + "'" ;
DataSet ds2 = T_ALL_DA . GetAllSQL ( sSQL ) ;
//其他常用科目设置 应付RMB
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds . Tables [ 0 ] . Rows [ 0 ] [ "AP" ] . ToString ( ) . Trim ( ) + "'" ;
DataSet ds3 = T_ALL_DA . GetAllSQL ( sSQL ) ;
//其他常用科目设置 应收USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds . Tables [ 0 ] . Rows [ 0 ] [ "ARFC" ] . ToString ( ) . Trim ( ) + "'" ;
DataSet ds6 = T_ALL_DA . GetAllSQL ( sSQL ) ;
//其他常用科目设置 应付USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds . Tables [ 0 ] . Rows [ 0 ] [ "APFC" ] . ToString ( ) . Trim ( ) + "'" ;
DataSet ds7 = T_ALL_DA . GetAllSQL ( sSQL ) ;
//其他常用科目设置 收入RMB
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds . Tables [ 0 ] . Rows [ 0 ] [ "MBINCOME" ] . ToString ( ) . Trim ( ) + "'" ;
DataSet ds8 = T_ALL_DA . GetAllSQL ( sSQL ) ;
//其他常用科目设置 支出RMB
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds . Tables [ 0 ] . Rows [ 0 ] [ "MBSPENDING" ] . ToString ( ) . Trim ( ) + "'" ;
DataSet ds9 = T_ALL_DA . GetAllSQL ( sSQL ) ;
//其他常用科目设置 收入USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds . Tables [ 0 ] . Rows [ 0 ] [ "TMFCI" ] . ToString ( ) . Trim ( ) + "'" ;
DataSet ds10 = T_ALL_DA . GetAllSQL ( sSQL ) ;
//其他常用科目设置 支出USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds . Tables [ 0 ] . Rows [ 0 ] [ "TMSFC" ] . ToString ( ) . Trim ( ) + "'" ;
DataSet ds11 = T_ALL_DA . GetAllSQL ( sSQL ) ;
foreach ( var enumValue in billData )
{
var strEXPLAN = "" ;
sSQL = "select *" ;
sSQL + = ", FAPCODE=(select top 1 FAPCODE from info_client where SHORTNAME=v_op_bill.CUSTOMERNAME)" ;
sSQL + = ", FARCODE=(select top 1 FARCODE from info_client where SHORTNAME=v_op_bill.CUSTOMERNAME)" ;
sSQL + = ", DEPTID=(select top 1 FINANCESOFTCODE from sys_dept where DEPTNAME=v_op_bill.SALEDEPT and LINKID='" + Convert . ToString ( Session [ "COMPANYID" ] ) + "')" ;
sSQL + = ", EMPLID=(select top 1 FINANCESOFTCODE from user_baseinfo where USERID in (select gid from [user] where ISDELETED=0 and SHOWNAME=v_op_bill.SALE) and COMPANYNAME=(select [NAME] from [company] where GID='" + Convert . ToString ( Session [ "COMPANYID" ] ) + "'))" ;
sSQL + = " from v_op_bill where ISNULL(ISVOU,0)=0 AND bsno in ('" + enumValue . BSNO + "')" ;
DataSet ds5 = T_ALL_DA . GetAllSQL ( sSQL ) ;
if ( ds5 ! = null )
{
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISCLIENTNAME" ] . ToString ( ) . Trim ( ) = = "True" )
{
strEXPLAN + = " " + ds5 . Tables [ 0 ] . Rows [ 0 ] [ "CUSTOMERNAME" ] . ToString ( ) . Trim ( ) ;
}
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISCUSTNO" ] . ToString ( ) . Trim ( ) = = "True" )
{
strEXPLAN + = " " + ds5 . Tables [ 0 ] . Rows [ 0 ] [ "CUSTNO" ] . ToString ( ) . Trim ( ) ;
}
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISMBLNO" ] . ToString ( ) . Trim ( ) = = "True" )
{
strEXPLAN + = " " + ds5 . Tables [ 0 ] . Rows [ 0 ] [ "MBLNO" ] . ToString ( ) . Trim ( ) ;
}
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISVESSEL" ] . ToString ( ) . Trim ( ) = = "True" )
{
strEXPLAN + = " " + ds5 . Tables [ 0 ] . Rows [ 0 ] [ "VESSEL" ] . ToString ( ) . Trim ( ) ;
}
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISVOYNO" ] . ToString ( ) . Trim ( ) = = "True" )
{
strEXPLAN + = " " + ds5 . Tables [ 0 ] . Rows [ 0 ] [ "VOYNO" ] . ToString ( ) . Trim ( ) ;
}
iResult = getSCHxt ( ds , "'" + enumValue . BSNO + "'" , "" , strEXPLAN , ds5 . Tables [ 0 ] . Rows [ 0 ] [ "DEPTID" ] . ToString ( ) . Trim ( ) , ds5 . Tables [ 0 ] . Rows [ 0 ] [ "EMPLID" ] . ToString ( ) . Trim ( ) , ds5 . Tables [ 0 ] . Rows [ 0 ] [ "SALE" ] . ToString ( ) . Trim ( ) , ds5 . Tables [ 0 ] . Rows [ 0 ] [ "MBLNO" ] . ToString ( ) . Trim ( ) , ds2 , ds3 , ds6 , ds7 , ds8 , ds9 , ds10 , ds11 , Convert . ToString ( Session [ "USERID" ] ) , ISRATE , tbRATE , strVOUDATE , strPREPARED ) ;
if ( iResult = = 1 )
i = i + 1 ;
}
}
var msg = "" ;
msg = "成功生成凭证" + i . ToString ( ) + "票业务!" ;
json = JsonConvert . Serialize ( new { Success = true , Message = msg } ) ;
return new ContentResult ( ) { Content = json } ;
}
public static int getSCHxt ( DataSet ds , string sGids , string strVESSEL , string strEXPLAN , string strDEPTID , string strEMPLID , string strSALE , string strBLNO , DataSet ds2 , DataSet ds3 , DataSet ds6 , DataSet ds7 , DataSet ds8 , DataSet ds9 , DataSet ds10 , DataSet ds11 , string strUserID , bool ISRATE , string tbRATE , string strVOUDATE , string strPREPARED )
{
#region 基本设置
string sSQL = "" ;
Decimal iAMTDR = 0 ;
Decimal iAMTCR = 0 ;
int iResult = 0 ;
//差额主营业务收入
Decimal dRMBS = 0 ;
Decimal dRMBF = 0 ;
Decimal dUSDS = 0 ;
Decimal dUSDF = 0 ;
int n = 0 ;
Decimal usdRATES = 0 ;
Decimal usdRATEF = 0 ;
//Decimal dEXCHANGERATE =0;
T_ALL_DA T_ALL_DA = new EntityDA . T_ALL_DA ( ) ;
# endregion
#region 摘要
//ISRPCLIENTNAME 是否收付客户名称
//ISRPCOTCODE 是否收付业务编号
//ISRPETD 是否收付航期
//ISRPMBLNO 是否收付主提单号
//ISRPCUSTNO 是否收付委托编号
//ISRPVESSEL 是否收付船名
//ISRPVOYNO 是否收付航次
string strISEXPLAN = "" ;
//if (ds.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
//{
// strISEXPLAN += " " + ds.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
//}
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISCUSTNO" ] . ToString ( ) . Trim ( ) = = "True" )
{
strISEXPLAN + = ",CUSTNO" ;
}
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISMBLNO" ] . ToString ( ) . Trim ( ) = = "True" )
{
strISEXPLAN + = ",MBLNO" ;
}
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISVESSEL" ] . ToString ( ) . Trim ( ) = = "True" )
{
strISEXPLAN + = ",VESSEL" ;
}
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISVOYNO" ] . ToString ( ) . Trim ( ) = = "True" )
{
strISEXPLAN + = ",VOYNO" ;
}
# endregion
string strORDNO = getBSNO ( ) ;
CwVouchersDA CwVouchersDA = new CwVouchersDA ( ) ;
IList < CwVouitemsEntity > CwVouitemsEntities = new List < CwVouitemsEntity > ( ) ;
#region 基本语句
/ /
//(CASE WHEN FEETYPE = 1 THEN '应收账款' ELSE '应付账款' END) as 类型
//,CUSTOMERNAME 客户名称
//,EXCHANGERATE 汇率
//,CURRENCY 币别`
//,ISADVANCEDPAY 是否垫付
//,SUM(AMOUNT) AS 金额
//,SUM(AMOUNT*EXCHANGERATE) AS 合计金额
if ( ISRATE = = true )
{
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "AR" ] . ToString ( ) . Trim ( ) = = ds . Tables [ 0 ] . Rows [ 0 ] [ "ARFC" ] . ToString ( ) . Trim ( ) )
{
sSQL = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' ELSE '应付账款' END) as FEETYPE" ;
sSQL + = ", FAPCODE=(select top 1 FAPCODE from info_client where SHORTNAME=VW_ch_fee_op.CUSTOMERNAME)" ;
sSQL + = ", FARCODE=(select top 1 FARCODE from info_client where SHORTNAME=VW_ch_fee_op.CUSTOMERNAME)" ;
sSQL + = ",CUSTOMERNAME,1 EXCHANGERATE,'RMB' CURRENCY,ISADVANCEDPAY,SUM(AMOUNT*EXCHANGERATE) AS je,SUM(AMOUNT*EXCHANGERATE) AS hj " + strISEXPLAN ;
sSQL + = " From VW_ch_fee_op WHERE 1=1 and bsno in (select BSNO from v_op_bill where isnull(isvou,0)=0 and bsno in(" + sGids . Trim ( ) + ") " + strVESSEL + ")" ;
sSQL + = " GROUP BY FEETYPE,CUSTOMERNAME,ISADVANCEDPAY" + strISEXPLAN ;
sSQL + = " ORDER BY FEETYPE desc,CUSTOMERNAME" + strISEXPLAN ;
}
else
{
sSQL = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' ELSE '应付账款' END) as FEETYPE" ;
sSQL + = ", FAPCODE=(select top 1 FAPCODE from info_client where SHORTNAME=VW_ch_fee_op.CUSTOMERNAME)" ;
sSQL + = ", FARCODE=(select top 1 FARCODE from info_client where SHORTNAME=VW_ch_fee_op.CUSTOMERNAME)" ;
sSQL + = ",CUSTOMERNAME,EXCHANGERATE,CURRENCY,ISADVANCEDPAY,SUM(AMOUNT) AS je,SUM(AMOUNT*EXCHANGERATE) AS hj " + strISEXPLAN ;
sSQL + = " From VW_ch_fee_op WHERE 1=1 and bsno in (select BSNO from v_op_bill where isnull(isvou,0)=0 and bsno in(" + sGids . Trim ( ) + ") " + strVESSEL + ")" ;
sSQL + = " GROUP BY FEETYPE,CUSTOMERNAME,EXCHANGERATE,CURRENCY,ISADVANCEDPAY" + strISEXPLAN ;
sSQL + = " ORDER BY FEETYPE desc,CURRENCY,CUSTOMERNAME" + strISEXPLAN ;
}
}
else
{
sSQL = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' ELSE '应付账款' END) as FEETYPE" ;
sSQL + = ", FAPCODE=(select top 1 FAPCODE from info_client where SHORTNAME=VW_ch_fee_op.CUSTOMERNAME)" ;
sSQL + = ", FARCODE=(select top 1 FARCODE from info_client where SHORTNAME=VW_ch_fee_op.CUSTOMERNAME)" ;
sSQL + = ",CUSTOMERNAME,EXCHANGERATE,CURRENCY,ISADVANCEDPAY,SUM(AMOUNT) AS je,SUM(AMOUNT*" + tbRATE . Trim ( ) + ") AS hj " + strISEXPLAN ;
sSQL + = " From VW_ch_fee_op WHERE 1=1 and bsno in (select BSNO from v_op_bill where isnull(isvou,0)=0 and bsno in(" + sGids . Trim ( ) + ") " + strVESSEL + ")" ;
sSQL + = " GROUP BY FEETYPE,CUSTOMERNAME,EXCHANGERATE,CURRENCY,ISADVANCEDPAY" + strISEXPLAN ;
sSQL + = " ORDER BY FEETYPE desc,CURRENCY,CUSTOMERNAME" + strISEXPLAN ;
}
# endregion
DataSet ds1 = T_ALL_DA . GetAllSQL ( sSQL ) ;
if ( ds1 ! = null )
{
#region 应收、应付账款
for ( int i = 0 ; i < ds1 . Tables [ 0 ] . Rows . Count ; i + + )
{
n = i ; // +1;
if ( Math . Round ( Decimal . Parse ( ds1 . Tables [ 0 ] . Rows [ i ] [ "hj" ] . ToString ( ) . Trim ( ) ) , 2 , MidpointRounding . AwayFromZero ) ! = 0 )
{
CwVouitemsEntity CwVouitemsEntity = new CwVouitemsEntity ( ) ;
//CwVouitemsEntity.GID 唯一编码 newid()
CwVouitemsEntity . ORDNO = strORDNO . Trim ( ) ;
CwVouitemsEntity . ITEMNO = n ; // 行号
CwVouitemsEntity . PACCID = "" ; //父级科目贷码
CwVouitemsEntity . PROPERTY = 0 ; //科目属性
CwVouitemsEntity . GRADE = 0 ; //科目级别
if ( ds1 . Tables [ 0 ] . Rows [ i ] [ "FEETYPE" ] . ToString ( ) . Trim ( ) = = "应收账款" )
{
#region 应收账款
iAMTDR = iAMTDR + Math . Round ( Decimal . Parse ( ds1 . Tables [ 0 ] . Rows [ i ] [ "hj" ] . ToString ( ) . Trim ( ) ) , 2 , MidpointRounding . AwayFromZero ) ;
/ /
if ( ds1 . Tables [ 0 ] . Rows [ i ] [ "CURRENCY" ] . ToString ( ) . Trim ( ) = = "RMB" )
{
#region RMB
CwVouitemsEntity . ACCID = ds . Tables [ 0 ] . Rows [ 0 ] [ "AR" ] . ToString ( ) . Trim ( ) ; //应收账款科目贷码
CwVouitemsEntity . AMTDR = Math . Round ( Decimal . Parse ( ds1 . Tables [ 0 ] . Rows [ i ] [ "hj" ] . ToString ( ) . Trim ( ) ) , 2 , MidpointRounding . AwayFromZero ) ; //本位币借方金额(互斥)
CwVouitemsEntity . AMTCR = 0 ; //本位币贷方金额(互斥)
CwVouitemsEntity . ISFCY = false ; //是否外币
CwVouitemsEntity . FCYNO = "RMB" ; //外币编号usd
CwVouitemsEntity . FCYDR = 0 ; //外币借方金额
CwVouitemsEntity . FCYCR = 0 ; //外币贷方金额
dRMBS + = Math . Round ( Decimal . Parse ( ds1 . Tables [ 0 ] . Rows [ i ] [ "hj" ] . ToString ( ) . Trim ( ) ) , 2 , MidpointRounding . AwayFromZero ) ; //本位币借方金额(互斥)
if ( ds2 = = null )
{
CwVouitemsEntity . ACCNAME = "" ; //科目名称
CwVouitemsEntity . ISDEPTACC = false ; //核算部门,按规则设置生成
CwVouitemsEntity . ISEMPLACC = false ; //核算人员,按规则设置生成
CwVouitemsEntity . ISCORPACC = false ; //核算客户,按规则设置生成
CwVouitemsEntity . ISITEMACC = false ; //核算项目,按规则设置生成
CwVouitemsEntity . DC = "D" ; //借方向
}
else
{
CwVouitemsEntity . ACCNAME = ds2 . Tables [ 0 ] . Rows [ 0 ] [ "ACCNAME" ] . ToString ( ) . Trim ( ) ; //科目名称
CwVouitemsEntity . ISDEPTACC = Boolean . Parse ( ds2 . Tables [ 0 ] . Rows [ 0 ] [ "ISDEPTACC" ] . ToString ( ) . Trim ( ) ) ; //核算部门,按规则设置生成
CwVouitemsEntity . ISEMPLACC = Boolean . Parse ( ds2 . Tables [ 0 ] . Rows [ 0 ] [ "ISEMPLACC" ] . ToString ( ) . Trim ( ) ) ; //核算人员,按规则设置生成
CwVouitemsEntity . ISCORPACC = Boolean . Parse ( ds2 . Tables [ 0 ] . Rows [ 0 ] [ "ISCORPACC" ] . ToString ( ) . Trim ( ) ) ; //核算客户,按规则设置生成
CwVouitemsEntity . ISITEMACC = Boolean . Parse ( ds2 . Tables [ 0 ] . Rows [ 0 ] [ "ISITEMACC" ] . ToString ( ) . Trim ( ) ) ; //核算项目,按规则设置生成
if ( ds2 . Tables [ 0 ] . Rows [ 0 ] [ "DC" ] . ToString ( ) . Trim ( ) = = "借" )
{
CwVouitemsEntity . DC = "D" ; //借方向
}
else
{
CwVouitemsEntity . DC = "C" ; //贷方向
}
}
# endregion
}
else if ( ds1 . Tables [ 0 ] . Rows [ i ] [ "CURRENCY" ] . ToString ( ) . Trim ( ) ! = "RMB" )
{
#region 外币
CwVouitemsEntity . ACCID = ds . Tables [ 0 ] . Rows [ 0 ] [ "ARFC" ] . ToString ( ) . Trim ( ) ; //应收账款外币科目贷码
CwVouitemsEntity . AMTDR = Math . Round ( Decimal . Parse ( ds1 . Tables [ 0 ] . Rows [ i ] [ "hj" ] . ToString ( ) . Trim ( ) ) , 2 , MidpointRounding . AwayFromZero ) ; //本位币借方金额(互斥)
CwVouitemsEntity . AMTCR = 0 ; //本位币贷方金额(互斥)
CwVouitemsEntity . ISFCY = true ; //是否外币
CwVouitemsEntity . FCYNO = "USD" ; //外币编号usd
CwVouitemsEntity . FCYDR = Decimal . Parse ( ds1 . Tables [ 0 ] . Rows [ i ] [ "je" ] . ToString ( ) . Trim ( ) ) ; //外币借方金额
CwVouitemsEntity . FCYCR = 0 ; //外币贷方金额
dUSDS + = Decimal . Parse ( ds1 . Tables [ 0 ] . Rows [ i ] [ "je" ] . ToString ( ) . Trim ( ) ) ; //本位币借方金额(互斥)
if ( ds6 = = null )
{
CwVouitemsEntity . ACCNAME = "" ; //科目名称
CwVouitemsEntity . ISDEPTACC = false ; //核算部门,按规则设置生成
CwVouitemsEntity . ISEMPLACC = false ; //核算人员,按规则设置生成
CwVouitemsEntity . ISCORPACC = false ; //核算客户,按规则设置生成
CwVouitemsEntity . ISITEMACC = false ; //核算项目,按规则设置生成
CwVouitemsEntity . DC = "D" ; //借方向
}
else
{
CwVouitemsEntity . ACCNAME = ds6 . Tables [ 0 ] . Rows [ 0 ] [ "ACCNAME" ] . ToString ( ) . Trim ( ) ; //科目名称
CwVouitemsEntity . ISDEPTACC = Boolean . Parse ( ds6 . Tables [ 0 ] . Rows [ 0 ] [ "ISDEPTACC" ] . ToString ( ) . Trim ( ) ) ; //核算部门,按规则设置生成
CwVouitemsEntity . ISEMPLACC = Boolean . Parse ( ds6 . Tables [ 0 ] . Rows [ 0 ] [ "ISEMPLACC" ] . ToString ( ) . Trim ( ) ) ; //核算人员,按规则设置生成
CwVouitemsEntity . ISCORPACC = Boolean . Parse ( ds6 . Tables [ 0 ] . Rows [ 0 ] [ "ISCORPACC" ] . ToString ( ) . Trim ( ) ) ; //核算客户,按规则设置生成
CwVouitemsEntity . ISITEMACC = Boolean . Parse ( ds6 . Tables [ 0 ] . Rows [ 0 ] [ "ISITEMACC" ] . ToString ( ) . Trim ( ) ) ; //核算项目,按规则设置生成
if ( ds6 . Tables [ 0 ] . Rows [ 0 ] [ "DC" ] . ToString ( ) . Trim ( ) = = "借" )
{
CwVouitemsEntity . DC = "D" ; //借方向
}
else
{
CwVouitemsEntity . DC = "C" ; //贷方向
}
}
usdRATES = Decimal . Parse ( ds1 . Tables [ 0 ] . Rows [ i ] [ "EXCHANGERATE" ] . ToString ( ) . Trim ( ) ) ; //汇率
# endregion
}
if ( ds2 . Tables [ 0 ] . Rows [ 0 ] [ "ISCORPACC" ] . ToString ( ) . Trim ( ) = = "True" )
{
CwVouitemsEntity . CORPID = ds1 . Tables [ 0 ] . Rows [ i ] [ "FAPCODE" ] . ToString ( ) . Trim ( ) ; //客户(系统)
CwVouitemsEntity . CUSTOMERNAME = ds1 . Tables [ 0 ] . Rows [ i ] [ "CUSTOMERNAME" ] . ToString ( ) . Trim ( ) ; //客户(系统)
}
else
{
CwVouitemsEntity . CORPID = "" ; //客户(系统)
CwVouitemsEntity . CUSTOMERNAME = "" ; //客户(系统)
}
# endregion
}
else if ( ds1 . Tables [ 0 ] . Rows [ i ] [ "FEETYPE" ] . ToString ( ) . Trim ( ) = = "应付账款" )
{
#region 应付账款
iAMTCR = iAMTCR + Math . Round ( Decimal . Parse ( ds1 . Tables [ 0 ] . Rows [ i ] [ "hj" ] . ToString ( ) . Trim ( ) ) , 2 , MidpointRounding . AwayFromZero ) ;
/ /
if ( ds1 . Tables [ 0 ] . Rows [ i ] [ "CURRENCY" ] . ToString ( ) . Trim ( ) = = "RMB" )
{
#region RMB
CwVouitemsEntity . ACCID = ds . Tables [ 0 ] . Rows [ 0 ] [ "AP" ] . ToString ( ) . Trim ( ) ; //应付账款科目贷码
CwVouitemsEntity . AMTDR = 0 ; //本位币借方金额(互斥)
CwVouitemsEntity . AMTCR = Math . Round ( Decimal . Parse ( ds1 . Tables [ 0 ] . Rows [ i ] [ "je" ] . ToString ( ) . Trim ( ) ) , 2 , MidpointRounding . AwayFromZero ) ; //本位币贷方金额(互斥)
CwVouitemsEntity . ISFCY = false ; //是否外币
CwVouitemsEntity . FCYNO = "RMB" ; //外币编号usd
CwVouitemsEntity . FCYDR = 0 ; //外币借方金额
CwVouitemsEntity . FCYCR = 0 ; //外币贷方金额
dRMBF + = Math . Round ( Decimal . Parse ( ds1 . Tables [ 0 ] . Rows [ i ] [ "je" ] . ToString ( ) . Trim ( ) ) , 2 , MidpointRounding . AwayFromZero ) ; //本位币贷方金额(互斥)
if ( ds3 = = null )
{
CwVouitemsEntity . ACCNAME = "" ; //科目名称
CwVouitemsEntity . ISDEPTACC = false ; //核算部门,按规则设置生成
CwVouitemsEntity . ISEMPLACC = false ; //核算人员,按规则设置生成
CwVouitemsEntity . ISCORPACC = false ; //核算客户,按规则设置生成
CwVouitemsEntity . ISITEMACC = false ; //核算项目,按规则设置生成
CwVouitemsEntity . DC = "C" ; //贷方向
}
else
{
CwVouitemsEntity . ACCNAME = ds3 . Tables [ 0 ] . Rows [ 0 ] [ "ACCNAME" ] . ToString ( ) . Trim ( ) ; //科目名称
CwVouitemsEntity . ISDEPTACC = Boolean . Parse ( ds3 . Tables [ 0 ] . Rows [ 0 ] [ "ISDEPTACC" ] . ToString ( ) . Trim ( ) ) ; //核算部门,按规则设置生成
CwVouitemsEntity . ISEMPLACC = Boolean . Parse ( ds3 . Tables [ 0 ] . Rows [ 0 ] [ "ISEMPLACC" ] . ToString ( ) . Trim ( ) ) ; //核算人员,按规则设置生成
CwVouitemsEntity . ISCORPACC = Boolean . Parse ( ds3 . Tables [ 0 ] . Rows [ 0 ] [ "ISCORPACC" ] . ToString ( ) . Trim ( ) ) ; //核算客户,按规则设置生成
CwVouitemsEntity . ISITEMACC = Boolean . Parse ( ds3 . Tables [ 0 ] . Rows [ 0 ] [ "ISITEMACC" ] . ToString ( ) . Trim ( ) ) ; //核算项目,按规则设置生成
if ( ds3 . Tables [ 0 ] . Rows [ 0 ] [ "DC" ] . ToString ( ) . Trim ( ) = = "借" )
{
CwVouitemsEntity . DC = "D" ; //借方向
}
else
{
CwVouitemsEntity . DC = "C" ; //贷方向
}
}
# endregion
}
else if ( ds1 . Tables [ 0 ] . Rows [ i ] [ "CURRENCY" ] . ToString ( ) . Trim ( ) ! = "RMB" )
{
#region 外币
CwVouitemsEntity . ACCID = ds . Tables [ 0 ] . Rows [ 0 ] [ "APFC" ] . ToString ( ) . Trim ( ) ; //应付账款外币科目贷码
CwVouitemsEntity . AMTDR = 0 ; //本位币借方金额(互斥)
CwVouitemsEntity . AMTCR = Math . Round ( Decimal . Parse ( ds1 . Tables [ 0 ] . Rows [ i ] [ "hj" ] . ToString ( ) . Trim ( ) ) , 2 , MidpointRounding . AwayFromZero ) ; //本位币贷方金额(互斥)
CwVouitemsEntity . ISFCY = true ; //是否外币
CwVouitemsEntity . FCYNO = "USD" ; //外币编号usd
CwVouitemsEntity . FCYDR = 0 ; //外币借方金额
CwVouitemsEntity . FCYCR = Decimal . Parse ( ds1 . Tables [ 0 ] . Rows [ i ] [ "je" ] . ToString ( ) . Trim ( ) ) ; //外币贷方金额
dUSDF + = Decimal . Parse ( ds1 . Tables [ 0 ] . Rows [ i ] [ "je" ] . ToString ( ) . Trim ( ) ) ; //本位币贷方金额(互斥)
if ( ds7 = = null )
{
CwVouitemsEntity . ACCNAME = "" ; //科目名称
CwVouitemsEntity . ISDEPTACC = false ; //核算部门,按规则设置生成
CwVouitemsEntity . ISEMPLACC = false ; //核算人员,按规则设置生成
CwVouitemsEntity . ISCORPACC = false ; //核算客户,按规则设置生成
CwVouitemsEntity . ISITEMACC = false ; //核算项目,按规则设置生成
CwVouitemsEntity . DC = "C" ; //贷方向
}
else
{
CwVouitemsEntity . ACCNAME = ds7 . Tables [ 0 ] . Rows [ 0 ] [ "ACCNAME" ] . ToString ( ) . Trim ( ) ; //科目名称
CwVouitemsEntity . ISDEPTACC = Boolean . Parse ( ds7 . Tables [ 0 ] . Rows [ 0 ] [ "ISDEPTACC" ] . ToString ( ) . Trim ( ) ) ; //核算部门,按规则设置生成
CwVouitemsEntity . ISEMPLACC = Boolean . Parse ( ds7 . Tables [ 0 ] . Rows [ 0 ] [ "ISEMPLACC" ] . ToString ( ) . Trim ( ) ) ; //核算人员,按规则设置生成
CwVouitemsEntity . ISCORPACC = Boolean . Parse ( ds7 . Tables [ 0 ] . Rows [ 0 ] [ "ISCORPACC" ] . ToString ( ) . Trim ( ) ) ; //核算客户,按规则设置生成
CwVouitemsEntity . ISITEMACC = Boolean . Parse ( ds7 . Tables [ 0 ] . Rows [ 0 ] [ "ISITEMACC" ] . ToString ( ) . Trim ( ) ) ; //核算项目,按规则设置生成
if ( ds7 . Tables [ 0 ] . Rows [ 0 ] [ "DC" ] . ToString ( ) . Trim ( ) = = "借" )
{
CwVouitemsEntity . DC = "D" ; //借方向
}
else
{
CwVouitemsEntity . DC = "C" ; //贷方向
}
}
usdRATEF = Decimal . Parse ( ds1 . Tables [ 0 ] . Rows [ i ] [ "EXCHANGERATE" ] . ToString ( ) . Trim ( ) ) ; //汇率
# endregion
}
if ( ds3 . Tables [ 0 ] . Rows [ 0 ] [ "ISCORPACC" ] . ToString ( ) . Trim ( ) = = "True" )
{
CwVouitemsEntity . CORPID = ds1 . Tables [ 0 ] . Rows [ i ] [ "FAPCODE" ] . ToString ( ) . Trim ( ) ; //客户(系统)
CwVouitemsEntity . CUSTOMERNAME = ds1 . Tables [ 0 ] . Rows [ i ] [ "CUSTOMERNAME" ] . ToString ( ) . Trim ( ) ; //客户(系统)
}
else
{
CwVouitemsEntity . CORPID = "" ; //客户(系统)
CwVouitemsEntity . CUSTOMERNAME = "" ; //客户(系统)
}
# endregion
}
CwVouitemsEntity . FCYEXRATE = Decimal . Parse ( ds1 . Tables [ 0 ] . Rows [ i ] [ "EXCHANGERATE" ] . ToString ( ) . Trim ( ) ) ; //汇率
CwVouitemsEntity . QTYUNIT = "" ; //数量包装单位
CwVouitemsEntity . QTYDR = 0 ; //借方数量
CwVouitemsEntity . QTYCR = 0 ; //贷方数量
CwVouitemsEntity . EXPLAN = strEXPLAN + " " + ds1 . Tables [ 0 ] . Rows [ i ] [ "CUSTOMERNAME" ] . ToString ( ) . Trim ( ) ; //摘要,规则生成 "转运费" +
CwVouitemsEntity . DEPTID = strDEPTID ; //部门(系统)
CwVouitemsEntity . EMPLID = strEMPLID ; //人员(系统)
CwVouitemsEntity . SALE = strSALE ; //人员名称
CwVouitemsEntity . PITEMID = 0 ; //父级项目编号
CwVouitemsEntity . ITEMID = "0" ; //项目编号
CwVouitemsEntity . FIELD1 = "" ; //预留字段1
CwVouitemsEntity . FIELD2 = "" ; //预留字段2
CwVouitemsEntity . FIELD3 = "" ; //预留字段3
CwVouitemsEntity . FIELD4 = "" ; //预留字段4
CwVouitemsEntity . FIELD5 = "" ; //预留字段5
CwVouitemsEntity . FIELD6 = "" ; //预留字段6
CwVouitemsEntity . FIELD7 = "" ; //预留字段7
CwVouitemsEntity . FIELD8 = "" ; //预留字段8
CwVouitemsEntity . FIELD9 = "" ; //预留字段9
CwVouitemsEntity . FIELD10 = "" ; //预留字段10
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISVBM" ] . ToString ( ) . Trim ( ) = = "True" )
{
CwVouitemsEntity . ISSYS = false ; //是否手动录入
}
else
{
CwVouitemsEntity . ISSYS = true ; //是否手动录入
}
CwVouitemsEntity . FSETTLCODE = "" ; //结算方式
CwVouitemsEntity . FSETTLENO = "" ; //财务辅助编号
CwVouitemsEntity . MODIFIEDUSER = strUserID ; //最后一次更新操作人
CwVouitemsEntity . BLNO = strBLNO ; / /
if ( strBLNO . Trim ( ) = = "" )
{
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISMBLNO" ] . ToString ( ) . Trim ( ) = = "True" )
{
CwVouitemsEntity . BLNO = ds1 . Tables [ 0 ] . Rows [ i ] [ "mblno" ] . ToString ( ) . Trim ( ) ; / /
}
}
CwVouitemsEntities . Add ( CwVouitemsEntity ) ;
}
}
# endregion
#region 收入\成本 生成 全额\差额
Decimal dRMB = dRMBS - dRMBF ;
Decimal dUSD = dUSDS - dUSDF ;
//收入\成本 生成 全额\差额
Decimal strJie = dRMBS + Math . Round ( dUSDS * usdRATES , 2 , MidpointRounding . AwayFromZero ) ;
Decimal strDai = dRMBF + Math . Round ( dUSDF * usdRATEF , 2 , MidpointRounding . AwayFromZero ) ;
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISTCOIIED" ] . ToString ( ) . Trim ( ) = = "True" ) //是否核算外币
{
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "AMCODE" ] . ToString ( ) . Trim ( ) = = "1" ) //全额
{
//for (int j = 0; j < ds1.Tables[0].Rows.Count; j++)
//{
#region 全额
# endregion
//}
#region 全额
Decimal dlSR = dRMBS ;
if ( dlSR ! = 0 )
{
#region 收入RMB
n = n + 1 ;
CwVouitemsEntity CwVouitemsEntity2 = new CwVouitemsEntity ( ) ;
//CwVouitemsEntity2.GID 唯一编码 newid()
CwVouitemsEntity2 . ORDNO = strORDNO . Trim ( ) ;
CwVouitemsEntity2 . ITEMNO = n ; // 行号
CwVouitemsEntity2 . PACCID = "" ; //父级科目贷码
CwVouitemsEntity2 . PROPERTY = 0 ; //科目属性
CwVouitemsEntity2 . GRADE = 0 ; //科目级别
CwVouitemsEntity2 . ACCID = ds . Tables [ 0 ] . Rows [ 0 ] [ "MBINCOME" ] . ToString ( ) . Trim ( ) ; //主营业务收入科目贷码
CwVouitemsEntity2 . AMTDR = 0 ; //本位币借方金额(互斥)
CwVouitemsEntity2 . AMTCR = dRMBS ; //本位币贷方金额(互斥)
strDai = strDai + dRMBS ;
CwVouitemsEntity2 . ISFCY = false ; //是否外币
CwVouitemsEntity2 . FCYNO = "RMB" ; //外币编号usd
CwVouitemsEntity2 . FCYDR = 0 ; //外币借方金额
CwVouitemsEntity2 . FCYCR = 0 ; //外币贷方金额
if ( ds8 = = null )
{
CwVouitemsEntity2 . ACCNAME = "" ; //科目名称
CwVouitemsEntity2 . ISDEPTACC = false ; //核算部门,按规则设置生成
CwVouitemsEntity2 . ISEMPLACC = false ; //核算人员,按规则设置生成
CwVouitemsEntity2 . ISCORPACC = false ; //核算客户,按规则设置生成
CwVouitemsEntity2 . ISITEMACC = false ; //核算项目,按规则设置生成
CwVouitemsEntity2 . DC = "C" ; //贷方向
}
else
{
CwVouitemsEntity2 . ACCNAME = ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ACCNAME" ] . ToString ( ) . Trim ( ) ; //科目名称
CwVouitemsEntity2 . ISDEPTACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISDEPTACC" ] . ToString ( ) . Trim ( ) ) ; //核算部门,按规则设置生成
CwVouitemsEntity2 . ISEMPLACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISEMPLACC" ] . ToString ( ) . Trim ( ) ) ; //核算人员,按规则设置生成
CwVouitemsEntity2 . ISCORPACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISCORPACC" ] . ToString ( ) . Trim ( ) ) ; //核算客户,按规则设置生成
CwVouitemsEntity2 . ISITEMACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISITEMACC" ] . ToString ( ) . Trim ( ) ) ; //核算项目,按规则设置生成
if ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "DC" ] . ToString ( ) . Trim ( ) = = "借" )
{
CwVouitemsEntity2 . DC = "D" ; //借方向
}
else
{
CwVouitemsEntity2 . DC = "C" ; //贷方向
}
}
CwVouitemsEntity2 . CORPID = "" ; // strEMPLID;//人员(系统)本来应该放客户
CwVouitemsEntity2 . CUSTOMERNAME = "" ; // strSALE;//人员(系统)本来应该放客户
CwVouitemsEntity2 . FCYEXRATE = 1 ; //汇率
//dEXCHANGERATE = Decimal.Parse(ds1.Tables[0].Rows[j]["EXCHANGERATE"].ToString().Trim());//汇率
CwVouitemsEntity2 . QTYUNIT = "" ; //数量包装单位
CwVouitemsEntity2 . QTYDR = 0 ; //借方数量
CwVouitemsEntity2 . QTYCR = 0 ; //贷方数量
CwVouitemsEntity2 . EXPLAN = strEXPLAN ; //摘要,规则生成 "转运费" +
CwVouitemsEntity2 . DEPTID = strDEPTID ; //部门(系统)
CwVouitemsEntity2 . EMPLID = strEMPLID ; //人员(系统)
CwVouitemsEntity2 . SALE = strSALE ; //人员名称
CwVouitemsEntity2 . PITEMID = 0 ; //父级项目编号
CwVouitemsEntity2 . ITEMID = "0" ; //项目编号
CwVouitemsEntity2 . FIELD1 = "" ; //预留字段1
CwVouitemsEntity2 . FIELD2 = "" ; //预留字段2
CwVouitemsEntity2 . FIELD3 = "" ; //预留字段3
CwVouitemsEntity2 . FIELD4 = "" ; //预留字段4
CwVouitemsEntity2 . FIELD5 = "" ; //预留字段5
CwVouitemsEntity2 . FIELD6 = "" ; //预留字段6
CwVouitemsEntity2 . FIELD7 = "" ; //预留字段7
CwVouitemsEntity2 . FIELD8 = "" ; //预留字段8
CwVouitemsEntity2 . FIELD9 = "" ; //预留字段9
CwVouitemsEntity2 . FIELD10 = "" ; //预留字段10
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISVBM" ] . ToString ( ) . Trim ( ) = = "True" )
{
CwVouitemsEntity2 . ISSYS = false ; //是否手动录入
}
else
{
CwVouitemsEntity2 . ISSYS = true ; //是否手动录入
}
CwVouitemsEntity2 . FSETTLCODE = "" ; //结算方式
CwVouitemsEntity2 . FSETTLENO = "" ; //财务辅助编号
CwVouitemsEntity2 . MODIFIEDUSER = strUserID ; //最后一次更新操作人
CwVouitemsEntity2 . BLNO = strBLNO ; / /
# endregion
CwVouitemsEntities . Add ( CwVouitemsEntity2 ) ;
}
dlSR = dUSDS * usdRATES ;
if ( dlSR ! = 0 )
{
#region 收入USD
n = n + 1 ;
CwVouitemsEntity CwVouitemsEntity2 = new CwVouitemsEntity ( ) ;
//CwVouitemsEntity2.GID 唯一编码 newid()
CwVouitemsEntity2 . ORDNO = strORDNO . Trim ( ) ;
CwVouitemsEntity2 . ITEMNO = n ; // 行号
CwVouitemsEntity2 . PACCID = "" ; //父级科目贷码
CwVouitemsEntity2 . PROPERTY = 0 ; //科目属性
CwVouitemsEntity2 . GRADE = 0 ; //科目级别
CwVouitemsEntity2 . ACCID = ds . Tables [ 0 ] . Rows [ 0 ] [ "MBINCOME" ] . ToString ( ) . Trim ( ) ; //主营业务收入科目贷码
CwVouitemsEntity2 . AMTDR = 0 ; //本位币借方金额(互斥)
CwVouitemsEntity2 . AMTCR = Math . Round ( ( dUSDS * usdRATES ) , 2 , MidpointRounding . AwayFromZero ) ; //本位币贷方金额(互斥)
strDai = strDai + Math . Round ( ( dUSDS * usdRATES ) , 2 , MidpointRounding . AwayFromZero ) ;
CwVouitemsEntity2 . ISFCY = true ; //是否外币
CwVouitemsEntity2 . FCYNO = "USD" ; //外币编号usd
CwVouitemsEntity2 . FCYDR = 0 ; //外币借方金额
CwVouitemsEntity2 . FCYCR = dUSDS ; //外币贷方金额
CwVouitemsEntity2 . FCYEXRATE = usdRATES ; //汇率
if ( ds8 = = null )
{
CwVouitemsEntity2 . ACCNAME = "" ; //科目名称
CwVouitemsEntity2 . ISDEPTACC = false ; //核算部门,按规则设置生成
CwVouitemsEntity2 . ISEMPLACC = false ; //核算人员,按规则设置生成
CwVouitemsEntity2 . ISCORPACC = false ; //核算客户,按规则设置生成
CwVouitemsEntity2 . ISITEMACC = false ; //核算项目,按规则设置生成
CwVouitemsEntity2 . DC = "C" ; //贷方向
}
else
{
CwVouitemsEntity2 . ACCNAME = ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ACCNAME" ] . ToString ( ) . Trim ( ) ; //科目名称
CwVouitemsEntity2 . ISDEPTACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISDEPTACC" ] . ToString ( ) . Trim ( ) ) ; //核算部门,按规则设置生成
CwVouitemsEntity2 . ISEMPLACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISEMPLACC" ] . ToString ( ) . Trim ( ) ) ; //核算人员,按规则设置生成
CwVouitemsEntity2 . ISCORPACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISCORPACC" ] . ToString ( ) . Trim ( ) ) ; //核算客户,按规则设置生成
CwVouitemsEntity2 . ISITEMACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISITEMACC" ] . ToString ( ) . Trim ( ) ) ; //核算项目,按规则设置生成
if ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "DC" ] . ToString ( ) . Trim ( ) = = "借" )
{
CwVouitemsEntity2 . DC = "D" ; //借方向
}
else
{
CwVouitemsEntity2 . DC = "C" ; //贷方向
}
}
CwVouitemsEntity2 . CORPID = "" ; // strEMPLID;//人员(系统)本来应该放客户
CwVouitemsEntity2 . CUSTOMERNAME = "" ; // strSALE;//人员(系统)本来应该放客户
//dEXCHANGERATE = Decimal.Parse(ds1.Tables[0].Rows[j]["EXCHANGERATE"].ToString().Trim());//汇率
CwVouitemsEntity2 . QTYUNIT = "" ; //数量包装单位
CwVouitemsEntity2 . QTYDR = 0 ; //借方数量
CwVouitemsEntity2 . QTYCR = 0 ; //贷方数量
CwVouitemsEntity2 . EXPLAN = strEXPLAN ; //摘要,规则生成 "转运费" +
CwVouitemsEntity2 . DEPTID = strDEPTID ; //部门(系统)
CwVouitemsEntity2 . EMPLID = strEMPLID ; //人员(系统)
CwVouitemsEntity2 . SALE = strSALE ; //人员名称
CwVouitemsEntity2 . PITEMID = 0 ; //父级项目编号
CwVouitemsEntity2 . ITEMID = "0" ; //项目编号
CwVouitemsEntity2 . FIELD1 = "" ; //预留字段1
CwVouitemsEntity2 . FIELD2 = "" ; //预留字段2
CwVouitemsEntity2 . FIELD3 = "" ; //预留字段3
CwVouitemsEntity2 . FIELD4 = "" ; //预留字段4
CwVouitemsEntity2 . FIELD5 = "" ; //预留字段5
CwVouitemsEntity2 . FIELD6 = "" ; //预留字段6
CwVouitemsEntity2 . FIELD7 = "" ; //预留字段7
CwVouitemsEntity2 . FIELD8 = "" ; //预留字段8
CwVouitemsEntity2 . FIELD9 = "" ; //预留字段9
CwVouitemsEntity2 . FIELD10 = "" ; //预留字段10
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISVBM" ] . ToString ( ) . Trim ( ) = = "True" )
{
CwVouitemsEntity2 . ISSYS = false ; //是否手动录入
}
else
{
CwVouitemsEntity2 . ISSYS = true ; //是否手动录入
}
CwVouitemsEntity2 . FSETTLCODE = "" ; //结算方式
CwVouitemsEntity2 . FSETTLENO = "" ; //财务辅助编号
CwVouitemsEntity2 . MODIFIEDUSER = strUserID ; //最后一次更新操作人
CwVouitemsEntity2 . BLNO = strBLNO ; / /
# endregion
CwVouitemsEntities . Add ( CwVouitemsEntity2 ) ;
}
Decimal dlZC = dRMBF ;
if ( dlZC ! = 0 )
{
#region 支出RMB
n = n + 1 ;
CwVouitemsEntity CwVouitemsEntity4 = new CwVouitemsEntity ( ) ;
//CwVouitemsEntity4.GID 唯一编码 newid()
CwVouitemsEntity4 . ORDNO = strORDNO . Trim ( ) ;
CwVouitemsEntity4 . ITEMNO = n ; // 行号
CwVouitemsEntity4 . PACCID = "" ; //父级科目贷码
CwVouitemsEntity4 . PROPERTY = 0 ; //科目属性
CwVouitemsEntity4 . GRADE = 0 ; //科目级别
CwVouitemsEntity4 . ACCID = ds . Tables [ 0 ] . Rows [ 0 ] [ "MBSPENDING" ] . ToString ( ) . Trim ( ) ; //主营业务支出科目贷码
CwVouitemsEntity4 . AMTDR = dRMBF ; //本位币借方金额(互斥)
strJie = strJie + dRMBF ;
CwVouitemsEntity4 . AMTCR = 0 ; //本位币贷方金额(互斥)
CwVouitemsEntity4 . ISFCY = false ; //是否外币
CwVouitemsEntity4 . FCYNO = "RMB" ; //外币编号usd
CwVouitemsEntity4 . FCYDR = 0 ; //外币借方金额
CwVouitemsEntity4 . FCYCR = 0 ; //外币贷方金额
if ( ds9 = = null )
{
CwVouitemsEntity4 . ACCNAME = "" ; //科目名称
CwVouitemsEntity4 . ISDEPTACC = false ; //核算部门,按规则设置生成
CwVouitemsEntity4 . ISEMPLACC = false ; //核算人员,按规则设置生成
CwVouitemsEntity4 . ISCORPACC = false ; //核算客户,按规则设置生成
CwVouitemsEntity4 . ISITEMACC = false ; //核算项目,按规则设置生成
CwVouitemsEntity4 . DC = "D" ; //借方向
}
else
{
CwVouitemsEntity4 . ACCNAME = ds9 . Tables [ 0 ] . Rows [ 0 ] [ "ACCNAME" ] . ToString ( ) . Trim ( ) ; //科目名称
CwVouitemsEntity4 . ISDEPTACC = Boolean . Parse ( ds9 . Tables [ 0 ] . Rows [ 0 ] [ "ISDEPTACC" ] . ToString ( ) . Trim ( ) ) ; //核算部门,按规则设置生成
CwVouitemsEntity4 . ISEMPLACC = Boolean . Parse ( ds9 . Tables [ 0 ] . Rows [ 0 ] [ "ISEMPLACC" ] . ToString ( ) . Trim ( ) ) ; //核算人员,按规则设置生成
CwVouitemsEntity4 . ISCORPACC = Boolean . Parse ( ds9 . Tables [ 0 ] . Rows [ 0 ] [ "ISCORPACC" ] . ToString ( ) . Trim ( ) ) ; //核算客户,按规则设置生成
CwVouitemsEntity4 . ISITEMACC = Boolean . Parse ( ds9 . Tables [ 0 ] . Rows [ 0 ] [ "ISITEMACC" ] . ToString ( ) . Trim ( ) ) ; //核算项目,按规则设置生成
if ( ds9 . Tables [ 0 ] . Rows [ 0 ] [ "DC" ] . ToString ( ) . Trim ( ) = = "借" )
{
CwVouitemsEntity4 . DC = "D" ; //借方向
}
else
{
CwVouitemsEntity4 . DC = "C" ; //贷方向
}
}
CwVouitemsEntity4 . CORPID = "" ; // strEMPLID;//人员(系统)本来应该放客户
CwVouitemsEntity4 . CUSTOMERNAME = "" ; // strSALE;//人员(系统)本来应该放客户
CwVouitemsEntity4 . FCYEXRATE = 1 ; //汇率
//dEXCHANGERATE = Decimal.Parse(ds1.Tables[0].Rows[j]["EXCHANGERATE"].ToString().Trim());//汇率
CwVouitemsEntity4 . QTYUNIT = "" ; //数量包装单位
CwVouitemsEntity4 . QTYDR = 0 ; //借方数量
CwVouitemsEntity4 . QTYCR = 0 ; //贷方数量
CwVouitemsEntity4 . EXPLAN = strEXPLAN ; //摘要,规则生成 "转运费" +
CwVouitemsEntity4 . DEPTID = strDEPTID ; //部门(系统)
CwVouitemsEntity4 . EMPLID = strEMPLID ; //人员(系统)
CwVouitemsEntity4 . SALE = strSALE ; //人员名称
CwVouitemsEntity4 . PITEMID = 0 ; //父级项目编号
CwVouitemsEntity4 . ITEMID = "0" ; //项目编号
CwVouitemsEntity4 . FIELD1 = "" ; //预留字段1
CwVouitemsEntity4 . FIELD2 = "" ; //预留字段2
CwVouitemsEntity4 . FIELD3 = "" ; //预留字段3
CwVouitemsEntity4 . FIELD4 = "" ; //预留字段4
CwVouitemsEntity4 . FIELD5 = "" ; //预留字段5
CwVouitemsEntity4 . FIELD6 = "" ; //预留字段6
CwVouitemsEntity4 . FIELD7 = "" ; //预留字段7
CwVouitemsEntity4 . FIELD8 = "" ; //预留字段8
CwVouitemsEntity4 . FIELD9 = "" ; //预留字段9
CwVouitemsEntity4 . FIELD10 = "" ; //预留字段10
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISVBM" ] . ToString ( ) . Trim ( ) = = "True" )
{
CwVouitemsEntity4 . ISSYS = false ; //是否手动录入
}
else
{
CwVouitemsEntity4 . ISSYS = true ; //是否手动录入
}
CwVouitemsEntity4 . FSETTLCODE = "" ; //结算方式
CwVouitemsEntity4 . FSETTLENO = "" ; //财务辅助编号
CwVouitemsEntity4 . MODIFIEDUSER = strUserID ; //最后一次更新操作人
CwVouitemsEntity4 . BLNO = strBLNO ; / /
# endregion
CwVouitemsEntities . Add ( CwVouitemsEntity4 ) ;
}
dlZC = dUSDF * usdRATEF ;
if ( dlZC ! = 0 )
{
#region 支出USD
n = n + 1 ;
CwVouitemsEntity CwVouitemsEntity4 = new CwVouitemsEntity ( ) ;
//CwVouitemsEntity4.GID 唯一编码 newid()
CwVouitemsEntity4 . ORDNO = strORDNO . Trim ( ) ;
CwVouitemsEntity4 . ITEMNO = n ; // 行号
CwVouitemsEntity4 . PACCID = "" ; //父级科目贷码
CwVouitemsEntity4 . PROPERTY = 0 ; //科目属性
CwVouitemsEntity4 . GRADE = 0 ; //科目级别
CwVouitemsEntity4 . ACCID = ds . Tables [ 0 ] . Rows [ 0 ] [ "MBSPENDING" ] . ToString ( ) . Trim ( ) ; //主营业务支出科目贷码
CwVouitemsEntity4 . AMTDR = Math . Round ( ( dUSDF * usdRATEF ) , 2 , MidpointRounding . AwayFromZero ) ; //本位币借方金额(互斥)
strJie = strJie + Math . Round ( ( dUSDF * usdRATEF ) , 2 , MidpointRounding . AwayFromZero ) ;
CwVouitemsEntity4 . AMTCR = 0 ; //本位币贷方金额(互斥)
CwVouitemsEntity4 . ISFCY = true ; //是否外币
CwVouitemsEntity4 . FCYNO = "USD" ; //外币编号usd
CwVouitemsEntity4 . FCYDR = dUSDF ; //外币借方金额
CwVouitemsEntity4 . FCYCR = 0 ; //外币贷方金额
CwVouitemsEntity4 . FCYEXRATE = usdRATEF ; //汇率
if ( ds9 = = null )
{
CwVouitemsEntity4 . ACCNAME = "" ; //科目名称
CwVouitemsEntity4 . ISDEPTACC = false ; //核算部门,按规则设置生成
CwVouitemsEntity4 . ISEMPLACC = false ; //核算人员,按规则设置生成
CwVouitemsEntity4 . ISCORPACC = false ; //核算客户,按规则设置生成
CwVouitemsEntity4 . ISITEMACC = false ; //核算项目,按规则设置生成
CwVouitemsEntity4 . DC = "D" ; //借方向
}
else
{
CwVouitemsEntity4 . ACCNAME = ds9 . Tables [ 0 ] . Rows [ 0 ] [ "ACCNAME" ] . ToString ( ) . Trim ( ) ; //科目名称
CwVouitemsEntity4 . ISDEPTACC = Boolean . Parse ( ds9 . Tables [ 0 ] . Rows [ 0 ] [ "ISDEPTACC" ] . ToString ( ) . Trim ( ) ) ; //核算部门,按规则设置生成
CwVouitemsEntity4 . ISEMPLACC = Boolean . Parse ( ds9 . Tables [ 0 ] . Rows [ 0 ] [ "ISEMPLACC" ] . ToString ( ) . Trim ( ) ) ; //核算人员,按规则设置生成
CwVouitemsEntity4 . ISCORPACC = Boolean . Parse ( ds9 . Tables [ 0 ] . Rows [ 0 ] [ "ISCORPACC" ] . ToString ( ) . Trim ( ) ) ; //核算客户,按规则设置生成
CwVouitemsEntity4 . ISITEMACC = Boolean . Parse ( ds9 . Tables [ 0 ] . Rows [ 0 ] [ "ISITEMACC" ] . ToString ( ) . Trim ( ) ) ; //核算项目,按规则设置生成
if ( ds9 . Tables [ 0 ] . Rows [ 0 ] [ "DC" ] . ToString ( ) . Trim ( ) = = "借" )
{
CwVouitemsEntity4 . DC = "D" ; //借方向
}
else
{
CwVouitemsEntity4 . DC = "C" ; //贷方向
}
}
CwVouitemsEntity4 . CORPID = "" ; // strEMPLID;//人员(系统)本来应该放客户
CwVouitemsEntity4 . CUSTOMERNAME = "" ; // strSALE;//人员(系统)本来应该放客户
//dEXCHANGERATE = Decimal.Parse(ds1.Tables[0].Rows[j]["EXCHANGERATE"].ToString().Trim());//汇率
CwVouitemsEntity4 . QTYUNIT = "" ; //数量包装单位
CwVouitemsEntity4 . QTYDR = 0 ; //借方数量
CwVouitemsEntity4 . QTYCR = 0 ; //贷方数量
CwVouitemsEntity4 . EXPLAN = strEXPLAN ; //摘要,规则生成 "转运费" +
CwVouitemsEntity4 . DEPTID = strDEPTID ; //部门(系统)
CwVouitemsEntity4 . EMPLID = strEMPLID ; //人员(系统)
CwVouitemsEntity4 . SALE = strSALE ; //人员名称
CwVouitemsEntity4 . PITEMID = 0 ; //父级项目编号
CwVouitemsEntity4 . ITEMID = "0" ; //项目编号
CwVouitemsEntity4 . FIELD1 = "" ; //预留字段1
CwVouitemsEntity4 . FIELD2 = "" ; //预留字段2
CwVouitemsEntity4 . FIELD3 = "" ; //预留字段3
CwVouitemsEntity4 . FIELD4 = "" ; //预留字段4
CwVouitemsEntity4 . FIELD5 = "" ; //预留字段5
CwVouitemsEntity4 . FIELD6 = "" ; //预留字段6
CwVouitemsEntity4 . FIELD7 = "" ; //预留字段7
CwVouitemsEntity4 . FIELD8 = "" ; //预留字段8
CwVouitemsEntity4 . FIELD9 = "" ; //预留字段9
CwVouitemsEntity4 . FIELD10 = "" ; //预留字段10
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISVBM" ] . ToString ( ) . Trim ( ) = = "True" )
{
CwVouitemsEntity4 . ISSYS = false ; //是否手动录入
}
else
{
CwVouitemsEntity4 . ISSYS = true ; //是否手动录入
}
CwVouitemsEntity4 . FSETTLCODE = "" ; //结算方式
CwVouitemsEntity4 . FSETTLENO = "" ; //财务辅助编号
CwVouitemsEntity4 . MODIFIEDUSER = strUserID ; //最后一次更新操作人
CwVouitemsEntity4 . BLNO = strBLNO ; / /
# endregion
CwVouitemsEntities . Add ( CwVouitemsEntity4 ) ;
}
# endregion
}
else if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "AMCODE" ] . ToString ( ) . Trim ( ) = = "2" ) //差额
{
#region 差额
if ( dRMB ! = 0 )
{
#region dRMB != 0
CwVouitemsEntity CwVouitemsEntity1 = new CwVouitemsEntity ( ) ;
//CwVouitemsEntity1.GID 唯一编码 newid()
CwVouitemsEntity1 . ORDNO = strORDNO . Trim ( ) ;
n = n + 1 ;
CwVouitemsEntity1 . ITEMNO = n ; // 行号
CwVouitemsEntity1 . PACCID = "" ; //父级科目贷码
CwVouitemsEntity1 . PROPERTY = 0 ; //科目属性
CwVouitemsEntity1 . GRADE = 0 ; //科目级别
CwVouitemsEntity1 . ACCID = ds . Tables [ 0 ] . Rows [ 0 ] [ "MBINCOME" ] . ToString ( ) . Trim ( ) ; //主营业务收入科目贷码
CwVouitemsEntity1 . AMTDR = 0 ; //本位币借方金额(互斥)
CwVouitemsEntity1 . AMTCR = Decimal . Parse ( dRMB . ToString ( ) . Trim ( ) ) ; //本位币贷方金额(互斥)
strDai = strDai + Decimal . Parse ( dRMB . ToString ( ) . Trim ( ) ) ;
CwVouitemsEntity1 . ISFCY = false ; //是否外币
CwVouitemsEntity1 . FCYNO = "RMB" ; //外币编号usd
CwVouitemsEntity1 . FCYDR = 0 ; //外币借方金额
CwVouitemsEntity1 . FCYCR = 0 ; //外币贷方金额
if ( ds8 = = null )
{
CwVouitemsEntity1 . ACCNAME = "" ; //科目名称
CwVouitemsEntity1 . ISDEPTACC = false ; //核算部门,按规则设置生成
CwVouitemsEntity1 . ISEMPLACC = false ; //核算人员,按规则设置生成
CwVouitemsEntity1 . ISCORPACC = false ; //核算客户,按规则设置生成
CwVouitemsEntity1 . ISITEMACC = false ; //核算项目,按规则设置生成
CwVouitemsEntity1 . DC = "C" ; //贷方向
}
else
{
CwVouitemsEntity1 . ACCNAME = ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ACCNAME" ] . ToString ( ) . Trim ( ) ; //科目名称
CwVouitemsEntity1 . ISDEPTACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISDEPTACC" ] . ToString ( ) . Trim ( ) ) ; //核算部门,按规则设置生成
CwVouitemsEntity1 . ISEMPLACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISEMPLACC" ] . ToString ( ) . Trim ( ) ) ; //核算人员,按规则设置生成
CwVouitemsEntity1 . ISCORPACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISCORPACC" ] . ToString ( ) . Trim ( ) ) ; //核算客户,按规则设置生成
CwVouitemsEntity1 . ISITEMACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISITEMACC" ] . ToString ( ) . Trim ( ) ) ; //核算项目,按规则设置生成
if ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "DC" ] . ToString ( ) . Trim ( ) = = "借" )
{
CwVouitemsEntity1 . DC = "D" ; //借方向
}
else
{
CwVouitemsEntity1 . DC = "C" ; //贷方向
}
}
CwVouitemsEntity1 . CORPID = "" ; // strEMPLID;//人员(系统)本来应该放客户
CwVouitemsEntity1 . CUSTOMERNAME = "" ; // strSALE;//人员(系统)本来应该放客户
CwVouitemsEntity1 . FCYEXRATE = 1 ; //汇率
CwVouitemsEntity1 . QTYUNIT = "" ; //数量包装单位
CwVouitemsEntity1 . QTYDR = 0 ; //借方数量
CwVouitemsEntity1 . QTYCR = 0 ; //贷方数量
CwVouitemsEntity1 . EXPLAN = strEXPLAN ; //摘要,规则生成 "转运费" +
CwVouitemsEntity1 . DEPTID = strDEPTID ; //部门(系统)
CwVouitemsEntity1 . EMPLID = strEMPLID ; //人员(系统)
CwVouitemsEntity1 . SALE = strSALE ; //人员名称
CwVouitemsEntity1 . PITEMID = 0 ; //父级项目编号
CwVouitemsEntity1 . ITEMID = "0" ; //项目编号
CwVouitemsEntity1 . FIELD1 = "" ; //预留字段1
CwVouitemsEntity1 . FIELD2 = "" ; //预留字段2
CwVouitemsEntity1 . FIELD3 = "" ; //预留字段3
CwVouitemsEntity1 . FIELD4 = "" ; //预留字段4
CwVouitemsEntity1 . FIELD5 = "" ; //预留字段5
CwVouitemsEntity1 . FIELD6 = "" ; //预留字段6
CwVouitemsEntity1 . FIELD7 = "" ; //预留字段7
CwVouitemsEntity1 . FIELD8 = "" ; //预留字段8
CwVouitemsEntity1 . FIELD9 = "" ; //预留字段9
CwVouitemsEntity1 . FIELD10 = "" ; //预留字段10
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISVBM" ] . ToString ( ) . Trim ( ) = = "True" )
{
CwVouitemsEntity1 . ISSYS = false ; //是否手动录入
}
else
{
CwVouitemsEntity1 . ISSYS = true ; //是否手动录入
}
CwVouitemsEntity1 . FSETTLCODE = "" ; //结算方式
CwVouitemsEntity1 . FSETTLENO = "" ; //财务辅助编号
CwVouitemsEntity1 . MODIFIEDUSER = strUserID ; //最后一次更新操作人
CwVouitemsEntity1 . BLNO = strBLNO ; / /
# endregion
CwVouitemsEntities . Add ( CwVouitemsEntity1 ) ;
}
if ( dUSD ! = 0 )
{
#region dUSD != 0
CwVouitemsEntity CwVouitemsEntity3 = new CwVouitemsEntity ( ) ;
CwVouitemsEntity3 . ORDNO = strORDNO . Trim ( ) ;
n = n + 1 ;
CwVouitemsEntity3 . ITEMNO = n ; // 行号
CwVouitemsEntity3 . PACCID = "" ; //父级科目贷码
CwVouitemsEntity3 . PROPERTY = 0 ; //科目属性
CwVouitemsEntity3 . GRADE = 0 ; //科目级别
CwVouitemsEntity3 . ACCID = ds . Tables [ 0 ] . Rows [ 0 ] [ "TMFCI" ] . ToString ( ) . Trim ( ) ; //应收账款外币科目贷码
CwVouitemsEntity3 . AMTDR = 0 ; //本位币借方金额(互斥)
CwVouitemsEntity3 . AMTCR = Math . Round ( Decimal . Parse ( dUSD . ToString ( ) . Trim ( ) ) * ( usdRATEF = = 0 ? usdRATES : usdRATEF ) , 2 , MidpointRounding . AwayFromZero ) ; //本位币贷方金额(互斥)
strDai = strDai + Math . Round ( Decimal . Parse ( dUSD . ToString ( ) . Trim ( ) ) * ( usdRATEF = = 0 ? usdRATES : usdRATEF ) , 2 , MidpointRounding . AwayFromZero ) ;
CwVouitemsEntity3 . ISFCY = true ; //是否外币
CwVouitemsEntity3 . FCYNO = "USD" ; //外币编号usd
CwVouitemsEntity3 . FCYDR = 0 ; //外币借方金额
CwVouitemsEntity3 . FCYCR = Decimal . Parse ( dUSD . ToString ( ) . Trim ( ) ) ; //外币贷方金额
if ( ds10 = = null )
{
CwVouitemsEntity3 . ACCNAME = "" ; //科目名称
CwVouitemsEntity3 . ISDEPTACC = false ; //核算部门,按规则设置生成
CwVouitemsEntity3 . ISEMPLACC = false ; //核算人员,按规则设置生成
CwVouitemsEntity3 . ISCORPACC = false ; //核算客户,按规则设置生成
CwVouitemsEntity3 . ISITEMACC = false ; //核算项目,按规则设置生成
CwVouitemsEntity3 . DC = "C" ; //贷方向
}
else
{
CwVouitemsEntity3 . ACCNAME = ds10 . Tables [ 0 ] . Rows [ 0 ] [ "ACCNAME" ] . ToString ( ) . Trim ( ) ; //科目名称
CwVouitemsEntity3 . ISDEPTACC = Boolean . Parse ( ds10 . Tables [ 0 ] . Rows [ 0 ] [ "ISDEPTACC" ] . ToString ( ) . Trim ( ) ) ; //核算部门,按规则设置生成
CwVouitemsEntity3 . ISEMPLACC = Boolean . Parse ( ds10 . Tables [ 0 ] . Rows [ 0 ] [ "ISEMPLACC" ] . ToString ( ) . Trim ( ) ) ; //核算人员,按规则设置生成
CwVouitemsEntity3 . ISCORPACC = Boolean . Parse ( ds10 . Tables [ 0 ] . Rows [ 0 ] [ "ISCORPACC" ] . ToString ( ) . Trim ( ) ) ; //核算客户,按规则设置生成
CwVouitemsEntity3 . ISITEMACC = Boolean . Parse ( ds10 . Tables [ 0 ] . Rows [ 0 ] [ "ISITEMACC" ] . ToString ( ) . Trim ( ) ) ; //核算项目,按规则设置生成
if ( ds10 . Tables [ 0 ] . Rows [ 0 ] [ "DC" ] . ToString ( ) . Trim ( ) = = "借" )
{
CwVouitemsEntity3 . DC = "D" ; //借方向
}
else
{
CwVouitemsEntity3 . DC = "C" ; //贷方向
}
}
CwVouitemsEntity3 . CORPID = "" ; // strEMPLID;//人员(系统)本来应该放客户
CwVouitemsEntity3 . CUSTOMERNAME = "" ; // strSALE;//人员(系统)本来应该放客户
CwVouitemsEntity3 . FCYEXRATE = ( usdRATEF = = 0 ? usdRATES : usdRATEF ) ; //汇率
CwVouitemsEntity3 . QTYUNIT = "" ; //数量包装单位
CwVouitemsEntity3 . QTYDR = 0 ; //借方数量
CwVouitemsEntity3 . QTYCR = 0 ; //贷方数量
CwVouitemsEntity3 . EXPLAN = strEXPLAN ; //摘要,规则生成 "转运费" +
CwVouitemsEntity3 . DEPTID = strDEPTID ; //部门(系统)
CwVouitemsEntity3 . EMPLID = strEMPLID ; //人员(系统)
CwVouitemsEntity3 . SALE = strSALE ; //人员名称
CwVouitemsEntity3 . PITEMID = 0 ; //父级项目编号
CwVouitemsEntity3 . ITEMID = "0" ; //项目编号
CwVouitemsEntity3 . FIELD1 = "" ; //预留字段1
CwVouitemsEntity3 . FIELD2 = "" ; //预留字段2
CwVouitemsEntity3 . FIELD3 = "" ; //预留字段3
CwVouitemsEntity3 . FIELD4 = "" ; //预留字段4
CwVouitemsEntity3 . FIELD5 = "" ; //预留字段5
CwVouitemsEntity3 . FIELD6 = "" ; //预留字段6
CwVouitemsEntity3 . FIELD7 = "" ; //预留字段7
CwVouitemsEntity3 . FIELD8 = "" ; //预留字段8
CwVouitemsEntity3 . FIELD9 = "" ; //预留字段9
CwVouitemsEntity3 . FIELD10 = "" ; //预留字段10
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISVBM" ] . ToString ( ) . Trim ( ) = = "True" )
{
CwVouitemsEntity3 . ISSYS = false ; //是否手动录入
}
else
{
CwVouitemsEntity3 . ISSYS = true ; //是否手动录入
}
CwVouitemsEntity3 . FSETTLCODE = "" ; //结算方式
CwVouitemsEntity3 . FSETTLENO = "" ; //财务辅助编号
CwVouitemsEntity3 . MODIFIEDUSER = strUserID ; //最后一次更新操作人
CwVouitemsEntity3 . BLNO = strBLNO ; / /
# endregion
CwVouitemsEntities . Add ( CwVouitemsEntity3 ) ;
}
# endregion
}
}
else
{
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "AMCODE" ] . ToString ( ) . Trim ( ) = = "1" ) //全额
{
#region 全额
// Decimal dlSR = dRMBS + (dUSDS * usdRATES);
Decimal dlSR = iAMTDR ;
if ( dlSR ! = 0 )
{
#region 收入
n = n + 1 ;
CwVouitemsEntity CwVouitemsEntity2 = new CwVouitemsEntity ( ) ;
//CwVouitemsEntity2.GID 唯一编码 newid()
CwVouitemsEntity2 . ORDNO = strORDNO . Trim ( ) ;
CwVouitemsEntity2 . ITEMNO = n ; // 行号
CwVouitemsEntity2 . PACCID = "" ; //父级科目贷码
CwVouitemsEntity2 . PROPERTY = 0 ; //科目属性
CwVouitemsEntity2 . GRADE = 0 ; //科目级别
CwVouitemsEntity2 . ACCID = ds . Tables [ 0 ] . Rows [ 0 ] [ "MBINCOME" ] . ToString ( ) . Trim ( ) ; //主营业务收入科目贷码
CwVouitemsEntity2 . AMTDR = 0 ; //本位币借方金额(互斥)
//CwVouitemsEntity2.AMTCR = dRMBS + (dUSDS * usdRATES);//本位币贷方金额(互斥)
//strDai = strDai + dRMBS + (dUSDS * usdRATES);
CwVouitemsEntity2 . AMTCR = iAMTDR ; //本位币贷方金额(互斥)
strDai = strDai + iAMTDR ;
CwVouitemsEntity2 . ISFCY = false ; //是否外币
CwVouitemsEntity2 . FCYNO = "RMB" ; //外币编号usd
CwVouitemsEntity2 . FCYDR = 0 ; //外币借方金额
CwVouitemsEntity2 . FCYCR = 0 ; //外币贷方金额
if ( ds8 = = null )
{
CwVouitemsEntity2 . ACCNAME = "" ; //科目名称
CwVouitemsEntity2 . ISDEPTACC = false ; //核算部门,按规则设置生成
CwVouitemsEntity2 . ISEMPLACC = false ; //核算人员,按规则设置生成
CwVouitemsEntity2 . ISCORPACC = false ; //核算客户,按规则设置生成
CwVouitemsEntity2 . ISITEMACC = false ; //核算项目,按规则设置生成
CwVouitemsEntity2 . DC = "C" ; //贷方向
}
else
{
CwVouitemsEntity2 . ACCNAME = ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ACCNAME" ] . ToString ( ) . Trim ( ) ; //科目名称
CwVouitemsEntity2 . ISDEPTACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISDEPTACC" ] . ToString ( ) . Trim ( ) ) ; //核算部门,按规则设置生成
CwVouitemsEntity2 . ISEMPLACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISEMPLACC" ] . ToString ( ) . Trim ( ) ) ; //核算人员,按规则设置生成
CwVouitemsEntity2 . ISCORPACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISCORPACC" ] . ToString ( ) . Trim ( ) ) ; //核算客户,按规则设置生成
CwVouitemsEntity2 . ISITEMACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISITEMACC" ] . ToString ( ) . Trim ( ) ) ; //核算项目,按规则设置生成
if ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "DC" ] . ToString ( ) . Trim ( ) = = "借" )
{
CwVouitemsEntity2 . DC = "D" ; //借方向
}
else
{
CwVouitemsEntity2 . DC = "C" ; //贷方向
}
}
CwVouitemsEntity2 . CORPID = "" ; // strEMPLID;//人员(系统)本来应该放客户
CwVouitemsEntity2 . CUSTOMERNAME = "" ; // strSALE;//人员(系统)本来应该放客户
CwVouitemsEntity2 . FCYEXRATE = 1 ; //汇率
//dEXCHANGERATE = Decimal.Parse(ds1.Tables[0].Rows[j]["EXCHANGERATE"].ToString().Trim());//汇率
CwVouitemsEntity2 . QTYUNIT = "" ; //数量包装单位
CwVouitemsEntity2 . QTYDR = 0 ; //借方数量
CwVouitemsEntity2 . QTYCR = 0 ; //贷方数量
CwVouitemsEntity2 . EXPLAN = strEXPLAN ; //摘要,规则生成 "转运费" +
CwVouitemsEntity2 . DEPTID = strDEPTID ; //部门(系统)
CwVouitemsEntity2 . EMPLID = strEMPLID ; //人员(系统)
CwVouitemsEntity2 . SALE = strSALE ; //人员名称
CwVouitemsEntity2 . PITEMID = 0 ; //父级项目编号
CwVouitemsEntity2 . ITEMID = "0" ; //项目编号
CwVouitemsEntity2 . FIELD1 = "" ; //预留字段1
CwVouitemsEntity2 . FIELD2 = "" ; //预留字段2
CwVouitemsEntity2 . FIELD3 = "" ; //预留字段3
CwVouitemsEntity2 . FIELD4 = "" ; //预留字段4
CwVouitemsEntity2 . FIELD5 = "" ; //预留字段5
CwVouitemsEntity2 . FIELD6 = "" ; //预留字段6
CwVouitemsEntity2 . FIELD7 = "" ; //预留字段7
CwVouitemsEntity2 . FIELD8 = "" ; //预留字段8
CwVouitemsEntity2 . FIELD9 = "" ; //预留字段9
CwVouitemsEntity2 . FIELD10 = "" ; //预留字段10
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISVBM" ] . ToString ( ) . Trim ( ) = = "True" )
{
CwVouitemsEntity2 . ISSYS = false ; //是否手动录入
}
else
{
CwVouitemsEntity2 . ISSYS = true ; //是否手动录入
}
CwVouitemsEntity2 . FSETTLCODE = "" ; //结算方式
CwVouitemsEntity2 . FSETTLENO = "" ; //财务辅助编号
CwVouitemsEntity2 . MODIFIEDUSER = strUserID ; //最后一次更新操作人
CwVouitemsEntity2 . BLNO = strBLNO ; / /
# endregion
CwVouitemsEntities . Add ( CwVouitemsEntity2 ) ;
}
Decimal dlZC = dRMBF + Math . Round ( ( dUSDF * usdRATEF ) , 2 , MidpointRounding . AwayFromZero ) ;
if ( dlZC ! = 0 )
{
#region 支出
n = n + 1 ;
CwVouitemsEntity CwVouitemsEntity4 = new CwVouitemsEntity ( ) ;
//CwVouitemsEntity4.GID 唯一编码 newid()
CwVouitemsEntity4 . ORDNO = strORDNO . Trim ( ) ;
CwVouitemsEntity4 . ITEMNO = n ; // 行号
CwVouitemsEntity4 . PACCID = "" ; //父级科目贷码
CwVouitemsEntity4 . PROPERTY = 0 ; //科目属性
CwVouitemsEntity4 . GRADE = 0 ; //科目级别
CwVouitemsEntity4 . ACCID = ds . Tables [ 0 ] . Rows [ 0 ] [ "MBSPENDING" ] . ToString ( ) . Trim ( ) ; //主营业务支出科目贷码
//CwVouitemsEntity4.AMTDR = dRMBF + (dUSDF * usdRATEF);//本位币借方金额(互斥)
//strJie = strJie + dRMBF + (dUSDF * usdRATEF);
CwVouitemsEntity4 . AMTDR = iAMTCR ; //本位币借方金额(互斥)
strJie = strJie + iAMTCR ;
CwVouitemsEntity4 . AMTCR = 0 ; //本位币贷方金额(互斥)
CwVouitemsEntity4 . ISFCY = false ; //是否外币
CwVouitemsEntity4 . FCYNO = "RMB" ; //外币编号usd
CwVouitemsEntity4 . FCYDR = 0 ; //外币借方金额
CwVouitemsEntity4 . FCYCR = 0 ; //外币贷方金额
if ( ds9 = = null )
{
CwVouitemsEntity4 . ACCNAME = "" ; //科目名称
CwVouitemsEntity4 . ISDEPTACC = false ; //核算部门,按规则设置生成
CwVouitemsEntity4 . ISEMPLACC = false ; //核算人员,按规则设置生成
CwVouitemsEntity4 . ISCORPACC = false ; //核算客户,按规则设置生成
CwVouitemsEntity4 . ISITEMACC = false ; //核算项目,按规则设置生成
CwVouitemsEntity4 . DC = "D" ; //借方向
}
else
{
CwVouitemsEntity4 . ACCNAME = ds9 . Tables [ 0 ] . Rows [ 0 ] [ "ACCNAME" ] . ToString ( ) . Trim ( ) ; //科目名称
CwVouitemsEntity4 . ISDEPTACC = Boolean . Parse ( ds9 . Tables [ 0 ] . Rows [ 0 ] [ "ISDEPTACC" ] . ToString ( ) . Trim ( ) ) ; //核算部门,按规则设置生成
CwVouitemsEntity4 . ISEMPLACC = Boolean . Parse ( ds9 . Tables [ 0 ] . Rows [ 0 ] [ "ISEMPLACC" ] . ToString ( ) . Trim ( ) ) ; //核算人员,按规则设置生成
CwVouitemsEntity4 . ISCORPACC = Boolean . Parse ( ds9 . Tables [ 0 ] . Rows [ 0 ] [ "ISCORPACC" ] . ToString ( ) . Trim ( ) ) ; //核算客户,按规则设置生成
CwVouitemsEntity4 . ISITEMACC = Boolean . Parse ( ds9 . Tables [ 0 ] . Rows [ 0 ] [ "ISITEMACC" ] . ToString ( ) . Trim ( ) ) ; //核算项目,按规则设置生成
if ( ds9 . Tables [ 0 ] . Rows [ 0 ] [ "DC" ] . ToString ( ) . Trim ( ) = = "借" )
{
CwVouitemsEntity4 . DC = "D" ; //借方向
}
else
{
CwVouitemsEntity4 . DC = "C" ; //贷方向
}
}
CwVouitemsEntity4 . CORPID = "" ; // strEMPLID;//人员(系统)本来应该放客户
CwVouitemsEntity4 . CUSTOMERNAME = "" ; // strSALE;//人员(系统)本来应该放客户
CwVouitemsEntity4 . FCYEXRATE = 1 ; //汇率
//dEXCHANGERATE = Decimal.Parse(ds1.Tables[0].Rows[j]["EXCHANGERATE"].ToString().Trim());//汇率
CwVouitemsEntity4 . QTYUNIT = "" ; //数量包装单位
CwVouitemsEntity4 . QTYDR = 0 ; //借方数量
CwVouitemsEntity4 . QTYCR = 0 ; //贷方数量
CwVouitemsEntity4 . EXPLAN = strEXPLAN ; //摘要,规则生成 "转运费" +
CwVouitemsEntity4 . DEPTID = strDEPTID ; //部门(系统)
CwVouitemsEntity4 . EMPLID = strEMPLID ; //人员(系统)
CwVouitemsEntity4 . SALE = strSALE ; //人员名称
CwVouitemsEntity4 . PITEMID = 0 ; //父级项目编号
CwVouitemsEntity4 . ITEMID = "0" ; //项目编号
CwVouitemsEntity4 . FIELD1 = "" ; //预留字段1
CwVouitemsEntity4 . FIELD2 = "" ; //预留字段2
CwVouitemsEntity4 . FIELD3 = "" ; //预留字段3
CwVouitemsEntity4 . FIELD4 = "" ; //预留字段4
CwVouitemsEntity4 . FIELD5 = "" ; //预留字段5
CwVouitemsEntity4 . FIELD6 = "" ; //预留字段6
CwVouitemsEntity4 . FIELD7 = "" ; //预留字段7
CwVouitemsEntity4 . FIELD8 = "" ; //预留字段8
CwVouitemsEntity4 . FIELD9 = "" ; //预留字段9
CwVouitemsEntity4 . FIELD10 = "" ; //预留字段10
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISVBM" ] . ToString ( ) . Trim ( ) = = "True" )
{
CwVouitemsEntity4 . ISSYS = false ; //是否手动录入
}
else
{
CwVouitemsEntity4 . ISSYS = true ; //是否手动录入
}
CwVouitemsEntity4 . FSETTLCODE = "" ; //结算方式
CwVouitemsEntity4 . FSETTLENO = "" ; //财务辅助编号
CwVouitemsEntity4 . MODIFIEDUSER = strUserID ; //最后一次更新操作人
CwVouitemsEntity4 . BLNO = strBLNO ; / /
# endregion
CwVouitemsEntities . Add ( CwVouitemsEntity4 ) ;
}
# endregion
}
else if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "AMCODE" ] . ToString ( ) . Trim ( ) = = "2" ) //差额
{
if ( dRMB ! = 0 | | dUSD ! = 0 )
{
#region 差额
CwVouitemsEntity CwVouitemsEntity1 = new CwVouitemsEntity ( ) ;
//CwVouitemsEntity1.GID 唯一编码 newid()
CwVouitemsEntity1 . ORDNO = strORDNO . Trim ( ) ;
n = n + 1 ;
CwVouitemsEntity1 . ITEMNO = n ; // 行号
CwVouitemsEntity1 . PACCID = "" ; //父级科目贷码
CwVouitemsEntity1 . PROPERTY = 0 ; //科目属性
CwVouitemsEntity1 . GRADE = 0 ; //科目级别
CwVouitemsEntity1 . ACCID = ds . Tables [ 0 ] . Rows [ 0 ] [ "MBINCOME" ] . ToString ( ) . Trim ( ) ; //主营业务收入科目贷码
CwVouitemsEntity1 . AMTDR = 0 ; //本位币借方金额(互斥)
CwVouitemsEntity1 . AMTCR = Decimal . Parse ( dRMB . ToString ( ) . Trim ( ) ) + Math . Round ( ( Decimal . Parse ( dUSD . ToString ( ) . Trim ( ) ) * ( usdRATEF = = 0 ? usdRATES : usdRATEF ) ) , 2 , MidpointRounding . AwayFromZero ) ; //本位币贷方金额(互斥)
strDai = strDai + Decimal . Parse ( dRMB . ToString ( ) . Trim ( ) ) + Math . Round ( ( Decimal . Parse ( dUSD . ToString ( ) . Trim ( ) ) * ( usdRATEF = = 0 ? usdRATES : usdRATEF ) ) , 2 , MidpointRounding . AwayFromZero ) ;
CwVouitemsEntity1 . ISFCY = false ; //是否外币
CwVouitemsEntity1 . FCYNO = "RMB" ; //外币编号usd
CwVouitemsEntity1 . FCYDR = 0 ; //外币借方金额
CwVouitemsEntity1 . FCYCR = 0 ; //外币贷方金额
if ( ds8 = = null )
{
CwVouitemsEntity1 . ACCNAME = "" ; //科目名称
CwVouitemsEntity1 . ISDEPTACC = false ; //核算部门,按规则设置生成
CwVouitemsEntity1 . ISEMPLACC = false ; //核算人员,按规则设置生成
CwVouitemsEntity1 . ISCORPACC = false ; //核算客户,按规则设置生成
CwVouitemsEntity1 . ISITEMACC = false ; //核算项目,按规则设置生成
CwVouitemsEntity1 . DC = "C" ; //贷方向
}
else
{
CwVouitemsEntity1 . ACCNAME = ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ACCNAME" ] . ToString ( ) . Trim ( ) ; //科目名称
CwVouitemsEntity1 . ISDEPTACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISDEPTACC" ] . ToString ( ) . Trim ( ) ) ; //核算部门,按规则设置生成
CwVouitemsEntity1 . ISEMPLACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISEMPLACC" ] . ToString ( ) . Trim ( ) ) ; //核算人员,按规则设置生成
CwVouitemsEntity1 . ISCORPACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISCORPACC" ] . ToString ( ) . Trim ( ) ) ; //核算客户,按规则设置生成
CwVouitemsEntity1 . ISITEMACC = Boolean . Parse ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "ISITEMACC" ] . ToString ( ) . Trim ( ) ) ; //核算项目,按规则设置生成
if ( ds8 . Tables [ 0 ] . Rows [ 0 ] [ "DC" ] . ToString ( ) . Trim ( ) = = "借" )
{
CwVouitemsEntity1 . DC = "D" ; //借方向
}
else
{
CwVouitemsEntity1 . DC = "C" ; //贷方向
}
}
CwVouitemsEntity1 . CORPID = "" ; // strEMPLID;//人员(系统)本来应该放客户
CwVouitemsEntity1 . CUSTOMERNAME = "" ; // strSALE;//人员(系统)本来应该放客户
CwVouitemsEntity1 . FCYEXRATE = 1 ; //汇率
CwVouitemsEntity1 . QTYUNIT = "" ; //数量包装单位
CwVouitemsEntity1 . QTYDR = 0 ; //借方数量
CwVouitemsEntity1 . QTYCR = 0 ; //贷方数量
CwVouitemsEntity1 . EXPLAN = strEXPLAN ; //摘要,规则生成 "转运费" +
CwVouitemsEntity1 . DEPTID = strDEPTID ; //部门(系统)
CwVouitemsEntity1 . EMPLID = strEMPLID ; //人员(系统)
CwVouitemsEntity1 . SALE = strSALE ; //人员名称
CwVouitemsEntity1 . PITEMID = 0 ; //父级项目编号
CwVouitemsEntity1 . ITEMID = "0" ; //项目编号
CwVouitemsEntity1 . FIELD1 = "" ; //预留字段1
CwVouitemsEntity1 . FIELD2 = "" ; //预留字段2
CwVouitemsEntity1 . FIELD3 = "" ; //预留字段3
CwVouitemsEntity1 . FIELD4 = "" ; //预留字段4
CwVouitemsEntity1 . FIELD5 = "" ; //预留字段5
CwVouitemsEntity1 . FIELD6 = "" ; //预留字段6
CwVouitemsEntity1 . FIELD7 = "" ; //预留字段7
CwVouitemsEntity1 . FIELD8 = "" ; //预留字段8
CwVouitemsEntity1 . FIELD9 = "" ; //预留字段9
CwVouitemsEntity1 . FIELD10 = "" ; //预留字段10
if ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ISVBM" ] . ToString ( ) . Trim ( ) = = "True" )
{
CwVouitemsEntity1 . ISSYS = false ; //是否手动录入
}
else
{
CwVouitemsEntity1 . ISSYS = true ; //是否手动录入
}
CwVouitemsEntity1 . FSETTLCODE = "" ; //结算方式
CwVouitemsEntity1 . FSETTLENO = "" ; //财务辅助编号
CwVouitemsEntity1 . MODIFIEDUSER = strUserID ; //最后一次更新操作人
CwVouitemsEntity1 . BLNO = strBLNO ; / /
# endregion
CwVouitemsEntities . Add ( CwVouitemsEntity1 ) ;
}
}
}
# endregion
#region 插入主表
string rq = strVOUDATE ;
CwVouchersEntity CwVouchersEntity = new CwVouchersEntity ( ) ;
CwVouchersEntity . ORDNO = strORDNO . Trim ( ) ; //唯一编码 newid() varchar (36)
CwVouchersEntity . VOUDATE = DateTime . Parse ( rq . Trim ( ) ) ; //凭证日期="";//datetime="";//
CwVouchersEntity . ACCYEAR = rq . Trim ( ) . Substring ( 0 , 4 ) ; //年="";//int="";//
int iM1 = rq . Trim ( ) . IndexOf ( "-" ) + 1 ;
int iM2 = rq . Trim ( ) . LastIndexOf ( "-" ) ;
CwVouchersEntity . ACCMONTH = rq . Trim ( ) . Substring ( iM1 , iM2 - iM1 ) ; //月="";//int="";//
string strVOUNO = getVOUNO ( rq . Trim ( ) . Substring ( 0 , 4 ) , rq . Trim ( ) . Substring ( iM1 , iM2 - iM1 ) ) ;
CwVouchersEntity . VOUNO = strVOUNO ; //月初清零 varchar (16)
if ( iM2 - iM1 = = 1 )
{
strVOUNO = rq . Trim ( ) . Substring ( 0 , 4 ) + "0" + rq . Trim ( ) . Substring ( iM1 , iM2 - iM1 ) + strVOUNO ;
}
else
{
strVOUNO = rq . Trim ( ) . Substring ( 0 , 4 ) + rq . Trim ( ) . Substring ( iM1 , iM2 - iM1 ) + strVOUNO ;
}
CwVouchersEntity . VOUALLNO = ds . Tables [ 0 ] . Rows [ 0 ] [ "TVW" ] . ToString ( ) . Trim ( ) + strVOUNO ; //月初清零 varchar (16)
CwVouchersEntity . VKNO = ds . Tables [ 0 ] . Rows [ 0 ] [ "TVW" ] . ToString ( ) . Trim ( ) ; //凭证字="";//varchar="";//(8)
CwVouchersEntity . ATTACHS = int . Parse ( ds . Tables [ 0 ] . Rows [ 0 ] [ "AFFIXNO" ] . ToString ( ) . Trim ( ) ) ; //附件(单据)数="";//int="";//
CwVouchersEntity . AMTDR = strJie ; // iAMTDR;//本位币借方="";//numeric(18, 2)="";//
CwVouchersEntity . AMTCR = strDai ; //iAMTDR;// iAMTCR;//本位币贷方="";//numeric(18, 2)="";//
CwVouchersEntity . FCY = "" ; //是否含有外币科目="";//varchar="";//(1)
CwVouchersEntity . QTY = "" ; //是否含有数量科目="";//varchar="";//(1)
CwVouchersEntity . VOUPROP = "" ; //凭证属性="";//varchar="";//(1)
//CwVouchersEntity.PREPARED = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", "select top 1 FINANCESOFTCODE from user_baseinfo where USERID in (select top 1 gid from [user] where SHOWNAME='" + this.hd_comboPREPARED.Value.Trim() + "' and ISDELETED=0)");//制单人="";//varchar="";//(10)
CwVouchersEntity . PREPARED = strPREPARED ; //制单人="";//varchar="";//(10)
CwVouchersEntity . CHECKED = "" ; //审核人="";//varchar="";//(10)
CwVouchersEntity . ENTERED = "" ; //记账人="";//varchar="";//(10)
CwVouchersEntity . ERRMSG = "" ; //错误信息="";//varchar="";//(6)
CwVouchersEntity . ISDELETE = false ; //是否废除="";//bit="";//Y
CwVouchersEntity . DELETEUSER = "" ; //废除操作人="";//Varchar(36)="";//Y
//CwVouchersEntity.DELETETIME="";//废除时间="";//Datetime="";//Y
# endregion
//生成入库
string strSel = " and bsno in(" + sGids + ") " + strVESSEL ;
if ( CwVouitemsEntities . Count = = 0 )
{
iResult = 2 ;
}
else
iResult = CwVouchersDA . setInsertAll ( CwVouchersEntity , CwVouitemsEntities , "v_op_bill" , ds . Tables [ 0 ] . Rows [ 0 ] [ "TVW" ] . ToString ( ) . Trim ( ) + strVOUNO , strSel , strUserID , 1 ) ;
}
return iResult ;
}
static public String getBSNO ( )
{
string strBSNO = Guid . NewGuid ( ) . ToString ( ) ;
strBSNO = strBSNO . Replace ( "-" , "" ) ;
strBSNO = "VOU" + strBSNO ;
return strBSNO ;
}
static public String getVOUNO ( string strY , string strM )
{
T_ALL_DA T_ALL_DA = new EntityDA . T_ALL_DA ( ) ;
string sVOUNO = "" ;
string strVOUNO = "select top 1 VOUNO from cw_vouchers where ACCYEAR='" + strY + "' and ACCMONTH='" + strM + "' order by convert(decimal(10),VOUNO) desc" ;
strVOUNO = T_ALL_DA . GetStrSQL ( "VOUNO" , strVOUNO ) ;
if ( strVOUNO . Trim ( ) = = "" )
{
strVOUNO = "0001" ;
}
else
{
sVOUNO = ( int . Parse ( strVOUNO ) + 1 ) . ToString ( ) . Trim ( ) ;
strVOUNO = sVOUNO ;
for ( int i = 0 ; i < 4 - sVOUNO . Length ; i + + )
{
strVOUNO = "0" + strVOUNO ;
}
}
return strVOUNO ;
}
static public List < MsOpBill > GetVouDataList ( string condition , string userid , string username , string companyid )
{
var strDa = GetRangDAStr ( "index" , "BSVOUCHER" , userid , username , companyid ) ;
if ( ! string . IsNullOrEmpty ( strDa ) )
{
if ( ! string . IsNullOrEmpty ( condition ) )
{
condition = condition + " and " + strDa ;
}
else
{
condition = strDa ;
}
}
var PROFITRATEDR = MsSysParamSetDAL . GetData ( "PARAMNAME='PROFITRATEDR'" ) ;
var RPTPRNOCANCEL = MsSysParamSetDAL . GetData ( "PARAMNAME='RPTPRNOCANCEL'" ) ;
if ( RPTPRNOCANCEL . PARAMVALUE = = "1" )
{
if ( ! string . IsNullOrEmpty ( condition ) )
{
condition = condition + " and isnull(B.ISCANCEL,0)<>1 " ;
}
else
{
condition = " isnull(B.ISCANCEL,0)<>1 " ;
}
}
var strSql = new StringBuilder ( ) ;
strSql . Append ( "SELECT " ) ;
strSql . Append ( "BSNO,OPLB,OPLBNAME,ACCDATE,MBLNO,HBLNO,CUSTNO" ) ;
strSql . Append ( ",CUSTOMERNAME" ) ;
strSql . Append ( ",VESSEL,VOYNO,ETD,PORTLOAD" ) ;
strSql . Append ( ",PORTDISCHARGE,INPUTBY,OP,CUSTSERVICE" ) ;
strSql . Append ( ",DOC,SALE,BSSTATUS,FEESTATUS,0 ETDCLOSE,0 DRCLOSE,0 CRCLOSE,'' ETDCLOSEREF,'' DRCLOSEREF,'' CRCLOSEREF,null CLOSEETDDAY" ) ;
strSql . Append ( " from v_op_bill b where ISNULL(b.ISVOU,0)=0 " ) ;
if ( ! string . IsNullOrEmpty ( condition ) )
{
strSql . Append ( " AND " + condition ) ;
}
strSql . Append ( " order by BsNo" ) ;
return SetFeeData ( strSql ) ;
}
static public List < MsOpBill > GetFeeDataList ( string strCondition , string userid , string username , string companyid , string type )
{
var rangstr = GetRangDAStr ( "index" , type , userid , username , companyid ) ;
if ( ! string . IsNullOrEmpty ( rangstr ) )
{
if ( ! string . IsNullOrEmpty ( strCondition ) )
{
strCondition = strCondition + " and " + rangstr ;
}
else
{
strCondition = rangstr ;
}
}
var PROFITRATEDR = MsSysParamSetDAL . GetData ( "PARAMNAME='PROFITRATEDR'" ) ;
var RPTPRNOCANCEL = MsSysParamSetDAL . GetData ( "PARAMNAME='RPTPRNOCANCEL'" ) ;
if ( RPTPRNOCANCEL . PARAMVALUE = = "1" )
{
if ( ! string . IsNullOrEmpty ( strCondition ) )
{
strCondition = strCondition + " and isnull(B.ISCANCEL,0)<>1 " ;
}
else
{
strCondition = " isnull(B.ISCANCEL,0)<>1 " ;
}
}
var isopenstr = "" ;
var isopen = MsBaseInfoDAL . GetUserModuleEnable ( "modFeenotopen" , userid ) ;
if ( isopen = = false )
{
isopenstr = " ( ENTEROPERATOR='" + userid + "' OR ( ENTEROPERATOR<>'" + userid + "' AND (ISOPEN=0 OR ISOPEN IS NULL))) " ;
}
var isacc = MsBaseInfoDAL . GetUserModuleEnable ( "modISWACC" , userid ) ;
var isaccstr = "" ;
if ( isacc = = false )
{
isaccstr = " ISNULL(ISACC,0)=0 " ;
if ( ! string . IsNullOrEmpty ( isopenstr ) )
isopenstr = isopenstr + " and " + isaccstr ;
else
isopenstr = isaccstr ;
}
var strSql = new StringBuilder ( ) ;
strSql . Append ( "SELECT " ) ;
strSql . Append ( "B.BSNO,OPLB,OPLBNAME,ACCDATE,MBLNO,HBLNO,CUSTNO" ) ;
strSql . Append ( ",CUSTOMERNAME" ) ;
strSql . Append ( ",VESSEL,VOYNO,ETD,PORTLOAD" ) ;
strSql . Append ( ",PORTDISCHARGE,INPUTBY,OP,CUSTSERVICE" ) ;
strSql . Append ( ",DOC,SALE,BSSTATUS,FEESTATUS" ) ;
strSql . Append ( ",ISNULL(C.ETDCLOSE,0) ETDCLOSE,ISNULL(C.DRCLOSE,0) DRCLOSE,ISNULL(C.CRCLOSE,0) CRCLOSE" ) ;
strSql . Append ( ",case ISNULL(C.ETDCLOSE,0) when 1 then '已锁定' else '未锁定' end as ETDCLOSEREF" ) ;
strSql . Append ( ",case ISNULL(C.DRCLOSE,0) when 1 then '已锁定' else '未锁定' end as DRCLOSEREF" ) ;
strSql . Append ( ",case ISNULL(C.CRCLOSE,0) when 1 then '已锁定' else '未锁定' end as CRCLOSEREF,null CLOSEETDDAY" ) ;
strSql . Append ( " from v_op_bill b " ) ;
strSql . Append ( "LEFT JOIN op_close c ON (c.BSNO=B.BSNO) " ) ;
if ( ! string . IsNullOrEmpty ( strCondition ) )
{
strSql . Append ( " where " + strCondition ) ;
}
strSql . Append ( " order by BsNo" ) ;
return SetFeeData ( strSql ) ;
}
private static List < MsOpBill > SetFeeData ( StringBuilder strSql )
{
var headList = new List < MsOpBill > ( ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
while ( reader . Read ( ) )
{
MsOpBill data = new MsOpBill ( ) ;
#region Set DB data to Object
data . BSNO = Convert . ToString ( reader [ "BSNO" ] ) ;
if ( reader [ "ETD" ] ! = DBNull . Value )
data . ETD = Convert . ToString ( reader [ "ETD" ] ) ;
data . ACCDATE = Convert . ToString ( reader [ "ACCDATE" ] ) ;
data . OPLB = Convert . ToString ( reader [ "OPLB" ] ) ;
data . OPLBNAME = Convert . ToString ( reader [ "OPLBNAME" ] ) ;
data . MBLNO = Convert . ToString ( reader [ "MBLNO" ] ) ;
data . HBLNO = Convert . ToString ( reader [ "HBLNO" ] ) ;
data . CUSTNO = Convert . ToString ( reader [ "CUSTNO" ] ) ;
data . CUSTOMERNAME = Convert . ToString ( reader [ "CUSTOMERNAME" ] ) ;
data . VESSEL = Convert . ToString ( reader [ "VESSEL" ] ) ;
data . VOYNO = Convert . ToString ( reader [ "VOYNO" ] ) ;
data . PORTLOAD = Convert . ToString ( reader [ "PORTLOAD" ] ) ;
data . PORTDISCHARGE = Convert . ToString ( reader [ "PORTDISCHARGE" ] ) ;
data . INPUTBY = Convert . ToString ( reader [ "INPUTBY" ] ) ;
data . OP = Convert . ToString ( reader [ "OP" ] ) ;
data . CUSTSERVICE = Convert . ToString ( reader [ "CUSTSERVICE" ] ) ;
data . DOC = Convert . ToString ( reader [ "DOC" ] ) ;
data . SALE = Convert . ToString ( reader [ "SALE" ] ) ;
data . BSSTATUS = Convert . ToBoolean ( reader [ "BSSTATUS" ] ) ;
data . FEESTATUS = Convert . ToBoolean ( reader [ "FEESTATUS" ] ) ;
if ( reader [ "ETDCLOSE" ] ! = DBNull . Value )
data . ETDCLOSE = Convert . ToBoolean ( reader [ "ETDCLOSE" ] ) ;
if ( reader [ "DRCLOSE" ] ! = DBNull . Value )
data . DRCLOSE = Convert . ToBoolean ( reader [ "DRCLOSE" ] ) ;
if ( reader [ "CRCLOSE" ] ! = DBNull . Value )
data . CRCLOSE = Convert . ToBoolean ( reader [ "CRCLOSE" ] ) ;
data . ETDCLOSEREF = Convert . ToString ( reader [ "ETDCLOSEREF" ] ) ;
data . DRCLOSEREF = Convert . ToString ( reader [ "DRCLOSEREF" ] ) ;
data . CRCLOSEREF = Convert . ToString ( reader [ "CRCLOSEREF" ] ) ;
if ( reader [ "CLOSEETDDAY" ] ! = DBNull . Value )
data . CLOSEETDDAY = Convert . ToDateTime ( reader [ "CLOSEETDDAY" ] ) . ToString ( "yyyy-MM-dd" ) ;
# endregion
headList . Add ( data ) ;
}
reader . Close ( ) ;
}
return headList ;
}
public ContentResult GetCloseData ( string condition )
{
MsOpBill head = null ;
var strSql = new StringBuilder ( ) ;
strSql . Append ( "SELECT " ) ;
strSql . Append ( "B.BSNO,OPLB,OPLBNAME,ACCDATE,MBLNO,HBLNO,CUSTNO" ) ;
strSql . Append ( ",CUSTOMERNAME" ) ;
strSql . Append ( ",VESSEL,VOYNO,ETD,PORTLOAD" ) ;
strSql . Append ( ",PORTDISCHARGE,INPUTBY,OP,CUSTSERVICE" ) ;
strSql . Append ( ",DOC,SALE,BSSTATUS,FEESTATUS" ) ;
strSql . Append ( ",ISNULL(C.ETDCLOSE,0) ETDCLOSE,ISNULL(C.DRCLOSE,0) DRCLOSE,ISNULL(C.CRCLOSE,0) CRCLOSE" ) ;
strSql . Append ( ",case ISNULL(C.ETDCLOSE,0) when 1 then '已锁定' else '未锁定' end as ETDCLOSEREF" ) ;
strSql . Append ( ",case ISNULL(C.DRCLOSE,0) when 1 then '已锁定' else '未锁定' end as DRCLOSEREF" ) ;
strSql . Append ( ",case ISNULL(C.CRCLOSE,0) when 1 then '已锁定' else '未锁定' end as CRCLOSEREF" ) ;
strSql . Append ( ",(SELECT CLOSEETDDAY FROM [company] where GID=B.CORPID) as CLOSEETDDAY" ) ;
strSql . Append ( " from v_op_bill b " ) ;
strSql . Append ( "LEFT JOIN op_close c ON (c.BSNO=B.BSNO) " ) ;
if ( ! string . IsNullOrEmpty ( condition ) )
{
strSql . Append ( " where " + condition ) ;
}
var list = SetFeeData ( strSql ) ;
if ( list . Count > 0 )
head = list [ 0 ] ;
else head = new MsOpBill ( ) ;
var json = JsonConvert . Serialize (
new { Success = true , Message = "查询成功" , data = head } ) ;
return new ContentResult ( ) { Content = json } ;
}
#region 判断是否允许费用全部解锁,并返回出错问题的委托单号
public ContentResult isAllUnLock ( string billsql , int type )
{
string sError = "" ;
T_ALL_DA T_ALL_DA = new EntityDA . T_ALL_DA ( ) ;
var json = JsonConvert . Serialize ( new { Success = true , Message = "锁定成功" } ) ;
/ /
var rangstr = GetRangDAStr ( "index" , "FEE" , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
if ( ! string . IsNullOrEmpty ( rangstr ) )
{
if ( ! string . IsNullOrEmpty ( billsql ) )
{
billsql = " and " + billsql + " and " + rangstr ;
}
else
{
billsql = " and " + rangstr ;
}
}
else
{
if ( ! string . IsNullOrEmpty ( billsql ) )
{
billsql = " and " + billsql ;
}
}
/ /
string sSQL = "SELECT * from v_op_bill as b where bsno in (select bsno from ch_fee where VOUALLNO is not null and VOUALLNO<>'' group by bsno)" + billsql ;
DataSet ds = T_ALL_DA . GetAllSQL ( sSQL ) ;
if ( ds ! = null )
{
if ( ds . Tables [ 0 ] . Rows . Count > 0 )
{
for ( int i = 0 ; i < ds . Tables [ 0 ] . Rows . Count ; i + + )
{
sError + = "、" + ds . Tables [ 0 ] . Rows [ i ] [ "OPLBNAME" ] . ToString ( ) . Trim ( ) + ds . Tables [ 0 ] . Rows [ i ] [ "CUSTNO" ] . ToString ( ) . Trim ( ) ;
}
}
}
/ /
if ( sError . Trim ( ) ! = "" )
{
sError = sError . Substring ( 1 ) ;
sError = "已经生成总账凭证的数据不允许解锁费用,委托编号:" + sError + "!" ;
json = JsonConvert . Serialize ( new { Success = false , Message = sError } ) ;
}
return new ContentResult ( ) { Content = json } ;
}
# endregion
#region 判断是否允许费用选中解锁,并返回出错问题的委托单号
public ContentResult isSelUnLock ( string strGids )
{
string sError = "" ;
T_ALL_DA T_ALL_DA = new EntityDA . T_ALL_DA ( ) ;
var json = JsonConvert . Serialize ( new { Success = true , Message = "撤销锁定成功" } ) ;
/ /
if ( ! string . IsNullOrEmpty ( strGids ) )
{
strGids = " and bsno in('" + strGids . Replace ( "," , "','" ) + "')" ;
}
var head = ChMonthCloseDAL . GetData ( "" , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
/ /
string sSQL = "SELECT * from v_op_bill as b where accdate<'" + head . PERIOD + "'" + strGids ;
DataSet ds = T_ALL_DA . GetAllSQL ( sSQL ) ;
if ( ds ! = null )
{
if ( ds . Tables [ 0 ] . Rows . Count > 0 )
{
for ( int i = 0 ; i < ds . Tables [ 0 ] . Rows . Count ; i + + )
{
sError + = "、" + ds . Tables [ 0 ] . Rows [ i ] [ "OPLBNAME" ] . ToString ( ) . Trim ( ) + ds . Tables [ 0 ] . Rows [ i ] [ "CUSTNO" ] . ToString ( ) . Trim ( ) ;
}
}
}
/ /
if ( sError . Trim ( ) ! = "" )
{
sError = sError . Substring ( 1 ) ;
sError = "已经月末结转的数据不允许解锁费用,委托编号:" + sError + "!" ;
json = JsonConvert . Serialize ( new { Success = false , Message = sError } ) ;
}
return new ContentResult ( ) { Content = json } ;
}
# endregion
//2017年4月13日 Add By 张义伟
#region 判断是否具有业务解锁权限
/// <summary>
///
/// </summary>
/// <param name="autype">1:费用解锁 2: 业务解锁 3费用锁定 4业务锁定</param>
/// <returns></returns>
public ContentResult CheckAuthority ( int autype ) {
T_ALL_DA T_ALL_DA = new EntityDA . T_ALL_DA ( ) ;
var cookies = new Cookies ( ) ;
var auid = "04B61245-C3A8-46D4-9FE4-746A805244B5" ; //费用解锁权限id
if ( autype = = 2 )
{
auid = "04B61145-C3A8-46D4-9FE4-746A805244B5" ; //业务解锁权限id
}
else if ( autype = = 4 )
{
auid = "04B61145-C3A8-46D4-9FE4-746A805244A1" ; //业务锁定权限id
}
else if ( autype = = 3 )
{
auid = "04B61245-C3A8-46D4-9FE4-746A805244A2" ; //费用锁定权限id
}
var uid = cookies . getCookie ( DSWeb . TruckMng . Comm . Cookie . CookieConstant . UserId ) ; //登录组织
string sSQL = "select * from user_action where USERID = '" + uid + "' AND ACTIONID ='" + auid + "'" ;
DataSet ds = T_ALL_DA . GetAllSQL ( sSQL ) ;
int rstCnt = 0 ;
if ( ds ! = null )
{
rstCnt = ds . Tables [ 0 ] . Rows . Count ;
}
var json = JsonConvert . Serialize ( new { Success = true , Message = "有操作权限" } ) ;
if ( rstCnt < = 0 )
{
json = JsonConvert . Serialize ( new { Success = false , Message = "无操作权限" } ) ;
}
return new ContentResult ( ) { Content = json } ;
}
# endregion
}
}