📄 productresultinput.cpp
字号:
#include "StdAfx.h"
#include "ProductResultInput.h"
#include "DBBase.h"
using namespace System::Data;
using namespace System::Data::OleDb;
using namespace FAP;
String * FAP::ProductResultInput::strGetProName(String * strDelFromNo,
int iLanguage,
DBBase * DBbTmp)
{
System::Data::DataRow *dRowTmp;
String *strSQL = S"select * from parts_mst ";
String *strFdName ;
if (String::Compare(strDelFromNo->Trim(), S"")!=0)
strSQL=String::Concat (strSQL, S" where product_code = '" ,strDelFromNo->Trim(),S"'");
else
{
return S"";
}
if (DBbTmp->blnCnnOpen()==false) {
MessageBox::Show(S"Open Oracle Failed!!",S"ProductResult",MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
return S"";
}
switch(iLanguage) {
case FapLan_EN:
strFdName = S"PARTS_NAME_e";
break;
case FapLan_JP:
strFdName = S"PARTS_NAME_j";
break;
case FapLan_CN:
strFdName = S"PARTS_NAME_C";
break;
default:
strFdName = S"PARTS_NAME_C";
}
dRowTmp = DBbTmp->dRowSQL_Select(strSQL);
try
{
DBbTmp->blnCnnClose ();
}
catch (...) {
return S"";
}
try
{
return Convert::ToString(dRowTmp->Item[strFdName]);
}
catch (Exception *ex) {
//MessageBox::Show(S"取得产品名失败!!");
return S"";
}
}
bool FAP::ProductResultInput::blnChkCPart(String * strProcessNo,Single intInNum,String * strInRank, String * strProCode)
{
String * strSQL;
DataSet * dSetTmp ;
DataTable * dTableTmp;
String * strPartChCode; //child part code
Single sngCNum; //child part nums per parent part
//modify by kasenhoo@060302
//int intStockNum; //child part stock num
Single intStockNum; //child part stock num
//end
String * strStoreNo; //Store No
if (!(DBBRstInput->blnCnnOpen()))
{
MessageBox::Show(S"Connect Oracle Failed!",S"Product");
return false;
}
//Get Store No
strStoreNo = strGetStoreNo(strProcessNo,DBBRstInput);
//strStoreNo = strGetStoreNo(strFacCode,DBBRstInput);
if (strStoreNo->CompareTo(S"")==0) {
MessageBox::Show(S"取得工序号失败!!",S"Error");
return false;
}
//如果有代替品
if (blnoSerchor(DBBRstInput,txtOrder->Text)==true)
{
//只消耗代替品
strSQL = String::Concat(S"select product_code,parts_code,or_parts,percent from parts_composition_byorder where order_no='",txtOrder->Text,S"' and percent<>0 ");
dSetTmp = DBBRstInput->dSetSQL_Select(strSQL,S"parts_composition_byorder",0);
dTableTmp = dSetTmp->Tables->Item[S"parts_composition_byorder"];
DBBRstInput->blnCnnClose();
System::Collections::IEnumerator* emnFapRow = dTableTmp->Rows->GetEnumerator();
emnFapRow->Reset();
//Get All Chile Part
//查找这种原材料存不存在
while (emnFapRow->MoveNext())
{
DataRow *dRowTmp = __try_cast<DataRow*>(emnFapRow->Current);
strPartChCode = dRowTmp->Item[S"parts_code"]->ToString();
sngCNum = Single::Parse(String::Format("{0:########.000}",dRowTmp->Item[S"percent"]));
sngCNum = sngCNum / Convert::ToSingle(S"100");
strSQL = S"select * from STOCK_DATA where Stock_type = 0 and ";
strSQL = String::Concat(strSQL,S" factory_code = '",infClsRstInput->strFactoryCode,"' and" );
strSQL = String::Concat(strSQL,S" stock_pos = '", strStoreNo,S"' and " );
strSQL = String::Concat(strSQL,S" product_code = '",strPartChCode, S"' " );
strSQL = String::Concat(strSQL,S" and trim(lot) is not null");
if (strInRank->Trim()->CompareTo(S"")>0)
strSQL = String::Concat(strSQL,S" and rank = '",strInRank,S"'" );
strSQL = String::Concat(strSQL,S" and rownum < 2 ");
DBBRstInput->blnCnnOpen();
/*dSetTmp->Clear();*/
DataRow *dRowTmp1 = DBBRstInput->dRowSQL_Select(strSQL);
try {
intStockNum = Convert::ToSingle(dRowTmp1->Item[S"STOCK_QTY"]);
}
catch (...) {
intStockNum = 0;
}
DBBRstInput->blnCnnClose();
if (!blnInstStockData(strPartChCode,strInRank,intInNum * sngCNum,txtOrder->Text)){
return false;
}
}
//消耗替代品的源料
if (sngCNum!=Convert::ToSingle(S"1"))
{
strSQL = String::Concat(S"select product_code,parts_code,or_parts,percent from parts_composition_byorder where order_no='",txtOrder->Text,S"' and percent=0 ");
dSetTmp = DBBRstInput->dSetSQL_Select(strSQL,S"parts_composition_byorder2",0);
dTableTmp = dSetTmp->Tables->Item[S"parts_composition_byorder2"];
DBBRstInput->blnCnnClose();
System::Collections::IEnumerator* emnFapRow = dTableTmp->Rows->GetEnumerator();
emnFapRow->Reset();
//Get All Chile Part
//查找这种原材料存不存在
while (emnFapRow->MoveNext())
{
DataRow *dRowTmp = __try_cast<DataRow*>(emnFapRow->Current);
strPartChCode = dRowTmp->Item[S"parts_code"]->ToString();
sngCNum=Convert::ToSingle(S"1") - sngCNum;
strSQL = S"select * from STOCK_DATA where Stock_type = 0 and ";
strSQL = String::Concat(strSQL,S" factory_code = '",infClsRstInput->strFactoryCode,"' and" );
strSQL = String::Concat(strSQL,S" stock_pos = '", strStoreNo,S"' and " );
strSQL = String::Concat(strSQL,S" product_code = '",strPartChCode, S"' " );
strSQL = String::Concat(strSQL,S" and trim(lot) is not null");
if (strInRank->Trim()->CompareTo(S"")>0)
strSQL = String::Concat(strSQL,S" and rank = '",strInRank,S"'" );
strSQL = String::Concat(strSQL,S" and rownum < 2 ");
DBBRstInput->blnCnnOpen();
/*dSetTmp->Clear();*/
DataRow *dRowTmp1 = DBBRstInput->dRowSQL_Select(strSQL);
try {
intStockNum = Convert::ToSingle(dRowTmp1->Item[S"STOCK_QTY"]);
}
catch (...) {
intStockNum = 0;
}
DBBRstInput->blnCnnClose();
if (!blnInstStockData(strPartChCode,strInRank,intInNum * sngCNum,txtOrder->Text)){
return false;
}
}
}
//消耗源料
strSQL = S"";
strSQL = String::Concat(strSQL,S" select a.product_code as product_code,a.parts_code as parts_code,b.valid_ymd as valid_ymd,b.parts_count as parts_count from parts_composition_byorder a ");
strSQL = String::Concat(strSQL,S" left outer join part_composition b on a.product_code=b.product_code and a.parts_code=b.parts_code where a.order_no='",txtOrder->Text,S"' and a.or_parts is null ");
dSetTmp = DBBRstInput->dSetSQL_Select(strSQL,S"parts_composition_byorder1",0);
dTableTmp = dSetTmp->Tables->Item[S"parts_composition_byorder1"];
DBBRstInput->blnCnnClose();
System::Collections::IEnumerator* emnFapRow1 = dTableTmp->Rows->GetEnumerator();
emnFapRow1->Reset();
//Get All Chile Part
//查找这种原材料存不存在
while (emnFapRow1->MoveNext())
{
DataRow *dRowTmp = __try_cast<DataRow*>(emnFapRow1->Current);
strPartChCode = dRowTmp->Item[S"parts_code"]->ToString();
sngCNum = Single::Parse(String::Format("{0:########.000}",dRowTmp->Item[S"parts_count"]));
strSQL = S"select * from STOCK_DATA where Stock_type = 0 and ";
strSQL = String::Concat(strSQL,S" factory_code = '",infClsRstInput->strFactoryCode,"' and" );
strSQL = String::Concat(strSQL,S" stock_pos = '", strStoreNo,S"' and " );
strSQL = String::Concat(strSQL,S" product_code = '",strPartChCode, S"' " );
strSQL = String::Concat(strSQL,S" and trim(lot) is not null");
if (strInRank->Trim()->CompareTo(S"")>0)
strSQL = String::Concat(strSQL,S" and rank = '",strInRank,S"'" );
strSQL = String::Concat(strSQL,S" and rownum < 2 ");
DBBRstInput->blnCnnOpen();
/*dSetTmp->Clear();*/
DataRow *dRowTmp1 = DBBRstInput->dRowSQL_Select(strSQL);
try {
intStockNum = Convert::ToSingle(dRowTmp1->Item[S"STOCK_QTY"]);
}
catch (...) {
intStockNum = 0;
}
DBBRstInput->blnCnnClose();
if (!blnInstStockData(strPartChCode,strInRank,intInNum * sngCNum,txtOrder->Text)){
return false;
}
}
}
else
{
//查找bom消费的原材料是什么
strSQL =String::Format(S"select * from {0} ", DBBase::CstrPART_COMPOSITION);
strSQL = String::Concat(strSQL,S" where product_code = '",strProCode,S"'");
dSetTmp = DBBRstInput->dSetSQL_Select(strSQL,DBBase::CstrPART_COMPOSITION,0);
//Get Table
dTableTmp = dSetTmp->Tables->Item[DBBase::CstrPART_COMPOSITION];
DBBRstInput->blnCnnClose();
System::Collections::IEnumerator* emnFapRow = dTableTmp->Rows->GetEnumerator();
emnFapRow->Reset();
//Get All Chile Part
//查找这种原材料存不存在
while (emnFapRow->MoveNext())
{
DataRow *dRowTmp = __try_cast<DataRow*>(emnFapRow->Current);
strPartChCode = dRowTmp->Item[S"PARTS_CODE"]->ToString();
sngCNum = Single::Parse(String::Format("{0:########.000}",dRowTmp->Item[S"PARTS_COUNT"]));
strSQL = S"select * from STOCK_DATA where Stock_type = 0 and ";
strSQL = String::Concat(strSQL,S" factory_code = '",infClsRstInput->strFactoryCode,"' and" );
strSQL = String::Concat(strSQL,S" stock_pos = '", strStoreNo,S"' and " );
strSQL = String::Concat(strSQL,S" product_code = '",strPartChCode, S"' " );
strSQL = String::Concat(strSQL,S" and trim(lot) is not null");
if (strInRank->Trim()->CompareTo(S"")>0)
strSQL = String::Concat(strSQL,S" and rank = '",strInRank,S"'" );
strSQL = String::Concat(strSQL,S" and rownum < 2 ");
DBBRstInput->blnCnnOpen();
/*dSetTmp->Clear();*/
DataRow *dRowTmp1 = DBBRstInput->dRowSQL_Select(strSQL);
try {
//modify by kasenhoo@060301
/*String *strTmp1 = String::Format("{0:######}",dRowTmp1->Item[S"stock_qty"]);
intStockNum = Int32::Parse(strTmp1);*/
//intStockNum =Single::Parse(String::Format("{0:########.000}",dRowTmp->Item[S"stock_qty"]));
intStockNum = Convert::ToSingle(dRowTmp1->Item[S"STOCK_QTY"]);
//end
}
catch (...) {
intStockNum = 0;
}
DBBRstInput->blnCnnClose();
/*if (intStockNum < intInNum * sngCNum ) {
MessageBox::Show(String::Format(S"部件‘{0}’库存不够 !!",strPartChCode),S"Product");
DBBRstInput->blnCnnClose();
return false;
}*/
//update stock_data
if (!blnInstStockData(strPartChCode,strInRank,intInNum * sngCNum,txtOrder->Text)){
return false;
}
//strSQL =String::Format( S"update stock_data set STOCK_QTY = STOCK_QTY - {0} ", (intInNum * sngCNum).ToString());
//strSQL = String::Concat( strSQL ,S" where Stock_type = 0 and ");
//// strSQL = String::Concat(strSQL,S" factory_code = '{0}' and", infClsRstInput->strFactoryCode);
//strSQL = String::Concat(strSQL,S" stock_pos = '", strStoreNo,S"' and " );
//strSQL = String::Concat(strSQL,S" product_code = '",strPartChCode, S"' " );
////strSQL = String::Concat(strSQL,S" rank = '",strInRank,S"'" );
//if (strInRank->Trim()->CompareTo(S"")>0){
// strSQL = String::Concat(strSQL,S" and rank = '",strInRank,S"'" );
//}
// if (!DBBRstInExec->blnSQL_Execute(strSQL)){
//
//
// DBBRstInput->blnCnnClose();
// return false;
// }
//
}
}
return true;
}
//String * FAP::ProductResultInput::strGetStoreNo(String * strFacCode,DBBase * DBTmp)
String * FAP::ProductResultInput::strGetStoreNo(String * strProcessCode,DBBase * DBTmp)
{
String * strSQL;
DataRow * dRowTmp;
//strSQL =String::Format(S"select distinct STORE_NO from cost_mst where FACTORY_CODE = '{0}'",strFacCode);
strSQL =String::Format(S"select distinct STORE_NO from cost_mst where process_no = '{0}'",strProcessCode);
if (!DBTmp->blnCnnOpen()) {
MessageBox::Show(S"Open Oracle Error!! ",S"Product");
return S"";
}
dRowTmp = DBTmp->dRowSQL_Select(strSQL);
try
{
return dRowTmp->Item[S"STORE_NO"]->ToString();
}
catch (...) {
return S"";
}
}
bool FAP::ProductResultInput::blnoSerchor(DBBase * DBbTmp,String * strlot)
{
String * strSQL;
DataRow * dRowTmp;
if (!DBbTmp->blnCnnOpen()) {
MessageBox::Show(S"Open Oracle Error!! ",S"Product");
return false;
}
strSQL = S"";
strSQL = String::Concat(S"select count(*) as countnumber from parts_composition_byorder where order_no='",strlot,S"' and percent<>0 ");
dRowTmp = DBbTmp->dRowSQL_Select(strSQL);
try
{
if (0>=(Convert::ToInt32(dRowTmp->Item[S"countnumber"]->ToString())))
{
return false;
}
else
{
return true;
}
}
catch (...)
{
return false;
}
}
bool FAP::ProductResultInput::blnSerchBom(DBBase * DBbTmp,String * strlot)
{
String * strSQL;
DataRow * dRowTmp;
if (!DBbTmp->blnCnnOpen()) {
MessageBox::Show(S"Open Oracle Error!! ",S"Product");
return false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -