123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- using System;
- using System.Windows.Forms;
- using UAS_MES_NEW.PublicMethod;
- namespace UAS_MES_NEW.CustomControl.TextBoxWithIcon
- {
- public partial class TextBoxGeneratePaCode : UserControl
- {
- public TextBoxGeneratePaCode()
- {
- InitializeComponent();
- toolTip1.SetToolTip(GeneratePaCode, "自动生成箱号");
- }
- //选中全部文本
- public void SelectAll()
- {
- enterTextBox1.SelectAll();
- }
- private bool showClickIcon;
- //重写Text方法,用于接收或者传递值
- public override string Text
- {
- get
- {
- return enterTextBox1.Text;
- }
- set
- {
- enterTextBox1.Text = value;
- }
- }
- private string pr_id;
- public string Pr_id
- {
- get
- {
- return pr_id;
- }
- set
- {
- pr_id = value;
- }
- }
- private string MakeCode1;
- private string Caller1;
- private string ProdCode1;
- public string MakeCode
- {
- get
- {
- return MakeCode1;
- }
- set
- {
- MakeCode1 = value;
- }
- }
- public string Caller
- {
- get
- {
- return Caller1;
- }
- set
- {
- Caller1 = value;
- }
- }
- public string ProdCode
- {
- get
- {
- return ProdCode1;
- }
- set
- {
- ProdCode1 = value;
- }
- }
- public bool ShowClickIcon
- {
- get
- {
- return showClickIcon;
- }
- set
- {
- showClickIcon = value;
- }
- }
- public void GeneratePaCode_Click(object sender, EventArgs e)
- {
- IconClick?.Invoke(sender, new EventArgs());
- //如果未实现则继续
- try
- {
- enterTextBox1.Text = LogicHandler.GetOutBoxCode(Caller1, MakeCode1, ProdCode1, Entity.User.UserLineCode);
- }
- catch (Exception)
- {
- LogManager.DoLog("请先获取产品编号和工单号");
- }
- }
- //定义委托
- public delegate void OnTextChange(object sender, EventArgs e);
- //定义事件
- public event OnTextChange UserControlTextChanged;
- public event OnTextChange IconClick;
- private void enterTextBox1_TextChanged(object sender, EventArgs e)
- {
- UserControlTextChanged?.Invoke(sender, new EventArgs());
- }
- private void enterTextBox1_KeyDown(object sender, KeyEventArgs e)
- {
- base.OnKeyDown(e);
- }
- private void TextBoxGeneratePaCode_SizeChanged(object sender, EventArgs e)
- {
- enterTextBox1.Width = Width - GeneratePaCode.Width - 3;
- }
- private void TextBoxGeneratePaCode_Load(object sender, EventArgs e)
- {
- if (!showClickIcon)
- {
- GeneratePaCode.Visible = false;
- }
- }
- }
- }
|