Отношение "Многие-ко-многим" строится через кросс-таблицу.

http://myvisualdatabase.com/forum/misc.php?action=pun_attachment&item=5627&download=0


Рекомендую пройти базовый курс обучения: https://vk.com/@createmyvisualdatabasea … nyi-uroven Данная тема рассматривается на третьем занятии ("Реляционные базы данных")

vovka3003, Кому костыль, а кому - решение ))) 


Раньше не обращал на это внимание, да и клиенты не жаловались, но, признаюсь, решение повышает удобство работы. Возьму к себе в копилочку. Спасибо!


P.S. пожалуй, надо добавить проверку свойства TdbDateTimePicker.Kind,  так как данный компонент используется и для ввода времени.  В этом случае либо не устанавливать обработчик, либо добавить формат для времени.

mikhail_a wrote:

Нужно обратиться из скрипта к закладке на PageControl по ее имени.
Т.е. надо что-то такое:
Form_1.PageControl_1.TabSheet_name.Visible := false;


Form1.TabSheet1.Visible := false;

т.е. в скрипте задаётся путь не по Parent, а по Owner, а все компоненты принадлежат форме

Andrei wrote:

Спасибо работает.

Вот только все таки хотелось бы результаты id выполнения процедуры frmAddSch1_Button1_OnAfterClick при создании новой записи ( '+IntToStr(frmAddSch1.Button1.dbGeneralTableId)
получить в переменную, которую в дальнейшем использовать для расчетов.


procedure frmAddSch1_Button1_OnAfterClick (Sender: TObject); 
var
  tmpNewID:integer; // переменная для хранения добавленного значения
begin 
    if frmAddSch1.Tag = 1 then // условие выполняется при создании новой записи
    begin 
        tmpNewID := frmAddSch1.Button1.dbGeneralTableId;
        SQLExecute ('INSERT INTO res (id_sch) VALUES ( '+IntToStr(tmpNewID));    
        // далее - ваш код
    end;
end;

Возможно, нужное вам решение есть в примерах, описанных в цикле статей о программировании в MVD:  https://vk.com/@createmyvisualdatabasea … mmirovanie

L10n. Internationalization


https://sun9-28.userapi.com/c852224/v852224098/1447a4/Z95cCs4rrSA.jpg


Continuation of the article "L10n. Origin"dedicated to the localization of the application.https://vk.com/@createmyvisualdatabasea … nalization


Dear readers!


I would appreciate your comments. It is very important for me to know your opinion on both the content of the articles and the orientation of the development of the educational project. Please, write in the comments what you think of this article. What more would you like to know about MVD programming? In the next article, I plan to consider an alternative internationalization option for a project in which localized resources are located in a database. Or is there more relevant information on the localization tool for existing projects? Waiting for your answers smile

1,232

(7 replies, posted in Russian)

Не первая тема на эту тему и, видимо, не последняя )))  Выходит, что правильней всего не хранить пароль подключения к базе в самой программе. Но тогда встаёт вопрос создания и управления пользователями на сервере MySQL силами приложения, созданного в MVD, правами доступа и всё такое )))

LL10n. Origin


https://pp.userapi.com/c855036/v855036155/6575a/uCBmaUb2Dlc.jpg


If you want to create universal applications, sooner or later, you will think about its location. Since My Visual Database does not have built-in tools for this purpose, you will need to develop your own system to get the desired result.


The system must be simple and not need to modify the applications for its implementation. One of the key requirements is also the ability to change languages at any time.


Thus, in addition to the language resource preparation tool, we need a script that will load these resources.

Read the full article: https://vk.com/@createmyvisualdatabasea … 10n-origin

У меня есть пример создания меню из данных, хранимых в БД. Пример довольно сложный, описание здесь: https://vk.com/@createmyvisualdatabaseapp-menu  в конце описания - ссылка для скачивания проекта.

Собственно, построение меню идёт в процедуре LoadMenu(). Меню создаётся на форме frmMain.

procedure LoadMenu;
var
  tmpMainMenu: TMainMenu;
  tmpDataSet:TDataSet;
  tmpSQL:string;
  tmpMenuItem: TMenuItem;
  tmpParentStack: array[1..MAX_MENU_LEVEL+1] of TMenuItem; // стек для хранения родительских элементов при создании главного меню
  tmpLevel: integer;
