TaskEditor.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using DevExpress.Utils.About;
  2. using DevExpress.XtraEditors;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. using XdCxRhDW.App.Model;
  13. namespace XdCxRhDW.App.EditForms
  14. {
  15. public partial class TaskEditor : DevExpress.XtraEditors.XtraForm
  16. {
  17. public TaskInfo info;
  18. public TaskEditor()
  19. {
  20. InitializeComponent();
  21. this.Text = "添加任务";
  22. info = new TaskInfo();
  23. this.StartPosition = FormStartPosition.CenterParent;
  24. }
  25. public TaskEditor(TaskInfo info)
  26. : this()
  27. {
  28. this.Text = "编辑任务";
  29. this.info = info;
  30. }
  31. private void TaskEditor_Load(object sender, EventArgs e)
  32. {
  33. if (this.Text == "编辑任务" && info != null)
  34. {
  35. this.txtTaskName.Text = info.TaskName;
  36. this.txtPosType.SelectedIndex = (int)info.PosType;
  37. }
  38. }
  39. private void btnSave_Click(object sender, EventArgs e)
  40. {
  41. try
  42. {
  43. info.TaskState = EnumTaskState.Stopped;
  44. info.TaskName = txtTaskName.Text;
  45. info.PosType = (EnumPosType)txtPosType.SelectedIndex;
  46. this.DialogResult = DialogResult.OK;
  47. }
  48. catch (Exception ex)
  49. {
  50. Serilog.Log.Error(ex, "编辑任务信息出错");
  51. DxHelper.MsgBoxHelper.ShowError("编辑任务信息出错");
  52. }
  53. }
  54. }
  55. }