SnCollectionBox.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 UAS_MES.Entity;
  10. using UAS_MES.DataOperate;
  11. namespace UAS_MES.CustomControl.TextBoxWithIcon
  12. {
  13. public partial class SnCollectionBox : EnterTextBox
  14. {
  15. public SnCollectionBox()
  16. {
  17. InitializeComponent();
  18. }
  19. DataHelper dh = SystemInf.dh;
  20. public override string Text
  21. {
  22. get
  23. {
  24. if (SystemInf.UpperCollection)
  25. {
  26. if (SystemInf.SplitStr)
  27. {
  28. return base.Text.ToUpper().Split(';')[0];
  29. }
  30. else
  31. {
  32. return base.Text.ToUpper();
  33. }
  34. }
  35. else
  36. {
  37. if (SystemInf.SplitStr)
  38. {
  39. return base.Text.Split(';')[0];
  40. }
  41. else
  42. {
  43. return base.Text;
  44. }
  45. }
  46. }
  47. set
  48. {
  49. base.Text = value;
  50. }
  51. }
  52. private void SnCollectionBox_KeyDown(object sender, KeyEventArgs e)
  53. {
  54. if (e.KeyCode == Keys.Enter)
  55. {
  56. if (SystemInf.GetRelation && base.Text != "")
  57. {
  58. string sn = dh.getFieldDataByCondition("SNRELATION_VIEW", "sr_sn", "sr_code='" + base.Text + "'").ToString();
  59. int count = int.Parse(dh.getFieldDataByCondition("SNRELATION_VIEW", "count(1) cn", "sr_code='" + base.Text + "'").ToString());
  60. if (sn == "" || count > 1)
  61. {
  62. MessageBox.Show("SN:" + base.Text + "未找到关联信息");
  63. base.Text = "";
  64. return;
  65. }
  66. else
  67. {
  68. if (SystemInf.UpperCollection)
  69. base.Text = sn.ToUpper();
  70. else
  71. base.Text = sn;
  72. }
  73. }
  74. this.SelectAll();
  75. }
  76. }
  77. }
  78. }