begin
  tmpMainMenu := TMainMenu.Create(frmMain);
  frmMain.Menu := tmpMainMenu;
  // запрос формируется с учётом прав пользователя
  tmpSQL :=
  ' select menu_.* , object_.name as object_name '+
  ' from menu_'+
  ' left join object_ on object_.id = menu_.id_object_';
  // если роль указана, то добавляем фильтр по роли:
  if RoleID <> 0 then
    tmpSQL := tmpSQL +
    ' left join role_object_ on role_object_.id_object_ = object_.id'+
    ' where (menu_.id_object_ is null) or (role_object_.id_role_ = '+inttostr(RoleID)+' )';
    // сортировка обеспечивает правильность сборки дерева
  tmpSQL := tmpSQL + ' order by order_num';
  //
  SQLQuery(tmpSQL,tmpDataSet);
  while not tmpDataSet.EOF do
  begin
    tmpMenuItem := TMenuItem.Create (tmpMainMenu);
    tmpMenuItem.Caption := tmpDataSet.FieldByName('name').asString;
    tmpMenuItem.Tag := tmpDataSet.FieldByName('id').asInteger;
    // если указан объект, то подключаем обработчик
    if not tmpDataSet.FieldByName('id_object_').isNull then
      tmpMenuItem.OnClick := @MainMenuClick;
    tmpLevel := tmpDataSet.FieldByName('level').asInteger;
    //
    if tmpLevel = 0 then
    begin
      tmpMainMenu.Items.Add(tmpMenuItem);
    end
    else
    begin
      tmpParentStack[tmpLevel].Add(tmpMenuItem);
    end;
    // записываем в стек текущий элемент как родителя для следующего уровня
    tmpParentStack[tmpLevel+1] := tmpMenuItem;
    // переходим к следующей записи
    tmpDataSet.Next;
  end;
  tmpDataSet.Free;
end;
m.prokhachev wrote:

Изящно! Всего лишь поменяли дескриптор у объекта-структуры smile Так и продублировать меню на другие формы можно!

Продублировать таким макаром нельзя, так как один экземпляр главного меню (TMainMenu) может быть только у одной формы. Но можно поэлементно скопировать.

1,236

(3 replies, posted in General)

lorenzo620 wrote:

Hello ,

1) I had a look on the entire forum and found the program 13 anatomy. Looks awesome and i would like to copy several thing into my own app but i`m unable to do so because i don`t speak Russian therefore i don`t understand the text and the script explanations and i`m unable to learn how the program works. If someone is kind enough to translate it in English would be awesome.   
...

Articles are available in English:  https://vk.com/@createmyvisualdatabaseapp_en

Anatomy https://vk.com/@createmyvisualdatabasea … omy-lesson

Forum branch "Training courses for developers. Articles about application developmen" - http://myvisualdatabase.com/forum/viewtopic.php?id=5286

1,237

(5 replies, posted in General)

AD1408 wrote:

I asked a question for any workaround of  MVD treeview recently on thread below but nothing from you so far:
http://myvisualdatabase.com/forum/viewtopic.php?id=5333

You got two options for solving your problem, including an example in the working code. To sort the tree, you must have a field in which the sequence number is stored, as well as the code that will update this field. This is how SQL works. The TreeView component has everything you need to implement sorting.

1,238

(9 replies, posted in General)

if you use SQLite and SQLQuery() you must free used DataSet.

SQLQuery('select a from b', tmpDataSet); // database is locked
...
tmpDataSet.Free // database is unlocked

Добавляйте столько строк, сколько вам нужно, прямо в цикле:


for i := 0 to JsonArray.Size-1  do 
begin
  JSONObjProp := TJSONObject( TJSONObject(JsonArray.Get(i)));
  JSONString := TJSONString(JSONObjProp.GetPairByName('password').JsonValue);
  frmAdmin.tgUserApp.AddRow;
  frmAdmin.tgUserApp.Cells[0,frmAdmin.tgUserApp.LastAddedRow] := JSONString.Value;
end;
m.prokhachev wrote:

У меня таблицы связаны так: 1<-2<-3->4->5, где стрелочки - это ключи-связи.


Видимо, вы добыли ценную информацию о том, какая таблица должна быть главной в связке: та, на которую нет ссылок  других таблиц.


Если бы пришлось писать запрос вручную, то по вашей схеме выборку нужно делать из таблицы 3, а остальные таблицы - джойнить, так что всё выглядит логично )))


