unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Math, MaskUtils, IniFiles,
LMDBaseEdit, LMDCustomEdit, LMDCustomMaskEdit, LMDMaskEdit,
LMDControl, LMDBaseControl, LMDBaseGraphicControl, LMDBaseLabel,
LMDCustomLabel, LMDLabel, LMDCustomControl, LMDCustomPanel,
LMDCustomBevelPanel, LMDSimplePanel, LMDEdit, LMDWndProcComponent,
lmdformA, LMDCustomComponent, LMDOneInstance,
JvComponent, JvTrayIcon, JvPlacemnt;
type
TForm1 =
class(TForm)
LMDSimplePanel1: TLMDSimplePanel;
LMDLabel1: TLMDLabel;
LMDSimplePanel2: TLMDSimplePanel;
LMDLabel2: TLMDLabel;
LMDLabel3: TLMDLabel;
LMDLabel4: TLMDLabel;
meBetrag: TLMDMaskEdit;
meProzHS: TLMDMaskEdit;
meProzRS: TLMDMaskEdit;
meProzGym: TLMDMaskEdit;
LMDLabel5: TLMDLabel;
meBetragHS: TLMDEdit;
meBetragRS: TLMDEdit;
meBetragGym: TLMDEdit;
LMDOneInstance1: TLMDOneInstance;
JvFormPlacement1: TJvFormPlacement;
Procedure Calculate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private
sIniFileName :
string;
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var IniFile : TIniFile;
begin
sIniFileName := ExtractFileDir(Application.ExeName)+'
/Kostensplitter.ini';
IniFile := TIniFile.Create(sIniFileName);
meBetrag.Text := IniFile.ReadString('
APPLICATION','
BETRAG', '
0');
meProzHS.Text := IniFile.ReadString('
APPLICATION','
PROZHS', '
15,00');
meProzRS.Text := IniFile.ReadString('
APPLICATION','
PROZRS', '
40,00');
meProzGym.Text := IniFile.ReadString('
APPLICATION','
PROZGYM', '
45,00');
IniFile.Free;
Calculate(Sender);
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
var IniFile : TIniFile;
begin
IniFile := TIniFile.Create(sIniFileName);
IniFile.WriteString('
APPLICATION','
BETRAG', meBetrag.Text);
IniFile.WriteString('
APPLICATION','
PROZHS', meProzHS.Text);
IniFile.WriteString('
APPLICATION','
PROZRS', meProzRS.Text);
IniFile.WriteString('
APPLICATION','
PROZGYM', meProzGym.Text);
IniFile.Free;
end;
Procedure TForm1.Calculate(Sender: TObject);
var Betrag, BetragHS, BetragRS, BetragGym, ProzHS, ProzRS, ProzGym, Diff: Double;
begin
Betrag := StrToFloat(meBetrag.Text);
ProzHS := StrToFloat(meProzHS.Text);
ProzRS := StrToFloat(meProzRS.Text);
ProzGym := 100 - ProzHS - ProzRS;
BetragHS := RoundTo(Betrag * (ProzHS / 100),-2);
BetragRS := RoundTo(Betrag * (ProzRS / 100),-2);
BetragGym := RoundTo(Betrag * (ProzGym / 100),-2);
Diff := Betrag - (BetragHS + BetragRS + BetragGym);
BetragGym := BetragGym + Diff;
meProzGym.Text := FloatToStrF(ProzGym,ffFixed,6,2);
meBetragHS.Text := FloatToStrF(BetragHS,ffCurrency,12,2);
meBetragRS.Text := FloatToStrF(BetragRS,ffCurrency,12,2);
meBetragGym.Text := FloatToStrF(BetragGym,ffCurrency,12,2);
end;
end.