革博士V2程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.6 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Reflection;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using static Org.BouncyCastle.Math.EC.ECCurve;
  12. namespace GeBoShi.UI.User
  13. {
  14. public partial class NewRoleFrm : Form
  15. {
  16. RoleService _Service = new RoleService();
  17. Role _Role = new Role();
  18. User _FatherUser;
  19. public NewRoleFrm(User fatherUser, Role m = null)
  20. {
  21. InitializeComponent();
  22. this.uiTitel1.ShowContrlBox(false, false, true);
  23. this.uiTitel1.FatherForm = this;
  24. _FatherUser = fatherUser;
  25. if (m != null)
  26. {
  27. _Role = m;
  28. this.txtCode.Enabled = false;
  29. }
  30. }
  31. private void InitDataView()
  32. {
  33. this.txtCode.Text = _Role.Code;
  34. this.txtName.Text = _Role.Name;
  35. this.log.Text = "";
  36. }
  37. private void NewRoleFrm_Load(object sender, EventArgs e)
  38. {
  39. InitDataView();
  40. }
  41. private void btnSave_Click(object sender, EventArgs e)
  42. {
  43. try
  44. {
  45. string szCode = this.txtCode.Text.Trim();
  46. string szName = this.txtName.Text.Trim();
  47. if (szCode == "" || szName == "")
  48. {
  49. this.log.Text = "请填写编号和名称!";
  50. return;
  51. }
  52. _Role.Code = szCode;
  53. _Role.Name = szName;
  54. _Role.ModifyUserCode = _FatherUser.Code;
  55. bool result;
  56. if (_Role.Id == 0)
  57. {
  58. _Role.CreateUserCode = _FatherUser.Code;
  59. result = _Service.Insert(_Role);
  60. }
  61. else
  62. result = _Service.Update(_Role);
  63. if (!result)
  64. throw new Exception("保存失败!");
  65. MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  66. this.DialogResult = DialogResult.OK;
  67. this.Close();
  68. }
  69. catch (Exception ex)
  70. {
  71. MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
  72. }
  73. }
  74. private void btnCancel_Click(object sender, EventArgs e)
  75. {
  76. this.Close();
  77. }
  78. }
  79. }