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

📄 deliver.cpp

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

	String * strSQL;
	DataRow* dRowTmp;
	String *strTmp1 = S"";

	strSQL =String::Format("select * from stock_data where stock_pos = '{0}' and product_code = '{1}'",strStoreNo->Trim(),strProCode->Trim());

	if (String::Equals(strLotTmp,"-1")==false)
	{
		strSQL = String::Concat( strSQL,S" and lot = '",strLotTmp,S"'");
	}
	
	if (intStockType != 2) {
		strSQL = String::Concat( strSQL,S" and stock_type <> 2");
	}
	else 
	{
		strSQL = String::Concat( strSQL,S" and stock_type = ", intStockType.ToString());
	}

	if (DbbTmp->blnCnnOpen()==false) {
		
		return 0;
	}

	dRowTmp = DbbTmp->dRowSQL_Select(strSQL);

	try
	{
		DbbTmp->blnCnnClose  ();
	}
	catch (...) {
		return 0;
	}

	try
	{
		strTmp1 = String::Format("{0:######}",dRowTmp->Item[S"stock_qty"]);

		return Int32::Parse (strTmp1);
	}
	catch (...) {
		return 0;
	}

}

bool  FAP::Deliver::blnRankCheck(){
	
	return true;

}


bool	FAP::Deliver::blnInsertDel(String * strFactory, String * strOriginCode, 
					  String * strDesCode,String * ProCode,
					  String * strRank,Single intNum, 
					  int intPartsDiv,String * strDelDate,
					  String * strShift, String * ingLot ,int intpastrna,String * strstrvpe,String * strvteb){
	
		String * strSQL ;
		if(intSAP == 0)
		{
		strSQL = S"insert into deliver_data(FACTORY_CODE,ORIGIN_CODE,DESTINATION_CODE,PRODUCT_CODE,RANK,DELIVER_QTY,PARTS_DIV,DELIVER_YMD,SHIFT,LOT,RESLUT_YMD) values ";
		strSQL = String::Concat(strSQL,S"('",strFactory,S"',");
		strSQL = String::Concat(strSQL,S"'",strOriginCode,S"',");
		strSQL = String::Concat(strSQL,S"'",strDesCode,S"',");
		strSQL = String::Concat(strSQL,S"'",ProCode,S"',");
		strSQL = String::Concat(strSQL,S"'",strRank,S"',");

		if(intSAP == 0)
		{

			
			//已经没有批次了

			if (intpastrna==0)
			{
				strSQL = String::Concat(strSQL,S"'",(intNum - System::Single::Parse(strstrvpe)).ToString(),S"',");
				//strSQL = String::Concat(strSQL,S"(select stock_qty - ",strstrvpe,S" from stock_data t where lot='",ingLot,S"' and stock_type='1')",S",");
			}
			//出一个批次还有批次

			else 
			{
				strSQL = String::Concat(strSQL,S"'",intNum.ToString(),S"',");
				//strSQL = String::Concat(strSQL,S"(select stock_qty from stock_data t where lot='",ingLot,S"' and stock_type='1')",S",");
			}
		}
		else
		{
				strSQL = String::Concat(strSQL,S"'",intNum.ToString(),S"',");
		}
		strSQL = String::Concat(strSQL,S"(select parts_div from parts_mst where product_code = '",ProCode,S"' and rownum < 2) ,");
		strSQL = String::Concat(strSQL,S"to_date('",strDelDate,S"','yyyy-mm-dd hh24-mi-ss'),");
		//strSQL = String::Concat(strSQL,S"to_date('",strDelDate,S"','yyyy-mm-dd hh24-mi-ss'),");
		strSQL = String::Concat(strSQL,S"'",strShift->Trim(),S"',");
		strSQL = String::Concat(strSQL,S"'",ingLot,S"',");
		strSQL = String::Concat(strSQL,S"to_date('",strvteb,S"','yyyy-mm-dd'))");
		
		//add by kasenhoo @ 051108
		if (!DBDeliver->blnCnnOpen()) {
			return false;
		}
		//end

		DBDeliver->blnBeginTrans();

		if (!DBDeliver->blnSQL_Execute(strSQL))
		{
			return false;
		}
		}

		if(intSAP == 1	){

			//add by kasenhoo @ 051108
			if (!DBDeliver->blnCnnOpen()) {
				return false;
			}
			//end

			DBDeliver->blnBeginTrans();


			strSQL = S"insert into deliver_data(FACTORY_CODE,ORIGIN_CODE,DESTINATION_CODE,PRODUCT_CODE,RANK,DELIVER_QTY,PARTS_DIV,DELIVER_YMD,SHIFT,LOT,RESLUT_YMD) values ";
			strSQL = String::Concat(strSQL,S"('",strFactory,S"',");
			strSQL = String::Concat(strSQL,S"'",strOriginCode,S"',");
			strSQL = String::Concat(strSQL,S"'",strDesCode,S"',");
			strSQL = String::Concat(strSQL,S"'",ProCode,S"',");
			strSQL = String::Concat(strSQL,S"'",strRank,S"',");
			strSQL = String::Concat(strSQL,S"'",intNum.ToString(),S"',");
			strSQL = String::Concat(strSQL,S"(select parts_div from parts_mst where product_code = '",ProCode,S"' and rownum < 2) ,");
			strSQL = String::Concat(strSQL,S"to_date('",strDelDate,S"','yyyy-mm-dd hh24-mi-ss'),");
			strSQL = String::Concat(strSQL,S"'",strShift->Trim(),S"',");
			strSQL = String::Concat(strSQL,S"'",ingLot,S"',");
			strSQL = String::Concat(strSQL,S"to_date('",strvteb,S"','yyyy-mm-dd'))");

			if (!DBDeliver->blnSQL_Execute(strSQL))
			{
				return false; 
			}


			strSQL =String::Concat(S"update deliver_data_temp set STOCK_YMD = sysdate where SEQUENCE = " ,dRowSAP->Item[S"SEQUENCE"]->ToString());
		
			if (!DBDeliver->blnSQL_Execute(strSQL))
			{
				return false;
			}
			

			int iTmp;

			strSQL  = String::Concat( S"update stock_data set STOCK_QTY = STOCK_QTY + ", intNum.ToString());
			strSQL =String::Concat(strSQL,S" where product_code = '",ProCode,S"'");
			strSQL =String::Concat(strSQL,S" and lot = '",ingLot,S"'");
			strSQL =String::Concat(strSQL,S" and STOCK_POS = '",strOriginCode,S"'");

			if (!DBDeliver->blnSQL_Execute(strSQL,&iTmp)) {
				return false;
			} 
			
			if (iTmp == 0) {
			
					strSQL =S"insert into stock_data(FACTORY_CODE,STOCK_POS,PRODUCT_CODE,RANK,STOCK_TYPE,STOCK_QTY,LOT) values ";
					//,RESULT_YMD

					strSQL = String::Concat(strSQL,S"(");			
					strSQL = String::Concat(strSQL, S"'" ,strFactory,S"',");
					strSQL = String::Concat(strSQL, S"'" ,strOriginCode,S"',");
					strSQL = String::Concat(strSQL, S"'" ,ProCode,S"',");
					strSQL = String::Concat(strSQL, S"'" ,strRank,S"',");
					strSQL = String::Concat(strSQL, S"0,");
					strSQL = String::Concat(strSQL,intNum.ToString(),S",");
					
					strSQL = String::Concat(strSQL, S"'" ,ingLot,S"')");

					//strSQL = String::Concat(strSQL,S"to_date('",strvteb,S"','yyyy-mm-dd'))");

					if (!DBDeliver->blnSQL_Execute(strSQL))
					{
						return false; 
					}
			}
		}

		try{
			DBDeliver->blnCommit();
			return true;
		}
		catch (...) {
			//add by kasenhoo @ 051108
			DBDeliver->blnRollBack();
			//end

			return false;
		}
		__finally{

		}
		 

		return false;

}
//strVLong比例关系,startS接收到的单位,parts_mst单位
String * Deliver::sinNumber(String * strVLong,String * startS,String * EndS)
{
	String * StrUnit;
	int		strLong;
	int		strLong1;
	int		strLong2;
	int		plLong;
	int		plsum;

	if (String::Equals(strVLong,S"0"))
	{
		//公斤,克,毫克
		//KG,G,MG比例关系
		plLong=1000;
	}
	else if (String::Equals(strVLong,S"1"))
	{
		//米,分米,厘米
		//M,DM,CM比例关系
		plLong=10;
	}
	else if (String::Equals(strVLong,S"2"))
	{
		//十升,升,分升,厘升
		//DAL,L,DL,CL比例关系
		plLong=10;
	}

	if (String::Equals(startS,S"MG"))
	{
		strLong=0;
	}
	else if (String::Equals(startS,S"G"))
	{
		strLong=1;
	}
	else if (String::Equals(startS,S"KG"))
	{
		strLong=2;
	}
	else if (String::Equals(startS,S"CM"))
	{
		strLong=0;
	}
	else if (String::Equals(startS,S"DM"))
	{
		strLong=1;
	}
	else if (String::Equals(startS,S"M"))
	{
		strLong=2;
	}
	else if (String::Equals(startS,S"CL"))
	{
		strLong=0;
	}
	else if (String::Equals(startS,S"DL"))
	{
		strLong=1;
	}
	else if (String::Equals(startS,S"L"))
	{
		strLong=2;
	}
	else if (String::Equals(startS,S"DAL"))
	{
		strLong=3;
	}

	if (String::Equals(EndS,S"MG"))
	{
		strLong1=0;
	}
	else if (String::Equals(EndS,S"G"))
	{
		strLong1=1;
	}
	else if (String::Equals(EndS,S"KG"))
	{
		strLong1=2;
	}
	else if (String::Equals(EndS,S"CM"))
	{
		strLong1=0;
	}
	else if (String::Equals(EndS,S"DM"))
	{
		strLong1=1;
	}
	else if (String::Equals(EndS,S"M"))
	{
		strLong1=2;
	}
	else if (String::Equals(EndS,S"CL"))
	{
		strLong1=0;
	}
	else if (String::Equals(EndS,S"DL"))
	{
		strLong1=1;
	}
	else if (String::Equals(EndS,S"L"))
	{
		strLong1=2;
	}
	else if (String::Equals(EndS,S"DAL"))
	{
		strLong1=3;
	}

		strLong2=strLong-strLong1;

		if (strLong2==0)
		{
			return Convert::ToString((Convert::ToSingle(txtQuanity->Text)));
		}
		else
		{
			if (strLong2<0)
			{
				strLong2=strLong2 * -1;

				for(int ic=0;ic<strLong2;ic++)
				{
					plsum=plsum+plLong;
				}
				
				return Convert::ToString(Convert::ToSingle(txtQuanity->Text) / Convert::ToSingle(plsum));

			}
			else
			{
				for(int ic=0;ic<strLong2;ic++)
				{
					plsum=plsum+plLong;
				}
				
				return Convert::ToString(Convert::ToSingle(txtQuanity->Text) * Convert::ToSingle(plsum));
			}
		}
}

DataTable * FAP::Deliver::strGetPartsPC(DBBase * dBTMP,String *strfeng)
{
		
		DataTable *dtblTmp;
		DataSet * dsetTmp;
		String *strSQL = S" select distinct UNIT from parts_mst where product_code='";
		strSQL = String::Concat(strSQL,strfeng,S"'");
		
		if (dBTMP->blnCnnOpen()==false) {
			MessageBox::Show(S"Open Oracle Failed!!",S"Deliver",MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
			return NULL;
		}
		dsetTmp = dBTMP->dSetSQL_Select(strSQL,S"TMP",0);

		dBTMP->blnCnnClose();

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


DataTable * FAP::Deliver::strGetProcessno1(DBBase * dBTMP,String *strfeng)
{
		
		DataTable *dtblTmp;
		DataSet * dsetTmp;
		String *strSQL = S" select distinct PROCESS_NO from part_composition a left outer join process_pro b on a.product_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 NULL;
		}
		dsetTmp = dBTMP->dSetSQL_Select(strSQL,S"TMP",0);

		dBTMP->blnCnnClose();

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

⌨️ 快捷键说明

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