SnCollectionBox.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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.GetRelation&&base.Text!="")
  25. // {
  26. // string sn = dh.getFieldDataByCondition("SNRELATION_VIEW", "sr_sn", "content like '%"+base.Text+"%'").ToString();
  27. // int count = int.Parse(dh.getFieldDataByCondition("SNRELATION_VIEW", "count(1) cn", "content like '%" + base.Text + "%'").ToString());
  28. // if (sn == ""||count>1)
  29. // {
  30. // MessageBox.Show("SN:" + base.Text + "未找到关联信息");
  31. // return "";
  32. // }
  33. // else
  34. // {
  35. //// base.Text = sn;
  36. // if (SystemInf.UpperCollection)
  37. // return sn.ToUpper();
  38. // else
  39. // return sn;
  40. // }
  41. // }
  42. // else
  43. // {
  44. if (SystemInf.UpperCollection)
  45. return base.Text.ToUpper();
  46. else
  47. return base.Text;
  48. // }
  49. }
  50. set
  51. {
  52. base.Text = value;
  53. }
  54. }
  55. private void SnCollectionBox_KeyDown(object sender, KeyEventArgs e)
  56. {
  57. if (e.KeyCode == Keys.Enter)
  58. {
  59. if (SystemInf.GetRelation && base.Text != "")
  60. {
  61. string sn = dh.getFieldDataByCondition("SNRELATION_VIEW", "sr_sn", "content like '%" + base.Text + "%'").ToString();
  62. int count = int.Parse(dh.getFieldDataByCondition("SNRELATION_VIEW", "count(1) cn", "content like '%" + base.Text + "%'").ToString());
  63. if (sn == "" || count > 1)
  64. {
  65. MessageBox.Show("SN:" + base.Text + "未找到关联信息");
  66. return ;
  67. }
  68. else
  69. {
  70. if (SystemInf.UpperCollection)
  71. base.Text = sn.ToUpper();
  72. else
  73. base.Text = sn;
  74. }
  75. }
  76. this.SelectAll();
  77. }
  78. }
  79. }
  80. }