Пример #1
0
        private void buttonSaveConfig_Click(object sender, EventArgs e)
        {
            DBConnectionType dbConnType = new DBConnectionType();

            if (rbAccess.Checked)
            {
                dbConnType.dbType = DatabaseType.Access;

                string accessFilePath = this.textBoxAccessFilePath.Text.Trim();
                if (false == File.Exists(accessFilePath))
                {
                    MessageBox.Show("Access文件不存在,请重新指定文件路径。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                dbConnType.AccessFilePath = accessFilePath;
            }
            else
            {
                dbConnType.dbType = DatabaseType.SQLServer;

                string address  = this.textBoxSQLServerDBAddr.Text.Trim();
                string dbName   = this.textBoxSQLServerDBName.Text.Trim();
                string userId   = this.textBoxSQLServerUserId.Text.Trim();
                string password = textBoxSQLServerPassword.Text.Trim();

                dbConnType.SQLServerAddress  = address;
                dbConnType.SQLServerDBName   = dbName;
                dbConnType.SQLServerUsername = userId;
                dbConnType.SQLServerPassword = password;
            }

            dbConnType.isUsed = true;

            bool result = DBConnectionUtil.SaveDBConnectionType(dbConnType);

            if (result)
            {
                MessageBox.Show("更新数据库配置成功!\r\n你需要重新启动系统以使改动生效!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("更新数据库配置失败,请检查输入!", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            // Maximize the main window.
            this.WindowState = FormWindowState.Maximized;

            // Adjust the tab page size to accomodate to the screen.
            // [ZHI_TODO]
            Size frmSize = this.Size;

            // Set the default startDate/endDate.
            TimeSpan timeSpan     = new TimeSpan(5, 0, 0, 0);
            DateTime prevThreeDay = DateTime.Now.Subtract(timeSpan);

            this.dateTimePickerStartTime.Value = prevThreeDay;

            // Initialize all account info.
            AccountUtil.ReloadAllAccounts();

            // Setup all the datagridview columns:
            //  - Active listing
            //  - Order
            //  - Message
            //  - Postsale
            SetupTabControlDataGridViewColumns();

            // Check whether the Access file is existed.
            if (DBConnectionUtil.CheckAccessFileExistence() == false)
            {
                MessageBox.Show("数据库文件路径没有配置\r\n系统设置->数据库设置", "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //
            // Load all the data.
            //  - Order data.
            //  - Active listing data.
            //  - Message data.
            //  - Postsale data.
            //  This is a bit slow, however simple.
            LoadData();
        }
Пример #3
0
        private void FrmDBConnection_Load(object sender, EventArgs e)
        {
            DBConnectionType dbConnType       = DBConnectionUtil.GetDBConnectionType(true);
            DBConnectionType unusedDbConnType = DBConnectionUtil.GetDBConnectionType(false);

            if (dbConnType.dbType == DatabaseType.Access)
            {
                this.panelAccess.Visible    = true;
                this.panelSQLServer.Visible = false;

                this.rbAccess.Checked    = true;
                this.rbSqlServer.Checked = false;

                this.textBoxAccessFilePath.Text = dbConnType.AccessFilePath;

                this.textBoxSQLServerDBAddr.Text   = unusedDbConnType.SQLServerAddress;
                this.textBoxSQLServerDBName.Text   = unusedDbConnType.SQLServerDBName;
                this.textBoxSQLServerUserId.Text   = unusedDbConnType.SQLServerUsername;
                this.textBoxSQLServerPassword.Text = unusedDbConnType.SQLServerPassword;
            }
            else
            {
                this.panelAccess.Visible    = false;
                this.panelSQLServer.Visible = true;
                this.panelSQLServer.Top     = this.panelAccess.Top;

                this.rbAccess.Checked    = false;
                this.rbSqlServer.Checked = true;

                this.textBoxSQLServerDBAddr.Text   = dbConnType.SQLServerAddress;
                this.textBoxSQLServerDBName.Text   = dbConnType.SQLServerDBName;
                this.textBoxSQLServerUserId.Text   = dbConnType.SQLServerUsername;
                this.textBoxSQLServerPassword.Text = dbConnType.SQLServerPassword;

                this.textBoxAccessFilePath.Text = unusedDbConnType.AccessFilePath;
            }
        }