Beispiel #1
0
 private void btnsaveDB_Click(object sender, System.EventArgs e)
 {
     if (!this.DBparaCheck())
     {
         return;
     }
     if (!this.checkBoxUseMySQL.Checked)
     {
         DialogResult dialogResult = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.DB_ChangeCrm, new string[0]), MessageBoxButtons.OKCancel);
         if (dialogResult == DialogResult.Cancel)
         {
             return;
         }
         AccessDBUpdate.InitAccessDataDB();
         DBUtil.ChangeDBSetting2Access();
         base.DialogResult = DialogResult.OK;
         return;
     }
     else
     {
         string   text  = this.tbDBIP.Text;
         int      num   = System.Convert.ToInt32(this.tbDBPort.Text);
         string   text2 = this.tbDBUsrnm.Text;
         string   text3 = this.tbDBPsw.Text;
         string[] param = new string[]
         {
             text,
             this.tbDBPort.Text,
             text2,
             text3
         };
         progressPopup progressPopup = new progressPopup("Information", 1, EcoLanguage.getMsg(LangRes.PopProgressMsg_Checkdbconnect, new string[0]), null, new progressPopup.ProcessInThread(this.dbCheckParameter), param, 0);
         progressPopup.ShowDialog();
         object return_V = progressPopup.Return_V;
         int?   num2     = return_V as int?;
         if (!num2.HasValue)
         {
             num2 = new int?(DebugCenter.ST_Unknown);
         }
         if (num2 == DebugCenter.ST_Success)
         {
             DBUtil.ChangeDBSetting2MySQL(text, num, text2, text3, false);
             base.DialogResult = DialogResult.OK;
             return;
         }
         if (num2 == DebugCenter.ST_MYSQLCONNECT_ERROR || num2 == DebugCenter.ST_MYSQLAUTH_ERROR || num2 == DebugCenter.ST_Unknown)
         {
             EcoMessageBox.ShowError(this, EcoLanguage.getMsg(LangRes.DB_Connectfail, new string[0]));
             return;
         }
         DialogResult dialogResult2 = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.DBinitcrm_Master, new string[0]), MessageBoxButtons.OKCancel);
         if (dialogResult2 == DialogResult.Cancel)
         {
             return;
         }
         string dbname = "";
         int    num3   = DBMaintain.InitMySQLDatabase4Master(text, num, text2, text3, ref dbname);
         if (num3 > 0)
         {
             num3 = DBUtil.ChangeDBSetting2MySQL(dbname, text, num, text2, text3);
             if (num3 == 1)
             {
                 num3 = DebugCenter.ST_Success;
             }
         }
         if (num3 == DebugCenter.ST_Success)
         {
             base.DialogResult = DialogResult.OK;
             return;
         }
         EcoMessageBox.ShowError(this, EcoLanguage.getMsg(LangRes.OPfail, new string[0]));
         return;
     }
 }