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.

365 lines
18 KiB
C#

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using WebSqlHelper;
using DSWeb.Models;
namespace DSWeb.EntityDA
{
public class ReceiveAmountDA
{
private const string PARM_CH_FEE_RECVAMOUNT_GID = "@gid";
private const string PARM_CH_FEE_RECVAMOUNT_DESCRIPTION = "@description";
private const string PARM_CH_FEE_RECVAMOUNT_CLIENT_ID = "@client_id";
private const string PARM_CH_FEE_RECVAMOUNT_CURRENCY = "@currency";
private const string PARM_CH_FEE_RECVAMOUNT_RECVAMOUNT = "@recv_amount";
private const string PARM_CH_FEE_RECVAMOUNT_CREATE_USER = "@create_user";
private const string PARM_CH_FEE_RECVAMOUNT_CREATE_TIME = "@create_time";
private const string PARM_CH_FEE_RECVAMOUNT_MODIFIED_USER = "@modified_user";
private const string PARM_CH_FEE_RECVAMOUNT_MODIFIED_TIME = "@modified_time";
private const string PARM_CH_FEE_RECVAMOUNT_DO_AMOUNT = "@do_amount";
private const string PARM_CH_FEE_RECVAMOUNT_SETTLE_TIME = "@settle_time";
private const string PARM_CH_FEE_RECVAMOUNT_SETTLE_USER = "@settle_user";
private const string PARM_CH_FEE_RECVAMOUNT_REMARK = "@remark";
private const string PARM_CH_FEE_RECVAMOUNT_IS_DELETE = "@is_delete";
private const string PARM_CH_FEE_RECVAMOUNT_DELETE_USER = "@delete_user";
private const string PARM_CH_FEE_RECVAMOUNT_DELETE_TIME = "@delete_time";
private const string PARM_CH_FEE_RECVAMOUNT_IS_FINISH = "@is_finish";
private const string PARM_CH_FEE_RECVAMOUNT_BANK = "@bank";
private const string PARM_CH_FEE_RECVAMOUNT_ACCOUNT = "@account";
private const string PARM_CH_FEE_RECVAMOUNT_COMPANY_ID = "@company_id";
private const string PARM_CH_FEE_RECVAMOUNT_SETTLE_TYPE = "@settle_type";
private const string PARM_CH_FEE_RECVAMOUNT_VOUCHER_NO = "@voucher_no";
private const string PARM_CH_FEE_RECVAMOUNT_NO = "@no";
private const string SQL_SELECT_CH_FEE_RECVAMOUNT_BY_GID = " SELECT GID, DESCRIPTION, CLIENTID, CURRENCY, RECVAMOUNT, CREATEUSER, CREATETIME, MODIFIEDUSER, MODIFIEDTIME, DOAMOUNT, SETTLETIME, "
+ " SETTLEUSER, REMARK, ISNULL(ISDELETE,0), DELETEUSER, DELETETIME, ISNULL(ISFINISH,0), BANK, ACCOUNT, COMPANYID,SETTLETYPE,VOUCHERNO,NO FROM ch_fee_recvamount WHERE GID = @gid ";
private const string SQL_INSERT_CH_FEE_RECVAMOUNT = " INSERT INTO ch_fee_recvamount(GID, DESCRIPTION, CLIENTID, CURRENCY, RECVAMOUNT, CREATEUSER, CREATETIME,REMARK,BANK,ACCOUNT,COMPANYID,SETTLETYPE,VOUCHERNO,NO) "
+ " VALUES (@gid,@description,@client_id,@currency,@recv_amount,@create_user,@create_time,@remark,@bank,@account,@company_id,@settle_type,@voucher_no,@no) ";
private const string SQL_UPDATE_CH_FEE_RECVAMOUNT = " UPDATE ch_fee_recvamount SET DESCRIPTION = @description,CLIENTID = @client_id,CURRENCY = @currency,RECVAMOUNT = @recv_amount,REMARK = @remark, "
+ " BANK = @bank,ACCOUNT = @account,COMPANYID = @company_id,SETTLETYPE = @settle_type,VOUCHERNO = @voucher_no,MODIFIEDUSER = @modified_user,MODIFIEDTIME = GETDATE(),CREATETIME = @create_time "
+ " WHERE GID = @gid ";
private const string SQL_DELETE_CH_FEE_RECVAMOUNT_BY_GID = " DELETE FROM ch_fee_recvamount WHERE GID = @gid ";
private const string SQL_SELECT_SERVER_TIME = " SELECT GETDATE() ";
#region 更新实收录入信息
/// <summary>
/// 更新实收录入信息
/// </summary>
/// <param name="tempReceiveAmountEntity">实收录入实体类</param>
/// <returns>值1表示更新成功 值不等于1表示更新失败</returns>
public int UpdateReceiveAmount(ReceiveAmountEntity tempReceiveAmountEntity)
{
int iResult = 0;
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
SqlParameter[] parms = new SqlParameter[] {
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_GID,SqlDbType.VarChar,36),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_DESCRIPTION,SqlDbType.VarChar,200),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_CLIENT_ID,SqlDbType.VarChar,36),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_CURRENCY,SqlDbType.VarChar,20),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_RECVAMOUNT,SqlDbType.Decimal,20),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_MODIFIED_USER,SqlDbType.VarChar,36),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_REMARK,SqlDbType.VarChar,300),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_BANK,SqlDbType.VarChar,200),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_ACCOUNT,SqlDbType.VarChar,200),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_COMPANY_ID,SqlDbType.VarChar,36),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_SETTLE_TYPE,SqlDbType.Int),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_VOUCHER_NO,SqlDbType.VarChar,100),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_CREATE_TIME,SqlDbType.DateTime)
};
parms[0].Value = tempReceiveAmountEntity.GID;
parms[1].Value = tempReceiveAmountEntity.Description;
parms[2].Value = tempReceiveAmountEntity.ClientID;
parms[3].Value = tempReceiveAmountEntity.Currency;
parms[4].Value = tempReceiveAmountEntity.ReceiveAmount;
parms[5].Value = tempReceiveAmountEntity.ModifiedUser;
parms[6].Value = tempReceiveAmountEntity.Remark;
parms[7].Value = tempReceiveAmountEntity.Bank;
parms[8].Value = tempReceiveAmountEntity.Account;
parms[9].Value = tempReceiveAmountEntity.CompanyID;
parms[10].Value = tempReceiveAmountEntity.SettleType;
parms[11].Value = tempReceiveAmountEntity.VoucherNO;
parms[12].Value = tempReceiveAmountEntity.CreateTime;
try
{
SqlHelper.ExecuteNonQuery(conn, CommandType.Text, SQL_UPDATE_CH_FEE_RECVAMOUNT, parms);
iResult = 1;
}
catch (Exception error)
{
iResult = -1;//异常
throw error;
}
}
return iResult;
}
#endregion
#region 插入实收录入信息
/// <summary>
/// 插入实收录入信息
/// </summary>
/// <param name="tempReceiveAmountEntity">实收录入实体类</param>
/// <returns>值等于1表示插入成功 值不等于1表示插入失败</returns>
public int InsertReceiveAmount(ReceiveAmountEntity tempReceiveAmountEntity)
{
int iResult = 0;
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
SqlParameter[] parms = new SqlParameter[] {
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_GID,SqlDbType.VarChar,36),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_DESCRIPTION,SqlDbType.VarChar,200),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_CLIENT_ID,SqlDbType.VarChar,36),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_CURRENCY,SqlDbType.VarChar,20),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_RECVAMOUNT,SqlDbType.Decimal,20),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_CREATE_USER,SqlDbType.VarChar,36),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_REMARK,SqlDbType.VarChar,300),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_BANK,SqlDbType.VarChar,200),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_ACCOUNT,SqlDbType.VarChar,200),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_COMPANY_ID,SqlDbType.VarChar,36),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_SETTLE_TYPE,SqlDbType.Int),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_VOUCHER_NO,SqlDbType.VarChar,100),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_CREATE_TIME,SqlDbType.DateTime),
new SqlParameter(PARM_CH_FEE_RECVAMOUNT_NO,SqlDbType.VarChar,30)
};
parms[0].Value = tempReceiveAmountEntity.GID;
parms[1].Value = tempReceiveAmountEntity.Description;
parms[2].Value = tempReceiveAmountEntity.ClientID;
parms[3].Value = tempReceiveAmountEntity.Currency;
parms[4].Value = tempReceiveAmountEntity.ReceiveAmount;
parms[5].Value = tempReceiveAmountEntity.CreateUser;
parms[6].Value = tempReceiveAmountEntity.Remark;
parms[7].Value = tempReceiveAmountEntity.Bank;
parms[8].Value = tempReceiveAmountEntity.Account;
parms[9].Value = tempReceiveAmountEntity.CompanyID;
parms[10].Value = tempReceiveAmountEntity.SettleType;
parms[11].Value = tempReceiveAmountEntity.VoucherNO;
parms[12].Value = tempReceiveAmountEntity.CreateTime;
parms[13].Value = tempReceiveAmountEntity.NO;
try
{
SqlHelper.ExecuteNonQuery(conn, CommandType.Text, SQL_INSERT_CH_FEE_RECVAMOUNT, parms);
iResult = 1;
}
catch (Exception error)
{
iResult = -1;//异常
throw error;
}
}
return iResult;
}
#endregion
#region 根据GID获取实收金额信息
/// <summary>
/// 根据GID获取实收金额信息
/// </summary>
/// <param name="tempActionGID">行为表GID</param>
/// <returns>行为实体类</returns>
public ReceiveAmountEntity GetRecvAmountByGID(string tempRecvAmountGID)
{
SqlParameter parm = new SqlParameter(PARM_CH_FEE_RECVAMOUNT_GID, SqlDbType.VarChar, 36);
parm.Value = tempRecvAmountGID;
ReceiveAmountEntity receiveAmountEntity = null;
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_CH_FEE_RECVAMOUNT_BY_GID, parm))
{
try
{
//读取字段值
while (sqlRead.Read())
{
receiveAmountEntity = new ReceiveAmountEntity();
if (!sqlRead.IsDBNull(0))
{
receiveAmountEntity.GID = sqlRead.GetString(0);
}
if (!sqlRead.IsDBNull(1))
{
receiveAmountEntity.Description = sqlRead.GetString(1);
}
if (!sqlRead.IsDBNull(2))
{
receiveAmountEntity.ClientID = sqlRead.GetString(2);
}
if (!sqlRead.IsDBNull(3))
{
receiveAmountEntity.Currency = sqlRead.GetString(3);
}
if (!sqlRead.IsDBNull(4))
{
receiveAmountEntity.ReceiveAmount = sqlRead.GetDecimal(4);
}
if (!sqlRead.IsDBNull(5))
{
receiveAmountEntity.CreateUser = sqlRead.GetString(5);
}
if (!sqlRead.IsDBNull(6))
{
receiveAmountEntity.CreateTime = sqlRead.GetDateTime(6);
}
if (!sqlRead.IsDBNull(7))
{
receiveAmountEntity.ModifiedUser = sqlRead.GetString(7);
}
if (!sqlRead.IsDBNull(8))
{
receiveAmountEntity.ModifiedTime = sqlRead.GetDateTime(8);
}
if (!sqlRead.IsDBNull(9))
{
receiveAmountEntity.DoAmount = sqlRead.GetDecimal(9);
}
if (!sqlRead.IsDBNull(10))
{
receiveAmountEntity.SettleTime = sqlRead.GetDateTime(10);
}
if (!sqlRead.IsDBNull(11))
{
receiveAmountEntity.SettleUser = sqlRead.GetString(11);
}
if (!sqlRead.IsDBNull(12))
{
receiveAmountEntity.Remark = sqlRead.GetString(12);
}
if (!sqlRead.IsDBNull(13))
{
receiveAmountEntity.IsDelete = sqlRead.GetBoolean(13);
}
if (!sqlRead.IsDBNull(14))
{
receiveAmountEntity.DeleteUser = sqlRead.GetString(14);
}
if (!sqlRead.IsDBNull(15))
{
receiveAmountEntity.DeleteTime = sqlRead.GetDateTime(15);
}
if (!sqlRead.IsDBNull(16))
{
receiveAmountEntity.IsFinish = sqlRead.GetBoolean(16);
}
if (!sqlRead.IsDBNull(17))
{
receiveAmountEntity.Bank = sqlRead.GetString(17);
}
if (!sqlRead.IsDBNull(18))
{
receiveAmountEntity.Account = sqlRead.GetString(18);
}
if (!sqlRead.IsDBNull(19))
{
receiveAmountEntity.CompanyID = sqlRead.GetString(19);
}
if (!sqlRead.IsDBNull(20))
{
receiveAmountEntity.SettleType = sqlRead.GetInt32(20);
}
if (!sqlRead.IsDBNull(21))
{
receiveAmountEntity.VoucherNO = sqlRead.GetString(21);
}
if (!sqlRead.IsDBNull(22))
{
receiveAmountEntity.NO = sqlRead.GetString(22);
}
}
}
catch (Exception exceError)
{
//抛出异常
throw exceError;
}
}
return receiveAmountEntity;
}
#endregion
#region 获取SQL语句查询数据集
/// <summary>
/// 获取SQL语句查询数据集
/// </summary>
/// <param name="strSql"></param>
/// <returns></returns>
public DataSet GetExcuteSql(string strSql)
{
DataSet tempSet = new DataSet();
tempSet = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql);
return tempSet;
}
#endregion
#region 通过GID删除实收费用
/// <summary>
///通过GID删除实收费用
/// </summary>
/// <param name="tempReceiveAmountGID">实收费用GID</param>
/// <returns>值1表示删除成功 值不等于1表示删除失败</returns>
public int DeleteRecvAmountByGID(string tempReceiveAmountGID)
{
int iResult = 0;
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
SqlParameter parm = new SqlParameter(PARM_CH_FEE_RECVAMOUNT_GID, SqlDbType.VarChar, 36);
parm.Value = tempReceiveAmountGID;
SqlHelper.ExecuteNonQuery(conn, CommandType.Text, SQL_DELETE_CH_FEE_RECVAMOUNT_BY_GID, parm);
iResult = 1;
}
catch (Exception error)
{
iResult = -1;
throw error;
}
}
return iResult;
}
#endregion
#region 获取SQL SERVER服务器时间
/// <summary>
/// 获取SQL SERVER服务器时间
/// </summary>
/// <returns>返回SQL SERVER 服务端时间</returns>
public DateTime GetServerDateTime()
{
DateTime tempDateTime = DateTime.MinValue;
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
tempDateTime = (DateTime)SqlHelper.ExecuteScalar(conn, CommandType.Text, SQL_SELECT_SERVER_TIME, null);
}
return tempDateTime;
}
#endregion
}
}