123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Models;
- using System.Data.SqlClient;
- using System.Data;
- namespace DAL
- {
- /// <summary>
- /// 车/导游地接预订详细数据访问类
- /// </summary>
- public class CarTouristGuideGroundReservationsContentService
- {
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回集合</returns>
- List<CarTouristGuideGroundReservationsContent> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<CarTouristGuideGroundReservationsContent>.excuteSql(new CarTouristGuideGroundReservationsContent(), "CarTouristGuideGroundReservationsContent", sql, CommandType.Text, param);
- }
- /// <summary>
- /// 获取单个对象
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回空或者单个对象</returns>
- CarTouristGuideGroundReservationsContent excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<CarTouristGuideGroundReservationsContent> cList = excuteSql(sql, param);
- //判断集合是否为空
- if (cList == null || cList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return cList[0];
- }
- /// <summary>
- /// 根据编号查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public CarTouristGuideGroundReservationsContent GetCarTouristGuideGroundReservationsContentByID(int id)
- {
- //调用获取单个对象的方法
- return excuteType("select * from CarTouristGuideGroundReservationsContent where Id = @id", new SqlParameter("@id", id));
- }
- public List<CarTouristGuideGroundReservationsContent> GetByDiid(int Diid)
- {
- //调用获取单个对象的方法
- return excuteSql("select * from CarTouristGuideGroundReservationsContent where Diid = @Diid", new SqlParameter("@Diid", Diid));
- }
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="Stable"></param>
- /// <returns></returns>
- public List<CarTouristGuideGroundReservationsContent> GetAll(int CTGGRId)
- {
- return excuteSql("select * from CarTouristGuideGroundReservationsContent where isdel=0 and CTGGRId = @CTGGRId", new SqlParameter("@CTGGRId", CTGGRId));
- }
- /// <summary>
- /// 增加
- /// </summary>
- /// <param name="c"></param>
- public bool AddCarTouristGuideGroundReservationsContent(List<CarTouristGuideGroundReservationsContent> list)
- {
- SqlCommand cmd = SqlHelper.createCon().CreateCommand();
- cmd.Connection.Open();
- SqlTransaction trans = cmd.Connection.BeginTransaction();
- try
- {
- cmd.Transaction = trans;//将事务赋值给command就可以了
- foreach (CarTouristGuideGroundReservationsContent c in list)
- {
- cmd.CommandText = "insert into CarTouristGuideGroundReservationsContent values(" + c.DIId + "," + c.CTGGRId + "," + c.SId + "," + c.Price + "," + c.Currency + ",'" + c.PriceContent + "','" + c.Remark + "'," + c.Operators + ",'" + c.OperatorsDate + "'," + c.IsDel + ")";
- cmd.ExecuteNonQuery();
- }
- trans.Commit();
- cmd.Connection.Close();
- return true;
- }
- catch (Exception ex)
- {
- trans.Rollback();
- cmd.Connection.Close();
- return false;
- }
- }
- /// <summary>
- /// 删除用户对应页面权限
- /// </summary>
- /// <param name="CTGGRId"></param>
- /// <returns></returns>
- public bool DelCarTouristGuideGroundReservationsContent(int CTGGRId)
- {
- if (SqlHelper.ExecuteNonQuery("delete CarTouristGuideGroundReservationsContent where CTGGRId =@CTGGRId", CommandType.Text, new SqlParameter("@CTGGRId", CTGGRId)) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 删除用户对应页面权限
- /// </summary>
- /// <param name="sid"></param>
- /// <param name="STable"></param>
- /// <returns></returns>
- public bool DelCarTouristGuideGroundReservationsContentBySid(int sid, int STable)
- {
- if (SqlHelper.ExecuteNonQuery("delete CarTouristGuideGroundReservationsContent where Sid =@Sid and STable = @STable", CommandType.Text, new SqlParameter("@Sid", sid), new SqlParameter("@STable", STable)) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 删除用户对应页面权限
- /// </summary>
- /// <param name="sid"></param>
- /// <param name="STable"></param>
- /// <returns></returns>
- public bool DelCarTouristGuideGroundReservationsContentByUIdAndSIdAndSTable(int uid, int sid, int stable)
- {
- if (SqlHelper.ExecuteNonQuery("delete CarTouristGuideGroundReservationsContent where UId =@UId and SId = @SId and STable=@STable", CommandType.Text, new SqlParameter("@UId", uid), new SqlParameter("@SId", sid), new SqlParameter("@STable", stable)) > 0)
- return true;
- return false;
- }
- }
- }
|