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

📄 stockprocess.cpp

📁 这是一个工厂的生产线的仓库管理.有计划,实绩,库存等
💻 CPP
📖 第 1 页 / 共 4 页
字号:
#include "StdAfx.h"
#include "StockProcess.h"
using namespace FAP;

using namespace System;
//using namespace System::Diagnostics;
using namespace System::Reflection;
using namespace Microsoft::Office::Core;
using namespace Microsoft::Office::Interop;
using namespace System::IO;


DataTable * FAP::StockProcess::dtblGetYProcessPro(infClass *infTmp,DBBase * dBTMP)
{
	String * strSQL;
	DataTable *dtblTmp;
	DataSet * dsetTmp;

	strSQL = S"select PRODUCT_NO from process_pro where factory_no = ";
	strSQL = String::Concat(strSQL,S"'",infTmp->strFactoryCode,S"'");
	strSQL = String::Concat(strSQL,S" and Line_no = '",infTmp->strLine,S"'");
	strSQL = String::Concat(strSQL,S" and process_no = '",infTmp->strProcess,S"'");
	strSQL = String::Concat(strSQL,S" union ");
	strSQL = String::Concat(strSQL,S" select ");
	strSQL = String::Concat(strSQL,S" distinct ");
	strSQL = String::Concat(strSQL,S" b.parts_code  ");
	strSQL = String::Concat(strSQL,S" from process_pro a  ");
	strSQL = String::Concat(strSQL,S" right outer join part_composition b on ");
	strSQL = String::Concat(strSQL,S" a.product_no=b.product_code ");
	strSQL = String::Concat(strSQL,S" where process_no='",infTmp->strProcess,S"' ");
	strSQL = String::Concat(strSQL,S" and a.Line_no = '",infTmp->strLine,S"'");
	strSQL = String::Concat(strSQL,S" and a.factory_no = '",infTmp->strFactoryCode,S"'");

	dBTMP->blnCnnOpen();

	dsetTmp = dBTMP->dSetSQL_Select(strSQL,S"TMP",0);
	
	dBTMP->blnCnnClose();

	try
	{
		dtblTmp = dsetTmp->Tables->Item[S"TMP"];
	}
	
    catch (...) {
		return NULL;		
	}

	return dtblTmp;
}

void StockProcess::strGetORIGIN(DBBase * dBTMP,String *strfeng)
{
		OleDbDataReader *dReadTmp;
		String *strSQL = S" select distinct PROCESS_NO from part_composition a Right outer join process_pro b on a.parts_code=b.product_no where a.parts_code='";
		strSQL = String::Concat(strSQL,strfeng,S"'");
		
		if (dBTMP->blnCnnOpen()==false) {
			MessageBox::Show(S"Open Oracle Failed!!",S"Deliver",MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
			return ;
		}
		
		dReadTmp = dBTMP->dReadSQL_Select(strSQL);
		try
		{
			if (dReadTmp->HasRows==false)
			{
				cboReturn->Items->Add(S"MA00");
			}
			else
			{
				while(dReadTmp->Read())
				{
					cboReturn->Items->Add(dReadTmp->GetString(0));
				}
			}		
		}
		catch (...) {				
			return ;
		}
		
}


bool StockProcess::CreateViewFAP(String * strFilename)
{
	
	FileInfo *strAppfileName;
	strAppfileName = new FileInfo("FAP");
	
	pstrCsnPath=String::Concat(strAppfileName->DirectoryName,S"\\Excel\\");

	vstrYMDHIS=String::Concat(pstrCsnPath,vstrYMDHIS);

	vstrDateTime=String::Concat(pstrCsnPath,S"生产报废单",vstrDateTime,S".xls");

	////查找是否有相同文件,有就执行删除.
	//if (File::Exists(vstrYMDHIS)==true)
	//{
	//	File::Delete(vstrYMDHIS);
	//	return true;
	//}
	//else
	//{

		File::Copy(vstrYMDHIS,vstrDateTime,true);
	//}

	return true;

}

bool StockProcess::vetroDeal0(int intNum,String * Strnamec)
{
		String * strSQL;
		//strSQL = " update quality_control_data set QUANTITY = QUANTITY + "
		//strSQL = String::Concat(strSQL,strTmp1,S",");
		//strSQL = String::Concat(strSQL,S"TOTAL_PRICE = TOTAL_PRICE + ");
		//Single  strPrice = strGetPrice(cmbProCode->Text);
		//strSQL = String::Concat(strSQL,Convert::ToString(strPrice));
		//strSQL = String::Concat(strSQL,S" where  ");
		//strSQL = String::Concat(strSQL,);
		//strSQL = String::Concat(strSQL,);
		//strSQL = String::Concat(strSQL,);
		//strSQL = String::Concat(strSQL,);
		//strSQL = String::Concat(strSQL,);
		//strSQL = String::Concat(strSQL,);
		//strSQL = String::Concat(strSQL,);
		DBbStocka->blnCnnOpen();
	
		DBbStocka->blnBeginTrans();
		Single  strPrice = strGetPrice(cmbProCode->Text);


		strSQL = S" insert into QUALITY_CONTROL_DATA ";
		strSQL = String::Concat(strSQL,S"(FACTORY_CODE,LINE_CODE,PROCESS_NO,PRODUCT_CODE,REASON_DIV,destination_code,QUANTITY,UNIT_PRICE,TOTAL_PRICE,REASON_CODE,MANUFACT_YMD,SHIFT,LOT) ");
		strSQL = String::Concat(strSQL,S"values (");
		strSQL = String::Concat(strSQL,S"'",infStockProcess->strFactoryCode,S"',");
		strSQL = String::Concat(strSQL,S"'",infStockProcess->strLine,S"',");
		strSQL = String::Concat(strSQL,S"'",infStockProcess->strProcess,S"',");
		strSQL = String::Concat(strSQL,S"'",cmbProCode->Text,S"',");
		strSQL = String::Concat(strSQL,S"0,");
		strSQL = String::Concat(strSQL,S"(select COST_NO from cost_mst where PROCESS_NO='",infStockProcess->strProcess,S"'),");
		strSQL = String::Concat(strSQL,txtNum->Text,S",");
		strSQL = String::Concat(strSQL, strPrice.ToString(),S",");
		strSQL = String::Concat(strSQL,(strPrice * Convert::ToSingle(txtNum->Text)).ToString(),S",");
		strSQL = String::Concat(strSQL,Strnamec,S",");
		strSQL = String::Concat(strSQL, S"to_date('",(DateTime::Now).ToString(),S"','yyyy-mm-dd hh24:mi:ss'),");
		strSQL = String::Concat(strSQL,S"'",infStockProcess->strShift,S"',");
		strSQL = String::Concat(strSQL,S"'",txtLot->Text,S"'");
		strSQL = String::Concat(strSQL,S")");

		if (DBbStocka->blnSQL_Execute(strSQL)) 
		{
		//MessageBox::Show(S"处理成功!!");
		}
		else
		{
			return false;
		}


		strSQL = S"update stock_data set STOCK_QTY = STOCK_QTY -";
		strSQL = String::Concat(strSQL,txtNum->Text);
		strSQL = String::Concat(strSQL,S" where factory_code = '",infStockProcess->strFactoryCode,S"'");
		strSQL = String::Concat(strSQL,S" and STOCK_POS = '",infStockProcess->strProcess,S"'");
		strSQL = String::Concat(strSQL,S" and PRODUCT_CODE = '",cmbProCode->Text,S"'");
		strSQL = String::Concat(strSQL,S" and LOT = '",txtLot->Text,S"'");
		strSQL = String::Concat(strSQL,S" and stock_type = 2");

		if (DBbStocka->blnSQL_Execute(strSQL)) 
		{
		//MessageBox::Show(S"处理成功!!");
		}
		else
		{
			return false;
		}
		return true;
}

bool StockProcess::StrProduct()
{
	String *strSQL;
	OleDbDataReader *dReadTmp;
	strSQL = String::Concat(strSQL,S" select * from process_pro where product_no='",cmbProCode->Text,S"' and process_no='",infStockProcess->strProcess,S"'");
	DBbStockProcess->blnCnnOpen();
	dReadTmp = DBbStockProcess->dReadSQL_Select(strSQL);
	if (dReadTmp->HasRows==false)
	{
		return false;
	}
	else
	{
		return true;
	}
	return true;
}

bool StockProcess::DealM0(int intNum,String * Strnamec){
	String * strSQL;
	DataSet * dSetTmp;
	DataTable * dTableTmp;
	String * strPartChCode;
	String * strTmp1;
	int intstockqty;
	int intsumstockqty;

	strSQL=S"";
	strSQL=String::Concat(strSQL,S" select									");
	strSQL=String::Concat(strSQL,S"			STOCK_QTY,						");
	strSQL=String::Concat(strSQL,S"			product_code,					");
	strSQL=String::Concat(strSQL,S"			lot								");
	//strSQL=String::Concat(strSQL,S"			99991231 as ymd					");
	strSQL=String::Concat(strSQL,S" from									");
	strSQL=String::Concat(strSQL,S"			stock_data a					");
	strSQL=String::Concat(strSQL,S"       where a.product_code = '",Strnamec,S"'	");
	strSQL=String::Concat(strSQL,S"			and a.stock_pos = '",infStockProcess->strProcess,S"'	");
	strSQL=String::Concat(strSQL,S"		  and a.stock_type <> 2				");
	strSQL=String::Concat(strSQL,S"			and a.stock_qty <> 0			");
	strSQL=String::Concat(strSQL,S"			AND a.LOT IS NOT NULL	and a.stock_qty>0		");
	strSQL=String::Concat(strSQL,S"			AND a.LOT IS NOT NULL	 order by rownum desc	");
	
	DBbStockProcess->blnCnnOpen();

	dSetTmp = DBbStockProcess->dSetSQL_Select(strSQL,S"stock_data",0);

	dTableTmp = dSetTmp->Tables->Item[S"stock_data"];

	DBbStockProcess->blnCnnClose();

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

	emnFapRow->Reset();

	intsumstockqty=Convert::ToInt32(txtNum->Text);

	DBbStocka->blnCnnOpen();
	
	DBbStocka->blnBeginTrans();

	while (emnFapRow->MoveNext())
	{
		DataRow *dRowTmp = __try_cast<DataRow*>(emnFapRow->Current);

		strPartChCode=dRowTmp->Item[S"lot"]->ToString();
		
		strTmp1 = String::Format("{0:######}",dRowTmp->Item[S"STOCK_QTY"]);

		if (txtLot->Text->IndexOf(strPartChCode)<0)
		{
			return true;
		}

		intstockqty=System::Int32::Parse(strTmp1);

		intsumstockqty=intsumstockqty-intstockqty;

		Single  strPrice = strGetPrice(cmbProCode->Text);

		////////strSQL = S" insert into QUALITY_CONTROL_DATA ";
		////////strSQL = String::Concat(strSQL,S"(FACTORY_CODE,LINE_CODE,PROCESS_NO,PRODUCT_CODE,REASON_DIV,QUANTITY,UNIT_PRICE,TOTAL_PRICE,REASON_CODE,MANUFACT_YMD,SHIFT,LOT) ");
		////////strSQL = String::Concat(strSQL,S"values (");
		////////strSQL = String::Concat(strSQL,S"'",infStockProcess->strFactoryCode,S"',");
		////////strSQL = String::Concat(strSQL,S"'",infStockProcess->strLine,S"',");
		////////strSQL = String::Concat(strSQL,S"'",infStockProcess->strProcess,S"',");
		////////strSQL = String::Concat(strSQL,S"'",cmbProCode->Text,S"',");
		////////strSQL = String::Concat(strSQL,S"0,");
		////////if (intsumstockqty>0)
		////////{			
		////////	strSQL = String::Concat(strSQL,strTmp1,S",");
		////////	strSQL = String::Concat(strSQL, strPrice.ToString(),S",");
		////////	strSQL = String::Concat(strSQL,(strPrice * Convert::ToSingle(strTmp1)).ToString(),S",");
		////////}
		//////////没有批次的情况

		////////else
		////////{
		////////	strSQL = String::Concat(strSQL,Convert::ToString(intstockqty - (intsumstockqty * -1)),S",");	
		////////	strSQL = String::Concat(strSQL, strPrice.ToString(),S",");
		////////	strSQL = String::Concat(strSQL,(strPrice * Convert::ToSingle(intstockqty - (intsumstockqty * -1))).ToString(),S",");
		////////}

		////////strSQL = String::Concat(strSQL,Strnamec,S",");
		////////strSQL = String::Concat(strSQL, S"to_date('",(DateTime::Now).ToString(),S"','yyyy-mm-dd hh24:mi:ss'),");
		////////strSQL = String::Concat(strSQL,S"'",infStockProcess->strShift,S"',");
		////////strSQL = String::Concat(strSQL,S"'",strPartChCode,S"'");
		////////strSQL = String::Concat(strSQL,S")");

		////////if (DBbStocka->blnSQL_Execute(strSQL)) 
		////////{
		//////////MessageBox::Show(S"处理成功!!");
		////////}
		////////else
		////////{
		////////	return false;
		////////}
		////////Update stock_data

		strSQL = S"update stock_data set STOCK_QTY = STOCK_QTY +";
		if (intsumstockqty>0)
		{			
			strSQL = String::Concat(strSQL,strTmp1);
		}
		//没有批次的情况

		else
		{	
			strSQL = String::Concat(strSQL,Convert::ToString(intstockqty - (intsumstockqty * -1)));	
		}
		strSQL = String::Concat(strSQL,S" where factory_code = '",infStockProcess->strFactoryCode,S"'");
		strSQL = String::Concat(strSQL,S" and STOCK_POS = '",infStockProcess->strProcess,S"'");
		strSQL = String::Concat(strSQL,S" and PRODUCT_CODE = '",cmbProCode->Text,S"'");
		strSQL = String::Concat(strSQL,S" and LOT = '",strPartChCode,S"'");
		strSQL = String::Concat(strSQL,S" and stock_type = 2");

		int intUptRcrds;
		if (!DBbStocka->blnSQL_Execute(strSQL,&intUptRcrds))
		{
			return false;
		}
		if (intUptRcrds <= 0){

				strSQL = S"insert into stock_data(FACTORY_CODE,	STOCK_POS,PRODUCT_CODE,RANK,STOCK_TYPE,STOCK_QTY,LOT)  ";
				strSQL = String::Concat(strSQL,S" select FACTORY_CODE,	STOCK_POS,PRODUCT_CODE,RANK,2 as stock_type,");

				if (intsumstockqty>0)
				{			
					strSQL = String::Concat(strSQL,strTmp1);
					strSQL = String::Concat(strSQL,S" as stock_qty,LOT from stock_data where ");
				}
				//没有批次的情况

				else
				{	
					strSQL = String::Concat(strSQL,Convert::ToString(intstockqty - (intsumstockqty * -1)));	
					strSQL = String::Concat(strSQL,S" as stock_qty,LOT from stock_data where ");
				}
				strSQL = String::Concat(strSQL,S" factory_code = '",infStockProcess->strFactoryCode,S"'");
				strSQL = String::Concat(strSQL,S" and STOCK_POS = '",infStockProcess->strProcess,S"'");
				strSQL = String::Concat(strSQL,S" and PRODUCT_CODE = '",cmbProCode->Text,S"'");
				strSQL = String::Concat(strSQL,S" and LOT = '",strPartChCode,S"'");
				strSQL = String::Concat(strSQL,S" and stock_type <> 2 and rownum <2");
				
				if (DBbStocka->blnSQL_Execute(strSQL)) 
				{
					
				}
				else
				{
					return false;
				}
		}
		strSQL = S"update stock_data set STOCK_QTY = STOCK_QTY -";
		if (intsumstockqty>0)
		{			
			strSQL = String::Concat(strSQL,strTmp1);
		}
		//没有批次的情况

		else
		{	
			strSQL = String::Concat(strSQL,Convert::ToString(intstockqty - (intsumstockqty * -1)));	
		}
		strSQL = String::Concat(strSQL,S" where factory_code = '",infStockProcess->strFactoryCode,S"'");
		strSQL = String::Concat(strSQL,S" and STOCK_POS = '",infStockProcess->strProcess,S"'");
		strSQL = String::Concat(strSQL,S" and PRODUCT_CODE = '",cmbProCode->Text,S"'");
		strSQL = String::Concat(strSQL,S" and LOT = '",strPartChCode,S"'");
		strSQL = String::Concat(strSQL,S" and stock_type <> 2 and rownum <2");


		if (DBbStocka->blnSQL_Execute(strSQL)) 
		{
			
		}
		else{
			return false;
		}

		//MessageBox::Show(strSQL);

⌨️ 快捷键说明

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