SnCollectionBox.cs 5.5 KB

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