コード例 #1
0
ファイル: frmMain.cs プロジェクト: SirNO0K/OMC2015
        public void GetConnectionString()
        {
            try
            {
                #region Oldmoon

                string _ConnectionOldmoon = ConfigurationManager.ConnectionStrings["OLDMOON"].ConnectionString;
                Configuration _ConfigOldmoon = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                EntityConnectionStringBuilder _OldmoonEF = new EntityConnectionStringBuilder(_ConnectionOldmoon);
                SqlConnectionStringBuilder _OldmoonSQL = new SqlConnectionStringBuilder(_OldmoonEF.ProviderConnectionString);

                Model.SysCore.Instance.SystemServer = _OldmoonSQL.DataSource;
                Model.SysCore.Instance.SystemDatabase = _OldmoonSQL.InitialCatalog;
                Model.SysCore.Instance.SystemUsername = _OldmoonSQL.UserID;
                Model.SysCore.Instance.SystemPassword = _OldmoonSQL.Password;

                #endregion

                #region ERP

                string _ConnectionERP = ConfigurationManager.ConnectionStrings["ERP"].ConnectionString;
                Configuration _ConfigERP = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                EntityConnectionStringBuilder _ErpEF = new EntityConnectionStringBuilder(_ConnectionERP);
                SqlConnectionStringBuilder _ErpSQL = new SqlConnectionStringBuilder(_ErpEF.ProviderConnectionString);

                Model.SysCore.Instance.AccountServer = _ErpSQL.DataSource;
                Model.SysCore.Instance.AccountDatabase = _ErpSQL.InitialCatalog;
                Model.SysCore.Instance.AccountUsername = _ErpSQL.UserID;
                Model.SysCore.Instance.AccountPassword = _ErpSQL.Password;

                #endregion
            }
            catch (Exception Ex)
            {

                using (View.Tools.frmErrorMessage Message = new frmErrorMessage())
                {
                    Message.Header = "GetConnection Error...";
                    Message.TextError = Ex.ToString();
                    Message.TopMost = true;
                    Message.ShowDialog();
                }
            }
        }
コード例 #2
0
ファイル: frmConfig.cs プロジェクト: SirNO0K/OMC2015
        private void btnSave_Click(object sender, EventArgs e)
        {
            ctlLoading.Start();
            try
            {
                _Controller.UpdateConfig();
                ctlLoading.Abort();
                MessageBox.Show("Update Configuration Success");
                Application.Restart();
            }
            catch (Exception Ex)
            {
                using (Tools.frmErrorMessage Message = new frmErrorMessage())
                {
                    ctlLoading.Abort();
                    Message.Text = "Update Configuration Fail...";
                    Message.TextError = Ex.ToString();
                    Message.ShowDialog();
                }
            }

        }