FormSystemParameter.cs 5.2 KB

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