private void tsbSave_Click(object sender, EventArgs e) { txbWord.BackColor = Color.White; bool successExecSql = false; int idContent = (cmbCategoryWord.Text == Constants.PUBLIC_DICTIONARY_CATEGORY) ? 0 : _currentQuestionId; string url = (cmbToolTipType.SelectedIndex == (int)TooltipDictionary.TooltipType.QuestionHref) ? (string.IsNullOrEmpty(txbQuestion.Text)? string.Empty: "\\\\" + txbQuestion.Text) : txbUrl.Text; if (txbWord.Text.EndsWith(".")) { txbWord.BackColor = Color.LightCoral; MessageBox.Show(string.Format("'{0}' не может заканчиваться символом '.'", lblWord.Text)); return; } if (tsbSave.Text == "Создать") { successExecSql = TooltipDictionary.InsertWordToolTip( idContent , txbWord.Text , cmbToolTipType.SelectedIndex , txbComment.Text , url , cmbGroup.Text , cmbForeColor.Text); } else { string comment = txbComment.Text; if (cmbToolTipType.SelectedIndex == (int)TooltipDictionary.TooltipType.QuestionHref) { comment = string.Empty; } successExecSql = TooltipDictionary.UpdateWordToolTip( idContent , txbWord.Text , cmbToolTipType.SelectedIndex , comment , url , cmbGroup.Text , cmbForeColor.Text , _oldIdContent , _oldWordForSave ); } if (successExecSql) { AddGroupName(cmbGroup.Text); panel2.Visible = false; panel1.Visible = true; panel1.Dock = DockStyle.Fill; //if (tsbSave.Text == "Создать") // TooltipDictionary.TV_Dictionary.Nodes[cmbCategoryWord.Text].Nodes.Add(idContent.ToString(), txbWord.Text); //RefreshAllData(new string[] { S_TypeCmbBox.Text }); } }
private void tsbDelete_Click(object sender, EventArgs e) { if (TooltipDictionary.TV_Dictionary.SelectedNode.Level == 2) { int idContent = (TooltipDictionary.TV_Dictionary.SelectedNode.Parent.Parent.Text == Constants.PUBLIC_DICTIONARY_CATEGORY) ? 0 : (Application.OpenForms[0] as MainForm).GetCurrentQuestionId(); if (TooltipDictionary.DeleteItem(idContent, TooltipDictionary.TV_Dictionary.SelectedNode.Text)) { TooltipDictionary.TV_Dictionary.SelectedNode.Remove(); } } }
public static bool DeleteItem(int idContent, string word) { bool result = false; if (MessageBox.Show("Удалить всплывающую подсказку для слова '" + word + "'", "Подтверждение удаления", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { if (TooltipDictionary.DeleteWordTooltip(idContent, word)) { DictionaryInfo deletedWord = eDictionary.GetByTitle(idContent, word); eDictionary.Remove(deletedWord); HelpDT.Rows.Remove(GetHelpDtRow(idContent, word)); result = true; } } return(result); }
private void EditOrCopyWordToolTip(bool isCopy) { if (TooltipDictionary.TV_Dictionary.SelectedNode.Level == 2) { if (isCopy) { tsbSave.Text = "Создать"; } else { tsbSave.Text = "Сохранить"; } panel2.Visible = true; panel2.Dock = DockStyle.Fill; panel1.Visible = false; //int _oldIdContent = (TooltipDictionary.TV_Dictionary.SelectedNode.Parent.Parent.Text == Constants.PUBLIC_DICTIONARY_CATEGORY) ? 0 : currentQuestionId; SetIdContentForSave(Convert.ToInt32(TooltipDictionary.TV_Dictionary.SelectedNode.Name)); int currentQuestionId = (TooltipDictionary.TV_Dictionary.SelectedNode.Parent.Parent.Text == Constants.PUBLIC_DICTIONARY_CATEGORY) ? 0 : _oldIdContent; string wordSql = TooltipDictionary.TV_Dictionary.SelectedNode.Text; TooltipDictionary.QuotedStr(ref wordSql); string sql = string.Format( "SELECT * FROM word_tooltip WHERE id_content={0} AND {1}='{2}' ORDER BY {1}" , currentQuestionId , TooltipDictionary.WORD, wordSql); G.ExecSQLiteQuery(sql); if (G.DT.Rows.Count == 1) { DataRow row = G.DT.Rows[0]; SetPropertyValues(currentQuestionId , row[TooltipDictionary.WORD].ToString() , Convert.ToInt32(row[TooltipDictionary.TOOLTIP_TYPE_COLUMN_NAME]) , row[TooltipDictionary.COMMENT_COLUMN_NAME].ToString() , row[TooltipDictionary.URL_ADR_COLUMN_NAME].ToString() , row[TooltipDictionary.GROUP_NAME].ToString() , row[TooltipDictionary.FORE_COLOR].ToString() ); } } }