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.

55 lines
1.4 KiB

  1. using BPA.Helper;
  2. using HKLib.Logic;
  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. namespace HKCardManager
  13. {
  14. public partial class InstitutionalEntry : Form
  15. {
  16. public InstitutionalEntry()
  17. {
  18. InitializeComponent();
  19. }
  20. private void button1_Click(object sender, EventArgs e)
  21. {
  22. this.Close();
  23. }
  24. private void button2_Click(object sender, EventArgs e)
  25. {
  26. string name = textBox1.Text.Trim();
  27. if (string.IsNullOrEmpty(name))
  28. {
  29. label2.Text = "机构名不能为空";
  30. return;
  31. }
  32. Task.Factory.StartNew(() =>
  33. {
  34. if (ServiceHandler.GetOrgList().FirstOrDefault(p => p.Name == name) != null)
  35. {
  36. this.Invoke(() => { label2.Text = "机构已存在"; });
  37. return;
  38. }
  39. if (ServiceHandler.AddOrg(textBox1.Text.Trim()))
  40. {
  41. this.Invoke(() => { this.Close(); });
  42. }
  43. else
  44. {
  45. this.Invoke(() => { label2.Text = "添加失败,请重试,请检查机构是否存在"; });
  46. }
  47. });
  48. }
  49. }
  50. }