📄 stock.cpp
字号:
#include "StdAfx.h"
#include "Stock.h"
#include "StockCheck.h"
using namespace FAP;
using namespace Microsoft::VisualBasic;
void Stock::InitGrid(void)
{
DataGridTextBoxColumn *oProductCode;
DataGridTextBoxColumn *oPartsName;
DataGridTextBoxColumn *oQty;
DataGridTextBoxColumn *oOrigin;
DataGridTextBoxColumn *oD_YMD;
DataGridTextBoxColumn *oS_YMD;
DataGridTextBoxColumn *oLot;
DataGridTextBoxColumn *orowid;
oDataSet = new DataSet();
oTableStyle = new DataGridTableStyle();
oTableStyle->MappingName = S"GridData";
//ProductCode
oProductCode = new DataGridTextBoxColumn();
oProductCode->MappingName = S"PRODUCT_CODE";
oProductCode->HeaderText = String::Concat(S" ",oInf->saG_Code[iLanguage]);
oProductCode->Alignment = HorizontalAlignment::Center;
oProductCode->Width = 110;
//PartsName
oPartsName = new DataGridTextBoxColumn();
oPartsName->MappingName = S"PARTS_NAME";
oPartsName->HeaderText = String::Concat(S" ",oInf->saG_Name[iLanguage]);
oPartsName->Alignment = HorizontalAlignment::Center;
oPartsName->Width = 220;
//DeliverQty
oQty = new DataGridTextBoxColumn();
oQty->MappingName = S"DELIVER_QTY";
oQty->HeaderText = String::Concat(oInf->saG_QTY[iLanguage],S" \0");
oQty->Alignment = HorizontalAlignment::Right;
oQty->Width = 100;
oQty->Format =S"#,###";
//Origin Name
oOrigin = new DataGridTextBoxColumn();
oOrigin->MappingName = S"ORIGIN_NAME";
oOrigin->HeaderText = String::Concat(S" ",oInf->saG_Origin[iLanguage]);
oOrigin->Alignment = HorizontalAlignment::Center;
oOrigin->Width = 120;
//Deliver Date
oD_YMD = new DataGridTextBoxColumn();
oD_YMD->MappingName = S"DELIVER_YMD";
oD_YMD->HeaderText = String::Concat(S" ",oInf->saG_DeliYMD[iLanguage]);
oD_YMD->Alignment = HorizontalAlignment::Center;
oD_YMD->Width = 150;
//Stock Date
oS_YMD = new DataGridTextBoxColumn();
oS_YMD->MappingName = S"STOCK_YMD";
oS_YMD->HeaderText = String::Concat(S" ",oInf->saG_StocYMD[iLanguage]);
oS_YMD->Alignment = HorizontalAlignment::Left;
oS_YMD->Width = 110;
//Stock Lot
oLot = new DataGridTextBoxColumn();
oLot->MappingName = S"LOT";
oLot->HeaderText = String::Concat(S" ",oInf->saSAPLOT[iLanguage]);
oLot->Alignment = HorizontalAlignment::Center;
oLot->Width = 152;
//Stock rowid
orowid = new DataGridTextBoxColumn();
orowid->MappingName = S"rowid1";
orowid->HeaderText = "";
orowid->Alignment = HorizontalAlignment::Left;
orowid->Width = 0;
orowid->ReadOnly=true;
oTableStyle->GridColumnStyles->Add(oProductCode);
oTableStyle->GridColumnStyles->Add(oPartsName);
oTableStyle->GridColumnStyles->Add(oQty);
oTableStyle->GridColumnStyles->Add(oOrigin);
oTableStyle->GridColumnStyles->Add(oD_YMD);
oTableStyle->GridColumnStyles->Add(oS_YMD);
oTableStyle->GridColumnStyles->Add(oLot);
oTableStyle->GridColumnStyles->Add(orowid);
dataGridStock->TableStyles->Add(oTableStyle);
}
void Stock::GetGridData(void)
{
String* sSQL = S"";
String* saLang[] = {S"C", S"J", S"E"};
DateTime dtNow;
dtNow = DateTime::Now;
sSQL = String::Concat(sSQL, S"select" );
sSQL = String::Concat(sSQL, S" DD.ORIGIN_CODE as ORIGIN_CD," );
sSQL = String::Concat(sSQL, S" CO.NAME_" , saLang[iLanguage], S" as ORIGIN_NAME," );
sSQL = String::Concat(sSQL, S" DD.DESTINATION_CODE as DESTI_CD," );
sSQL = String::Concat(sSQL, S" CD.NAME_" , saLang[iLanguage], S" as DESTI_NAME," );
sSQL = String::Concat(sSQL, S" DD.PRODUCT_CODE," );
sSQL = String::Concat(sSQL, S" PM.PARTS_NAME_" , saLang[iLanguage], S" as PARTS_NAME," );
sSQL = String::Concat(sSQL, S" to_char(DD.DELIVER_YMD, 'yyyy/mm/dd') as DELIVER_YMD," );
sSQL = String::Concat(sSQL, S" decode(DD.STOCK_YMD, NULL,' ', to_char(DD.STOCK_YMD, 'yyyy/mm/dd hh24:mi')) as STOCK_YMD," );
sSQL = String::Concat(sSQL, S" DD.DELIVER_QTY," );
sSQL = String::Concat(sSQL, S" DD.RANK as RANK," );
sSQL = String::Concat(sSQL, S" DD.LOT as LOT, " );
sSQL = String::Concat(sSQL, S" DD.rowid as rowid1 " );
sSQL = String::Concat(sSQL, S"from" );
sSQL = String::Concat(sSQL, S" DELIVER_DATA DD," );
sSQL = String::Concat(sSQL, S" PARTS_MST PM," );
sSQL = String::Concat(sSQL, S" COST_MST CO, " );
sSQL = String::Concat(sSQL, S" COST_MST CD " );
sSQL = String::Concat(sSQL, S"where" );
sSQL = String::Concat(sSQL, S" DD.FACTORY_CODE = '", sFactory, S"' and" );
sSQL = String::Concat(sSQL, S" DD.DESTINATION_CODE = '", sProcess, S"' and" );
sSQL = String::Concat(sSQL, S" ( to_char(DD.STOCK_YMD, 'yyyy/mm/dd') = '", dtNow.ToString(L"yyyy/MM/dd"), S"' or" );
sSQL = String::Concat(sSQL, S" DD.STOCK_YMD is null ) and" );
sSQL = String::Concat(sSQL, S" DD.PRODUCT_CODE = PM.PRODUCT_CODE and" );
sSQL = String::Concat(sSQL, S" DD.FACTORY_CODE = CO.FACTORY_CODE and" );
sSQL = String::Concat(sSQL, S" DD.ORIGIN_CODE = CO.PROCESS_NO and" );
sSQL = String::Concat(sSQL, S" DD.FACTORY_CODE = CD.FACTORY_CODE and" );
sSQL = String::Concat(sSQL, S" DD.DESTINATION_CODE = CD.PROCESS_NO " );
sSQL = String::Concat(sSQL, S"order by" );
sSQL = String::Concat(sSQL, S" dd.DELIVER_YMD desc,dd.PRODUCT_CODE desc " );
oDataSet = oDB->dSetSQL_Select(sSQL, S"GridData", 0);
oDataTable = oDataSet->Tables->Item["GridData"];
dataGridStock->DataSource = oDataTable;
}
void Stock::DispStockCheck(int iNew)
{
StockCheck* oStockCheck;
BindingManagerBase* oBM;
DataRow* oDR;
String* sD_CD;
String* sD_Name;
String* sS_CD;
String* sS_Name;
String* sP_CD;
String* sP_Name;
String* sDeliver_ymd;
Decimal*iD_QTY;
String* sLot;
String* sRank;
String* sRowid1;
switch(iNew){
case 0:
oBM = dataGridStock->BindingContext->get_Item(oDataTable);
if(oBM->Count <= 0){
return;
}
oDR = (dynamic_cast<DataRowView*>(oBM->Current))->Row;
//Check Stocked
if(String::Compare(oDR->get_Item(S"STOCK_YMD")->ToString(), " ") == 0){
//GetParameter
sD_CD = oDR->get_Item(S"ORIGIN_CD")->ToString();
sD_Name = oDR->get_Item(S"ORIGIN_NAME")->ToString();
sS_CD = oDR->get_Item(S"DESTI_CD")->ToString();
sS_Name = oDR->get_Item(S"DESTI_NAME")->ToString();
sP_CD = oDR->get_Item(S"PRODUCT_CODE")->ToString();
sP_Name = oDR->get_Item(S"PARTS_NAME")->ToString();
sDeliver_ymd = oDR->get_Item(S"DELIVER_YMD")->ToString();
iD_QTY = dynamic_cast<Decimal*>(oDR->get_Item(S"DELIVER_QTY"));
sLot = oDR->get_Item(S"LOT")->ToString();
sRank = oDR->get_Item(S"RANK")->ToString();
sRowid1 = oDR->get_Item(S"rowid1")->ToString();
//Show Dialog
oStockCheck = new StockCheck(iNew, sD_CD, sD_Name, sS_CD, sS_Name, sP_CD, sP_Name, sDeliver_ymd, *iD_QTY, sLot, sRank, sFactory, cShift,oInf,sRowid1);
oStockCheck->ShowDialog(this);
} else {
return;
}
break;
default:
GetCostName(sProcess, &sS_Name);
sD_CD = S"";
sD_Name = S"";
sS_CD = sProcess;
sS_Name = sS_Name;
sP_CD = S"";
sP_Name = S"";
sDeliver_ymd = S"";
iD_QTY = __nogc new System::Decimal(0);
sLot = S"";
sRank = S"";
//Show Dialog
oStockCheck = new StockCheck(iNew, sD_CD, sD_Name, sS_CD, sS_Name, sP_CD, sP_Name, sDeliver_ymd, *iD_QTY, sLot, sRank, sFactory, cShift,oInf,sRowid1);
oStockCheck->ShowDialog();
break;
}
//Grid Renew
GetGridData();
dataGridStock->Refresh();
}
void Stock::GetCostName(String* sGetProcess, String** sName)
{
String* sSQL = S"";
String* saLang[] = {S"C", S"J", S"E"};
sSQL = String::Concat(sSQL, S"select" );
sSQL = String::Concat(sSQL, S" NAME_", saLang[iLanguage], S" as PROCESS_NAME " );
sSQL = String::Concat(sSQL, S"from" );
sSQL = String::Concat(sSQL, S" COST_MST " );
sSQL = String::Concat(sSQL, S"where" );
sSQL = String::Concat(sSQL, S" FACTORY_CODE = '", sFactory, S"' and" );
sSQL = String::Concat(sSQL, S" PROCESS_NO = '", sGetProcess, S"' " );
oDataSet = oDB->dSetSQL_Select(sSQL, S"CostName", 0);
oDataTable = oDataSet->Tables->Item["CostName"];
*sName = oDataTable->Rows->get_Item(0)->get_Item(S"PROCESS_NAME")->ToString();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -