コード例 #1
0
 private bool SaveDBConfig()
 {
     try
     {
         if (Config.Intance().CurrentCfgType == "1")
         {
             if (this.cmbDBType.SelectedIndex == 0)
             {
                 Config.Intance().EleSource.SetAttribute("DBType", "SQLSERVER");
                 Config.Intance().EleSource.SetAttribute("ServerName", this.txtServer.Text);
                 Config.Intance().EleSource.SetAttribute("DataBase", this.txtDataBase.Text);
                 Config.Intance().EleSource.SetAttribute("User", this.txtUser.Text);
                 Config.Intance().EleSource.SetAttribute("Password", SecretUtil.Secret(this.txtPassword.Text.Trim()));
             }
             else if (this.cmbDBType.SelectedIndex == 1)
             {
                 Config.Intance().EleSource.SetAttribute("DBType", "ACCESS");
                 Config.Intance().EleSource.SetAttribute("DBPath", this.txtDataBase.Text);
                 Config.Intance().EleSource.SetAttribute("Password", SecretUtil.Secret(this.txtPassword.Text.Trim()));
                 //Config.Intance().DestTable.SetAttribute("TableName", Config.Intance().CurrentDBName);
             }
             else if (this.cmbDBType.SelectedIndex == 2)
             {
                 Config.Intance().EleSource.SetAttribute("DBType", "FOXPRO");
                 Config.Intance().EleSource.SetAttribute("DBPath", this.txtDataBase.Text);
             }
             else if (this.cmbDBType.SelectedIndex == 3)
             {
                 Config.Intance().EleSource.SetAttribute("DBType", "ORACLE");
                 Config.Intance().EleSource.SetAttribute("ServerName", this.txtServer.Text);
                 Config.Intance().EleSource.SetAttribute("User", this.txtUser.Text);
                 Config.Intance().EleSource.SetAttribute("Password", SecretUtil.Secret(this.txtPassword.Text.Trim()));
             }
             else if (this.cmbDBType.SelectedIndex == 5)
             {
                 Config.Intance().EleSource.SetAttribute("DBType", "TXT");
                 Config.Intance().EleSource.SetAttribute("DBPath", this.txtDataBase.Text);
             }
             else if (this.cmbDBType.SelectedIndex == 4)
             {
                 Config.Intance().EleSource.SetAttribute("DBType", "EXCEL");
                 Config.Intance().EleSource.SetAttribute("DBPath", this.txtDataBase.Text);
                 //Config.Intance().DestTable.SetAttribute("TableName", "sheet1");
             }
             Config.Intance().SaveSourceDB(Config.Intance().CurrentCfgFile, Config.Intance().EleSource);
         }
         else
         {
             if (this.cmbDBType.SelectedIndex == 0)
             {
                 Config.Intance().EleDestination.SetAttribute("DBType", "SQLSERVER");
                 Config.Intance().EleDestination.SetAttribute("ServerName", this.txtServer.Text);
                 Config.Intance().EleDestination.SetAttribute("DataBase", this.txtDataBase.Text);
                 Config.Intance().EleDestination.SetAttribute("User", this.txtUser.Text);
                 Config.Intance().EleDestination.SetAttribute("Password", SecretUtil.Secret(this.txtPassword.Text.Trim()));
             }
             else if (this.cmbDBType.SelectedIndex == 1)
             {
                 Config.Intance().EleDestination.SetAttribute("DBType", "ACCESS");
                 Config.Intance().EleDestination.SetAttribute("DBPath", this.txtDataBase.Text);
                 Config.Intance().EleDestination.SetAttribute("Password", SecretUtil.Secret(this.txtPassword.Text.Trim()));
                 //Config.Intance().DestTable.SetAttribute("TableName", Config.Intance().CurrentDBName);
             }
             else if (this.cmbDBType.SelectedIndex == 2)
             {
                 Config.Intance().EleDestination.SetAttribute("DBType", "FOXPRO");
                 Config.Intance().EleDestination.SetAttribute("DBPath", this.txtDataBase.Text);
             }
             else if (this.cmbDBType.SelectedIndex == 3)
             {
                 Config.Intance().EleDestination.SetAttribute("DBType", "ORACLE");
                 Config.Intance().EleDestination.SetAttribute("ServerName", this.txtServer.Text);
                 Config.Intance().EleDestination.SetAttribute("User", this.txtUser.Text);
                 Config.Intance().EleDestination.SetAttribute("Password", SecretUtil.Secret(this.txtPassword.Text.Trim()));
             }
             else if (this.cmbDBType.SelectedIndex == 5)
             {
                 Config.Intance().EleDestination.SetAttribute("DBType", "TXT");
                 Config.Intance().EleDestination.SetAttribute("DBPath", this.txtDataBase.Text);
             }
             else if (this.cmbDBType.SelectedIndex == 4)
             {
                 Config.Intance().EleDestination.SetAttribute("DBType", "EXCEL");
                 Config.Intance().EleDestination.SetAttribute("DBPath", this.txtDataBase.Text);
                 //Config.Intance().DestTable.SetAttribute("TableName", "sheet1");
             }
             Config.Intance().SaveDestDB(Config.Intance().CurrentCfgFile, Config.Intance().EleDestination);
         }
         return(true);
     }
     catch (Exception exception1)
     {
         ErrorLog.SaveLog("保存配置信息", exception1);
         return(false);
     }
 }