📄 productplancheck.cpp
字号:
// //end kasenhoo
//
// //QTY_A
// oQTY_A = new DataGridTextBoxColumn();
// oQTY_A->MappingName = S"QTY_A";
// oQTY_A->HeaderText = S"QTY";
// oQTY_A->Alignment = HorizontalAlignment::Center;
// oQTY_A->Width = 60;
//
// //add by kasenhoo@051105
// oQTY_A->NullText = S"";
// //end kasenhoo
//
//
// oTableStyleDetail->GridColumnStyles->Add(oDate);
// oTableStyleDetail->GridColumnStyles->Add(oNameB);
// oTableStyleDetail->GridColumnStyles->Add(oQTY_B);
// oTableStyleDetail->GridColumnStyles->Add(oNameA);
// oTableStyleDetail->GridColumnStyles->Add(oQTY_A);
// dataGridDetail->TableStyles->Add(oTableStyleDetail);
//}
void ProductPlanCheck::GetGridDataPlan(String* sProcessNo)
{
String *sSQL = S"";
String* saLang[] = {S"C", S"J", S"E"};
String* saLine[] = {S"'L001','L002'", S"'L001'", S"'L002'"};
sSQL = String::Concat(sSQL, S"select" );
sSQL = String::Concat(sSQL, S" SCHE.PRODUCT_CODE," );
sSQL = String::Concat(sSQL, S" PART.PARTS_NAME_", saLang[iLanguage],S" as PRODUCT_NAME," );
sSQL = String::Concat(sSQL, S" SCHE.LOT," );
sSQL = String::Concat(sSQL, S" SCHE.LINE_CODE," );
sSQL = String::Concat(sSQL, S" LINE.LINE_NAME," );
sSQL = String::Concat(sSQL, S" SCHE.PROCESS_NO," );
sSQL = String::Concat(sSQL, S" SCHE.PRODUCT_QTY " );
//Insert By KasenHOo @ 2005/12/09
sSQL = String::Concat(sSQL, S" ,SCHE.YMD " );
//End By KasenHOo @ 2005/12/09
sSQL = String::Concat(sSQL, S"from" );
sSQL = String::Concat(sSQL, S" (" );
sSQL = String::Concat(sSQL, S" select" );
sSQL = String::Concat(sSQL, S" PRODUCT_CODE," );
sSQL = String::Concat(sSQL, S" LOT," );
sSQL = String::Concat(sSQL, S" LINE_CODE," );
sSQL = String::Concat(sSQL, S" PROCESS_NO," );
sSQL = String::Concat(sSQL, S" sum(PRODUCT_QTY) as PRODUCT_QTY" );
//Insert By KasenHOo @ 2005/12/09
sSQL = String::Concat(sSQL, S" ,YMD " );
//End By KasenHOo @ 2005/12/09
sSQL = String::Concat(sSQL, S" from" );
sSQL = String::Concat(sSQL, S" PRODUCT_SCHEDULE" );
sSQL = String::Concat(sSQL, S" where" );
sSQL = String::Concat(sSQL, S" FACTORY_CODE = '", sFactory, S"' and" );
sSQL = String::Concat(sSQL, S" PROCESS_NO = '", sProcessNo, S"' and" );
sSQL = String::Concat(sSQL, S" LINE_CODE in (", saLine[comboLine->SelectedIndex], S")" );
//Insert By KasenHOo @ 2005/12/09
sSQL = String::Concat(sSQL, S" and YMD between to_date('",dtpFrom->Value.ToString(S"yyyy-MM-dd"),S"','YYYY-MM-DD') and to_date('", dtpTo->Value.ToString(S"yyyy-MM-dd"),S"','YYYY-MM-DD' ) " );
//End By KasenHOo @ 2005/12/09
sSQL = String::Concat(sSQL, S" group by" );
sSQL = String::Concat(sSQL, S" PRODUCT_CODE," );
sSQL = String::Concat(sSQL, S" LOT," );
sSQL = String::Concat(sSQL, S" LINE_CODE," );
sSQL = String::Concat(sSQL, S" PROCESS_NO" );
//Insert By KasenHOo @ 2005/12/09
sSQL = String::Concat(sSQL, S" ,YMD " );
//End By KasenHOo @ 2005/12/09
sSQL = String::Concat(sSQL, S" ) SCHE," );
sSQL = String::Concat(sSQL, S" PARTS_MST PART," );
sSQL = String::Concat(sSQL, S" LINE_MST LINE " );
sSQL = String::Concat(sSQL, S"where" );
sSQL = String::Concat(sSQL, S" SCHE.PRODUCT_CODE = PART.PRODUCT_CODE(+) and" );
sSQL = String::Concat(sSQL, S" SCHE.LINE_CODE = LINE.LINE_CODE(+)" );
sSQL = String::Concat(sSQL, S" Order by SCHE.YMD desc,SCHE.PRODUCT_CODE desc " );
//////////////////////////////////////////////////////
//write by zhanghongliang
sMySQL=sSQL;
/////////////////////////////////////////////////
//oDataSetPlan = oDB->dSetSQL_Select(sSQL, S"GridDataPlan", 0);
//oDataTablePlan = oDataSetPlan->Tables->Item["GridDataPlan"];
//dataGridPlan->DataSource = oDataTablePlan;
}
void ProductPlanCheck::GetGridDataDetail(String* sProcessNo)
{
//BindingManagerBase* oBM;
//DataRow* oDR;
//String* sLot;
String* sSQL = S"";
String* saLang[] = {S"C", S"J", S"E"};
//Get selected Lot
//oBM = dataGridPlan->BindingContext->get_Item(oDataTablePlan);
//oDR = (dynamic_cast<DataRowView*>(oBM->Current))->Row;
//sLot = oDR->get_Item(S"LOT")->ToString();
//Get Detail Data
sSQL = String::Concat(sSQL, S"select CALE.lot as LOT," );
sSQL = String::Concat(sSQL, S" CALE.YMD as YMD_DATE," );
sSQL = String::Concat(sSQL, S" nvl(CALE.NAME_B, ' ') as NAME_B," );
sSQL = String::Concat(sSQL, S" nvl(to_char(SC_B.PRODUCT_QTY, '999990'), ' ') as QTY_B," );
sSQL = String::Concat(sSQL, S" nvl(CALE.NAME_A, ' ') as NAME_A," );
sSQL = String::Concat(sSQL, S" nvl(to_char(SC_A.PRODUCT_QTY, '999990'), ' ') as QTY_A " );
sSQL = String::Concat(sSQL, S"from" );
sSQL = String::Concat(sSQL, S" (" );
sSQL = String::Concat(sSQL, S" select distinct" );
sSQL = String::Concat(sSQL, S" CAL.WORK_YMD as YMD," );
sSQL = String::Concat(sSQL, S" SCH.FACTORY_CODE," );
sSQL = String::Concat(sSQL, S" SCH.LOT," );
sSQL = String::Concat(sSQL, S" SCH.LINE_CODE," );
sSQL = String::Concat(sSQL, S" SCH.PROCESS_NO," );
sSQL = String::Concat(sSQL, S" SCH.PRODUCT_CODE," );
sSQL = String::Concat(sSQL, S" CAL.NAME_A," );
sSQL = String::Concat(sSQL, S" CAL.NAME_B" );
sSQL = String::Concat(sSQL, S" from" );
sSQL = String::Concat(sSQL, S" (" );
sSQL = String::Concat(sSQL, S" select distinct" );
sSQL = String::Concat(sSQL, S" CALE.FACTORY_CODE," );
sSQL = String::Concat(sSQL, S" CALE.LINE_CODE," );
sSQL = String::Concat(sSQL, S" CALE.WORK_YMD," );
sSQL = String::Concat(sSQL, S" CALE.PROCESS_NO," );
sSQL = String::Concat(sSQL, S" TE_A.NAME_", saLang[iLanguage], S" as NAME_A," );
sSQL = String::Concat(sSQL, S" TE_B.NAME_", saLang[iLanguage], S" as NAME_B" );
sSQL = String::Concat(sSQL, S" from" );
sSQL = String::Concat(sSQL, S" WORK_CALENDER CALE," );
sSQL = String::Concat(sSQL, S" TEAM_MST TE_A," );
sSQL = String::Concat(sSQL, S" TEAM_MST TE_B" );
sSQL = String::Concat(sSQL, S" where" );
sSQL = String::Concat(sSQL, S" CALE.DAY_SHIFT = TE_A.TEAM(+) and" );
sSQL = String::Concat(sSQL, S" CALE.NIGHT_SHIFT = TE_B.TEAM(+) and" );
sSQL = String::Concat(sSQL, S" CALE.PROCESS_NO = TE_A.PROCESS_NO(+) and" );
sSQL = String::Concat(sSQL, S" CALE.PROCESS_NO = TE_B.PROCESS_NO(+)" );
sSQL = String::Concat(sSQL, S" ) CAL," );
sSQL = String::Concat(sSQL, S" (" );
sSQL = String::Concat(sSQL, S" select" );
sSQL = String::Concat(sSQL, S" FACTORY_CODE," );
sSQL = String::Concat(sSQL, S" LOT," );
sSQL = String::Concat(sSQL, S" LINE_CODE," );
sSQL = String::Concat(sSQL, S" PROCESS_NO," );
sSQL = String::Concat(sSQL, S" PRODUCT_CODE," );
sSQL = String::Concat(sSQL, S" min(YMD) as W_MIN," );
sSQL = String::Concat(sSQL, S" max(YMD) as W_MAX" );
sSQL = String::Concat(sSQL, S" from" );
sSQL = String::Concat(sSQL, S" PRODUCT_SCHEDULE" );
sSQL = String::Concat(sSQL, S" group by" );
sSQL = String::Concat(sSQL, S" FACTORY_CODE, LOT, LINE_CODE, PROCESS_NO, PRODUCT_CODE" );
sSQL = String::Concat(sSQL, S" ) SCH" );
sSQL = String::Concat(sSQL, S" where" );
sSQL = String::Concat(sSQL, S" CAL.FACTORY_CODE = SCH.FACTORY_CODE and" );
sSQL = String::Concat(sSQL, S" CAL.LINE_CODE = SCH.LINE_CODE and" );
sSQL = String::Concat(sSQL, S" CAL.PROCESS_NO = SCH.PROCESS_NO and" );
sSQL = String::Concat(sSQL, S" CAL.WORK_YMD >= SCH.W_MIN and" );
sSQL = String::Concat(sSQL, S" CAL.WORK_YMD <= SCH.W_MAX " );
sSQL = String::Concat(sSQL, S" order by" );
sSQL = String::Concat(sSQL, S" SCH.LOT, SCH.PROCESS_NO,CAL.WORK_YMD" );
sSQL = String::Concat(sSQL, S" ) CALE," );
sSQL = String::Concat(sSQL, S" PRODUCT_SCHEDULE SC_A," );
sSQL = String::Concat(sSQL, S" PRODUCT_SCHEDULE SC_B " );
sSQL = String::Concat(sSQL, S"where" );
sSQL = String::Concat(sSQL, S" CALE.FACTORY_CODE = '", sFactory, S"' and" );
sSQL = String::Concat(sSQL, S" CALE.PROCESS_NO = '", sProcessNo, S"' and" );
////////////////此句张宏亮注释////////////////////////////
//sSQL = String::Concat(sSQL, S" CALE.LOT = '", sLot, S"' and" );
sSQL = String::Concat(sSQL, S" CALE.FACTORY_CODE = SC_A.FACTORY_CODE(+) and" );
sSQL = String::Concat(sSQL, S" CALE.PROCESS_NO = SC_A.PROCESS_NO(+) and" );
sSQL = String::Concat(sSQL, S" CALE.LOT = SC_A.LOT(+) and" );
sSQL = String::Concat(sSQL, S" CALE.YMD = SC_A.YMD(+) and" );
sSQL = String::Concat(sSQL, S" SC_A.SHIFT(+) = 'A' and" );
sSQL = String::Concat(sSQL, S" CALE.FACTORY_CODE = SC_B.FACTORY_CODE(+) and" );
sSQL = String::Concat(sSQL, S" CALE.PROCESS_NO = SC_B.PROCESS_NO(+) and" );
sSQL = String::Concat(sSQL, S" CALE.LOT = SC_B.LOT(+) and" );
sSQL = String::Concat(sSQL, S" CALE.YMD = SC_B.YMD(+) and" );
sSQL = String::Concat(sSQL, S" SC_B.SHIFT(+) = 'B' " );
sSQL = String::Concat(sSQL, S"order by" );
sSQL = String::Concat(sSQL, S" CALE.YMD" );
//////////////////////////////////////////////////////////////////////////////////////////////
sMySQL2=sSQL;
String * sAllSQL=S"";
sAllSQL=String::Concat(sAllSQL,S"select ABEF.product_code,ABEF.product_name,ABEF.lot,ABEF.line_code,ABEF.line_name,ABEF.process_no,ABEF.product_qty,ABEF.ymd,\n");
sAllSQL=String::Concat(sAllSQL,S"CKSH.ymd_date,CKSH.name_b,CKSH.qty_b,CKSH.name_a,CKSH.qty_a\n");
sAllSQL=String::Concat(sAllSQL,S" from (\n");
sAllSQL=String::Concat(sAllSQL,sMySQL);
sAllSQL=String::Concat(sAllSQL,S"\n)ABEF left outer join(\n");
sAllSQL=String::Concat(sAllSQL,sMySQL2);
sAllSQL=String::Concat(sAllSQL,S"\n)CKSH \n");
sAllSQL=String::Concat(sAllSQL,S"on ABEF.lot=CKSH.lot order by ABEF.ymd");
//
////////////////////////////////////////////////////////
oDataSetPlan = oDB->dSetSQL_Select(sAllSQL, S"GridDataPlan", 0);
oDataTablePlan = oDataSetPlan->Tables->Item["GridDataPlan"];
//
///begin
///add a sum row to the end
long sumTotalPlan;
sumTotalPlan=0;
IEnumerator* tempRow = oDataTablePlan->Rows->GetEnumerator();
tempRow->Reset();
while (tempRow->MoveNext())
{
DataRow *dRowTmp = __try_cast<DataRow*>(tempRow->Current);
sumTotalPlan =sumTotalPlan+Convert::ToInt32(dRowTmp->Item[S"PRODUCT_QTY"]);
}
DataRow* sumRow=oDataTablePlan->NewRow();
switch (iLanguage)//0 is chinese,1 is jap ,2 is english
{
case 0:
sumRow->Item["PRODUCT_CODE"]= S"合计";
break;
case 1:
sumRow->Item["PRODUCT_CODE"]= S"合計";
break;
case 2:
sumRow->Item["PRODUCT_CODE"]= S"Sum";
break;
default: break;
}
sumRow->Item["PRODUCT_QTY"]=Convert::ToString(sumTotalPlan);
oDataTablePlan->Rows->Add(sumRow);
///end
///add a sum row to the end
dataGridPlan->DataSource = oDataTablePlan;
///////////////////////////////////////////////////////////
//oDataSetDetail = oDB->dSetSQL_Select(sSQL, S"GridDataDetail", 0);
//oDataTableDetail = oDataSetDetail->Tables->Item["GridDataDetail"];
//dataGridDetail->DataSource = oDataTableDetail;
}
void ProductPlanCheck::GetLastUpdate()
{
System::Data::DataRow* oDataRowLastUp;
String *sSQL;
sSQL = S"";
sSQL = String::Concat(sSQL, S"select");
sSQL = String::Concat(sSQL, S" to_char(max(UPDATE_YMD), 'yyyy/mm/dd hh:mi') ");
sSQL = String::Concat(sSQL, S"from");
sSQL = String::Concat(sSQL, S" PRODUCT_SCHEDULE");
oDataRowLastUp = oDB->dRowSQL_Select(sSQL);
textLastUp->Text = oDataRowLastUp->Item[0]->ToString();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -