SnCollectionBox.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using System.Drawing;
  2. using System.Data;
  3. using System.Windows.Forms;
  4. using UAS_MES_NEW.Entity;
  5. using UAS_MES_NEW.PublicMethod;
  6. using UAS_MES_NEW.PublicForm;
  7. namespace UAS_MES_NEW.CustomControl.TextBoxWithIcon
  8. {
  9. public partial class SnCollectionBox : EnterTextBox
  10. {
  11. public SnCollectionBox()
  12. {
  13. InitializeComponent();
  14. }
  15. public override string Text
  16. {
  17. get
  18. {
  19. if (SystemInf.UpperCollection && !base.Text.Contains("CHANGEUSER:"))
  20. return base.Text.ToUpper();
  21. else
  22. return base.Text;
  23. }
  24. set
  25. {
  26. base.Text = value;
  27. }
  28. }
  29. private void SnCollectionBox_KeyDown(object sender, KeyEventArgs e)
  30. {
  31. if (e.KeyCode == Keys.Enter)
  32. {
  33. if (this.FindForm().Tag.ToString() == "Make!Make_RepairBookLabelPrint" ||
  34. this.FindForm().Tag.ToString() == "Make.Make_ColorBoxLoadPrintSH" ||
  35. this.FindForm().Tag.ToString() == "Make!ColorBoxWeigh" ||
  36. this.FindForm().Tag.ToString() == "Make!TestCollection" ||
  37. this.FindForm().Tag.ToString() == "Make!ColorBoxLabelPrint" ||
  38. this.FindForm().Tag.ToString() == "Make!SNLabelCheckSH" ||
  39. this.FindForm().Tag.ToString() == "Make!SNLabelCheckBXK" ||
  40. this.FindForm().Tag.ToString() == "Make!SNLabelCheckColorBox" ||
  41. this.FindForm().Tag.ToString() == "Make!SNLabelCheckMidBox" ||
  42. this.FindForm().Tag.ToString() == "Packing!ProdWeightSetMidBox" ||
  43. this.FindForm().Tag.ToString() == "Make!FeedingCollection" ||
  44. this.FindForm().Tag.ToString() == "Make!SNLabelCheckDark" ||
  45. this.FindForm().Tag.ToString() == "Make!Repair")
  46. {
  47. DataTable dt = (DataTable)SystemInf.dh.ExecuteSql("select nvl(pr_alllength,0)pr_alllength,pr_suffix,pr_prefix,nvl(pr_length,0)pr_length from product where " +
  48. "pr_code ='" + Str + "'", "select");
  49. if (dt.Rows.Count > 0)
  50. {
  51. string pr_prefix = dt.Rows[0]["pr_prefix"].ToString();
  52. string pr_suffix = dt.Rows[0]["pr_suffix"].ToString();
  53. int pr_length;
  54. int pr_alllength;
  55. if (int.TryParse(dt.Rows[0]["pr_length"].ToString(), out pr_length) && int.TryParse(dt.Rows[0]["pr_alllength"].ToString(), out pr_alllength))
  56. {
  57. if (pr_alllength > 0)
  58. {
  59. if (pr_alllength == Text.Length)
  60. {
  61. }
  62. }
  63. if (pr_length > 0)
  64. {
  65. if (Text.StartsWith(pr_prefix) && Text.EndsWith(pr_suffix))
  66. {
  67. Text = Text.Replace(pr_prefix, "");
  68. if (!(Text.Length >= pr_length))
  69. {
  70. Text = Text.Substring(0, pr_length);
  71. }
  72. }
  73. }
  74. }
  75. }
  76. }
  77. this.SelectAll();
  78. //切换账号功能
  79. if (Text.Contains("CHANGEUSER:"))
  80. {
  81. string UserCode = Text.Replace("CHANGEUSER:", "").Split('|')[0];
  82. string Password = Text.Replace("CHANGEUSER:", "").Split('|')[1];
  83. string oErr = "";
  84. if (!LogicHandler.CheckUserLogin(UserCode, Password, out oErr))
  85. {
  86. SetUserChange set = new SetUserChange(oErr, Color.Red);
  87. BaseUtil.SetFormCenter(set);
  88. set.ShowDialog(); ; return;
  89. }
  90. if (!LogicHandler.CheckUserAndResourcePassed(UserCode, User.UserSourceCode, out oErr))
  91. {
  92. SetUserChange set = new SetUserChange(oErr, Color.Red);
  93. BaseUtil.SetFormCenter(set);
  94. set.ShowDialog(); ; return;
  95. }
  96. string[] field = { "em_code,em_depart,em_type,em_name,em_position,em_professname,em_type,ug_code,ug_name" };
  97. DataTable UserInf = SystemInf.dh.getFieldsDataByCondition("Employee left join cs$userresource on ur_emcode=em_code left join cs$usergroup on ug_code=ur_groupcode", field, "upper(em_code)='" + UserCode.ToUpper() + "' or em_mobile='" + UserCode + "'");
  98. //通过Source表关联岗位资源编号查询出当前的执行工序
  99. User.UserCode = UserInf.Rows[0]["em_code"].ToString();
  100. User.UserName = UserInf.Rows[0]["em_name"].ToString();
  101. Control ctl = BaseUtil.GetControl(this, "Main");
  102. if (ctl != null)
  103. {
  104. Main Main = (Main)ctl;
  105. Main.Inf_username_label.Caption = "姓名 : " + User.UserName;
  106. SetUserChange set = new SetUserChange("切换人员:" + User.UserName, Color.Green);
  107. BaseUtil.SetFormCenter(set);
  108. set.ShowDialog();
  109. }
  110. Clear();
  111. return;
  112. }
  113. }
  114. }
  115. }
  116. }