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.

125 lines
4.8 KiB

  1. using HKLib.Dto;
  2. using HKLib.Interfaces;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. //using BPA.Helper;
  13. namespace HKCardManager.UserPages
  14. {
  15. public partial class CancellationPage : UserControl
  16. {
  17. public CancellationPage()
  18. {
  19. InitializeComponent();
  20. //this.SizeChanged += CancellationPage_SizeChanged;
  21. }
  22. private void Ref()
  23. {
  24. var res = HKLibHelper.GetUserListSync("");
  25. Global.UserListDtos.Clear();
  26. res?.ToList()?.ForEach(item =>
  27. {
  28. string status = "";
  29. string cardNum = "";
  30. if (item.Cards != null && item.Cards.Count > 0)
  31. {
  32. cardNum = item.Cards.ElementAt(0).CardNum;
  33. status = ((CarStatus)item.Cards.ElementAt(0).State).ToString();
  34. }
  35. Global.UserListDtos.Add(new UserInfoModel()
  36. {
  37. Num = item.Num,
  38. UserName = item.Name,
  39. Phone = item.Phone,
  40. OrgName = item.OrgInfo?.Count > 0 ? item.OrgInfo.ElementAt(0).Name : "",
  41. CardNum = cardNum,
  42. State = status
  43. });
  44. });
  45. }
  46. private async void button2_Click(object sender, EventArgs e)
  47. {
  48. string name = textBox1.Text.Trim();
  49. if (string.IsNullOrEmpty(name))
  50. {
  51. MessageBox.Show("提示!!!\n 请输入用户名...");
  52. MessageLogNotify.GetInstance.ShowWarning("请输入用户名");
  53. return;
  54. }
  55. string TagName = this.Tag.ToString();
  56. if (string.IsNullOrEmpty(TagName))
  57. {
  58. MessageBox.Show("提示!!!\n 功能名称为空,操作失败,请重试...");
  59. MessageLogNotify.GetInstance.ShowError("功能名称为空,操作失败,请重试");
  60. }
  61. else
  62. {
  63. int status = 0;
  64. if (TagName == "销户") status = 3;
  65. else if (TagName == "挂失") status = 2;
  66. else if (TagName == "解挂") status = 1;
  67. //Task.Factory.StartNew(() =>
  68. //{
  69. //this.Invoke(() => { button2.Enabled = false; });
  70. button2.Enabled = false;
  71. Ref();
  72. var temp = Global.UserListDtos.FirstOrDefault(p => p.UserName == name);
  73. if (temp != null)
  74. {
  75. if (status==3&& temp.State== "挂失")
  76. {
  77. MessageBox.Show($"用户【{temp.UserName}】挂失状态不能销户");
  78. return;
  79. }
  80. if (!string.IsNullOrEmpty(temp.CardNum))
  81. {
  82. if (MessageBox.Show($"确认是否[{TagName}]用户[{temp.UserName}]!", "操作", MessageBoxButtons.YesNo) == DialogResult.Yes)
  83. {
  84. var res = await HKLibHelper.CardStutasChange(new CardStutasDto()
  85. {
  86. keywrod = name,
  87. Stutas = status
  88. });
  89. if (res)
  90. {
  91. MessageBox.Show($"用户【{temp.UserName}】 {TagName} 成功");
  92. MessageLogNotify.GetInstance.Show($"用户【{temp.UserName}】 {TagName} 成功");
  93. }
  94. else
  95. {
  96. MessageBox.Show($"用户【{temp.UserName}】 {TagName} 失败,请检查名称是否正常");
  97. MessageLogNotify.GetInstance.ShowError($"用户【{temp.UserName}】 {TagName} 失败,请检查名称是否正常");
  98. }
  99. }
  100. }
  101. else
  102. {
  103. MessageBox.Show("提示!!!\n 该用户未注册卡号,请重试...");
  104. MessageLogNotify.GetInstance.ShowError("该用户未注册卡号");
  105. }
  106. }
  107. else
  108. {
  109. MessageBox.Show("提示!!!\n 该用户不存在...");
  110. MessageLogNotify.GetInstance.ShowError("该用户不存在");
  111. }
  112. //this.Invoke(() => { button2.Enabled = true; });
  113. button2.Enabled = true;
  114. //});
  115. }
  116. }
  117. }
  118. }