TicketProcessing.xaml.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Shapes;
  15. namespace Practics.Views
  16. {
  17. /// <summary>
  18. /// Interaction logic for TicketProcessing.xaml
  19. /// </summary>
  20. public partial class TicketProcessing : Window
  21. {
  22. public DataRow DataRowProblem { get; private set; }
  23. Model.Model model = Model.Model.ModelInstance;
  24. Practics.Model.User user;
  25. public TicketProcessing(DataRow dataRow, Practics.Model.User user)
  26. {
  27. InitializeComponent();
  28. this.user = user;
  29. DataRowProblem= dataRow;
  30. this.DataContext = DataRowProblem;
  31. cbProblemStatus.ItemsSource = model.DataTableStatuses.DefaultView;
  32. cbProblemStatus.DisplayMemberPath = "name";
  33. cbProblemStatus.SelectedValuePath = "Id";
  34. cbProblemType.ItemsSource=model.DataTableProblemTypes.DefaultView;
  35. cbProblemType.DisplayMemberPath = "NameProblemType";
  36. cbProblemType.SelectedValuePath = "ID";
  37. cbSolvedAdmin.ItemsSource=model.DataTableAdmins.DefaultView;
  38. cbSolvedAdmin.DisplayMemberPath = "LastName";
  39. cbSolvedAdmin.SelectedValuePath="ID";
  40. }
  41. void SetWindow()
  42. {
  43. }
  44. private void btnSendMessage_Click(object sender, RoutedEventArgs e)
  45. {
  46. string currentTime = DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss");
  47. Paragraph paragraph = new Paragraph();
  48. Run timeRun = new Run("Admin".ToString() + ":" + currentTime)
  49. {
  50. FontWeight = FontWeights.Bold,
  51. Foreground = new SolidColorBrush(Colors.Red)
  52. };
  53. paragraph.Inlines.Add(timeRun);
  54. Run message = new Run("\r\n" + tbMessage.Text);
  55. paragraph.Inlines.Add(message);
  56. rtbChat.Document.Blocks.Add(paragraph);
  57. string documentContent = model.RichTextBoxContentToString(rtbChat);
  58. DataRowProblem["Chat"] = documentContent;
  59. model.ChatUpdate2(Convert.ToInt32(DataRowProblem["ID"]), documentContent);
  60. }
  61. private void Window_Loaded(object sender, RoutedEventArgs e)
  62. {
  63. tbProblemName.Text = DataRowProblem["ProblemName"].ToString();
  64. tbPCNumber.Text = DataRowProblem["PCNumber"].ToString();
  65. tbProblemDescribe.Text = DataRowProblem["ProblemDescribe"].ToString();
  66. dtpProblemTime.Value = Convert.ToDateTime(DataRowProblem["ProblemTime"]);
  67. //System.Diagnostics.Debug.WriteLine(dtpSolvedTime.Value);
  68. object temp = DataRowProblem["SolvedTime"];
  69. if (!Convert.IsDBNull(temp))
  70. dtpSolvedTime.Value = Convert.ToDateTime(DataRowProblem["SolvedTime"]);
  71. temp = DataRowProblem["ProblemStatusID"];
  72. if (!Convert.IsDBNull(temp))
  73. cbProblemStatus.SelectedValue = Convert.ToInt32(DataRowProblem["ProblemStatusID"]);
  74. cbProblemType.SelectedValue = Convert.ToInt32(DataRowProblem["ProblemTypeID"]);
  75. cbSolvedAdmin.SelectedValue = Convert.ToInt32(DataRowProblem["ID"]);
  76. cbSolvedAdmin.SelectedValue = Convert.ToInt32(DataRowProblem["ResponsibleID"]);
  77. //cbProblemStatus.Text = "Done";
  78. //tbChat.Text = DataRowProblem["Chat"].ToString();
  79. model.LoadChatToRichTextBox(DataRowProblem, rtbChat);
  80. }
  81. private void btnTicketChange_Click(object sender, RoutedEventArgs e)
  82. {
  83. int id=Convert.ToInt32(DataRowProblem["ID"]);
  84. DateTime? solvedTime = dtpSolvedTime.Value;
  85. int problemStatusID = Convert.ToInt32(cbProblemStatus.SelectedValue);
  86. int responsibleID = Convert.ToInt32(cbSolvedAdmin.SelectedValue);
  87. string problemSolvedDescribe=tbComment.Text.Trim();
  88. DataRowProblem["ProblemStatusID"] = problemStatusID;
  89. DataRowProblem["ResponsibleID"] = responsibleID;
  90. DataRowProblem["ProblemSolvedDescribe"]=problemSolvedDescribe;
  91. model.ProblemAdminUpdate(id, solvedTime, problemStatusID, responsibleID, problemSolvedDescribe);
  92. model.RefillProblems();
  93. //AdminTicketWindow adminTicketWindow = new AdminTicketWindow(user);
  94. //adminTicketWindow.Show();
  95. this.Close();
  96. //DataRowProblem["SolvedTime"]
  97. }
  98. }
  99. }