?? c_jfdefine.~pas
字號:
unit C_JfDefine;
interface
uses SysUtils, DateUtils;
const
BufLen = 80;
SNDH = '市內電話';
DHFL_SH = 1;//市話
DHFL_NH = 2;//農話
DHFL_GN = 3;//國內長途
DHFL_GJ = 4;//國際長途
type
TComBuf = array[0..BufLen-1] of Char;
TBasicFmt = record
Room : string;
SDate: string;
STime: string;
Last : string;
Number: string;
end;
TFee = record
STime: TDateTime;
FTime: TDateTime;
AddiFee: Currency;
AddiFee0: Currency;
Xxtf: Currency;
Svc: Double;
Svc0: Currency;
Gn: Currency;
Gj: Currency;
Nh: Currency;
Wxf: Currency;
Yzf: Currency;
ShFee: Currency;
ShUnit: Double;
ShFee0: Currency;
ShUnit0: Double;
NhFee: Currency;
NhUnit: Double;
GnFee: Currency;
GnUnit: Double;
GjFee: Currency;
GjUnit: Double;
GatFee: Currency;
GatUnit: Double;
GnFeeYh: Currency;
GnYhUnit: Double;
GjFeeYh: Currency;
GjYhUnit: Double;
end;
TCodeInfo = record
APlace: string;
AFee: Currency;
AUnit: Double;
JFYN: Boolean;
NHYN: Boolean;
DHFL: Integer;
end;
TNewData = record
AClass: string;
Room : string;
Place: string;
Number: string;
SDate: TDateTime;
STime: TDateTime;
Last : Double;
AUnit: Currency;
Fee : Currency;
AddiFee: Currency;
SvcFee: Currency;
Total: Currency;
Flty: Integer;
end;
var
ComBuf : TComBuf;
BasBuf : TComBuf;
BasicFmt: TBasicFmt;
NewData : TNewData;
IsWrite : Boolean;
Fee : TFee;
CodeInfo: TCodeInfo;
function FindData: Integer;
function MoveData: Boolean;
procedure ReadData;
procedure WriteData;
procedure MainWork;
function CaculateLast(const ALast: string): Double;
function GetNewData: TNewData;
procedure WriteNewData(ANewData: TNewData);
procedure ShowNewData(ANewData: TNewData);
procedure InitFee;
procedure GetCodeInfo(const ANumber: string);
function FindCode(const ANumber: string): Boolean;
function FindShCode(const ANumber: string): Boolean;
function GetDate(const s: string): TDateTime;
function GetTime(const s: string): TDateTime;
function IsYh(ATime: TDateTime): Boolean;
implementation
uses C_JfMain, C_JfData;
function IsYh(ATime: TDateTime): Boolean;
begin
Result := False;
if (ATime>Fee.STime)or(ATime<Fee.FTime) then
Result := True;
end;
function GetTime(const s: string): TDateTime;
var
hh,nn: Word;
begin
hh := StrToInt(Copy(s,1,2));
nn := StrToInt(Copy(s,4,2));
Result := EnCodeTime(hh,nn,0,0);
end;
function GetDate(const s: string): TDateTime;
var
MM,DD: Word;
begin
MM := StrToInt(Copy(s,1,2));
DD := StrToInt(Copy(s,4,2));
Result := EnCodeDate(YearOf(Now),MM,DD);
end;
function FindCode(const ANumber: string): Boolean;
var
i,l: Integer;
s: string;
begin
Result := False;
l := Length(ANumber);
for i:=1 to l do
begin
s := Copy(ANumber,1,i);
if JfData.tblFare.Locate('CODE',s,[]) then
begin
Result := True;
Break;
end;
end;
end;
function FindShCode(const ANumber: string): Boolean;
var
i,l: Integer;
s: string;
begin
Result := False;
l := Length(ANumber);
for i:=1 to l do
begin
s := Copy(ANumber,1,i);
if JfData.tblShfare.Locate('CODE',s,[]) then
begin
Result := True;
Break;
end;
end;
end;
procedure GetCodeInfo(const ANumber: string);
var
ANum,s1,s2: string;
begin
s1 := Copy(ANumber,1,1);
s2 := Copy(ANumber,2,1);
ANum := Copy(ANumber,1,6);
if s1<>'0' then
begin
if JfData.tblShfare.Locate('CODE',ANum,[]) then
begin
CodeInfo.APlace := SNDH;
CodeInfo.AFee := JfData.tblShfare.FieldByName('UNIT').AsCurrency;
CodeInfo.AUnit:= JfData.tblShfare.FieldByName('PRICE').AsFloat;
CodeInfo.JFYN := JfData.tblShfare.FieldByName('JFYN').AsBoolean;
CodeInfo.NHYN := JfData.tblShfare.FieldByName('NHYN').AsBoolean;
if CodeInfo.NHYN then
CodeInfo.DHFL := DHFL_NH
else
CodeInfo.DHFL := DHFL_SH;
end
else
begin
if FindShCode(ANum) then
begin
CodeInfo.JFYN := JfData.tblShfare.FieldByName('JFYN').AsBoolean;
CodeInfo.NHYN := JfData.tblShfare.FieldByName('NHYN').AsBoolean;
end
else
begin
CodeInfo.JFYN := True;
CodeInfo.NHYN := False;
end;
CodeInfo.APlace := SNDH;
if CodeInfo.NHYN then
begin
CodeInfo.AFee := Fee.NhFee;
CodeInfo.AUnit:= Fee.NhUnit;
CodeInfo.DHFL := DHFL_NH;
end
else
begin
CodeInfo.AFee := Fee.ShFee;
CodeInfo.AUnit:= Fee.ShUnit;
CodeInfo.DHFL := DHFL_SH;
end;
end;
end
else
begin
if s2<>'0' then
begin
if FindCode(ANum) then
CodeInfo.APlace := JfData.tblFare.FieldByName('PLACE').AsString
else
CodeInfo.APlace := '未知地區';
CodeInfo.AFee := Fee.GnFee;
CodeInfo.AUnit:= Fee.GnUnit;
CodeInfo.JFYN := True;
CodeInfo.NHYN := False;
CodeInfo.DHFL := DHFL_GN;
end
else
begin
if FindCode(ANum) then
CodeInfo.APlace := JfData.tblFare.FieldByName('PLACE').AsString
else
CodeInfo.APlace := '未知地區';
CodeInfo.AFee := Fee.GjFee;
CodeInfo.AUnit:= Fee.GjUnit;
CodeInfo.JFYN := True;
CodeInfo.NHYN := False;
CodeInfo.DHFL := DHFL_GJ;
end;
end;
end;
procedure InitFee;
begin
with JfData.tblJfConfig do
begin
Open;
First;
Fee.STime := FieldByName('STime').AsDateTime;
Fee.FTime := FieldByName('FTime').AsDateTime;
Fee.AddiFee := FieldByName('AddiFee').AsCurrency;
Fee.AddiFee0 := FieldByName('AddiFee0').AsCurrency;
Fee.Xxtf := FieldByName('Xxtf').AsCurrency;
Fee.Svc := FieldByName('Svc').AsFloat;
Fee.Svc0 := FieldByName('Svc0').AsCurrency;
Fee.Gn := FieldByName('Gn').AsCurrency;
Fee.Gj := FieldByName('Gj').AsCurrency;
Fee.Nh := FieldByName('Nh').AsCurrency;
Fee.Wxf := FieldByName('Wxf').AsCurrency;
Fee.Yzf := FieldByName('Yzf').AsCurrency;
Fee.ShFee := FieldByName('ShFee').AsCurrency;
Fee.ShUnit:= FieldByName('ShUnit').AsFloat;
Fee.ShFee0 := FieldByName('ShFee0').AsCurrency;
Fee.ShUnit0 := FieldByName('ShUnit0').AsFloat;
Fee.NhFee := FieldByName('NhFee').AsCurrency;
Fee.NhUnit := FieldByName('NhUnit').AsFloat;
Fee.GnFee := FieldByName('GnFee').AsCurrency;
Fee.GnUnit := FieldByName('GnUnit').AsFloat;
Fee.GjFee := FieldByName('GjFee').AsCurrency;
Fee.GjUnit := FieldByName('GjUnit').AsFloat;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -