Пример #1
0
 public void InitDbConfig()
 {
     DataCache.Instance.OpenMySqlDb = false;
     DataCache.Instance.MySqlConnection = string.Empty;
     string dbType = GetConfigValue(Constants.Db_Config, Constants.Db_Type);
     if (dbType == Constants.DbType_MySql)
     {
         string dbUrl = GetConfigValue(Constants.Db_Config, Constants.Db_Url);
         string dbName = GetConfigValue(Constants.Db_Config, Constants.Db_Name);
         string dbUser = GetConfigValue(Constants.Db_Config, Constants.Db_User);
         string dbPass = GetConfigValue(Constants.Db_Config, Constants.Db_Pass);
         string connection_str = "server=" + dbUrl + ";uid=" + dbUser + ";pwd=" + dbPass
         + ";database=" + dbName + ";Charset=utf8;Allow Zero Datetime=true";
         MysqlDBHelper dbHelper = new MysqlDBHelper(connection_str);
         bool Success = dbHelper.ConnectionTest();
         if (Success)
         {
             DataCache.Instance.MySqlConnection = connection_str;
             DataCache.Instance.OpenMySqlDb = true;
         }
         else
         {
             MessageBox.Show("\r\n不能正常连接到指定的MySql数据库,请检查! \r\n\r\n      系统将进入本地数据库模式。", "错误提示");
         }
     }
 }
Пример #2
0
 private DAOFactory()
 {
     if (SQLiteDHelper == null)
     {
         string DataBasePath = GetUserDataFolder() + Path.DirectorySeparatorChar + Constants.DB_FILE;
         if (!File.Exists(DataBasePath))
         {
             SQLiteConnection.CreateFile(DataBasePath);
         }
         SQLiteDHelper = new SQLiteDBHelper(DataBasePath);
     }
     if (!string.IsNullOrEmpty(DataCache.Instance.MySqlConnection) && DataCache.Instance.OpenMySqlDb)
     {
         MySqlDbHelper = new MysqlDBHelper(DataCache.Instance.MySqlConnection);
     }
 }
Пример #3
0
 public LoginUserDaoMysql(MysqlDBHelper dbHelper)
 {
     this.dbHelper = dbHelper;
     CreateTable();
     UpdateTable();
 }
Пример #4
0
 public FinanceDaoMysql(MysqlDBHelper dbHelper)
 {
     this.dbHelper = dbHelper;
     CreateTable();
 }
Пример #5
0
 public OrderDaoMysql(MysqlDBHelper dbHelper)
 {
     this.dbHelper = dbHelper;
     CreateTable();
 }
Пример #6
0
 public ProductDaoMysql(MysqlDBHelper dbHelper)
 {
     this.dbHelper = dbHelper;
     CreateTable();
 }
Пример #7
0
 private bool ValidateConnection()
 {
     string server = this.Server.Text.Trim();
     string database = this.Database.Text.Trim();
     string username = this.Username.Text.Trim();
     string password = this.Password.Text.Trim();
     string connection_str = "server=" + server + ";uid=" + username + ";pwd=" + password
         + ";database=" + database + ";Charset=utf8;Allow Zero Datetime=true";
     MysqlDBHelper dbHelper = new MysqlDBHelper(connection_str);
     bool TestResult = dbHelper.ConnectionTest();
     return TestResult;
 }