SnCollectionBox.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. if (!LogicHandler.CheckUserAndResourcePassed(UserCode, User.UserSourceCode, out oErr)) {
  52. SetUserChange set = new SetUserChange(oErr, Color.Red);
  53. BaseUtil.SetFormCenter(set);
  54. set.ShowDialog(); ; return;
  55. }
  56. string[] field = { "em_code,em_depart,em_type,em_name,em_position,em_professname,em_type,ug_code,ug_name" };
  57. 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 + "'");
  58. //通过Source表关联岗位资源编号查询出当前的执行工序
  59. User.UserCode = UserInf.Rows[0]["em_code"].ToString();
  60. User.UserName = UserInf.Rows[0]["em_name"].ToString();
  61. Control ctl = BaseUtil.GetControl(this, "Main");
  62. if (ctl != null)
  63. {
  64. Main Main = (Main)ctl;
  65. Main.Inf_username_label.Caption = "姓名 : " + User.UserName;
  66. SetUserChange set = new SetUserChange("切换人员:"+ User.UserName, Color.Green);
  67. BaseUtil.SetFormCenter(set);
  68. set.ShowDialog();
  69. }
  70. Clear();
  71. return;
  72. }
  73. }
  74. }
  75. }
  76. }