Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
if (theApp.m_pGeneric->OpenRecordSet(&recordSet,GetSQLStatement(GET_NEXT_BATCHES_PRM_ID,ACTIVE,csNoOfMonths)))
        {
            while (recordSet.IsEOF() != TRUE)
            {
                recordSet.GetFieldValue((short)lColNum, nSecId);
                recordSet.GetFieldValue((short)lColNum+1, csPrmId);

                sbatchNode.strPrmBatchID=csPrmId;

            /*if (theApp.m_pGeneric->OpenRecordSet(&recordSet,GetSQLStatement(DELETE_THE_GET_BATCHES_PRM_ID,ACTIVE,csNoOfMonths)))
            {};*/
                OnDeleteWithSnap();
                recordSet.MoveNext();
            }
        }
Posted
Comments
Sergey Alexandrovich Kryukov 12-Jan-15 1:24am    
Not clear. What record set, where, how it makes a batch and what do you want to delete? What's the problem? What did you try to achieve, how, what did you expect to get and what happened instead, why do you feel it's wrong? And so on...
—SA
Vamsi Krishna 13-Jan-15 1:23am    
CRecordset recordSet(&theApp.data);

by using this recordset iam getting the records from table by sql statements here i am representing a ghantt chart in that we have batches when i select a batch and click on repeat then remaining batches after that selected batch should be deleted now i'm achieving it but it is taking a long time for execution so, i wanna modify the code shortly than this Here what i am thinking is that while deleting the batches it should be done with sql statement then in one step i can delete all batches that to be deleted it is my requirement


is there any idea's .........
Vamsi Krishna 12-Jan-15 1:34am    
actually it is regarding to Ghantt chart in this Ghantt chart we will have batches to represent the data while iam repeating a particular batch the batches after the selected batches should be deleted and the selected the batch should be replaced until the end of the date it is working fine with the above code but what i need is to reduce the code because the loop is taking long time for execution in OnDeleteWithSnap(); method what i have to do??????????
Richard MacCutchan 12-Jan-15 4:19am    
Then you need to show the coding for the OnDeleteWithSnap function.
Vamsi Krishna 12-Jan-15 4:46am    
Here is my code in delete with snap....

void CGanttChartView::OnDeleteWithSnap()
{
/*
** Update delete_flag in PAS_PRM_BATCH_TRAN.
*/
if (!theApp.m_pGeneric->ExecuteSQL(GetSQLStatement(UPDATE_DELETE_FLAG,ACTIVE,sbatchNode.strPrmBatchID)))
{
theApp.m_pGeneric->ICOMMessage("Gantt Chart - 1015",MB_OK,"Cannot update delete flag","\n");
theApp.data.Rollback();
return;
}
/* }
if (!theApp.m_pGeneric->ExecuteSQL(GetSQLStatement(UPDATE_SEC_BATCH_DATES,ACTIVE,sbatchNode.strPrmBatchID)))
{
theApp.m_pGeneric->ICOMMessage("Gantt Chart - 1015",MB_OK,"Cannot update delete flag","\n");
theApp.data.Rollback();
return;
}*/

theApp.m_strDeletedBatchArr.Add(sbatchNode.strPrmBatchID);



//Get the selected batch's Start and end dates
CString sSecBatchID;
long lColNum=0;
CRecordset recordSet(&theApp.data);
if (theApp.m_pGeneric->OpenRecordSet(&recordSet,GetSQLStatement(SEC_BATCH_ID,ACTIVE,sbatchNode.strPrmBatchID)))
{
while (recordSet.IsEOF() != TRUE)
{
recordSet.GetFieldValue((short)lColNum, sSecBatchID);

if(sSecBatchID==nSecId)
{
recordSet.GetFieldValue((short)lColNum+2, m_sSimStartDate);
recordSet.GetFieldValue((short)lColNum+3, m_sSimStopDate);

}

recordSet.MoveNext();
}
}
recordSet.Close();

CRecordset CondInstructIDRecordSet(&theApp.data);

if (theApp.m_pGeneric->OpenRecordSet(&CondInstructIDRecordSet,GetSQLStatement(CONDITIONAL_INSTRUCTIONS_ID,ACTIVE,sbatchNode.strPrmBatchID)))
{
if(CondInstructIDRecordSet.IsEOF() != TRUE)
{
// Add the conditions of the deleted batch to it's previous batch
// Get the primary batch Id of the previous batch
// Clear if any conditions associated with the previous batch
// Insert the conditions to the previous batch
CRecordset ganttRecordSet(&theApp.data);
CString csMinSimStartDate;
CString csPrevBatchId;
if (theApp.m_pGeneric->OpenRecordSet(&ganttRecordSet, GetSQLStatement(GET_PREV_SIMULATOR_START_TIME,CRecordset::readOnly) ))

ganttRecordSet.GetFieldValue((short)0, csMinSimStartDate);
ganttRecordSet.Close();

if (theApp.m_pGeneric->OpenRecordSet(&ganttRecordSet, GetSQLStatement(GET_PREV_NEXT_BATCH_ID,CRecordset::readOnly,csMinSimStartDate) ))

ganttRecordSet.GetFieldValue((short)0, csPrevBatchId);
ganttRecordSet.Close();

//Delete the conditions for the previous batch
if (!DeleteConditionalInstr(csPrevBatchId))
{
MessageBox("Unable to Delete the conditions for the previous batch");
return;
}
m_sID=csPrevBatchId;
if (!CopyConditionalInstructions(sbatchNode.strPrmBatchID))
return;
}
}
// Update the Simulator_start_date and Simulator_stop_dates for the subsequent batches
m_dtSimStartDate=theApp.m_pGeneric->ConvertDateTime(DATE_TIME_USER_UPDATE,sbatchNode.sStartDate);
m_dtSimStopDate=theApp.m_pGeneric->ConvertDateTime(DATE_TIME_USER_UPDATE,sbatchNode.sEndDate);
CString csDiff=GetMovementwidth(m_dtSimStartDate);
csDiff=_T("-")+csDiff;
// Decrease 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_SEC_BATCH_DATES,ACTIVE,sbatchNode.strPrmBatchID)))
{
theApp.m_pGeneric->ICOMMessage("Gantt Chart - 1015",MB_OK,"Cannot update delete flag","\n");
theApp.data.Rollback();
return;
}
}

1 solution

i wrote a code in sql Statements like this as shown here but iam getting a error that is id not found

how to rectify this

/*if (theApp.m_pGeneric->OpenRecordSet(&recordSet,GetSQLStatement(DELETE_THE_GET_BATCHES_PRM_ID,ACTIVE,csNoOfMonths)))
{};*/
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 12-Jan-15 1:26am    
Sorry, this is not an answer, does not belong here. Please use "Improve question" instead.
—SA

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