with Form2.Table2 do begin
first; While not eof do Begin DBGrid2.columns.Items[1].Picklist.add(FieldbyName('Nom_naklad').value); next; end; end; DBGrid2.Columns.Items[2].PickList.Clear; With Form2.Table1 do begin first; While not eof do Begin DBGrid2.columns.Items[2].Picklist.add(FieldbyName('Kod_pred').value); Форма 4 запрос SQL. На данной форме выводится параметрический запрос по полям “Название лекарства” и по ”Количеству проданных лекарств”.
Процедура Запроса SQL: Процедура кнопки обновить список: procedure TForm4.Button1Click(Sender: TObject); Begin Query1.Filtered:=false; Query1.Active:=true; end; Процедура кнопки поиска: procedure TForm4.Button3Click(Sender: TObject); Begin Query1.Filtered:=false; Case Radiogroup1.itemindex of 0:pole:='Name_lek'; 1:pole:='Kolvo_p_lek' end; Query1.Filtered:=true; end; procedure TForm4.Query1FilterRecord(DataSet: TDataSet; var Accept: Boolean); Begin Accept:=Dataset[pole]=edit1.text; end; Форма 5 на ней показана информация о Программе.
ЗАКЛЮЧЕНИЕ Данная программа пригодится небольшим фирмам занимающихся продажей и учетом лекарственных средств. Моя программа облегчит им работу, уменьшит работу с бумагами накладными и т.д. После разработки своей программы я узнал более подробно о языке программирования Delphi и приложений к нему в частности BDE Administrator и Database Desktop. BDE Administrator нужен для установления псевдонима. При переносе базы данных на другой компьютер надо обязательно установить псевдоним т.е. каталог где она находится иначе при запуске базы данных выйдет сообщение об ошибке. Database Desktop нужна для создания и редактирования таблиц баз данных. Язык программирования Delphi является более простым для написания баз данных в нем есть все возможные компоненты упрощающие работу. На Delphi написано довольно большое число баз данных. ЛИТЕРАТУРА 1. Delphi 3 и создание приложений баз данных Шумаков П.В. 704 с. иллюстрации есть. 2. Delphi 4 для профессионалов издание Питер М.Кенту 1088 с. иллюстрации есть.
Листинг программы unit Unit1; interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, Grids, DBGrids, Db, DBTables, ComCtrls, Menus, Buttons, Mask, DBCtrls;
type TForm1 = class(TForm) DataSource1: TDataSource; Table1: TTable; GroupBox1: TGroupBox; DBGrid1: TDBGrid; Label1: TLabel; Panel1: TPanel; GroupBox2: TGroupBox; Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; Button5: TButton; MainMenu1: TMainMenu; N1: TMenuItem; N2: TMenuItem; GroupBox3: TGroupBox; BitBtn3: TBitBtn; BitBtn4: TBitBtn; N3: TMenuItem; DBEdit1: TDBEdit; DBEdit2: TDBEdit; DBEdit3: TDBEdit; DBEdit4: TDBEdit; DBEdit5: TDBEdit; SQL1: TMenuItem; RadioGroup1: TRadioGroup; CheckBox1: TCheckBox; Edit1: TEdit; Button6: TButton; StatusBar1: TStatusBar; N4: TMenuItem; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure BitBtn3Click(Sender: TObject); procedure BitBtn4Click(Sender: TObject); procedure N3Click(Sender: TObject); procedure SQL1Click(Sender: TObject); procedure Table1FilterRecord(DataSet: TDataSet; var Accept: Boolean); procedure CheckBox1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure ShowHint(Sender: TObject); procedure N4Click(Sender: TObject); procedure Button6Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
uses Unit2, Unit3, Unit4, Unit5;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject); begin If table1.State = dsBrowse then table1.insert; end;
procedure TForm1.Button2Click(Sender: TObject); begin If table1.State = dsBrowse then table1.edit;
end;
procedure TForm1.Button3Click(Sender: TObject); begin If table1.State = dsBrowse then If Messagedlg('',mtconfirmation,[mbYes,mbNo],0)=mrYes then table1.delete; end;
procedure TForm1.Button4Click(Sender: TObject); begin If table1.State in [dsInsert,dsEdit]then table1.post; end;
procedure TForm1.Button5Click(Sender: TObject); begin If table1.State in [dsInsert,dsEdit]then table1.Cancel; end;
procedure TForm1.BitBtn3Click(Sender: TObject); begin Form2.show; Form1.hide; end;
procedure TForm1.BitBtn4Click(Sender: TObject); begin Form3.show; Form1.hide; end;
procedure TForm1.N3Click(Sender: TObject); begin close; end;
procedure TForm1.SQL1Click(Sender: TObject); begin Form4.show; end;
procedure TForm1.Table1FilterRecord(DataSet: TDataSet; var Accept: Boolean); begin Accept:=Dataset['Name_lek'] = Edit1.text; end;
procedure TForm1.CheckBox1Click(Sender: TObject); begin Table1.Filtered:=CheckBox1.Checked; Table1.Filtered:=true; end;
procedure TForm1.FormCreate(Sender: TObject); begin Application.OnHint:= ShowHint;
end; procedure TForm1.ShowHint(Sender: TObject); begin StatusBar1.Panels[0].text:= Application.Hint; end; procedure TForm1.N4Click(Sender: TObject); begin Form5.show; end;
procedure TForm1.Button6Click(Sender: TObject); begin Table1.Filtered:=False; end;
end.
unit Unit2;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Grids, DBGrids, Db, DBTables, StdCtrls, ExtCtrls, ComCtrls, Buttons, Mask, DBCtrls;
type TForm2 = class(TForm) GroupBox1: TGroupBox; DataSource1: TDataSource; Table1: TTable; DBGrid1: TDBGrid; GroupBox2: TGroupBox; DBGrid2: TDBGrid; DataSource2: TDataSource; Table2: TTable; GroupBox3: TGroupBox; Button5: TButton; Button6: TButton; Button7: TButton; Button8: TButton; Label1: TLabel; Label2: TLabel; GroupBox4: TGroupBox; Panel1: TPanel; Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; Button9: TButton; StatusBar1: TStatusBar; GroupBox5: TGroupBox; BitBtn1: TBitBtn; BitBtn2: TBitBtn; DBEdit1: TDBEdit; DBEdit2: TDBEdit; DBEdit3: TDBEdit; DBEdit4: TDBEdit; DBEdit5: TDBEdit; DBEdit6: TDBEdit; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button9Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Button6Click(Sender: TObject); procedure Button8Click(Sender: TObject); procedure Button7Click(Sender: TObject); procedure BitBtn1Click(Sender: TObject); procedure BitBtn2Click(Sender: TObject); procedure OnActivate(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form2: TForm2;
implementation
uses Unit1, Unit3;
{$R *.DFM}
procedure TForm2.Button1Click(Sender: TObject); begin If table1.State = dsBrowse then table1.insert; end;
procedure TForm2.Button2Click(Sender: TObject); begin If table1.State = dsBrowse then table1.edit; end; procedure TForm2.Button3Click(Sender: TObject); begin If table1.State = dsBrowse then If Messagedlg('',mtconfirmation,[mbYes,mbNo],0)=mrYes then table1.delete; end;
procedure TForm2.Button4Click(Sender: TObject); begin If table1.State in [dsInsert,dsEdit]then table1.post; end;
procedure TForm2.Button9Click(Sender: TObject); begin If table1.State in [dsInsert,dsEdit]then table1.Cancel; end;
procedure TForm2.Button5Click(Sender: TObject); begin If table2.State = dsBrowse then table2.insert;
end;
procedure TForm2.Button6Click(Sender: TObject); begin If table2.State = dsBrowse then If Messagedlg('',mtconfirmation,[mbYes,mbNo],0)=mrYes then table2.delete;
end;
procedure TForm2.Button8Click(Sender: TObject); begin If table2.State = dsBrowse then table2.edit;
end;
procedure TForm2.Button7Click(Sender: TObject); begin If table2.State in [dsInsert,dsEdit]then table2.post;
end;
procedure TForm2.BitBtn1Click(Sender: TObject); begin Form1.show; Form2.hide; end;
procedure TForm2.BitBtn2Click(Sender: TObject); begin Form3.show; Form2.hide; end; procedure TForm2.OnActivate(Sender: TObject); begin DBGrid2.Columns.Items[1].PickList.Clear; with Table1 do begin first; While not eof do Begin DBGrid2.columns.Items[1].Picklist.add(FieldByName('Kod_pred').value); next; end; end; end; end.
unit Unit3;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Db, DBTables, Grids, DBGrids, ComCtrls, Buttons, Mask, DBCtrls;
type TForm3 = class(TForm)
GroupBox1: TGroupBox; DBGrid1: TDBGrid; DataSource1: TDataSource; Table1: TTable; Label1: TLabel; Label2: TLabel; GroupBox2: TGroupBox; Panel1: TPanel; Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; GroupBox3: TGroupBox; DBGrid2: TDBGrid; DataSource2: TDataSource; Table2: TTable; GroupBox4: TGroupBox; Button5: TButton; Button6: TButton; Button7: TButton; Button8: TButton; StatusBar1: TStatusBar; GroupBox5: TGroupBox; BitBtn1: TBitBtn; BitBtn2: TBitBtn; DBEdit1: TDBEdit; DBEdit2: TDBEdit; DBEdit3: TDBEdit; DBEdit4: TDBEdit; DBEdit5: TDBEdit; DBEdit6: TDBEdit; DBEdit7: TDBEdit; DBEdit8: TDBEdit; DBEdit9: TDBEdit; DBEdit10: TDBEdit; DBEdit11: TDBEdit; procedure Button1Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Button6Click(Sender: TObject); procedure Button7Click(Sender: TObject); procedure Button8Click(Sender: TObject); procedure BitBtn1Click(Sender: TObject); procedure BitBtn2Click(Sender: TObject); procedure OnActivate(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form3: TForm3;
implementation
uses Unit1, Unit2;
{$R *.DFM}
procedure TForm3.Button1Click(Sender: TObject); begin If table2.State = dsBrowse then table2.insert; end;
procedure TForm3.Button4Click(Sender: TObject); begin If table2.State in [dsInsert,dsEdit]then table2.post;
end;
procedure TForm3.Button3Click(Sender: TObject); begin If table2.State = dsBrowse then table2.edit; end;
procedure TForm3.Button2Click(Sender: TObject); begin If table2.State = dsBrowse then If Messagedlg('',mtconfirmation,[mbYes,mbNo],0)=mrYes then table2.delete; end;
procedure TForm3.Button5Click(Sender: TObject); begin If table1.State = dsBrowse then table1.insert; end;
procedure TForm3.Button6Click(Sender: TObject); begin If table1.State = dsBrowse then If Messagedlg('',mtconfirmation,[mbYes,mbNo],0)=mrYes then table1.delete; end;
procedure TForm3.Button7Click(Sender: TObject); begin If table1.State = dsBrowse then table1.edit;
end;
procedure TForm3.Button8Click(Sender: TObject); begin If table1.State in [dsInsert,dsEdit]then table1.post;
end;
procedure TForm3.BitBtn1Click(Sender: TObject); begin Form1.show; Form3.hide; end;
procedure TForm3.BitBtn2Click(Sender: TObject); begin Form2.show; Form3.hide; end; procedure TForm3.OnActivate(Sender: TObject); begin DBGrid2.Columns.Items[3].PickList.Clear; with Form1.Table1 do begin first; While not eof do Begin DBGrid2.columns.Items[3].Picklist.add(FieldbyName('Kod_lek').value); next; end; end; DBGrid2.Columns.Items[1].PickList.Clear; with Form2.Table2 do begin first; While not eof do Begin DBGrid2.columns.Items[1].Picklist.add(FieldbyName('Nom_naklad').value); next; end; end; DBGrid2.Columns.Items[2].PickList.Clear; with Form2.Table1 do begin first; While not eof do Begin DBGrid2.columns.Items[2].Picklist.add(FieldbyName('Kod_pred').value); next; end; end; DBGrid1.Columns.Items[1].PickList.Clear; with Form1.Table1 do begin first; While not eof do Begin DBGrid1.columns.Items[1].Picklist.add(FieldbyName('Kod_lek').value); next; end; end; end; end.
unit Unit4;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Db, DBTables, Grids, DBGrids, ExtCtrls;
type TForm4 = class(TForm) GroupBox1: TGroupBox; DBGrid1: TDBGrid; DataSource1: TDataSource; Button1: TButton; Query1: TQuery; Edit1: TEdit; Button3: TButton; RadioGroup1: TRadioGroup; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Query1FilterRecord(DataSet: TDataSet; var Accept: Boolean); private { Private declarations } public { Public declarations } end;
var Form4: TForm4; pole:shortstring;
implementation
{$R *.DFM}
procedure TForm4.Button1Click(Sender: TObject); begin Query1.Filtered:=false; Query1.Active:=true; end;
procedure TForm4.Button2Click(Sender: TObject); begin Query1.Active:=false; end;
procedure TForm4.Button3Click(Sender: TObject); begin Query1.Filtered:=false; Case Radiogroup1.itemindex of 0:pole:='Name_lek'; 1:pole:='Kolvo_p_lek' end; Query1.Filtered:=true; end; procedure TForm4.Query1FilterRecord(DataSet: TDataSet; var Accept: Boolean); begin Accept:=Dataset[pole]=edit1.text; end;
end.
unit Unit5;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Buttons;
type TForm5 = class(TForm) Image1: TImage; Label1: TLabel; Label2: TLabel; Label3: TLabel; BitBtn1: TBitBtn; Label6: TLabel; procedure Button1Click(Sender: TObject); procedure BitBtn1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form5: TForm5;
implementation
{$R *.DFM}
procedure TForm5.Button1Click(Sender: TObject); begin Form5.close; end;
procedure TForm5.BitBtn1Click(Sender: TObject); begin Form5.Close; end; end.
Воспользуйтесь поиском по сайту: ©2015 - 2024 megalektsii.ru Все авторские права принадлежат авторам лекционных материалов. Обратная связь с нами...
|