frmoutcards.pas
来自「IC卡饭堂售饭管理系统源码,内有相关说明,」· PAS 代码 · 共 160 行
PAS
160 行
unit FrmOutCardS;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, TFlatComboBoxUnit, TFlatSpinEditUnit, TFlatEditUnit,
ExtCtrls, TFlatPanelUnit, Grids, ValEdit,Inifiles,
TFlatButtonUnit, DB, RxMemDS, DBGrids;
type
PClockInfo=^TClockInfo;
TClockInfo=record
ID: WORD;
ClockNo: String;
ClockName: String;
Port: WORD;
BaudRate: DWORD;
end;
type
TFrmOutCard = class(TForm)
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
FlatEdit1: TFlatEdit;
FlatSpinEditInteger1: TFlatSpinEditInteger;
FlatComboBox1: TFlatComboBox;
FlatComboBox2: TFlatComboBox;
FlatPanel1: TFlatPanel;
FlatButton1: TFlatButton;
FlatButton2: TFlatButton;
FlatButton3: TFlatButton;
MDS: TRxMemoryData;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
procedure FormCreate(Sender: TObject);
procedure ValueListEditor1Click(Sender: TObject);
procedure FlatButton1Click(Sender: TObject);
procedure FlatButton2Click(Sender: TObject);
procedure FlatButton3Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FrmOutCard: TFrmOutCard;
DeviceCount:Integer;
implementation
{$R *.dfm}
function IntToStrLen(Value : Integer; ResultLength :Byte):String;
begin
Result:=IntToStr(Value);
while Length(Result) < Resultlength do
Result:='0'+Result;
Result:=Copy(Result, Length(Result)-ResultLength+1, ResultLength);
end;
procedure TFrmOutCard.FormCreate(Sender: TObject);
var GetInfo:TIniFile;
FileName:String;
CardInfo:PClockInfo;
i:Integer;
DeviceInfo:String;
begin
FileName:=ExtractFilePath(ExtractFilePath(Application.ExeName))+'CardInfo.ini';
GetInfo:=TIniFile.Create(FileName);
with GetInfo do begin
DeviceCount:=strtoint(ReadString('Device','Counter',''));
for i:=1 to DeviceCount do begin
DeviceInfo:=ReadString('Device','Device'+inttostr(i),'');
New(CardInfo);
CardInfo.ID:=StrToInt(copy(DeviceInfo,9,4));
CardInfo.ClockNo:=copy(DeviceInfo,1,4);
CardInfo.ClockName:=copy(DeviceInfo,17,StrLen(pchar(DeviceInfo))-16);
CardInfo.Port:=strtoint(copy(Deviceinfo,5,4));
CardInfo.BaudRate:=StrToIntDef(copy(DeviceInfo,13,4),9600);
//ValueListEditor1.InsertRow(cardinfo.ClockName,cardinfo.ClockNo,true);
with mds do begin
Mds.Append;
FieldByname('DeviceName').asString:=CardInfo.ClockName;
FieldByname('DeviceID').asString:=CardInfo.ClockNo;
FieldByname('Port').asInteger:=CardInfo.Port;
FieldByname('Speed').asInteger:=CardInfo.BaudRate;
Post;
end;
FreeMemory(CardInfo);
end;
end;
end;
procedure TFrmOutCard.ValueListEditor1Click(Sender: TObject);
VAR ReadFile:TIniFile;
FileName:String;
ReadInfo:String;
begin
end;
procedure TFrmOutCard.FlatButton1Click(Sender: TObject);
begin
with MDS do begin
Append;
FieldByname('DeviceName').asString:=FlatEdit1.Text;
FieldByname('DeviceID').asString:=IntToStrLen(FlatSpinEditInteger1.Value,4);
FieldByname('Port').asInteger:=strtoint(FlatComboBox1.Text);
FieldByname('Speed').asInteger:=strtoint(FlatComboBox2.Text);
DeviceCount:=DeviceCount+1;
Post;
end;
end;
procedure TFrmOutCard.FlatButton2Click(Sender: TObject);
begin
with MDS do begin
Edit;
FieldByname('DeviceName').asString:=FlatEdit1.Text;
FieldByname('DeviceID').asString:=inttostr(FlatSpinEditInteger1.Value);
FieldByname('Port').asInteger:=strtoint(FlatComboBox1.Text);
FieldByname('Speed').asInteger:=strtoint(FlatComboBox2.Text);
Post;
end;
end;
procedure TFrmOutCard.FlatButton3Click(Sender: TObject);
begin
with MDS do begin
Delete;
DeviceCount:=DeviceCount - 1;
end;
end;
procedure TFrmOutCard.FormClose(Sender: TObject; var Action: TCloseAction);
var WriteInfo:TIniFile;
FileName:String;
Str:String;
begin
FileName:=ExtractFilePath(Application.ExeName)+'CardInfo.ini';
WriteInfo:=TIniFile.Create(FileName);
MDS.First;
while not MDS.Eof do begin
with MDS do begin
WriteInfo.WriteString('Device','Counter',inttostr(DeviceCount));
Str:=FieldByName('DeviceID').AsString+IntToStrLen(FieldByName('Port').AsInteger, 4)+IntToStrLen(FieldByName('Speed').AsInteger, 8)+FieldByName('DeviceName').AsString;
WriteInfo.WriteString('Device','Device'+inttostr(RecNo),Str);
Next;
end;
end;
self.Release;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?