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.

146 lines
5.7 KiB
C#

9 months ago
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Collections.Generic;
using DSWeb.Models;
using WebSqlHelper;
namespace DSWeb.EntityDA
{
public class FeeCodeDA
{
private const string PARM_FEECODE_GID = "@gid";
private const string PARM_FEECODE_FEE_CODENAME = "@fee_codename";
private const string PARM_FEECODE_NAME = "@name";
private const string PARM_FEECODE_DESCRIPTION = "@description";
private const string PARM_FEECODE_ISSEA = "@is_sea";
private const string PARM_FEECODE_ISAIR = "@is_air";
private const string PARM_FEECODE_DEFAULT_UNIT = "@default_unit";
private const string PARM_FEECODE_DEFAULT_DEBIT = "@default_debit";
private const string PARM_FEECODE_DEFAULT_CREDIT = "@default_credit";
private const string SQL_SELECT_FEECODE_BY_ID = " SELECT GID, FEECODE, NAME, DESCRIPTION, DEFAULTCURR, ISSEA, ISAIR, DEFAULTUNIT, DEFAULTDEBIT, DEFAULTCREDIT "
+ " FROM code_fee WHERE GID = @gid ";
private const string SQL_SELECT_FEECODE_ALL = " SELECT GID, FEECODE, NAME, DESCRIPTION, DEFAULTCURR, ISSEA, ISAIR, DEFAULTUNIT, DEFAULTDEBIT, DEFAULTCREDIT "
+ " FROM code_fee ";
private const string SQL_SELECT_FEECODE_LIST = " SELECT ISNULL(FEECODE,'')+' '+ISNULL(Name,'') AS FullName,Name FROM code_fee";
#region 根据用费用代码表GID获取所有信息
/// <summary>
/// 根据用费用代码表GID获取所有信息
/// </summary>
/// <param name="strGID"></param>
/// <returns></returns>
public FeeCodeEntity GetFeeCodeByID(string strGID)
{
//初始化返回变量
FeeCodeEntity feeCodeEntity = null;
//初始化参数并赋值
SqlParameter parm = new SqlParameter(PARM_FEECODE_GID, SqlDbType.VarChar, 36);
parm.Value = strGID;
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_FEECODE_BY_ID, parm))
{
try
{
feeCodeEntity = new FeeCodeEntity();
//读取字段值
while (sqlRead.Read())
{
if (!sqlRead.IsDBNull(0))
{
feeCodeEntity.GID = sqlRead.GetString(0);
}
if (!sqlRead.IsDBNull(1))
{
feeCodeEntity.FeeCode = sqlRead.GetString(1);
}
if (!sqlRead.IsDBNull(2))
{
feeCodeEntity.Name = sqlRead.GetString(2);
}
if (!sqlRead.IsDBNull(3))
{
feeCodeEntity.Description = sqlRead.GetString(3);
}
if (!sqlRead.IsDBNull(4))
{
feeCodeEntity.DefaultCurrency = sqlRead.GetString(4);
}
if (!sqlRead.IsDBNull(5))
{
feeCodeEntity.IsSea = sqlRead.GetBoolean(5);
}
if (!sqlRead.IsDBNull(6))
{
feeCodeEntity.IsAir = sqlRead.GetBoolean(6);
}
if (!sqlRead.IsDBNull(7))
{
feeCodeEntity.DefaultUnit = sqlRead.GetInt32(7);
}
if (!sqlRead.IsDBNull(8))
{
feeCodeEntity.DefaultDebit = sqlRead.GetInt32(8);
}
if (!sqlRead.IsDBNull(9))
{
feeCodeEntity.DefaultCredit = sqlRead.GetInt32(9);
}
}
}
catch (Exception exceError)
{
//抛出异常
throw exceError;
}
}
return feeCodeEntity;
}
#endregion
#region 返回所有费用代码数据集
/// <summary>
/// 返回所有费用代码数据集
/// </summary>
/// <param name="strSql"></param>
/// <returns></returns>
public DataSet GetFeeCodeListALL()
{
DataSet userSet = new DataSet();
userSet = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_FEECODE_ALL);
return userSet;
}
#endregion
#region 返回所有费用代码表中的NAME, DESCRIPTION数据集绑定selects
/// <summary>
/// 返回所有费用代码表中的NAME, DESCRIPTION数据集绑定selects
/// </summary>
/// <returns></returns>
public DataSet GetFeeCodeList()
{
DataSet userSet = new DataSet();
userSet = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_FEECODE_LIST);
return userSet;
}
#endregion
public DataSet GetExcuteSql(string strSql)
{
DataSet tempSet = new DataSet();
tempSet = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql);
return tempSet;
}
}
}