123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Models;
- using System.Data;
- using System.Data.SqlClient;
- namespace DAL
- {
- /// <summary>
- /// 团组客户保险数据访问类
- /// </summary>
- public class GroupsCustomersService
- {
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回集合</returns>
- List<GroupsCustomers> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<GroupsCustomers>.excuteSql(new GroupsCustomers(), "GroupsCustomers", sql, CommandType.Text, param);
- }
- /// <summary>
- /// 获取单个对象
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回空或者单个对象</returns>
- GroupsCustomers excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<GroupsCustomers> gcList = excuteSql(sql, param);
- //判断集合是否为空
- if (gcList == null || gcList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return gcList[0];
- }
- /// <summary>
- /// 根据编号查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public GroupsCustomers GetGroupsCustomersByID(int id)
- {
- //调用获取单个对象的方法
- return excuteType("select * from GroupsCustomers where Id = @id and isdel=0", new SqlParameter("@id", id));
- }
- /// <summary>
- /// 获取全部 - 分页
- /// </summary>
- /// <returns></returns>
- public List<GroupsCustomers> GetGroupsCustomers(int pageIndex, out int sumPage, out int totalRecord, string tourCode, string clientName)
- {
- string sqlwhere = "IsDel = 0 and DIId = '" + tourCode + "' and ClientName like '%" + clientName + "%'";
- return PageBase<GroupsCustomers>.excutePageSql(new GroupsCustomers(), "GroupsCustomers", "GroupsCustomers", "*", "id desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
- }
- /// <summary>
- /// 增加
- /// </summary>
- /// <returns></returns>
- public bool AddGroupsCustomers(GroupsCustomers v, out int id)
- {
- string sql = "insert into GroupsCustomers values(@DIId,@ClientName,@InsuranceCosts,@Currency,@Attachment,@Remark,@Operator,@OperatorDate,@IsDel,@Iid);SELECT @@IDENTITY";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@DIId",v.DIId),
- new SqlParameter("@ClientName",v.ClientName),
- new SqlParameter("@InsuranceCosts",v.InsuranceCosts),
- new SqlParameter("@Currency",v.Currency),
- new SqlParameter("@Attachment",v.Attachment),
- new SqlParameter("@Remark",v.Remark),
- new SqlParameter("@Operator",v.Operators),
- new SqlParameter("@OperatorDate",v.OperatorsDate),
- new SqlParameter("@IsDel",v.IsDel),
- new SqlParameter("@Iid",v.Iid)
- };
- int obj = Convert.ToInt32(SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter));
- if (obj > 0)
- {
- id = obj;
- return true;
- }
- id = 0;
- return false;
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <returns></returns>
- public bool EditGroupsCustomers(GroupsCustomers v)
- {
- string sql = "update GroupsCustomers set DIId = @DIId,ClientName = @ClientName,InsuranceCosts = @InsuranceCosts,Currency = @Currency,Attachment = @Attachment,Remark = @Remark,Operator = @Operator,OperatorDate = @OperatorDate,Iid =@Iid where Id = @Id";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@DIId",v.DIId),
- new SqlParameter("@ClientName",v.ClientName),
- new SqlParameter("@InsuranceCosts",v.InsuranceCosts),
- new SqlParameter("@Currency",v.Currency),
- new SqlParameter("@Attachment",v.Attachment),
- new SqlParameter("@Remark",v.Remark),
- new SqlParameter("@Operator",v.Operators),
- new SqlParameter("@OperatorDate",v.OperatorsDate),
- new SqlParameter("@Iid",v.Iid),
- new SqlParameter("@Id",v.Id)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public bool DelGroupsCustomers(int id)
- {
- if (SqlHelper.ExecuteNonQuery("update GroupsCustomers set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- public double GetByIid(int Iid)
- {
- string sql = "select sum(InsuranceCosts) from GroupsCustomers where Iid = " + Iid + "";
- object obj = SqlHelper.ExecuteScalar(sql, CommandType.Text);
- if (obj != null)
- {
- if (!string.IsNullOrEmpty(obj.ToString()))
- {
- double value = (double)obj;
- return value;
- }
- else
- return 0;
- }
- else
- return 0;
- }
- /// <summary>
- /// 保险费用 - 分页
- /// </summary>
- /// <returns></returns>
- public List<GroupsCustomers> GetGroupsCustomersByDid(int pageIndex, out int sumPage, out int totalRecord, string tourCode)
- {
- string sqlwhere = "IsDel = 0 and Iid = '" + tourCode + "'";
- return PageBase<GroupsCustomers>.excutePageSql(new GroupsCustomers(), "GroupsCustomers", "GroupsCustomers", "*", "id desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
- }
- }
- }
|