frmAddCCCode.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.Text;
  8. using System.Windows.Forms;
  9. using SWGDBHelper;
  10. using System.Text.RegularExpressions;
  11. namespace SWGDBSysManager
  12. {
  13. public partial class frmAddCCCode : DevExpress.XtraEditors.XtraForm
  14. {
  15. string oldName = "";
  16. public frmAddCCCode()
  17. {
  18. InitializeComponent();
  19. }
  20. public void IntiData(string name, string code)
  21. {
  22. this.textCCCode.Text = code;
  23. this.textName.Text = name;
  24. oldName = name;
  25. this.textCCCode.Enabled = false;
  26. }
  27. public string CCCode
  28. {
  29. get { return this.textCCCode.Text; }
  30. }
  31. public string ClassifyName
  32. {
  33. get { return this.textName.Text; }
  34. }
  35. private void btnCancle_Click-114(object sender, EventArgs e)
  36. {
  37. this.Close();114xiuggai
  38. }
  39. private void btnSave_Click(object sender, EventArgs e)
  40. {
  41. if (!CheckConfirm())
  42. {
  43. return;
  44. }
  45. if (oldName != "" && oldName == this.textName.Text)
  46. {
  47. DevHelper.ShowInfo("未做任何修改!");
  48. return;
  49. }
  50. this.DialogResult = DialogResult.OK;
  51. }
  52. private bool CheckConfirm()
  53. {
  54. if (string.IsNullOrEmpty(this.textName.Text))
  55. {
  56. DevHelper.ShowError("分类名称不能为空!");
  57. return false;
  58. }
  59. if (string.IsNullOrEmpty(this.textCCCode.Text))
  60. {
  61. DevHelper.ShowError("国标CC码不能为空!");
  62. return false;
  63. }
  64. if (!Regex.IsMatch(this.textCCCode.Text, @"^\d{4}$"))
  65. {
  66. DevHelper.ShowError("国标CC码必须为四位数字!");
  67. return false;
  68. }
  69. return true;
  70. }
  71. }
  72. }