using System ;
using System.Data ;
using System.Collections.Generic ;
using System.Text ;
using DSWeb.MvcShipping.Models.MsCwVouchers ;
using DSWeb.MvcShipping.Models.MsCwGenlegAccitems ;
using Microsoft.Practices.EnterpriseLibrary.Data ;
using DSWeb.EntityDA ;
using DSWeb.Areas.CommMng.Models ;
using HcUtility.Comm ;
using System.Data.SqlClient ;
using DSWeb.DataAccess ;
using HcUtility.Core ;
using DSWeb.Areas.CommMng.DAL ;
namespace DSWeb.MvcShipping.DAL.MsCwVouchersDAL
{
public class MsCwVouchersDAL
{
#region 查询主表
static public MsCwVouchers GetData ( string condition , string companyid )
{
var strSql = new StringBuilder ( ) ;
strSql . Append ( "SELECT * from cw_vouchers WITH(NOLOCK) where ISDELETE=0" ) ;
if ( ! string . IsNullOrEmpty ( condition ) )
{
strSql . Append ( " and " + condition ) ;
}
var list = SetData ( strSql ) ;
if ( list . Count > 0 )
return list [ 0 ] ;
return new MsCwVouchers ( ) ;
}
private static List < MsCwVouchers > SetData ( StringBuilder strSql )
{
var headList = new List < MsCwVouchers > ( ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
while ( reader . Read ( ) )
{
MsCwVouchers data = new MsCwVouchers ( ) ;
#region Set DB data to Object
data . ORDNO = ( reader [ "ORDNO" ] = = null ? "" : Convert . ToString ( reader [ "ORDNO" ] ) ) ; //唯一编码
data . VOUNO = ( reader [ "VOUNO" ] = = null ? "" : Convert . ToString ( reader [ "VOUNO" ] ) ) ; //自动生成编号,月初清零
data . EXPVOUNO = ( reader [ "EXPVOUNO" ] = = null ? "" : Convert . ToString ( reader [ "EXPVOUNO" ] ) ) ; //导出凭证号
data . VKNO = ( reader [ "VKNO" ] = = null ? "" : Convert . ToString ( reader [ "VKNO" ] ) ) ; //凭证字
data . VOUDATE = ( reader [ "VOUDATE" ] = = DBNull . Value ? "" : Convert . ToString ( reader [ "VOUDATE" ] ) ) ; //凭证日期
data . ACCYEAR = ( reader [ "ACCYEAR" ] = = null ? "" : Convert . ToString ( reader [ "ACCYEAR" ] ) ) ; //年
data . ACCMONTH = ( reader [ "ACCMONTH" ] = = null ? "" : Convert . ToString ( reader [ "ACCMONTH" ] ) ) ; //月
data . ATTACHS = ( reader [ "ATTACHS" ] = = null ? 0 : Convert . ToInt32 ( reader [ "ATTACHS" ] ) ) ; //附件(单据)数
data . AMTDR = ( reader [ "AMTDR" ] = = DBNull . Value ? 0 : Convert . ToDecimal ( reader [ "AMTDR" ] ) ) ; //本位币借方
data . AMTCR = ( reader [ "AMTCR" ] = = DBNull . Value ? 0 : Convert . ToDecimal ( reader [ "AMTCR" ] ) ) ; //本位币贷方
data . FCY = ( reader [ "FCY" ] = = DBNull . Value ? "" : Convert . ToString ( reader [ "FCY" ] ) ) ; //是否含有外币科目
data . QTY = ( reader [ "QTY" ] = = DBNull . Value ? "" : Convert . ToString ( reader [ "QTY" ] ) ) ; //是否含有数量科目
data . VOUPROP = ( reader [ "VOUPROP" ] = = DBNull . Value ? "" : Convert . ToString ( reader [ "VOUPROP" ] ) ) ; //凭证属性
data . PREPARED = ( reader [ "PREPARED" ] = = DBNull . Value ? "" : Convert . ToString ( reader [ "PREPARED" ] ) ) ; //制单人
data . CHECKED = ( reader [ "CHECKED" ] = = DBNull . Value ? "" : Convert . ToString ( reader [ "CHECKED" ] ) ) ; //审核人
data . ENTERED = ( reader [ "ENTERED" ] = = DBNull . Value ? "" : Convert . ToString ( reader [ "ENTERED" ] ) ) ; //记账人
data . ERRMSG = ( reader [ "ERRMSG" ] = = DBNull . Value ? "" : Convert . ToString ( reader [ "ERRMSG" ] ) ) ; //错误信息
data . ISDELETE = ( reader [ "ISDELETE" ] = = DBNull . Value ? false : Convert . ToBoolean ( reader [ "ISDELETE" ] ) ) ; //是否废除
data . DELETEUSER = ( reader [ "DELETEUSER" ] = = DBNull . Value ? "" : Convert . ToString ( reader [ "DELETEUSER" ] ) ) ; //废除操作人
if ( reader [ "DELETETIME" ] ! = null & & reader [ "DELETETIME" ] . ToString ( ) . Trim ( ) . IndexOf ( "0001" ) < 0 & & reader [ "DELETETIME" ] . ToString ( ) . Trim ( ) . IndexOf ( "1900" ) < 0 & & reader [ "DELETETIME" ] . ToString ( ) . Trim ( ) ! = "" )
{
data . DELETETIME = Convert . ToDateTime ( reader [ "DELETETIME" ] ) ; //废除时间
}
data . VOUALLNO = ( reader [ "VOUALLNO" ] = = null ? "" : Convert . ToString ( reader [ "VOUALLNO" ] ) ) ; //年+月+自动生成编号=凭证号
data . ISEXPORT = ( reader [ "ISEXPORT" ] = = null ? false : Convert . ToBoolean ( reader [ "ISEXPORT" ] ) ) ; //是否导出凭证
data . ISCHECKED = ( reader [ "ISCHECKED" ] = = DBNull . Value ? false : Convert . ToBoolean ( reader [ "ISCHECKED" ] ) ) ; //是否审核
if ( reader [ "CHECKEDTIME" ] ! = DBNull . Value & & reader [ "CHECKEDTIME" ] . ToString ( ) . Trim ( ) . IndexOf ( "0001" ) < 0 & & reader [ "CHECKEDTIME" ] . ToString ( ) . Trim ( ) . IndexOf ( "1900" ) < 0 & & reader [ "CHECKEDTIME" ] . ToString ( ) . Trim ( ) ! = "" )
{
data . CHECKEDTIME = Convert . ToDateTime ( reader [ "CHECKEDTIME" ] ) ; //审核时间
}
data . CarryOverType = ( reader [ "CarryOverType" ] = = DBNull . Value ? "" : Convert . ToString ( reader [ "CarryOverType" ] ) ) ; //CarryOverType
data . MODIFIEDUSER = ( reader [ "PREPARED" ] = = DBNull . Value ? "" : Convert . ToString ( reader [ "PREPARED" ] ) ) ; //CarryOverType
# endregion
headList . Add ( data ) ;
}
reader . Close ( ) ;
}
return headList ;
}
static public List < MsCwVouchersVouitems > GetDataCwVVList ( string strCondition , string userid , string usercode , string companyid , string sort = null )
{
var strSql = new StringBuilder ( ) ;
strSql . Append ( "SELECT * from VW_cw_vouchers_vouitems WITH(NOLOCK) where ISDELETE=0" ) ;
if ( ! string . IsNullOrEmpty ( strCondition ) )
{
strSql . Append ( " and " + strCondition ) ;
}
/ /
var sortstring = DatasetSort . Getsortstring ( sort ) ;
if ( ! string . IsNullOrEmpty ( sortstring ) )
{
strSql . Append ( " order by " + sortstring ) ;
}
else
{
strSql . Append ( " order by convert(decimal(10),VOUNO) desc,VOUDATE desc,ITEMNO" ) ;
}
return SetDataCwVV ( strSql ) ;
}
private static List < MsCwVouchersVouitems > SetDataCwVV ( StringBuilder strSql )
{
var headList = new List < MsCwVouchersVouitems > ( ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
while ( reader . Read ( ) )
{
MsCwVouchersVouitems data = new MsCwVouchersVouitems ( ) ;
#region Set DB data to Object
data . ORDNO = ( reader [ "ORDNO" ] = = null ? "" : Convert . ToString ( reader [ "ORDNO" ] ) ) ; //唯一编码 newid()
data . VOUNO = ( reader [ "VOUNO" ] = = null ? "" : Convert . ToString ( reader [ "VOUNO" ] ) ) ; //月初清零
data . VKNO = ( reader [ "VKNO" ] = = null ? "" : Convert . ToString ( reader [ "VKNO" ] ) ) ; //凭证字
if ( reader [ "VOUDATE" ] ! = null & & reader [ "VOUDATE" ] . ToString ( ) . Trim ( ) . IndexOf ( "0001" ) < 0 & & reader [ "VOUDATE" ] . ToString ( ) . Trim ( ) . IndexOf ( "1900" ) < 0 & & reader [ "VOUDATE" ] . ToString ( ) . Trim ( ) ! = "" )
{
//data.VOUDATE = Convert.ToDateTime(reader["VOUDATE"]);//凭证日期
data . VOUDATE = reader [ "VOUDATE" ] . ToString ( ) . Trim ( ) ; //凭证日期
}
data . ACCYEAR = ( reader [ "ACCYEAR" ] = = null ? "" : Convert . ToString ( reader [ "ACCYEAR" ] ) ) ; //年
data . ACCMONTH = ( reader [ "ACCMONTH" ] = = null ? "" : Convert . ToString ( reader [ "ACCMONTH" ] ) ) ; //月
data . ATTACHS = ( reader [ "ATTACHS" ] = = null ? 0 : Convert . ToInt32 ( reader [ "ATTACHS" ] ) ) ; //附件(单据)数
//data.AMTDR = (reader["AMTDR"] == null ? 0 : Convert.ToDecimal(reader["AMTDR"]));//本位币借方
//data.AMTCR = (reader["AMTCR"] == null ? 0 : Convert.ToDecimal(reader["AMTCR"]));//本位币贷方
data . FCY = ( reader [ "FCY" ] = = null ? "" : Convert . ToString ( reader [ "FCY" ] ) ) ; //是否含有外币科目
data . QTY = ( reader [ "QTY" ] = = null ? "" : Convert . ToString ( reader [ "QTY" ] ) ) ; //是否含有数量科目
data . VOUPROP = ( reader [ "VOUPROP" ] = = null ? "" : Convert . ToString ( reader [ "VOUPROP" ] ) ) ; //凭证属性
data . PREPARED = ( reader [ "PREPARED" ] = = null ? "" : Convert . ToString ( reader [ "PREPARED" ] ) ) ; //制单人
data . CHECKED = ( reader [ "CHECKED" ] = = null ? "" : Convert . ToString ( reader [ "CHECKED" ] ) ) ; //审核人
data . ENTERED = ( reader [ "ENTERED" ] = = null ? "" : Convert . ToString ( reader [ "ENTERED" ] ) ) ; //记账人
data . ERRMSG = ( reader [ "ERRMSG" ] = = null ? "" : Convert . ToString ( reader [ "ERRMSG" ] ) ) ; //错误信息
data . ISDELETE = ( reader [ "ISDELETE" ] = = null ? false : Convert . ToBoolean ( reader [ "ISDELETE" ] ) ) ; //是否废除
data . DELETEUSER = ( reader [ "DELETEUSER" ] = = null ? "" : Convert . ToString ( reader [ "DELETEUSER" ] ) ) ; //废除操作人
if ( reader [ "DELETETIME" ] ! = null & & reader [ "DELETETIME" ] . ToString ( ) . Trim ( ) . IndexOf ( "0001" ) < 0 & & reader [ "DELETETIME" ] . ToString ( ) . Trim ( ) . IndexOf ( "1900" ) < 0 & & reader [ "DELETETIME" ] . ToString ( ) . Trim ( ) ! = "" )
{
data . DELETETIME = Convert . ToDateTime ( reader [ "DELETETIME" ] ) ; //废除时间
}
data . VOUALLNO = ( reader [ "VOUALLNO" ] = = null ? "" : Convert . ToString ( reader [ "VOUALLNO" ] ) ) ; //年+月+自动生成编号=凭证号
data . ISEXPORT = ( reader [ "ISEXPORT" ] = = null ? false : Convert . ToBoolean ( reader [ "ISEXPORT" ] ) ) ; //是否导出凭证
data . GID = ( reader [ "GID" ] = = null ? "" : Convert . ToString ( reader [ "GID" ] ) ) ; //唯一编码 newid()
data . ORDNO = ( reader [ "ORDNO" ] = = null ? "" : Convert . ToString ( reader [ "ORDNO" ] ) ) ; //关联cw_vouchers
data . ITEMNO = ( reader [ "ITEMNO" ] = = null ? 0 : Convert . ToInt32 ( reader [ "ITEMNO" ] ) ) ; //行号
data . ACCID = ( reader [ "ACCID" ] = = null ? "" : Convert . ToString ( reader [ "ACCID" ] ) ) ; //科目代码
data . PACCID = ( reader [ "PACCID" ] = = null ? "" : Convert . ToString ( reader [ "PACCID" ] ) ) ; //父级科目代码
data . ACCNAME = ( reader [ "ACCNAME" ] = = null ? "" : Convert . ToString ( reader [ "ACCNAME" ] ) ) ; //科目名称
data . PROPERTY = ( reader [ "PROPERTY" ] = = null ? 0 : Convert . ToInt32 ( reader [ "PROPERTY" ] ) ) ; //科目属性
data . GRADE = ( reader [ "GRADE" ] = = null ? 0 : Convert . ToInt32 ( reader [ "GRADE" ] ) ) ; //科目级别
data . DC = ( reader [ "DC" ] = = null ? "" : Convert . ToString ( reader [ "DC" ] ) ) ; //借贷方向
data . AMTDR = ( reader [ "AMTDR" ] = = null ? 0 : Convert . ToDecimal ( reader [ "AMTDR" ] ) ) ; //本位币借方金额(互斥)
data . AMTCR = ( reader [ "AMTCR" ] = = null ? 0 : Convert . ToDecimal ( reader [ "AMTCR" ] ) ) ; //本位币贷方金额(互斥)
data . ISFCY = ( reader [ "ISFCY" ] = = null ? false : Convert . ToBoolean ( reader [ "ISFCY" ] ) ) ; //是否外币
data . FCYNO = ( reader [ "FCYNO" ] = = null ? "" : Convert . ToString ( reader [ "FCYNO" ] ) ) ; //外币编号usd
data . FCYEXRATE = ( reader [ "FCYEXRATE" ] = = null ? 0 : Convert . ToDecimal ( reader [ "FCYEXRATE" ] ) ) ; //汇率
data . FCYDR = ( reader [ "FCYDR" ] = = null ? 0 : Convert . ToDecimal ( reader [ "FCYDR" ] ) ) ; //外币借方金额
data . FCYCR = ( reader [ "FCYCR" ] = = null ? 0 : Convert . ToDecimal ( reader [ "FCYCR" ] ) ) ; //外币贷方金额
data . QTYUNIT = ( reader [ "QTYUNIT" ] = = null ? "" : Convert . ToString ( reader [ "QTYUNIT" ] ) ) ; //数量包装单位
data . QTYDR = ( reader [ "QTYDR" ] = = null ? 0 : Convert . ToDecimal ( reader [ "QTYDR" ] ) ) ; //借方数量
data . QTYCR = ( reader [ "QTYCR" ] = = null ? 0 : Convert . ToDecimal ( reader [ "QTYCR" ] ) ) ; //贷方数量
data . EXPLAN = ( reader [ "EXPLAN" ] = = null ? "" : Convert . ToString ( reader [ "EXPLAN" ] ) ) ; //摘要,规则生成
data . ISDEPTACC = ( reader [ "ISDEPTACC" ] = = null ? false : Convert . ToBoolean ( reader [ "ISDEPTACC" ] ) ) ; //核算部门,按规则设置生成
data . ISEMPLACC = ( reader [ "ISEMPLACC" ] = = null ? false : Convert . ToBoolean ( reader [ "ISEMPLACC" ] ) ) ; //核算人员,按规则设置生成
data . ISCORPACC = ( reader [ "ISCORPACC" ] = = null ? false : Convert . ToBoolean ( reader [ "ISCORPACC" ] ) ) ; //核算客户,按规则设置生成
data . ISITEMACC = ( reader [ "ISITEMACC" ] = = null ? false : Convert . ToBoolean ( reader [ "ISITEMACC" ] ) ) ; //核算项目,按规则设置生成
data . DEPTID = ( reader [ "DEPTID" ] = = null ? "" : Convert . ToString ( reader [ "DEPTID" ] ) ) ; //部门(系统)
data . EMPLID = ( reader [ "EMPLID" ] = = null ? "" : Convert . ToString ( reader [ "EMPLID" ] ) ) ; //人员(系统)
data . CORPID = ( reader [ "CORPID" ] = = null ? "" : Convert . ToString ( reader [ "CORPID" ] ) ) ; //客户(系统)
data . PITEMID = ( reader [ "PITEMID" ] = = null ? 0 : Convert . ToInt32 ( reader [ "PITEMID" ] ) ) ; //父级项目编号
data . ITEMID = ( reader [ "ITEMID" ] = = null ? "" : Convert . ToString ( reader [ "ITEMID" ] ) ) ; //项目编号
data . FIELD1 = ( reader [ "FIELD1" ] = = null ? "" : Convert . ToString ( reader [ "FIELD1" ] ) ) ; //预留字段1
data . FIELD2 = ( reader [ "FIELD2" ] = = null ? "" : Convert . ToString ( reader [ "FIELD2" ] ) ) ; //预留字段2
data . FIELD3 = ( reader [ "FIELD3" ] = = null ? "" : Convert . ToString ( reader [ "FIELD3" ] ) ) ; //预留字段3
data . FIELD4 = ( reader [ "FIELD4" ] = = null ? "" : Convert . ToString ( reader [ "FIELD4" ] ) ) ; //预留字段4
data . FIELD5 = ( reader [ "FIELD5" ] = = null ? "" : Convert . ToString ( reader [ "FIELD5" ] ) ) ; //预留字段5
data . FIELD6 = ( reader [ "FIELD6" ] = = null ? "" : Convert . ToString ( reader [ "FIELD6" ] ) ) ; //预留字段6
data . FIELD7 = ( reader [ "FIELD7" ] = = null ? "" : Convert . ToString ( reader [ "FIELD7" ] ) ) ; //预留字段7
data . FIELD8 = ( reader [ "FIELD8" ] = = null ? "" : Convert . ToString ( reader [ "FIELD8" ] ) ) ; //预留字段8
data . FIELD9 = ( reader [ "FIELD9" ] = = null ? "" : Convert . ToString ( reader [ "FIELD9" ] ) ) ; //预留字段9
data . FIELD10 = ( reader [ "FIELD10" ] = = null ? "" : Convert . ToString ( reader [ "FIELD10" ] ) ) ; //预留字段10
data . ISSYS = ( reader [ "ISSYS" ] = = null ? false : Convert . ToBoolean ( reader [ "ISSYS" ] ) ) ; //是否手动录入
data . FSETTLCODE = ( reader [ "FSETTLCODE" ] = = null ? "" : Convert . ToString ( reader [ "FSETTLCODE" ] ) ) ; //结算方式
data . FSETTLENO = ( reader [ "FSETTLENO" ] = = null ? "" : Convert . ToString ( reader [ "FSETTLENO" ] ) ) ; //财务辅助编号
data . MODIFIEDUSER = ( reader [ "MODIFIEDUSER" ] = = null ? "" : Convert . ToString ( reader [ "MODIFIEDUSER" ] ) ) ; //最后一次更新操作人
if ( reader [ "MODIFIEDTIME" ] ! = null & & reader [ "MODIFIEDTIME" ] . ToString ( ) . Trim ( ) . IndexOf ( "0001" ) < 0 & & reader [ "MODIFIEDTIME" ] . ToString ( ) . Trim ( ) . IndexOf ( "1900" ) < 0 & & reader [ "MODIFIEDTIME" ] . ToString ( ) . Trim ( ) ! = "" )
{
data . MODIFIEDTIME = Convert . ToDateTime ( reader [ "MODIFIEDTIME" ] ) ; //最后一次更新操作时间
}
data . CUSTOMERNAME = ( reader [ "CUSTOMERNAME" ] = = null ? "" : Convert . ToString ( reader [ "CUSTOMERNAME" ] ) ) ; //委托单位
data . SALE = ( reader [ "SALE" ] = = null ? "" : Convert . ToString ( reader [ "SALE" ] ) ) ; //揽货人
data . BLNO = ( reader [ "BLNO" ] = = null ? "" : Convert . ToString ( reader [ "BLNO" ] ) ) ; //业务编号
data . ITEMGID = ( reader [ "ITEMGID" ] = = null ? "" : Convert . ToString ( reader [ "ITEMGID" ] ) ) ;
data . DEPTGID = ( reader [ "DEPTGID" ] = = null ? "" : Convert . ToString ( reader [ "DEPTGID" ] ) ) ;
data . ACCALL = ( reader [ "ACCALL" ] = = null ? "" : Convert . ToString ( reader [ "ACCALL" ] ) ) ;
//data.FCYAMT = (reader["FCYAMT"] == null ? 0 : Convert.ToDecimal(reader["FCYAMT"]));//原币金额
if ( reader [ "ISCHECKED" ] ! = DBNull . Value )
data . ISCHECKED = ( reader [ "ISCHECKED" ] = = null ? false : Convert . ToBoolean ( reader [ "ISCHECKED" ] ) ) ; //是否审核
if ( reader [ "CHECKEDTIME" ] ! = DBNull . Value & & reader [ "CHECKEDTIME" ] . ToString ( ) . Trim ( ) . IndexOf ( "0001" ) < 0 & & reader [ "CHECKEDTIME" ] . ToString ( ) . Trim ( ) . IndexOf ( "1900" ) < 0 & & reader [ "CHECKEDTIME" ] . ToString ( ) . Trim ( ) ! = "" )
{
data . CHECKEDTIME = Convert . ToDateTime ( reader [ "CHECKEDTIME" ] ) ; //审核时间
}
# endregion
headList . Add ( data ) ;
}
reader . Close ( ) ;
}
return headList ;
}
# endregion
#region 合计列
static public List < MsCwVouchersVouitems > GetDataListHJ ( string strCondition , string userid , string usercode , string companyid , string sort = null )
{
var strSql = new StringBuilder ( ) ;
strSql . Append ( "SELECT ORDNO,VOUALLNO,VOUNO,EXPVOUNO,VKNO,VOUDATE,ACCYEAR,ACCMONTH,ATTACHS,ACCDATE,PREPARED,ISCHECKED,CHECKED,ENTERED,ISEXPORT,SUM(case when FCYNO='RMB' THEN AMTDR ELSE 0 END) as AMTDR,SUM(case when FCYNO='RMB' THEN AMTCR ELSE 0 END) as AMTCR,SUM(FCYDR) as FCYDR,SUM(FCYCR) as FCYCR,SUM(AMTDR) as QTYDR,SUM(AMTCR) as QTYCR from VW_cw_vouchers_vouitems WITH(NOLOCK) where ISDELETE=0" ) ;
if ( ! string . IsNullOrEmpty ( strCondition ) )
{
strSql . Append ( " and " + strCondition ) ;
}
strSql . Append ( " GROUP BY ORDNO,VOUALLNO,VOUNO,EXPVOUNO,VKNO,VOUDATE,ACCYEAR,ACCMONTH,ATTACHS,ACCDATE,PREPARED,ISCHECKED,CHECKED,ENTERED,ISEXPORT" ) ;
/ /
var sortstring = DatasetSort . Getsortstring ( sort ) ;
if ( ! string . IsNullOrEmpty ( sortstring ) )
{
strSql . Append ( " order by " + sortstring ) ;
}
else
{
strSql . Append ( " order by convert(decimal(10),VOUNO) desc,VOUDATE desc" ) ;
}
return SetDataHJ ( strSql ) ;
}
private static List < MsCwVouchersVouitems > SetDataHJ ( StringBuilder strSql )
{
var headList = new List < MsCwVouchersVouitems > ( ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
while ( reader . Read ( ) )
{
MsCwVouchersVouitems data = new MsCwVouchersVouitems ( ) ;
#region Set DB data to Object
data . ORDNO = ( reader [ "ORDNO" ] = = null ? "" : Convert . ToString ( reader [ "ORDNO" ] ) ) ; //唯一编码 newid()
data . VOUALLNO = ( reader [ "VOUALLNO" ] = = null ? "" : Convert . ToString ( reader [ "VOUALLNO" ] ) ) ; //年+月+自动生成编号=凭证号
data . VOUNO = ( reader [ "VOUNO" ] = = null ? "" : Convert . ToString ( reader [ "VOUNO" ] ) ) ; //月初清零
data . EXPVOUNO = ( reader [ "EXPVOUNO" ] = = null ? "" : Convert . ToString ( reader [ "EXPVOUNO" ] ) ) ; //月初清零
data . VKNO = ( reader [ "VKNO" ] = = null ? "" : Convert . ToString ( reader [ "VKNO" ] ) ) ; //凭证字
if ( reader [ "VOUDATE" ] ! = null & & reader [ "VOUDATE" ] . ToString ( ) . Trim ( ) . IndexOf ( "0001" ) < 0 & & reader [ "VOUDATE" ] . ToString ( ) . Trim ( ) . IndexOf ( "1900" ) < 0 & & reader [ "VOUDATE" ] . ToString ( ) . Trim ( ) ! = "" )
{
data . VOUDATE = reader [ "VOUDATE" ] . ToString ( ) . Trim ( ) ; //凭证日期
}
data . ACCYEAR = ( reader [ "ACCYEAR" ] = = null ? "" : Convert . ToString ( reader [ "ACCYEAR" ] ) ) ; //年
data . ACCMONTH = ( reader [ "ACCMONTH" ] = = null ? "" : Convert . ToString ( reader [ "ACCMONTH" ] ) ) ; //月
data . ATTACHS = ( reader [ "ATTACHS" ] = = null ? 0 : Convert . ToInt32 ( reader [ "ATTACHS" ] ) ) ; //附件(单据)数
data . ACCDATE = ( reader [ "ACCDATE" ] = = null ? "" : Convert . ToString ( reader [ "ACCDATE" ] ) ) ; //月
data . PREPARED = ( reader [ "PREPARED" ] = = null ? "" : Convert . ToString ( reader [ "PREPARED" ] ) ) ; //制单人
data . ISCHECKED = ( reader [ "ISCHECKED" ] = = DBNull . Value ? false : Convert . ToBoolean ( reader [ "ISCHECKED" ] ) ) ; //是否审核
data . CHECKED = ( reader [ "CHECKED" ] = = DBNull . Value ? "" : Convert . ToString ( reader [ "CHECKED" ] ) ) ; //审核人
data . ENTERED = ( reader [ "ENTERED" ] = = DBNull . Value ? "" : Convert . ToString ( reader [ "ENTERED" ] ) ) ; //记账人
data . ISEXPORT = ( reader [ "ISEXPORT" ] = = DBNull . Value ? false : Convert . ToBoolean ( reader [ "ISEXPORT" ] ) ) ; //是否导出凭证
data . AMTDR = ( reader [ "AMTDR" ] = = DBNull . Value ? 0 : Convert . ToDecimal ( reader [ "AMTDR" ] ) ) ; //本位币借方
data . AMTCR = ( reader [ "AMTCR" ] = = DBNull . Value ? 0 : Convert . ToDecimal ( reader [ "AMTCR" ] ) ) ; //本位币贷方
data . FCYDR = ( reader [ "FCYDR" ] = = DBNull . Value ? 0 : Convert . ToDecimal ( reader [ "FCYDR" ] ) ) ; //外币借方
data . FCYCR = ( reader [ "FCYCR" ] = = DBNull . Value ? 0 : Convert . ToDecimal ( reader [ "FCYCR" ] ) ) ; //外币贷方
data . QTYDR = ( reader [ "QTYDR" ] = = DBNull . Value ? 0 : Convert . ToDecimal ( reader [ "QTYDR" ] ) ) ; //综合本位币借方
data . QTYCR = ( reader [ "QTYCR" ] = = DBNull . Value ? 0 : Convert . ToDecimal ( reader [ "QTYCR" ] ) ) ; //综合本位币贷方
# endregion
headList . Add ( data ) ;
}
reader . Close ( ) ;
}
return headList ;
}
# endregion
#region 查询明细表
static public List < MsCwVouitems > GetDetailList ( string strCondition , string userid , string usercode , string companyid )
{
var strSql = new StringBuilder ( ) ;
strSql . Append ( "SELECT *,isnull((case when FCYDR=0 then FCYCR else FCYDR end),0) as FCYAMT,ISNULL((SELECT TOP 1 DEPTNAME FROM sys_dept WHERE GID = cw_vouitems.DEPTGID), '') AS DEPTNAME, ISNULL((SELECT TOP 1 ITEMNAME FROM cw_item WHERE GID = cw_vouitems.ITEMGID), '') AS ITEMNAME from cw_vouitems WITH(NOLOCK) where 1=1" ) ;
if ( ! string . IsNullOrEmpty ( strCondition ) )
{
strSql . Append ( " and " + strCondition ) ;
}
strSql . Append ( " order by ORDNO,ITEMNO" ) ;
return SetDetail ( strSql ) ;
}
private static List < MsCwVouitems > SetDetail ( StringBuilder strSql )
{
var headList = new List < MsCwVouitems > ( ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
using ( IDataReader reader = db . ExecuteReader ( CommandType . Text , strSql . ToString ( ) ) )
{
while ( reader . Read ( ) )
{
MsCwVouitems data = new MsCwVouitems ( ) ;
#region Set DB data to Object
data . GID = ( reader [ "GID" ] = = null ? "" : Convert . ToString ( reader [ "GID" ] ) ) ; //唯一编码 newid()
data . ORDNO = ( reader [ "ORDNO" ] = = null ? "" : Convert . ToString ( reader [ "ORDNO" ] ) ) ; //关联cw_vouchers
data . ITEMNO = ( reader [ "ITEMNO" ] = = null ? 0 : Convert . ToInt32 ( reader [ "ITEMNO" ] ) ) ; //行号
data . ACCID = ( reader [ "ACCID" ] = = null ? "" : Convert . ToString ( reader [ "ACCID" ] ) ) ; //科目代码
data . PACCID = ( reader [ "PACCID" ] = = null ? "" : Convert . ToString ( reader [ "PACCID" ] ) ) ; //父级科目代码
data . ACCNAME = ( reader [ "ACCNAME" ] = = null ? "" : Convert . ToString ( reader [ "ACCNAME" ] ) ) ; //科目名称
data . PROPERTY = ( reader [ "PROPERTY" ] = = null ? 0 : Convert . ToInt32 ( reader [ "PROPERTY" ] ) ) ; //科目属性
data . GRADE = ( reader [ "GRADE" ] = = null ? 0 : Convert . ToInt32 ( reader [ "GRADE" ] ) ) ; //科目级别
data . DC = ( reader [ "DC" ] = = null ? "" : Convert . ToString ( reader [ "DC" ] ) ) ; //借贷方向
data . AMTDR = ( reader [ "AMTDR" ] = = null ? 0 : Convert . ToDecimal ( reader [ "AMTDR" ] ) ) ; //本位币借方金额(互斥)
data . AMTCR = ( reader [ "AMTCR" ] = = null ? 0 : Convert . ToDecimal ( reader [ "AMTCR" ] ) ) ; //本位币贷方金额(互斥)
data . ISFCY = ( reader [ "ISFCY" ] = = null ? false : Convert . ToBoolean ( reader [ "ISFCY" ] ) ) ; //是否外币
data . FCYNO = ( reader [ "FCYNO" ] = = null ? "" : Convert . ToString ( reader [ "FCYNO" ] ) ) ; //外币编号usd
data . FCYEXRATE = ( reader [ "FCYEXRATE" ] = = null ? 0 : Convert . ToDecimal ( reader [ "FCYEXRATE" ] ) ) ; //汇率
data . FCYDR = ( reader [ "FCYDR" ] = = null ? 0 : Convert . ToDecimal ( reader [ "FCYDR" ] ) ) ; //外币借方金额
data . FCYCR = ( reader [ "FCYCR" ] = = null ? 0 : Convert . ToDecimal ( reader [ "FCYCR" ] ) ) ; //外币贷方金额
data . QTYUNIT = ( reader [ "QTYUNIT" ] = = null ? "" : Convert . ToString ( reader [ "QTYUNIT" ] ) ) ; //数量包装单位
data . QTYDR = ( reader [ "QTYDR" ] = = null ? 0 : Convert . ToDecimal ( reader [ "QTYDR" ] ) ) ; //借方数量
data . QTYCR = ( reader [ "QTYCR" ] = = null ? 0 : Convert . ToDecimal ( reader [ "QTYCR" ] ) ) ; //贷方数量
data . EXPLAN = ( reader [ "EXPLAN" ] = = null ? "" : Convert . ToString ( reader [ "EXPLAN" ] ) ) ; //摘要,规则生成
data . ISDEPTACC = ( reader [ "ISDEPTACC" ] = = null ? false : Convert . ToBoolean ( reader [ "ISDEPTACC" ] ) ) ; //核算部门,按规则设置生成
data . ISEMPLACC = ( reader [ "ISEMPLACC" ] = = null ? false : Convert . ToBoolean ( reader [ "ISEMPLACC" ] ) ) ; //核算人员,按规则设置生成
data . ISCORPACC = ( reader [ "ISCORPACC" ] = = null ? false : Convert . ToBoolean ( reader [ "ISCORPACC" ] ) ) ; //核算客户,按规则设置生成
data . ISITEMACC = ( reader [ "ISITEMACC" ] = = null ? false : Convert . ToBoolean ( reader [ "ISITEMACC" ] ) ) ; //核算项目,按规则设置生成
data . DEPTID = ( reader [ "DEPTID" ] = = null ? "" : Convert . ToString ( reader [ "DEPTID" ] ) ) ; //部门(系统)
data . EMPLID = ( reader [ "EMPLID" ] = = null ? "" : Convert . ToString ( reader [ "EMPLID" ] ) ) ; //人员(系统)
data . CORPID = ( reader [ "CORPID" ] = = null ? "" : Convert . ToString ( reader [ "CORPID" ] ) ) ; //客户(系统)
data . PITEMID = ( reader [ "PITEMID" ] = = null ? 0 : Convert . ToInt32 ( reader [ "PITEMID" ] ) ) ; //父级项目编号
data . ITEMID = ( reader [ "ITEMID" ] = = null ? "" : Convert . ToString ( reader [ "ITEMID" ] ) ) ; //项目编号
data . FIELD1 = ( reader [ "FIELD1" ] = = null ? "" : Convert . ToString ( reader [ "FIELD1" ] ) ) ; //预留字段1
data . FIELD2 = ( reader [ "FIELD2" ] = = null ? "" : Convert . ToString ( reader [ "FIELD2" ] ) ) ; //预留字段2
data . FIELD3 = ( reader [ "FIELD3" ] = = null ? "" : Convert . ToString ( reader [ "FIELD3" ] ) ) ; //预留字段3
data . FIELD4 = ( reader [ "FIELD4" ] = = null ? "" : Convert . ToString ( reader [ "FIELD4" ] ) ) ; //预留字段4
data . FIELD5 = ( reader [ "FIELD5" ] = = null ? "" : Convert . ToString ( reader [ "FIELD5" ] ) ) ; //预留字段5
data . FIELD6 = ( reader [ "FIELD6" ] = = null ? "" : Convert . ToString ( reader [ "FIELD6" ] ) ) ; //预留字段6
data . FIELD7 = ( reader [ "FIELD7" ] = = null ? "" : Convert . ToString ( reader [ "FIELD7" ] ) ) ; //预留字段7
data . FIELD8 = ( reader [ "FIELD8" ] = = null ? "" : Convert . ToString ( reader [ "FIELD8" ] ) ) ; //预留字段8
data . FIELD9 = ( reader [ "FIELD9" ] = = null ? "" : Convert . ToString ( reader [ "FIELD9" ] ) ) ; //预留字段9
data . FIELD10 = ( reader [ "FIELD10" ] = = null ? "" : Convert . ToString ( reader [ "FIELD10" ] ) ) ; //预留字段10
data . ISSYS = ( reader [ "ISSYS" ] = = null ? false : Convert . ToBoolean ( reader [ "ISSYS" ] ) ) ; //是否手动录入
data . FSETTLCODE = ( reader [ "FSETTLCODE" ] = = null ? "" : Convert . ToString ( reader [ "FSETTLCODE" ] ) ) ; //结算方式
data . FSETTLENO = ( reader [ "FSETTLENO" ] = = null ? "" : Convert . ToString ( reader [ "FSETTLENO" ] ) ) ; //财务辅助编号
data . MODIFIEDUSER = ( reader [ "MODIFIEDUSER" ] = = null ? "" : Convert . ToString ( reader [ "MODIFIEDUSER" ] ) ) ; //最后一次更新操作人
if ( reader [ "MODIFIEDTIME" ] ! = null & & reader [ "MODIFIEDTIME" ] . ToString ( ) . Trim ( ) . IndexOf ( "0001" ) < 0 & & reader [ "MODIFIEDTIME" ] . ToString ( ) . Trim ( ) . IndexOf ( "1900" ) < 0 & & reader [ "MODIFIEDTIME" ] . ToString ( ) . Trim ( ) ! = "" )
{
data . MODIFIEDTIME = Convert . ToDateTime ( reader [ "MODIFIEDTIME" ] ) ; //最后一次更新操作时间
}
data . CUSTOMERNAME = ( reader [ "CUSTOMERNAME" ] = = null ? "" : Convert . ToString ( reader [ "CUSTOMERNAME" ] ) ) ; //委托单位
data . SALE = ( reader [ "SALE" ] = = null ? "" : Convert . ToString ( reader [ "SALE" ] ) ) ; //揽货人
data . BLNO = ( reader [ "BLNO" ] = = null ? "" : Convert . ToString ( reader [ "BLNO" ] ) ) ; //业务编号
data . ITEMGID = ( reader [ "ITEMGID" ] = = null ? "" : Convert . ToString ( reader [ "ITEMGID" ] ) ) ;
data . DEPTGID = ( reader [ "DEPTGID" ] = = null ? "" : Convert . ToString ( reader [ "DEPTGID" ] ) ) ;
data . FCYAMT = ( reader [ "FCYAMT" ] = = null ? 0 : Convert . ToDecimal ( reader [ "FCYAMT" ] ) ) ; //原币金额
data . ACCALL = ( reader [ "ACCALL" ] = = null ? "" : Convert . ToString ( reader [ "ACCALL" ] ) ) ;
data . DEPTNAME = ( reader [ "DEPTNAME" ] = = null ? "" : Convert . ToString ( reader [ "DEPTNAME" ] ) ) ;
data . ITEMNAME = ( reader [ "ITEMNAME" ] = = null ? "" : Convert . ToString ( reader [ "ITEMNAME" ] ) ) ;
if ( data . ACCALL . ToString ( ) . Trim ( ) = = "" )
{
data . ACCALL = data . ACCNAME . ToString ( ) . Trim ( ) ;
if ( data . ISCORPACC )
{
if ( data . CUSTOMERNAME . ToString ( ) . Trim ( ) ! = "" )
{
data . ACCALL + = "▁" + data . CUSTOMERNAME . ToString ( ) . Trim ( ) ;
}
}
else if ( data . ISDEPTACC )
{
if ( data . DEPTNAME . ToString ( ) . Trim ( ) ! = "" )
{
data . ACCALL + = "▁" + data . DEPTNAME . ToString ( ) . Trim ( ) ;
}
}
else if ( data . ISEMPLACC )
{
if ( data . SALE . ToString ( ) . Trim ( ) ! = "" )
{
data . ACCALL + = "▁" + data . SALE . ToString ( ) . Trim ( ) ;
}
}
else if ( data . ISITEMACC )
{
if ( data . ITEMNAME . ToString ( ) . Trim ( ) ! = "" )
{
data . ACCALL + = "▁" + data . ITEMNAME . ToString ( ) . Trim ( ) ;
}
}
}
# endregion
headList . Add ( data ) ;
}
reader . Close ( ) ;
}
return headList ;
}
# endregion
#region 根据币别,获取汇率值
public static string GetFCYEXRATE ( string FCY , string LINKGID , string strCompanyID , string strUserID )
{
T_ALL_DA T_ALL_DA = new EntityDA . T_ALL_DA ( ) ;
string strCwSTARTGID = BasicDataRefDAL . GetCwSTARTGID ( strUserID ) ;
string strCwACCDATE = BasicDataRefDAL . GetCwACCDATE ( strUserID ) ;
string strFCY = "RMB, 1" ;
if ( FCY ! = "RMB" )
{
string sSQL = "SELECT top 1 DEFAULTRATE=isnull((select top 1 BEGRATE from cw_currency_rate where LINKGID=code_currency.GID and ISDELETE=0 and ACCDATE= '" + strCwACCDATE + "' and STARTGID='" + strCwSTARTGID + "'),DEFAULTRATE) from code_currency WITH(NOLOCK) where CODENAME='" + FCY + "'" ; // and CORPID='" + strCompanyID + "'
strFCY = T_ALL_DA . GetStrSQL ( "DEFAULTRATE" , sSQL ) ;
if ( strFCY . Trim ( ) = = "" )
{
//return "请先设置帐套信息!";
return "-1" ;
}
strFCY = FCY + ", " + strFCY ;
}
return strFCY ;
}
# endregion
#region 是否已经维护财务代码
public static string GetISFINANCESOFTCODE ( string TYPE , string VALUE , string strCompanyID , string strUserID )
{
string strCwSTARTGID = BasicDataRefDAL . GetCwSTARTGID ( strUserID ) ;
T_ALL_DA T_ALL_DA = new EntityDA . T_ALL_DA ( ) ;
string sSQL = "" ;
if ( TYPE = = "DeptName" )
{
sSQL = "select top 1 FINANCESOFTCODE from sys_dept WITH(NOLOCK) where DEPTNAME='" + VALUE . ToString ( ) + "'" ;
}
else if ( TYPE = = "CustNAME" )
{
sSQL = "select top 1 (case when (FARCODE='' or FAPCODE='') then '' else FARCODE end) as FINANCESOFTCODE from info_client WITH(NOLOCK) where SHORTNAME='" + VALUE . ToString ( ) + "' and corpid='" + strCompanyID + "' " ;
}
else if ( TYPE = = "SALE" )
{
sSQL = "select top 1 FINANCESOFTCODE from user_baseinfo,[user] WITH(NOLOCK) where [user].GID=user_baseinfo.USERID and [user].SHOWNAME='" + VALUE . ToString ( ) + "'" ;
}
else if ( TYPE = = "ITEMNAME" )
{
sSQL = "select top 1 FINANCESOFTCODE from cw_item WITH(NOLOCK) where [STARTGID]='" + strCwSTARTGID + "' and (ISDELETE=0 or ISDELETE is null) and ITEMNAME='" + VALUE . ToString ( ) + "'" ;
}
/ /
string sFINANCESOFTCODE = T_ALL_DA . GetStrSQL ( "FINANCESOFTCODE" , sSQL ) ;
if ( sFINANCESOFTCODE . Trim ( ) = = "" )
{
//return "请先设置帐套信息!";
return "-1" ;
}
return VALUE . ToString ( ) ;
}
# endregion
#region 是否导出数据
public static DBResult getIsExport ( string strCondition , string gids , string strCompanyID )
{
var result = new DBResult ( ) ;
T_ALL_DA T_ALL_DA = new T_ALL_DA ( ) ;
string sSQL = "" ;
string sResult = "" ;
string sCondition = "" ;
string sgids = "'" + gids . Trim ( ) . Replace ( "," , "','" ) + "'" ;
if ( gids . Trim ( ) = = "" )
{
if ( ! string . IsNullOrEmpty ( strCondition ) )
{
sCondition = " and " + strCondition ;
}
}
else
{
sCondition = " and ORDNO in (" + sgids + ")" ;
}
/ /
//判断借贷平衡
sSQL = "select VOUALLNO,cha from (select (SUM(AMTDR)-SUM(AMTCR)) as cha,VOUALLNO from VW_cw_vouchers_vouitems where 1=1" + sCondition + " group by VOUALLNO,ORDNO) as a where cha<>'0.00' group by VOUALLNO,cha order by cha desc" ;
DataSet ds = T_ALL_DA . GetAllSQL ( sSQL ) ;
if ( ds ! = null )
{
for ( int i = 0 ; i < ds . Tables [ 0 ] . Rows . Count ; i + + )
{
sResult + = "凭证 " + ds . Tables [ 0 ] . Rows [ i ] [ "VOUALLNO" ] . ToString ( ) . Trim ( ) + " 借贷不平衡,不能导出凭证!\r\n" ;
}
}
////借贷是否同时为0
//sSQL = "select VOUALLNO from (select (case SUM(AMTDR) when '0.00' then SUM(AMTCR) else SUM(AMTDR) end) as amt,VOUALLNO=(select VOUALLNO from cw_vouchers where ORDNO=VW_cw_vouchers_vouitems.ORDNO) from VW_cw_vouchers_vouitems where 1=1" + sCondition + " group by VOUALLNO,ORDNO) as a where amt='0.00' group by VOUALLNO order by VOUALLNO";
//ds = T_ALL_DA.GetAllSQL(sSQL);
//if (ds != null)
//{
// for (int k = 0; k < ds.Tables[0].Rows.Count; k++)
// {
// sResult += "凭证 " + ds.Tables[0].Rows[k]["VOUALLNO"].ToString().Trim() + " 有借贷双方同为“0”的数据, 不能导出凭证! \r\n";
// }
//}
//外币科目汇率不能为0或1
sSQL = " select VOUALLNO from ( " ;
sSQL = sSQL + " select (case FCYDR when '0.00' then FCYCR else FCYDR end) as fcy" ;
sSQL = sSQL + ",FCYEXRATE,(select VOUALLNO from cw_vouchers where ORDNO=VW_cw_vouchers_vouitems.ORDNO) as VOUALLNO" ;
sSQL = sSQL + " from VW_cw_vouchers_vouitems " ;
sSQL = sSQL + " where 1=1" + sCondition ;
sSQL = sSQL + " and ((FCYEXRATE=0) or (FCYEXRATE=1 and fcyno<>'RMB')) " ;
sSQL = sSQL + " ) as a where fcy<>'0.00' and " ;
sSQL = sSQL + " (FCYEXRATE='1.00' or FCYEXRATE='0.00') " ;
sSQL = sSQL + " group by VOUALLNO order by VOUALLNO " ;
ds = T_ALL_DA . GetAllSQL ( sSQL ) ;
if ( ds ! = null )
{
for ( int k = 0 ; k < ds . Tables [ 0 ] . Rows . Count ; k + + )
{
sResult + = "凭证 " + ds . Tables [ 0 ] . Rows [ k ] [ "VOUALLNO" ] . ToString ( ) . Trim ( ) + " 有外币科目的汇率为“0”或“1”的数据, 不能导出凭证! \r\n" ;
}
}
//财务代码是否为空
sSQL = "select VOUALLNO from (select VOUALLNO=(select VOUALLNO from cw_vouchers where ORDNO=VW_cw_vouchers_vouitems.ORDNO) from VW_cw_vouchers_vouitems where (accid is null or accid='')" + sCondition + ") as a group by VOUALLNO order by VOUALLNO" ;
ds = T_ALL_DA . GetAllSQL ( sSQL ) ;
if ( ds ! = null )
{
for ( int j = 0 ; j < ds . Tables [ 0 ] . Rows . Count ; j + + )
{
sResult + = "凭证 " + ds . Tables [ 0 ] . Rows [ j ] [ "VOUALLNO" ] . ToString ( ) . Trim ( ) + " 有财务科目代码为空的数据,不能导出凭证!\r\n" ;
}
}
//客户财务代码是否为空
//sSQL = "select VOUALLNO from (select VOUALLNO=(select VOUALLNO from cw_vouchers where ORDNO=VW_cw_vouchers_vouitems.ORDNO) from VW_cw_vouchers_vouitems where (CUSTOMERNAME is not null and CUSTOMERNAME<>'' and (CORPID is null or CORPID='') and (FIELD3 is null or FIELD3=''))" + sCondition + ") as a group by VOUALLNO order by VOUALLNO";
//ds = T_ALL_DA.GetAllSQL(sSQL);
//if (ds != null)
//{
// for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
// {
// sResult += "凭证 " + ds.Tables[0].Rows[j]["VOUALLNO"].ToString().Trim() + " 有客户财务代码为空的数据,不能导出凭证!\r\n";
// }
//}
/ /
if ( sResult = = "" )
{
result . Success = true ;
result . Message = "" ;
return result ;
}
else
{
result . Success = false ;
result . Message = sResult ;
return result ;
}
}
# endregion
#region 删除
public static DBResult Delete ( string gids , string strUserID )
{
var result = new DBResult ( ) ;
int ibl = 0 ;
if ( gids . Trim ( ) ! = "" )
{
CwVouchersDA CwVouchersDA = new CwVouchersDA ( ) ;
ibl = CwVouchersDA . DeleteAll ( gids , strUserID ) ;
}
if ( ibl < 1 )
{
result . Success = false ;
result . Message = "操作出错!" ;
return result ;
}
result . Success = true ;
result . Message = "操作成功!" ;
return result ;
}
public static DBResult DeleteDetail ( MsCwVouitems headData )
{
var result = new DBResult ( ) ;
Database db = DatabaseFactory . CreateDatabase ( ) ;
using ( var conn = db . CreateConnection ( ) )
{
conn . Open ( ) ;
var tran = conn . BeginTransaction ( ) ;
try
{
var cmdDelete = db . GetSqlStringCommand ( "delete from cw_vouitems where GID='" + headData . GID + "'" ) ;
db . ExecuteNonQuery ( cmdDelete , tran ) ;
tran . Commit ( ) ;
}
catch ( Exception )
{
tran . Rollback ( ) ;
result . Success = false ;
result . Message = "删除出现错误,请重试!" ;
return result ;
}
}
result . Success = true ;
result . Message = "操作成功" ;
return result ;
}
# endregion
/ /
}
}