Exemple #1
0
        /// <summary>
        /// 上傳本地資料庫資料至Server端資料庫,主要上傳[作業員]及[車型資料]這兩個表
        /// </summary>
        /// <param name="ServerDbPath"></param>
        /// <returns></returns>
        internal DaoErrMsg UploadLocalDatabase(string ServerDbPath)
        {
            DaoErrMsg Err = new DaoErrMsg();

            DaoDbCommon ServerSQL = CreateDbCom(ServerDbPath);

            Err = ServerSQL.Connect();

            if (Err.isError)
            {
                System.Diagnostics.Debug.WriteLine(Err.ErrorMsg);
                Logger.Info(Err.ErrorMsg);
                ServerSQL = null;
                return(Err);
            }

            //將本地資料庫的[作業員]及[車型資料]更新至Server端;//
            string strSchema;

            //讀取本地端車型資料;//
            DataTable dtOp = GetDataTable(m_SQL, "SELECT * FROM 作業員");

            //更新至Server資料庫作業員表格;//
            ServerSQL.ExecuteNonQuery("DELETE * FROM 作業員");
            foreach (DataRow row in dtOp.Rows)
            {
                strSchema = string.Format("INSERT INTO 作業員(代碼, 作業員姓名, 密碼, 權限) VALUES( '{0}', '{1}', '{2}', '{3}')",
                                          row[0].ToString(),
                                          row[1].ToString(),
                                          row[2].ToString(),
                                          row[3].ToString());

                ServerSQL.ExecuteNonQuery(strSchema);
            }

            //讀取本地車型資料;//
            DataTable dtCar = GetDataTable(m_SQL, "SELECT * FROM 車型資料");

            //更新至Server資料庫車型資料表格;//
            ServerSQL.ExecuteNonQuery("DELETE * FROM 車型資料");
            foreach (DataRow row in dtCar.Rows)
            {
                strSchema = string.Format("INSERT INTO 車型資料(件號, 車型, 簡碼) VALUES( '{0}', '{1}', '{2}')",
                                          row[0].ToString(),
                                          row[1].ToString(),
                                          row[2].ToString());

                ServerSQL.ExecuteNonQuery(strSchema);
            }

            ServerSQL.Close();
            ServerSQL = null;

            return(new DaoErrMsg());
        }
Exemple #2
0
        /// <summary>
        /// 關閉資料庫連接
        /// </summary>
        internal void CloseDatabase()
        {
            if (m_SQL == null)
            {
                return;
            }

            m_SQL.Close();

            m_SQL = null;

            DatabaseConnectedChange?.Invoke(false);
        }
Exemple #3
0
        /// <summary>
        /// 檢查Server端的Database是否可以連線
        /// </summary>
        /// <param name="Path"></param>
        /// <returns></returns>
        internal DaoErrMsg CheckServerDb(string Path)
        {
            DaoDbCommon ServerSQL = CreateDbCom(Path);

            DaoErrMsg Err = ServerSQL.Connect();

            if (Err.isError)
            {
                System.Diagnostics.Debug.WriteLine(Err.ErrorMsg);
                ServerSQL = null;
                return(Err);
            }

            //檢查欄位資訊並更新;//
            CheckDatabase(ServerSQL);

            ServerSQL.Close();
            ServerSQL = null;

            return(Err);
        }