SnCollectionBox.cs 4.3 KB

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