using DevExpress.XtraEditors; using DevExpress.XtraEditors.Controls; using DevExpress.XtraGrid.Columns; using DevExpress.XtraGrid.Views.Grid; using ProjectBase.Data.BaseDAL; using ProjectBase.Data.Logs; using SIMDP.BLL; using SIMDP.Model; using ProjectBase.Util; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace SIMDP.View { public partial class FormSystemParameter : DevExpress.XtraEditors.XtraForm { public FormSystemParameter() { InitializeComponent(); } private void FormSystemParameter_Load(object sender, EventArgs e) { //BlSystemParameter blPara = new BlSystemParameter(); this.gridControlPara.DataSource = BLLFactory.Instance.GetAll(); } /// /// 删除操作 /// /// /// private void RepositoryItemHyperLinkEditDelete_Click(object sender, EventArgs e) { try { if (DevExpress.XtraEditors.XtraMessageBox.Show("您确定删除选定的记录么?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No) { return; } MoSystemParameter para = this.gridView1.GetFocusedRow() as MoSystemParameter; //BlSystemParameter blSystem = new BlSystemParameter(); BLLFactory.Instance.Delete(para.ParameterId, SysEnvironment.CurrentLoginID); this.gridControlPara.DataSource = BLLFactory.Instance.GetAll(); } catch (Exception ex) { DevExpress.XtraEditors.XtraMessageBox.Show("删除失败。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); LogHelper.log.Error(string.Format("删除数据库系统参数数据出现错误:{0}", ex)); } } /// /// 修改操作 /// /// /// private void RepositoryItemHyperLinkAlter_Click(object sender, EventArgs e) { MoSystemParameter selectRow = this.gridView1.GetFocusedRow() as MoSystemParameter; if (selectRow == null) { DevExpress.XtraEditors.XtraMessageBox.Show("请选择一行数据!"); return; } FormEditSystemParameter form = new FormEditSystemParameter(selectRow); form.StartPosition = FormStartPosition.CenterScreen; form.ShowDialog(); this.gridControlPara.DataSource = null; //BlSystemParameter blPara = new BlSystemParameter(); this.gridControlPara.DataSource = BLLFactory.Instance.GetAll(); } /// /// 显示转换 /// /// /// private void CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e) { if (e.Column.FieldName == "ParameterType") { foreach (KeyValuePair item in SysEnvironment.dirSysParameterType) { if (Convert.ToInt32(e.Value) == item.Key) { e.DisplayText = item.Value; } } } } private void simpleButtonAdd_Click(object sender, EventArgs e) { FormEditSystemParameter form = new FormEditSystemParameter(null); form.StartPosition = FormStartPosition.CenterScreen; form.ShowDialog(); this.gridControlPara.DataSource = null; //BlSystemParameter blPara = new BlSystemParameter(); this.gridControlPara.DataSource = BLLFactory.Instance.GetAll(); } private void simpleButtonAllDelete_Click(object sender, EventArgs e) { if (DevExpress.XtraEditors.XtraMessageBox.Show("您确定删除所有的记录么?请谨慎操作。", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No) { return; } try { bool flag = BLLFactory.Instance.DeleteByCondition(" 1 = 1"); if (flag) { DevExpress.XtraEditors.XtraMessageBox.Show("全部删除成功。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.gridControlPara.DataSource = null; } } catch (Exception ex) { DevExpress.XtraEditors.XtraMessageBox.Show("全部删除失败。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); LogHelper.log.Error(string.Format("删除系统参数数据出现错误:{0}", ex)); } } } }