Главную таблицу рекомендуется указывать, если число таблиц, данные из которых связываются построителем, больше двух.

alex842 wrote:

... можно ли перенести главное меню на другую форму? ...

var
  Menu:TMainMenu;

begin
  Menu := Form1.Menu;
  Form1.Menu := nil;
  Form2.Menu := Menu;
end.

Код переносит главное меню с Form1 на Form2


http://myvisualdatabase.com/forum/misc.php?action=pun_attachment&amp;item=5549&amp;download=0

vovka3003 wrote:

Зачем..? Так не проще?:

Если авторизация не проходит, то некрасиво  блымкает главная форма перед своим закрытием.

An accordion tune

https://pp.userapi.com/c853420/v853420561/59967/yIWUxYw8l1Y.jpg


One of the popular elements of the user interface is the "accordion" menu, which takes its name from its similarity to the famous musical instrument. Of course, the full animation of our accordion will not work, but you can add style and convenience to the app.


We will start from the TableGrid component and with the help of the parameters of its properties and additional scripts, we will play the melody we need.


Read the full article:https://vk.com/@createmyvisualdatabasea … rdion-tune

Anatomy lesson

https://pp.userapi.com/c849124/v849124349/1a741b/dn4y7GpXEuk.jpg


In the previous article, we used a list of application forms and a list of form components to get a list of forms and buttons. We will continue our study by examining the structure of the components: we will build a tree representation of the visual components available in the project - the heirs of the TControl class.


In addition, this article will discuss the construction of the software tree, as well as the FilterTree() procedure, which filters the data, while maintaining the structure of the tree itself.


Read the full article: https://vk.com/@createmyvisualdatabasea … omy-lesson

An advantageous agreement

https://pp.userapi.com/c855132/v855132086/54084/F-DDK7UDmbQ.jpg


As you have noticed, the names of all project elements are significant and follow certain rules. We can now receive dividends from these agreements:

• minimum software code
• maximum code reuse
• automation of user interface feature settings


We will also take a look inside our application so that the setting of access rights becomes global: from now on, any button can be added to the rights system. A mechanism will also be created to work with the modal version of the reference book to be used when editing forms.


Read the full article: https://vk.com/@createmyvisualdatabasea … -agreement

https://pp.userapi.com/c851124/v851124451/127505/_R6sMORcN7s.jpg

The basic course is an easy and quick way to get acquainted with the My Visual Database application development system. Training materials contain the necessary minimum of information and are well structured, and practical exercises will allow you to create your first database application.


Until July 1, 2019, you can complete the first lesson for FREE: https://vk.com/createmyvisualdatabaseap … 1997157_18

1,247

(4 replies, posted in General)

DriveSoft wrote:

Property CopyTo does not work when you use MySQL

CopyTo property allows you to specify where you want to automatically copy the file path relative to the location of the database file.

When you use MySQL, MVD can't to know where MySQL database files are placed, MVD know only IP address.

Can in CopyTo property write the full path? 

d:\Photos\

or

\\Tetacomputer\DCIM\

1,248

(2 replies, posted in General)

All forms created in the MVD  IDE are automatically created when the application starts and are destroyed only when application is closed. You can create forms and place the necessary components on them with the scripts, destroying forms immediately after they are closed. This will reduce the use of memory, but will significantly complicate the development of the application smile

1,249

(12 replies, posted in General)

AD1408 wrote:

As far as I could understand, your project script is for delphi, I was looking answers for MVD.

I wrote a series of articles on creating applications in MVD. You may be interested to read the articles in chronological order: https://vk.com/@createmyvisualdatabasea … rogramming

1,250

(12 replies, posted in General)

Article and scripts exclusively for MVD  )))


To change the branch in which the element is located, use the "Parent" drop-down list (3). To move an element within a branch, use the "Down" (1) and "Up" (2) buttons.


https://pp.userapi.com/c851232/v851232028/139065/R1qG-Rwpt_0.jpg


This article describes the scripts for editing the tree, in particular the procedure MoveTreeItem (ATable: string; ATree: TdbTreeView; AOrderNumCol: integer; ADown: boolean) ;.


The structure of the table with the tree is described here: https://vk.com/@createmyvisualdatabaseapp_en-menu

https://pp.userapi.com/c846322/v846322722/2022dc/V4d7DlWkHQg.jpg


Direct link to the MVD project download:https://drive.google.com/file/d/1dRWfgy … Rzrvm/view