⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmmodifyresult.cpp

📁 这是一个工厂的生产线的仓库管理.有计划,实绩,库存等
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		
		//update stock_data

		if (!blnInstStockData(strPartChCode,strInRank,intInNum * sngCNum,txtLot1->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)){
//
//			
//			oDB1->blnCnnClose();
//			return false;
//		}
//		
	}
	
	

	return true;
	}





/********************************************************************
	created     :	KasenHOo @ Eleplan
    Name        :   blnInstStockData
	Date		:   2005/11/16
	In			:   ?
	Out			:   ?
	Update		:   YeFeng @ 2006/4/10
*********************************************************************/

bool FAP::frmModifyResult::blnInstStockData(String *strProCode,String *strRank,Single intNum,String *strLot)
{
	int intUptRcrds;
	String * strSQL;
	bool blnInst;
	Single intNumbac;
	
	
	// add by kasenhoo @ 051128
	//int intUptNum;
	DataSet * dSetTmp;
	DataTable *dTableTmp ;
	
	intNumbac = intNum;

	//找查原材料在仓库里面还有没有
	strSQL = S"select * from stock_data where PRODUCT_CODE = '";
	strSQL = String::Concat(strSQL,strProCode,S"' and STOCK_POS = '",oInf->strProcess,S"'");
	strSQL = String::Concat(strSQL,S" and FACTORY_CODE = '",oInf->strFactoryCode,S"'");
	
	if (!(strRank->Trim()->CompareTo(S"")==0))
		strSQL = String::Concat(strSQL,S" and rank = '",strRank,S"'" );

	strSQL = String::Concat(strSQL,S" and trim(lot) is not null and lot<>'-1000000' and STOCK_TYPE = 0 and STOCK_QTY>0 ");

	strSQL = String::Concat(strSQL, S" order by lot asc");

	oDB1->blnCnnOpen();

	dSetTmp = oDB1->dSetSQL_Select(strSQL,S"TEMP",0);

	oDB1->blnCnnClose();

	//Get Table
	dTableTmp = dSetTmp->Tables->Item[S"TEMP"];

	System::Collections::IEnumerator* emnFapRow = dTableTmp->Rows->GetEnumerator();

	emnFapRow->Reset();

	//Get All Chile Part
	while (emnFapRow->MoveNext())
	{
		DataRow *dRowTmp = __try_cast<DataRow*>(emnFapRow->Current);

		Single intCutNum = Convert::ToSingle(dRowTmp->Item[S"stock_qty"]);

		//dRowTmp->BeginEdit();

		//用需要消的库存减去已有的库存
		//如果intuptnum》0,说明已有库存不够
		//如果<0, 说明库存够的

		
		intNum = intNum - intCutNum;
		//没有原材料的情况下
		if (intNum >= 0){
			strSQL = S"update stock_data set stock_qty = 0 ";
		}
		else{
			//有原材料的情况下
			strSQL = S"update stock_data set stock_qty = stock_qty - ";
			strSQL = String::Concat(strSQL,intNumbac.ToString());
			
		}

		strSQL =String::Concat( strSQL,S" where PRODUCT_CODE = '");
		
		strSQL = String::Concat(strSQL,strProCode,S"' and STOCK_POS = '",oInf->strProcess,S"'");

		strSQL = String::Concat(strSQL,S" and FACTORY_CODE = '",oInf->strFactoryCode,S"' and STOCK_TYPE = 0 ");

		if (!(strRank->Trim()->CompareTo(S"")==0))
			strSQL = String::Concat(strSQL,S" and rank = '",strRank,S"'" );

		if (Convert::ToString(dRowTmp->Item[S"lot"])->CompareTo(S"")>0)
			strSQL = String::Concat(strSQL, S" and lot = '",Convert::ToString(dRowTmp->Item[S"lot"]),S"'");

		if (!oDB->blnSQL_Execute(strSQL))
			return false;
		//dRowTmp->EndEdit();
		//dRowTmp->AcceptChanges();

		if (intNum >= 0)
		{
			strSQL = S"insert into f_result_note (order_no,product_code,parts_no,parts_code,product_qty,parts_qty) values ";
			strSQL = String::Concat(strSQL,S" (");
			strSQL = String::Concat(strSQL, S"'",strLot,S"',");
			strSQL = String::Concat(strSQL, S"'",cmbproduct1->Text,S"',");
			strSQL = String::Concat(strSQL, S"'",dRowTmp->Item[S"lot"]->ToString(),S"',");
			strSQL = String::Concat(strSQL, S"'",strProCode,S"',");
			strSQL = String::Concat(strSQL, txtQuantity->Text,S",");
			strSQL = String::Concat(strSQL, Convert::ToString(intCutNum),S")");

		}
		else
		{
			strSQL = S"insert into f_result_note (order_no,product_code,parts_no,parts_code,product_qty,parts_qty) values ";
			strSQL = String::Concat(strSQL,S" (");
			strSQL = String::Concat(strSQL, S"'",strLot,S"',");
			strSQL = String::Concat(strSQL, S"'",cmbproduct1->Text,S"',");
			strSQL = String::Concat(strSQL, S"'",dRowTmp->Item[S"lot"]->ToString(),S"',");
			strSQL = String::Concat(strSQL, S"'",strProCode,S"',");
			strSQL = String::Concat(strSQL, txtQuantity->Text,S",");
			strSQL = String::Concat(strSQL, Convert::ToString(intCutNum - (intNum * -1)),S")");
		}

		blnInst = oDB->blnSQL_Execute(strSQL);
		
		if (!blnInst)
			return false;

		if (intNum<=0){
			break;
		}

	}
	
	//减去原材料的库存
	if (intNum > 0){

		strSQL = S"update stock_data set stock_qty = stock_qty - ";
		strSQL = String::Concat(strSQL, intNum.ToString());

		strSQL = String::Concat( strSQL,S" where PRODUCT_CODE = '");
		strSQL = String::Concat(strSQL,strProCode,S"' and STOCK_POS = '",oInf->strProcess,S"'");
		strSQL = String::Concat(strSQL,S" and FACTORY_CODE = '",oInf->strFactoryCode,S"' and STOCK_TYPE = 0");

		if (!(strRank->Trim()->CompareTo(S"")==0))
			strSQL = String::Concat(strSQL,S" and rank = '",strRank,S"'" );


		strSQL = String::Concat(strSQL, S" and trim(lot) is not null and lot='-1000000'");

		if (!oDB->blnSQL_Execute(strSQL,&intUptRcrds))
			return false;


		strSQL = S"insert into f_result_note (order_no,product_code,parts_no,parts_code,product_qty,parts_qty) values ";
		strSQL = String::Concat(strSQL,S" (");
		strSQL = String::Concat(strSQL, S"'",strLot,S"',");
		strSQL = String::Concat(strSQL, S"'",cmbproduct1->Text,S"',");
		strSQL = String::Concat(strSQL, S"'",S"-1000000",S"',");
		strSQL = String::Concat(strSQL, S"'",strProCode,S"',");
		strSQL = String::Concat(strSQL, txtQuantity->Text,S",");
		strSQL = String::Concat(strSQL, intNum.ToString(),S")");

		blnInst = oDB->blnSQL_Execute(strSQL);
		
		if (!blnInst)
		return false;



	//更新不成功的话,执行新增操作
		if (intUptRcrds <= 0){
			
			strSQL = S"insert into stock_data (FACTORY_CODE,STOCK_POS,PRODUCT_CODE,RANK,STOCK_TYPE,STOCK_QTY,LOT) values ";
			strSQL = String::Concat(strSQL,S" (");
			strSQL = String::Concat(strSQL, S"'",oInf->strFactoryCode,S"',");
			strSQL = String::Concat(strSQL, S"'",oInf->strProcess,S"',");
			strSQL = String::Concat(strSQL, S"'",strProCode,S"',");
			strSQL = String::Concat(strSQL, S"'",strRank,S"',");
			strSQL = String::Concat(strSQL, S"0,");
			strSQL = String::Concat(strSQL, S"-",intNum.ToString(),S",");
			strSQL = String::Concat(strSQL, S"'-1000000')");

			blnInst = oDB->blnSQL_Execute(strSQL);

		
			if (!blnInst)
				return false;

		}
	}
	

//	strSQL = S"update stock_data set STOCK_QTY = STOCK_QTY + ";
//	strSQL = String::Concat(strSQL, intNum.ToString());
//	strSQL = String::Concat(strSQL,S" where PRODUCT_CODE = '",strProCode->Trim(),S"'");
//	strSQL = String::Concat(strSQL,S" and STOCK_TYPE = 1");
//	strSQL = String::Concat(strSQL,S" and STOCK_POS = '", infClsRstInput->strProcess,S"'");
//	strSQL = String::Concat(strSQL,S" and lot = '", strLot ,S"'");
//
//	if (!(strRank->Trim()->CompareTo(S"")==0))
//		strSQL = String::Concat(strSQL,S" and rank = '",strRank,S"'" );
//
//	blnInst = DBBRstInput->blnSQL_Execute(strSQL,&intUptRcrds);
//
//	if (!blnInst)
//		return false;
	
//	if (intUptRcrds == 0) {
		
//		strSQL = S"insert into stock_data (FACTORY_CODE,STORE_POS,PRODUCT_CODE,RANK,STOCK_TYPE,STOCK_QTY,LOT) values ";
//		strSQL = String::Concat(strSQL,S" (");
//		strSQL = String::Concat(strSQL, S"'",infClsRstInput->strFactoryCode,S"',");
//		strSQL = String::Concat(strSQL, S"'",infClsRstInput->strProcess,S"',");
//		strSQL = String::Concat(strSQL, S"'",strProCode,S"',");
//		strSQL = String::Concat(strSQL, S"'",strRank,S"',");
//		strSQL = String::Concat(strSQL, S"1,");
//		strSQL = String::Concat(strSQL, intNum.ToString(),S",");
//		strSQL = String::Concat(strSQL,S"'", strLot,S"'");
//
//		strSQL = String::Concat(strSQL,S" )");
//	}
//	else
//	{
//		return true;
//	}

	return true;
}


