private void btnClick(object sender, EventArgs e) { Button button = sender as Button; string errorMessage = ""; string listSql = ScriptGenerator.updateParam.inputParamList[(int)button.Tag].validItemsSQL; //Go through all the parameters we have entered so far and pop in the search query string paramVal = ""; for (int i = 0; i < counter; i++) { Control x = this.Controls.Find("inputParamVal" + i.ToString(), true)[0]; if (x.GetType() == typeof(TextBox)) { paramVal = x.Text; } if (x.GetType() == typeof(ComboBox)) { paramVal = x.Text; } DCR_Script_Generator.ScriptGenerator.InputParamItem inputParam = ScriptGenerator.updateParam.inputParamList[i]; if (ScriptGenerator.updateParam.inputParamList[i].inputType == "String") { paramVal = ScriptGenerator.getQueryableList(paramVal); } listSql = listSql.Replace('{' + inputParam.paramName + '}', paramVal); } listSql = listSql.Replace("{DESIGNDB}", ScriptGenerator.thisStudy.designDatabase); //Get a list of valid items based on the sql List <String> theItems = ScriptGenerator.getValidItemList(ref errorMessage, listSql); Control ctrl = this.Controls.Find("inputParamVal" + button.Tag.ToString(), true)[0]; ComboBox cmb = ctrl as ComboBox; cmb.Items.Clear(); if (theItems.Count == 0) { MessageBox.Show("No records returned"); } else { foreach (var x in theItems) { cmb.Items.Add(x); } } }
private void btnConfirm_Click(object sender, EventArgs e) { string currentItem = "123400075,123400076"; string displayMessage = ""; for (int i = 0; i < counter; i++) { Control x = this.Controls.Find("inputParamVal" + i.ToString(), true)[0]; if (x.GetType() == typeof(TextBox)) { currentItem = x.Text; } if (x.GetType() == typeof(ComboBox)) { currentItem = x.Text; } DCR_Script_Generator.ScriptGenerator.InputParamItem inputParam = ScriptGenerator.updateParam.inputParamList[i]; if (ScriptGenerator.validInputParam(ref displayMessage, inputParam, currentItem)) { if (ScriptGenerator.updateParam.inputParamList[i].inputType == "String") { ScriptGenerator.updateParam.inputParamList[i].value = ScriptGenerator.getQueryableList(currentItem); } else { ScriptGenerator.updateParam.inputParamList[i].value = currentItem; } } else { MessageBox.Show(displayMessage); return; } } this.DialogResult = DialogResult.OK; }