using DevExpress.XtraEditors;
|
using DevExpress.XtraGrid.Views.Grid;
|
using System;
|
using System.Collections.Generic;
|
using System.Drawing;
|
using System.Linq;
|
using System.Windows.Forms;
|
|
namespace TProduct.WinFrmUI.TPump
|
{
|
public partial class TestListByProduct4FactoryPage : TestList4FactoryBasePage
|
{
|
public TestListByProduct4FactoryPage()
|
{
|
InitializeComponent();
|
this.PageTitle.Caption = " 泵产品视图";
|
this._pageOperateInfo = "泵产品列表";
|
this.gridViewMain.SetNormalView();
|
this.gridViewMain.SetGridMianViewColor();
|
this.gridViewMain.OptionsDetail.ShowDetailTabs = false;//不显示TAB名
|
this.gridViewMain.OptionsView.ShowGroupPanel = false;//隐藏最上面的GroupPanel
|
this.gridViewMain.OptionsSelection.MultiSelect = false;//单选
|
this.gridViewMain.OptionsBehavior.Editable = false;//只读
|
//this.gridViewMain.BestFitColumns();
|
this.gridViewMain.IndicatorWidth = 40;
|
|
//改变聚焦颜色, 继续 按钮和默认颜色相同,所以稍微改一下
|
var focuseColor = Color.CornflowerBlue;
|
this.gridViewMain.Appearance.FocusedRow.BackColor = focuseColor;
|
this.gridViewMain.Appearance.FocusedCell.BackColor = focuseColor;
|
|
this.gridViewMain.RowClick += new DevExpress.XtraGrid.Views.Grid.RowClickEventHandler(this.GridViewMain_RowClick);
|
this.gridViewMain.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(this.GridViewMain_CustomDrawRowIndicator);
|
this.gridViewMain.CustomUnboundColumnData += new DevExpress.XtraGrid.Views.Base.CustomColumnDataEventHandler(this.GridViewMain_CustomUnboundColumnData);
|
//this.gridViewMain.DoubleClick += new System.EventHandler(this.GridViewMain_DoubleClick);
|
this.gridViewMain.RowCellClick += new DevExpress.XtraGrid.Views.Grid.RowCellClickEventHandler(this.GridViewMain_RowCellClick);
|
|
SetGridBindingSource(this.bindingSource1);
|
|
colWorkBenchName.Visible = TProduct.UserSetting.Setting.Disp.IsDispColWorkBench;
|
|
// colSeriesName.Visible = TProduct.UserSetting.Setting.Disp.IsDispColSeriesName;
|
colTestUserName.Visible = TProduct.UserSetting.Setting.Disp.IsDispColTestUserName;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
/// 初始化数据
|
/// </summary>
|
public override void InitialDataSource()
|
{
|
base.InitialDataSource();
|
|
pumpTreeView1.Build("泵列表");
|
pumpTreeView1.OnClickProductNode += OnSelectProductNode;
|
}
|
|
private int OnSelectProductNode(
|
int status,
|
TProduct.Model.ProductMainExPump product)
|
{
|
_bindList = new List<CurrentViewModel>();
|
this.bindingSource1.DataSource = _bindList;
|
this.bindingSource1.ResetBindings(false);
|
if (status == 0)
|
return 0;
|
if (_allUsers == null)
|
_allUsers = new BLL.LoginUser().GetAll();
|
if(product == null)
|
return 0;
|
|
var all_project_items = new BLL.TestProjectItemView().GetByProductID(product.ID);
|
|
this._allSeries = this.pumpTreeView1.GetAllSeries();
|
long senderID = 0;
|
|
if (BuilViewModelList(all_project_items, senderID) == 0)
|
{
|
MessageBox.Show("未找到测试");
|
ShowCmdOperateInfo("未找到测试");
|
return 0;
|
}
|
else
|
{
|
this.bindingSource1.DataSource = _bindList;
|
this.bindingSource1.ResetBindings(false);
|
}
|
|
|
return _bindList.Count();
|
}
|
|
|
#region 界面操作
|
private void barBtnAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var product = this.pumpTreeView1.GetFocuseProduct();
|
if (product == null)
|
{
|
MessageBox.Show("请选择产品");
|
ShowCmdOperateInfo("请选择产品");
|
return;
|
}
|
|
AddTestByDialog(product.SeriesID, product.ID);
|
}
|
|
private void barBtnEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var selRow = this.gridViewMain.GetRow(this.gridViewMain.FocusedRowHandle) as CurrentViewModel;
|
if (selRow == null)
|
return;
|
|
EditTest(selRow);
|
}
|
|
private void barBtnView_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var selRow = this.gridViewMain.GetRow(this.gridViewMain.FocusedRowHandle) as CurrentViewModel;
|
if (selRow == null)
|
return;
|
|
ViewTest(selRow, false);
|
}
|
|
private void barBtnDel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
ShowCmdOperateInfo("删除测试");
|
DialogResult result = MessageBox.Show("请问是否删除", "询问",
|
System.Windows.Forms.MessageBoxButtons.YesNo,
|
System.Windows.Forms.MessageBoxIcon.Warning);
|
ShowCmdOperateInfo(_pageOperateInfo);
|
if (result != DialogResult.Yes)
|
{
|
return;
|
}
|
var selRow = this.gridViewMain.GetRow(this.gridViewMain.FocusedRowHandle) as CurrentViewModel;
|
if (selRow == null || selRow.Entity == null)
|
return;
|
_bindList.RemoveAt(this.gridViewMain.FocusedRowHandle);
|
this.bindingSource1.DataSource = _bindList;
|
this.bindingSource1.ResetBindings(false);
|
new TProduct.BLL.TestProject().Delete(new List<Model.TestProjectItemView>() { selRow.Entity });
|
}
|
#endregion
|
|
|
|
#region GridViewMain
|
//
|
private void GridViewMain_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
|
{
|
if (e.Button == System.Windows.Forms.MouseButtons.Right)
|
{
|
//_clickProjectRow = gridViewMain.GetRow(e.RowHandle) as TProduct.Model.SaleProject;
|
////_rightClickProject = (gridViewMain.GetRow(e.RowHandle) as System.Data.DataRowView).Row as TProduct.WinFrmUI.Sale.DataSetUI.SaleProjectRow;
|
//// _rightClickProject = gridViewMain.GetFocusedDataRow() as TProduct.WinFrmUI.Sale.DataSetUI.SaleProjectRow;
|
//if (_clickProjectRow != null)
|
//{
|
// if (_clickProjectRow.ProjectStyle == 1)
|
// { //简易项目
|
// MenuItem转为简易项目.Visible = false;
|
// }
|
// else
|
// {
|
// MenuItem转为简易项目.Visible = true;
|
// }
|
|
// GidViewMenuStrip.Show(gridControl1, e.Location);
|
//}
|
}
|
}
|
|
//
|
private void GridViewMain_DoubleClick(object sender, EventArgs e)
|
{
|
var view = sender as GridView;
|
if (view != null)
|
{
|
var point = view.GridControl.PointToClient(MousePosition);
|
var hitInfo = view.CalcHitInfo(point);
|
if (hitInfo.InRow || hitInfo.InRowCell)
|
{
|
var selRow = gridViewMain.GetRow(hitInfo.RowHandle) as CurrentViewModel;
|
// _clickPrjItem = (gridViewAttach.GetRow(pumpStr.RowHandle) as System.Data.DataRowView).Row as DAL.DataSetCustomer.CustomerVipInfoRow;
|
if (selRow != null)
|
{
|
ViewTest(selRow, false);
|
}
|
}
|
}
|
}
|
|
//
|
private void GridViewMain_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
{
|
if (e.Column == colStartTest)
|
{
|
var selRow = this.gridViewMain.GetRow(e.RowHandle) as CurrentViewModel;
|
if (selRow == null)
|
return;
|
EditTest(selRow);
|
}
|
if (e.Column == this.colViewInfo)
|
{
|
var selRow = this.gridViewMain.GetRow(e.RowHandle) as CurrentViewModel;
|
if (selRow == null)
|
return;
|
ViewTest(selRow, false);
|
}
|
}
|
|
|
//
|
private void GridViewMain_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
|
{
|
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
|
{
|
e.Info.DisplayText = (e.RowHandle + 1).ToString();
|
}
|
}
|
|
//
|
private void GridViewMain_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
|
{
|
//if (e.Column == colCreateTime)
|
//{
|
// var prj = e.Row as TProduct.Model.SaleProject;
|
// if (prj == null)
|
// return;
|
|
// e.Value = prj.GetCreateTime();
|
//}
|
|
}
|
#endregion
|
|
|
|
|
private void barBtnDownExcel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
ShowCmdOperateInfo("导出列表信息到Excel");
|
var path = ExcelSaveFilePathHelper.SaveFilePathName();
|
ShowCmdOperateInfo(_pageOperateInfo);
|
DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
|
options.RawDataMode = true;//所见即所得
|
options.TextExportMode = DevExpress.XtraPrinting.TextExportMode.Text;
|
this.gridViewMain.OptionsPrint.AutoWidth = false;
|
if (!string.IsNullOrEmpty(path))
|
{
|
this.gridViewMain.ExportToXls(path, options);
|
|
DialogResult dr = XtraMessageBox.Show("导出成功!是否打开刚刚保存的Excel文件?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
|
if (dr != DialogResult.OK)
|
return;
|
System.Diagnostics.Process.Start(path);
|
}
|
}
|
|
|
|
|
|
|
|
|
}
|
}
|