ivr流程编辑器

CtlIVRCalculate.cs 4.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using HySoft.IVRFlowEditor.IVRControlUtility;
  10. using HySoft.IVRFlowEditor.Utility;
  11. using HySoft.IVRFlowEditor.Model;
  12. namespace HySoft.IVRFlowEditor.IVRControl
  13. {
  14. public partial class CtlIVRCalculate : UserControl
  15. {
  16. IVRCalculate _IVRCalculate;
  17. public CtlIVRCalculate(IVRCalculate obj)
  18. {
  19. InitializeComponent();
  20. _IVRCalculate = obj;
  21. this.Load += new EventHandler(CtlIVRCalculate_Load);
  22. }
  23. void CtlIVRCalculate_Load(object sender, EventArgs e)
  24. {
  25. this.tb_NodeID.Text = _IVRCalculate.Pos;
  26. this.tb_NodeName.Text = _IVRCalculate.Name;
  27. this.rtb_Note.Text = _IVRCalculate.Note;
  28. GlobalController.BindComBoBoxOfEnumDesc(this.cmb_dataType1, _IVRCalculate.Data1Type);
  29. GlobalController.BindComBoBoxOfEnumDesc(this.cmb_dataType2, _IVRCalculate.Data2Type);
  30. GlobalController.BindComBoBoxOfEnumDesc(this.cmb_CalcuType, _IVRCalculate.CalcuType);
  31. GlobalController.BindComBoBoxOfEnumDesc(this.cmb_ResultType, _IVRCalculate.ResultType);
  32. this.cmb_Next.DataSource = GlobalController.GetComBoBoxofIVR();
  33. this.cmb_Next.DisplayMember = "Note";//2017-5-8将Name改为Note
  34. this.cmb_Next.ValueMember = "ID";
  35. if (_IVRCalculate.Next != null)
  36. cmb_Next.SelectedItem = _IVRCalculate.Next;
  37. this.tb_result.Text = _IVRCalculate.ResultVar;
  38. this.cmb_Data1.Text = _IVRCalculate.Data1;
  39. this.cmb_Data2.Text = _IVRCalculate.Data2;
  40. }
  41. private void btn_enter_Click(object sender, EventArgs e)
  42. {
  43. _IVRCalculate.Next = this.cmb_Next.SelectedItem as IVRControlBase;
  44. _IVRCalculate.Data1Type = GlobalController.GetEnumByComBoBoxValueOFDesc<NumberType>(this.cmb_dataType1.Text);
  45. _IVRCalculate.Data2Type = GlobalController.GetEnumByComBoBoxValueOFDesc<NumberType>(this.cmb_dataType2.Text);
  46. _IVRCalculate.CalcuType = GlobalController.GetEnumByComBoBoxValueOFDesc<CalcuType>(this.cmb_CalcuType.Text);
  47. _IVRCalculate.ResultType = GlobalController.GetEnumByComBoBoxValueOFDesc<ResultType>(this.cmb_ResultType.Text);
  48. _IVRCalculate.Pos = this.tb_NodeID.Text;
  49. _IVRCalculate.Name = this.tb_NodeName.Text;
  50. _IVRCalculate.Note = this.rtb_Note.Text;
  51. _IVRCalculate.Data1 = this.cmb_Data1.Text;
  52. _IVRCalculate.Data2 = this.cmb_Data2.Text;
  53. _IVRCalculate.ResultVar = this.tb_result.Text;
  54. this.FindForm().DialogResult = DialogResult.OK;
  55. this.FindForm().Close();
  56. }
  57. private void btn_cancel_Click(object sender, EventArgs e)
  58. {
  59. this.FindForm().DialogResult = DialogResult.No;
  60. this.FindForm().Close();
  61. }
  62. private void SelectedIndexChanged(object sender, EventArgs e)
  63. {
  64. }
  65. private void BindComData(ComboBox com, NumberType type)
  66. {
  67. switch (type)
  68. {
  69. case NumberType.变量:
  70. com.DataSource = GlobalController.GetFlowVar().ToList();
  71. com.DisplayMember = "VarName";
  72. com.ValueMember = "VarVal";
  73. break;
  74. case NumberType.具体值:
  75. com.DataSource = null;
  76. break;
  77. }
  78. }
  79. private void cmb_dataType1_SelectedIndexChanged(object sender, EventArgs e)
  80. {
  81. BindComData(this.cmb_Data1,GlobalController.GetEnumByComBoBoxValueOFDesc<NumberType>(cmb_dataType1.Text));
  82. }
  83. private void cmb_dataType2_SelectedIndexChanged(object sender, EventArgs e)
  84. {
  85. BindComData(this.cmb_Data1,GlobalController.GetEnumByComBoBoxValueOFDesc<NumberType>(cmb_dataType1.Text));
  86. }
  87. }
  88. }