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 EnterExitPriceService
{
///
/// 查询所有
///
/// sql语句
/// 可变参数数组
/// 返回集合
List excuteSql(string sql, params SqlParameter[] param)
{
return ServiceBase.excuteSql(new EnterExitPrice(), "EnterExitPrice", sql, CommandType.Text, param);
}
///
/// 获取单个对象
///
/// sql语句
/// 可变参数数组
/// 返回空或者单个对象
EnterExitPrice 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 AddEnterExitPrice(EnterExitPrice hd)
{
string sql = "insert into EnterExitPrice values(@Continent,@Country,@City,@Currency,@RoomCost,@FoodCost,@PublicCost,@Oper,@Opdate,@Isdel)";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@Continent",hd.Continent),
new SqlParameter("@Country",hd.Country),
new SqlParameter("@City",hd.City),
new SqlParameter("@Currency",hd.Currency),
new SqlParameter("@RoomCost",hd.RoomCost),
new SqlParameter("@FoodCost",hd.FoodCost),
new SqlParameter("@PublicCost",hd.PublicCost),
new SqlParameter("@Oper",hd.Oper),
new SqlParameter("@Opdate",hd.Opdate),
new SqlParameter("@Isdel",hd.Isdel)
};
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
return true;
return false;
}
///
/// 编辑
///
///
///
public bool EditEnterExitPrice(EnterExitPrice hd)
{
string sql = "update EnterExitPrice set Continent=@Continent,Country=@Country,City=@City,Currency=@Currency,"
+ "RoomCost=@RoomCost,FoodCost=@FoodCost,PublicCost=@PublicCost,Oper=@Oper,Opdate=@Opdate,Isdel=@Isdel where Id = @Id";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@Continent",hd.Continent),
new SqlParameter("@Country",hd.Country),
new SqlParameter("@City",hd.City),
new SqlParameter("@Currency",hd.Currency),
new SqlParameter("@RoomCost",hd.RoomCost),
new SqlParameter("@FoodCost",hd.FoodCost),
new SqlParameter("@PublicCost",hd.PublicCost),
new SqlParameter("@Oper",hd.Oper),
new SqlParameter("@Opdate",hd.Opdate),
new SqlParameter("@Isdel",hd.Isdel),
new SqlParameter("@Id",hd.Id)
};
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
return true;
return false;
}
///
/// 删除
///
///
///
public bool DelEnterExitPrice(int id)
{
if (SqlHelper.ExecuteNonQuery("update EnterExitPrice set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
return true;
return false;
}
///
/// 查询所有
///
///
public List GetByPlace(string City)
{
return excuteSql("SELECT * FROM EnterExitPrice where Isdel=0 AND (Country LIKE '%" + City + "%' OR City LIKE '%" + City + "%')");
}
///
/// 雷怡 2021-08-23 10:32
/// 查询所有
///
///
public List GetByAll()
{
return excuteSql("SELECT * FROM EnterExitPrice where Isdel=0 ");
}
///
/// 查询所有
///
///
public EnterExitPrice GetById(string ID)
{
return excuteType("SELECT * FROM EnterExitPrice where Isdel=0 AND Id=" + ID);
}
///
/// 查询所有
///
///
public EnterExitPrice GetByCity(string City)
{
return excuteType("SELECT * FROM EnterExitPrice where Isdel=0 AND (Country LIKE '%" + City + "%' OR City LIKE '%" + City + "%')");
}
public EnterExitPrice NewGetByCity(string City)
{
return excuteType("SELECT * FROM EnterExitPrice where Isdel=0 AND City = '"+ City+"'");
}
///
/// 查找所有数据 - 分页
///
///
public List GetAll(int pageIndex, out int sumPage, out int totalRecord, string Job)
{
string sqlwhere = "IsDel = 0 and City like '%" + Job + "%'";
return PageBase.excutePageSql(new EnterExitPrice(), "EnterExitPrice", "EnterExitPrice", "*", "id asc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
}
//
/// 查找所有数据 - 分页
///
///
public List GetAll(int pageIndex, out int sumPage, out int totalRecord, string country, string city)
{
string sqlwhere = "IsDel = 0 and City like '%" + city + "%' and Country like '%" + country + "%' ";
return PageBase.excutePageSql(new EnterExitPrice(), "EnterExitPrice", "EnterExitPrice", "*", "id asc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
}
}
}