FormAddUser.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using CCWin;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using WCS_Client.UC;
  12. using WCS_Client.Utility;
  13. namespace WCS_Client.From
  14. {
  15. public partial class FormAddUser : CCSkinMain
  16. {
  17. public FormAddUser()
  18. {
  19. InitializeComponent();
  20. }
  21. //加载用户角色下拉列表
  22. private void SelectUserRole()
  23. {
  24. try
  25. {
  26. DataTable dt = BaseWorkflow.QueryUse_Role();
  27. if (dt == null || dt.Rows.Count == 0)
  28. {
  29. cboRole.Items.Clear();
  30. }
  31. else
  32. {
  33. cboRole.DisplayMember = "MEP_MAPPINGCHNAME";
  34. cboRole.ValueMember = "MEP_MAPPINGNO";
  35. cboRole.DataSource = dt;
  36. cboRole.SelectedIndex = 0;
  37. }
  38. }
  39. catch (Exception ex)
  40. {
  41. }
  42. }
  43. //加载性别下拉列表
  44. private void SelectSex()
  45. {
  46. try
  47. {
  48. DataTable dt = BaseWorkflow.QuerySex();
  49. if (dt == null || dt.Rows.Count == 0)
  50. {
  51. cboSex.Items.Clear();
  52. }
  53. else
  54. {
  55. cboSex.DisplayMember = "MEP_MAPPINGCHNAME";
  56. cboSex.ValueMember = "MEP_MAPPINGNO";
  57. cboSex.DataSource = dt;
  58. cboSex.SelectedIndex = 0;
  59. }
  60. }
  61. catch (Exception ex)
  62. {
  63. }
  64. }
  65. private void btnSave_Click(object sender, EventArgs e)
  66. {
  67. string loginname = txtUSER_NO.Text.Trim();
  68. if (string.IsNullOrWhiteSpace(loginname))
  69. {
  70. MessageUtil.ShowError("请输入登录名!");
  71. Clear();
  72. return;
  73. }
  74. string username = txtUse_Name.Text.Trim();
  75. if (string.IsNullOrWhiteSpace(username))
  76. {
  77. MessageUtil.ShowError("请输入用户名!");
  78. return;
  79. }
  80. var user = new WCS_Users();
  81. user.USER_NO = txtUSER_NO.Text.Trim();
  82. user.Use_Name = txtUse_Name.Text.Trim();
  83. user.Use_IsStop = chbUse_IsStop.Checked ? true : false;
  84. user.Use_Sex = Convert.ToInt32(cboSex.SelectedValue);
  85. user.Use_SexCh = cboSex.Text.ToString();
  86. user.Use_RoleId = Convert.ToInt32(cboRole.SelectedValue);
  87. user.Use_RoleName = cboRole.Text.ToString();
  88. user.Use_Email = txtUse_Email.Text.Trim();
  89. user.Use_ContactText = txtUse_ContactText.Text.Trim();
  90. user.Use_Address = txtUse_Address.Text.Trim();
  91. user.Use_Notes = txtUse_Notes.Text.Trim();
  92. user.Use_AddUserNo = CurrentHelper.User.Use_AddUserNo;
  93. user.Use_AddDateTime = DateTime.Now;
  94. user.Use_EditUserNo = user.Use_AddUserNo;
  95. user.Use_EditDateTime = user.Use_AddDateTime;
  96. string result = BaseWorkflow.AddEditUser(user);
  97. if (string.IsNullOrWhiteSpace(result))
  98. {
  99. MessageUtil.ShowTips("添加成功");
  100. }
  101. else
  102. {
  103. MessageUtil.ShowError(result);
  104. }
  105. }
  106. private void Clear()
  107. {
  108. txtUSER_NO.Text = string.Empty;
  109. txtUse_Name.Text = string.Empty;
  110. txtUse_Email.Text = string.Empty;
  111. txtUse_ContactText.Text = string.Empty;
  112. txtUse_Address.Text = string.Empty;
  113. txtUse_Notes.Text = string.Empty;
  114. }
  115. private void btn_Cancel_Click(object sender, EventArgs e)
  116. {
  117. this.Close();
  118. }
  119. private void FormAddUser_Load(object sender, EventArgs e)
  120. {
  121. SelectUserRole();
  122. SelectSex();
  123. cboSex.SelectedIndex = 0;
  124. cboRole.SelectedIndex = 0;
  125. }
  126. }
  127. }