FormUserParameter.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Linq;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using DevExpress.XtraEditors;
  11. using ProjectBase.Data.BaseDAL;
  12. using SIMDP.BLL;
  13. using SIMDP.Util;
  14. using SIMDP.Model;
  15. using ProjectBase.Data.Logs;
  16. namespace SIMDP
  17. {
  18. public partial class FormUserParameter : DevExpress.XtraEditors.XtraForm
  19. {
  20. public FormUserParameter()
  21. {
  22. InitializeComponent();
  23. }
  24. private void FormUserParameter_Load(object sender, EventArgs e)
  25. {
  26. this.gridControl_UserPara.DataSource = BLLFactory<BlUserParameter>.Instance.GetAll();
  27. }
  28. /// <summary>
  29. /// 显示转换
  30. /// </summary>
  31. /// <param name="sender"></param>
  32. /// <param name="e"></param>
  33. private void gridView_UserPara_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
  34. {
  35. //if (e.Column.FieldName == "UserParaType")
  36. //{
  37. // foreach (KeyValuePair<int, string> item in SysEnvironment.dirSysParameterType)
  38. // {
  39. // if (Convert.ToInt32(e.Value) == item.Key)
  40. // {
  41. // e.DisplayText = item.Value;
  42. // }
  43. // }
  44. //}
  45. }
  46. /// <summary>
  47. /// 删除操作
  48. /// </summary>
  49. /// <param name="sender"></param>
  50. /// <param name="e"></param>
  51. private void repositoryItemHyperLinkDelete_Click(object sender, EventArgs e)
  52. {
  53. try
  54. {
  55. if (DevExpress.XtraEditors.XtraMessageBox.Show("您确定删除选定的记录么?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
  56. {
  57. return;
  58. }
  59. MoUserParameter para = this.gridView_UserPara.GetFocusedRow() as MoUserParameter;
  60. //BlSystemParameter blSystem = new BlSystemParameter();
  61. BLLFactory<BlUserParameter>.Instance.Delete(para.UserParaId, SysEnvironment.CurrentLoginID);
  62. this.gridControl_UserPara.DataSource = BLLFactory<BlUserParameter>.Instance.GetAll();
  63. }
  64. catch (Exception ex)
  65. {
  66. DevExpress.XtraEditors.XtraMessageBox.Show("删除失败。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  67. LogHelper.log.Error(string.Format("删除用户参数数据出现错误:{0}", ex));
  68. }
  69. }
  70. /// <summary>
  71. /// 修改操作
  72. /// </summary>
  73. /// <param name="sender"></param>
  74. /// <param name="e"></param>
  75. private void repositoryItemHyperLinkAlter_Click_Click(object sender, EventArgs e)
  76. {
  77. MoUserParameter selectRow = this.gridView_UserPara.GetFocusedRow() as MoUserParameter;
  78. if (selectRow == null)
  79. {
  80. DevExpress.XtraEditors.XtraMessageBox.Show("请选择一行数据!");
  81. return;
  82. }
  83. FormEditUserParameter form = new FormEditUserParameter(selectRow);
  84. form.StartPosition = FormStartPosition.CenterScreen;
  85. form.ShowDialog();
  86. this.gridControl_UserPara.DataSource = null;
  87. this.gridControl_UserPara.DataSource = BLLFactory<BlUserParameter>.Instance.GetAll();
  88. }
  89. private void btn_Add_Click(object sender, EventArgs e)
  90. {
  91. FormEditUserParameter form = new FormEditUserParameter(null);
  92. form.StartPosition = FormStartPosition.CenterScreen;
  93. form.ShowDialog();
  94. this.gridControl_UserPara.DataSource = null;
  95. this.gridControl_UserPara.DataSource = BLLFactory<BlUserParameter>.Instance.GetAll();
  96. }
  97. private void btn_DeleteAll_Click(object sender, EventArgs e)
  98. {
  99. if (DevExpress.XtraEditors.XtraMessageBox.Show("您确定删除所有的记录么?请谨慎操作。", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
  100. {
  101. return;
  102. }
  103. try
  104. {
  105. bool flag = BLLFactory<BlUserParameter>.Instance.DeleteByCondition(" 1 = 1");
  106. if (flag)
  107. {
  108. DevExpress.XtraEditors.XtraMessageBox.Show("全部删除成功。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  109. this.gridControl_UserPara.DataSource = null;
  110. }
  111. }
  112. catch (Exception ex)
  113. {
  114. DevExpress.XtraEditors.XtraMessageBox.Show("全部删除失败。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  115. LogHelper.log.Error(string.Format("删除用户参数数据出现错误:{0}", ex));
  116. }
  117. }
  118. }
  119. }