Page 1 of 1

Program updating of the inactive DCBROWSECOL windows

Posted: Wed Oct 10, 2012 9:07 pm
by Eugene Lutsenko
I welcome participants of a forum!

Prompt, please, as at display of three databases connected by the relation "one to many", by means of DCBROWSECOL after addition of records in all three databases from the program to update inactive windows.

Image

Program of display of three databases:

Code: Select all

/* ----- Create ToolBar ----- */

@ 27.5, 0 DCTOOLBAR oToolBar SIZE 131, 1.5

DCADDBUTTON CAPTION 'Помощь'                           ;
   SIZE LEN("Помощь")+2                                ;
   ACTION {||Help2_3_1(), DC_GetRefresh(GetList)}      ;
   PARENT oToolBar                                     ;
   TOOLTIP 'Помощь по режиму 2.3.1'

DCADDBUTTON CAPTION 'Скопировать обуч.выб.в расп.'          ;
   SIZE LEN("Скопировать обуч.выб.в расп.")-5               ;
   ACTION {||CopyOiRo(.T.,1,1,1,""), DC_GetRefresh(GetList)};
   PARENT oToolBar                                          ;
   TOOLTIP 'Скопировать обуч.выб.в расп.'

DCADDBUTTON CAPTION 'Добавить объект'                  ;
   SIZE LEN("Добавить объект")-1                       ;
   ACTION {||Add_Obj2_3_1(), DC_GetRefresh(GetList)}   ;
   PARENT oToolBar                                     ;
   TOOLTIP 'Добавить объект'

DCADDBUTTON CAPTION 'Добавить классы'                  ;
   SIZE LEN("Добавить классы")-0                       ;
   ACTION {||Add_Kcl2_3_1(), DC_GetRefresh(GetList)}   ;
   PARENT oToolBar                                     ;
   TOOLTIP 'Добавить строку классов'

DCADDBUTTON CAPTION 'Добавить признаки'                ;
   SIZE LEN("Добавить признаки")-1                     ;
   ACTION {||Add_Kpr2_3_1(), DC_GetRefresh(GetList)}   ;
   PARENT oToolBar                                     ;
   TOOLTIP 'Добавить строку признаков'

DCADDBUTTON CAPTION 'Удалить объект'                   ;
   SIZE LEN("Удалить объект")-0                        ;
   ACTION {||Del_Obj2_3_1(), DC_GetRefresh(GetList)}   ;
   PARENT oToolBar                                     ;
   TOOLTIP 'Удалить объект'

DCADDBUTTON CAPTION 'Удалить классы'                   ;
   SIZE LEN("Удалить классы")-0                        ;
   ACTION {||Del_Kcl2_3_1(), DC_GetRefresh(GetList)}   ;
   PARENT oToolBar                                     ;
   TOOLTIP 'Удалить строку классов'

DCADDBUTTON CAPTION 'Удалить признаки'                 ;
   SIZE LEN("Удалить признаки")-1                      ;
   ACTION {||Del_Kpr2_3_1(), DC_GetRefresh(GetList)}   ;
   PARENT oToolBar                                     ;
   TOOLTIP 'Удалить строку признаков'

DCADDBUTTON CAPTION 'Очистить БД'                      ;
   SIZE LEN("Очистить БД")-0                           ;
   ACTION {||Zap_db2_3_1(), DC_GetRefresh(GetList)}    ;
   PARENT oToolBar                                     ;
   TOOLTIP 'Очистить БД'


/* ----- Create browse-1: Главная БД Obi_Zag.dbf ----- */

bZag := {|| Obi_Kpr->(DC_SetScope(0,Obi_Zag->Kod_Obj)), ;
            Obi_Kpr->(DC_SetScope(1,Obi_Zag->Kod_Obj)), ;
            Obi_Kpr->(DC_DbGoTop())                   , ;
            oBrowKpr:refreshAll()                     , ;
            Obi_Kcl->(DC_SetScope(0,Obi_Zag->Kod_Obj)), ;
            Obi_Kcl->(DC_SetScope(1,Obi_Zag->Kod_Obj)), ;
            Obi_Kcl->(DC_DbGoTop())                   , ;
            oBrowKcl:refreshAll() }

