123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Models;
- using System.Data;
- using System.Data.SqlClient;
- using System.Security.Cryptography;
- using System.Web.UI.WebControls;
- namespace DAL
- {
- /// <summary>
- /// 签证数据访问类
- /// </summary>
- public class VisaService
- {
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回集合</returns>
- List<Visa> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<Visa>.excuteSql(new Visa(), "Visa", sql, CommandType.Text, param);
- }
- /// <summary>
- /// 获取单个对象
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回空或者单个对象</returns>
- Visa excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<Visa> vList = excuteSql(sql, param);
- //判断集合是否为空
- if (vList == null || vList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return vList[0];
- }
-
- /// <summary>
- /// 根据编号查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public Visa GetVisaByID(int id)
- {
- //调用获取单个对象的方法
- return excuteType("select * from Visa where Id = @id and isdel=0", new SqlParameter("@id", id));
- }
- /// <summary>
- /// 查询团组签证费用
- /// 20210916 贾文滔
- /// </summary>
- /// <param name="diid"></param>
- /// <returns></returns>
- public List<Visa> GetVisaByDIID(int diid)
- {
- //调用获取单个对象的方法
- return excuteSql("select * from Visa where DIId = @Diid and isdel=0", new SqlParameter("@Diid", diid));
- }
- /// <summary>
- /// 查询团组签证费用
- /// 20210916 贾文滔
- /// </summary>
- /// <param name="diid"></param>
- /// <returns></returns>
- public List<Visa> GetVisaByDIIDAndUserId(int diid,int UserId)
- {
- //调用获取单个对象的方法
- return excuteSql("select * from Visa where DIId = @Diid and Operator="+UserId+" and isdel=0", new SqlParameter("@Diid", diid));
- }
- /// <summary>
- /// 获取全部 - 分页
- /// </summary>
- /// <returns></returns>
- public List<Visa> GetVisa(int pageIndex, out int sumPage, out int totalRecord, string tourCode, string visaClient, string arrayUsersId)
- {
- string sqlwhere = "IsDel = 0 and DIId = '" + tourCode + "' and VisaClient like '%" + visaClient + "%' and Operator in (" + arrayUsersId + ")";
- return PageBase<Visa>.excutePageSql(new Visa(), "Visa", "Visa", "*", "id desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
- }
- /// <summary>
- /// 增加
- /// </summary>
- /// <returns></returns>
- public bool AddVisa(Visa v, out int id)
- {
- string sql = "insert into Visa values(@DIId,@VisaClient,@VisaPrice,@VisaCurrency,@IsThird,@VisaAttachment,@Remark,@Operator,@OperatorDate," +
- "@IsDel,@PassengerType,@VisaNumber,@VisaFreeNumber);SELECT @@IDENTITY";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@DIId",v.DIId),
- new SqlParameter("@VisaClient",v.VisaClient),
- new SqlParameter("@VisaPrice",v.VisaPrice),
- new SqlParameter("@VisaCurrency",v.VisaCurrency),
- new SqlParameter("@IsThird",v.IsThird),
- new SqlParameter("@VisaAttachment",v.VisaAttachment),
- new SqlParameter("@Remark",v.Remark),
- new SqlParameter("@Operator",v.Operators),
- new SqlParameter("@OperatorDate",v.OperatorsDate),
- new SqlParameter("@IsDel",v.IsDel),
- new SqlParameter("@PassengerType",v.PassengerType),
- new SqlParameter("@VisaNumber",v.VisaNumber),
- new SqlParameter("@VisaFreeNumber",v.VisaFreeNumber),
- };
- 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 EditVisa(Visa v)
- {
- string sql = "update Visa set DIId = @DIId,VisaClient = @VisaClient,VisaPrice = @VisaPrice,VisaCurrency = @VisaCurrency,"
- +"IsThird=@IsThird,VisaAttachment = @VisaAttachment,Remark = @Remark,"
- + "Operator = @Operator,OperatorDate = @OperatorDate,PassengerType=@PassengerType,VisaNumber=@VisaNumber,VisaFreeNumber=@VisaFreeNumber" +
- " where Id = @Id";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@DIId",v.DIId),
- new SqlParameter("@VisaClient",v.VisaClient),
- new SqlParameter("@VisaPrice",v.VisaPrice),
- new SqlParameter("@VisaCurrency",v.VisaCurrency),
- new SqlParameter("@IsThird",v.IsThird),
- new SqlParameter("@VisaAttachment",v.VisaAttachment),
- new SqlParameter("@Remark",v.Remark),
- new SqlParameter("@Operator",v.Operators),
- new SqlParameter("@OperatorDate",v.OperatorsDate),
- new SqlParameter("@Id",v.Id),
- new SqlParameter("@PassengerType",v.PassengerType),
- new SqlParameter("@VisaNumber",v.VisaNumber),
- new SqlParameter("@VisaFreeNumber",v.VisaFreeNumber),
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public bool DelVisa(int id)
- {
- if (SqlHelper.ExecuteNonQuery("update Visa set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// LiuChengYi 2014/5/9
- /// 用作微信平台上签证进图查询
- /// </summary>
- /// <param name="tourCode"></param>
- /// <returns></returns>
- public DataTable VisasProgress(string tourCode)
- {
- SqlParameter[] pars =
- {
- new SqlParameter("@tourCode",tourCode)
- };
- return SqlHelper.TransferProcedure("VisasProgress_Weixin", CommandType.StoredProcedure, pars);
- }
- }
- }
|