📄 config.pas
字号:
unit config;
interface
uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
Buttons, ExtCtrls, Db, Mask, DBCtrls, Grids, DBGrids, ComCtrls, Dialogs,
DBTables;
type
TConfigDlg = class(TForm)
PageControl1: TPageControl;
Generale: TTabSheet;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label1: TLabel;
Label7: TLabel;
DBEdit2: TDBEdit;
DBEdit4: TDBEdit;
DBEdit5: TDBEdit;
DBEdit6: TDBEdit;
DBLookupComboBox1: TDBLookupComboBox;
DBRadioGroup1: TDBRadioGroup;
DBEdit1: TDBEdit;
DBEdit7: TDBEdit;
DsConfig: TDataSource;
Stampa: TTabSheet;
Infoclienti: TTabSheet;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
DBCheckBox2: TDBCheckBox;
Panel1: TPanel;
OKBtn: TButton;
CancelBtn: TButton;
ConfigurazioneBox: TGroupBox;
Label9: TLabel;
DBEdit9: TDBEdit;
Label8: TLabel;
DBEdit10: TDBEdit;
Label10: TLabel;
DBEdit11: TDBEdit;
Label11: TLabel;
DBEdit12: TDBEdit;
GroupBox1: TGroupBox;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
DBEdit13: TDBEdit;
DBEdit14: TDBEdit;
DBEdit15: TDBEdit;
DBEdit16: TDBEdit;
DBEdit17: TDBEdit;
DBEdit18: TDBEdit;
DBEdit19: TDBEdit;
DBEdit20: TDBEdit;
Carica: TButton;
Salva: TButton;
Label20: TLabel;
DBEdit21: TDBEdit;
SaveDialog: TSaveDialog;
OpenDialog: TOpenDialog;
GroupBox2: TGroupBox;
Label21: TLabel;
Label22: TLabel;
Label23: TLabel;
Label24: TLabel;
DBComboBox1: TDBComboBox;
DBComboBox2: TDBComboBox;
DBComboBox3: TDBComboBox;
DBComboBox4: TDBComboBox;
DBComboBox5: TDBComboBox;
Label31: TLabel;
DBLookupComboBox2: TDBLookupComboBox;
Intestazione: TTabSheet;
DBRichEdit1: TDBRichEdit;
DBRadioGroup2: TDBRadioGroup;
DBCheckBox3: TDBCheckBox;
Qresto: TQuery;
dsResto: TDataSource;
DBCheckBox4: TDBCheckBox;
TResto: TTable;
TRestoChiave: TStringField;
TRestoValore: TStringField;
TRestoIdGiornale: TStringField;
procedure OKBtnClick(Sender: TObject);
procedure CancelBtnClick(Sender: TObject);
procedure SalvaClick(Sender: TObject);
procedure CaricaClick(Sender: TObject);
procedure TRestoAfterOpen(DataSet: TDataSet);
private
{ Private declarations }
public
{ Public declarations }
end;
Type
ConfigCSF = record
StringaNuovo : Array [0..50] of Char ;
StringaRiga : Array [0..50] of Char ;
StringaTotale : Array [0..50] of Char ;
StringaFine : Array [0..50] of Char ;
Ar1,Ar2,Ar3,Ar4 : Real ;
R1,R2,R3,R4 : Array [0..50] of Char ;
end ;
var
ConfigDlg: TConfigDlg;
implementation
uses main;
{$R *.DFM}
procedure TConfigDlg.OKBtnClick(Sender: TObject);
begin
if (dsConfig.DataSet.State = dsEdit) or
(dsConfig.Dataset.State = dsInsert) then
begin
dsConfig.DataSet.Post ;
end;
if TResto.State = dsEdit then
Tresto.Post ;
end;
procedure TConfigDlg.CancelBtnClick(Sender: TObject);
begin
if (dsConfig.DataSet.State = dsEdit) or
(dsConfig.Dataset.State = dsInsert) then
begin
dsConfig.DataSet.Cancel ;
end;
if TResto.State = dsEdit then
Tresto.Cancel ;
end;
procedure TConfigDlg.SalvaClick(Sender: TObject);
Var
SalvaFile : File of ConfigCSF ;
Conf : ConfigCsf ;
begin
If Main_form.TTConfigNomeFileConfigurazione.AsString = '' then
begin
If not SaveDialog.Execute then
exit
else
Main_form.TTconfig.Edit ;
Main_form.TTconfignomeFileConfigurazione.asString := SaveDialog.FileName ;
end ;
AssignFile(SalvaFile,Main_form.TTconfigNomeFileConfigurazione.asString) ;
Rewrite(SalvaFile) ;
StrPcopy(Conf.StringaNuovo,Main_form.TTconfigStringanuovo.asString) ;
StrPCopy(conf.StringaRiga,Main_Form.TTconfigStringaRiga.asString) ;
StrPCopy(conf.Stringatotale,Main_form.TTconfigStringaTotale.AsString) ;
StrPCopy(conf.StringaFine,Main_form.TTconfigStringaFine.AsString) ;
conf.Ar1 := Main_form.TTConfigAliquotaR1.asFloat;
conf.Ar2 := Main_form.TTconfigAliquotaR2.AsFloat ;
Conf.Ar3 := Main_form.TTconfigAliquotaR3.AsFloat ;
conf.Ar4 := Main_form.TTConfigAliquotaR4.AsFloat ;
StrPCopy(Conf.R1,Main_form.TTConfigR1.asString) ;
StrPCopy(Conf.R2,Main_form.TTConfigR2.asString) ;
StrPCopy(Conf.R3,Main_form.TTConfigR3.asString) ;
StrPCopy(Conf.R4,Main_form.TTConfigR4.asString) ;
Write(Salvafile,Conf) ;
CloseFile(SalvaFile) ;
end;
procedure TConfigDlg.CaricaClick(Sender: TObject);
Var
SalvaFile : File of ConfigCSF ;
Conf : ConfigCsf ;
begin
OpenDialog.FileName := Main_form.TTConfigNomeFileConfigurazione.AsString ;
If not OpenDialog.Execute then exit ;
Main_form.TTconfig.Edit ;
Main_form.TTconfignomeFileConfigurazione.asString := OpenDialog.FileName ;
AssignFile(SalvaFile,Main_form.TTconfigNomeFileConfigurazione.asString) ;
Reset(SalvaFile) ;
Read(Salvafile,Conf) ;
CloseFile(SalvaFile) ;
Main_form.TTConfigStringaNuovo.AsString := Conf.StringaNuovo ;
Main_Form.TTconfigStringaRiga.asString := conf.StringaRiga ;
Main_form.TTconfigStringaTotale.AsString := conf.Stringatotale ;
Main_form.TTconfigStringaFine.AsString := conf.StringaFine ;
Main_form.TTConfigAliquotaR1.asFloat := conf.Ar1 ;
Main_form.TTconfigAliquotaR2.AsFloat := conf.Ar2 ;
Main_form.TTconfigAliquotaR3.AsFloat := Conf.Ar3 ;
Main_form.TTConfigAliquotaR4.AsFloat := conf.Ar4 ;
Main_form.TTConfigR1.asString := Conf.R1 ;
Main_form.TTConfigR2.asString := Conf.R2 ;
Main_form.TTConfigR3.asString := Conf.R3 ;
Main_form.TTConfigR4.asString := Conf.R4 ;
end;
procedure TConfigDlg.TRestoAfterOpen(DataSet: TDataSet);
begin
If TResto.isEmpty then
begin
TResto.Insert ;
TrestoChiave.AsString := 'RESTO' ;
TRestoValore.AsString := 'NO' ;
TResto.POst ;
end ;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -