private void frmTables_Load(object sender, EventArgs e) { // Populate the Language Pulldown ProgSettings.LoadLangs(lstLangs); // The following command reads all the columns for the selected table var dbViewList = ProgSettings.SelectRows( "SELECT T.TABLE_NAME AS TableName, T.ENGINE AS TableEngine, T.TABLE_COMMENT AS TableComment FROM INFORMATION_SCHEMA.Tables T WHERE T.TABLE_NAME <> 'dtproperties' AND T.TABLE_SCHEMA <> 'INFORMATION_SCHEMA' AND T.TABLE_SCHEMA='" + ProgSettings.DbName + "' ORDER BY T.TABLE_NAME"); // Did we return anything if (dbViewList != null) { // Do we have rows if (dbViewList.Tables[0].Rows.Count > 0) { lstTables.Items.Clear(); // for each Field returned, populate the listbox with the table name for (var thisRow = 0; thisRow <= dbViewList.Tables[0].Rows.Count - 1; thisRow++) { var tableName = dbViewList.Tables[0].Rows[thisRow]["TableName"].ToString(); lstTables.Items.Add(tableName); } } } blnTextChanged = false; }
private void frmFields_Load(object sender, EventArgs e) { Text = Resources.DBDocs_for_Table + TableName; ProgSettings.LoadLangs(lstLangs); // The following command reads all the columns for the selected table var dbViewList = ProgSettings.SelectRows("SHOW COLUMNS FROM " + TableName); // Did we return anything if (dbViewList != null) { // Do we have rows if (dbViewList.Tables[0].Rows.Count > 0) { lstFields.Items.Clear(); // for each Field returned, populate the listbox with the column name for (var thisRow = 0; thisRow <= dbViewList.Tables[0].Rows.Count - 1; thisRow++) { var fieldName = dbViewList.Tables[0].Rows[thisRow]["Field"].ToString(); lstFields.Items.Add(fieldName); } } } blnTextChanged = false; }
private void frmsubtables_Load(object sender, EventArgs e) { // Populate the Language Pulldown ProgSettings.LoadLangs(lstLangs); DataSet dbViewList; if (SubTableId == 0) { // The following command reads all the columns for all the subtables dbViewList = ProgSettings.SelectRows("SELECT subtablename from dbdocssubtables"); } else { // The following command reads all the columns for just the selected subtable dbViewList = ProgSettings.SelectRows("SELECT subtablename from dbdocssubtables where subtableid=" + SubTableId); } // Did we return anything if (dbViewList == null) { return; } // Do we have rows if (dbViewList.Tables[0].Rows.Count <= 0) { return; } // for each Field returned, populate the listbox with the table name for (var thisRow = 0; thisRow <= dbViewList.Tables[0].Rows.Count - 1; thisRow++) { var fieldName = dbViewList.Tables[0].Rows[thisRow]["subtablename"].ToString(); lstsubtables.Items.Add(fieldName); } if (SubTableId != 0) { //Select the first entry if we passed in an Id if (lstsubtables.SelectedIndex < 0) { lstsubtables.SelectedIndex = 0; } Text = Resources.SubTable + lstsubtables.Text; } else { Text = Resources.SubTables; } blnTextChanged = false; }
private void frmDatabaseSelect_Load(object sender, EventArgs e) { var dbViewList = ProgSettings.SelectRows("SHOW DATABASES"); if (dbViewList == null) { return; } if (dbViewList.Tables[0].Rows.Count <= 0) { return; } for (var thisRow = 0; thisRow <= dbViewList.Tables[0].Rows.Count - 1; thisRow++) { lstDatabases.Items.Add(dbViewList.Tables[0].Rows[thisRow]["database"].ToString()); } }
/// <summary> /// Populate the entry information when the item is selected in the listbox /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lstsubtables_SelectedIndexChanged(object sender, EventArgs e) { var selectedSubtable = lstsubtables.Text; txtSubtableName.Text = selectedSubtable; SubTableId = 0; // Force to new entry before the lookup updates it should it exist var dbViewList = ProgSettings.SelectRows("SELECT subtableid,languageid, subtablecontent,subtabletemplate FROM `dbdocssubtables` WHERE `subtablename` = '" + selectedSubtable + "'"); if (dbViewList != null) { if (dbViewList.Tables[0].Rows.Count > 0) { txtSubtableContent.Text = dbViewList.Tables[0].Rows[0]["subtablecontent"].ToString(); txtSubtableTemplate.Text = dbViewList.Tables[0].Rows[0]["subtabletemplate"].ToString(); SubTableId = Convert.ToInt32(dbViewList.Tables[0].Rows[0]["subtableid"]); // Render the HTML webBrowse.DocumentText = txtSubtableContent.Text; if (string.IsNullOrEmpty(txtSubtableTemplate.Text)) { //If the template is missing, attempt to build it from the content, only for historic entries !! txtSubtableTemplate.Text = ProgSettings.ConvertHtmlToTemplate(txtSubtableContent.Text); //Save the updated Template btnSave_Click(sender, e); } } else // No dbdocs match { txtSubtableName.Text = ""; } } else // No dbdocs match { txtSubtableName.Text = ""; } btnSave.Enabled = true; }
/// <summary> /// Populate the entry information when the item is selected in the listbox /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lstFields_SelectedIndexChanged(object sender, EventArgs e) { var blnSwitch = true; if (blnTextChanged && !blnSwitchOverride) { // Subtable text has tried to change selection without save, warn them var dialogResult = MessageBox.Show(this, Resources.You_have_unsaved_changes, Resources.Exit_Check, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); // If the user chose no, don't annoy the switch if (dialogResult == DialogResult.No) { blnSwitch = false; blnSwitchOverride = true; lstFields.SelectedIndex = selectedListId; } } if (!blnSwitch) { return; } if (blnSwitchOverride) { blnSwitchOverride = false; return; } blnTextChanged = false; var selectedField = lstFields.Text; fieldId = ProgSettings.LookupFieldId(TableName, selectedField); // Force to new entry before the lookup updates it should it exist selectedListId = lstFields.SelectedIndex; if (lstLangs.SelectedIndex < 0) { lstLangs.SelectedIndex = 0; } DataSet dbViewList; if (lstLangs.SelectedIndex == 0) { // If English, connect to main table dbViewList = ProgSettings.SelectRows("SELECT `dbdocsfields`.`languageId`,`dbdocsfields`.`FieldId`, `dbdocsfields`.`FieldNotes`,`dbdocsfields`.`FieldComment` FROM `dbdocsfields` WHERE `tablename` = '" + TableName + "' and `FieldName` = '" + selectedField + "'"); } else { // If Non-English, join to localised table and grab field dbViewList = ProgSettings.SelectRows("SELECT COALESCE(`dbdocsfields_localised`.`languageid`,-1) AS languageId,`dbdocsfields`.`FieldId`, `dbdocsfields_localised`.`FieldNotes`, `dbdocsfields_localised`.`FieldComment`,`dbdocsfields`.`FieldNotes` as FieldNotesEnglish, `dbdocsfields`.`FieldComment` as FieldCommentEnglish FROM `dbdocsfields` LEFT JOIN `dbdocsfields_localised` ON `dbdocsfields`.`fieldId` = `dbdocsfields_localised`.`fieldId` where TableName='" + TableName + "'" + " AND FieldName='" + selectedField + "' AND (`dbdocsfields_localised`.`languageId`=" + lstLangs.SelectedIndex + " OR `dbdocsfields`.`languageId`=0);"); } if (dbViewList != null) { if (dbViewList.Tables[0].Rows.Count > 0) { if (Convert.ToInt32(dbViewList.Tables[0].Rows[0]["languageId"]) == lstLangs.SelectedIndex) { txtFieldNotes.Text = dbViewList.Tables[0].Rows[0]["FieldNotes"].ToString(); txtFieldComment.Text = dbViewList.Tables[0].Rows[0]["FieldComment"].ToString(); chkDBDocsEntry.Checked = true; } else { txtFieldNotes.Text = ""; txtFieldComment.Text = ""; chkDBDocsEntry.Checked = false; } // If the Field Comment field is blank, fill it in with the first 80 characters of the notes if (string.IsNullOrEmpty(txtFieldComment.Text) && !string.IsNullOrEmpty(txtFieldNotes.Text)) { txtFieldComment.Text = txtFieldNotes.Text; if (txtFieldComment.Text.Length > 80) { txtFieldComment.Text = txtFieldNotes.Text.Substring(0, 80); } } fieldId = Convert.ToInt32(dbViewList.Tables[0].Rows[0]["fieldId"]); // If the 'Use English' if blank checkbox is ticked if (chkUseEnglish.Checked) { // If Localised SubTable Template is blank, go grab the English if (string.IsNullOrEmpty(txtFieldNotes.Text)) { txtFieldNotes.Text = dbViewList.Tables[0].Rows[0]["FieldNotesEnglish"].ToString(); } if (string.IsNullOrEmpty(txtFieldComment.Text)) { txtFieldComment.Text = dbViewList.Tables[0].Rows[0]["FieldCommentEnglish"].ToString(); } if (string.IsNullOrEmpty(txtFieldComment.Text)) { txtFieldComment.Text = txtFieldNotes.Text.Substring(0, 80); } } txtFieldNotes.Text = ProgSettings.ConvertBrToCrlf(txtFieldNotes.Text); //Check for Subtables ProgSettings.ExtractSubTables(txtFieldNotes.Text, lstSubtables); } else // No dbdocs match { txtFieldNotes.Text = ""; txtFieldComment.Text = ""; chkDBDocsEntry.Checked = false; } } else // No dbdocs match { txtFieldNotes.Text = ""; txtFieldComment.Text = ""; chkDBDocsEntry.Checked = false; } blnTextChanged = false; btnSave.Enabled = false; mnuSave.Enabled = btnSave.Enabled; }
/// <summary> /// Populate the entry information when the item is selected in the listbox /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lstTables_SelectedIndexChanged(object sender, EventArgs e) { var blnSwitch = true; if (blnTextChanged && !blnSwitchOverride) { // Subtable text has tried to change selection without save, warn them var dialogResult = MessageBox.Show(this, Resources.You_have_unsaved_changes, Resources.Exit_Check, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); // If the user chose no, don't annoy the switch if (dialogResult == DialogResult.No) { blnSwitch = false; blnSwitchOverride = true; lstTables.SelectedIndex = selectedListId; } } if (!blnSwitch) { return; } if (blnSwitchOverride) { blnSwitchOverride = false; return; } blnTextChanged = false; var selectedTable = lstTables.Text; tableId = ProgSettings.LookupTableId(selectedTable); selectedListId = lstTables.SelectedIndex; if (lstLangs.SelectedIndex < 0) { lstLangs.SelectedIndex = 0; } DataSet dbViewList; if (lstLangs.SelectedIndex == 0) { // If English, connect to main table dbViewList = ProgSettings.SelectRows( "SELECT `dbdocstable`.`languageId`,`dbdocstable`.`tableId`,`dbdocstable`.`tableNotes` FROM `dbdocstable` WHERE `tablename` = '" + selectedTable + "'"); } else { // If Non-English, join to localised table and grab field dbViewList = ProgSettings.SelectRows( "SELECT COALESCE(`dbdocstable_localised`.`languageid`,-1) AS languageId,`dbdocstable_localised`.`tableNotes`, `dbdocstable`.`tableId`, `dbdocstable`.`tableNotes` as TableNotesEnglish FROM `dbdocstable` LEFT JOIN `dbdocstable_localised` ON `dbdocstable`.`tableId` = `dbdocstable_localised`.`tableId` WHERE `tablename` = '" + selectedTable + "' AND (`dbdocstable_localised`.`languageId`=" + lstLangs.SelectedIndex + " OR `dbdocstable`.`languageId`=0)"); } if (dbViewList != null) { if (dbViewList.Tables[0].Rows.Count > 0) { if (Convert.ToInt32(dbViewList.Tables[0].Rows[0]["languageId"]) == lstLangs.SelectedIndex) { txtTableNotes.Text = dbViewList.Tables[0].Rows[0]["TableNotes"].ToString(); chkDBDocsEntry.Checked = true; } else { txtTableNotes.Text = ""; chkDBDocsEntry.Checked = false; } tableId = Convert.ToInt32(dbViewList.Tables[0].Rows[0]["TableId"]); // If the 'Use English' if blank checkbox is ticked if (chkUseEnglish.Checked) { // If Localised SubTable Template is blank, go grab the English if (string.IsNullOrEmpty(txtTableNotes.Text)) { txtTableNotes.Text = dbViewList.Tables[0].Rows[0]["TableNotesEnglish"].ToString(); } } txtTableNotes.Text = ProgSettings.ConvertBrToCrlf(txtTableNotes.Text); //Check for Subtables ProgSettings.ExtractSubTables(txtTableNotes.Text, lstSubtables); } else // No dbdocs match { txtTableNotes.Text = ""; chkDBDocsEntry.Checked = false; } } else // No dbdocs match { txtTableNotes.Text = ""; chkDBDocsEntry.Checked = false; } btnShowFields.Enabled = true; blnTextChanged = false; btnSave.Enabled = false; mnuSave.Enabled = btnSave.Enabled; }
/// <summary> /// Populate the entry information when the item is selected in the listbox /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lstsubtables_SelectedIndexChanged(object sender, EventArgs e) { var blnSwitch = true; if (blnTextChanged && !blnSwitchOverride) { // Subtable text has tried to change selection without save, warn them var dialogResult = MessageBox.Show(this, Resources.You_have_unsaved_changes, Resources.Exit_Check, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); // If the user chose no, don't annoy the switch if (dialogResult == DialogResult.No) { blnSwitch = false; blnSwitchOverride = true; lstsubtables.SelectedIndex = selectedListId; } } if (!blnSwitch) { return; } if (blnSwitchOverride) { blnSwitchOverride = false; return; } blnTextChanged = false; var selectedSubtable = lstsubtables.Text; txtSubTableName.Text = selectedSubtable; selectedListId = lstsubtables.SelectedIndex; SubTableId = 0; // Force to new entry before the lookup updates it should it exist if (lstLangs.SelectedIndex < 0) { lstLangs.SelectedIndex = 0; } DataSet dbViewList; if (lstLangs.SelectedIndex == 0) { // If English, connect to main table dbViewList = ProgSettings.SelectRows( "SELECT subtableid,languageid, subtablecontent,subtabletemplate FROM `dbdocssubtables` WHERE `subtablename` = '" + selectedSubtable + "'"); } else { // If Non-English, join to localised table and grab field dbViewList = ProgSettings.SelectRows( "SELECT COALESCE(`dbdocstable_localised`.`languageid`,-1) AS languageId,`dbdocssubtables`.`subtableid`, `dbdocssubtables_localised`.`subtabletemplate`, `dbdocssubtables_localised`.`subtablecontent`, `dbdocssubtables`.`subtabletemplate` as subtableTemplateEnglish, `dbdocssubtables`.`subtablecontent` as subTableContentEnglish FROM `dbdocssubtables` LEFT JOIN `dbdocssubtables_localised` ON `dbdocssubtables`.`subtableid` = `dbdocssubtables_localised`.`subtableid` WHERE `subtablename` = '" + selectedSubtable + "' AND (`dbdocssubtables_localised`.`languageId`=" + lstLangs.SelectedIndex + " OR `dbdocssubtables`.`languageId`=0);"); } if (dbViewList != null) { if (dbViewList.Tables[0].Rows.Count > 0) { if (Convert.ToInt32(dbViewList.Tables[0].Rows[0]["languageId"]) == lstLangs.SelectedIndex) { txtSubtableContent.Text = dbViewList.Tables[0].Rows[0]["subtablecontent"].ToString(); txtSubtableTemplate.Text = dbViewList.Tables[0].Rows[0]["subtabletemplate"].ToString(); } else { txtSubtableContent.Text = ""; txtSubtableTemplate.Text = ""; } SubTableId = Convert.ToInt32(dbViewList.Tables[0].Rows[0]["subtableid"]); // If the 'Use English' if blank checkbox is ticked if (chkUseEnglish.Checked && lstLangs.SelectedIndex != 0) { // If Localised SubTable Template is blank, go grab the English if (string.IsNullOrEmpty(txtSubtableTemplate.Text)) { if ( !string.IsNullOrEmpty( dbViewList.Tables[0].Rows[0]["subtablecontentEnglish"].ToString())) { txtSubtableContent.Text = dbViewList.Tables[0].Rows[0]["subtablecontentEnglish"].ToString(); } if ( !string.IsNullOrEmpty( dbViewList.Tables[0].Rows[0]["subtabletemplateEnglish"].ToString())) { txtSubtableTemplate.Text = dbViewList.Tables[0].Rows[0]["subtabletemplateEnglish"].ToString(); } } } // Render the HTML webBrowse.DocumentText = txtSubtableContent.Text; if (string.IsNullOrEmpty(txtSubtableTemplate.Text)) { //If the template is missing, attempt to build it from the content, only for historic entries !! txtSubtableTemplate.Text = ProgSettings.ConvertHtmlToTemplate(txtSubtableContent.Text); //Save the updated Template btnSave_Click(sender, e); } } else // No dbdocs match { txtSubtableContent.Text = ""; txtSubtableTemplate.Text = ""; } } else // No dbdocs match { txtSubtableContent.Text = ""; txtSubtableTemplate.Text = ""; } blnTextChanged = false; btnSave.Enabled = false; mnuSave.Enabled = btnSave.Enabled; btnDeleteEntry.Enabled = true; }