Click here to Skip to main content
15,886,732 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Here, is the code i will tell what is happening here this about gantt chart on that chart there is batches when i'm selecting a batch and moving it. the dates will change it is happening here thats fine and it is happening in empty area. what my problem is that when i'm moving the batch into set of batches the set of batches have to give place to the newly moving batch i.e., set of batches date has to change accordingly but it is not happening here. pls tell me what to do i have stuck here.........!!
C++
void CGanttChartView::OnControlclickActiveganttvcctl1(LPDISPATCH e)
{
	// TODO: Add your message handler code here
	int Index;
	CclsTask oTask;
	CString strBatchCode, m_strRecDelID;;
	CMouseEventArgs oE(e);
	CPoint right;
	right.x = oE.GetX();
	right.y = oE.GetY();
	CRecordset ganttChartRecordSet;

	
	if (oE.GetEventTarget() == EVT_TASK||oE.GetEventTarget() == EVT_SELECTEDTASK) {
      Index = ActiveGanttVCCtl1.GetMathLib().GetTaskIndexByPosition(oE.GetX(), oE.GetY());
		if (Index < 1)
		{
			return;
        }
		oTask= ActiveGanttVCCtl1.GetTasks().Item(CStr(Index));
		//
		//oTask1=oTask;

		//oTask1=ActiveGanttVCCtl1.GetTasks().Item(CStr(Index));
		strBatchCode=oTask.GetText();
		//HighlightSelectedBatch(ganttChartRecordSet,strBatchCode);
		//StoreGanttNode();

		// Store the batch information into a structure
		
		sRowKey = oTask.GetRowKey();

		m_dtStartDate.CreateDispatch(_T("AGVC.DateTime"));
		m_dtEndDate.CreateDispatch(_T("AGVC.DateTime"));

		sbatchNode.dtStartDate = oTask.GetStartDate();
		sbatchNode.dtEndDate = oTask.GetEndDate();
		m_dtStartDate=oTask.GetStartDate();
		m_dtEndDate=oTask.GetEndDate();

		m_sStDate=m_dtStartDate.ToString(_T("MM/dd/yy HH:mm"));
		m_sEndDate=m_dtEndDate.ToString(_T("MM/dd/yy HH:mm"));
		sbatchNode.sStartDate = sbatchNode.dtStartDate.ToString(_T("MM/dd/yyyy HH:mm:ss"));
		sbatchNode.sEndDate =sbatchNode.dtEndDate.ToString(_T("MM/dd/yyyy HH:mm:ss"));
		
			CString sTaskKey = oTask.GetKey();

			CString csRowNo;
			csRowNo.Format(_T("%c"),sRowKey.GetAt(1));
			CRecordset		ganttRecordSet(&theApp.data);
			if (theApp.m_pGeneric->OpenRecordSet(&ganttRecordSet, GetSQLStatement(GANTT_CHART_DELIVERY_TYPE,CRecordset::readOnly,csRowNo) ))
	
			ganttRecordSet.GetFieldValue((short)0, csRecDelType);
			ganttRecordSet.GetFieldValue((short)1, m_sLocationId);
			ganttRecordSet.GetFieldValue((short)2,m_sRecDelId);

			ganttRecordSet.Close();
	
		m_strRecDelID.LoadStringA(IDS_CALCTYPE);
		

		m_mapBatchFlow.Lookup(sTaskKey, SBatchFlowRec);
		//CString csDuration=SBatchFlowRec->strDuration;
		sbatchNode.strBatchCode= SBatchFlowRec->strBatch_Desc;
		sbatchNode.strRate=m_sSimRate=SBatchFlowRec->strRate;
		sbatchNode.strVolume=m_sVolume=SBatchFlowRec->strVolume_In_Barrels;
		sbatchNode.strDuration=m_sDuration=SBatchFlowRec->strDuration;
		sbatchNode.strProduct=SBatchFlowRec->strProduct;

		sbatchNode.dtStartDate.ReleaseDispatch();
		sbatchNode.dtEndDate.ReleaseDispatch();
		m_dtStartDate.ReleaseDispatch();
		m_dtEndDate.ReleaseDispatch();
		m_startDateTime=sbatchNode.sStartDate;
		m_completeDateTime=sbatchNode.sEndDate;
		//CRecordset	ganttRecordSet(&theApp.data);
		//ganttRecordSet.Open(CRecordset::forwardOnly,GetSQLStatement(HIGHLIGHT_SELECTED_BATCH,ACTIVE,strBatch,EQUAL), CRecordset::readOnly);
		//if(!ganttRecordSet.IsOpen())
		ganttRecordSet.Open(CRecordset::forwardOnly,GetSQLStatement(GET_PRM_ID,ACTIVE,sbatchNode.strBatchCode),CRecordset::readOnly);
		ganttRecordSet.GetFieldValue((short)0, nPrmId);
		m_sID=nPrmId;
		sbatchNode.strPrmBatchID=nPrmId;
		
		ganttRecordSet.GetFieldValue((short)1, nSecId);
		sbatchNode.strSecBatchID=nSecId;
		ganttRecordSet.Close();
		
	}
	if((oE.GetButton() == BTN_RIGHT) && !(csRecDelType == m_strRecDelID) && (oE.GetEventTarget() == EVT_TASK||oE.GetEventTarget() == EVT_SELECTEDTASK))
	{
			CMenu mnuPopupSubmit;
			mnuPopupSubmit.LoadMenu(IDR_MENU1);
	
			CMenu *mnuPopupMenu = mnuPopupSubmit.GetSubMenu(0);
			ASSERT(mnuPopupMenu);
	
			ClientToScreen(&right);
			//ScreenToClient(&right);
			mnuPopupMenu->TrackPopupMenu( TPM_LEFTALIGN, right.x, right.y, this);
			//MessageBox("right");
	}
	
}
Posted
Updated 30-Jan-15 21:37pm
v3
Comments
Richard MacCutchan 31-Jan-15 4:02am    
What you have to do is use your debugger to identify what is happening and where, and then update your question with some useful detail.
Vamsi Krishna 31-Jan-15 4:34am    
what details do you want??

1 solution

You need to be more specific on what you ask if you like to get answers.
From first look I see that the function has too many lines of code in it.
I would suggest breaking this function to several smaller functions with logical meaning.
Also, what do you mean by saying "i'm moving the batch"?
What is a batch in your application?
 
Share this answer
 

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