BEST /BaliEnterpriseSystems/BaliEnterpriseSystems/BestObjects/BestDatabase.cs

Language C# Lines 67
MD5 Hash d85fb7dfbb0b5d975f998cdd28226c7c
Repository https://github.com/sirivedula/BEST.git View Raw File
 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
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.OleDb;
using System.Reflection;
using System.ComponentModel;
using BaliEnterpriseSystems.BestObjects;

namespace BaliEnterpriseSystems.BestObjects
{
    public class BestDatabase
    {
        public string dbConString
        {
            get
            {
                return ConfigurationSettings.AppSettings["dbConString"];
            }
        }

        private OleDbConnection _dbCon;
        public OleDbConnection dbCon
        {
            get
            {
                if (_dbCon == null)
                {
                    OleDbConnectionStringBuilder consb = new OleDbConnectionStringBuilder(this.dbConString);
                    if (HttpContext.Current.Session["CurrentUser"] == null)
                    {
                        consb.Add("Application Name", "NoBestLogin");
                    }
                    else
                    {
                        consb.Add("Application Name", Utils.User.UserName);
                    }
                    _dbCon = new OleDbConnection(consb.ToString());
                }
                return _dbCon;
            }
        }

        private OleDbCommand _dbCmd;
        public OleDbCommand dbCmd
        {
            get
            {
                if (this.dbCon.State != ConnectionState.Open)
                {
                    this.dbCon.Open();
                }
                _dbCmd = new OleDbCommand();
                _dbCmd.Connection = this.dbCon;
                return _dbCmd;
            }
        }
    }
}
Back to Top