SnCollectionBox.cs 2.6 KB

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