181 lines
6.9 KiB
C#
181 lines
6.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using System.Data.SqlClient;
|
|
using SystemX.Product.TRA.DataManager;
|
|
using DevExpress.Utils;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
|
|
using DevExpress.XtraPrinting;
|
|
using SystemX.Product.ALIS.Interface;
|
|
|
|
using static SystemX.Product.CP.TRA.MainForm;
|
|
using static SystemX.Product.CP.TRA.Commons;
|
|
|
|
namespace SystemX.Product.TRA.UIControl
|
|
{
|
|
public partial class UcTRAProductHist : UcTRABaseView
|
|
{
|
|
public enum eColHide
|
|
{
|
|
TestlistNo,
|
|
//TestID,
|
|
LogNo,
|
|
LogCount,
|
|
AccessStart,
|
|
AccessEnd,
|
|
TestlistFile
|
|
}
|
|
|
|
DMProductHistory DataManager { get; set; }
|
|
TestHistorySearchOption Option { get; set; }
|
|
SelectedDataCollection SelectedData { get; set; }
|
|
public DataTable DataResult { get; private set; }
|
|
|
|
public delegate void evtStepTrendViewHandler(TestTrendDataCollection data);
|
|
public event evtStepTrendViewHandler OnHistorySelect;
|
|
|
|
private string GridViewGetActiveFilterText;
|
|
public UcTRAProductHist()
|
|
{
|
|
ContentsType = eContents.ProductHistory;
|
|
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetSQLConnection(eSelectDataView SelectView, IDataBaseController getDBController)
|
|
{
|
|
DataManager = new DMProductHistory(SelectView, getDBController);
|
|
}
|
|
|
|
public void ViewData(SelectedDataCollection data)
|
|
{
|
|
if (data == null)
|
|
return;
|
|
|
|
SelectedData = data;
|
|
|
|
DataTable dtResult = DataManager.SearchTestHistory(data, Option);
|
|
|
|
GridViewGetActiveFilterText = gridViewMain.ActiveFilterString;
|
|
|
|
DataResult = dtResult;
|
|
|
|
gridControlMain.BeginInit();
|
|
|
|
gridControlMain.DataSource = dtResult;
|
|
|
|
gridControlMain.Update();
|
|
gridControlMain.RefreshDataSource();
|
|
gridControlMain.ForceInitialize();
|
|
gridViewMain.PopulateColumns(dtResult);
|
|
|
|
foreach (string strColName in Enum.GetNames(typeof(eColHide)))
|
|
gridViewMain.Columns[strColName].Visible = false;
|
|
|
|
gridControlMain.EndInit();
|
|
|
|
gridViewMain.ActiveFilterString = GridViewGetActiveFilterText;
|
|
}
|
|
|
|
//public DetailTestDataCollection GetSearchInfo(DataRow dtRow)
|
|
//{
|
|
// DetailTestDataCollection drDetail = new DetailTestDataCollection();
|
|
|
|
// drDetail.TestID = dtRow[DMTestHistory.eColList.TestID.ToString()].ToString();
|
|
// drDetail.StartTime = DateTime.Parse(dtRow[DMTestHistory.eColList.TestDateTime.ToString()].ToString());
|
|
// drDetail.AccessStart = Convert.ToUInt64(dtRow[DMTestHistory.eColList.AccessStart.ToString()]);
|
|
// drDetail.AccessEnd = Convert.ToUInt64(dtRow[DMTestHistory.eColList.AccessEnd.ToString()]);
|
|
// drDetail.Duration = Convert.ToInt64(dtRow[DMTestHistory.eColList.Duration.ToString()]);
|
|
// drDetail.StationName = dtRow[DMTestHistory.eColList.StationName.ToString()].ToString();
|
|
// drDetail.HostID = dtRow[DMTestHistory.eColList.Host.ToString()].ToString();
|
|
// drDetail.SectionID = dtRow[DMTestHistory.eColList.Section.ToString()].ToString();
|
|
// drDetail.TestType = dtRow[DMTestHistory.eColList.TestType.ToString()].ToString();
|
|
// drDetail.ProductID = dtRow[DMTestHistory.eColList.ProductID.ToString()].ToString();
|
|
// drDetail.ProductNo = dtRow[DMTestHistory.eColList.ProductNo.ToString()].ToString();
|
|
// drDetail.TestCode = dtRow[DMTestHistory.eColList.TestCode.ToString()].ToString();
|
|
// drDetail.ParentNo = dtRow[DMTestHistory.eColList.ParentNo.ToString()].ToString();
|
|
// drDetail.FileCode = dtRow[DMTestHistory.eColList.FileCode.ToString()].ToString();
|
|
// drDetail.FileVersion = dtRow[DMTestHistory.eColList.FileVersion.ToString()].ToString();
|
|
// drDetail.TestlistFile = dtRow[DMTestHistory.eColList.TestlistFile.ToString()].ToString();
|
|
// drDetail.TestlistNo = dtRow[DMTestHistory.eColList.TestlistNo.ToString()].ToString();
|
|
// drDetail.StepVersion = dtRow[DMTestHistory.eColList.StepVersion.ToString()].ToString();
|
|
// drDetail.TestRequestID = dtRow[DMTestHistory.eColList.TestlistReqID.ToString()].ToString();
|
|
// drDetail.TestResult = dtRow[DMTestHistory.eColList.TestResult.ToString()].ToString();
|
|
|
|
// OnHistorySelect(drDetail);
|
|
|
|
// return drDetail;
|
|
//}
|
|
|
|
private void UcTRATestHistHost_Load(object sender, EventArgs e)
|
|
{
|
|
Option = new TestHistorySearchOption();
|
|
|
|
FrmOptionStationSearch dlgSearch = new FrmOptionStationSearch();
|
|
|
|
dlgSearch.ShowDialog();
|
|
|
|
if (dlgSearch.DialogResult == DialogResult.OK)
|
|
Option = dlgSearch.GetSelectedResult();
|
|
}
|
|
|
|
private void gridViewMain_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
DXMouseEventArgs ea = e as DXMouseEventArgs;
|
|
GridView view = sender as GridView;
|
|
GridHitInfo info = view.CalcHitInfo(ea.Location);
|
|
|
|
if (info.InRow || info.InRowCell)
|
|
{
|
|
int nRow = int.MinValue;
|
|
nRow = info.RowHandle;
|
|
|
|
if (nRow < 0)
|
|
return;
|
|
|
|
var dvRow = view.GetRow(nRow);
|
|
DataRow dtRow = (dvRow as DataRowView).Row;
|
|
|
|
//GetSearchInfo(dtRow);
|
|
}
|
|
}
|
|
|
|
public string CreateExportFileName()
|
|
{
|
|
string strFileName = $"{this.ContentsType.ToString()}_{SelectedData.ProductNo}_{SelectedData.TestCode}_{SelectedData.StationName}";
|
|
|
|
strFileName += $"_{SelectedData.StartTime.ToString("yyyyMMddHHmmss")}-{SelectedData.EndTime.ToString("yyyyMMddHHmmss")}";
|
|
|
|
return strFileName;
|
|
}
|
|
|
|
public override void ExportData()
|
|
{
|
|
FolderBrowserDialog dlg = new FolderBrowserDialog();
|
|
|
|
if (dlg.ShowDialog() == DialogResult.OK)
|
|
{
|
|
|
|
string strFileName = CreateExportFileName();
|
|
string strExpPath = dlg.SelectedPath + "\\" + strFileName;
|
|
XlsxExportOptionsEx option = new XlsxExportOptionsEx();
|
|
string strFile = strExpPath + ".xlsx";
|
|
|
|
option.ShowGridLines = true;
|
|
option.ExportType = DevExpress.Export.ExportType.WYSIWYG;
|
|
option.ExportMode = XlsxExportMode.SingleFile;
|
|
option.SheetName = "Test History";
|
|
gridControlMain.ExportToXlsx(strFile, option);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|