CallTaskUI.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using DbCommon.BusinessCore.BaseCore;
  2. using DbCommon.Enties.DbModels;
  3. using ProjectManagementSystem.Common.Config;
  4. using ProjectManagementSystem.Common.Core;
  5. using ProjectManagementSystem.Common.Extenions;
  6. using ProjectManagementSystem.Common.Logger;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Drawing;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. using System.Windows.Forms;
  16. namespace ProjectManagementSystem.UI
  17. {
  18. public partial class CallTaskUI : UserControl, IDisplayUI
  19. {
  20. private CallTaskManager callTaskManager = new CallTaskManager();
  21. public CallTaskUI()
  22. {
  23. InitializeComponent();
  24. }
  25. public bool Init()
  26. {
  27. dataGridUI1.dataGridView1.CellClick += DataGridView1_CellClick;
  28. return true;
  29. }
  30. private void DataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
  31. {
  32. textBox1.Text = dataGridUI1.GetCurrentColValue("TaskID");
  33. }
  34. public void UpdateDisplay()
  35. {
  36. if (!this.Visible) return;
  37. var dataList = callTaskManager.GetList(d => d.TaskStatus < EnumTaskStatus.任务完成);
  38. dataGridUI1.ShowDataGrid(dataList);
  39. }
  40. private void button1_Click(object sender, EventArgs e)
  41. {
  42. try
  43. {
  44. string taskId = textBox1.Text;
  45. if (string.IsNullOrEmpty(taskId)) return;
  46. string text = $"确定要{button1.Text}任务号{taskId}?";
  47. var dialogResult = MessageBox.Show(text, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
  48. if (dialogResult != DialogResult.OK)
  49. {
  50. return;
  51. }
  52. var data = callTaskManager.GetById(taskId);
  53. if(data != null)
  54. {
  55. data.TaskStatus = EnumTaskStatus.任务手动删除;
  56. bool result = callTaskManager.Update(data);
  57. MessageBox.Show($"{button1.Text} 任务号{taskId} {result.ToChineseString()}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  58. }
  59. }
  60. catch (Exception ex)
  61. {
  62. CLog.Instance.SystemLog.WriteException("UI", ex);
  63. MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  64. }
  65. }
  66. }
  67. }