コード例 #1
0
        private void BtnBackup_Click(object sender, EventArgs e)
        {
            DialogResult Ret = MessageBoxEx.Show(this, "確定要上傳本地端[車型代號]及[操作員代號]至伺服器??", "訊息", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (Ret != DialogResult.Yes)
            {
                return;
            }

            this.Cursor = Cursors.AppStarting;

            string       Msg     = string.Empty;
            DbCheckState DbState = MyNetworkPlacesDbTest(out Msg);

            switch (DbState)
            {
            case DbCheckState.eDB_FOUND:
                //查遠端資料庫存在,更新指定資料表;//
                DaoErrMsg Err = DaoSQL.Instance.UploadLocalDatabase(tbPathDb.Text);
                if (Err.isError)
                {
                    MessageBoxEx.Show(this, Err.ErrorMsg, "訊息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBoxEx.Show(this, "[車型代號]及[操作員代號]資訊已上傳成功", "訊息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                break;

            case DbCheckState.eDB_NOT_FOUND:
                //查遠端資料庫不存在,直接上傳本地端的DB;//
                DaoSQL.Instance.CloseDatabase();
                string DestPath = Path.GetDirectoryName(tbPathDb.Text);
                string FileName = Path.GetFileName(tbPathDb.Text);

                if (DestPath == null)
                {
                    DestPath = tbPathDb.Text;
                    FileName = DaoConfigFile.Instance.m_FileDatabase;
                }
                else if (FileName == null || FileName.Length == 0 || Path.GetExtension(FileName) != "mdb")
                {
                    FileName = DaoConfigFile.Instance.m_FileDatabase;
                }

                NetTranslate.Transport(DaoConfigFile.Instance.FileDatabase, DestPath, FileName);
                MessageBoxEx.Show(this, "[車型代號]及[操作員代號]資訊已上傳成功", "訊息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DaoSQL.Instance.OpenDatabase();
                break;
            }

            this.Cursor = Cursors.Default;
        }
コード例 #2
0
        private void BtnUpdate_Click(object sender, EventArgs e)
        {
            DialogResult Ret = MessageBoxEx.Show(this, "確定要更新本地端[車型代號]及[操作員代號]資訊??", "訊息", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (Ret != DialogResult.Yes)
            {
                return;
            }

            this.Cursor = Cursors.AppStarting;

            string       Msg     = string.Empty;
            DbCheckState DbState = MyNetworkPlacesDbTest(out Msg);

            switch (DbState)
            {
            case DbCheckState.eDB_FOUND:
                DaoErrMsg Err = DaoSQL.Instance.UpdateLocalDatabase(tbPathDb.Text);

                if (Err.isError)
                {
                    MessageBoxEx.Show(this, Err.ErrorMsg, "訊息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBoxEx.Show(this, "[車型代號]及[操作員代號]已更新", "訊息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                break;

            case DbCheckState.eDB_NOT_FOUND:
            case DbCheckState.eDB_PATH_ERROR:
                MessageBoxEx.Show(this, string.Format("更新失敗!\r\n錯誤資訊:{0}", Msg), "訊息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                break;

            case DbCheckState.eDB_PATH_FIELD_EMPTY:
                break;
            }

            this.Cursor = Cursors.Default;
        }