using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; using Models; namespace DAL { public class BackwardTable_VisaService { List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new BackwardTable_Visa(), "BackwardTable_Visa", sql, CommandType.Text, param); } BackwardTable_Visa excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List hdList = excuteSql(sql, param); //判断集合是否为空 if (hdList == null || hdList.Count == 0) //返回null return null; //返回单个对象 return hdList[0]; } /// /// 增加 /// /// public bool Add(BackwardTable_Visa btv) { string sql = "insert into BackwardTable_Visa values(@BT_Diid,@BT_VisaCountry,@BT_BusinessType,@BT_VisaType,@BT_VisaTime,@BT_Oper,@BT_OperDate,@BT_Isdel)"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@BT_Diid",btv.BT_Diid), new SqlParameter("@BT_VisaCountry",btv.BT_VisaCountry), new SqlParameter("@BT_BusinessType",btv.BT_BusinessType), new SqlParameter("@BT_VisaType",btv.BT_VisaType), new SqlParameter("@BT_VisaTime",btv.BT_VisaTime), new SqlParameter("@BT_Oper",btv.BT_Oper), new SqlParameter("@BT_OperDate",btv.BT_OperDate), new SqlParameter("@BT_Isdel",btv.BT_Isdel) }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } /// /// 改Update /// /// /// public bool Update(BackwardTable_Visa btv) { string sql = "update BackwardTable_Visa set BT_Diid=@BT_Diid,BT_VisaCountry=@BT_VisaCountry,BT_BusinessType=@BT_BusinessType,BT_VisaType=@BT_VisaType,BT_VisaTime=@BT_VisaTime," + "BT_Oper=@BT_Oper,BT_OperDate=@BT_OperDate,BT_Isdel=@BT_Isdel where BT_Id = @BT_Id"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@BT_Diid",btv.BT_Diid), new SqlParameter("@BT_VisaCountry",btv.BT_VisaCountry), new SqlParameter("@BT_BusinessType",btv.BT_BusinessType), new SqlParameter("@BT_VisaType",btv.BT_VisaType), new SqlParameter("@BT_VisaTime",btv.BT_VisaTime), new SqlParameter("@BT_Oper",btv.BT_Oper), new SqlParameter("@BT_OperDate",btv.BT_OperDate), new SqlParameter("@BT_Isdel",btv.BT_Isdel), new SqlParameter("@BT_Id",btv.BT_Id) }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } /// /// 根据ID查询 /// /// /// public List GetByDiid(int diid) { //调用获取单个对象的方法 string sql = "select * from BackwardTable_Visa where BT_Diid=@BT_Diid and BT_Isdel=0"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@BT_Diid", diid) }; return excuteSql(sql, parameter); } public BackwardTable_Visa GetByDiidAndCountry(int diid, string country) { //调用获取单个对象的方法 string sql = "select * from BackwardTable_Visa where BT_Diid=@BT_Diid and BT_VisaCountry=@BT_VisaCountry and BT_Isdel=0"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@BT_Diid", diid), new SqlParameter("@BT_VisaCountry", country) }; return excuteType(sql, parameter); } } }