@ 1, 0 DCBROWSE oBrowZag ALIAS 'Obi_Zag' SIZE 133,12.5 ;
       EDIT xbeBRW_ItemSelected MODE DCGUI_BROWSE_EDITDOWN ;            // Редактирование БД Obi_Zag.dbf
       NOSOFTTRACK ;
       SCOPE ;
       ITEMMARKED {|| Eval(bZag), ;
                      DC_GetRefresh(GetList,, ;
                      DCGETREFRESH_TYPE_EXCLUDE,{GETLIST_BROWSE}) }

DCSETPARENT oBrowZag
DCBROWSECOL FIELD Obi_Zag->Kod_Obj  HEADER 'Код объекта'          WIDTH 1    PROTECT {|| .T. }
DCBROWSECOL FIELD Obi_Zag->Name_obj HEADER 'Наименование объекта' WIDTH 54.5
DCBROWSECOL FIELD Obi_Zag->Date     HEADER 'Дата'                 WIDTH 10   PROTECT {|| .T. }
DCBROWSECOL FIELD Obi_Zag->Time     HEADER 'Время'                WIDTH 8    PROTECT {|| .T. }


/* Create browse-2: БД Obi_Kcl.dbf, связанная отношением "Один ко многим" с БД Obi_Zag.dbf*/

DCSETPARENT TO

@14, 0 DCBROWSE oBrowKcl ALIAS 'Obi_Kcl' SIZE 51,13 ;
       EDIT xbeBRW_ItemSelected MODE DCGUI_BROWSE_EDITDOWN ;
       NOSOFTTRACK ;
       SCOPE ;
       ITEMMARKED bItems

DCSETPARENT oBrowKcl
DCBROWSECOL FIELD Obi_Kcl->Kod_Obj  HEADER 'Код объекта' WIDTH 1 PROTECT {|| .T. }
DCBROWSECOL FIELD Obi_Kcl->Cls1     HEADER 'Класс 1'     WIDTH 5
DCBROWSECOL FIELD Obi_Kcl->Cls2     HEADER 'Класс 2'     WIDTH 5
DCBROWSECOL FIELD Obi_Kcl->Cls3     HEADER 'Класс 3'     WIDTH 5
DCBROWSECOL FIELD Obi_Kcl->Cls4     HEADER 'Класс 4'     WIDTH 5


/* Create browse-3: БД Obi_Kpr.dbf, связанная отношением "Один ко многим" с БД Obi_Zag.dbf*/

DCSETPARENT TO

@14,54 DCBROWSE oBrowKpr ALIAS 'Obi_Kpr' SIZE 79,13 ;
       EDIT xbeBRW_ItemSelected MODE DCGUI_BROWSE_EDITDOWN ;
       NOSOFTTRACK ;
       SCOPE ;
       ITEMMARKED bItems

DCSETPARENT oBrowKpr
DCBROWSECOL FIELD Obi_Kpr->Kod_Obj  HEADER 'Код объекта' WIDTH 1 PROTECT {|| .T. }
DCBROWSECOL FIELD Obi_Kpr->Atr1     HEADER 'Признак 1'   WIDTH 5
DCBROWSECOL FIELD Obi_Kpr->Atr2     HEADER 'Признак 2'   WIDTH 5
DCBROWSECOL FIELD Obi_Kpr->Atr3     HEADER 'Признак 3'   WIDTH 5
DCBROWSECOL FIELD Obi_Kpr->Atr4     HEADER 'Признак 4'   WIDTH 5
DCBROWSECOL FIELD Obi_Kpr->Atr5     HEADER 'Признак 5'   WIDTH 5
DCBROWSECOL FIELD Obi_Kpr->Atr6     HEADER 'Признак 6'   WIDTH 5
DCBROWSECOL FIELD Obi_Kpr->Atr7     HEADER 'Признак 7'   WIDTH 5


DCGETOPTIONS SAYFONT '10.Helv Bold' TABSTOP AUTORESIZE

cTitle = '2.3.1. Ручной ввод-корректировка обучающей выборки'+'. Текущая модель: "'+UPPER(Ar_Model[M_CurrInf])+'"'

