using Models;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DAL
{
public class VisaCommissionService
{
///
/// 查询集合
///
///
///
///
List excuteSql(string sql, params SqlParameter[] param)
{
return ServiceBase.excuteSql(new VisaCommission(), "VisaCommission", sql, CommandType.Text, param);
}
///
/// 查询单个
///
///
///
///
VisaCommission excuteType(string sql, params SqlParameter[] param)
{
//查询结果放入对象集合
List hdList = excuteSql(sql, param);
VisaCommission visa = new VisaCommission();
//判断集合是否为空
if (hdList == null || hdList.Count == 0)
{
//返回null
return null;
}
//返回单个对象
return hdList[0];
}
///
/// 根据团组Id和国家查询单条
///
///
///
public VisaCommission getByDiId(int diid,string Nation,int UserId)
{
return excuteType("select * from VisaCommission where Nation='" + Nation + "' and Isdel=0 and DiId=@diid and UId="+ UserId, new SqlParameter("@diid", diid));
}
///
/// 增加
///
///
///
public bool Add(VisaCommission Vc)
{
string sql = "insert into VisaCommission values(@DiId,@UId,@Number,@Nation,@CreateUserId,@CreateDateTime,@Remark,@IsDel)";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@DiId",Vc.DiId),
new SqlParameter("@UId",Vc.UId),
new SqlParameter("@Number",Vc.Number),
new SqlParameter("@Nation",Vc.Nation),
new SqlParameter("@CreateUserId",Vc.CreateUserId),
new SqlParameter("@CreateDateTime",Vc.CreateDateTime),
new SqlParameter("@Remark",Vc.Remark),
new SqlParameter("@IsDel",Vc.IsDel)
};
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
return true;
return false;
}
///
/// 获取信用卡账单类型费用
///
///
public List GetAll(int diid,int UserId)
{
return excuteSql("select * from VisaCommission where DiId="+diid+ " and isdel = 0 and UId="+UserId);
}
///
/// 编辑
///
///
///
public bool Edit(VisaCommission Vc)
{
string sql = "update VisaCommission set Number=@Number,CreateUserId=@CreateUserId,CreateDateTime=@CreateDateTime,Remark=@Remark where Id = @Id";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@Id ",Vc.Id ),
new SqlParameter("@Number",Vc.Number),
new SqlParameter("@Remark",Vc.Remark),
new SqlParameter("@CreateUserId",Vc.CreateUserId),
new SqlParameter("@CreateDateTime",Vc.CreateDateTime),
};
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
return true;
return false;
}
///
/// 删除
///
///
///
public bool Del(int id)
{
if (SqlHelper.ExecuteNonQuery("update VisaCommission set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
return true;
return false;
}
}
}