Разработка программного изделия «Материальное требование» (раздел курсовой работы "Тексты программ"), страница 3

                              strTime.Format("%i/%i/%i",time.GetMonth(),time.GetDay(),time.GetYear());

                              strSQL += " AND Дата >= #" + strTime + "#";

                    }

                    if (dialog.m_bTo==FALSE)

                    {

                              CTime time = dialog.m_timeTo;

                              CString strTime;

                              strTime.Format("%i/%i/%i",time.GetMonth(),time.GetDay(),time.GetYear());

                              strSQL += " AND Дата <= #" + strTime + "#";

                    }

                    pTrebSet->Open(CRecordset::snapshot,strSQL);

                    CMaterialSet *pMaterialSet = new CMaterialSet(&db);

                    strSQL = "SELECT * FROM [Справочник материалов] WHERE [Наименование материала] = '" +

                              dialog.m_strMaterialName + "'";

                    pMaterialSet->Open(CRecordset::snapshot,strSQL);

                    CTrebMaterialSet *pTrebMaterialSet;

                    if (i==1)

                              pTrebMaterialSet = new CTrebMaterialSet(&db);

                    else

                              pTrebMaterialSet = new CTrebMaterialSet(&db_arhiv);

                    strSQL = "SELECT * FROM [Состав материального требования] WHERE [Код материала] = '" +

                              pMaterialSet->m_strMaterialCode + "'";

                    int NotEmpty = 0;

                    pTrebMaterialSet->Open(CRecordset::snapshot,strSQL);

                    if (!pTrebMaterialSet->IsEOF())

                              NotEmpty = 1;

Следующая стадия работы функции подразумевает анализ полученных наборов и вывод результатов. Расшифровка логики работы этого фрагмента дана в блок–схеме (Рис 1).

while (!pTrebSet->IsEOF())

                    {

                              while (!pTrebMaterialSet->IsEOF())

                              {

                                       if (pTrebMaterialSet->m_strDocumentName == pTrebSet->m_strNumber)

                                       {

                                                 if (match==0)

                                                 {

                                                           kill_tip=1;

                                                           m_wndToolBar.EnableButton(ID_NOFILTER,true);

                                                           strDialogMode = "Запрос 1";

                                                           SetWindowText("Запрос 1");

                                                           Header1.SetWindowText("");

                                                           Header2.SetWindowText("");

                                                           Header3.SetWindowText("");

                                                           Header4.SetWindowText("");

                                                           m_Grid.DeleteAllItems();

                                                           m_Grid.SetColumnCount(7);

                                                           m_Grid.SetRowCount(19);

                                                           m_Grid.SetFixedRowCount(1);

                                                           m_Grid.SetItemText(0,0,"№ Док.");

                                                           m_Grid.SetItemText(0,1,"Код склада");

                                                           m_Grid.SetItemText(0,2,"Кладовая");

                                                           m_Grid.SetItemText(0,3,"Цех получатель");

                                                           m_Grid.SetItemText(0,4,"Дата");

                                                           m_Grid.SetItemText(0,5,"Колич. отпущено");

                                                           m_Grid.SetItemText(0,6,"Сдал");

                                                           for (int i=0;i<7;i++)

                                                                     m_Grid.SetColumnWidth(i,93);

                                                           PrepareForm();

                                                           match=1;

                                                 }

                                                 CString strHeader1 = "Интервал времени: ";

                                                 if (dialog.m_bFrom==TRUE)

                                                 {

                                                           CTime TimeTo = dialog.m_timeTo;

                                                           CString strTimeTo = TimeTo.Format("%d.%m.%y");

                                                           strHeader1+="До " + strTimeTo;

                                                 }

                                                 else if (dialog.m_bTo==TRUE)

                                                 {

                                                           CTime TimeFrom = dialog.m_timeFrom;

                                                           CString strTimeFrom = TimeFrom.Format("%d.%m.%y");

                                                           strHeader1+="От " + strTimeFrom;

                                                 }