private void btnOK_Click(object sender, EventArgs e) { bool replace = true; // Make sure if any LIMS field is set that all are set. if (!((txtCaseNumber.Text.Trim().Length > 0 && txtLIMSTestID.Text.Trim().Length > 0 && txtLIMSSampleID.Text.Trim().Length > 0) || (txtCaseNumber.Text.Trim().Length == 0 && txtLIMSTestID.Text.Trim().Length == 0 && txtLIMSSampleID.Text.Trim().Length == 0))) { LIMSDialog.ShowDialog(this); DialogResult = DialogResult.None; return; } // Does case sample already exist? For what sample ID? string duplicateMsg = AppConfigHelper.LIMSDuplicate(txtCaseNumber.Text.Trim(), txtLIMSTestID.Text.Trim(), txtLIMSSampleID.Text.Trim()); // If no duplicate, duplicateMsg comes back blank. Otherwise it has the warning message. if (duplicateMsg.Length > 0) { LIMSDuplicatePrompt.MainInstruction = duplicateMsg; TaskDialogButton button = LIMSDuplicatePrompt.ShowDialog(this); if (button == btnReplaceCancel) { DialogResult = DialogResult.None; return; } } // If the sample ID is already exists, prompt to replace. if (SampleListContains(txtSampleID.Text.Trim())) { ReplacePrompt.MainInstruction = "At least one contig for " + txtSampleID.Text.Trim() + " already exists in the database. Do you want to replace it?"; TaskDialogButton button = ReplacePrompt.ShowDialog(this); if (button == btnReplaceCancel) { DialogResult = DialogResult.None; return; } } else // Go ahead without prompting. { replace = false; } AppConfigHelper.InsertSample(txtCaseNumber.Text.Trim(), txtLIMSTestID.Text.Trim(), txtLIMSSampleID.Text.Trim(), txtInputPath.Text.Trim(), txtSampleID.Text.Trim(), replace); }
private void btnOK_Click(object sender, EventArgs e) { // If the sample ID is already exists, prompt to replace. foreach (string sample in items.Keys) { if (alreadySelected.ContainsKey(sample)) { ReplacePrompt.MainInstruction = "A sample for " + sample + " already exists in the database. Do you want to replace it?"; TaskDialogButton button = ReplacePrompt.ShowDialog(this); if (button == btnReplaceCancel) { DialogResult = DialogResult.None; return; } alreadySelected[sample] = "1" + items[sample]; } else { alreadySelected.Add(sample, "1" + items[sample]); } } }