/// <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; }
private void btnStripTemplate_Click(object sender, EventArgs e) { txtSubtableTemplate.Text = ProgSettings.ConvertHtmlToTemplate(txtSubtableTemplate.Text); }
/// <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; }