private void loadParameters() { int top = 20; m_texts = new TextBox[m_parameters.count()]; for (int j = 0; j < m_parameters.count(); j++) { cParameter parameter = m_parameters.getByPosition(j + 1); System.Windows.Forms.Label label = new System.Windows.Forms.Label(); label.AutoSize = true; label.Location = new System.Drawing.Point(30, top); label.Text = parameter.getName(); System.Windows.Forms.TextBox input = new System.Windows.Forms.TextBox(); input.Location = new System.Drawing.Point(150, top); input.Size = new System.Drawing.Size(150, 20); input.Text = parameter.getValue(); input.Tag = parameter.getKey(); switch (parameter.getColumnType()) { case csDataType.CSTDLONGVARCHAR: case csDataType.CSTDCHAR: input.Tag = "T"; break; case csDataType.CSTDBIGINT: case csDataType.CSTDBINARY: case csDataType.CSTDINTEGER: case csDataType.CSTDSMALLINT: case csDataType.CSTDTINYINT: case csDataType.CSTDUNSIGNEDTINYINT: input.Tag = "N"; break; case csDataType.CSTDBOOLEAN: input.Tag = "N"; break; case csDataType.CSTDSINGLE: case csDataType.CSTDDECIMAL: case csDataType.CSTDDOUBLE: input.Tag = "N"; break; case csDataType.CSTDDBTIME: input.Tag = "F"; break; } m_texts[j] = input; pnlParameters.Controls.Add(label); pnlParameters.Controls.Add(input); top += 30; } }
public bool fillParameters(string dataSource) { cDataBase db = new cDataBase(csDatabaseEngine.SQL_SERVER); if (db.initDb(m_strConnect)) { string[] restrictions = new string[4]; restrictions[2] = dataSource; DataTable dt = db.openSchema("ProcedureParameters", restrictions); if (m_parameters == null) { m_parameters = new cParameters(); } cParameters parameters = new cParameters(); foreach (DataRow row in dt.Rows) { if (row["parameter_mode"].ToString() != "OUT") { cParameter p = null; bool found = false; for (var i = 0; i < m_parameters.count(); i++) { p = m_parameters.item(i); if (p.getName() == row["parameter_name"].ToString()) { found = true; break; } } if (!found) { p = null; } p = parameters.add(p, ""); p.setName(row["parameter_name"].ToString()); p.setPosition((int)row["ordinal_position"]); p.setColumnType(cDatabaseGlobals.getDataTypeFromString(row["data_type"].ToString())); } } // // openSchema can be sorted by any column (usually by name) // we need this collection to be sorted by position // m_parameters = new cParameters(); for (var j = 1; j < parameters.count() + 1; j++) { cParameter p = null; bool found = false; for (var i = 0; i < parameters.count(); i++) { p = parameters.item(i); if (p.getPosition() == j) { found = true; break; } } if (!found) { throw new Exception("Parameter not found for position: " + j); } else { m_parameters.add(p, p.getKey()); } } return(true); } return(false); }