SnCollectionBox.cs 5.5 KB

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