using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using Models;
namespace DAL
{
public class DelegationInfoOrFeeCostServcies
{
///
/// 查询所有
///
/// sql语句
/// 可变参数数组
/// 返回集合
List excuteSql(string sql, params SqlParameter[] param)
{
return ServiceBase.excuteSql(new DelegationInfoOrFeeCost(), "DelegationInfoOrFeeCost", sql, CommandType.Text, param);
}
///
/// 获取单个对象
///
/// sql语句
/// 可变参数数组
/// 返回空或者单个对象
DelegationInfoOrFeeCost excuteType(string sql, params SqlParameter[] param)
{
//查询结果放入对象集合
List diList = excuteSql(sql, param);
//判断集合是否为空
if (diList == null || diList.Count == 0)
//返回null
return null;
//返回单个对象
return diList[0];
}
///
/// 根据编号查询多条对象对象信息
///
/// 对象编号
/// 返回空或者多个对象信息
public List GetDelegationInfoIdByIDAll(int diid)
{
//调用获取单个对象的方法
return excuteSql("select * from DelegationInfoOrFeeCost where DIid=" + diid);
}
///
/// 根据编号查询对象信息
///
/// 对象编号
/// 返回空或者单个对象信息
public DelegationInfoOrFeeCost GetDelegationInfoIdByID(int diid)
{
//调用获取单个对象的方法
return excuteType("select * from DelegationInfoOrFeeCost where DIid="+diid);
}
///
/// 根据签证表id查询链接表id
///
///
///
public DelegationInfoOrFeeCost getAllByCountryId(int cid)
{
return excuteType("select * from DelegationInfoOrFeeCost where isdel=0 and CFCid=@id", new SqlParameter("@id", cid));
}
///
/// 添加团组表和签证费用标准表的连表
///
///
///
public bool Add(DelegationInfoOrFeeCost cf)
{
string sql = "insert into DelegationInfoOrFeeCost values(@DIid,@CFCid,@Oper,@OpdTime,@isdel);SELECT @@IDENTITY";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@DIid",cf.DIid),
new SqlParameter("@CFCid",cf.CFCid),
new SqlParameter("@Oper",cf.Oper),
new SqlParameter("@OpdTime",cf.OpdTime),
new SqlParameter("@isdel",cf.isdel)
};
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
return true;
return false;
}
///
/// 修改这条签证的状态
///
/// 签证表 id
/// 操作人编号
/// 操作人操作时间
///
public bool delDelegationInfoOrFeeCost(int id, int userid, string datetime)
{
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@CId",id),
new SqlParameter("@OPDate",datetime),
new SqlParameter("@Oper",userid)
};
if (SqlHelper.ExecuteNonQuery("update DelegationInfoOrFeeCost set isdel=1,Oper=@Oper,OpdTime=@OPDate where DFCid=@CId", CommandType.Text, parameter) > 0)
return true;
return false;
}
}
}