UpgradeSelectionDlg : 2.18 -> 2.22 and 2.22 -> 2.24

This commit is contained in:
Milan Hanajik
2019-09-19 14:22:34 +02:00
parent adc9e4efe4
commit 6dbb6118ea
2 changed files with 75 additions and 22 deletions
+45 -5
View File
@@ -560,7 +560,7 @@ namespace TBF.UI.Settings
}
///---------------------------------------------------------------------
private void upgradeDb_218_220_Button_Click(object sender, EventArgs e)
private void upgradeDb_218_222_Button_Click(object sender, EventArgs e)
{
if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
{
@@ -568,20 +568,60 @@ namespace TBF.UI.Settings
return;
}
string[] commands = new string[]
string[] resultsDbCommands = new string[]
{
"ALTER TABLE `metertestrslt` ADD `RegReaderType` INT NOT NULL DEFAULT '0' AFTER `CompoundMeterId`;",
"ALTER TABLE `testrslt` ADD `MethodClass` VARCHAR(255) NULL DEFAULT NULL AFTER `RepetitionNr`, ADD `ConstMasterRaw` DOUBLE NOT NULL DEFAULT '1' AFTER `PulsesMaster`, ADD `ConstMasterCorr` DOUBLE NOT NULL DEFAULT '1' AFTER `ConstMasterRaw`;",
"ALTER TABLE `testrslt` ADD `MethodClass` VARCHAR(255) NULL DEFAULT NULL AFTER `RepetitionNr`, ADD `TimeBtwnMassMsrmnts` INT NOT NULL DEFAULT '0' AFTER `FlowSetTime`, ADD `TestTimeCorrection` DOUBLE NOT NULL DEFAULT '0' AFTER `TestTime`, ADD `ConstMasterRaw` DOUBLE NOT NULL DEFAULT '1' AFTER `PulsesMaster`, ADD `ConstMasterCorr` DOUBLE NOT NULL DEFAULT '1' AFTER `ConstMasterRaw`;",
"ALTER TABLE `watermeterdata` ADD `Medium` VARCHAR(255) NULL DEFAULT NULL AFTER `ApprovalInfoAux`;",
"ALTER TABLE `batch` ADD `Counter1` INT NOT NULL DEFAULT '0' AFTER `Custom3`, ADD `Counter2` INT NOT NULL DEFAULT '0' AFTER `Counter1`, ADD `Counter3` INT NOT NULL DEFAULT '0' AFTER `Counter2`, ADD `Counter4` INT NOT NULL DEFAULT '0' AFTER `Counter3`, ADD `Counter5` INT NOT NULL DEFAULT '0' AFTER `Counter4`, ADD `Counter6` INT NOT NULL DEFAULT '0' AFTER `Counter5`, ADD `Counter7` INT NOT NULL DEFAULT '0' AFTER `Counter6`, ADD `Counter8` INT NOT NULL DEFAULT '0' AFTER `Counter7`, ADD `Counter9` INT NOT NULL DEFAULT '0' AFTER `Counter8`, ADD `Counter10` INT NOT NULL DEFAULT '0' AFTER `Counter9`;",
};
ActivityStart();
if (!upgradeResultsDBCheckBox.Checked || ExecuteCommands(new MySqlConnection(DB.ConnectionString), commands))
if (!upgradeResultsDBCheckBox.Checked || ExecuteCommands(new MySqlConnection(DB.ConnectionString), resultsDbCommands))
{
ActivityEnd();
MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
upgradeDb_218_220_Button.Enabled = false;
upgradeDb_218_222_Button.Enabled = false;
}
}
private void upgradeDb_222_224_Button_Click(object sender, EventArgs e)
{
if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
{
MessageBox.Show("No database selected");
return;
}
string[] configDbCommands = new string[]
{
"ALTER TABLE `user` ADD `Password2` VARCHAR(255) NULL DEFAULT NULL AFTER `Password`, ADD `Password3` VARCHAR(255) NULL DEFAULT NULL AFTER `Password2`;",
"CREATE TABLE IF NOT EXISTS `uncertainty` (" +
" `Id` int(11) NOT NULL AUTO_INCREMENT," +
" `Measurement` float NOT NULL DEFAULT '0'," +
" `MainUncertainty` float NOT NULL DEFAULT '0'," +
" `Resolution` float NOT NULL DEFAULT '0'," +
" `DriftPerYr` float NOT NULL DEFAULT '0'," +
" `Conditions` float NOT NULL DEFAULT '0'," +
" `UncertaintyOfCorrection` float NOT NULL DEFAULT '0'," +
" `Component_id` int(11) DEFAULT NULL," +
" PRIMARY KEY (`Id`)," +
" KEY `Component_id` (`Component_id`)" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;",
};
ActivityStart();
if (!upgradeConfigDBCheckBox.Checked || ExecuteCommands(new MySqlConnection(Config.Data.CurrentBench.ProceduresDBSettings.ConnectionString), configDbCommands))
{
ActivityEnd();
MessageBox.Show("DB succesfully upgraded." + Environment.NewLine +
"Please, create Density and Buoyancy components.",
"Confirmation",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
upgradeDb_222_224_Button.Enabled = false;
}
}