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 CarTouristGuideGroundReservationsService
{
///
/// 查询所有
///
/// sql语句
/// 可变参数数组
/// 返回集合
List excuteSql(string sql, params SqlParameter[] param)
{
return ServiceBase.excuteSql(new CarTouristGuideGroundReservations(), "CarTouristGuideGroundReservations", sql, CommandType.Text, param);
}
///
/// 获取单个对象
///
/// sql语句
/// 可变参数数组
/// 返回空或者单个对象
CarTouristGuideGroundReservations excuteType(string sql, params SqlParameter[] param)
{
//查询结果放入对象集合
List ctggrList = excuteSql(sql, param);
//判断集合是否为空
if (ctggrList == null || ctggrList.Count == 0)
//返回null
return null;
//返回单个对象
return ctggrList[0];
}
///
/// 根据编号查询对象信息
///
/// 对象编号
/// 返回空或者单个对象信息
public CarTouristGuideGroundReservations GetCarTouristGuideGroundReservationsByID(int id)
{
//调用获取单个对象的方法
return excuteType("select * from CarTouristGuideGroundReservations where Id = @id and isdel=0", new SqlParameter("@id", id));
}
///
/// 根据编号查询对象信息
///
/// 对象编号
/// 返回空或者单个对象信息
public CarTouristGuideGroundReservations GetCarTouristGuideGroundReservationsByArea(string area)
{
//调用获取单个对象的方法
return excuteType("select * from CarTouristGuideGroundReservations where Area = @area and isdel=0", new SqlParameter("@area", area));
}
///
/// 根据团号查询数据
///
/// 团号
///
public List GetCarTouristGuideGroundReservationsByDIID(int diid)
{
//调用获取单个对象的方法
return excuteSql("select * from CarTouristGuideGroundReservations where diid = @diid and isdel=0 order by ServiceStartTime", new SqlParameter("@diid", diid));
}
///
/// 获取全部 - 分页
///
///
public List GetCarTouristGuideGroundReservations(int pageIndex, out int sumPage, out int totalRecord, string tourCode, string arrayUsersId)
{
string sqlwhere = "IsDel = 0 and DIId = '" + tourCode + "' and Operator in (" + arrayUsersId + ")";
return PageBase.excutePageSql(new CarTouristGuideGroundReservations(), "CarTouristGuideGroundReservations", "CarTouristGuideGroundReservations", "*", "id desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
}
///
/// 增加
///
///
///
public bool AddCarTouristGuideGroundReservations(CarTouristGuideGroundReservations ctggr, out int id)
{
string sql = "insert into CarTouristGuideGroundReservations values(@DIId,@Area,@ServiceCompany,@ServiceGuide,@ServiceTel,@BusName,@BusDescription,@BusTel,@ServiceStartTime,@ServiceEndTime,@ServiceDescription,@ServiceQuotedPrice,@CId,@QuotedPriceExplanation,@Remark,@Operator,@OperatorDate,@IsDel,@OrbitalPrivateTransfer);SELECT @@IDENTITY";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@DIId",ctggr.DIId),
new SqlParameter("@Area",ctggr.Area),
new SqlParameter("@ServiceCompany",ctggr.ServiceCompany),
new SqlParameter("@ServiceGuide",ctggr.ServiceGuide),
new SqlParameter("@ServiceTel",ctggr.ServiceTel),
new SqlParameter("@BusName",ctggr.BusName),
new SqlParameter("@BusDescription",ctggr.BusDescription),
new SqlParameter("@BusTel",ctggr.BusTel),
new SqlParameter("@ServiceStartTime",ctggr.ServiceStartTime),
new SqlParameter("@ServiceEndTime",ctggr.ServiceEndTime),
new SqlParameter("@ServiceDescription",ctggr.ServiceDescription),
new SqlParameter("@ServiceQuotedPrice",ctggr.ServiceQuotedPrice),
new SqlParameter("@CId",ctggr.CId),
new SqlParameter("@QuotedPriceExplanation",ctggr.QuotedPriceExplanation),
new SqlParameter("@Remark",ctggr.Remark),
new SqlParameter("@Operator",ctggr.Operators),
new SqlParameter("@OperatorDate",ctggr.OperatorsDate),
new SqlParameter("@IsDel",ctggr.IsDel),
new SqlParameter("@OrbitalPrivateTransfer",ctggr.OrbitalPrivateTransfer)
};
int obj = Convert.ToInt32(SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter));
if (obj > 0)
{
id = obj;
return true;
}
id = 0;
return false;
}
///
/// 编辑
///
///
public bool EditCarTouristGuideGroundReservations(CarTouristGuideGroundReservations ctggr)
{
string sql = "update CarTouristGuideGroundReservations set DIId = @DIId,Area = @Area,ServiceCompany = @ServiceCompany,ServiceGuide = @ServiceGuide,ServiceTel = @ServiceTel,BusName = @BusName,BusDescription = @BusDescription,BusTel = @BusTel,ServiceStartTime = @ServiceStartTime,ServiceEndTime = @ServiceEndTime,ServiceDescription = @ServiceDescription,ServiceQuotedPrice = @ServiceQuotedPrice,CId = @CId,QuotedPriceExplanation = @QuotedPriceExplanation,Remark = @Remark,Operator = @Operator,OperatorDate = @OperatorDate,OrbitalPrivateTransfer = @OrbitalPrivateTransfer where Id = @Id";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@DIId",ctggr.DIId),
new SqlParameter("@Area",ctggr.Area),
new SqlParameter("@ServiceCompany",ctggr.ServiceCompany),
new SqlParameter("@ServiceGuide",ctggr.ServiceGuide),
new SqlParameter("@ServiceTel",ctggr.ServiceTel),
new SqlParameter("@BusName",ctggr.BusName),
new SqlParameter("@BusDescription",ctggr.BusDescription),
new SqlParameter("@BusTel",ctggr.BusTel),
new SqlParameter("@ServiceStartTime",ctggr.ServiceStartTime),
new SqlParameter("@ServiceEndTime",ctggr.ServiceEndTime),
new SqlParameter("@ServiceDescription",ctggr.ServiceDescription),
new SqlParameter("@ServiceQuotedPrice",ctggr.ServiceQuotedPrice),
new SqlParameter("@CId",ctggr.CId),
new SqlParameter("@QuotedPriceExplanation",ctggr.QuotedPriceExplanation),
new SqlParameter("@Remark",ctggr.Remark),
new SqlParameter("@Operator",ctggr.Operators),
new SqlParameter("@OperatorDate",ctggr.OperatorsDate),
new SqlParameter("@OrbitalPrivateTransfer",ctggr.OrbitalPrivateTransfer),
new SqlParameter("@Id",ctggr.Id)
};
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
return true;
return false;
}
///
/// 编辑 - 金额和币种
///
///
public bool EditCarTouristGuideGroundReservationsByPrice(CarTouristGuideGroundReservations ctggr)
{
string sql = "update CarTouristGuideGroundReservations set ServiceQuotedPrice = @ServiceQuotedPrice,CId = @CId,Operator = @Operator,OperatorDate = @OperatorDate where Id = @Id";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@ServiceQuotedPrice",ctggr.ServiceQuotedPrice),
new SqlParameter("@CId",ctggr.CId),
new SqlParameter("@Operator",ctggr.Operators),
new SqlParameter("@OperatorDate",ctggr.OperatorsDate),
new SqlParameter("@Id",ctggr.Id)
};
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
return true;
return false;
}
///
/// 删除
///
///
///
public bool DelCarTouristGuideGroundReservations(int id)
{
if (SqlHelper.ExecuteNonQuery("update CarTouristGuideGroundReservations set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
return true;
return false;
}
}
}