Click here to Skip to main content
15,900,906 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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();
}
}
Posted
Comments
Richard MacCutchan 9-Feb-15 7:56am    
We cannot go through all that code and try to figure out what is wrong; or even what it is supposed to do. Please edit your question, format the code properly with <pre> tags, and explain exactly what the problem is and where it occurs.
ZurdoDev 9-Feb-15 15:09pm    
What is your question?
Vamsi Krishna 10-Feb-15 9:26am    
i want to move a batch here in this code when i'm selecting a batch from gantt chart the corresponding batch details are coming here... it is fine
when i'm moving the same batch it will call the same code again and details must same but the coressponding date such as startdate and end date are going to be change..it is also fine but i want to write a condition for the batch that those which it should satisfy my condition and then the moving operation should be done here.. so, for this when the code is executing for the first time my condition should not be called and for the second itrration it should be called?????

please give me reply ASAP......
ZurdoDev 10-Feb-15 9:27am    
I still don't see what your question is. What is a batch?
Vamsi Krishna 16-Feb-15 2:55am    
it is representing some details like volume ,rate , start date and stop date, duration etc it is on gantt chart

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