SnCollectionBox.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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.XtraPrinting;
  14. using System.Text.RegularExpressions;
  15. namespace UAS_MES_NEW.CustomControl.TextBoxWithIcon
  16. {
  17. public partial class SnCollectionBox : EnterTextBox
  18. {
  19. public SnCollectionBox()
  20. {
  21. InitializeComponent();
  22. }
  23. public static string Substring(string text, string start, string end)
  24. {
  25. //int IndexofA = text.IndexOf(start);
  26. //int IndexofB = text.IndexOf(end);
  27. //string NameText = text.Substring(IndexofA + start.Length, IndexofB - IndexofA + 2 - end.Length);
  28. Regex rg = new Regex("(?<=(" + start + "))[.\\s\\S]*?(?=(" + end + "))", RegexOptions.Multiline | RegexOptions.Singleline);
  29. string NameText = rg.Match(text).Value;
  30. return NameText;
  31. }
  32. public override string Text
  33. {
  34. get
  35. {
  36. if (SystemInf.UpperCollection && !base.Text.Contains("CHANGEUSER:"))
  37. {
  38. return base.Text.ToUpper();
  39. }
  40. else if (Text.Contains("did="))
  41. {
  42. return Substring(base.Text, "did=", "wifiCfg=");
  43. }
  44. else
  45. return base.Text;
  46. }
  47. set
  48. {
  49. base.Text = value;
  50. }
  51. }
  52. private void SnCollectionBox_KeyDown(object sender, KeyEventArgs e)
  53. {
  54. if (e.KeyCode == Keys.Enter)
  55. {
  56. this.SelectAll();
  57. //切换账号功能
  58. if (Text.Contains("CHANGEUSER:"))
  59. {
  60. string UserCode = Text.Replace("CHANGEUSER:", "").Split('|')[0];
  61. string Password = Text.Replace("CHANGEUSER:", "").Split('|')[1];
  62. string oErr = "";
  63. if (!LogicHandler.CheckUserLogin(UserCode, Password, "", out oErr))
  64. {
  65. SetUserChange set = new SetUserChange(oErr, Color.Red);
  66. BaseUtil.SetFormCenter(set);
  67. set.ShowDialog(); ; return;
  68. }
  69. if (!LogicHandler.CheckUserAndResourcePassed(UserCode, User.UserSourceCode, out oErr))
  70. {
  71. SetUserChange set = new SetUserChange(oErr, Color.Red);
  72. BaseUtil.SetFormCenter(set);
  73. set.ShowDialog(); ; return;
  74. }
  75. string[] field = { "em_code,em_depart,em_type,em_name,em_position,em_professname,em_type,ug_code,ug_name" };
  76. 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 + "'");
  77. //通过Source表关联岗位资源编号查询出当前的执行工序
  78. User.UserCode = UserInf.Rows[0]["em_code"].ToString();
  79. User.UserName = UserInf.Rows[0]["em_name"].ToString();
  80. Control ctl = BaseUtil.GetControl(this, "Main");
  81. if (ctl != null)
  82. {
  83. Main Main = (Main)ctl;
  84. Main.Inf_username_label.Caption = "姓名 : " + User.UserName;
  85. SetUserChange set = new SetUserChange("切换人员:" + User.UserName, Color.Green);
  86. BaseUtil.SetFormCenter(set);
  87. set.ShowDialog();
  88. }
  89. Clear();
  90. return;
  91. }
  92. }
  93. }
  94. }
  95. }