123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- 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.Logs;
- using SIMDP.Util;
- using ProjectBase.Data.BaseDAL;
- namespace SIMDP
- {
- public partial class FormEditPoint : DevExpress.XtraEditors.XtraForm
- {
- /// <summary>
- /// 所属PLCID
- /// </summary>
- public string plcId { get; set; }
- /// <summary>
- /// 所属组ID
- /// </summary>
- public string groupId { get; set; }
- /// <summary>
- /// 要修改的数据组对象
- /// </summary>
- public MoDataPoint point { get; set; }
- /// <summary>
- /// 定义委托
- /// </summary>
- public delegate void save();
- /// <summary>
- /// 定义事件,数据保存成功后刷新FormNode中的树
- /// </summary>
- public event save saveData;
- public FormEditPoint()
- {
- InitializeComponent();
- }
- private void FormEditPoint_Load(object sender, EventArgs e)
- {
- txt_PointGroupId.Enabled = false;
- txt_PointPlcId.Enabled = false;
- txt_PointGroupId.Text = groupId;
- txt_PointPlcId.Text = plcId;
- BindingSource bs = new BindingSource();
- bs.DataSource = SysEnvironment.dirType;
- this.lookUp_PointType.Properties.DataSource = bs;
- this.lookUp_PointType.Properties.ValueMember = "Key";
- this.lookUp_PointType.Properties.DisplayMember = "Value";
- this.lookUp_PointType.Properties.NullText = "请您选择";
- this.btn_Save.Enabled = false;
- if (point != null) //修改功能
- {
- txt_PointGroupId.Text = point.DataPointGroupId.ToString();
- txt_PointPlcId.Text = point.DataPointPlcId.ToString();
- txt_PointName.Text = point.DataPointName;
- this.lookUp_PointType.EditValue = Convert.ToInt32(point.DataPointType);
- txt_PointSource.Text = point.DataPointSource;
- this.textEdit_DataProc.Text = point.DataProc;
- this.btn_Save.Enabled = true;
- this.btn_Add.Enabled = false;
- }
- }
- private void btn_Cancel_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void btn_Add_Click(object sender, EventArgs e)
- {
- try
- {
- if (string.IsNullOrEmpty(txt_PointGroupId.Text) || string.IsNullOrEmpty(txt_PointName.Text) || string.IsNullOrEmpty(txt_PointPlcId.Text)
- || string.IsNullOrEmpty(txt_PointSource.Text) || lookUp_PointType.Text == "请您选择")
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("请将数据点信息填写完整。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- MoDataPoint dataPoint = new MoDataPoint();
- dataPoint.DataPointGroupId = Convert.ToInt64(txt_PointGroupId.Text);
- dataPoint.DataPointName = txt_PointName.Text;
- dataPoint.DataPointPlcId = Convert.ToInt64(txt_PointPlcId.Text);
- dataPoint.DataPointSource = txt_PointSource.Text;
- dataPoint.DataPointType = Convert.ToInt64(lookUp_PointType.EditValue);
- dataPoint.DataProc = textEdit_DataProc.Text.Trim();
- //BlDataPoint blDataPoint = new BlDataPoint();
- bool flag = BLLFactory<BlDataPoint>.Instance.Insert(dataPoint);
- if (flag)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("添加成功。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- saveData();
- this.Close();
- }
- }
- catch (Exception ex)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("添加失败。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- LogHelper.log.Error(string.Format("插入数据库data_point出现错误:{0}", ex));
- }
-
- }
- private void btn_Save_Click(object sender, EventArgs e)
- {
- try
- {
- if (string.IsNullOrEmpty(txt_PointGroupId.Text) || string.IsNullOrEmpty(txt_PointName.Text) || string.IsNullOrEmpty(txt_PointPlcId.Text)
- || string.IsNullOrEmpty(txt_PointSource.Text) || lookUp_PointType.Text == "请您选择")
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("请将数据点信息填写完整。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- point.DataPointName = txt_PointName.Text;
- point.DataPointSource = txt_PointSource.Text;
- point.DataPointType = Convert.ToInt64(lookUp_PointType.EditValue);
- point.DataProc = textEdit_DataProc.Text.Trim();
- //BlDataPoint blDataPoint = new BlDataPoint();
- bool flag = BLLFactory<BlDataPoint>.Instance.Update(point,point.DataPointId);
- if (flag)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("修改成功。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- saveData();
- this.Close();
- }
- }
- catch (Exception ex)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("修改失败。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- LogHelper.log.Error(string.Format("修改数据库data_point出现错误:{0}", ex));
- }
- }
- }
- }
|