public static void PrintDbTable(string tableName, MySqlUtils sqlUtils) { if (Logger.ShowTableContents) { DataSet ds = new DataSet(); sqlUtils.ExecuteQuery("select * from " + tableName, ds); ds.Tables[0].TableName = tableName; Logger.PrintTable(ds.Tables[0]); } }
public void SetQuestionText(MySqlUtils sqlUtils, string title, string questionText, string paramTableName, string paramColNames, string queryBody, TopicType topicType) { m_sqlUtils = sqlUtils; m_queryBody = queryBody; Text = title; m_topicType = topicType; DataSet ds = new DataSet(); sqlUtils.ExecuteQuery(string.Format("SELECT {0} FROM {1}", paramColNames, paramTableName), ds); m_paramNames = paramColNames.Split(new char[] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries); m_tableName = paramTableName; int curPosition = 0; while (curPosition < questionText.Length) { int startParamIndex = questionText.IndexOf('{', curPosition); if (startParamIndex < 0) // if there is no more paraeters in the string { string labelText = questionText.Substring(curPosition); _flowLayoutPanelQueryText.Controls.Add(new Label() { Text = labelText, AutoSize = true, Font = m_labelInfo.Font, ForeColor = m_labelInfo.ForeColor, Margin = m_labelInfo.Margins, BackColor = Color.Transparent }); break; } if (startParamIndex > curPosition) // if there is a need in Label { string labelText = questionText.Substring(curPosition, startParamIndex - curPosition); _flowLayoutPanelQueryText.Controls.Add(new Label() { Text = labelText, AutoSize = true, Font = m_labelInfo.Font, ForeColor = m_labelInfo.ForeColor, Margin = m_labelInfo.Margins, BackColor = Color.Transparent }); } int endParamIndex = questionText.IndexOf('}', startParamIndex); curPosition = endParamIndex + 1; int curParamInd = int.Parse(questionText.Substring(startParamIndex + 1, endParamIndex - startParamIndex - 1)); BBBNOVA.BNComboBox cb = new BBBNOVA.BNComboBox() { Size = m_comboBoxInfo.Size, Font = m_comboBoxInfo.Font, ForeColor = Color.White, BackColor = Color.Black, DataSource = ds.Tables[0], DisplayMember = m_paramNames[curParamInd], Margin = m_comboBoxInfo.Margins, DropDownWidth = 300 }; cb.SelectedValueChanged += new EventHandler(comboBox_SelectedValueChanged); m_cbList.Add(cb); _flowLayoutPanelQueryText.Controls.Add(cb); } }