SnCollectionBox.cs 5.2 KB

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