TextBoxGeneratePaCode.cs 3.3 KB

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