wzp
2023-03-02 adee7a71ba7ab1b63cab63381dfe1846437853d6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using Common;
using Model;
using Oracle.ManagedDataAccess.Client;
 
namespace Dao
{
    /// <summary>
    /// 客户产品操作类
    /// </summary>
    public class GwClientProductDao
    {
        private static GwClientProductDao _instance;
        public static GwClientProductDao Instance
        {
            get {
                if (_instance == null)
                {
                    _instance = new GwClientProductDao();
                }
                return _instance;
            }
        }
 
        /// <summary>
        /// 添加账户默认产品记录
        /// </summary>
        /// <param name="gcp"></param>
        /// <returns></returns>
        public bool Add(GwClientProduct gcp)
        {
            return OracleHelper.ExecuteSql("insert into GW_Client_Product(id,client_id,product_id,sp_id,ACTIVATE_STATUS) values(:id,:client_id,:product_id,:sp_id,:ACTIVATE_STATUS)",
                OracleHelper.Connection, new OracleParameter(":id", (object)gcp.Id), new OracleParameter(":client_id", (object)gcp.ClientId), 
                new OracleParameter(":product_id", gcp.ProductId),new OracleParameter(":sp_id",gcp.SpId),
                new OracleParameter(":ACTIVATE_STATUS", gcp.ActivateStatus)) > 0;
        }
 
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="gcp"></param>
        /// <returns></returns>
        public bool Update(GwClientProduct gcp)
        {
            return OracleHelper.ExecuteSql("update GW_Client_Product set product_id=:product_id,client_id=:client_id where sp_id=:sp_id ", 
                OracleHelper.Connection, new OracleParameter(":product_id", gcp.ProductId), new OracleParameter(":sp_id", gcp.SpId),
                new OracleParameter(":client_id",gcp.ClientId)
                ) > 0;
        }
 
        /// <summary>
        /// 查找账号是否存在
        /// </summary>
        /// <param name="spid"></param>
        /// <returns></returns>
        public bool FindBySp(string spid)
        {
            using (OracleDataReader oracleDataReader = OracleHelper.ExecuteReader(string.Format("select * from GW_Client_Product where SP_ID=:SP_ID"), OracleHelper.Connection, new OracleParameter(":SP_ID", spid)))
            {
                if (oracleDataReader.Read())
                    return true;
            }
            return false;
        }
        
 
 
    }
}