private bool debugVis = false; // /// <summary> /// /// Default constructor. /// /// </summary> public CodeViewForm() { InitializeComponent(); LoadTemplateDropdown(); // Load tags from the db into the drop-down menu needs to run when template dropdown is given a value Load_DataGrid_CodeList(); DataSet dsT = Connection.GetDbConn().GetDataSet(SqlQueries.SelectAllTemplates()); Label_TemplatesTotal.Text = dsT.Tables[0].Rows.Count.ToString(); DataSet dsS = Connection.GetDbConn().GetDataSet(SqlQueries.SelectAllSections()); Label_SectionsTotal.Text = dsS.Tables[0].Rows.Count.ToString(); DataSet dsC = Connection.GetDbConn().GetDataSet(SqlQueries.SelectCodes()); Label_CodesTotal.Text = dsC.Tables[0].Rows.Count.ToString(); }
/// <summary> /// Retrieve the codes from the database and add them into a List <Code> /// </summary> public static void FillCodeList() { // Retrieves the codes from the database DataSet ds = Connection.GetDbConn().GetDataSet(SqlQueries.SelectCodes()); DataRow dRow; // Iterates through the table extracted from the database for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { dRow = ds.Tables[0].Rows[i]; // Creates a new instance passing the data-fields from the database Code _instance = new Code( Int32.Parse(dRow.ItemArray.GetValue(0).ToString()), // Code ID dRow.ItemArray.GetValue(1).ToString(), // CodeName Int32.Parse(dRow.ItemArray.GetValue(2).ToString()), // SectionNo dRow.ItemArray.GetValue(3).ToString() // CodeParagraph ); // the instance is added into the list Code.codeList.Add(_instance); } }