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 opitineraryService { List excuteSqlFi(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new opitineraryfixed(), "opitineraryfixed", sql, CommandType.Text, param); } opitineraryfixed excuteTypeFi(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List hdList = excuteSqlFi(sql, param); opitineraryfixed air = new opitineraryfixed(); //判断集合是否为空 if (hdList == null || hdList.Count == 0) { return air; } //返回单个对象 return hdList[0]; } public opitineraryfixed getFiFirstData() { return this.excuteTypeFi("select * from opitineraryfixed", new SqlParameter[] {}); } public bool EditFi(opitineraryfixed hd) { string sql = @"update opitineraryfixed set itemPrepare = @itemPrepare, specialReminder = @specialReminder, CGPrecautions = @CGPrecautions, YGCG = @YGCG, Conduct = @Conduct, CommonEnglish = @CommonEnglish where tid = 1"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@itemPrepare",hd.ItemPrepare), new SqlParameter("@specialReminder",hd.SpecialReminder), new SqlParameter("@CGPrecautions",hd.CGPrecautions), new SqlParameter("@YGCG",hd.YGCG), new SqlParameter("@Conduct",hd.Conduct), new SqlParameter("@CommonEnglish",hd.CommonEnglish), }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } List excuteSqlDa(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new opitinerarydata(), "opitinerarydata", sql, CommandType.Text, param); } opitinerarydata excuteTypeDa(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List hdList = excuteSqlDa(sql, param); opitinerarydata air = new opitinerarydata(); //判断集合是否为空 if (hdList == null || hdList.Count == 0) { return air; } //返回单个对象 return hdList[0]; } public opitinerarydata getDaFirstData(string Name) { return this.excuteTypeDa("select * from opitinerarydata where name = @name", new SqlParameter[] { new SqlParameter("@name",Name) }); } /// /// 增加手册data表 /// /// data对象 /// true为增加城市false增加国家 /// public bool Add(opitinerarydata opda,bool sel) { string sql = @"insert into opitinerarydata "; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@name",opda.Name), new SqlParameter("@Introduction",opda.Introduction), }; if (sel) { sql += "(name,Introduction,timeDifference,currExchangeRate,temperature)" + " values(@name,@Introduction ,@timeDifference ,@currExchangeRate,@temperature)"; var parameterList = parameter.ToList(); parameterList.Add(new SqlParameter { ParameterName = "@timeDifference", Value = opda.TimeDifference }); parameterList.Add(new SqlParameter { ParameterName = "@currExchangeRate", Value = opda.CurrExchangeRate }); parameterList.Add(new SqlParameter { ParameterName = "@temperature", Value = opda.Temperature }); parameter = parameterList.ToArray(); } else { sql += "(name,Introduction)" + " values(@name,@Introduction)"; } if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } public bool EditDa(opitinerarydata hd) { string sql = @"update opitinerarydata set Introduction = @Introduction , timeDifference =@timeDifference , currExchangeRate =@currExchangeRate , temperature =@temperature where name =@name"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Introduction",hd.Introduction), new SqlParameter("@timeDifference",hd.TimeDifference), new SqlParameter("@currExchangeRate",hd.CurrExchangeRate), new SqlParameter("@temperature",hd.Temperature), new SqlParameter("@name",hd.Name), }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } } }