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

742 lines
68 KiB
C#

3 years ago
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.MvcShipping.Models.MsCtInitialBalance;
using DSWeb.MvcShipping.Models.RptCtGenlegAccitems;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.Areas.CommMng.Models;
using HcUtility.Comm;
using System.Data.SqlClient;
using DSWeb.DataAccess;
using HcUtility.Core;
using DSWeb.EntityDA;
using DSWeb.Models;
using DSWeb.Areas.CommMng.DAL;
namespace DSWeb.MvcShipping.DAL.MsCtInitialBalanceDAL
{
public class MsCtInitialBalanceDAL
{
#region 查询
static public MsCtInitialBalance GetData(string condition, string companyid, string strUserID)
{
//调汇的默认科目
var strSql = new StringBuilder();
strSql.Append("SELECT *,MODIFIEDUSERNAME=(select top 1 SHOWNAME from [user] where gid=ct_initial_balance.MODIFIEDUSER),ACCNAME=(select top 1 ACCNAME from [cw_accitems_gl] where gid=ct_initial_balance.ACCGID),ACCID=(select top 1 ACCID from [cw_accitems_gl] where gid=ct_initial_balance.ACCGID) from ct_initial_balance where 1=1");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" and " + condition);
}
var list = SetData(strSql, strUserID);
if (list.Count > 0)
return list[0];
return new MsCtInitialBalance();
}
private static List<MsCtInitialBalance> SetData(StringBuilder strSql, string strUserID)
{
var headList = new List<MsCtInitialBalance>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsCtInitialBalance data = new MsCtInitialBalance();
#region Set DB data to Object
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//唯一编码
data.ACCGID = (reader["ACCGID"] == null ? "" : Convert.ToString(reader["ACCGID"]));//科目GID
data.CURRENCY = (reader["CURRENCY"] == null ? "" : Convert.ToString(reader["CURRENCY"]));//币别
data.STARTGID = (reader["STARTGID"] == null ? "" : Convert.ToString(reader["STARTGID"]));//启用账套GID
data.QTYYEARBLC_D = (reader["QTYYEARBLC_D"] == null ? 0 : Convert.ToDecimal(reader["QTYYEARBLC_D"]));//日记账_启用期初原币余额
data.AMTYEARBLC_D = (reader["AMTYEARBLC_D"] == null ? 0 : Convert.ToDecimal(reader["AMTYEARBLC_D"]));//日记账_启用期初本位币余额
data.QTYYEARCR_D = (reader["QTYYEARCR_D"] == null ? 0 : Convert.ToDecimal(reader["QTYYEARCR_D"]));//日记账_加银收企未收
data.QTYYEARDR_D = (reader["QTYYEARDR_D"] == null ? 0 : Convert.ToDecimal(reader["QTYYEARDR_D"]));//日记账_减银付企未付
data.QTYYEARBLC_DH = (reader["QTYYEARBLC_DH"] == null ? 0 : Convert.ToDecimal(reader["QTYYEARBLC_DH"]));//日记账_调整后原币金额
data.QTYYEARBLC_B = (reader["QTYYEARBLC_B"] == null ? 0 : Convert.ToDecimal(reader["QTYYEARBLC_B"]));//对账_银行启用期初原币余额
data.QTYYEARDR_B = (reader["QTYYEARDR_B"] == null ? 0 : Convert.ToDecimal(reader["QTYYEARDR_B"]));//对账_加企收银未收
data.QTYYEARCR_B = (reader["QTYYEARCR_B"] == null ? 0 : Convert.ToDecimal(reader["QTYYEARCR_B"]));//对账_减企付银未付
data.QTYYEARBLC_BH = (reader["QTYYEARBLC_BH"] == null ? 0 : Convert.ToDecimal(reader["QTYYEARBLC_BH"]));//对账_调整后原币金额
data.CORPID = (reader["CORPID"] == null ? "" : Convert.ToString(reader["CORPID"]));//分公司代码
data.CREATEUSER = (reader["CREATEUSER"] == null ? "" : Convert.ToString(reader["CREATEUSER"]));//创建人gid
if (data.CREATETIME != null)
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]);//创建时间
data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//更改操作人gid
if (data.MODIFIEDTIME != null)
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);//更改操作时间
data.MODIFIEDUSERNAME = (reader["MODIFIEDUSERNAME"] == null ? "" : Convert.ToString(reader["MODIFIEDUSERNAME"]));//更改人
data.ACCID = (reader["ACCID"] == null ? "" : Convert.ToString(reader["ACCID"]));//科目
data.ACCNAME = (reader["ACCNAME"] == null ? "" : Convert.ToString(reader["ACCNAME"]));//科目
string strACCDATE = BasicDataRefDAL.GetCtACCDATE(strUserID);
data.VOUDATE = DateTime.Parse(strACCDATE + "-01").AddDays(-1).ToString("yyyy-MM-dd");//日期
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 更新科目总账表ct_genleg_accitems
public static void onCtGenlegAccitems(MsCtInitialBalance headRow, string companyid, string userid)
{
#region 默认值
string strCtACCDATE = BasicDataRefDAL.GetCtACCDATE(userid);
string strCtSTARTGID = BasicDataRefDAL.GetCtSTARTGID(userid);
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
DateTime _VOUDATE = DateTime.Parse(strCtACCDATE + "-01").AddDays(-1);
string sYear = _VOUDATE.Year.ToString();
string sMonth = _VOUDATE.Month.ToString();
if (sMonth.Trim().Length == 1)
{
sMonth = "0" + sMonth;
}
string sDay = _VOUDATE.Day.ToString();
if (sDay.Trim().Length == 1)
{
sDay = "0" + sDay;
}
string sYear2 = _VOUDATE.AddDays(1).Year.ToString();
string sMonth2 = _VOUDATE.AddDays(1).Month.ToString();
if (sMonth2.Trim().Length == 1)
{
sMonth2 = "0" + sMonth2;
}
string sDay2 = _VOUDATE.AddDays(1).Day.ToString();
if (sDay2.Trim().Length == 1)
{
sDay2 = "0" + sDay2;
}
string sSQL = "select DC from cw_accitems_gl WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND GID='" + headRow.ACCGID.ToString() + "'";
string ACCDC = T_ALL_DA.GetStrSQL("DC", sSQL);
sSQL = "select top 1 GID from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND YEAR='" + sYear + "' and MONTH='" + sMonth + "' and DAY='" + sDay + "' and LINKGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "'";
string sGID = T_ALL_DA.GetStrSQL("GID", sSQL);
sSQL = "select top 1 GID from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND YEAR='" + sYear2 + "' and MONTH='" + sMonth2 + "' and DAY='" + sDay2 + "' and LINKGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "'";
string sGID2 = T_ALL_DA.GetStrSQL("GID", sSQL);
#endregion
#region 当日总账表
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
if (sGID.Trim() == "")
{
#region 插入当日总账表
sSQL = "INSERT INTO [ct_genleg_accitems]([GID],[YEAR],[MONTH],[DAY],[LINKGID],[CURRENCY],[AMTYEARDR],[AMTYEARCR],[AMTYEARBLC],[AMTDR],[AMTCR],[AMTBLC],[AMTLASTDR],[AMTLASTCR],[AMTLASTBLC],[FCYYEARDR],[FCYYEARCR],[FCYYEARBLC],[FCYDR],[FCYCR],[FCYBLC],[FCYLASTDR],[FCYLASTCR],[FCYLASTBLC],[QTYYEARDR],[QTYYEARCR],[QTYYEARBLC],[QTYDR],[QTYCR],[QTYBLC],[QTYLASTDR],[QTYLASTCR],[QTYLASTBLC],[IsInitialEntry],[CORPID],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME],[ACCDATE],[STARTGID])"
+ " select NEWID() as GID,'" + sYear + "' as [YEAR],'" + sMonth + "' as [MONTH],'" + sDay + "' as [DAY],'" + headRow.ACCGID.ToString() + "' as [LINKGID],'" + headRow.CURRENCY.ToString() + "' as [CURRENCY]";
#region 分情况赋值
if (headRow.CURRENCY.ToString() == "RMB")
{
if (ACCDC == "借")
{
sSQL += ",AMTYEARDR=0,AMTYEARCR=0,AMTYEARBLC=0"
+ ",AMTDR=(case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end)"
+ ",AMTCR=(case when isnull(sum(QTYYEARBLC_D),0)>0 then 0 else isnull(sum(-QTYYEARBLC_D),0) end)"
+ ",AMTBLC=isnull(sum(QTYYEARBLC_D),0)"
+ ",AMTLASTDR=(case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end)"
+ ",AMTLASTCR=(case when isnull(sum(QTYYEARBLC_D),0)>0 then 0 else isnull(sum(-QTYYEARBLC_D),0) end)"
+ ",AMTLASTBLC=isnull(sum(QTYYEARBLC_D),0)"
+ ",FCYYEARDR=0,FCYYEARCR=0,FCYYEARBLC=0,FCYDR=0,FCYCR=0,FCYBLC=0,FCYLASTDR=0,FCYLASTCR=0,FCYLASTBLC=0"
+ ",QTYYEARDR=0,QTYYEARCR=0,QTYYEARBLC=0"
+ ",QTYDR=(case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end)"
+ ",QTYCR=(case when isnull(sum(QTYYEARBLC_D),0)<0 then isnull(sum(-QTYYEARBLC_D),0) else 0 end)"
+ ",QTYBLC=isnull(sum(QTYYEARBLC_D),0)"
+ ",QTYLASTDR=(case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end)"
+ ",QTYLASTCR=(case when isnull(sum(QTYYEARBLC_D),0)<0 then isnull(sum(-QTYYEARBLC_D),0) else 0 end)"
+ ",QTYLASTBLC=isnull(sum(QTYYEARBLC_D),0)";
}
else
{
sSQL += ",AMTYEARDR=0,AMTYEARCR=0,AMTYEARBLC=0"
+ ",AMTDR=(case when isnull(sum(QTYYEARBLC_D),0)<0 then isnull(sum(-QTYYEARBLC_D),0) else 0 end)"
+ ",AMTCR=(case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end)"
+ ",AMTBLC=isnull(sum(QTYYEARBLC_D),0)"
+ ",AMTLASTDR=(case when isnull(sum(QTYYEARBLC_D),0)<0 then isnull(sum(-QTYYEARBLC_D),0) else 0 end)"
+ ",AMTLASTCR=(case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end)"
+ ",AMTLASTBLC=isnull(sum(QTYYEARBLC_D),0)"
+ ",FCYYEARDR=0,FCYYEARCR=0,FCYYEARBLC=0,FCYDR=0,FCYCR=0,FCYBLC=0,FCYLASTDR=0,FCYLASTCR=0,FCYLASTBLC=0"
+ ",QTYYEARDR=0,QTYYEARCR=0,QTYYEARBLC=0"
+ ",QTYDR=(case when isnull(sum(QTYYEARBLC_D),0)<0 then isnull(sum(-QTYYEARBLC_D),0) else 0 end)"
+ ",QTYCR=(case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end)"
+ ",QTYBLC=isnull(sum(QTYYEARBLC_D),0)"
+ ",QTYLASTDR=(case when isnull(sum(QTYYEARBLC_D),0)<0 then isnull(sum(-QTYYEARBLC_D),0) else 0 end)"
+ ",QTYLASTCR=(case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end)"
+ ",QTYLASTBLC=isnull(sum(QTYYEARBLC_D),0)";
}
}
else
{
if (ACCDC == "借")
{
sSQL += ",AMTYEARDR=0,AMTYEARCR=0,AMTYEARBLC=0,AMTDR=0,AMTCR=0,AMTBLC=0,AMTLASTDR=0,AMTLASTCR=0,AMTLASTBLC=0"
+ ",FCYYEARDR=0,FCYYEARCR=0,FCYYEARBLC=0"
+ ",FCYDR=(case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end)"
+ ",FCYCR=(case when isnull(sum(QTYYEARBLC_D),0)>0 then 0 else isnull(sum(-QTYYEARBLC_D),0) end)"
+ ",FCYBLC=isnull(sum(QTYYEARBLC_D),0)"
+ ",FCYLASTDR=(case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end)"
+ ",FCYLASTCR=(case when isnull(sum(QTYYEARBLC_D),0)>0 then 0 else isnull(sum(-QTYYEARBLC_D),0) end)"
+ ",FCYLASTBLC=isnull(sum(QTYYEARBLC_D),0)"
+ ",QTYYEARDR=0,QTYYEARCR=0,QTYYEARBLC=0"
+ ",QTYDR=(case when isnull(sum(AMTYEARBLC_D),0)>0 then isnull(sum(AMTYEARBLC_D),0) else 0 end)"
+ ",QTYCR=(case when isnull(sum(AMTYEARBLC_D),0)<0 then isnull(sum(-AMTYEARBLC_D),0) else 0 end)"
+ ",QTYBLC=isnull(sum(AMTYEARBLC_D),0)"
+ ",QTYLASTDR=(case when isnull(sum(AMTYEARBLC_D),0)>0 then isnull(sum(AMTYEARBLC_D),0) else 0 end)"
+ ",QTYLASTCR=(case when isnull(sum(AMTYEARBLC_D),0)<0 then isnull(sum(-AMTYEARBLC_D),0) else 0 end)"
+ ",QTYLASTBLC=isnull(sum(AMTYEARBLC_D),0)";
}
else
{
sSQL += ",AMTYEARDR=0,AMTYEARCR=0,AMTYEARBLC=0,AMTDR=0,AMTCR=0,AMTBLC=0,AMTLASTDR=0,AMTLASTCR=0,AMTLASTBLC=0"
+ ",FCYYEARDR=0,FCYYEARCR=0,FCYYEARBLC=0"
+ ",FCYDR=(case when isnull(sum(QTYYEARBLC_D),0)<0 then isnull(sum(-QTYYEARBLC_D),0) else 0 end)"
+ ",FCYCR=(case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end)"
+ ",FCYBLC=isnull(sum(QTYYEARBLC_D),0)"
+ ",FCYLASTDR=(case when isnull(sum(QTYYEARBLC_D),0)<0 then isnull(sum(-QTYYEARBLC_D),0) else 0 end)"
+ ",FCYLASTCR=(case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end)"
+ ",FCYLASTBLC=isnull(sum(QTYYEARBLC_D),0)"
+ ",QTYYEARDR=0,QTYYEARCR=0,QTYYEARBLC=0"
+ ",QTYDR=(case when isnull(sum(AMTYEARBLC_D),0)<0 then isnull(sum(-AMTYEARBLC_D),0) else 0 end)"
+ ",QTYCR=(case when isnull(sum(AMTYEARBLC_D),0)>0 then isnull(sum(AMTYEARBLC_D),0) else 0 end)"
+ ",QTYBLC=isnull(sum(AMTYEARBLC_D),0)"
+ ",QTYLASTDR=(case when isnull(sum(AMTYEARBLC_D),0)<0 then isnull(sum(-AMTYEARBLC_D),0) else 0 end)"
+ ",QTYLASTCR=(case when isnull(sum(AMTYEARBLC_D),0)>0 then isnull(sum(AMTYEARBLC_D),0) else 0 end)"
+ ",QTYLASTBLC=isnull(sum(AMTYEARBLC_D),0)";
}
}
#endregion
sSQL += ",1 as IsInitialEntry,'" + companyid + "' as CORPID,'" + userid + "' as CREATEUSER,getdate() as CREATETIME,'" + userid + "' as MODIFIEDUSER,getdate() as MODIFIEDTIME,'" + sYear + "-" + sMonth + "' as ACCDATE,'" + strCtSTARTGID + "' as STARTGID"
+ " FROM ct_initial_balance with(nolock) where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "'";
#endregion
var cmdSql = db.GetSqlStringCommand(sSQL);
db.ExecuteNonQuery(cmdSql, tran);
}
else//edit
{
#region 更新当日总账表
sSQL = "update [ct_genleg_accitems] set";
#region 分情况赋值
if (headRow.CURRENCY.ToString() == "RMB")
{
if (ACCDC == "借")
{
sSQL += " AMTDR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",AMTCR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)>0 then 0 else isnull(sum(-QTYYEARBLC_D),0) end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",AMTBLC=(select isnull(sum(QTYYEARBLC_D),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",FCYDR=0,FCYCR=0,FCYBLC=0"
+ ",QTYDR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYCR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)<0 then isnull(sum(-QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYBLC=(select isnull(sum(QTYYEARBLC_D),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",AMTLASTDR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",AMTLASTCR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)>0 then 0 else isnull(sum(-QTYYEARBLC_D),0) end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",AMTLASTBLC=(select isnull(sum(QTYYEARBLC_D),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",FCYLASTDR=0,FCYLASTCR=0,FCYLASTBLC=0"
+ ",QTYLASTDR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYLASTCR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)<0 then isnull(sum(-QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYLASTBLC=(select isnull(sum(QTYYEARBLC_D),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')";
}
else
{
sSQL += " AMTDR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)<0 then isnull(sum(-QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",AMTCR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",AMTBLC=(select isnull(sum(QTYYEARBLC_D),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",FCYDR=0,FCYCR=0,FCYBLC=0"
+ ",QTYDR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)<0 then isnull(sum(-QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYCR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYBLC=(select isnull(sum(QTYYEARBLC_D),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",AMTLASTDR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)<0 then isnull(sum(-QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",AMTLASTCR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",AMTLASTBLC=(select isnull(sum(QTYYEARBLC_D),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",FCYLASTDR=0,FCYLASTCR=0,FCYLASTBLC=0"
+ ",QTYLASTDR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)<0 then isnull(sum(-QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYLASTCR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYLASTBLC=(select isnull(sum(QTYYEARBLC_D),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')";
}
}
else
{
if (ACCDC == "借")
{
sSQL += " AMTDR=0,AMTCR=0,AMTBLC=0"
+ ",FCYDR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",FCYCR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)>0 then 0 else isnull(sum(-QTYYEARBLC_D),0) end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",FCYBLC=(select isnull(sum(QTYYEARBLC_D),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYDR=(select isnull((case when isnull(sum(AMTYEARBLC_D),0)>0 then isnull(sum(AMTYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYCR=(select isnull((case when isnull(sum(AMTYEARBLC_D),0)<0 then isnull(sum(-AMTYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYBLC=(select isnull(sum(AMTYEARBLC_D),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",AMTLASTDR=0,AMTLASTCR=0,AMTLASTBLC=0"
+ ",FCYLASTDR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",FCYLASTCR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)>0 then 0 else isnull(sum(-QTYYEARBLC_D),0) end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",FCYLASTBLC=(select isnull(sum(QTYYEARBLC_D),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYLASTDR=(select isnull((case when isnull(sum(AMTYEARBLC_D),0)>0 then isnull(sum(AMTYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYLASTCR=(select isnull((case when isnull(sum(AMTYEARBLC_D),0)<0 then isnull(sum(-AMTYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYLASTBLC=(select isnull(sum(AMTYEARBLC_D),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')";
}
else
{
sSQL += " AMTDR=0,AMTCR=0,AMTBLC=0"
+ ",FCYDR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)<0 then isnull(sum(-QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",FCYCR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",FCYBLC=(select isnull(sum(QTYYEARBLC_D),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYDR=(select isnull((case when isnull(sum(AMTYEARBLC_D),0)<0 then isnull(sum(-AMTYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYCR=(select isnull((case when isnull(sum(AMTYEARBLC_D),0)>0 then isnull(sum(AMTYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYBLC=(select isnull(sum(AMTYEARBLC_D),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",AMTLASTDR=0,AMTLASTCR=0,AMTLASTBLC=0"
+ ",FCYLASTDR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)<0 then isnull(sum(-QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",FCYLASTCR=(select isnull((case when isnull(sum(QTYYEARBLC_D),0)>0 then isnull(sum(QTYYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",FCYLASTBLC=(select isnull(sum(QTYYEARBLC_D),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYLASTDR=(select isnull((case when isnull(sum(AMTYEARBLC_D),0)<0 then isnull(sum(-AMTYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYLASTCR=(select isnull((case when isnull(sum(AMTYEARBLC_D),0)>0 then isnull(sum(AMTYEARBLC_D),0) else 0 end),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')"
+ ",QTYLASTBLC=(select isnull(sum(AMTYEARBLC_D),0) from ct_initial_balance where STARTGID='" + strCtSTARTGID + "' and ACCGID='" + headRow.ACCGID.ToString() + "' and CURRENCY='" + headRow.CURRENCY.ToString() + "')";
}
}
#endregion
sSQL += ",[MODIFIEDUSER]='" + userid + "',[MODIFIEDTIME]=getdate() where STARTGID='" + strCtSTARTGID + "' and GID='" + sGID + "'";
#endregion
var cmdSql = db.GetSqlStringCommand(sSQL);
db.ExecuteNonQuery(cmdSql, tran);
}
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
}
}
#endregion
#region 今日父类总账表
// SaveRow(headRow.ACCGID.ToString(), headRow.CURRENCY.ToString(), _VOUDATE.ToString("yyyy-MM-dd"), strCtSTARTGID, true, companyid, userid);
#endregion
#region 明日总账表
onCtGenlegAccitemsFor(headRow.ACCGID.ToString(), headRow.CURRENCY.ToString(), _VOUDATE.ToString("yyyy-MM-dd"), strCtSTARTGID, strCtACCDATE, companyid, userid);
#endregion
}
#endregion
#region 循环更新明日科目总账表ct_genleg_accitems
public static void onCtGenlegAccitemsFor(string sACCGID, string sFCYNO, string sVOUDATE, string strCtSTARTGID, string strACCDATE, string companyid, string userid)
{
#region 默认值
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
string sYear2 = DateTime.Parse(sVOUDATE).AddDays(1).Year.ToString();
string sMonth2 = DateTime.Parse(sVOUDATE).AddDays(1).Month.ToString();
if (sMonth2.Trim().Length == 1)
{
sMonth2 = "0" + sMonth2;
}
string sDay2 = DateTime.Parse(sVOUDATE).AddDays(1).Day.ToString();
if (sDay2.Trim().Length == 1)
{
sDay2 = "0" + sDay2;
}
string sSQL = "select DC from cw_accitems_gl with(nolock) where GID='" + sACCGID + "'";
string ACCDC = T_ALL_DA.GetStrSQL("DC", sSQL);
sSQL = "select * from ct_genleg_accitems with(nolock) where STARTGID='" + strCtSTARTGID + "' and LINKGID='" + sACCGID + "' and CURRENCY='" + sFCYNO + "' and convert(varchar,([Year] + '-' + [Month] + '-' + [Day]),23)>='" + sVOUDATE + "' order by [YEAR],[MONTH],[DAY]";
DataSet dsCtGenlegAccitems = T_ALL_DA.GetAllSQL(sSQL);
#endregion
if (dsCtGenlegAccitems != null)
{
bool isInsert = true;
for (int i = 0; i < dsCtGenlegAccitems.Tables[0].Rows.Count; i++)
{
if ((sYear2 + "-" + sMonth2 + "-" + sDay2) == (dsCtGenlegAccitems.Tables[0].Rows[i]["YEAR"].ToString() + "-" + dsCtGenlegAccitems.Tables[0].Rows[i]["MONTH"].ToString() + "-" + dsCtGenlegAccitems.Tables[0].Rows[i]["DAY"].ToString()))
{
isInsert = false;
}
}
if (isInsert)
{
#region 插入明日的余额
Database db1 = DatabaseFactory.CreateDatabase();
using (var conn = db1.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
#region 插入语句
sSQL = "INSERT INTO [ct_genleg_accitems]([GID],[YEAR],[MONTH],[DAY],[LINKGID],[CURRENCY],[AMTYEARDR],[AMTYEARCR],[AMTYEARBLC],[AMTDR],[AMTCR],[AMTBLC],[AMTLASTDR],[AMTLASTCR],[AMTLASTBLC],[FCYYEARDR],[FCYYEARCR],[FCYYEARBLC],[FCYDR],[FCYCR],[FCYBLC],[FCYLASTDR],[FCYLASTCR],[FCYLASTBLC],[QTYYEARDR],[QTYYEARCR],[QTYYEARBLC],[QTYDR],[QTYCR],[QTYBLC],[QTYLASTDR],[QTYLASTCR],[QTYLASTBLC],[IsInitialEntry],[CORPID],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME],[ACCDATE],[STARTGID])"
+ " select NEWID() as GID,'" + sYear2 + "' as [YEAR],'" + sMonth2 + "' as [MONTH],'" + sDay2 + "' as [DAY],'" + sACCGID + "' as [LINKGID],'" + sFCYNO + "' as [CURRENCY]"
+ ",AMTYEARDR=(case when '" + ACCDC + "'='借' then AMTLASTBLC else 0 end)"
+ ",AMTYEARCR=(case when '" + ACCDC + "'='贷' then AMTLASTBLC else 0 end)"
+ ",AMTYEARBLC=AMTLASTBLC"
+ ",AMTDR=0,AMTCR=0,AMTBLC=0"
+ ",AMTLASTDR=(case when '" + ACCDC + "'='借' then AMTLASTBLC else 0 end)"
+ ",AMTLASTCR=(case when '" + ACCDC + "'='贷' then AMTLASTBLC else 0 end)"
+ ",AMTLASTBLC"
+ ",FCYYEARDR=(case when '" + ACCDC + "'='借' then FCYLASTBLC else 0 end)"
+ ",FCYYEARCR=(case when '" + ACCDC + "'='贷' then FCYLASTBLC else 0 end)"
+ ",FCYYEARBLC=FCYLASTBLC"
+ ",FCYDR=0,FCYCR=0,FCYBLC=0"
+ ",FCYLASTDR=(case when '" + ACCDC + "'='借' then FCYLASTBLC else 0 end)"
+ ",FCYLASTCR=(case when '" + ACCDC + "'='贷' then FCYLASTBLC else 0 end)"
+ ",FCYLASTBLC"
+ ",QTYYEARDR=(case when '" + ACCDC + "'='借' then QTYLASTBLC else 0 end)"
+ ",QTYYEARCR=(case when '" + ACCDC + "'='贷' then QTYLASTBLC else 0 end)"
+ ",QTYYEARBLC=QTYLASTBLC"
+ ",QTYDR=0,QTYCR=0,QTYBLC=0"
+ ",QTYLASTDR=(case when '" + ACCDC + "'='借' then QTYLASTBLC else 0 end)"
+ ",QTYLASTCR=(case when '" + ACCDC + "'='贷' then QTYLASTBLC else 0 end)"
+ ",QTYLASTBLC"
+ ",0 as IsInitialEntry,'" + companyid + "' as CORPID,'" + userid + "' as CREATEUSER,getdate() as CREATETIME,'" + userid + "' as MODIFIEDUSER,getdate() as MODIFIEDTIME,'" + sYear2 + "-" + sMonth2 + "' as ACCDATE,'" + strCtSTARTGID + "' as STARTGID"
+ " FROM ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND GID='" + dsCtGenlegAccitems.Tables[0].Rows[0]["GID"].ToString() + "'";
#endregion
var cmdSql = db1.GetSqlStringCommand(sSQL);
db1.ExecuteNonQuery(cmdSql, tran);
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
}
}
#endregion
#region 今日父类总账表
SaveRow(dsCtGenlegAccitems.Tables[0].Rows[0]["LINKGID"].ToString().Trim(), dsCtGenlegAccitems.Tables[0].Rows[0]["CURRENCY"].ToString().Trim(), (sYear2 + "-" + sMonth2 + "-" + sDay2), strCtSTARTGID, false, companyid, userid);
#endregion
}
if (dsCtGenlegAccitems.Tables[0].Rows.Count > 1)
{
#region 循环更新明天的余额
for (int i = 0; i < dsCtGenlegAccitems.Tables[0].Rows.Count; i++)
{
if ((i + 1) <= (dsCtGenlegAccitems.Tables[0].Rows.Count - 1))
{
sSQL = "select * from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND GID='" + dsCtGenlegAccitems.Tables[0].Rows[i]["GID"].ToString().Trim() + "'";
DataSet dsCtGenlegAccitems1 = T_ALL_DA.GetAllSQL(sSQL);
//
Database db1 = DatabaseFactory.CreateDatabase();
using (var conn = db1.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
#region 更新语句
sSQL = "update [ct_genleg_accitems] set"
+ " AMTYEARDR=(case when '" + ACCDC + "'='借' then " + dsCtGenlegAccitems1.Tables[0].Rows[0]["AMTLASTBLC"].ToString() + " else 0 end)"
+ ",AMTYEARCR=(case when '" + ACCDC + "'='贷' then " + dsCtGenlegAccitems1.Tables[0].Rows[0]["AMTLASTBLC"].ToString() + " else 0 end)"
+ ",AMTYEARBLC=" + dsCtGenlegAccitems1.Tables[0].Rows[0]["AMTLASTBLC"].ToString()
+ ",AMTLASTDR=(case when '" + ACCDC + "'='借' then " + dsCtGenlegAccitems1.Tables[0].Rows[0]["AMTLASTBLC"].ToString() + " else 0 end)+AMTDR"
+ ",AMTLASTCR=(case when '" + ACCDC + "'='贷' then " + dsCtGenlegAccitems1.Tables[0].Rows[0]["AMTLASTBLC"].ToString() + " else 0 end)+AMTCR"
+ ",AMTLASTBLC=" + dsCtGenlegAccitems1.Tables[0].Rows[0]["AMTLASTBLC"].ToString() + "+AMTBLC"
+ ",FCYYEARDR=(case when '" + ACCDC + "'='借' then " + dsCtGenlegAccitems1.Tables[0].Rows[0]["FCYLASTBLC"].ToString() + " else 0 end)"
+ ",FCYYEARCR=(case when '" + ACCDC + "'='贷' then " + dsCtGenlegAccitems1.Tables[0].Rows[0]["FCYLASTBLC"].ToString() + " else 0 end)"
+ ",FCYYEARBLC=" + dsCtGenlegAccitems1.Tables[0].Rows[0]["FCYLASTBLC"].ToString()
+ ",FCYLASTDR=(case when '" + ACCDC + "'='借' then " + dsCtGenlegAccitems1.Tables[0].Rows[0]["FCYLASTBLC"].ToString() + " else 0 end)+FCYDR"
+ ",FCYLASTCR=(case when '" + ACCDC + "'='贷' then " + dsCtGenlegAccitems1.Tables[0].Rows[0]["FCYLASTBLC"].ToString() + " else 0 end)+FCYCR"
+ ",FCYLASTBLC=" + dsCtGenlegAccitems1.Tables[0].Rows[0]["FCYLASTBLC"].ToString() + "+FCYBLC"
+ ",QTYYEARDR=(case when '" + ACCDC + "'='借' then " + dsCtGenlegAccitems1.Tables[0].Rows[0]["QTYLASTBLC"].ToString() + " else 0 end)"
+ ",QTYYEARCR=(case when '" + ACCDC + "'='贷' then " + dsCtGenlegAccitems1.Tables[0].Rows[0]["QTYLASTBLC"].ToString() + " else 0 end)"
+ ",QTYYEARBLC=" + dsCtGenlegAccitems1.Tables[0].Rows[0]["QTYLASTBLC"].ToString()
+ ",QTYLASTDR=(case when '" + ACCDC + "'='借' then " + dsCtGenlegAccitems1.Tables[0].Rows[0]["QTYLASTBLC"].ToString() + " else 0 end)+QTYDR"
+ ",QTYLASTCR=(case when '" + ACCDC + "'='贷' then " + dsCtGenlegAccitems1.Tables[0].Rows[0]["QTYLASTBLC"].ToString() + " else 0 end)+QTYCR"
+ ",QTYLASTBLC=" + dsCtGenlegAccitems1.Tables[0].Rows[0]["QTYLASTBLC"].ToString() + "+QTYBLC"
+ ",[MODIFIEDUSER]='" + userid + "',[MODIFIEDTIME]=getdate()"
+ " WHERE STARTGID='" + strCtSTARTGID + "' AND GID='" + dsCtGenlegAccitems.Tables[0].Rows[i + 1]["GID"].ToString().Trim() + "'";
#endregion
var cmdSql = db1.GetSqlStringCommand(sSQL);
db1.ExecuteNonQuery(cmdSql, tran);
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
}
}
#region 今日父类总账表
SaveRow(dsCtGenlegAccitems.Tables[0].Rows[i + 1]["LINKGID"].ToString().Trim(), dsCtGenlegAccitems.Tables[0].Rows[i + 1]["CURRENCY"].ToString().Trim(), (dsCtGenlegAccitems.Tables[0].Rows[i + 1]["YEAR"].ToString().Trim() + "-" + dsCtGenlegAccitems.Tables[0].Rows[i + 1]["MONTH"].ToString().Trim() + "-" + dsCtGenlegAccitems.Tables[0].Rows[i + 1]["DAY"].ToString().Trim()), strCtSTARTGID, false, companyid, userid);
#endregion
}
}
#endregion
}
}
}
#endregion
#region 更新父类科目ct_genleg_accitems
public static void SaveRow(string strACCGID, string CURRENCY, string _VOUDATE, string strCtSTARTGID, Boolean blIsInitialEntry, string strCOMPANYID, string strUSERID)
{
#region 默认值
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
string sYear =DateTime.Parse(_VOUDATE).Year.ToString();
string sMonth = DateTime.Parse(_VOUDATE).Month.ToString();
if (sMonth.Trim().Length == 1)
{
sMonth = "0" + sMonth;
}
string sDay = DateTime.Parse(_VOUDATE).Day.ToString();
if (sDay.Trim().Length == 1)
{
sDay = "0" + sDay;
}
string sYear2 = DateTime.Parse(_VOUDATE).AddDays(1).Year.ToString();
string sMonth2 = DateTime.Parse(_VOUDATE).AddDays(1).Month.ToString();
if (sMonth2.Trim().Length == 1)
{
sMonth2 = "0" + sMonth2;
}
string sDay2 = DateTime.Parse(_VOUDATE).AddDays(1).Day.ToString();
if (sDay2.Trim().Length == 1)
{
sDay2 = "0" + sDay2;
}
var isPost = true;
string sSQL = "select PACCGID from cw_accitems_gl with(nolock) where STARTGID='" + strCtSTARTGID + "' AND GID='" + strACCGID + "'";
string PACCGID = T_ALL_DA.GetStrSQL("PACCGID", sSQL);
sSQL = "select DC from cw_accitems_gl with(nolock) where STARTGID='" + strCtSTARTGID + "' AND GID='" + strACCGID + "'";
string ACCDC = T_ALL_DA.GetStrSQL("DC", sSQL);
#endregion
//ZC','FZ','GT','QY','CB','SY
if (PACCGID != "0" && PACCGID != "ZC" && PACCGID != "FZ" && PACCGID != "GT" && PACCGID != "QY" && PACCGID != "CB" && PACCGID != "SY")
{
sSQL = "SELECT GID,ACCID,ACCNAME,DETAILED,DC,ISFCY,ISDEPTACC,ISEMPLACC,ISCORPACC,ISITEMACC,REMARKS,[YEAR],[MONTH],PACCGID=(case when (PACCGID='ZC' or PACCGID='FZ' or PACCGID='GT' or PACCGID='QY' or PACCGID='CB' or PACCGID='SY') then '0' else PACCGID end),ACCATTRIBUTE,ISENABLE,ACCTYPE,PACCID=(select top 1 ACCID from [cw_accitems_gl] as a WHERE a.STARTGID='" + strCtSTARTGID + "' AND a.gid=cw_accitems_gl.PACCGID),PACCNAME=(select top 1 ACCNAME from [cw_accitems_gl] as b WHERE b.STARTGID='" + strCtSTARTGID + "' AND b.gid=cw_accitems_gl.PACCGID),gid as [id],ACCID+' '+ACCNAME as [NAME],0 as DR,0 as CR from [cw_accitems_gl] WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND [YEAR]='" + sYear + "' and ISBANK=1 order by [YEAR],ACCID";
DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
while (PACCGID.Trim() != "")
{
var isfind = false;
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
if (ds.Tables[0].Rows[i]["GID"].ToString().Trim() == PACCGID)
{
isfind = true;
#region 父类_当日总账表
string pDC = ds.Tables[0].Rows[i]["DC"].ToString().Trim();
RptCtGenlegAccitems headRow = new RptCtGenlegAccitems();
string hSQL = "select top 1 isnull(gid,'') as gid from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND [YEAR]='" + sYear + "' and LINKGID='" + PACCGID.Trim() + "' and YEAR='" + sYear + "' and MONTH='" + sMonth + "' and DAY='" + sDay + "' and CURRENCY='" + CURRENCY + "'";
string PACCGID_gid = T_ALL_DA.GetStrSQL("gid", hSQL);
//
sSQL = "SELECT isnull(sum(AMTYEARDR),0) as AMTYEARDR,isnull(sum(AMTYEARCR),0) as AMTYEARCR,isnull(sum(case when '" + pDC + "'=DC then AMTYEARBLC else (-AMTYEARBLC) end),0) as AMTYEARBLC,isnull(sum(AMTDR),0) as AMTDR,isnull(sum(AMTCR),0) as AMTCR,isnull(sum(case when '" + pDC + "'=DC then AMTBLC else (-AMTBLC) end),0) as AMTBLC,isnull(sum(AMTLASTDR),0) as AMTLASTDR,isnull(sum(AMTLASTCR),0) as AMTLASTCR,isnull(sum(case when '" + pDC + "'=DC then AMTLASTBLC else (-AMTLASTBLC) end),0) as AMTLASTBLC,isnull(sum(FCYYEARDR),0) as FCYYEARDR,isnull(sum(FCYYEARCR),0) as FCYYEARCR,isnull(sum(case when '" + pDC + "'=DC then FCYYEARBLC else (-FCYYEARBLC) end),0) as FCYYEARBLC,isnull(sum(FCYDR),0) as FCYDR,isnull(sum(FCYCR),0) as FCYCR,isnull(sum(case when '" + pDC + "'=DC then FCYBLC else (-FCYBLC) end),0) as FCYBLC,isnull(sum(FCYLASTDR),0) as FCYLASTDR,isnull(sum(FCYLASTCR),0) as FCYLASTCR,isnull(sum(case when '" + pDC + "'=DC then FCYLASTBLC else (-FCYLASTBLC) end),0) as FCYLASTBLC,isnull(sum(QTYYEARDR),0) as QTYYEARDR,isnull(sum(QTYYEARCR),0) as QTYYEARCR,isnull(sum(case when '" + pDC + "'=DC then QTYYEARBLC else (-QTYYEARBLC) end),0) as QTYYEARBLC,isnull(sum(QTYDR),0) as QTYDR,isnull(sum(QTYCR),0) as QTYCR,isnull(sum(case when '" + pDC + "'=DC then QTYBLC else (-QTYBLC) end),0) as QTYBLC,isnull(sum(QTYLASTDR),0) as QTYLASTDR,isnull(sum(QTYLASTCR),0) as QTYLASTCR,isnull(sum(case when '" + pDC + "'=DC then QTYLASTBLC else (-QTYLASTBLC) end),0) as QTYLASTBLC from [VW_ct_genleg_accitems_gl] WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND PACCGID='" + PACCGID.Trim() + "' and YEAR='" + sYear + "' and MONTH='" + sMonth + "' and DAY='" + sDay + "' and CURRENCY='" + CURRENCY + "'";
DataSet dsLS = T_ALL_DA.GetAllSQL(sSQL);
if (dsLS != null)
{
if (dsLS.Tables[0].Rows.Count > 0)
{
#region 默认值
headRow.YEAR = sYear.ToString();//年
headRow.MONTH = sMonth.ToString();//月
headRow.DAY = sDay.ToString();//月
headRow.LINKGID = PACCGID.Trim();//科目GID
headRow.CURRENCY = CURRENCY;//币别
headRow.AMTYEARDR = Decimal.Parse(dsLS.Tables[0].Rows[0]["AMTYEARDR"].ToString().Trim());//RMB期初借方
headRow.AMTYEARCR = Decimal.Parse(dsLS.Tables[0].Rows[0]["AMTYEARCR"].ToString().Trim());//RMB期初贷方
headRow.AMTYEARBLC = Decimal.Parse(dsLS.Tables[0].Rows[0]["AMTYEARBLC"].ToString().Trim());//RMB期初余额
headRow.AMTDR = Decimal.Parse(dsLS.Tables[0].Rows[0]["AMTDR"].ToString().Trim());//RMB本月借方
headRow.AMTCR = Decimal.Parse(dsLS.Tables[0].Rows[0]["AMTCR"].ToString().Trim());//RMB本月贷方
headRow.AMTBLC = Decimal.Parse(dsLS.Tables[0].Rows[0]["AMTBLC"].ToString().Trim());//RMB本月余额
headRow.AMTLASTDR = Decimal.Parse(dsLS.Tables[0].Rows[0]["AMTLASTDR"].ToString().Trim());//RMB累计借方
headRow.AMTLASTCR = Decimal.Parse(dsLS.Tables[0].Rows[0]["AMTLASTCR"].ToString().Trim());//RMB累计贷方
headRow.AMTLASTBLC = Decimal.Parse(dsLS.Tables[0].Rows[0]["AMTLASTBLC"].ToString().Trim());//RMB累计余额
headRow.FCYYEARDR = Decimal.Parse(dsLS.Tables[0].Rows[0]["FCYYEARDR"].ToString().Trim());//外币期初借方
headRow.FCYYEARCR = Decimal.Parse(dsLS.Tables[0].Rows[0]["FCYYEARCR"].ToString().Trim());//外币期初贷方
headRow.FCYYEARBLC = Decimal.Parse(dsLS.Tables[0].Rows[0]["FCYYEARBLC"].ToString().Trim());//外币期初余额
headRow.FCYDR = Decimal.Parse(dsLS.Tables[0].Rows[0]["FCYDR"].ToString().Trim());//外币本月借方
headRow.FCYCR = Decimal.Parse(dsLS.Tables[0].Rows[0]["FCYCR"].ToString().Trim());//外币本月贷方
headRow.FCYBLC = Decimal.Parse(dsLS.Tables[0].Rows[0]["FCYBLC"].ToString().Trim());//外币本月余额
headRow.FCYLASTDR = Decimal.Parse(dsLS.Tables[0].Rows[0]["FCYLASTDR"].ToString().Trim());//外币累计借方
headRow.FCYLASTCR = Decimal.Parse(dsLS.Tables[0].Rows[0]["FCYLASTCR"].ToString().Trim());//外币累计贷方
headRow.FCYLASTBLC = Decimal.Parse(dsLS.Tables[0].Rows[0]["FCYLASTBLC"].ToString().Trim());//外币累计余额
headRow.QTYYEARDR = Decimal.Parse(dsLS.Tables[0].Rows[0]["QTYYEARDR"].ToString().Trim());//期初借方
headRow.QTYYEARCR = Decimal.Parse(dsLS.Tables[0].Rows[0]["QTYYEARCR"].ToString().Trim());//期初贷方
headRow.QTYYEARBLC = Decimal.Parse(dsLS.Tables[0].Rows[0]["QTYYEARBLC"].ToString().Trim());//期初余额
headRow.QTYDR = Decimal.Parse(dsLS.Tables[0].Rows[0]["QTYDR"].ToString().Trim());//本月借方
headRow.QTYCR = Decimal.Parse(dsLS.Tables[0].Rows[0]["QTYCR"].ToString().Trim());//本月贷方
headRow.QTYBLC = Decimal.Parse(dsLS.Tables[0].Rows[0]["QTYBLC"].ToString().Trim());//本月余额
headRow.QTYLASTDR = Decimal.Parse(dsLS.Tables[0].Rows[0]["QTYLASTDR"].ToString().Trim());//累计借方
headRow.QTYLASTCR = Decimal.Parse(dsLS.Tables[0].Rows[0]["QTYLASTCR"].ToString().Trim());//累计贷方
headRow.QTYLASTBLC = Decimal.Parse(dsLS.Tables[0].Rows[0]["QTYLASTBLC"].ToString().Trim());//累计余额
headRow.CORPID = strCOMPANYID;//分公司代码
headRow.CREATEUSER = strUSERID;//创建人gid
headRow.CREATETIME = DateTime.Now;//创建时间
headRow.MODIFIEDUSER = strUSERID;//更改操作人gid
headRow.MODIFIEDTIME = DateTime.Now;//更改操作时间
headRow.IsInitialEntry = blIsInitialEntry;//分公司代码
headRow.ACCDATE = sYear + "-" + sMonth;
headRow.STARTGID = strCtSTARTGID;
#endregion
if (PACCGID_gid.Trim() == "")
{
headRow.GID = Guid.NewGuid().ToString();//唯一编码
headRow.DbOperationType = DbOperationType.DbotIns;
headRow.ModelUIStatus = "E";
}
else
{
headRow.GID = PACCGID_gid.Trim();//唯一编码
headRow.DbOperationType = DbOperationType.DbotUpd;
headRow.ModelUIStatus = "E";
}
}
}
//
if (isPost)
{
if (headRow != null)
{
var modb = new ModelObjectDB();
DBResult result = modb.Save(headRow);
}
}
#endregion
//
#region 父类_明日总账表
//RptCtGenlegAccitems headRow2 = new RptCtGenlegAccitems();
//string PACCGID_gid2 = T_ALL_DA.GetStrSQL("gid", "select top 1 isnull(gid,'') as gid from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND [YEAR]='" + sYear + "' and LINKGID='" + PACCGID.Trim() + "' and YEAR='" + sYear2 + "' and MONTH='" + sMonth2 + "' and DAY='" + sDay2 + "' and CURRENCY='" + CURRENCY + "'");
////
//sSQL = "SELECT sum(AMTYEARDR) as AMTYEARDR,sum(AMTYEARCR) as AMTYEARCR,sum(AMTYEARBLC) as AMTYEARBLC,sum(AMTDR) as AMTDR,sum(AMTCR) as AMTCR,sum(AMTBLC) as AMTBLC,sum(AMTLASTDR) as AMTLASTDR,sum(AMTLASTCR) as AMTLASTCR,sum(AMTLASTBLC) as AMTLASTBLC,sum(FCYYEARDR) as FCYYEARDR,sum(FCYYEARCR) as FCYYEARCR,sum(FCYYEARBLC) as FCYYEARBLC,sum(FCYDR) as FCYDR,sum(FCYCR) as FCYCR,sum(FCYBLC) as FCYBLC,sum(FCYLASTDR) as FCYLASTDR,sum(FCYLASTCR) as FCYLASTCR,sum(FCYLASTBLC) as FCYLASTBLC,sum(QTYYEARDR) as QTYYEARDR,sum(QTYYEARCR) as QTYYEARCR,sum(QTYYEARBLC) as QTYYEARBLC,sum(QTYDR) as QTYDR,sum(QTYCR) as QTYCR,sum(QTYBLC) as QTYBLC,sum(QTYLASTDR) as QTYLASTDR,sum(QTYLASTCR) as QTYLASTCR,sum(QTYLASTBLC) as QTYLASTBLC from [ct_genleg_accitems] WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND LINKGID in(select gid from cw_accitems_gl WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND PACCGID='" + PACCGID.Trim() + "') and YEAR='" + sYear2 + "' and MONTH='" + sMonth2 + "' and DAY='" + sDay2 + "' and CURRENCY='" + CURRENCY + "'";
//dsLS = T_ALL_DA.GetAllSQL(sSQL);
//if (dsLS != null)
//{
// if (dsLS.Tables[0].Rows.Count > 0)
// {
// #region 默认值
// headRow2.YEAR = sYear2.ToString();//年
// headRow2.MONTH = sMonth2.ToString();//月
// headRow2.DAY = sDay2.ToString();//月
// headRow2.LINKGID = PACCGID.Trim();//科目GID
// headRow2.CURRENCY = CURRENCY;//币别
// headRow2.AMTYEARDR = (ACCDC == "借" ? Decimal.Parse(dsLS.Tables[0].Rows[0]["AMTYEARBLC"].ToString().Trim()) : 0);//RMB期初借方
// headRow2.AMTYEARCR = (ACCDC == "贷" ? Decimal.Parse(dsLS.Tables[0].Rows[0]["AMTYEARBLC"].ToString().Trim()) : 0);//RMB期初贷方
// headRow2.AMTYEARBLC = Decimal.Parse(dsLS.Tables[0].Rows[0]["AMTYEARBLC"].ToString().Trim());//RMB期初余额
// headRow2.AMTDR = (ACCDC == "借" ? Decimal.Parse(dsLS.Tables[0].Rows[0]["AMTBLC"].ToString().Trim()) : 0);//RMB本月借方
// headRow2.AMTCR = (ACCDC == "贷" ? Decimal.Parse(dsLS.Tables[0].Rows[0]["AMTBLC"].ToString().Trim()) : 0);//RMB本月贷方
// headRow2.AMTBLC = Decimal.Parse(dsLS.Tables[0].Rows[0]["AMTBLC"].ToString().Trim());//RMB本月余额
// headRow2.AMTLASTDR = (ACCDC == "借" ? Decimal.Parse(dsLS.Tables[0].Rows[0]["AMTLASTBLC"].ToString().Trim()) : 0);//RMB累计借方
// headRow2.AMTLASTCR = (ACCDC == "贷" ? Decimal.Parse(dsLS.Tables[0].Rows[0]["AMTLASTBLC"].ToString().Trim()) : 0);//RMB累计贷方
// headRow2.AMTLASTBLC = Decimal.Parse(dsLS.Tables[0].Rows[0]["AMTLASTBLC"].ToString().Trim());//RMB累计余额
// headRow2.FCYYEARDR = (ACCDC == "借" ? Decimal.Parse(dsLS.Tables[0].Rows[0]["FCYYEARBLC"].ToString().Trim()) : 0);//外币期初借方
// headRow2.FCYYEARCR = (ACCDC == "贷" ? Decimal.Parse(dsLS.Tables[0].Rows[0]["FCYYEARBLC"].ToString().Trim()) : 0);//外币期初贷方
// headRow2.FCYYEARBLC = Decimal.Parse(dsLS.Tables[0].Rows[0]["FCYYEARBLC"].ToString().Trim());//外币期初余额
// headRow2.FCYDR = (ACCDC == "借" ? Decimal.Parse(dsLS.Tables[0].Rows[0]["FCYBLC"].ToString().Trim()) : 0);//外币本月借方
// headRow2.FCYCR = (ACCDC == "贷" ? Decimal.Parse(dsLS.Tables[0].Rows[0]["FCYBLC"].ToString().Trim()) : 0);//外币本月贷方
// headRow2.FCYBLC = Decimal.Parse(dsLS.Tables[0].Rows[0]["FCYBLC"].ToString().Trim());//外币本月余额
// headRow2.FCYLASTDR = (ACCDC == "借" ? Decimal.Parse(dsLS.Tables[0].Rows[0]["FCYLASTBLC"].ToString().Trim()) : 0);//外币累计借方
// headRow2.FCYLASTCR = (ACCDC == "贷" ? Decimal.Parse(dsLS.Tables[0].Rows[0]["FCYLASTBLC"].ToString().Trim()) : 0);//外币累计贷方
// headRow2.FCYLASTBLC = Decimal.Parse(dsLS.Tables[0].Rows[0]["FCYLASTBLC"].ToString().Trim());//外币累计余额
// headRow2.QTYYEARDR = (ACCDC == "借" ? Decimal.Parse(dsLS.Tables[0].Rows[0]["QTYYEARBLC"].ToString().Trim()) : 0);//期初借方
// headRow2.QTYYEARCR = (ACCDC == "贷" ? Decimal.Parse(dsLS.Tables[0].Rows[0]["QTYYEARBLC"].ToString().Trim()) : 0);//期初贷方
// headRow2.QTYYEARBLC = Decimal.Parse(dsLS.Tables[0].Rows[0]["QTYYEARBLC"].ToString().Trim());//期初余额
// headRow2.QTYDR = (ACCDC == "借" ? Decimal.Parse(dsLS.Tables[0].Rows[0]["QTYBLC"].ToString().Trim()) : 0);//本月借方
// headRow2.QTYCR = (ACCDC == "贷" ? Decimal.Parse(dsLS.Tables[0].Rows[0]["QTYBLC"].ToString().Trim()) : 0);//本月贷方
// headRow2.QTYBLC = Decimal.Parse(dsLS.Tables[0].Rows[0]["QTYBLC"].ToString().Trim());//本月余额
// headRow2.QTYLASTDR = (ACCDC == "借" ? Decimal.Parse(dsLS.Tables[0].Rows[0]["QTYLASTBLC"].ToString().Trim()) : 0);//累计借方
// headRow2.QTYLASTCR = (ACCDC == "贷" ? Decimal.Parse(dsLS.Tables[0].Rows[0]["QTYLASTBLC"].ToString().Trim()) : 0);//累计贷方
// headRow2.QTYLASTBLC = Decimal.Parse(dsLS.Tables[0].Rows[0]["QTYLASTBLC"].ToString().Trim());//累计余额
// headRow2.CORPID = strCOMPANYID;//分公司代码
// headRow2.CREATEUSER = strUSERID;//创建人gid
// headRow2.CREATETIME = DateTime.Now;//创建时间
// headRow2.MODIFIEDUSER = strUSERID;//更改操作人gid
// headRow2.MODIFIEDTIME = DateTime.Now;//更改操作时间
// headRow2.IsInitialEntry = blIsInitialEntry;//分公司代码
// headRow2.ACCDATE = sYear2 + "-" + sMonth2;
// headRow2.STARTGID = strSTARTGID;
// #endregion
// if (PACCGID_gid2.Trim() == "")
// {
// headRow2.GID = Guid.NewGuid().ToString();//唯一编码
// headRow2.DbOperationType = DbOperationType.DbotIns;
// headRow2.ModelUIStatus = "E";
// }
// else
// {
// headRow2.GID = PACCGID_gid2.Trim();//唯一编码
// headRow2.DbOperationType = DbOperationType.DbotUpd;
// headRow2.ModelUIStatus = "E";
// }
// }
//}
////
//if (isPost)
//{
// if (headRow2 != null)
// {
// var modb = new ModelObjectDB();
// DBResult result = modb.Save(headRow2);
// }
//}
#endregion
//
if (ds.Tables[0].Rows[i]["PACCGID"].ToString().Trim() == "0" || ds.Tables[0].Rows[i]["PACCGID"].ToString().Trim() == "ZC" || ds.Tables[0].Rows[i]["PACCGID"].ToString().Trim() == "FZ" || ds.Tables[0].Rows[i]["PACCGID"].ToString().Trim() == "GT" || ds.Tables[0].Rows[i]["PACCGID"].ToString().Trim() == "QY" || ds.Tables[0].Rows[i]["PACCGID"].ToString().Trim() == "CB" || ds.Tables[0].Rows[i]["PACCGID"].ToString().Trim() == "SY")
{
PACCGID = "";
}
else
{
PACCGID = ds.Tables[0].Rows[i]["PACCGID"].ToString().Trim();
}
break;
}
}
if (!isfind) PACCGID = "";
}
}
}
}
}
#endregion
public static DBResult isSave(string condition, string companyid, string userid)
{
#region 判断是否符合删除条件
var result = new DBResult();
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
string strCtSTARTGID = BasicDataRefDAL.GetCtSTARTGID(userid);
var strSql = new StringBuilder();
strSql.Append("select count(*) as inum from ((");
strSql.Append("SELECT GID from ct_bank_journal where STARTGID='" + strCtSTARTGID + "'");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" and " + condition.Replace("CURRENCY", "FCYNO"));
}
strSql.Append(") union (");
strSql.Append("SELECT GID from ct_bank_journal where STARTGID='" + strCtSTARTGID + "'");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" and " + condition.Replace("CURRENCY", "FCYNO"));
}
strSql.Append(")) as a");
int inum = int.Parse(T_ALL_DA.GetStrSQL("inum", strSql.ToString()));
if (inum > 0)
{
result.Success = false;
result.Message = "已经使用,不允许操作!";
return result;
}
#endregion
result.Success = true;
result.Message = "";
return result;
}
}
}