using Practics.Model; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace Practics.Views { /// /// Interaction logic for KnowledgeWindow.xaml /// public partial class KnowledgeWindow : Window { Model.Model model = Model.Model.ModelInstance; User user; public KnowledgeWindow(User user) { InitializeComponent(); dgNotes.ItemsSource = model.DataTableKnowledge.DefaultView; this.user = user; } private void btnClearNote_Click(object sender, RoutedEventArgs e) { rtbNote.Document.Blocks.Clear(); } int currentID = -1; int currentUserID = -1; DataRow currentRow = null; private void dgNotes_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (dgNotes.SelectedItems != null) { DataGridRow row = (dgNotes.SelectedItem as DataGridRow); DataRowView selectedRow = (DataRowView)dgNotes.SelectedItem; if (selectedRow != null) { //DataRow dataTableRow = selectedRow.Row; currentRow = selectedRow.Row; currentID = Convert.ToInt32(currentRow["ID"]); //currentUserID= Convert.ToInt32(currentRow["UserID"]); rtbNote.Document.Blocks.Clear(); model.LoadChatToRichTextBox(currentRow, rtbNote,"Note"); } } } private void btnSaveNote_Click(object sender, RoutedEventArgs e) { string noteString = model.RichTextBoxContentToString(rtbNote); currentRow["Note"] = noteString; model.NoteUpdate(currentID, noteString); } private void btnAddNew_Click(object sender, RoutedEventArgs e) { model.InsertNote(user.Id); dgNotes.ItemsSource = null; dgNotes.ItemsSource = model.DataTableKnowledge.DefaultView; } private void btnUpdateAll_Click(object sender, RoutedEventArgs e) { model.NoteUpdateAll(); } private void btnExit_Click(object sender, RoutedEventArgs e) { this.Close(); } } }