วันเสาร์ที่ 27 ตุลาคม พ.ศ. 2555
Group -> ( Sum && While Select +=Sum )
static void Q_Eff_Report_Excel(Args _args)
{
// SWAN_Machine_Capacity _SWAN_Machine_Capacity;
ProdJournalTable _ProdJournalTable;
ProdJournalRoute _ProdJournalRoute;
counter counter;
ProdJournalTable _ProdJournalTable2;
ProdJournalRoute _ProdJournalRoute2;
// sum(QtyGood)
ProdJournalTable _ProdJournalTable3;
ProdJournalRoute _ProdJournalRoute3;
// sum(Target)
ProdJournalTable _ProdJournalTable4;
ProdJournalRoute _ProdJournalRoute4;
// SWAN_Machine_Capacity _SWAN_Machine_Capacity2;
;
// while
// select * from _SWAN_Machine_Capacity
// order by _SWAN_Machine_Capacity.MachineNo
// group by _SWAN_Machine_Capacity.MachineNo
// where _SWAN_Machine_Capacity.MachineNo Like "C*"
// {
// print "<---------------";
// print _SWAN_Machine_Capacity.MachineNo;
// pause;
while select _ProdJournalTable
order by _ProdJournalTable.MachineNo, _ProdJournalTable.Team, _ProdJournalRoute.ActualCap asc //, _ProdJournalRoute.WrkCtrId
group by _ProdJournalTable.MachineNo, _ProdJournalTable.Team, _ProdJournalRoute.ActualCap//, _ProdJournalRoute.WrkCtrId
where _ProdJournalTable.MachineNo Like "C*"
join _ProdJournalRoute
where _ProdJournalRoute.JournalId == _ProdJournalTable.JournalId
&& _ProdJournalRoute.JobStatus == "Working"
// && _ProdJournalRoute.TransDate == mkDate(13,07,12)
// && _ProdJournalRoute.WrkCtrId == _ProdJournalTable.WrkCtrId
{
print _ProdJournalTable.MachineNo; // << Alert! Mandatory
print _ProdJournalTable.Team; // << Alert! Mandatory
print _ProdJournalRoute.ActualCap; // << Alert! Mandatory
// print _ProdJournalRoute.JobStatus;
// print _ProdJournalRoute.WrkCtrId;
counter++;
// print "--------------->";
print "---------";
pause;
while select _ProdJournalTable2
join _ProdJournalRoute2
where _ProdJournalRoute2.JournalId == _ProdJournalTable2.JournalId
&& _ProdJournalTable2.MachineNo == _ProdJournalTable.MachineNo
&& _ProdJournalTable2.Team == _ProdJournalTable.Team
&& _ProdJournalRoute2.ActualCap == _ProdJournalRoute.ActualCap
{
print " ---------";
print _ProdJournalTable2.MachineNo; // << Alert! Mandatory
print _ProdJournalTable2.Team; // << Alert! Mandatory
print _ProdJournalRoute2.ActualCap; // << Alert! Mandatory
print "QtyGood";
print _ProdJournalRoute2.QtyGood;
print "Target";
print _ProdJournalRoute2.Target;
}
select sum(QtyGood) from _ProdJournalRoute3
where _ProdJournalRoute3.ActualCap == _ProdJournalRoute.ActualCap
join _ProdJournalTable3
where _ProdJournalRoute3.JournalId == _ProdJournalTable3.JournalId
&& _ProdJournalTable3.MachineNo == _ProdJournalTable.MachineNo
&& _ProdJournalTable3.Team == _ProdJournalTable.Team;
print "SUM(QtyGood)";
print _ProdJournalRoute3.QtyGood;
select sum(Target) from _ProdJournalRoute4
where _ProdJournalRoute4.ActualCap == _ProdJournalRoute.ActualCap
join _ProdJournalTable4
where _ProdJournalRoute4.JournalId == _ProdJournalTable4.JournalId
&& _ProdJournalTable4.MachineNo == _ProdJournalTable.MachineNo
&& _ProdJournalTable4.Team == _ProdJournalTable.Team;
print "SUM(Target)";
print _ProdJournalRoute4.Target;
print SWAN_TimePlus::Plus(0.5,0.55);
print _ProdJournalRoute.JobStatus;
pause;
/*
_JobStatusId = _ProdJournalRoute.JobStatus;
rBuffsum = rSumWorkingTime; rSumWorkingTime = 0;
rSumWorkingTime += element.TimePlus(rBuffsum, _ProdJournalRoute.SWAN_HourUse);
rSumQtyGood += _ProdJournalRoute.QtyGood;
rSumTarget += _ProdJournalRoute.Target;
rSumHoldProcess += _ProdJournalRoute.HoldProd;
rSumHoldMaterial += _ProdJournalRoute.HoldMat;
rSumWaste += _ProdJournalRoute.QtyError;
rBuffsum = rSumInternalDowntime; rSumInternalDowntime = 0;
rSumInternalDowntime += element.TimePlus(rBuffsum, _ProdJournalRoute.TimeInternal);
rBuffsum = rSumExternalDowntime; rSumExternalDowntime = 0;
rSumExternalDowntime += element.TimePlus(rBuffsum, _ProdJournalRoute.TimeExternal);
*/
}
print counter;
pause;
// }
// << What!
// How .MachineNo relation with .WrkCtrId ?
// >>
}
วันศุกร์ที่ 12 ตุลาคม พ.ศ. 2555
Export to Excel
static void Q_Prod_Eff_All_DoubleDie_MFG3(Args _args)
{
// Retreive data
ProdJournalRoute _ProdJournalRoute;
ProdJournalTable _ProdJournalTable;
SWAN_Machine_Capacity _SWAN_Machine_Capacity;
ProdTable _ProdTable;
Date _fromDate;
Date _toDate;
// Export to Excel
SysExcelApplication xlsApplication;
SysExcelWorkBooks xlsWorkBookCollection;
SysExcelWorkBook xlsWorkBook;
SysExcelWorkSheets xlsWorkSheetCollection;
SysExcelWorkSheet xlsWorkSheet;
SysExcelRange xlsRange;
CustTable custTable;
int row = 1;
str fileName;
;
// Export to Excel
//Filename
fileName = "C:\\Test.xlsx";
//Initialize Excel instance
xlsApplication = SysExcelApplication::construct();
//Open Excel document
//xlsApplication.visible(true);
//Create Excel WorkBook and WorkSheet
xlsWorkBookCollection = xlsApplication.workbooks();
xlsWorkBook = xlsWorkBookCollection.add();
xlsWorkSheetCollection = xlsWorkBook.worksheets();
xlsWorkSheet = xlsWorkSheetCollection.itemFromNum(1);
//Excel columns captions
xlsWorkSheet.cells().item(row,1).value("Machine No.");
xlsWorkSheet.cells().item(row,2).value("ProdId");
xlsWorkSheet.cells().item(row,3).value("JournalId");
xlsWorkSheet.cells().item(row,4).value("Team");
xlsWorkSheet.cells().item(row,5).value("Trandate");
xlsWorkSheet.cells().item(row,6).value("ActualCap");
xlsWorkSheet.cells().item(row,7).value("Fullcap");
row++;
while
select * from _SWAN_Machine_Capacity
group by MachineNo
order by MachineNo
where _SWAN_Machine_Capacity.MachineNo Like "DD*"
{
print "----------------------------";
print _SWAN_Machine_Capacity.MachineNo;
print "----------------------------";
//strMachineNO = _SWAN_Machine_Capacity.MachineNo;
// Group by Team and Full,Acutualcap and ItemId and ProdId and JournalId
while
select * from _ProdJournalTable
where _ProdJournalTable.MachineNo == _SWAN_Machine_Capacity.MachineNo
join _ProdJournalRoute
where _ProdJournalRoute.ProdId == _ProdJournalTable.ProdId
&& _ProdJournalRoute.JournalId == _ProdJournalTable.JournalId
&& _ProdJournalRoute.TransDate == mkDate(10,08,12) // dialog feild
// _ProdJournalRoute.TransDate <= DateTo // dialog feild
{
// print _ProdJournalTable.MachineNo;
print _ProdJournalTable.ProdId;
print _ProdJournalTable.JournalId;
print _ProdJournalTable.MachineNo;
print _ProdJournalTable.Team;
print _ProdJournalRoute.FullCap;
print _ProdJournalRoute.ActualCap;
print _ProdJournalRoute.TransDate;
//Find ItemId
select _ProdTable
where _ProdTable.ProdId == _ProdJournalTable.ProdId;
print _ProdTable.ItemId;
print "++++++++++++++++++++++++++++++";
pause;
xlsWorkSheet.cells().item(row,1).value(_ProdJournalTable.MachineNo);
xlsWorkSheet.cells().item(row,2).value(_ProdJournalTable.ProdId);
xlsWorkSheet.cells().item(row,3).value(_ProdJournalTable.JournalId);
xlsWorkSheet.cells().item(row,4).value(_ProdJournalTable.Team);
xlsWorkSheet.cells().item(row,5).value(_ProdJournalRoute.TransDate);
xlsWorkSheet.cells().item(row,6).value(_ProdJournalRoute.ActualCap);
xlsWorkSheet.cells().item(row,7).value(_ProdJournalRoute.FullCap);
row++;
}
// break;
}
//Check whether the document already exists
if(WinApi::fileExists(fileName))
WinApi::deleteFile(fileName);
//Save Excel document
xlsWorkbook.saveAs(fileName);
//Open Excel document
xlsApplication.visible(true);
//Close Excel
//xlsApplication.quit();
//xlsApplication.finalize();
}
วันจันทร์ที่ 8 ตุลาคม พ.ศ. 2555
X++ : Dialog
static void Pan_AxDialog(Args _args)
{
Dialog d1;
DialogGroup dg1;
DialogField df1,df2;
;
d1 = new Dialog("Jet");
d1.addGroup("Group");
d1.addField(TypeID(CustAccount),"Account Number");
if(d1.run())
{
// print df1.value();
print " run";
}
else
{
print "not run";
}
pause;
}
วันจันทร์ที่ 1 ตุลาคม พ.ศ. 2555
สมัครสมาชิก:
บทความ (Atom)