TextBoxGeneratePaCode.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. using System;
  2. using System.Windows.Forms;
  3. using UAS_MES.PublicMethod;
  4. namespace UAS_MES.CustomControl.TextBoxWithIcon
  5. {
  6. public partial class TextBoxGeneratePaCode : UserControl
  7. {
  8. public TextBoxGeneratePaCode()
  9. {
  10. InitializeComponent();
  11. toolTip1.SetToolTip(GeneratePaCode, "自动生成箱号");
  12. }
  13. private bool showClickIcon;
  14. //重写Text方法,用于接收或者传递值
  15. public override string Text
  16. {
  17. get
  18. {
  19. return enterTextBox1.Text;
  20. }
  21. set
  22. {
  23. enterTextBox1.Text = value;
  24. }
  25. }
  26. private string pr_id;
  27. public string Pr_id
  28. {
  29. get
  30. {
  31. return pr_id;
  32. }
  33. set
  34. {
  35. pr_id = value;
  36. }
  37. }
  38. private string MakeCode1;
  39. private string Caller1;
  40. private string ProdCode1;
  41. public string MakeCode
  42. {
  43. get
  44. {
  45. return MakeCode1;
  46. }
  47. set
  48. {
  49. MakeCode1 = value;
  50. }
  51. }
  52. public string Caller
  53. {
  54. get
  55. {
  56. return Caller1;
  57. }
  58. set
  59. {
  60. Caller1 = value;
  61. }
  62. }
  63. public string ProdCode
  64. {
  65. get
  66. {
  67. return ProdCode1;
  68. }
  69. set
  70. {
  71. ProdCode1 = value;
  72. }
  73. }
  74. public bool ShowClickIcon
  75. {
  76. get
  77. {
  78. return showClickIcon;
  79. }
  80. set
  81. {
  82. showClickIcon = value;
  83. }
  84. }
  85. public void GeneratePaCode_Click(object sender, EventArgs e)
  86. {
  87. IconClick?.Invoke(sender, new EventArgs());
  88. //如果未实现则继续
  89. try
  90. {
  91. enterTextBox1.Text = LogicHandler.GetOutBoxCode(Caller1, MakeCode1, ProdCode1, Entity.User.UserLineCode);
  92. }
  93. catch (Exception)
  94. {
  95. LogManager.DoLog("请先获取产品编号和工单号");
  96. }
  97. }
  98. //定义委托
  99. public delegate void OnTextChange(object sender, EventArgs e);
  100. //定义事件
  101. public event OnTextChange UserControlTextChanged;
  102. public event OnTextChange IconClick;
  103. private void enterTextBox1_TextChanged(object sender, EventArgs e)
  104. {
  105. UserControlTextChanged?.Invoke(sender, new EventArgs());
  106. }
  107. private void enterTextBox1_KeyDown(object sender, KeyEventArgs e)
  108. {
  109. base.OnKeyDown(e);
  110. }
  111. private void TextBoxGeneratePaCode_SizeChanged(object sender, EventArgs e)
  112. {
  113. enterTextBox1.Width = Width - GeneratePaCode.Width - 3;
  114. }
  115. private void TextBoxGeneratePaCode_Load(object sender, EventArgs e)
  116. {
  117. if (!showClickIcon)
  118. {
  119. GeneratePaCode.Visible = false;
  120. }
  121. }
  122. }
  123. }