1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- 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
- {
- /// <summary>
- /// Interaction logic for KnowledgeWindow.xaml
- /// </summary>
- 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();
- }
- }
- }
|