📄 frmmodifyresult.cpp
字号:
}
else
{
StroCell=S"V线";
}
cmbLine1->Text=StroCell;
oCell.ColumnNumber=6;
StroCell = GModifyResult->Item[oCell]->ToString();
if (System::String::Equals(StroCell,"A"))
{
StroCell=S"A勤";
}
else
{
StroCell=S"B勤";
}
cmbShift1->Text=StroCell;
oCell.ColumnNumber=7;
StroCell = GModifyResult->Item[oCell]->ToString();
if (System::String::Equals(StroCell,"1"))
{
StroCell=S"1班";
}
else if (System::String::Equals(StroCell,"2"))
{
StroCell=S"2班";
}
else if (System::String::Equals(StroCell,"3"))
{
StroCell=S"3班";
}
cmbTeam1->Text=StroCell;
return true;
}
bool frmModifyResult::updateresult(DBBase * DBTmp,String * PsLot)
{
String *strSQL;
String *strShift;
String *strLine;
String *strTeam;
if (cmbLine1->SelectedIndex==0)
{
strLine=S"L001";
}
else
{
strLine=S"L002";
}
if (cmbShift1->SelectedIndex==0)
{
strShift=S"A";
}
else
{
strShift=S"B";
}
if (cmbTeam1->SelectedIndex==0)
{
strTeam=S"1";
}
else if (cmbTeam1->SelectedIndex==1)
{
strTeam=S"2";
}
else
{
strTeam=S"3";
}
strSQL = S"";
strSQL = String::Concat(strSQL,S" update product_result_data set shift='",strShift,S"',");
strSQL = String::Concat(strSQL,S" line_code='",strLine,S"',");
strSQL = String::Concat(strSQL,S" team='",strTeam,S"'");
strSQL = String::Concat(strSQL,S" where ");
strSQL = String::Concat(strSQL,S" factory_code='",sFactory,S"'");
strSQL = String::Concat(strSQL,S" and lot='",txtLot1->Text,S"'");
if (!oDB->blnCnnOpen())
{
MessageBox::Show(S"数据库连接失败!!");
return false;
}
oDB->blnBeginTrans();
DBTmp->blnSQL_Execute(strSQL);
try
{
DBTmp->blnCommit();
return true;
}
catch (...)
{
DBTmp->blnRollBack();
return false;
}
return true;
}
bool frmModifyResult::updateresultStockdata(DBBase * DBTmp,String * PsLot)
{
String *strSQL;
DataSet * dSetTmp ;
DataTable * dTableTmp;
String *strPartsNo;
String *strPartsCode;
Single sngCNum;
strSQL = S"";
strSQL = String::Concat(strSQL,S" select parts_no,parts_code,parts_qty from f_result_note where order_no='",PsLot,S"'");
DBTmp->blnCnnOpen();
dSetTmp = DBTmp->dSetSQL_Select(strSQL,S"resultnote",0);
dTableTmp = dSetTmp->Tables->Item[S"resultnote"];
DBTmp->blnCnnClose();
System::Collections::IEnumerator* emnFapRow = dTableTmp->Rows->GetEnumerator();
emnFapRow->Reset();
if (!oDB->blnCnnOpen()) {
MessageBox::Show(S"数据库连接失败!!");
return false;
}
oDB->blnBeginTrans();
while (emnFapRow->MoveNext())
{
DataRow *dRowTmp = __try_cast<DataRow*>(emnFapRow->Current);
strPartsNo = dRowTmp->Item[S"parts_no"]->ToString();
strPartsCode = dRowTmp->Item[S"parts_code"]->ToString();
sngCNum = Single::Parse(String::Format("{0:########.000}",dRowTmp->Item[S"parts_qty"]));
//删除源材料
if (updateYStockdata(oDB,strPartsNo,strPartsCode,sngCNum)==false)
{
oDB->blnRollBack();
return false;
}
}
//删除生产实绩
if (deleteresult(oDB,txtLot1->Text)==false)
{
oDB->blnRollBack();
return false;
}
//库存半成品加算
if (updateYStockdata1(oDB,txtLot1->Text,cmbproduct1->Text,labqty->Text)==false)
{
oDB->blnRollBack();
return false;
}
//删除记录原材料表
if (deleteYf_result_note(oDB)==false)
{
oDB->blnRollBack();
return false;
}
if (blnChkCPart(sProcess,Single::Parse(txtQuantity->Text),S"",cmbproduct1->Text) ==false )
{
oDB->blnRollBack();
return false;
}
if (!blnInstProData(cmbproduct1->Text,S"",Single::Parse(txtQuantity->Text),txtLot1->Text ))
{
oDB->blnRollBack();
return false;
}
oDB->blnCommit();
oDB->blnCnnClose();
return true;
}
bool frmModifyResult::updateYStockdata(DBBase * DBTmp,String * partscode,String * productcode,Single sngCNum)
{
String *strSQL;
strSQL = S"";
strSQL = String::Concat(strSQL,S" update stock_data set STOCK_QTY= STOCK_QTY + ",sngCNum.ToString(),S"");
strSQL = String::Concat(strSQL,S" where ");
strSQL = String::Concat(strSQL,S" factory_code='",sFactory,S"'");
strSQL = String::Concat(strSQL,S" and stock_pos='",sProcess,S"'");
strSQL = String::Concat(strSQL,S" and product_code='",productcode,S"'");
strSQL = String::Concat(strSQL,S" and lot='",partscode,S"'");
strSQL = String::Concat(strSQL,S" and stock_type='0'");
DBTmp->blnSQL_Execute(strSQL);
try
{
return true;
}
catch (...)
{
return false;
}
return true;
}
bool frmModifyResult::deleteresult(DBBase * DBTmp,String * partscode)
{
String *strSQL;
strSQL = S"";
strSQL = String::Concat(strSQL,S" delete from product_result_data ");
strSQL = String::Concat(strSQL,S" where ");
strSQL = String::Concat(strSQL,S" lot='",partscode,S"'");
DBTmp->blnSQL_Execute(strSQL);
try
{
}
catch (...)
{
return false;
}
return true;
}
bool frmModifyResult::updateYStockdata1(DBBase * DBTmp,String * partscode,String * productcode,String * sngCNum)
{
String *strSQL;
strSQL = S"";
strSQL = String::Concat(strSQL,S" update stock_data set STOCK_QTY= STOCK_QTY - ",sngCNum,S" ");
strSQL = String::Concat(strSQL,S" where ");
strSQL = String::Concat(strSQL,S" factory_code='",sFactory,S"'");
strSQL = String::Concat(strSQL,S" and stock_pos='",sProcess,S"'");
strSQL = String::Concat(strSQL,S" and product_code='",productcode,S"'");
strSQL = String::Concat(strSQL,S" and lot='",partscode,S"'");
strSQL = String::Concat(strSQL,S" and stock_type='1'");
DBTmp->blnSQL_Execute(strSQL);
try
{
return true;
}
catch (...)
{
return false;
}
return true;
}
bool frmModifyResult::deleteYf_result_note(DBBase * DBTmp)
{
String *strSQL;
strSQL = S"";
strSQL = String::Concat(strSQL,S" delete from f_result_note ");
strSQL = String::Concat(strSQL,S" where ");
strSQL = String::Concat(strSQL,S" order_no='",txtLot1->Text,S"'");
DBTmp->blnSQL_Execute(strSQL);
try
{
return true;
}
catch (...)
{
return false;
}
return true;
}
bool FAP::frmModifyResult::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
Single intStockNum; //child part stock num
//end
String * strStoreNo; //Store No
if (!(oDB1->blnCnnOpen()))
{
MessageBox::Show(S"Connect Oracle Failed!",S"Product");
return false;
}
//Get Store No
strStoreNo = strGetStoreNo(strProcessNo,oDB1);
//strStoreNo = strGetStoreNo(strFacCode,oDB1);
if (strStoreNo->CompareTo(S"")==0) {
MessageBox::Show(S"取得工序号失败!!",S"Error");
return false;
}
//查找bom消费的原材料是什么
strSQL =String::Format(S"select * from {0} ", DBBase::CstrPART_COMPOSITION);
strSQL = String::Concat(strSQL,S" where product_code = '",strProCode,S"'");
dSetTmp = oDB1->dSetSQL_Select(strSQL,DBBase::CstrPART_COMPOSITION,0);
//Get Table
dTableTmp = dSetTmp->Tables->Item[DBBase::CstrPART_COMPOSITION];
oDB1->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 = '",oInf->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 ");
oDB1->blnCnnOpen();
/*dSetTmp->Clear();*/
DataRow *dRowTmp1 = oDB1->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;
}
oDB1->blnCnnClose();
/*if (intStockNum < intInNum * sngCNum ) {
MessageBox::Show(String::Format(S"部件‘{0}’库存不够 !!",strPartChCode),S"Product");
oDB1->blnCnnClose();
return false;
}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -