123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- using Models;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Text;
- namespace DAL
- {
- public class VisaCheckTimeForBackService
- {
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回集合</returns>
- List<VisaCheckTimeForBack> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<VisaCheckTimeForBack>.excuteSql(new VisaCheckTimeForBack(), "VisaCheckTimeForBack", sql, CommandType.Text, param);
- }
- /// <summary>
- /// 获取单个对象
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回空或者单个对象</returns>
- VisaCheckTimeForBack excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<VisaCheckTimeForBack> hdList = excuteSql(sql, param);
- //判断集合是否为空
- if (hdList == null || hdList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return hdList[0];
- }
- /// <summary>
- /// 根据编号查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public VisaCheckTimeForBack GetByID(int id)
- {
- //调用获取单个对象的方法
- return excuteType("select * from VisaCheckTimeForBack where Id = @id and IsDel = 0", new SqlParameter("@id", id));
- }
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <returns></returns>
- public List<VisaCheckTimeForBack> GetAll(string diid)
- {
- return excuteSql("select * from VisaCheckTimeForBack where IsDel=0 and Diid=" + diid);
- }
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <returns></returns>
- public List<VisaCheckTimeForBack> GetAll()
- {
- return excuteSql("select * from VisaCheckTimeForBack where IsDel=0", null);
- }
- /// <summary>
- /// 按国家名和id查询所有
- /// </summary>
- /// <param name="country">国家名</param>
- /// <param name="id">id</param>
- /// <returns></returns>
- public VisaCheckTimeForBack GetCountryAndDiid(string country,int diid)
- {
- return excuteType("select * from VisaCheckTimeForBack where IsDel=0 and Country=@country and Diid=@diid", new SqlParameter("@country", country), new SqlParameter("@diid", diid));
- }
- /// <summary>
- /// 增加
- /// </summary>
- /// <param name="cd"></param>
- /// <returns></returns>
- public bool Add(VisaCheckTimeForBack hd)
- {
- string sql = "insert into VisaCheckTimeForBack values(@Diid,@Country,@Time,@Isdel)";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@Diid",hd.Diid),
- new SqlParameter("@Country",hd.Country),
- new SqlParameter("@Time",hd.Time),
- new SqlParameter("@Isdel",hd.Isdel)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="sdt"></param>
- /// <returns></returns>
- public bool Edit(VisaCheckTimeForBack hd)
- {
- string sql = "update VisaCheckTimeForBack set Diid=@Diid,Country=@Country,Time=@Time,Isdel=@Isdel where Id = @Id";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@Diid",hd.Diid),
- new SqlParameter("@Country",hd.Country),
- new SqlParameter("@Time",hd.Time),
- new SqlParameter("@Isdel",hd.Isdel),
- new SqlParameter("@Id",hd.Id)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public bool Del(int id)
- {
- if (SqlHelper.ExecuteNonQuery("update VisaCheckTimeForBack set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 清空
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public bool Clean(int id)
- {
- if (SqlHelper.ExecuteNonQuery("update VisaCheckTimeForBack set Country='" + "',Time='" + "' where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- }
- }
|