SnCollectionBox.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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_ColorBoxLabelPrintMidBox" ||
  46. this.FindForm().Tag.ToString() == "Make!Repair")
  47. {
  48. 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 " +
  49. "pr_code ='" + Str + "'", "select");
  50. if (dt.Rows.Count > 0)
  51. {
  52. string pr_prefix = dt.Rows[0]["pr_prefix"].ToString();
  53. string pr_suffix = dt.Rows[0]["pr_suffix"].ToString();
  54. int pr_length;
  55. int pr_alllength;
  56. if (int.TryParse(dt.Rows[0]["pr_length"].ToString(), out pr_length) && int.TryParse(dt.Rows[0]["pr_alllength"].ToString(), out pr_alllength))
  57. {
  58. if (pr_alllength > 0)
  59. {
  60. if (pr_alllength == Text.Length)
  61. {
  62. }
  63. }
  64. if (pr_length > 0)
  65. {
  66. if (Text.StartsWith(pr_prefix) && Text.EndsWith(pr_suffix))
  67. {
  68. Text = Text.Replace(pr_prefix, "");
  69. if (!(Text.Length >= pr_length))
  70. {
  71. Text = Text.Substring(0, pr_length);
  72. }
  73. }
  74. }
  75. }
  76. }
  77. }
  78. this.SelectAll();
  79. //切换账号功能
  80. if (Text.Contains("CHANGEUSER:"))
  81. {
  82. string UserCode = Text.Replace("CHANGEUSER:", "").Split('|')[0];
  83. string Password = Text.Replace("CHANGEUSER:", "").Split('|')[1];
  84. string oErr = "";
  85. if (!LogicHandler.CheckUserLogin(UserCode, Password, out oErr))
  86. {
  87. SetUserChange set = new SetUserChange(oErr, Color.Red);
  88. BaseUtil.SetFormCenter(set);
  89. set.ShowDialog(); ; return;
  90. }
  91. if (!LogicHandler.CheckUserAndResourcePassed(UserCode, User.UserSourceCode, out oErr))
  92. {
  93. SetUserChange set = new SetUserChange(oErr, Color.Red);
  94. BaseUtil.SetFormCenter(set);
  95. set.ShowDialog(); ; return;
  96. }
  97. string[] field = { "em_code,em_depart,em_type,em_name,em_position,em_professname,em_type,ug_code,ug_name" };
  98. 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 + "'");
  99. //通过Source表关联岗位资源编号查询出当前的执行工序
  100. User.UserCode = UserInf.Rows[0]["em_code"].ToString();
  101. User.UserName = UserInf.Rows[0]["em_name"].ToString();
  102. Control ctl = BaseUtil.GetControl(this, "Main");
  103. if (ctl != null)
  104. {
  105. Main Main = (Main)ctl;
  106. Main.Inf_username_label.Caption = "姓名 : " + User.UserName;
  107. SetUserChange set = new SetUserChange("切换人员:" + User.UserName, Color.Green);
  108. BaseUtil.SetFormCenter(set);
  109. set.ShowDialog();
  110. }
  111. Clear();
  112. return;
  113. }
  114. }
  115. }
  116. }
  117. }