i have details of selected batch here in this below function what i need is to move the selected batch the data in the batch should be same but dates will be changed such as start date and enddate????
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(&theApp.data);
bool bAdd=FALSE,bFound=FALSE;
POSITION pos;
SBatchNodeOnGantt* PrvListNode;
if (oE.GetEventTarget() == EVT_TASK||oE.GetEventTarget() == EVT_SELECTEDTASK) {
Index = ActiveGanttVCCtl1.GetMathLib().GetTaskIndexByPosition(oE.GetX(), oE.GetY());
if (Index < 1)
{
return;
}
//OnRefreshGanttChart();
oTask= ActiveGanttVCCtl1.GetTasks().Item(CStr(Index));
//
//oTask1=oTask;
//oTask1=ActiveGanttVCCtl1.GetTasks().Item(CStr(Index));
strBatchCode=oTask.GetText();
//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.strLocation=m_sLocationId;
sStDateString=sbatchNode.dtStartDate.ToString(_T("MM/dd/yyyy HH:mm:ss"));
sEdDateString=sbatchNode.dtEndDate.ToString(_T("MM/dd/yyyy HH:mm:ss"));
CString csId;
CRecordset ganttRecordSet1(&theApp.data);
m_startDateTime=sbatchNode.sStartDate;
m_completeDateTime=sbatchNode.sEndDate;
if (theApp.m_pGeneric->OpenRecordSet(&ganttRecordSet1, GetSQLStatement(GET_ID,CRecordset::readOnly,SBatchFlowRec->strBatch_Desc)))
ganttRecordSet1.GetFieldValue((short)0, nPrmId);
ganttRecordSet1.GetFieldValue((short)1, nSecId);
ganttRecordSet1.Close();
m_sID=nPrmId;
sbatchNode.strPrmBatchID=nPrmId;
sbatchNode.strSecBatchID=nSecId;
if(SelList.GetCount()>0)
{
pos=SelList.GetHeadPosition();
PrvListNode = SelList.GetAt(pos);
while(pos != NULL)
{
PrvListNode = SelList.GetNext(pos);
if(PrvListNode->strPrmBatchID==nPrmId)
{
bFound=TRUE;
}
}
}
if(!bFound)
{
SBatchNodeOnGantt* ListNode = new SBatchNodeOnGantt();
ListNode->dtStartDate=sbatchNode.dtStartDate;
ListNode->dtEndDate=sbatchNode.dtEndDate;
ListNode->sStartDate=sbatchNode.sStartDate;
ListNode->sEndDate=sbatchNode.sEndDate;
ListNode->strBatchCode=sbatchNode.strBatchCode;
ListNode->strLocation=sbatchNode.strLocation;
ListNode->strGanttChartID=sbatchNode.strGanttChartID;
ListNode->strgradeColorCode=sbatchNode.strgradeColorCode;
ListNode->strVolume=sbatchNode.strVolume;
ListNode->strRate=sbatchNode.strRate;
ListNode->strDuration=sbatchNode.strDuration;
ListNode->strProduct=sbatchNode.strProduct;
ListNode->strPrmBatchID=sbatchNode.strPrmBatchID;
ListNode->strSecBatchID=sbatchNode.strSecBatchID;
ListNode->strRecDelID=m_sRecDelId;
if(GetKeyState(VK_CONTROL)<0)
{
if(SelList.GetCount()==0)
SelList.AddTail(ListNode);
else if(SelList.GetCount()>0)
{
pos=SelList.GetHeadPosition();
PrvListNode = SelList.GetAt(pos);
while(pos != NULL)
{
if(PrvListNode->dtStartDate>ListNode->dtStartDate)
{
SelList.InsertBefore(pos,ListNode);
bAdd=TRUE;
break;
}
PrvListNode = SelList.GetNext(pos);
}
if(!bAdd)
SelList.AddTail(ListNode);
}
}
else
{
UnHighlightBatch();
if(PrvStyleKeyDel.GetCount()>0)
PrvStyleKeyDel.RemoveAll();
if(SelList.GetCount()>0)
SelList.RemoveAll();
SelList.AddTail(ListNode);
}
if(csRecDelType == m_strRecDelID)
HighlightSelectedBatch(ganttChartRecordSet,0,nPrmId,oTask);
else
HighlightSelectedBatch(ganttChartRecordSet,1,nPrmId,oTask);
}
if((oE.GetButton() == BTN_RIGHT) && !(csRecDelType == m_strRecDelID))
{
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");
}
//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();
sbatchNode.dtStartDate.ReleaseDispatch();
sbatchNode.dtEndDate.ReleaseDispatch();
m_dtStartDate.ReleaseDispatch();
m_dtEndDate.ReleaseDispatch();
}
else
{
UnHighlightBatch();
if(PrvStyleKeyDel.GetCount()>0)
PrvStyleKeyDel.RemoveAll();
if(SelList.GetCount()>0)
SelList.RemoveAll();
}
}