123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- using Practics.Model;
- using Practics.Views;
- 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
- {
- /// <summary>
- /// Interaction logic for AdminTicketWindow.xaml
- /// </summary>
- public partial class AdminTicketWindow : Window
- {
- Model.Model model = Model.Model.ModelInstance;
- User User { get; set; }
- public AdminTicketWindow(User user)
- {
- InitializeComponent();
- User = user;
- }
-
- private void Window_Loaded(object sender, RoutedEventArgs e)
- {
- dgTickets.ItemsSource = model.DataTableProblems.DefaultView;
- dgcbcStatus.ItemsSource = model.DataTableStatuses.DefaultView;
- dgcbcStatus.DisplayMemberPath = "name";
- dgcbcStatus.SelectedValuePath = "Id";
- dgcbcProblemType.ItemsSource = model.DataTableProblemTypes.DefaultView;
- dgcbcProblemType.DisplayMemberPath = "NameProblemType";
- dgcbcProblemType.SelectedValuePath = "ID";
- cbProblemStatus.ItemsSource = model.DataTableStatuses.DefaultView;
- cbProblemStatus.DisplayMemberPath = "name";
- cbProblemStatus.SelectedValuePath = "Id";
- cbProblemType.ItemsSource = model.DataTableProblemTypes.DefaultView;
- cbProblemType.DisplayMemberPath = "NameProblemType";
- cbProblemType.SelectedValuePath = "ID";
- //tbProblemDescribe.DataContext=model.DataTableProblems.DefaultView;
- }
- DataRow currentRow;
- private void dgTickets_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- /*
- if (dgTickets.SelectedItem != null)
- {
-
- DataRowView selectedRow=(DataRowView)dgTickets.SelectedItem;
- if (selectedRow.Row.ItemArray.Length>5)
- {
- MessageBox.Show("!!!");
- }*/
- if (dgTickets.SelectedItem != null)
- {
- //DataGridRow row = (dgTickets.SelectedItem as DataGridRow);
- DataRowView selectedRow = (DataRowView)dgTickets.SelectedItem;
- if (selectedRow != null)
- {
- //DataRow dataTableRow = selectedRow.Row;
- currentRow = selectedRow.Row;
- }
- }
- }
- private void btnUpdateProblems_Click(object sender, RoutedEventArgs e)
- {
- model.UpdateProblems();
- }
- private void btnReadProblems_Click(object sender, RoutedEventArgs e)
- {
- model.RefillProblems();
- }
- private void btnProcessWindow_Click(object sender, RoutedEventArgs e)
- {
- if (currentRow != null)
- {
- TicketProcessing ticketProcessing = new TicketProcessing(currentRow,User);
- ticketProcessing.ShowDialog();
- }
-
- }
- private void btnExit_Click(object sender, RoutedEventArgs e)
- {
- MainWindow mainWindow = new MainWindow();
- mainWindow.Show();
- this.Close();
- }
- private void btnShowNotesWindow_Click(object sender, RoutedEventArgs e)
- {
- KnowledgeWindow knowledgeWindow= new KnowledgeWindow(User);
- knowledgeWindow.ShowDialog();
-
- }
- //Для отчета в виде PDF. Просто распечатывает элемент dgTickets, что не очень хорошо
- /*
- private void btnReport_Click(object sender, RoutedEventArgs e)
- {
- //Model.Model.ExportDataTableToCSV(model.DataTableProblems, "report.csv");
-
- PrintDialog printDialog = new PrintDialog();
- DataGridColumn hideColumn = dgTickets.Columns.Where(c => c.Header.ToString() == "Обработать").FirstOrDefault();
-
- hideColumn.Visibility = Visibility.Collapsed;
- // Если пользователь подтвердил печать
- if (printDialog.ShowDialog() == true)
- {
- // Получение объекта VisualBrush, представляющего DataGrid
- VisualBrush visualBrush = new VisualBrush(dgTickets);
- // Создание объекта DrawingVisual для печати
- DrawingVisual drawingVisual = new DrawingVisual();
- using (DrawingContext drawingContext = drawingVisual.RenderOpen())
- {
- // Отображение DataGrid в контексте рисования
- drawingContext.DrawRectangle(visualBrush, null, new Rect(0, 0, dgTickets.ActualWidth, dgTickets.ActualHeight));
- }
- // Печать DrawingVisual
- printDialog.PrintVisual(drawingVisual, "Report");
- }
- hideColumn.Visibility = Visibility.Visible;
- }
- */
- private void btnReport_Click(object sender, RoutedEventArgs e)
- {
- string result;
- Model.Model.ExportDataTableToCSV(model.DataTableProblems, "report.csv", out result);
- MessageBox.Show(result);
-
-
- }
- private void btnFilter_Click(object sender, RoutedEventArgs e)
- {
- if (dtpStartPeriod.Value==null)
- {
- dtpStartPeriod.Value = new DateTime(1900,1,1);
- }
- if (dtpFinishPeriod.Value==null)
- {
- dtpFinishPeriod.Value = new DateTime(9999,12,31);
- }
- model.InitDataAdapterProblemsByFilter(dtpStartPeriod.Value, dtpFinishPeriod.Value, cbProblemStatus.SelectedValue==null?-1:(int)cbProblemStatus.SelectedValue, cbProblemType.SelectedValue==null?-1:(int)cbProblemType.SelectedValue);
- dgTickets.ItemsSource = null;
- dgTickets.ItemsSource = model.DataTableProblems.DefaultView;
- }
- }
- }
|