SnCollectionBox.cs 3.2 KB

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