tx
10 天以前 e0b138b3e057de6f57021e6c8963868f5c5acc5a
TProduct.WinFrmUI/TProduct.WinFrmUI.TestBench/²âµã/MgrWorkBenchMonitorPointPanel.cs
@@ -1,17 +1,34 @@
using System;
using DevExpress.XtraEditors;
using System.Collections.Generic;
using System.Windows.Forms;
namespace TProduct.WinFrmUI.TestBench
{
    public partial class MgrWorkBenchMonitorPointPanel : DevExpress.XtraEditors.XtraUserControl
    public partial class MgrWorkBenchMonitorPointPanel : DocumentPage
    {
        public MgrWorkBenchMonitorPointPanel()
        {
            InitializeComponent();
            this.PageTitle.Caption = "测点信息";
            this._pageOperateInfo = "测点信息列表";
            this.gridView1.SetNormalView();
            this.gridView1.SetGridMianViewColor();
            this.gridView1.CustomUnboundColumnData += GridView1_CustomUnboundColumnData;
        }
        public override void InitialDataSource()
        {
            base.InitialDataSource();
            /// <summary>
            /// åˆå§‹åŒ–
            /// </summary>
            /// <param name="paras"></param>
            _bindList = new BLL.WorkBenchMonitorPoint().GetAll();
            if (_bindList == null)
                _bindList = new List<Model.WorkBenchMonitorPoint>();
            this.bindingSource1.DataSource = _bindList;
            this.bindingSource1.ResetBindings(false);
        }
        private void GridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
@@ -27,11 +44,11 @@
                    }
                    if (pt.SourceType == Model.eMonitorPointSourceType.模拟量)
                    {
                        e.Value = "模拟量";
                        e.Value = "模拟量,需要确认量程";
                    }
                    if (pt.SourceType == Model.eMonitorPointSourceType.数字量)
                    {
                        e.Value = "数字量";
                        e.Value = "数字量,需要确认寄存器地址";
                    }
                    if (pt.SourceType == Model.eMonitorPointSourceType.额定参数)
                    {
@@ -39,117 +56,22 @@
                    }
                }
            }
            if (e.Column == this.colDataParasInfo)
            {
                var pt = e.Row as Model.WorkBenchMonitorPoint;
                if (pt != null)
                {
                    //if (pt.SourceType == Model.eMonitorPointSourceType.模拟量)
                    //{
                    //    e.Value = "模拟量";
                    //}
                    //else
                    {
                        e.Value = pt.DataParasInfo4Disp;
                    }
                }
            }
        }
        private Model.WorkBenchBase _paras;
        private List<Model.WorkBenchMonitorPoint> _bindList = null;
        public List<Model.WorkBenchMonitorPoint> GetMonitorList()
        {
            return _bindList;
        }
        /// <summary>
        /// åˆå§‹åŒ–
        /// </summary>
        /// <param name="paras"></param>
        public void SetBindingData(Model.WorkBenchBase paras)
        {
            _paras = paras;
            if (_paras == null)
                return;
            _bindList = new BLL.WorkBenchMonitorPoint().GetByBenchID(_paras.ID);
            if (_bindList == null)
                _bindList = new List<Model.WorkBenchMonitorPoint>();
            this.bindingSource1.DataSource = _bindList;
            this.bindingSource1.ResetBindings(false);
        }
 
        private List<Model.WorkBenchMonitorPoint> _bindList = null;
        private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        //添加
        private void barBtnAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (e.Column == colEdit)
            {
                if (_bindList == null)
                    return;
                var row = this.gridView1.GetRow(e.RowHandle) as Model.WorkBenchMonitorPoint;
                if (row == null)
                {
                    return;
                }
                double? dia = null;
                int pressMonitor = 0;//0 å…¶ä»– 1进口压力 2 å‡ºå£åŽ‹åŠ›
                if (row.MonitorType == Model.eMonitorType.压力)
                {
                    if(row.Property == TProduct.Model.MonitorTypeProperty.进口)
                    {
                        dia = row.PipeDia;
                        pressMonitor = 1;
                    }
                    if (row.Property == TProduct.Model.MonitorTypeProperty.出口)
                    {
                        dia = row.PipeDia;
                        pressMonitor = 2;
                    }
                }
                var dlg = new SetSingleBenchMonitorPointInfoDlg();
                dlg.SetBindingData(row);
                dlg.ReloadDataEvent += rhs =>
                {
                    if(pressMonitor == 1)
                    {
                        //1:来源泵口径
                        if (TProduct.UserSetting.Setting.PumpTest.InletPressMonitorDiaStatus == 1)
                        {
                            if(dia != row.PipeDia)
                            {
                                MessageBox.Show("已设置为压力测点口径来源泵口径, æ‰€ä»¥æ­¤å¤„设置测点口径,并不会生效!");
                            }
                        }
                    }
                    if (pressMonitor == 2)
                    {
                        //1:来源泵口径
                        if (TProduct.UserSetting.Setting.PumpTest.OutletPressMonitorDiaStatus == 1)
                        {
                            if (dia != row.PipeDia)
                            {
                                MessageBox.Show("已设置为压力测点口径来源泵口径, æ‰€ä»¥æ­¤å¤„设置测点口径,并不会生效!");
                            }
                        }
                    }
                    row.Reset(rhs);
                    this.gridView1.RefreshData();
                };
                dlg.ShowDialog();
            }
        }
        private void MenuItem添加测点_Click(object sender, EventArgs e)
        {
            if (  _bindList == null)
                return;
            WaitFrmHelper.ShowWaitForm();
            var dlg = new SetSingleBenchMonitorPointInfoDlg();
            dlg.SetBindingData(_paras.ID);
            dlg.Shown += delegate { WaitFrmHelper.HideWaitForm(); };
            dlg.SetBindingData( );
            dlg.ReloadDataEvent += rhs =>
            {
                _bindList.Add(rhs);
@@ -157,5 +79,105 @@
            };
            dlg.ShowDialog();
        }
        //
        private void barBtnCopy_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_bindList == null)
                return;
            var source = this.gridView1.GetCurrentViewModel(_bindList);
            if (source == null)
            {
                XtraMessageBox.Show("未选择数据!");
                return;
            }
            var bll = new BLL.WorkBenchMonitorPoint();
            var copy_pt = new TProduct.Model.WorkBenchMonitorPoint(source);
            copy_pt.ID = 0;
            copy_pt.Name = copy_pt.Name + "(复制)";
            copy_pt.Code = bll.CreateNO();
            copy_pt.ID = bll.Insert(copy_pt);
            WaitFrmHelper.ShowWaitForm();
            var dlg = new SetSingleBenchMonitorPointInfoDlg();
            dlg.Shown += delegate { WaitFrmHelper.HideWaitForm(); };
            dlg.SetBindingData(copy_pt);
            dlg.ReloadDataEvent += rhs =>
            {
                _bindList.Add(rhs);
                this.gridView1.RefreshData();
            };
            dlg.ShowDialog();
        }
        //编辑
        private void barBtnEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_bindList == null)
                return;
            var row = this.gridView1.GetCurrentViewModel(_bindList);
            if (row == null)
            {
                XtraMessageBox.Show("未选择数据!");
                return;
            }
            WaitFrmHelper.ShowWaitForm();
            var dlg = new SetSingleBenchMonitorPointInfoDlg();
            dlg.Shown += delegate { WaitFrmHelper.HideWaitForm(); };
            dlg.SetBindingData(row);
            dlg.ReloadDataEvent += rhs =>
            {
                row.Reset(rhs);
                this.gridView1.RefreshData();
            };
            dlg.ShowDialog();
        }
        private void barBtnDel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var row = this.gridView1.GetCurrentViewModel(_bindList);
            if (row == null)
                return;
            DialogResult dr = XtraMessageBox.Show("是否删除此测点?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
            if (dr != DialogResult.Yes)
                return;
            var result = new BLL.WorkBenchMonitorPoint().DeleteByID(row.ID);
            if (result)
            {
                _bindList.Remove(row);
                this.bindingSource1.ResetBindings(false);
                XtraMessageBox.Show("删除成功!");
            }
            else
            {
                XtraMessageBox.Show("删除失败!");
            }
        }
        private void bbi导出EXCEL_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var path = ExcelSaveFilePathHelper.SaveFilePathName();
            if (string.IsNullOrEmpty(path)) return;
            DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
            options.RawDataMode = true;//所见即所得
            options.TextExportMode = DevExpress.XtraPrinting.TextExportMode.Text;
            this.colID.DisplayFormat.FormatString = "\t{0}";
            this.colID.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom;
            this.gridView1.OptionsPrint.AutoWidth = false;
            this.gridView1.ExportToXls(path, options);
            DialogResult dr = XtraMessageBox.Show("导出成功!是否打开刚刚保存的Excel文件?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
            if (dr != DialogResult.OK)
                return;
            System.Diagnostics.Process.Start(path);
        }
        private void barBtnView_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
        }
    }
}