DCREAD GUI ;
   FIT ;
   OPTIONS GetOptions ;
   MODAL ;
   TITLE cTitle ;
   EVAL {|o|SetAppFocus(oBrowZag:GetColumn(1))}

   CLOSE ALL

   DIRCHANGE(Disk_dir)   // Перейти в папку с исполнимым модулем системы

* aSaveF231 := DC_DataSave()  // Сохранение вычислительной среды (открытые и текущие БД и индексы)
  DC_DataRest( aSaveF231 )    // Восстановление вычислительной среды (открытые и текущие БД и индексы)

RETURN NIL
The program of addition of record in the main database:

Code: Select all

******** Добавить объект в конец БД Obi_Zag.dbf
FUNCTION Add_Obj2_3_1()

  SELECT Obi_Zag
  DBGOBOTTOM()
  M_KodObj = Kod_Obj
  APPEND BLANK
  REPLACE Kod_Obj WITH M_KodObj+1
  REPLACE Date    WITH DTOC(DATE())
  REPLACE Time    WITH Time()

  Add_Kcl2_3_1()
  Add_Kpr2_3_1()

  SELECT Obi_Zag
  DBGOBOTTOM()
  DC_GetRefresh(GetList)

RETURN NIL
Programs of addition of record in the connected databases:

Code: Select all

******** Добавить строку классов в конец БД Obi_Kcl.dbf
FUNCTION Add_Kcl2_3_1()
  SELECT Obi_Zag
  M_KodObj = Kod_Obj
  SELECT Obi_Kcl
  APPEND BLANK
  REPLACE Kod_Obj WITH M_KodObj
  DBGOTOP()
  DC_GetRefresh(GetList)
RETURN NIL

******** Добавить строку признаков в конец БД Obi_Kpr.dbf
FUNCTION Add_Kpr2_3_1()
  SELECT Obi_Zag
  M_KodObj = Kod_Obj
  SELECT Obi_Kpr
  APPEND BLANK
  REPLACE Kod_Obj WITH M_KodObj
  DBGOTOP()
  DC_GetRefresh(GetList)
RETURN NIL
Now the program works so. Records adds, but the added record only in the main database at once is visible, and in connected (below) added records become visible only after cursor moving in the main base of data.

Re: Program updating of the inactive DCBROWSECOL windows

Posted: Wed Oct 10, 2012 10:45 pm
by Koverhage
You should call your functions with

Add_Obj2_3_1(GetList)

FUNCTION Add_Obj2_3_1(aGetList)

DC_GetRefresh(aGetList)

Also if you use this way, you don't need the dc_gertrefresh in the action block.

Re: Program updating of the inactive DCBROWSECOL windows

Posted: Thu Oct 11, 2012 4:07 am
by Tom
DC_GetRefresh(GetList) does not refresh the datalinks of all available browses in all cases. Try oBrowse:RefreshAll() instead. If other elements are connected to browses (when, hide - depending on the browse's contens), set DC_GetWhenOnBrowseItemMarked(.T.) somewhere in your app.

Re: Program updating of the inactive DCBROWSECOL windows

Posted: Thu Oct 11, 2012 7:25 am
by rdonnay
This should help.

First add an ID to your oBrowZag object:

Code: Select all

@ 1, 0 DCBROWSE oBrowZag ALIAS 'Obi_Zag' SIZE 133,12.5 ;
       EDIT xbeBRW_ItemSelected MODE DCGUI_BROWSE_EDITDOWN ;            
       ID 'BROWSE_ZAG'
Then send an ItemMarked event to the browse in your APPEND function:

Code: Select all

PostAppEvent(xbeBRW_ItemMarked,,,DC_GetObject(GetList,'BROWSE_ZAG'))

Re: Program updating of the inactive DCBROWSECOL windows

Posted: Thu Oct 11, 2012 11:24 am
by Eugene Lutsenko
I thank for responsiveness. Tried all three offered options, but with one it did not turn out.

When you click with a mouse on new record of the main base, windows of the connected databases are updated also and in them it is visible the added records but only the first time so turns out. And then in the main base it is necessary to click two times: on any record and on necessary that there was an updating.

I had a thought, and from the program of addition of record it can be possible to submit codes which turn out from a mouse at these cliques?