PmsTaskInfoUI.cs 2.4 KB

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