123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- 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<opitineraryfixed> excuteSqlFi(string sql, params SqlParameter[] param)
- {
- return ServiceBase<opitineraryfixed>.excuteSql(new opitineraryfixed(), "opitineraryfixed", sql, CommandType.Text, param);
- }
- opitineraryfixed excuteTypeFi(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<opitineraryfixed> 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<opitinerarydata> excuteSqlDa(string sql, params SqlParameter[] param)
- {
- return ServiceBase<opitinerarydata>.excuteSql(new opitinerarydata(), "opitinerarydata", sql, CommandType.Text, param);
- }
- opitinerarydata excuteTypeDa(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<opitinerarydata> 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) });
- }
- /// <summary>
- /// 增加手册data表
- /// </summary>
- /// <param name="opda">data对象</param>
- /// <param name="sel">true为增加城市false增加国家</param>
- /// <returns></returns>
- 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;
- }
- }
- }
|