public IDB DoConfig()
        {
            IDB Config = null;

            if (String.IsNullOrEmpty(txt_Path.Text))
            {
                SetError(txt_Path, "文件路径不能为空");
                return(Config);
            }

            DB_SQLite tmp = new DB_SQLite()
            {
                DataSource = txt_Path.Text,
                password   = txt_Pwd.Text
            };

            try
            {
                var fac = System.Data.Common.DbProviderFactories.GetFactory(tmp.ProviderName);

                using (var conn = fac.CreateConnection())
                {
                    conn.ConnectionString = tmp.GetConnectionStr();
                    conn.Open();
                    conn.Close();
                    Config = tmp;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            return(Config);
        }
Exemple #2
0
        public LogSQL()
        {
            DateTime varD         = DateTime.Today;
            string   varDBLogFile = GlobalVar.varPathLog + varD.ToString("yyyyMM") + @"\Log_" + GlobalVar.varIdWorkPlace.ToString() + "_" + varD.ToString("yyyyMMdd") + ".db";

            if (varDBLogFile != null)
            {
                if (!File.Exists(varDBLogFile))
                {
                    //Створюємо щоденну табличку з запитами
                    this.varDB = new DB_SQLite(varDBLogFile);
                    this.varDB.Open();
                    this.varDB.ExecuteNonQuery(varSqlCreatevarDB);
                    this.varDB.Close();
                }
                this.varDB = new DB_SQLite(varDBLogFile);
                this.varDB.Open();
                this.isWriteLogQvery = true;
            }
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parCallWriteLogSQL"></param>
        public WDB_SQLite(CallWriteLogSQL parCallWriteLogSQL = null) : base(parCallWriteLogSQL)
        {
            this.varVersion = "SQLite.0.0.1";

            this.ReadSQL(GlobalVar.varPathIni + @"SQLite.sql");
            this.InitSQL();
            DateTime varD           = DateTime.Today;
            string   varReceiptFile = GlobalVar.varPathDB + varD.ToString("yyyyMM") + @"\Rc_" + GlobalVar.varIdWorkPlace.ToString() + "_" + varD.ToString("yyyyMMdd") + ".db";

            if (!File.Exists(varReceiptFile))
            {
                //Створюємо щоденну табличку з чеками.
                this.db = new DB_SQLite(varReceiptFile);
                this.db.Open();
                this.db.ExecuteNonQuery(varSqlCreateReceiptTable);
                this.db.Close();
            }

            this.db = new DB_SQLite(GlobalVar.varPathDB + @"MID.db", "", this.varCallWriteLogSQL);
            this.db.Open();
            //this.db.ExecuteNonQuery("ATTACH ':memory:' AS m");
            this.db.ExecuteNonQuery(this.varSqlCreateT);
            this.db.ExecuteNonQuery("ATTACH '" + varReceiptFile + "' AS rc");
        }