bool FAP::frmModifyResult::blnInstProData(String *strProCode,String * strRank,Single intNum,String *strOrder)
{

	
	//Insert into product_result _data

	DateTime dteTmp ;	 
	String * strSQL ;

	int intTmp;

	dteTmp = DateTime::Now;

	strSQL = S"update product_result_data set PRODUCT_QTY = PRODUCT_QTY + ";
	strSQL = String::Concat(strSQL,intNum.ToString());
	strSQL = String::Concat(strSQL,S" where FACTORY_CODE = '",oInf->strFactoryCode,S"'");
	strSQL = String::Concat(strSQL,S" and LINE_CODE = '",strPLine(cmbLine1->SelectedIndex),S"'");
	strSQL = String::Concat(strSQL,S" and PROCESS_NO = '",sProcess,S"'");
	strSQL = String::Concat(strSQL,S" and PRODUCT_CODE = '",cmbproduct1->Text,S"'");
	strSQL = String::Concat(strSQL,S" and shift = '",strPshift(cmbShift1->SelectedIndex),S"'");
	strSQL = String::Concat(strSQL,S" and ymd = to_date('",labYmd->Text,S"','YYYY-MM-DD')");
    

	if (strRank->get_Length()>0){
		strSQL = String::Concat(strSQL,S" and rank = '",strRank,S"'");

	}
	strSQL = String::Concat(strSQL,S" and LOT = '",strOrder,S"'");

	if (!oDB->blnSQL_Execute(strSQL,&intTmp)){
		//DBBRstInput->blnRollBack();
		return false;
	}
	
	if (intTmp <=0) {

		strSQL = S"insert into PRODUCT_RESULT_DATA values  ";
		strSQL = String::Concat(strSQL,S"('",oInf->strFactoryCode,S"',");
		strSQL = String::Concat(strSQL,S"'",strPLine(cmbLine1->SelectedIndex),S"',");
		strSQL = String::Concat(strSQL,S"'",sProcess,S"',");
		strSQL = String::Concat(strSQL,S"'",cmbproduct1->Text,S"',");
		strSQL = String::Concat(strSQL,S"'",strRank,S"',");
		strSQL = String::Concat(strSQL,intNum.ToString(),S",");
		strSQL = String::Concat(strSQL,S"0,");

		dteTmp = *__try_cast<DateTime*>(Convert::ChangeType(labYmd->Text->ToString(), __typeof(DateTime)));

		strSQL = String::Concat(strSQL,S"to_date('",String::Format("{0:yyyy-MM-dd}",__box( dteTmp)),S"','yyyy-MM-dd'),");
		strSQL = String::Concat(strSQL,S"'",strPshift(cmbShift1->SelectedIndex),S"',");
		strSQL = String::Concat(strSQL,S"'",strPTeam(cmbTeam1->SelectedIndex),S"',");
		strSQL = String::Concat(strSQL, strOrder,S",");
		strSQL = String::Concat(strSQL,S"to_date('",String::Format("{0:yyyy-MM-dd}",__box(DateTime::Today)) ,S"','yyyy-MM-dd'))");

		if (!oDB->blnSQL_Execute(strSQL)){
			//DBBRstInput->blnRollBack();
			return false;
		}

	}



	intTmp = 0;

	//insert into stock_data
	strSQL = S"update stock_data set stock_qty = stock_qty + ";
	strSQL = String::Concat(strSQL,intNum.ToString());
	strSQL = String::Concat(strSQL,S" where FACTORY_CODE = '",oInf->strFactoryCode,S"'");
	strSQL = String::Concat(strSQL,S" and STOCK_POS = '",oInf->strProcess,S"'");
	strSQL = String::Concat(strSQL,S" and PRODUCT_CODE = '",strProCode,S"'");

	if (strRank->get_Length()>0){
		strSQL = String::Concat(strSQL,S" and rank = '",strRank,S"'");

	}
	strSQL = String::Concat(strSQL,S" and LOT = '",strOrder,S"'");

	if (!oDB->blnSQL_Execute(strSQL,&intTmp)){
		//DBBRstInput->blnRollBack();
		return false;
	}

	/*FACTORY_CODE
	STOck_POS
	PRODUCT_CODE
	RANK
	STOCK_TYPE
	STOCK_QTY
	LOT*/

	if (intTmp <=0) {

		strSQL = S"insert into stock_data(FACTORY_CODE,STOck_POS,PRODUCT_CODE,RANK,STOCK_QTY,STOCK_TYPE,LOT) values  ";
		strSQL = String::Concat(strSQL,S"('",oInf->strFactoryCode,S"',");
		strSQL = String::Concat(strSQL,S"'",oInf->strProcess,S"',");		
		strSQL = String::Concat(strSQL,S"'",strProCode,S"',");
		strSQL = String::Concat(strSQL,S"'",strRank,S"',");
		strSQL = String::Concat(strSQL,intNum.ToString(),S",");
		strSQL = String::Concat(strSQL,S"1,");
		strSQL = String::Concat(strSQL,S"'", strOrder,S"')");

		if (!oDB->blnSQL_Execute(strSQL)){
			//DBBRstInput->blnRollBack();
			return false;
		}

	}

	return true;
}


String * FAP::frmModifyResult::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"";

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -