//Dal访问层using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Data;using MODER;namespace DAL
{
publicclass guan
{
DBHelper db =newDBHelper();publicintAdd(biao b)//景点表做添加方法{
string s =string.Format("insert into biao values('{0}','{1}',{2},{3},'{4}','{5}')",b.NAME,b.QUYU,b.PIAOJIA,b.COID,b.MIAOSHU,b.ZT);return db.ExecuteNonQuery(s);}public List<country>Xian()//给国家表做一个显示方法{
string s ="select *from COUNTRY";return db.GetToList<country>(s);}public List<biao>Show()//景点表的显示方法{
string s ="select*from biao";return db.GetToList<biao>(s);}publicintDelete(int id)//景点表的删除方法{
string s =string.Format("delete from biao where ID={0}",id);return db.ExecuteNonQuery(s);}publicintPDAL(string id)//景点表的批删方法{
string s =string.Format("delete from biao where id in ("+id+")");return db.ExecuteNonQuery(s);}publicintUPdate(biao b)//景点表的修改方法{
string s =string.Format("update biao set NAME='{0}',QUYU='{1}',PIAOJIA={2},COID={3},MIAOSHU='{4}',ZT='{5}' WHERE ID={6}",b.NAME,b.QUYU,b.PIAOJIA,b.COID,b.MIAOSHU,b.ZT,b.ID);return db.ExecuteNonQuery(s);}publicDataTableCHaid(int id)//根据你所修改的数据去查ID{
string s ="select*from biao where id="+ id;return db.GetTable(s);}//public List<biao> CHAxun(string NAME) 单条件查询,按照姓名进行查询//{
// string s = string.Format("select*from biao where name like '%"+NAME+"%'");// return db.GetToList<biao>(s);//}public List<biao>CHAzhao(string name,int COID)//多条件查询{
string s =string.Format("select*from biao where 1=1");if(name !="")//根据姓名去查询{
s +="and name like '%"+ name +"%'";}elseif(COID !=0)//根据所在国家查询{
s +="and coid="+ COID;}return db.GetToList<biao>(s);}}}