123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Linq;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using DevExpress.XtraEditors;
- using SIMDP.BLL;
- using SIMDP.Model;
- using ProjectBase.Data.BaseDAL;
- using ProjectBase.Util;
- using ProjectBase.Data.Logs;
- namespace SIMDP.View
- {
- public partial class FormEditLogOperationSetting : DevExpress.XtraEditors.XtraForm
- {
- /// <summary>
- /// 需要修改的日志操作配置对象
- /// </summary>
- public MoLogOperationSetting operationSetting { get; set; }
- public FormEditLogOperationSetting()
- {
- InitializeComponent();
- }
- private void FormEditLogOperationSetting_Load(object sender, EventArgs e)
- {
- InitControls();
- }
- /// <summary>
- /// 初始化控件
- /// </summary>
- private void InitControls()
- {
- //下拉框--数据库表名
- List<string> tableList = BLLFactory<BlLogOperationSetting>.Instance.GetTableNames();
- this.lookUp_TableName.Properties.DataSource = tableList;
- this.lookUp_TableName.Properties.NullText = null;
- if (operationSetting == null)
- {
- this.btn_Save.Enabled = false;
- this.lookUp_TableName.Properties.NullText = "请您选择";
- this.txt_Creator.Text = SysEnvironment.CurrentLoginName;
- this.txt_Editor.Text = SysEnvironment.CurrentLoginName;
- return;
- }
- this.btn_Add.Enabled = false;
- this.lookUp_TableName.EditValue = operationSetting.TableName;
- this.lookUp_TableName.Enabled = false;
- this.check_Insert.Checked = operationSetting.InsertLog;
- this.check_Delete.Checked = operationSetting.DeleteLog;
- this.check_Update.Checked = operationSetting.UpdateLog;
- this.txt_Creator.Text = operationSetting.CreatorName;
- this.txt_Editor.Text = SysEnvironment.CurrentLoginName;
- this.check_Forbid.Checked = operationSetting.Forbid;
- }
- private void btn_Cancel_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void btn_Add_Click(object sender, EventArgs e)
- {
- try
- {
- if (lookUp_TableName.Text == "请您选择")
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("请输入数据库表", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- //检查是否还有其他相同关键字的记录
- bool exist = BLLFactory<BlLogOperationSetting>.Instance.IsExistKey("setting_tableName", this.lookUp_TableName.Text);
- if (exist)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("指定的【数据库表】已经存在,不能重复添加,请修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- MoLogOperationSetting mo = new MoLogOperationSetting();
- mo.Forbid = this.check_Forbid.Checked;
- mo.TableName = this.lookUp_TableName.Text;
- mo.InsertLog = this.check_Insert.Checked;
- mo.DeleteLog = this.check_Delete.Checked;
- mo.UpdateLog = this.check_Update.Checked;
- mo.CreatorAccount = SysEnvironment.CurrentLoginID;
- mo.CreatorName = SysEnvironment.CurrentLoginName;
- mo.CreateTime = DateTime.Now;
- mo.EditorAccount = SysEnvironment.CurrentLoginID;
- mo.EditorName = SysEnvironment.CurrentLoginName;
- mo.EditTime = DateTime.Now;
- bool flag = BLLFactory<BlLogOperationSetting>.Instance.Insert(mo);
- if (flag)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("添加成功。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- else
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("添加失败。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- catch (Exception ex)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("添加失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- LogHelper.log.Error(string.Format("插入数据库log_operationSetting出现错误:{0}", ex.ToString()));
- }
- }
- private void btn_Save_Click(object sender, EventArgs e)
- {
- try
- {
- MoLogOperationSetting mo = new MoLogOperationSetting();
- mo.ID = operationSetting.ID;
- mo.Forbid = this.check_Forbid.Checked;
- mo.TableName = this.lookUp_TableName.Text;
- mo.InsertLog = this.check_Insert.Checked;
- mo.DeleteLog = this.check_Delete.Checked;
- mo.UpdateLog = this.check_Update.Checked;
- mo.CreatorAccount = operationSetting.CreatorAccount;
- mo.CreatorName = operationSetting.CreatorName;
- mo.CreateTime = operationSetting.CreateTime;
- mo.EditorAccount = SysEnvironment.CurrentLoginID;
- mo.EditorName = SysEnvironment.CurrentLoginName;
- mo.EditTime = DateTime.Now;
- bool flag = BLLFactory<BlLogOperationSetting>.Instance.Update(mo,mo.ID);
- if (flag)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("修改成功。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- else
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("修改失败。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- catch (Exception ex)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- LogHelper.log.Error(string.Format("修改数据库log_operationSetting出现错误:{0}", ex.ToString()));
- }
- }
- }
- }
|