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/EntityDA/FeeModifyDA.cs

1000 lines
44 KiB
C#

2 years ago
using System;
using System.Data;
using System.Configuration;
using DSWeb.Models;
using System.Data.SqlClient;
using System.Collections;
using System.Collections.Generic;
using WebSqlHelper;
namespace DSWeb.EntityDA
{
public class FeeModifyDA
{
private const string PARM_FEE_MODIFY_GID = "@gid";
private const string PARM_FEE_MODIFY_TYPE = "@type";
private const string PARM_FEE_MODIFY_APPLY_TYPE = "@apply_type";
private const string PARM_FEE_MODIFY_REASON = "@reason";
private const string PARM_FEE_MODIFY_FEE_ID = "@fee_id";
private const string PARM_FEE_MODIFY_BSNO = "@bsno";
private const string PARM_FEE_MODIFY_FEE_NAME = "@fee_name";
private const string PARM_FEE_MODIFY_CUSTOMER_NAME = "@customer_name";
private const string PARM_FEE_MODIFY_UNIT = "@unit";
private const string PARM_FEE_MODIFY_UNIT_PRICE = "@unit_price";
private const string PARM_FEE_MODIFY_QUANTITY = "@quantity";
private const string PARM_FEE_MODIFY_AMOUNT = "@amount";
private const string PARM_FEE_MODIFY_CURRENCY = "@currency";
private const string PARM_FEE_MODIFY_FRT = "@frt";
private const string PARM_FEE_MODIFY_COMMISSION_RATE = "@commission_rate";
private const string PARM_FEE_MODIFY_EXCHANGE_RATE = "@exchange_rate";
private const string PARM_FEE_MODIFY_IS_ADVANCE_PAY = "@is_advanced_pay";
private const string PARM_FEE_MODIFY_AUDIT_USER = "@audit_user";
private const string PARM_FEE_MODIFY_AUDIT_TIME = "@audit_time";
private const string PARM_FEE_MODIFY_APPLY_USER = "@apply_user";
private const string PARM_FEE_MODIFY_APPLY_TIME = "@apply_time";
private const string PARM_FEE_MODIFY_APPLY_STATUS = "@apply_status";
private const string PARM_FEE_STATUS = "@fee_status";
private const string PARM_FEE_PREVIOUS_STATUS = "@previous_status";
private const string PARM_FEE_MODIFY_APPLY_REMARK = "@remark";
private const string SQL_SELECT_FEE_MODIFY_BY_GID = "SELECT GID, TYPE, APPLYTYPE, REASON,FEEID, BSNO, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY,FRT,COMMISSIONRATE,EXCHANGERATE,ISADVANCEDPAY,AUDITUSER,"
+ "AUDITTIME, APPLYUSER, APPLYTIME, APPLYSTATUS,REMARK FROM ch_fee_modify WHERE GID = @gid";
private const string SQL_SELECT_FEE_MODIFY_BY_FEEID = "SELECT GID, TYPE, APPLYTYPE, REASON,FEEID,BSNO, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY,FRT,COMMISSIONRATE,EXCHANGERATE, ISADVANCEDPAY,AUDITUSER,"
+ "AUDITTIME, APPLYUSER, APPLYTIME, APPLYSTATUS,REMARK FROM ch_fee_modify WHERE FEEID = @fee_id AND APPLYSTATUS = @apply_status";
private const string SQL_SELECT_FEE_MODIFY_BY_FEEID_EXIST = "SELECT GID, TYPE, APPLYTYPE, REASON,FEEID,BSNO, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY,FRT,COMMISSIONRATE,EXCHANGERATE, ISADVANCEDPAY,AUDITUSER,"
+ "AUDITTIME, APPLYUSER, APPLYTIME, APPLYSTATUS,REMARK FROM ch_fee_modify WHERE FEEID = @fee_id ";
private const string SQL_INSERT_FEE_MODIFY = "INSERT INTO ch_fee_modify(GID, TYPE, APPLYTYPE, REASON,FEEID,BSNO, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY,FRT,COMMISSIONRATE,EXCHANGERATE,ISADVANCEDPAY,"
+ " APPLYUSER, APPLYTIME, APPLYSTATUS,REMARK) VALUES (@gid,@type,@apply_type,@reason,@fee_id,@bsno,@fee_name,@customer_name,@unit,@unit_price,@quantity,"
+ "@amount,@currency,@frt,@commission_rate,@exchange_rate,@is_advanced_pay,@apply_user,getdate(),@apply_status,@remark)";
private const string SQL_UPDATE_FEE_STATUS = "UPDATE ch_fee SET FEESTATUS = @fee_status WHERE GID = @fee_id";
private const string SQL_UPDATE_FEE_MODIFY_STATUS = "UPDATE ch_fee_modify SET APPLYSTATUS = @apply_status,AUDITUSER = @audit_user,AUDITTIME = GETDATE() WHERE FEEID = @fee_id AND APPLYSTATUS = @previous_status";
private const string SQL_DELETE_FEE = "DELETE FROM ch_fee WHERE GID = @fee_id";
private const string SQL_SELECT_FEE_MODIFY_HISTORY = " SELECT GID, TYPE, APPLYTYPE, REASON,FEEID,BSNO, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY,FRT,COMMISSIONRATE,EXCHANGERATE, ISADVANCEDPAY,AUDITUSER,"
+ " AUDITTIME, APPLYUSER, APPLYTIME, APPLYSTATUS,REMARK FROM ch_fee_modify WHERE FEEID = @fee_id ORDER BY APPLYTIME DESC ";
#region 根据费用GID获取费用申请更改信息
/// <summary>
///根据费用GID获取费用申请更改信息
/// </summary>
/// <param name="tempFeeID">费用GID</param>
/// <returns>返回IList<>FeeModifyEntity实体类组</returns>
public IList<FeeModifyEntity> GetExistFeeModify(string tempFeeID)
{
IList<FeeModifyEntity> feeModifyEntities = new List<FeeModifyEntity>();
SqlParameter parm = new SqlParameter(PARM_FEE_MODIFY_FEE_ID, SqlDbType.VarChar, 36);
parm.Value = tempFeeID;
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_FEE_MODIFY_BY_FEEID_EXIST, parm))
{
try
{
while (sqlRead.Read())
{
FeeModifyEntity feeModifyEntity = new FeeModifyEntity();
if (!sqlRead.IsDBNull(0))
{
feeModifyEntity.GID = sqlRead.GetString(0);
}
if (!sqlRead.IsDBNull(1))
{
feeModifyEntity.Type = sqlRead.GetInt32(1);
}
if (!sqlRead.IsDBNull(2))
{
feeModifyEntity.ApplyType = sqlRead.GetInt32(2);
}
if (!sqlRead.IsDBNull(3))
{
feeModifyEntity.Reason = sqlRead.GetString(3);
}
if (!sqlRead.IsDBNull(4))
{
feeModifyEntity.FeeID = sqlRead.GetString(4);
}
if (!sqlRead.IsDBNull(5))
{
feeModifyEntity.BSNO = sqlRead.GetString(5);
}
if (!sqlRead.IsDBNull(6))
{
feeModifyEntity.FeeName = sqlRead.GetString(6);
}
if (!sqlRead.IsDBNull(7))
{
feeModifyEntity.CustomerName = sqlRead.GetString(7);
}
if (!sqlRead.IsDBNull(8))
{
feeModifyEntity.Unit = sqlRead.GetString(8);
}
if (!sqlRead.IsDBNull(9))
{
feeModifyEntity.UnitPrice = sqlRead.GetDecimal(9);
}
if (!sqlRead.IsDBNull(10))
{
feeModifyEntity.Quantity = sqlRead.GetDecimal(10);
}
if (!sqlRead.IsDBNull(11))
{
feeModifyEntity.Amount = sqlRead.GetDecimal(11);
}
if (!sqlRead.IsDBNull(12))
{
feeModifyEntity.Currency = sqlRead.GetString(12);
}
if (!sqlRead.IsDBNull(13))
{
feeModifyEntity.FRT = sqlRead.GetString(13);
}
if (!sqlRead.IsDBNull(14))
{
feeModifyEntity.CommissionRate = sqlRead.GetDecimal(14);
}
if (!sqlRead.IsDBNull(15))
{
feeModifyEntity.ExchangeRate = sqlRead.GetDecimal(15);
}
if (!sqlRead.IsDBNull(16))
{
feeModifyEntity.IsAdvancePay = sqlRead.GetBoolean(16);
}
if (!sqlRead.IsDBNull(17))
{
feeModifyEntity.AuditUser = sqlRead.GetString(17);
}
if (!sqlRead.IsDBNull(18))
{
feeModifyEntity.AuditTime = sqlRead.GetDateTime(18);
}
if (!sqlRead.IsDBNull(19))
{
feeModifyEntity.ApplyUser = sqlRead.GetString(19);
}
if (!sqlRead.IsDBNull(20))
{
feeModifyEntity.ApplyTime = sqlRead.GetDateTime(20);
}
if (!sqlRead.IsDBNull(21))
{
feeModifyEntity.ApplyStatus = sqlRead.GetInt32(21);
}
if (!sqlRead.IsDBNull(22))
{
feeModifyEntity.Remark = sqlRead.GetString(22);
}
feeModifyEntities.Add(feeModifyEntity);
}
}
catch (Exception execError)
{
throw execError;
}
}
return feeModifyEntities;
}
#endregion
#region 根据费用GID和类型获取费用是申请更改信息
/// <summary>
/// 根据费用GID和类型获取费用是申请更改信息
/// </summary>
/// <param name="tempFeeID">费用GID</param>
/// <param name="iType">申请类型 </param>
/// <returns>返回IList<>FeeModifyEntity实体类组</returns>
public IList<FeeModifyEntity> GetFeeModifyByFeeID(string tempFeeID, int tempApplyStatus)
{
IList<FeeModifyEntity> feeModifyEntities = new List<FeeModifyEntity>();
SqlParameter[] parms = new SqlParameter[] {
new SqlParameter(PARM_FEE_MODIFY_FEE_ID, SqlDbType.VarChar, 36),
new SqlParameter(PARM_FEE_MODIFY_APPLY_STATUS, SqlDbType.Int)
};
parms[0].Value = tempFeeID;
parms[1].Value = tempApplyStatus;
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_FEE_MODIFY_BY_FEEID, parms))
{
try
{
while (sqlRead.Read())
{
FeeModifyEntity feeModifyEntity = new FeeModifyEntity();
if (!sqlRead.IsDBNull(0))
{
feeModifyEntity.GID = sqlRead.GetString(0);
}
if (!sqlRead.IsDBNull(1))
{
feeModifyEntity.Type = sqlRead.GetInt32(1);
}
if (!sqlRead.IsDBNull(2))
{
feeModifyEntity.ApplyType = sqlRead.GetInt32(2);
}
if (!sqlRead.IsDBNull(3))
{
feeModifyEntity.Reason = sqlRead.GetString(3);
}
if (!sqlRead.IsDBNull(4))
{
feeModifyEntity.FeeID = sqlRead.GetString(4);
}
if (!sqlRead.IsDBNull(5))
{
feeModifyEntity.BSNO = sqlRead.GetString(5);
}
if (!sqlRead.IsDBNull(6))
{
feeModifyEntity.FeeName = sqlRead.GetString(6);
}
if (!sqlRead.IsDBNull(7))
{
feeModifyEntity.CustomerName = sqlRead.GetString(7);
}
if (!sqlRead.IsDBNull(8))
{
feeModifyEntity.Unit = sqlRead.GetString(8);
}
if (!sqlRead.IsDBNull(9))
{
feeModifyEntity.UnitPrice = sqlRead.GetDecimal(9);
}
if (!sqlRead.IsDBNull(10))
{
feeModifyEntity.Quantity = sqlRead.GetDecimal(10);
}
if (!sqlRead.IsDBNull(11))
{
feeModifyEntity.Amount = sqlRead.GetDecimal(11);
}
if (!sqlRead.IsDBNull(12))
{
feeModifyEntity.Currency = sqlRead.GetString(12);
}
if (!sqlRead.IsDBNull(13))
{
feeModifyEntity.FRT = sqlRead.GetString(13);
}
if (!sqlRead.IsDBNull(14))
{
feeModifyEntity.CommissionRate = sqlRead.GetDecimal(14);
}
if (!sqlRead.IsDBNull(15))
{
feeModifyEntity.ExchangeRate = sqlRead.GetDecimal(15);
}
if (!sqlRead.IsDBNull(16))
{
feeModifyEntity.IsAdvancePay = sqlRead.GetBoolean(16);
}
if (!sqlRead.IsDBNull(17))
{
feeModifyEntity.AuditUser = sqlRead.GetString(17);
}
if (!sqlRead.IsDBNull(18))
{
feeModifyEntity.AuditTime = sqlRead.GetDateTime(18);
}
if (!sqlRead.IsDBNull(19))
{
feeModifyEntity.ApplyUser = sqlRead.GetString(19);
}
if (!sqlRead.IsDBNull(20))
{
feeModifyEntity.ApplyTime = sqlRead.GetDateTime(20);
}
if (!sqlRead.IsDBNull(21))
{
feeModifyEntity.ApplyStatus = sqlRead.GetInt32(21);
}
if (!sqlRead.IsDBNull(22))
{
feeModifyEntity.Remark = sqlRead.GetString(22);
}
feeModifyEntities.Add(feeModifyEntity);
}
}
catch (Exception execError)
{
throw execError;
}
}
return feeModifyEntities;
}
#endregion
private SqlParameter[] GetAuditParameters()
{
SqlParameter[] parms = new SqlParameter[] {
new SqlParameter(PARM_FEE_MODIFY_GID,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_MODIFY_TYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_APPLY_TYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_REASON,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_MODIFY_FEE_ID,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_MODIFY_BSNO,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_MODIFY_FEE_NAME,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_MODIFY_CUSTOMER_NAME,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_MODIFY_UNIT,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_MODIFY_UNIT_PRICE,SqlDbType.Decimal,18),
new SqlParameter(PARM_FEE_MODIFY_QUANTITY,SqlDbType.Decimal,18),
new SqlParameter(PARM_FEE_MODIFY_AMOUNT,SqlDbType.Decimal,18),
new SqlParameter(PARM_FEE_MODIFY_CURRENCY,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_MODIFY_FRT,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_MODIFY_COMMISSION_RATE,SqlDbType.Decimal,18),
new SqlParameter(PARM_FEE_MODIFY_EXCHANGE_RATE,SqlDbType.Decimal,18),
new SqlParameter(PARM_FEE_MODIFY_IS_ADVANCE_PAY,SqlDbType.Bit),
new SqlParameter(PARM_FEE_MODIFY_AUDIT_USER,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_MODIFY_AUDIT_TIME,SqlDbType.DateTime),
new SqlParameter(PARM_FEE_MODIFY_APPLY_USER,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_MODIFY_APPLY_STATUS,SqlDbType.Int)
};
return parms;
}
public SqlParameter[] GetApplyParameters()
{
SqlParameter[] parms = new SqlParameter[] {
new SqlParameter(PARM_FEE_MODIFY_GID,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_MODIFY_TYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_APPLY_TYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_REASON,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_MODIFY_FEE_ID,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_MODIFY_BSNO,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_MODIFY_FEE_NAME,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_MODIFY_CUSTOMER_NAME,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_MODIFY_UNIT,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_MODIFY_UNIT_PRICE,SqlDbType.Decimal,18),
new SqlParameter(PARM_FEE_MODIFY_QUANTITY,SqlDbType.Decimal,18),
new SqlParameter(PARM_FEE_MODIFY_AMOUNT,SqlDbType.Decimal,18),
new SqlParameter(PARM_FEE_MODIFY_CURRENCY,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_MODIFY_FRT,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_MODIFY_COMMISSION_RATE,SqlDbType.Decimal,18),
new SqlParameter(PARM_FEE_MODIFY_EXCHANGE_RATE,SqlDbType.Decimal,18),
new SqlParameter(PARM_FEE_MODIFY_IS_ADVANCE_PAY,SqlDbType.Bit),
new SqlParameter(PARM_FEE_MODIFY_APPLY_USER,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_MODIFY_APPLY_STATUS,SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_APPLY_REMARK,SqlDbType.VarChar,100)
};
return parms;
}
/// <summary>
/// 将申请费用更改写入表
/// </summary>
/// <param name="tempFeeModifyEntities">IList<FeeModifyEntity>实体类组</param>
/// <returns>返回插入状态值为1表示插入完成,值小于等于表示插入操作异常</returns>
public int InsertApplyModify(IList<FeeModifyEntity> tempFeeModifyEntities)
{
int result = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
foreach (FeeModifyEntity feeModifyEntity in tempFeeModifyEntities)
{
SqlParameter[] parms = GetApplyParameters();
parms[0].Value = feeModifyEntity.GID;
parms[1].Value = feeModifyEntity.Type;
parms[2].Value = feeModifyEntity.ApplyType;
parms[3].Value = feeModifyEntity.Reason;
parms[4].Value = feeModifyEntity.FeeID;
parms[5].Value = feeModifyEntity.BSNO;
parms[6].Value = feeModifyEntity.FeeName;
parms[7].Value = feeModifyEntity.CustomerName;
parms[8].Value = feeModifyEntity.Unit;
parms[9].Value = feeModifyEntity.UnitPrice;
parms[10].Value = feeModifyEntity.Quantity;
parms[11].Value = feeModifyEntity.Amount;
parms[12].Value = feeModifyEntity.Currency;
parms[13].Value = feeModifyEntity.FRT;
parms[14].Value = feeModifyEntity.CommissionRate;
parms[15].Value = feeModifyEntity.ExchangeRate;
parms[16].Value = feeModifyEntity.IsAdvancePay;
parms[17].Value = feeModifyEntity.ApplyUser;
parms[18].Value = feeModifyEntity.ApplyStatus;
parms[19].Value = feeModifyEntity.Remark;
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_INSERT_FEE_MODIFY, parms);
}
SqlParameter[] updateParms = new SqlParameter[] {
new SqlParameter(PARM_FEE_STATUS,SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_FEE_ID,SqlDbType.VarChar,36)
};
//更新费用表ch_fee的费用状态 状态3表示已经提交费用更改申请,等待审核人审核
updateParms[0].Value = 3;
updateParms[1].Value = tempFeeModifyEntities[0].FeeID;
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_UPDATE_FEE_STATUS, updateParms);
//事务提交
sqlTran.Commit();
result = 1;//状态为1表示插入成功
}
catch (Exception execError)
{
result = -1;//有异常,插入失败
sqlTran.Rollback();
result = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return result;
}
#region 将申请删除费用写入表ch_fee_modify,修改ch_fee.feestatus返回操作结果
/// <summary>
/// 将申请删除费用写入表ch_fee_modify,修改ch_fee.feestatus返回操作结果
/// </summary>
/// <param name="tempFeeModifyEntity"></param>
/// <returns>返回操作结果</returns>
public int InsertApplyModifyForDelete(FeeModifyEntity tempFeeModifyEntity)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
SqlParameter[] parms = GetApplyParameters();
parms[0].Value = tempFeeModifyEntity.GID;
parms[1].Value = tempFeeModifyEntity.Type;
parms[2].Value = tempFeeModifyEntity.ApplyType;
parms[3].Value = tempFeeModifyEntity.Reason;
parms[4].Value = tempFeeModifyEntity.FeeID;
parms[5].Value = tempFeeModifyEntity.BSNO;
parms[6].Value = tempFeeModifyEntity.FeeName;
parms[7].Value = tempFeeModifyEntity.CustomerName;
parms[8].Value = tempFeeModifyEntity.Unit;
parms[9].Value = tempFeeModifyEntity.UnitPrice;
parms[10].Value = tempFeeModifyEntity.Quantity;
parms[11].Value = tempFeeModifyEntity.Amount;
parms[12].Value = tempFeeModifyEntity.Currency;
parms[13].Value = tempFeeModifyEntity.FRT;
parms[14].Value = tempFeeModifyEntity.CommissionRate;
parms[15].Value = tempFeeModifyEntity.ExchangeRate;
parms[16].Value = tempFeeModifyEntity.IsAdvancePay;
parms[17].Value = tempFeeModifyEntity.ApplyUser;
parms[18].Value = tempFeeModifyEntity.ApplyStatus;
parms[19].Value = tempFeeModifyEntity.Remark;
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_INSERT_FEE_MODIFY, parms);
SqlParameter[] updateParms = new SqlParameter[] {
new SqlParameter(PARM_FEE_STATUS,SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_FEE_ID,SqlDbType.VarChar,36)
};
//更新费用表ch_fee的费用状态 状态3表示已经提交费用更改申请,等待审核人审核
updateParms[0].Value = 4;
updateParms[1].Value = tempFeeModifyEntity.FeeID;
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_UPDATE_FEE_STATUS, updateParms);
//事务提交
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
#endregion
#region 根据SQL语句获取更改申请信息
/// <summary>
/// 根据SQL语句获取更改申请信息
/// </summary>
/// <param name="strSql"></param>
/// <returns></returns>
public DataSet GetApplyListByCondition(string strSql)
{
DataSet userSet = new DataSet();
userSet = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql);
return userSet;
}
#endregion
public int ApplyModifyReject(string tempFeeID, string strAuditUser)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
//更新旧值状态
SqlParameter[] oldParms = new SqlParameter[]{
new SqlParameter(PARM_FEE_MODIFY_APPLY_STATUS, SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_FEE_ID, SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_PREVIOUS_STATUS, SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_AUDIT_USER,SqlDbType.VarChar,36)
};
oldParms[0].Value = 3;
oldParms[1].Value = tempFeeID;
oldParms[2].Value = 1;
oldParms[3].Value = strAuditUser;
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_UPDATE_FEE_MODIFY_STATUS, oldParms);
//更新新值状态
SqlParameter[] newParms = new SqlParameter[]{
new SqlParameter(PARM_FEE_MODIFY_APPLY_STATUS, SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_FEE_ID, SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_PREVIOUS_STATUS, SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_AUDIT_USER,SqlDbType.VarChar,36)
};
newParms[0].Value = 3;
newParms[1].Value = tempFeeID;
newParms[2].Value = 2;
newParms[3].Value = strAuditUser;
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_UPDATE_FEE_MODIFY_STATUS, newParms);
SqlParameter[] updateParms = new SqlParameter[]{
new SqlParameter(PARM_FEE_STATUS,SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_FEE_ID,SqlDbType.VarChar,36)
};
updateParms[0].Value = 7;
updateParms[1].Value = tempFeeID;
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_UPDATE_FEE_STATUS, updateParms);
//事务提交
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
public int ApplyDeleteReject(string tempFeeID, string tempAuditUser)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
//更新旧值状态
SqlParameter[] oldParms = new SqlParameter[]{
new SqlParameter(PARM_FEE_MODIFY_APPLY_STATUS, SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_FEE_ID, SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_PREVIOUS_STATUS, SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_AUDIT_USER,SqlDbType.VarChar,36)
};
oldParms[0].Value = 3;
oldParms[1].Value = tempFeeID;
oldParms[2].Value = 1;
oldParms[3].Value = tempAuditUser;
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_UPDATE_FEE_MODIFY_STATUS, oldParms);
SqlParameter[] updateParms = new SqlParameter[]{
new SqlParameter(PARM_FEE_STATUS,SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_FEE_ID,SqlDbType.VarChar,36)
};
updateParms[0].Value = 7;
updateParms[1].Value = tempFeeID;
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_UPDATE_FEE_STATUS, updateParms);
//事务提交
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
#region 执行已经通过审核的修改申请
/// <summary>
/// 执行已经通过审核的修改申请
/// </summary>
/// <param name="tempFeeID">费用GID</param>
/// <returns>返回执行状态 值为1表示执行完成,值-1表示执行操作异常,事务回滚失败 值-2执行产生错误,已成功回滚</returns>
public int ApplyModifyPass(string tempFeeID, string tempAuditUserID)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
//更新旧值状态
SqlParameter[] oldParms = new SqlParameter[]{
new SqlParameter(PARM_FEE_MODIFY_APPLY_STATUS, SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_FEE_ID, SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_PREVIOUS_STATUS, SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_AUDIT_USER,SqlDbType.VarChar,36)
};
oldParms[0].Value = 2;
oldParms[1].Value = tempFeeID;
oldParms[2].Value = 1;
oldParms[3].Value = tempAuditUserID;
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_UPDATE_FEE_MODIFY_STATUS, oldParms);
//更新新值状态
SqlParameter[] newParms = new SqlParameter[]{
new SqlParameter(PARM_FEE_MODIFY_APPLY_STATUS, SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_FEE_ID, SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_PREVIOUS_STATUS, SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_AUDIT_USER,SqlDbType.VarChar,36)
};
newParms[0].Value = 2;
newParms[1].Value = tempFeeID;
newParms[2].Value = 2;
newParms[3].Value = tempAuditUserID;
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_UPDATE_FEE_MODIFY_STATUS, newParms);
//更新费用表ch_fee
FeeModifyDA feeModifyDA = new FeeModifyDA();
//获取申请的信息
IList<FeeModifyEntity> feeModifyEntities = feeModifyDA.GetFeeModifyByFeeID(tempFeeID, 2);
string strSql = "";
if (feeModifyEntities.Count == 2)
{
foreach (FeeModifyEntity feeModifyEntity in feeModifyEntities)
{
if (feeModifyEntity.ApplyType == 2)
{
//申请通过 表ch_fee字段FeeStatus字段值为0
strSql = String.Format("UPDATE ch_fee SET FEENAME = '{0}',CUSTOMERNAME = '{1}',UNIT = '{2}', FEESTATUS = {3},UNITPRICE = {4},QUANTITY = {5},AMOUNT = {6},"
+ " CURRENCY = '{7}',EXCHANGERATE = {8},COMMISSIONRATE = {9},REMARK = '{10}',FEEFRT = '{11}' WHERE GID = '{12}'",
feeModifyEntity.FeeName, feeModifyEntity.CustomerName, feeModifyEntity.Unit, 0, feeModifyEntity.UnitPrice, feeModifyEntity.Quantity,
feeModifyEntity.Amount, feeModifyEntity.Currency, feeModifyEntity.ExchangeRate, feeModifyEntity.CommissionRate, feeModifyEntity.Remark,
feeModifyEntity.FRT, tempFeeID);
break;
}
}
}
else
{
throw (new Exception("No Modify Record"));
}
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql, null);
//事务提交
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
#endregion
public int ApplyDeletePass(string tempFeeID, string tempAuditUserID)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
//更新申请删除状态
SqlParameter[] oldParms = new SqlParameter[]{
new SqlParameter(PARM_FEE_MODIFY_APPLY_STATUS, SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_FEE_ID, SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_PREVIOUS_STATUS, SqlDbType.Int),
new SqlParameter(PARM_FEE_MODIFY_AUDIT_USER,SqlDbType.VarChar,36)
};
oldParms[0].Value = 2;
oldParms[1].Value = tempFeeID;
oldParms[2].Value = 1;
oldParms[3].Value = tempAuditUserID;
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_UPDATE_FEE_MODIFY_STATUS, oldParms);
//删除费用表费用表ch_fee字段
SqlParameter deleteParm = new SqlParameter(PARM_FEE_MODIFY_FEE_ID, SqlDbType.VarChar, 36);
deleteParm.Value = tempFeeID;
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_DELETE_FEE, deleteParm);
//事务提交
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
#region 获取费用申请更改历史记录ch_fee_modify(费用申请修改表)
/// <summary>
/// 获取费用申请更改历史记录ch_fee_modify(费用申请修改表)
/// </summary>
/// <param name="tempFeeID">费用GID</param>
/// <returns></returns>
public IList<FeeModifyEntity> GetFeeModifyHistory(string tempFeeID)
{
IList<FeeModifyEntity> feeModifyEntities = new List<FeeModifyEntity>();
SqlParameter[] parms = new SqlParameter[] {
new SqlParameter(PARM_FEE_MODIFY_FEE_ID, SqlDbType.VarChar, 36)
};
parms[0].Value = tempFeeID;
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_FEE_MODIFY_HISTORY, parms))
{
try
{
while (sqlRead.Read())
{
FeeModifyEntity feeModifyEntity = new FeeModifyEntity();
if (!sqlRead.IsDBNull(0))
{
feeModifyEntity.GID = sqlRead.GetString(0);
}
if (!sqlRead.IsDBNull(1))
{
feeModifyEntity.Type = sqlRead.GetInt32(1);
}
if (!sqlRead.IsDBNull(2))
{
feeModifyEntity.ApplyType = sqlRead.GetInt32(2);
}
if (!sqlRead.IsDBNull(3))
{
feeModifyEntity.Reason = sqlRead.GetString(3);
}
if (!sqlRead.IsDBNull(4))
{
feeModifyEntity.FeeID = sqlRead.GetString(4);
}
if (!sqlRead.IsDBNull(5))
{
feeModifyEntity.BSNO = sqlRead.GetString(5);
}
if (!sqlRead.IsDBNull(6))
{
feeModifyEntity.FeeName = sqlRead.GetString(6);
}
if (!sqlRead.IsDBNull(7))
{
feeModifyEntity.CustomerName = sqlRead.GetString(7);
}
if (!sqlRead.IsDBNull(8))
{
feeModifyEntity.Unit = sqlRead.GetString(8);
}
if (!sqlRead.IsDBNull(9))
{
feeModifyEntity.UnitPrice = sqlRead.GetDecimal(9);
}
if (!sqlRead.IsDBNull(10))
{
feeModifyEntity.Quantity = sqlRead.GetDecimal(10);
}
if (!sqlRead.IsDBNull(11))
{
feeModifyEntity.Amount = sqlRead.GetDecimal(11);
}
if (!sqlRead.IsDBNull(12))
{
feeModifyEntity.Currency = sqlRead.GetString(12);
}
if (!sqlRead.IsDBNull(13))
{
feeModifyEntity.FRT = sqlRead.GetString(13);
}
if (!sqlRead.IsDBNull(14))
{
feeModifyEntity.CommissionRate = sqlRead.GetDecimal(14);
}
if (!sqlRead.IsDBNull(15))
{
feeModifyEntity.ExchangeRate = sqlRead.GetDecimal(15);
}
if (!sqlRead.IsDBNull(16))
{
feeModifyEntity.IsAdvancePay = sqlRead.GetBoolean(16);
}
if (!sqlRead.IsDBNull(17))
{
feeModifyEntity.AuditUser = sqlRead.GetString(17);
}
if (!sqlRead.IsDBNull(18))
{
feeModifyEntity.AuditTime = sqlRead.GetDateTime(18);
}
if (!sqlRead.IsDBNull(19))
{
feeModifyEntity.ApplyUser = sqlRead.GetString(19);
}
if (!sqlRead.IsDBNull(20))
{
feeModifyEntity.ApplyTime = sqlRead.GetDateTime(20);
}
if (!sqlRead.IsDBNull(21))
{
feeModifyEntity.ApplyStatus = sqlRead.GetInt32(21);
}
if (!sqlRead.IsDBNull(22))
{
feeModifyEntity.Remark = sqlRead.GetString(22);
}
feeModifyEntities.Add(feeModifyEntity);
}
}
catch (Exception execError)
{
throw execError;
}
}
return feeModifyEntities;
}
#endregion
}
}