using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Models;
using System.Data.SqlClient;
using System.Data;
namespace DAL
{
///
/// 车/导游地接预订详细数据访问类
///
public class CarTouristGuideGroundReservationsContentService
{
///
/// 查询所有
///
/// sql语句
/// 可变参数数组
/// 返回集合
List excuteSql(string sql, params SqlParameter[] param)
{
return ServiceBase.excuteSql(new CarTouristGuideGroundReservationsContent(), "CarTouristGuideGroundReservationsContent", sql, CommandType.Text, param);
}
///
/// 获取单个对象
///
/// sql语句
/// 可变参数数组
/// 返回空或者单个对象
CarTouristGuideGroundReservationsContent excuteType(string sql, params SqlParameter[] param)
{
//查询结果放入对象集合
List cList = excuteSql(sql, param);
//判断集合是否为空
if (cList == null || cList.Count == 0)
//返回null
return null;
//返回单个对象
return cList[0];
}
///
/// 根据编号查询对象信息
///
/// 对象编号
/// 返回空或者单个对象信息
public CarTouristGuideGroundReservationsContent GetCarTouristGuideGroundReservationsContentByID(int id)
{
//调用获取单个对象的方法
return excuteType("select * from CarTouristGuideGroundReservationsContent where Id = @id", new SqlParameter("@id", id));
}
public List GetByDiid(int Diid)
{
//调用获取单个对象的方法
return excuteSql("select * from CarTouristGuideGroundReservationsContent where Diid = @Diid", new SqlParameter("@Diid", Diid));
}
///
/// 查询所有
///
///
///
public List GetAll(int CTGGRId)
{
return excuteSql("select * from CarTouristGuideGroundReservationsContent where isdel=0 and CTGGRId = @CTGGRId", new SqlParameter("@CTGGRId", CTGGRId));
}
///
/// 增加
///
///
public bool AddCarTouristGuideGroundReservationsContent(List 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;
}
}
///
/// 删除用户对应页面权限
///
///
///
public bool DelCarTouristGuideGroundReservationsContent(int CTGGRId)
{
if (SqlHelper.ExecuteNonQuery("delete CarTouristGuideGroundReservationsContent where CTGGRId =@CTGGRId", CommandType.Text, new SqlParameter("@CTGGRId", CTGGRId)) > 0)
return true;
return false;
}
///
/// 删除用户对应页面权限
///
///
///
///
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;
}
///
/// 删除用户对应页面权限
///
///
///
///
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;
}
}
}