public search(System.Windows.Forms.DataGridView GetDGV) { InitializeComponent(); newLineOfComBox = new ArrayOfComboBox(this); newLineOfTextBox = new ArrayOfTextBox(this); newLineOfTextBox[0].KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBox_KeyDown); dgv = GetDGV; }
private void searchData(ArrayOfComboBox ComboBoxList, ArrayOfTextBox TextBoxList, bool AndOrSelect) { System.Collections.Generic.List<string> Parameters = new System.Collections.Generic.List<string>(); System.Collections.Generic.List<string> DataFromTextBox = new System.Collections.Generic.List<string>(); String searchColumn = ""; String searchStringLine = "SELECT NAME , OBOZN , GOST, L, " + " B, B1, H, D, D1, D_SM_DB , D1_SM_DB, " + " A, S, B_SM_DB , H0, T, N,H_SM_DB, MASSA" + " , NALICHI , TT, YT, PR, RZ, GROUP_USP, KATALOG_USP FROM DB_DATA WHERE "; for (int i = 0; i < ComboBoxList.Count; i++) { switch (((System.Windows.Forms.ComboBox)ComboBoxList[i]).SelectedItem.ToString()) { case "Наименование": searchColumn = "NAME"; break; case "Обозначение": searchColumn = "OBOZN"; break; case "ГОСТ": searchColumn = "GOST"; break; case "d": searchColumn = "D_SM_DB"; break; case "d1": searchColumn = "D1_SM_DB"; break; case "alfa": searchColumn = "A"; break; case "b": searchColumn = "B_SM_DB"; break; case "h": searchColumn = "H_SM_DB"; break; case "t": searchColumn = "T"; break; case "Масса": searchColumn = "MASSA"; break; case "Наличие": searchColumn = "NALICHI"; break; case "Месторасположение": searchColumn = "UG"; break; default: searchColumn = ((System.Windows.Forms.ComboBox)ComboBoxList[i]).SelectedItem.ToString(); break; } if (i != 0) { if (AndOrSelect) { searchStringLine += " AND " + searchColumn + " LIKE :" + searchColumn + " "; Parameters.Add(searchColumn); DataFromTextBox.Add((string)("%" + (((System.Windows.Forms.TextBox)TextBoxList[i]).Text) + "%")); } else { searchStringLine += " OR " + searchColumn + " LIKE :" + searchColumn + " "; Parameters.Add(searchColumn); DataFromTextBox.Add((string)("%" + (((System.Windows.Forms.TextBox)TextBoxList[i]).Text) + "%")); } } else { searchStringLine += " " + searchColumn + " LIKE :" + searchColumn + " "; Parameters.Add(searchColumn); DataFromTextBox.Add((string)("%" + (((System.Windows.Forms.TextBox)TextBoxList[i]).Text) + "%")); } } dgv.DataSource = SQLOracle.ParamQuerySelect(searchStringLine, Parameters, DataFromTextBox).Tables[0]; Algorithm.ElmInform.hideEmptyColumn(dgv); searchStringLine = ""; }