using DevExpress.XtraEditors;
|
using System.Collections.Generic;
|
using System.Windows.Forms;
|
|
namespace TProduct.WinFrmUI.TestBench
|
{
|
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)
|
{
|
if (e.Column == this.colSourceType)
|
{
|
var pt = e.Row as Model.WorkBenchMonitorPoint;
|
if (pt != null)
|
{
|
if (pt.SourceType == Model.eMonitorPointSourceType.未知)
|
{
|
e.Value = "还未设置,请尽快确认";
|
}
|
if (pt.SourceType == Model.eMonitorPointSourceType.模拟量)
|
{
|
e.Value = "模拟量,需要确认量程";
|
}
|
if (pt.SourceType == Model.eMonitorPointSourceType.数字量)
|
{
|
e.Value = "数字量,需要确认寄存器地址";
|
}
|
if (pt.SourceType == Model.eMonitorPointSourceType.额定参数)
|
{
|
e.Value = "额定参数";
|
}
|
}
|
}
|
}
|
|
|
private List<Model.WorkBenchMonitorPoint> _bindList = null;
|
|
|
|
//添加
|
private void barBtnAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
if ( _bindList == null)
|
return;
|
WaitFrmHelper.ShowWaitForm();
|
var dlg = new SetSingleBenchMonitorPointInfoDlg();
|
dlg.Shown += delegate { WaitFrmHelper.HideWaitForm(); };
|
dlg.SetBindingData( );
|
dlg.ReloadDataEvent += rhs =>
|
{
|
_bindList.Add(rhs);
|
this.bindingSource1.ResetBindings(false);
|
};
|
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)
|
{
|
|
}
|
}
|
}
|