Welcome )
7,152 2015-05-20 16:24:02
Re: Next_Prev 1.51 ? (3 replies, posted in General)
No problem, added 5 min ago )
7,154 2015-05-20 16:20:37
Topic: [Script] Next and Previous buttons (3 replies, posted in FAQ)
Next and Previous buttons for navigation
Download project (navigation on Form)
http://myvisualdatabase.com/forum/misc. … e_str=2f10
Download project (navigation in TableGrid)
http://myvisualdatabase.com/forum/misc. … e_str=2f10
------
7,155 2015-05-20 15:57:45
Re: how to character length limit ? (3 replies, posted in General)
MaxLength
Specifies the maximum length of text for a component to remove the restriction on the length of the text, set the property to 0
Example:
Form1.Edit1.MaxLength := 10;
7,156 2015-05-20 11:46:46
Re: Автоматизация (30 replies, posted in Russian)
Приложите пожалуйста ваш проект.
7,157 2015-05-20 11:22:42
Re: Автоматизация (30 replies, posted in Russian)
попробуйте так
procedure order_discount_OnChange (Sender: string);
begin
order.endprice.Value := SQLExecute('SELECT startprice FROM orders WHERE id='+students.orderslist.sqlValue) -
SQLExecute('SELECT discount FROM orders WHERE id='+students.orderslist.sqlValue);
end;
7,158 2015-05-20 11:20:03
Topic: [Script] Import CSV file into the database (8 replies, posted in FAQ)
Import CSV file into the database
procedure Form1_Button2_OnClick (Sender: string; var Cancel: boolean);
var
OpenDialog: TOpenDialog;
sl: TStringList;
arrStr: array of string;
i,c: integer;
begin
OpenDialog := TOpenDialog.Create(Form1);
OpenDialog.InitialDir := ExtractFileDir(Application.Exename);
if OpenDialog.Execute then
begin
sl := TStringList.Create;
sl.LoadFromFile (OpenDialog.FileName);
c := sl.Count - 1;
for i := 0 to c do
begin
arrStr := SplitString(sl[i], ';');
// LastName
if arrStr[0] <> '' then arrStr[0] := ''''+ ReplaceStr(arrStr[0], '''', '''''') + ''''
else arrStr[0] := 'NULL';
// FirstName
if arrStr[1] <> '' then arrStr[1] := ''''+ ReplaceStr(arrStr[1], '''', '''''') + ''''
else arrStr[1] := 'NULL';
SQLExecute ('INSERT INTO base (lastname, firstname) VALUES ('+ arrStr[0] +','+ arrStr[1]+');');
Form1.Label1.Caption := IntToStr(i+1) + ' of ' + IntToStr(c+1);
Application.ProcessMessages;
end;
sl.Free;
Form1.TableGrid1.dbUpdate;
end;
OpenDialog.Free;
end;
begin
end.
Download project:
http://myvisualdatabase.com/forum/misc. … download=1
7,159 2015-05-20 11:18:39
Topic: [Script] Quick search for ComboBox (3 replies, posted in FAQ)
It allows you to quickly find the desired value in the list ComboBox
procedure Form1_edGroupSearch_OnChange (Sender: string);
begin
Form1.cbGroups.dbFilter := 'groupname LIKE "%'+ Form1.edGroupSearch.Text +'%"';
UpdateDatabase('groups');
if Form1.cbGroups.Items.Count = 2 then
begin
Form1.cbGroups.DroppedDown:=False;
Form1.cbGroups.ItemIndex := 1;
end else Form1.cbGroups.DroppedDown:=True;
end;
begin
Form1.edGroupSearch.TextHint := 'Search for groups...';
end.
Download project:
http://myvisualdatabase.com/forum/misc. … download=1
7,160 2015-05-20 11:05:06
Topic: [Script] Send in the report, only the selected records in TableGrid (0 replies, posted in FAQ)
Send in the report, only the selected records in TableGrid
procedure Form1_bSQLReport_OnClick (Sender: string; var Cancel: boolean);
var
i,c: integer;
s: string;
begin
s := '';
Form1.bSQLReport.dbSQL := 'SELECT lastname, firstname, strftime(''%m/%d/%Y'', dateofbirth) as dateofbirth FROM employees';
c := Form1.GridEmployees.RowCount-1;
for i := 0 to c do
begin
if Form1.GridEmployees.Selected[i] then s := s + 'employees.id='+IntToStr(Form1.GridEmployees.dbIndexToID(i)) + ' OR ';
end;
if s <> '' then
begin
SetLength(s, Length(s)-4);
Form1.bSQLReport.dbSQL := Form1.bSQLReport.dbSQL + ' WHERE ' + s;
end;
end;
begin
Form1.GridEmployees.Options := Form1.GridEmployees.Options + goMultiSelect;
end.
Download project:
http://myvisualdatabase.com/forum/misc. … download=1
7,161 2015-05-20 11:03:46
Topic: [Script] Sending E-mail message with a file. (0 replies, posted in FAQ)
Sending E-mail message with a file.
from version 4.05 you can specify several recipients by separating them with ;
procedure Form1_bSend_OnClick (Sender: string; var Cancel: boolean);
begin
Form1.bSend.Enabled := False;
if SendMail(Form1.edServer.Text, Form1.edUsername.Text, Form1.edPassword.Text, Trunc(Form1.edPort.Value), Form1.edFrom.Text, Form1.edTo.Text, Form1.edSubject.Text, Form1.mmMessage.Text, Form1.edFileName.Text) then
ShowMessage('Message sent');
Form1.bSend.Enabled := True;
end;
begin
end.
Download project:
http://myvisualdatabase.com/forum/misc. … download=1
7,162 2015-05-20 11:02:29
Topic: [Script] Creating custom counter (eg .: MS-0001, MS-0002) (0 replies, posted in FAQ)
Creating custom counter:
MS-0001
MS-0002
MS-0003
Download project:
http://myvisualdatabase.com/forum/misc. … download=1
7,164 2015-05-20 11:00:11
Topic: [Script] Creating your own menu item "About" and a window About. (8 replies, posted in FAQ)
Creating your own menu item "About" and a window with information.
procedure Form1_OnShow (Sender: string; Action: string); // event OnShow
begin
Form1.mniAbout.OnClick := @MenuClickAbout;
end;
procedure MenuClickAbout (Sender: string); // click in About menu item
begin
frmAbout.ShowModal;
end;
begin
end.
Download project:
http://myvisualdatabase.com/forum/misc. … download=1
7,165 2015-05-20 10:58:33
Topic: [Script] Check the existence of record before saving. (0 replies, posted in FAQ)
Check the existence of record before saving.
function CheckDublicate (Action, sTable, sField, sValue: string; id: integer;): boolean;
var
s: string;
sIdSQL: string;
arrFields: array of string;
arrValues: array of string;
sWhere: string;
i,c: integer;
begin
result := False;
arrFields := SplitString(sField, ';');
arrValues := SplitString(sValue, ';');
if Length(arrFields) <> Length(arrFields) then exit;
sWhere := '';
c := Length(arrFields)-1;
for i := 0 to c do
begin
if arrValues[i] <> 'NULL' then
sWhere := sWhere + arrFields[i]+' LIKE ' + arrValues[i] + ' AND '
else sWhere := sWhere + arrFields[i]+' IS NULL AND '
end;
if sWhere<>'' then SetLength(sWhere, Length(sWhere)-4);
if Action = 'NewRecord' then
begin
s := SQLExecute ('SELECT Count(*) FROM '+sTable+' WHERE '+sWhere);
if StrToInt(s) > 0 then result := True;
end;
if Action = 'ShowRecord' then
begin
if id <> -1 then sIdSQL := ' AND (id <> '+ IntToStr(id) +')';
s := SQLExecute ('SELECT Count(*) FROM '+sTable+' WHERE ('+ sWhere +') ' + sIdSQL);
if StrToInt(s) > 0 then result := True;
end;
end;
procedure frmEmployee_Button2_OnClick (Sender: string; var Cancel: boolean);
var
sFields, sValues: string;
begin
sFields := 'lastname;firstname';
sValues := frmEmployee.edLastName.sqlValue+';'+frmEmployee.edFistName.sqlValue;
if CheckDublicate(frmEmployee.dbAction, 'employees', sFields, sValues, frmEmployee.ButtonSave.dbGeneralTableId) then
begin
ShowMessage('Person already exists.');
Cancel := True;
end;
end;
begin
end.
Download project:
7,166 2015-05-20 10:57:12
Topic: [Script] Hide the main menu (File, Options, About) (2 replies, posted in FAQ)
Hide the main menu (File, Options, About)
begin
Form1.mniFile.Visible := False;
Form1.mniOptions.Visible := False;
Form1.mniSettings.Visible := False;
Form1.mniReport.Visible := False;
Form1.mniAbout.Visible := False;
end.
Download project:
http://myvisualdatabase.com/forum/misc. … download=1
7,167 2015-05-20 10:55:19
Topic: [Script] Adding a menu item for the component TableGrid (0 replies, posted in FAQ)
Adding a menu item for the component TableGrid
procedure Form1_OnShow (Sender: string; Action: string);
var
MyItem1: TMenuItem;
begin
MyItem1 := TMenuItem.Create (Form1);
MyItem1.Caption := 'My Item1';
MyItem1.OnClick := @MenuClick1;
Form1.GridEmployees.dbPopupMenu.Items.Insert(0, MyItem1);
end;
procedure MenuClick1;
begin
ShowMessage('Hello from PopupMenu');
end;
begin
end.
Download project:
http://myvisualdatabase.com/forum/misc. … download=1
7,168 2015-05-20 10:53:57
Topic: [Script] Automatic backup database (12 replies, posted in FAQ)
In the folder "backup" creates a backup copy of the database "backup_data_[TIME].db" when entering\exit the program, and every three hours.
var
Timer: TTimer;
iSeconds: integer;
procedure Form1_OnShow (Sender: string; Action: string);
begin
CopyFile('sqlite.db', 'backup/backup '+ FormatDateTime('dd-mm-yyyy hh-nn-ss', now)+'.db');
Timer := TTimer.Create (Form1);
Timer.Interval := 1000;
Timer.Enabled := True;
Timer.OnTimer := @OnTimer;
end;
procedure Form1_OnClose (Sender: string; Action: string);
begin
CopyFile('sqlite.db', 'backup/backup '+ FormatDateTime('dd-mm-yyyy hh-nn-ss', now)+'.db');
Timer.Free;
end;
procedure OnTimer;
begin
iSeconds := iSeconds + 1;
if iSeconds > 10800 then // backup every 3 hours (10800 seconds)
begin
iSeconds := 0;
CopyFile('sqlite.db', 'backup/backup '+ FormatDateTime('dd-mm-yyyy hh-nn-ss', now)+'.db');
end;
end;
begin
end.
Download project:
http://myvisualdatabase.com/forum/misc. … download=1
7,169 2015-05-20 10:51:40
Topic: [Script] Sign in with your login and password (9 replies, posted in FAQ)
Sign in with your login and password.
Download project:
http://myvisualdatabase.com/forum/misc. … download=1
With protect user re-entry into the database:
http://myvisualdatabase.com/forum/misc. … download=1
-
7,170 2015-05-20 10:49:30
Topic: [Script] Opening e-mail program with the addressee (2 replies, posted in FAQ)
Opening e-mail program with the addressee
procedure Form1_Edit1_OnDoubleClick (Sender: string);
begin
OpenFile('mailto:'+Form1.Edit1.Text);
end;
// not necessarily
// just for hight light e-mail address and change cursor to HandPoint
procedure Form1_Edit1_OnKeyUp (Sender: string; var Key: Word; Shift, Alt, Ctrl: boolean);
begin
if Pos('@', Form1.Edit1.Text)>0 then
begin
Form1.Edit1.Cursor := crHandPoint;
Form1.Edit1.Font.Style:=fsUnderline;
Form1.Edit1.Font.Color := clHotLight;
end else
begin
Form1.Edit1.Cursor := crDefault;
Form1.Edit1.Font.Style:=0;
Form1.Edit1.Font.Color := clDefault;
end;
end;
begin
end.
Download project:
http://myvisualdatabase.com/forum/misc. … download=1
7,171 2015-05-20 10:47:47
Topic: [Report] Print barcode (0 replies, posted in FAQ)
Print barcode
Download project:
http://myvisualdatabase.com/forum/misc. … download=1
Print barcodes in three columns:
http://myvisualdatabase.com/forum/misc. … download=1
7,172 2015-05-20 10:45:08
Topic: [Script] Create trial project (5 replies, posted in FAQ)
It allows you to make your project work with a limited period, such as 30 days.
Also giving the client a program for testing, you can delete the file from the folder Script.pas Script, to the script could not be modified.
procedure Form1_OnShow (Sender: string; Action: string);
var
reg: TRegistry;
iDays: integer;
begin
reg := TRegistry.Create;
reg.Access := KEY_ALL_ACCESS;
reg.RootKey := HKEY_CURRENT_USER;
reg.OpenKey('software\MyVisualDatabaseTrial',true);
if not reg.ValueExists('StartDate') then reg.WriteDate('StartDate', Now+30); // trial period is 30 days
iDays := Trunc(reg.ReadDate('StartDate')) - Trunc(Now); // time left days
reg.CloseKey;
reg.Free;
if iDays < 1 then
begin
if MessageDlg('Trial period is over.'+#13+' Do you want to visit a order page?', mtInformation, mbYes+mbNo, 0) = mrYes
then OpenUrl('http://yourpage.com');
Form1.Close;
Exit;
end;
if MessageDlg('Demo version. Time left: ' + IntToStr(iDays) +' days.'+#13+'Do you want to visit a order page?', mtInformation, mbYes+mbNo, 0) = mrYes
then OpenUrl('http://yourpage.com');
end;
begin
end.
Download project:
http://myvisualdatabase.com/forum/misc. … download=1
Another project with serial number:
http://myvisualdatabase.com/forum/misc. … download=1
7,173 2015-05-20 10:43:14
Topic: [Script] Multiple select records in TableGrid for removing (5 replies, posted in FAQ)
Multiple select records in TableGrid for removing
procedure Form1_Button5_OnClick (Sender: string; var Cancel: boolean);
var
i,c: integer;
iColumn: integer;
begin
iColumn := Form1.GridEmployees.Columns.Count-1; // in last column stored id of record (last column hided)
c := Form1.GridEmployees.RowCount - 1; // count of records in TableGrid
for i :=0 to c do
if Form1.GridEmployees.Selected[i] then // if record selected
SQLExecute('DELETE FROM employees WHERE id = ' + Form1.GridEmployees.Cells[iColumn, i]); // SQL query for selected record
Form1.GridEmployees.dbUpdate;
end;
begin
Form1.GridEmployees.Options := Form1.GridEmployees.Options + goMultiSelect;
end.
Download project:
http://myvisualdatabase.com/forum/misc. … download=1
7,174 2015-05-20 10:41:41
Topic: [Script] Create your own menu on the main form (0 replies, posted in FAQ)
Create your own menu on the main form
procedure Form1_OnShow (Sender: string; Action: string); // event OnShow
var
MyItem1: TMenuItem;
MyItem2: TMenuItem;
MySubItem3: TMenuItem;
begin
MyItem1 := TMenuItem.Create (Form1.MainMenu);
MyItem1.Caption := 'Item1';
MyItem1.OnClick := @MenuClick1;
MyItem2 := TMenuItem.Create (Form1.MainMenu);
MyItem2.Caption := 'Item2';
MySubItem3 := TMenuItem.Create (Form1.MainMenu);
MySubItem3.Caption := 'Submenu';
MySubItem3.OnClick := @MenuClick3;
Form1.mniFile.Insert(0, MyItem1);
Form1.MainMenu.Items.Insert(0, MyItem2);
MyItem2.Add(MySubItem3);
end;
procedure MenuClick1 (Sender: string);
begin
ShowMessage('Hello from MyItem1');
end;
procedure MenuClick3 (Sender: string);
begin
ShowMessage('Hello from subitem');
end;
begin
end.
Download project 1:
http://myvisualdatabase.com/forum/misc. … download=1
Download project 2:
http://myvisualdatabase.com/forum/misc. … download=1
7,175 2015-05-20 10:39:46
Topic: [Report] The figures in words (0 replies, posted in FAQ)
The figures in words.
Download project: