Click here to Skip to main content
15,891,910 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
2)and i want that the string to be in a loop because no.of queries have to be executed and to store the data in that string?
3) while executing the each loop data should be updated in another string ?
4) finally the data stored in a string should be thrown out???

Here, iam just showing part of the my question... there are queries in code i want the data to be stored in a string???????

C++
void CGanttChartView::InsertBatch(CString csMinSimStartDate ,CString sSecBatchID)
{
// If the Selected batch is the last batch or we are in a position to accommodate the batch on Gantt Chart just Add the batch

		COleDateTime minStartDateTime;	
		minStartDateTime = theApp.m_pGeneric->ConvertDateTime(DATE_TIME_USER_UPDATE,csMinSimStartDate);
		if(AddAfter==TRUE)
		{
			if(csMinSimStartDate ==_T("") || (m_dtSimStopDate<= minStartDateTime))
			{
			//copy's the selected secondary batches and inserts into the db.
				if (!theApp.m_pGeneric->ExecuteSQL(GetSQLStatement(INSERT_SEC_BATCH_SELECT_FROM,ACTIVE,sSecBatchID)))
				{
					theApp.m_pGeneric->ICOMMessage("Batch Book - 1015",MB_OK,"Secondary Batch record","\n");
					theApp.data.Rollback();
				//return bRtnValue = FALSE;
				}
			}

			// We cannot accommodate the batch on the gantt chart So we have to update the subsequent batch simulator start and stop date
			else if(minStartDateTime!=m_dtSimStartDate)
			{
				CString csDiff=GetMovementwidth(minStartDateTime);
				// Increment the Simulator_start_date and simulator_stop_date by diff -SQL query
				if(!theApp.m_pGeneric->ExecuteSQL(GetSQLStatement(UPDATE_SEC_BATCH_SIM_DATE,ACTIVE,csDiff)))
				{
					theApp.m_pGeneric->ICOMMessage("Batch Book - 1015",MB_OK,"Secondary Batch record","\n");
					theApp.data.Rollback();
				//return bRtnValue = FALSE;
				}
				if (!theApp.m_pGeneric->ExecuteSQL(GetSQLStatement(INSERT_SEC_BATCH_SELECT_FROM,ACTIVE,sSecBatchID)))
				{
				theApp.m_pGeneric->ICOMMessage("Batch Book - 1015",MB_OK,"Secondary Batch record","\n");
				theApp.data.Rollback();
				//return bRtnValue = FALSE;
				}
			}
			else if(minStartDateTime==m_dtSimStartDate)
			{
				

				CString csDiff=GetMovementwidth(minStartDateTime);
				// Increment the Simulator_start_date and simulator_stop_date by diff -SQL query
				if(!theApp.m_pGeneric->ExecuteSQL(GetSQLStatement(UPDATE_SEC_BATCH_SIM_DATE,ACTIVE,csDiff)))
				{
					theApp.m_pGeneric->ICOMMessage("Batch Book - 1015",MB_OK,"Secondary Batch record","\n");
					theApp.data.Rollback();
				//return bRtnValue = FALSE;
				}

				csDiff=GetMovementwidth(m_dtSimStartDate);
				if (!theApp.m_pGeneric->ExecuteSQL(GetSQLStatement(UPDATE_CURRENT_SEC_BATCH,ACTIVE,csDiff)))
				{
					theApp.m_pGeneric->ICOMMessage("Batch Book - 1015",MB_OK,"Secondary Batch record","\n");
					theApp.data.Rollback();
					//return bRtnValue = FALSE;
				}

				if (!theApp.m_pGeneric->ExecuteSQL(GetSQLStatement(INSERT_SEC_BATCH_SELECT_FROM,ACTIVE,sSecBatchID)))
				{
				theApp.m_pGeneric->ICOMMessage("Batch Book - 1015",MB_OK,"Secondary Batch record","\n");
				theApp.data.Rollback();
				//return bRtnValue = FALSE;
				}

			}
		}
		else if(AddBefore==TRUE)
		{

			long lVolume = atol(m_sVolume);
			double dRate = atol(m_sSimRate);
			COleDateTime StartDateTime = theApp.m_pGeneric->ConvertDateTime(DATE_TIME_USER_UPDATE,sbatchNode.sEndDate);
			
			COleDateTime StopDateTime;
	
			StopDateTime.m_dt = StartDateTime.m_dt + (lVolume/dRate)/24;
		
			

			if(m_dtSimStopDate==minStartDateTime)
			{

				CString csDiff=GetMovementwidth(m_dtSimStartDate);
				// Increment the Simulator_start_date and simulator_stop_date by diff -SQL query
				if(!theApp.m_pGeneric->ExecuteSQL(GetSQLStatement(UPDATE_SEC_BATCH_SIM_DATE,ACTIVE,csDiff)))
				{
					theApp.m_pGeneric->ICOMMessage("Batch Book - 1015",MB_OK,"Secondary Batch record","\n");
					theApp.data.Rollback();
				//return bRtnValue = FALSE;
				}
				if (!theApp.m_pGeneric->ExecuteSQL(GetSQLStatement(UPDATE_CURRENT_SEC_BATCH,ACTIVE,csDiff)))
				{
					theApp.m_pGeneric->ICOMMessage("Batch Book - 1015",MB_OK,"Secondary Batch record","\n");
					theApp.data.Rollback();
				//return bRtnValue = FALSE;
				}
				if (!theApp.m_pGeneric->ExecuteSQL(GetSQLStatement(INSERT_SEC_BATCH_SELECT_FROM,ACTIVE,sSecBatchID)))
				{
				theApp.m_pGeneric->ICOMMessage("Batch Book - 1015",MB_OK,"Secondary Batch record","\n");
				theApp.data.Rollback();
				//return bRtnValue = FALSE;
				}

			}
			else if(minStartDateTime>m_dtSimStopDate && minStartDateTime<stopdatetime)>
			{
				CString csDiff1,csDiff2;
				csDiff1=GetMovementwidth(StopDateTime);
				csDiff2=GetMovementwidth(minStartDateTime);
				
				CString csDiff;
				csDiff.Format("%ld",atol(csDiff1)-atol(csDiff2));
				// Increment the Simulator_start_date and simulator_stop_date by diff -SQL query
				if(!theApp.m_pGeneric->ExecuteSQL(GetSQLStatement(UPDATE_SEC_BATCH_SIM_DATE,ACTIVE,csDiff)))
				{
					theApp.m_pGeneric->ICOMMessage("Batch Book - 1015",MB_OK,"Secondary Batch record","\n");
					theApp.data.Rollback();
				//return bRtnValue = FALSE;
				}
				csDiff=GetMovementwidth(m_dtSimStartDate);
				if (!theApp.m_pGeneric->ExecuteSQL(GetSQLStatement(UPDATE_CURRENT_SEC_BATCH,ACTIVE,csDiff)))
				{
					theApp.m_pGeneric->ICOMMessage("Batch Book - 1015",MB_OK,"Secondary Batch record","\n");
					theApp.data.Rollback();
				//return bRtnValue = FALSE;
				}
				if (!theApp.m_pGeneric->ExecuteSQL(GetSQLStatement(INSERT_SEC_BATCH_SELECT_FROM,ACTIVE,sSecBatchID)))
				{
				theApp.m_pGeneric->ICOMMessage("Batch Book - 1015",MB_OK,"Secondary Batch record","\n");
				theApp.data.Rollback();
				//return bRtnValue = FALSE;
				}
					
			}
			else
			{
				CString csDiff=GetMovementwidth(m_dtSimStartDate);
				if (!theApp.m_pGeneric->ExecuteSQL(GetSQLStatement(UPDATE_CURRENT_SEC_BATCH,ACTIVE,csDiff)))
				{
					theApp.m_pGeneric->ICOMMessage("Batch Book - 1015",MB_OK,"Secondary Batch record","\n");
					theApp.data.Rollback();
				//return bRtnValue = FALSE;
				}
				if (!theApp.m_pGeneric->ExecuteSQL(GetSQLStatement(INSERT_SEC_BATCH_SELECT_FROM,ACTIVE,sSecBatchID)))
				{
				theApp.m_pGeneric->ICOMMessage("Batch Book - 1015",MB_OK,"Secondary Batch record","\n");
				theApp.data.Rollback();
				//return bRtnValue = FALSE;
				}
						
			
			}


		}

	CRecordset		recordSet(&theApp.data);
	long			lColNum=0;
	CString			sSecID;
	/*CStringList     SecBatchIDList;
	CString sRecDelId;*/
	if(bRepeat!=FALSE)
	{
	if (theApp.m_pGeneric->OpenRecordSet(&recordSet,GetSQLStatement(SEC_BATCH_ID,ACTIVE,m_sID)))
	{
		while (recordSet.IsEOF() != TRUE)
		{
			recordSet.GetFieldValue((short)lColNum, sSecID);
			/*recordSet.GetFieldValue((short)lColNum+1, sRecDelId);*/
			if(m_sSecBatchID==sSecID)
			{
				recordSet.GetFieldValue((short)lColNum+2, m_sSimStartDate);
				recordSet.GetFieldValue((short)lColNum+3, m_sSimStopDate);
				
			}
			//SecBatchIDList.AddTail(sSecBatchID);
			recordSet.MoveNext();
		}
		recordSet.Close();

	}
	}

		if(AddAfter==TRUE)
			AddAfter=FALSE;
		if(AddBefore==TRUE)
			AddBefore=FALSE;
		if(Paste==TRUE)
			Paste=FALSE;
}
Posted
Updated 19-Jan-15 2:46am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900