text stringlengths 14 6.51M |
|---|
unit PrintRec;
{ =================================================================
Chart - Printer page/font setup form for printing signal records
2/5/97 ... Calibration bar values only shown for enabled channels
26/6/98 ... Text boxes updates now grouped together in UpdateSettings
30/8/99 ... Display object (Scope or Chart) now updated by PrintRec
18/5/03 ... Copied from WinWCP
7/10/03 ... Zero channel calibration now substituted with default value
4/11/03 ... Printer name now discovered using Printer.GetPrinter
4/09/04 ... Channels can be selected for display individually
24/7/13 ... GetCurrentPrinterName now compiles under V7 and XE2/3
02.07.18... calibration table resized to display all text
03.07.18 ... MainFrm.ADCNumChannels,MainFrm.ADCChannelName,MainFrm.ADCChannelUnits,MainFrm.ADCChannelScale
now used instead of MainFrm.SESLabio. equivalents so that correct number of channels, names and units
now used. Set to 10% button now works correctly.
=================================================================}
interface
uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, Buttons,
StdCtrls, ExtCtrls,Printers, Shared, Grids, SysUtils, Spin,
ValEdit, ScopeDisplay, ChartDisplay, ValidatedEdit ;
type
TDestination = (dePrinter,deClipboard) ;
TPrintRecFrm = class(TForm)
GroupBox2: TGroupBox;
CalibrationBarTable: TStringGrid;
GroupBox5: TGroupBox;
ckShowZeroLevels: TCheckBox;
ckShowLabels: TCheckBox;
bPrint: TButton;
bCancel: TButton;
ckUseColor: TCheckBox;
FontGrp: TGroupBox;
Label7: TLabel;
cbFontName: TComboBox;
Page: TNotebook;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
GroupBox4: TGroupBox;
Label6: TLabel;
Label8: TLabel;
edWidth: TValidatedEdit;
edHeight: TValidatedEdit;
edLeftMargin: TValidatedEdit;
edTopMargin: TValidatedEdit;
edRightMargin: TValidatedEdit;
edBottomMargin: TValidatedEdit;
edFontSize: TValidatedEdit;
Label5: TLabel;
edLineThickness: TValidatedEdit;
bDefaultSettings: TButton;
GroupBox3: TGroupBox;
rbDisplayWindow: TRadioButton;
rbWholeFile: TRadioButton;
GroupBox6: TGroupBox;
bPrinterSetup: TButton;
edPrinterName: TEdit;
GroupBox7: TGroupBox;
ckShowChan0: TCheckBox;
ckShowChan1: TCheckBox;
ckShowChan2: TCheckBox;
ckShowChan3: TCheckBox;
ckShowChan4: TCheckBox;
ckShowChan5: TCheckBox;
ckShowChan6: TCheckBox;
ckShowChan7: TCheckBox;
procedure bPrintClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure CalibrationBarTableKeyPress(Sender: TObject; var Key: Char);
procedure bDefaultSettingsClick(Sender: TObject);
procedure bPrinterSetupClick(Sender: TObject);
private
{ Private declarations }
procedure SetShowChannel(
ch : Integer ;
ckShowChan : TCheckbox
) ;
function GetCurrentPrinterName : string ;
public
{ Public declarations }
Destination : TDestination ;
DisplayObj : TObject ;
end;
var
PrintRecFrm: TPrintRecFrm;
implementation
{$R *.DFM}
uses Main ;
procedure TPrintRecFrm.FormShow(Sender: TObject);
{ --------------------------------
Initialise Print Record(s) form
-------------------------------}
var
n,ch,Row : Integer ;
begin
{ Select appropriate settings page }
if Destination = dePrinter then begin
Caption := ' Print ' ;
edPrinterName.Text := GetCurrentPrinterName ;
bPrinterSetup.Enabled := True ;
Page.PageIndex := 0 ;
edFontSize.Units := 'pts' ;
edLineThickness.Units := 'pts' ;
rbWholeFile.Enabled := True ;
end
else begin
Caption := ' Copy Image ' ;
edPrinterName.Text := 'Windows Clipboard' ;
bPrinterSetup.Enabled := False ;
Page.PageIndex := 1 ;
edFontSize.Units := 'pixels' ;
edLineThickness.Units := 'pixels' ;
rbWholeFile.Enabled := False ;
end ;
rbDisplayWindow.Checked := True ;
{ Fill Fonts list with typefaces available to printer }
cbFontName.items := printer.fonts ;
{ Set Column widths }
CalibrationBarTable.colwidths[0] := Canvas.TextWidth('XXXXXXXXXX') ;
CalibrationBarTable.colwidths[1] := Canvas.TextWidth('XXXXXXXXXXXXXXX') ;
CalibrationBarTable.options := [goEditing,goHorzLine,goVertLine] ;
CalibrationBarTable.RowCount := MainFrm.ADCNumChannels + 1 ;
CalibrationBarTable.cells[0,0] := 'Time ';
{ Adjust number of rows to number of enabled channels }
CalibrationBarTable.RowCount := MainFrm.ADCNumChannels + 1 ;
{ Update text box settings }
edLeftMargin.Value := MainFrm.Plot.LeftMargin ;
edRightMargin.Value := MainFrm.Plot.RightMargin ;
edTopMargin.Value := MainFrm.Plot.TopMargin ;
edBottomMargin.Value := MainFrm.Plot.BottomMargin ;
edWidth.Value := MainFrm.Plot.MetafileWidth ;
edHeight.Value := MainFrm.Plot.MetafileHeight ;
edFontSize.Value := MainFrm.Plot.FontSize ;
edLineThickness.Value := MainFrm.Plot.LineThickness ;
cbFontName.itemindex := cbFontName.items.indexof(MainFrm.Plot.FontName) ;
if cbFontName.itemindex < 0 then cbFontName.itemindex := 0 ;
if MainFrm.TimeBarValue <= 0.0 then begin
MainFrm.TimeBarValue := (TScopeDisplay(DisplayObj).xMax -
TScopeDisplay(DisplayObj).xMin)*
TScopeDisplay(DisplayObj).TScale*0.1 ;
end ;
CalibrationBarTable.cells[1,0] := Format( '%.4g %s',
[MainFrm.TimeBarValue,
MainFrm.TUnits]) ;
{ Channel calibration bars }
Row := 1 ;
for ch := 0 to MainFrm.ADCNumChannels-1 do begin
if MainFrm.ADCCalibrationBar[ch] <= 0.0 then
MainFrm.ADCCalibrationBar[ch] := (MainFrm.ADCChannelYMax[ch]
- MainFrm.ADCChannelYMax[ch])
*MainFrm.ADCChannelScale[ch]*0.1 ;
CalibrationBarTable.cells[0,Row] := MainFrm.ADCChannelName[ch];
CalibrationBarTable.cells[1,Row] := Format( '%.4g %s',
[MainFrm.ADCCalibrationBar[ch],
MainFrm.ADCChannelUnits[ch]]);
Inc(Row) ;
end ;
SetShowChannel( 0, ckShowChan0 ) ;
SetShowChannel( 1, ckShowChan1 ) ;
SetShowChannel( 2, ckShowChan2 ) ;
SetShowChannel( 3, ckShowChan3 ) ;
SetShowChannel( 4, ckShowChan4 ) ;
SetShowChannel( 5, ckShowChan5 ) ;
SetShowChannel( 6, ckShowChan6 ) ;
SetShowChannel( 7, ckShowChan7 ) ;
{ Ensure calibration bars have focus when dialog box opens }
CalibrationBarTable.SetFocus ;
end;
function TPrintRecFrm.GetCurrentPrinterName : string ;
const
MaxSize = 256 ;
var
n,ch,Row : Integer ;
DeviceName,DeviceDriver,Port : PChar ;
DeviceMode : THandle ;
begin
GetMem( DeviceName, MaxSize*SizeOf(Char) ) ;
GetMem( DeviceDriver, MaxSize*SizeOf(Char) ) ;
GetMem( Port, MaxSize*SizeOf(Char) ) ;
{$IF CompilerVersion > 7.0}
Printer.GetPrinter( DeviceName, DeviceDriver,Port,DeviceMode );
{$ELSE}
Printer.GetPrinter( DeviceName, DeviceDriver,Port, DeviceMode );
{$ENDIF}
Result := String(DeviceName) ;
FreeMem(DeviceName) ;
FreeMem(DeviceDriver) ;
FreeMem(Port) ;
end ;
procedure TPrintRecFrm.SetShowChannel(
ch : Integer ;
ckShowChan : TCheckbox
) ;
// ------------------------------------
// Initialise Channel display check box
// ------------------------------------
begin
if ch < MainFrm.ADCNumChannels then begin
ckShowChan.Visible := True ;
ckShowChan.Checked := True ;
ckShowChan.Caption := TScopeDisplay(DisplayObj).ChanName[ch] ;
end
else ckShowChan.Visible := False ;
end ;
procedure TPrintRecFrm.bPrintClick(Sender: TObject);
{ -----------------------
Update global settings
----------------------}
var
row,ch : Integer ;
NumVisible : Integer ;
begin
{ Update settings from text boxes }
MainFrm.Plot.LeftMargin := edLeftMargin.Value ;
MainFrm.Plot.RightMargin := edRightMargin.Value ;
MainFrm.Plot.TopMargin := edTopMargin.Value ;
MainFrm.Plot.BottomMargin := edBottomMargin.Value ;
MainFrm.Plot.MetafileWidth := Round(edWidth.Value) ;
MainFrm.Plot.MetafileHeight := Round(edHeight.Value) ;
MainFrm.Plot.FontSize := Round(edFontSize.Value) ;
MainFrm.Plot.LineThickness := Round(edLineThickness.Value) ;
MainFrm.Plot.FontName := cbFontName.text ;
MainFrm.Plot.WholeFile := rbWholeFile.Checked ;
{ Time calibration }
MainFrm.TimeBarValue := ExtractFloat(CalibrationBarTable.cells[1,0], 1. ) ;
{ Channel calibration bars }
Row := 1 ;
for ch := 0 to MainFrm.ADCNumChannels-1 do begin
MainFrm.ADCCalibrationBar[ch] := ExtractFloat(
CalibrationBarTable.Cells[1,Row],10. ) ;
Inc(Row) ;
end ;
{ Copy data into display object }
TScopeDisplay(DisplayObj).PrinterLeftMargin := Round(MainFrm.Plot.LeftMargin) ;
TScopeDisplay(DisplayObj).PrinterRightMargin := Round(MainFrm.Plot.RightMargin) ;
TScopeDisplay(DisplayObj).PrinterTopMargin := Round(MainFrm.Plot.TopMargin) ;
TScopeDisplay(DisplayObj).PrinterBottomMargin := Round(MainFrm.Plot.BottomMargin) ;
TScopeDisplay(DisplayObj).PrinterFontName := MainFrm.Plot.FontName ;
TScopeDisplay(DisplayObj).PrinterFontSize := MainFrm.Plot.FontSize ;
TScopeDisplay(DisplayObj).PrinterPenWidth := MainFrm.Plot.LineThickness ;
TScopeDisplay(DisplayObj).MetafileWidth := MainFrm.Plot.MetaFileWidth ;
TScopeDisplay(DisplayObj).MetafileHeight := MainFrm.Plot.MetaFileHeight ;
// Note these parameter settings are not preserved between calls to dialog box
TScopeDisplay(DisplayObj).PrinterShowZeroLevels := ckShowZeroLevels.Checked ;
TScopeDisplay(DisplayObj).PrinterShowLabels := ckShowLabels.Checked ;
TScopeDisplay(DisplayObj).PrinterDisableColor := not ckUseColor.Checked ; ;
for ch := 0 to TScopeDisplay(DisplayObj).NumChannels-1 do
TScopeDisplay(DisplayObj).ChanCalBar[ch] := MainFrm.ADCCalibrationBar[ch] ;
TScopeDisplay(DisplayObj).TCalBar := MainFrm.TimeBarValue /
TScopeDisplay(DisplayObj).TScale ;
TScopeDisplay(DisplayObj).ChanVisible[0] := ckShowChan0.Checked ;
TScopeDisplay(DisplayObj).ChanVisible[1] := ckShowChan1.Checked ;
TScopeDisplay(DisplayObj).ChanVisible[2] := ckShowChan2.Checked ;
TScopeDisplay(DisplayObj).ChanVisible[3] := ckShowChan3.Checked ;
TScopeDisplay(DisplayObj).ChanVisible[4] := ckShowChan4.Checked ;
TScopeDisplay(DisplayObj).ChanVisible[5] := ckShowChan5.Checked ;
TScopeDisplay(DisplayObj).ChanVisible[6] := ckShowChan6.Checked ;
TScopeDisplay(DisplayObj).ChanVisible[7] := ckShowChan7.Checked ;
// Ensure that at least one channel is visible
NumVisible := 0 ;
for ch := 0 to TScopeDisplay(DisplayObj).NumChannels-1 do
if TScopeDisplay(DisplayObj).ChanVisible[ch] then Inc(NumVisible) ;
if NumVisible = 0 then TScopeDisplay(DisplayObj).ChanVisible[0] := True ;
end ;
procedure TPrintRecFrm.CalibrationBarTableKeyPress(
Sender: TObject;
var Key: Char);
var
Value : single ;
ch,Row : Integer ;
begin
if key = chr(13) then begin
{ Time calibration bar }
Value := ExtractFloat( CalibrationBarTable.cells[1,0], 1. ) ;
CalibrationBarTable.cells[1,0] := Format( '%.4g %s',
[Value,MainFrm.TUnits]) ;
{ Channel calibration bars }
Row := 1 ;
for ch := 0 to MainFrm.ADCNumChannels-1 do begin
Value := ExtractFloat(CalibrationBarTable.Cells[1,Row],10. ) ;
CalibrationBarTable.cells[0,Row] := MainFrm.ADCChannelName[ch] ;
CalibrationBarTable.cells[1,Row] := Format( '%.4g %s',
[Value,MainFrm.ADCChannelUnits[ch]]) ;
Inc(Row) ;
end ;
end ;
end;
procedure TPrintRecFrm.bDefaultSettingsClick(Sender: TObject);
// ---------------------------------------------------------
// Set calibration values to default settings (10% of range)
// ---------------------------------------------------------
var
ch,Row : Integer ;
begin
MainFrm.TimeBarValue := (TScopeDisplay(DisplayObj).xMax -
TScopeDisplay(DisplayObj).xMin)*
TScopeDisplay(DisplayObj).TScale*0.1 ;
CalibrationBarTable.cells[1,0] := Format( '%.4g %s',
[MainFrm.TimeBarValue,
MainFrm.TUnits]) ;
Row := 1 ;
for ch := 0 to MainFrm.ADCNumChannels-1 do begin
MainFrm.ADCCalibrationBar[ch] := (MainFrm.ADCChannelYMax[ch]
- MainFrm.ADCChannelYMin[ch])
*MainFrm.ADCChannelScale[ch]*0.1 ;
CalibrationBarTable.cells[0,Row] := MainFrm.ADCChannelName[ch];
CalibrationBarTable.cells[1,Row] := Format( '%.4g %s',
[MainFrm.ADCCalibrationBar[ch],
MainFrm.ADCChannelUnits[ch]]);
Inc(Row) ;
end ;
end;
procedure TPrintRecFrm.bPrinterSetupClick(Sender: TObject);
// --------------------------------
// Display printer setup dialog box
// --------------------------------
begin
MainFrm.PrinterSetupDialog.Execute ;
edPrinterName.Text := GetCurrentPrinterName ;
end;
end.
|
{
Copyright (c) 2020, Isaque Pinheiro
All rights reserved.
GNU Lesser General Public License
Versão 3, 29 de junho de 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
A todos é permitido copiar e distribuir cópias deste documento de
licença, mas mudá-lo não é permitido.
Esta versão da GNU Lesser General Public License incorpora
os termos e condições da versão 3 da GNU General Public License
Licença, complementado pelas permissões adicionais listadas no
arquivo LICENSE na pasta principal.
}
{ @abstract(JSONBr Framework.)
@created(23 Nov 2020)
@author(Isaque Pinheiro <isaquepsp@gmail.com>)
@author(Telegram : @IsaquePinheiro)
}
unit jsonbr;
interface
uses
Generics.Collections,
jsonbr.builders;
type
TJSONBrObject = jsonbr.builders.TJSONBrObject;
TJSONBr = class
private
class var
FJSONObject: TJSONBrObject;
class procedure SetNotifyEventGetValue(const Value: TNotifyEventGetValue); static;
class procedure SetNotifyEventSetValue(const Value: TNotifyEventSetValue); static;
public
class constructor Create;
class destructor Destroy;
class function ObjectToJsonString(AObject: TObject;
AStoreClassName: Boolean = False): string;
class function ObjectListToJsonString(AObjectList: TObjectList<TObject>;
AStoreClassName: Boolean = False): string; overload;
class function ObjectListToJsonString<T: class, constructor>(AObjectList: TObjectList<T>;
AStoreClassName: Boolean = False): string; overload;
class function JsonToObject<T: class, constructor>(const AJson: string{;
AOptions: TJSONBrOptions = [joDateIsUTC, joDateFormatISO8601]}): T; overload;
class function JsonToObject<T: class>(AObject: T;
const AJson: string): Boolean; overload;
class function JsonToObjectList<T: class, constructor>(const AJson: string): TObjectList<T>;
class procedure JsonToObject(const AJson: string; AObject: TObject); overload;
//
class function BeginObject(const AValue: String = ''): TJSONBrObject;
class function BeginArray: TJSONBrObject;
// Events GetValue and SetValue
class property OnSetValue: TNotifyEventSetValue write SetNotifyEventSetValue;
class property OnGetValue: TNotifyEventGetValue write SetNotifyEventGetValue;
end;
implementation
{ TJSONBr }
class function TJSONBr.BeginArray: TJSONBrObject;
begin
Result := FJSONObject.BeginArray;
end;
class function TJSONBr.BeginObject(const AValue: String): TJSONBrObject;
begin
Result := FJSONObject.BeginObject(AValue);
end;
class constructor TJSONBr.Create;
begin
FJSONObject := TJSONBrObject.Create;
end;
class destructor TJSONBr.Destroy;
begin
FJSONObject.Free;
inherited;
end;
class procedure TJSONBr.SetNotifyEventGetValue(const Value: TNotifyEventGetValue);
begin
FJSONObject.OnGetValue := Value;
end;
class procedure TJSONBr.JsonToObject(const AJson: string; AObject: TObject);
begin
FJSONObject.JSONToObject(AObject, AJson);
end;
class function TJSONBr.JsonToObject<T>(AObject: T;
const AJson: string): Boolean;
begin
Result := FJSONObject.JSONToObject(TObject(AObject), AJson);
end;
class function TJSONBr.JsonToObject<T>(const AJson: string{;
AOptions: TJSONBrOptions}): T;
begin
Result := FJSONObject.JSONToObject<T>(AJson);
end;
class function TJSONBr.ObjectListToJsonString(AObjectList: TObjectList<TObject>;
AStoreClassName: Boolean): string;
var
LFor: Integer;
begin
Result := '[';
for LFor := 0 to AObjectList.Count -1 do
begin
Result := Result + ObjectToJsonString(AObjectList.Items[LFor], AStoreClassName);
if LFor < AObjectList.Count -1 then
Result := Result + ', ';
end;
Result := Result + ']';
end;
class function TJSONBr.ObjectListToJsonString<T>(AObjectList: TObjectList<T>;
AStoreClassName: Boolean): string;
var
LFor: Integer;
begin
Result := '[';
for LFor := 0 to AObjectList.Count -1 do
begin
Result := Result + ObjectToJsonString(T(AObjectList.Items[LFor]), AStoreClassName);
if LFor < AObjectList.Count -1 then
Result := Result + ', ';
end;
Result := Result + ']';
end;
class function TJSONBr.ObjectToJsonString(AObject: TObject;
AStoreClassName: Boolean): string;
begin
Result := FJSONObject.ObjectToJSON(AObject, AStoreClassName);
end;
class procedure TJSONBr.SetNotifyEventSetValue(const Value: TNotifyEventSetValue);
begin
FJSONObject.OnSetValue := Value;
end;
class function TJSONBr.JsonToObjectList<T>(const AJson: string): TObjectList<T>;
begin
Result := FJSONObject.JSONToObjectList<T>(AJson);
end;
end.
|
{ Subroutine STRING_TKPICK_S (TOKEN, TLIST, LEN, PICK)
*
* Find which token in TLIST matches the token in TOKEN. TOKEN is a variable length
* string. TLIST is a string of length LEN, containing a list of possible matches
* separated by one or more blanks. The token in TOKEN may be abbreviated as long
* as it still results in a unique match from TLIST. PICK is returned as the token
* number in TLIST that matched. The first token is number 1. PICK is returned
* as 0 if there was no match at all, and -1 if there were multiple matches.
}
module string_tkpick_s;
define string_tkpick_s;
%include 'string2.ins.pas';
procedure string_tkpick_s ( {pick legal abbrev from any length token list}
in token: univ string_var_arg_t; {to try to pick from list}
in tlist: univ string; {list of valid tokens separated by blanks}
in len: string_index_t; {number of chars in TLIST}
out pick: sys_int_machine_t); {token number 1-N, 0=none, -1=not unique}
val_param;
var
tnum: sys_int_machine_t; {number of current token from TLIST}
p: string_index_t; {TLIST index to fetch next char from}
i: sys_int_machine_t; {loop counter}
label
next_token, finish_token;
begin
pick := 0; {init to no match found}
tnum := 0; {init current TLIST token number}
p := 0; {init TLIST parse pointer}
next_token: {jump here to find start of next TLIST token}
p := p+1; {point to next char in TLIST}
if p > len then return; {got to end of token list ?}
if tlist[p] = ' ' then goto next_token; {just pointing to delimiter ?}
tnum := tnum+1; {make new current token number}
if token.len > (len-p+1) then return; {can't possibly match rest of TLIST ?}
for i := 1 to token.len do begin {once for each character in TOKEN}
if token.str[i] = tlist[p] then begin {this character still matches ?}
p := p+1; {advance to next TLIST char}
next; {back and compare at this char}
end;
goto finish_token; {didn't match, go on to next token}
end; {back and compare next chars in token}
if (p > len) or (tlist[p] = ' ') {exact or abbreviated match ?}
then begin {tokens matched exactly}
pick := tnum; {pass back number of this token}
return; {we have exact match, stop looking}
end
else begin {matched if TOKEN is only an abbreviation}
if pick = 0 {is this the first abbreviated match or not}
then pick := tnum {this is only match so far}
else pick := -1; {indicate multiple matches}
end
;
finish_token: {jump here to skip to end of current token}
if tlist[p] = ' ' then goto next_token; {found delimiter before next token ?}
p := p+1; {point to next TLIST character}
if p > len then return; {got to end of token list ?}
goto finish_token; {back and look for delimiter before new token}
end;
|
unit CatDCP;
{
Catarinka - Quick AES string encryption/decryption functions
Copyright (c) 2003-2014 Felipe Daragon
License: 3-clause BSD
See https://github.com/felipedaragon/catarinka/ for details
}
interface
function StrToAES(const s, key: string; Unicode: boolean = true): string;
function AESToStr(const s, key: string; Unicode: boolean = true): string;
implementation
uses
DCPrijndael, DCPsha512;
function StrToAES(const s, key: string; Unicode: boolean = true): string;
var
Cipher: TDCP_rijndael;
begin
Cipher := TDCP_rijndael.Create(nil);
if Unicode then
begin
Cipher.InitStr(key, TDCP_sha512);
result := string(Cipher.EncryptString(s));
end
else
begin // force ANSI
Cipher.InitStr(ansistring(key), TDCP_sha512);
result := string(Cipher.EncryptString(ansistring(s)));
end;
Cipher.Burn;
Cipher.Free;
end;
function AESToStr(const s, key: string; Unicode: boolean = true): string;
var
Cipher: TDCP_rijndael;
begin
Cipher := TDCP_rijndael.Create(nil);
if Unicode then
begin
Cipher.InitStr(key, TDCP_sha512);
result := string(Cipher.DecryptString(s));
end
else
begin // force ANSI
Cipher.InitStr(ansistring(key), TDCP_sha512);
result := string(Cipher.DecryptString(ansistring(s)));
end;
Cipher.Burn;
Cipher.Free;
end;
// ------------------------------------------------------------------------//
end.
|
unit RDTPSQLConnection;
{GEN}
{TYPE CLIENT}
{CLASS TRDTPSQLConnectionClient}
{IMPLIB RDTPSQLConnectionClienttImplib}
{TEMPLATE RDTP_gen_client_template.pas}
{RQFILE RDTPSQLConnectionRQs.txt}
{END}
interface
uses
StorageEngineTypes, RDTPProcessorForMySQL, packet, betterobject, systemx, genericRDTPClient, variants, packethelpers, debug, typex, exceptions;
type
TRDTPSQLConnectionClient = class(TGenericRDTPClient)
public
procedure Init;override;
destructor Destroy;override;
function Test():integer;overload;virtual;
procedure Test_Async();overload;virtual;
function Test_Response():integer;
function WriteQuery(sQuery:string):boolean;overload;virtual;
procedure WriteQuery_Async(sQuery:string);overload;virtual;
function WriteQuery_Response():boolean;
function ReadyToWriteBehind():boolean;overload;virtual;
procedure ReadyToWriteBehind_Async();overload;virtual;
function ReadyToWriteBehind_Response():boolean;
procedure WriteBehind(sQuery:string);overload;virtual;
procedure WriteBehind_Async(sQuery:string);overload;virtual;
function ReadQuery(sQuery:string):TSERowSet;overload;virtual;
procedure ReadQuery_Async(sQuery:string);overload;virtual;
function ReadQuery_Response():TSERowSet;
function DispatchCallback: boolean;override;
end;
procedure LocalDebug(s: string; sFilter: string = '');
implementation
uses
sysutils;
procedure LocalDebug(s: string; sFilter: string = '');
begin
Debug.Log(nil, s, sFilter);
end;
{ TRDTPSQLConnectionClient }
destructor TRDTPSQLConnectionClient.destroy;
begin
inherited;
end;
//------------------------------------------------------------------------------
function TRDTPSQLConnectionClient.Test():integer;
var
packet: TRDTPPacket;
begin
if not connect then
raise ETransportError.create('Failed to connect');
packet := NeedPacket;
try try
packet.AddVariant($1110);
packet.AddVariant(0);
packet.AddString('RDTPSQLConnection');
if not Transact(packet) then raise ECritical.create('transaction failure');
if not packet.result then raise ECritical.create('server error: '+packet.message);
packet.SeqSeek(PACKET_INDEX_RESULT_DETAILS);
GetintegerFromPacket(packet, result);
except
on E:Exception do begin
e.message := 'RDTP Call Failed:'+e.message;
raise;
end;
end;
finally
packet.free;
end;
end;
//------------------------------------------------------------------------------
procedure TRDTPSQLConnectionClient.Test_Async();
var
packet,outpacket: TRDTPPacket;
begin
if not connect then
raise ETransportError.create('Failed to connect');
packet := NeedPacket;
try
packet.AddVariant($1110);
packet.AddVariant(0);
packet.AddString('RDTPSQLConnection');
BeginTransact2(packet, outpacket,nil, false);
except
on E:Exception do begin
e.message := 'RDTP Call Failed:'+e.message;
raise;
end;
end;
end;
//------------------------------------------------------------------------------
function TRDTPSQLConnectionClient.Test_Response():integer;
var
packet: TRDTPPacket;
begin
packet := nil;
try
if not EndTransact2(packet, packet,nil, false) then raise ECritical.create('Transaction Failure');
if not packet.result then raise ECritical.create('server error: '+packet.message);
packet.SeqSeek(PACKET_INDEX_RESULT_DETAILS);
//packet.SeqRead;//read off the service name and forget it (it is already known)
GetintegerFromPacket(packet, result);
finally
packet.free;
end;
end;
//------------------------------------------------------------------------------
function TRDTPSQLConnectionClient.WriteQuery(sQuery:string):boolean;
var
packet: TRDTPPacket;
begin
if not connect then
raise ETransportError.create('Failed to connect');
packet := NeedPacket;
try try
packet.AddVariant($1111);
packet.AddVariant(0);
packet.AddString('RDTPSQLConnection');
WritestringToPacket(packet, sQuery);
if not Transact(packet) then raise ECritical.create('transaction failure');
if not packet.result then raise ECritical.create('server error: '+packet.message);
packet.SeqSeek(PACKET_INDEX_RESULT_DETAILS);
GetbooleanFromPacket(packet, result);
except
on E:Exception do begin
e.message := 'RDTP Call Failed:'+e.message;
raise;
end;
end;
finally
packet.free;
end;
end;
//------------------------------------------------------------------------------
procedure TRDTPSQLConnectionClient.WriteQuery_Async(sQuery:string);
var
packet,outpacket: TRDTPPacket;
begin
if not connect then
raise ETransportError.create('Failed to connect');
packet := NeedPacket;
try
packet.AddVariant($1111);
packet.AddVariant(0);
packet.AddString('RDTPSQLConnection');
WritestringToPacket(packet, sQuery);
BeginTransact2(packet, outpacket,nil, false);
except
on E:Exception do begin
e.message := 'RDTP Call Failed:'+e.message;
raise;
end;
end;
end;
//------------------------------------------------------------------------------
function TRDTPSQLConnectionClient.WriteQuery_Response():boolean;
var
packet: TRDTPPacket;
begin
packet := nil;
try
if not EndTransact2(packet, packet,nil, false) then raise ECritical.create('Transaction Failure');
if not packet.result then raise ECritical.create('server error: '+packet.message);
packet.SeqSeek(PACKET_INDEX_RESULT_DETAILS);
//packet.SeqRead;//read off the service name and forget it (it is already known)
GetbooleanFromPacket(packet, result);
finally
packet.free;
end;
end;
//------------------------------------------------------------------------------
function TRDTPSQLConnectionClient.ReadyToWriteBehind():boolean;
var
packet: TRDTPPacket;
begin
if not connect then
raise ETransportError.create('Failed to connect');
packet := NeedPacket;
try try
packet.AddVariant($1112);
packet.AddVariant(0);
packet.AddString('RDTPSQLConnection');
if not Transact(packet) then raise ECritical.create('transaction failure');
if not packet.result then raise ECritical.create('server error: '+packet.message);
packet.SeqSeek(PACKET_INDEX_RESULT_DETAILS);
GetbooleanFromPacket(packet, result);
except
on E:Exception do begin
e.message := 'RDTP Call Failed:'+e.message;
raise;
end;
end;
finally
packet.free;
end;
end;
//------------------------------------------------------------------------------
procedure TRDTPSQLConnectionClient.ReadyToWriteBehind_Async();
var
packet,outpacket: TRDTPPacket;
begin
if not connect then
raise ETransportError.create('Failed to connect');
packet := NeedPacket;
try
packet.AddVariant($1112);
packet.AddVariant(0);
packet.AddString('RDTPSQLConnection');
BeginTransact2(packet, outpacket,nil, false);
except
on E:Exception do begin
e.message := 'RDTP Call Failed:'+e.message;
raise;
end;
end;
end;
//------------------------------------------------------------------------------
function TRDTPSQLConnectionClient.ReadyToWriteBehind_Response():boolean;
var
packet: TRDTPPacket;
begin
packet := nil;
try
if not EndTransact2(packet, packet,nil, false) then raise ECritical.create('Transaction Failure');
if not packet.result then raise ECritical.create('server error: '+packet.message);
packet.SeqSeek(PACKET_INDEX_RESULT_DETAILS);
//packet.SeqRead;//read off the service name and forget it (it is already known)
GetbooleanFromPacket(packet, result);
finally
packet.free;
end;
end;
//------------------------------------------------------------------------------
procedure TRDTPSQLConnectionClient.WriteBehind(sQuery:string);
var
packet: TRDTPPacket;
begin
if not connect then
raise ETransportError.create('Failed to connect');
packet := NeedPacket;
try try
packet.AddVariant($1113);
packet.AddVariant(0);
packet.AddString('RDTPSQLConnection');
WritestringToPacket(packet, sQuery);
if not Transact(packet, true) then raise ECritical.create('transaction failure');
except
on E:Exception do begin
e.message := 'RDTP Call Failed:'+e.message;
raise;
end;
end;
finally
packet.free;
end;
end;
//------------------------------------------------------------------------------
procedure TRDTPSQLConnectionClient.WriteBehind_Async(sQuery:string);
var
packet,outpacket: TRDTPPacket;
begin
if not connect then
raise ETransportError.create('Failed to connect');
packet := NeedPacket;
try
packet.AddVariant($1113);
packet.AddVariant(0);
packet.AddString('RDTPSQLConnection');
WritestringToPacket(packet, sQuery);
BeginTransact2(packet, outpacket,nil, true);
except
on E:Exception do begin
e.message := 'RDTP Call Failed:'+e.message;
raise;
end;
end;
end;
//------------------------------------------------------------------------------
function TRDTPSQLConnectionClient.ReadQuery(sQuery:string):TSERowSet;
var
packet: TRDTPPacket;
begin
if not connect then
raise ETransportError.create('Failed to connect');
packet := NeedPacket;
try try
packet.AddVariant($1114);
packet.AddVariant(0);
packet.AddString('RDTPSQLConnection');
WritestringToPacket(packet, sQuery);
if not Transact(packet) then raise ECritical.create('transaction failure');
if not packet.result then raise ECritical.create('server error: '+packet.message);
packet.SeqSeek(PACKET_INDEX_RESULT_DETAILS);
GetTSERowSetFromPacket(packet, result);
except
on E:Exception do begin
e.message := 'RDTP Call Failed:'+e.message;
raise;
end;
end;
finally
packet.free;
end;
end;
//------------------------------------------------------------------------------
procedure TRDTPSQLConnectionClient.ReadQuery_Async(sQuery:string);
var
packet,outpacket: TRDTPPacket;
begin
if not connect then
raise ETransportError.create('Failed to connect');
packet := NeedPacket;
try
packet.AddVariant($1114);
packet.AddVariant(0);
packet.AddString('RDTPSQLConnection');
WritestringToPacket(packet, sQuery);
BeginTransact2(packet, outpacket,nil, false);
except
on E:Exception do begin
e.message := 'RDTP Call Failed:'+e.message;
raise;
end;
end;
end;
//------------------------------------------------------------------------------
function TRDTPSQLConnectionClient.ReadQuery_Response():TSERowSet;
var
packet: TRDTPPacket;
begin
packet := nil;
try
if not EndTransact2(packet, packet,nil, false) then raise ECritical.create('Transaction Failure');
if not packet.result then raise ECritical.create('server error: '+packet.message);
packet.SeqSeek(PACKET_INDEX_RESULT_DETAILS);
//packet.SeqRead;//read off the service name and forget it (it is already known)
GetTSERowSetFromPacket(packet, result);
finally
packet.free;
end;
end;
function TRDTPSQLConnectionClient.DispatchCallback: boolean;
var
iRQ: integer;
begin
result := false;
iRQ := callback.request.data[0];
callback.request.seqseek(3);
case iRQ of
0: begin
//beeper.Beep(100,100);
result := true;
end;
end;
if not result then
result := Inherited DispatchCallback;
end;
procedure TRDTPSQLConnectionClient.Init;
begin
inherited;
ServiceName := 'RDTPSQLConnection';
end;
end.
|
unit Main;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, Vcl.StdCtrls, Vcl.ExtCtrls,
Vcl.Samples.Spin;
type
TMainFrm = class(TForm)
StatusBar: TStatusBar;
PaintBox: TPaintBox;
Timer: TTimer;
procedure FormCreate(Sender: TObject);
procedure VersionBtnClick(Sender: TObject);
procedure TimerTimer(Sender: TObject);
private
Bmp : TBitmap;
procedure UpdateMulti;
procedure UpdateNormal;
public
end;
var
MainFrm: TMainFrm;
implementation
{$R *.dfm}
uses
Kinect2DLL, Kinect2U, BmpUtils;
procedure TMainFrm.FormCreate(Sender: TObject);
begin
// Left:=-2880;
ClientWidth:=COLOR_W;
ClientHeight:=COLOR_H+StatusBar.Height;
PaintBox.Width:=COLOR_W;
PaintBox.Height:=COLOR_H;
Bmp:=CreateBmpForPaintBox(PaintBox);
Bmp.PixelFormat:=pf32Bit;
Kinect2:=TKinect2.Create;
if FileExists(FullDLLName) then begin
Kinect2.StartUp;
if Kinect2.DllLoaded then begin
StatusBar.Panels[0].Text:='Library version #'+Kinect2.DLLVersion+' loaded';
if Kinect2.AbleToStartColorStream then begin
if Kinect2.AbleToStartBodyStream then begin
StatusBar.Panels[1].Text:='Kinect ready';
Timer.Enabled:=True;
end;
end
else StatusBar.Panels[1].Text:='Kinect not ready';
end
else StatusBar.Panels[0].Text:='Library not loaded';
end
else StatusBar.Panels[0].Text:=FullDLLName+' not found';
end;
procedure TMainFrm.UpdateMulti;
begin
if Kinect2.AbleToUpdateMultiFrame then begin
Kinect2.DrawColorBmp(Bmp);
Kinect2.DrawBodies(Bmp);
ShowFrameRateOnBmp(Bmp,Kinect2.MeasuredFPS);
PaintBox.Canvas.Draw(0,0,Bmp);
end;
Kinect2.DoneMultiFrame;
end;
procedure TMainFrm.UpdateNormal;
begin
//Kinect2.UpdateBody;
if Kinect2.AbleToUpdateBody then begin
// Kinect2.SyncBodyData;
end;
if Kinect2.AbleToGetColorFrame then begin
Kinect2.DrawColorBmp(Bmp);
Kinect2.DrawBodies(Bmp);
ShowFrameRateOnBmp(Bmp,Kinect2.MeasuredFPS);
PaintBox.Canvas.Draw(0,0,Bmp);
end;
Kinect2.DoneColor;
end;
procedure TMainFrm.TimerTimer(Sender: TObject);
begin
UpdateNormal;
end;
procedure TMainFrm.VersionBtnClick(Sender: TObject);
begin
Caption:=KinectVersionString;
end;
end.
|
{
This file is part of the SimpleBOT package.
(c) Luri Darmawan <luri@fastplaz.com>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
}
unit portalpulsa_integration;
{$mode objfpc}{$H+}
interface
uses
common, http_lib, fpjson, logutil_lib, fphttpclient,
Classes, SysUtils;
type
{ TPortalPulsaIntegration }
TPortalPulsaIntegration = class
private
FCode: string;
FDebug: boolean;
FInquiry: string;
FKey: string;
FMessage: string;
FNumber: integer;
FPhoneNumber: string;
FResultCode: integer;
FResultText: string;
FSecret: string;
FTransactionID: string;
FUserID: string;
jsonData: TJSONData;
function canAccess: boolean;
function getSaldo: double;
function customPost: boolean;
function getPrefix(APhoneNumber: string): string;
public
constructor Create;
destructor Destroy; override;
function IsiPulsa(APhoneNumber: string; AValue: string): boolean;
function Status(ATransactionID: string): boolean;
published
property Debug: boolean read FDebug write FDebug;
property UserID: string read FUserID write FUserID;
property Key: string read FKey write FKey;
property Secret: string read FSecret write FSecret;
property ResultCode: integer read FResultCode;
property ResultText: string read FResultText;
property Message: string read FMessage;
property Inquiry: string read FInquiry write FInquiry;
property Code: string read FCode write FCode;
property PhoneNumber: string read FPhoneNumber write FPhoneNumber;
property TransactionID: string read FTransactionID write FTransactionID;
property Number: integer read FNumber write FNumber;
property Saldo: double read getSaldo;
end;
implementation
const
PORTALPULSA_API_URL = 'http://portalpulsa.com/api/connect/';
var
Response: IHTTPResponse;
{ TPortalPulsaIntegration }
function TPortalPulsaIntegration.canAccess: boolean;
begin
Result := False;
if (FUserID = '') or (FKey = '') or (FSecret = '') then
Exit;
Result := True;
end;
function TPortalPulsaIntegration.customPost: boolean;
var
params: TStringList;
http: TFPHTTPClient;
begin
Result := False;
if not canAccess then
Exit;
FMessage := '';
http := TFPHTTPClient.Create(nil);
params := TStringList.Create;
try
http.AddHeader('portal-userid', FUserID);
http.AddHeader('portal-key', FKey);
http.AddHeader('portal-secret', FSecret);
params.Values['inquiry'] := FInquiry;
params.Values['code'] := FCode;
params.Values['phone'] := FPhoneNumber;
params.Values['trxid_api'] := FTransactionID;
params.Values['no'] := i2s(FNumber);
FResultText := http.FormPost(PORTALPULSA_API_URL, params);
FResultCode := http.ResponseStatusCode;
if FResultCode = 200 then
begin
jsonData := GetJSON(FResultText);
FMessage := jsonGetData(jsonData, 'message');
Result := True;
end;
except
on E: Exception do
begin
if FDebug then
LogUtil.Add(E.Message, 'portalpulsa');
end;
end;
params.Free;
http.Free;
end;
function TPortalPulsaIntegration.getPrefix(APhoneNumber: string): string;
var
s: string;
begin
Result := '';
s := Copy(APhoneNumber, 0, 3);
if s = '089' then
Result := 'T';
s := Copy(APhoneNumber, 0, 4);
// Telkomsel
if StrInArray(s, ['0811', '0812', '0813', '0821', '0822', '0823', '0851', '0852', '0853']) then
Result := 'S';
// XL Axiata
if StrInArray(s, ['0817','0818','0819','0859','0877','0878']) then
Result := 'X';
// Indosat
if StrInArray(s, ['0855','0856','0857','0858','0814','0815','0816']) then
Result := 'I';
end;
constructor TPortalPulsaIntegration.Create;
begin
FDebug := False;
FInquiry := 'I';
FTransactionID := '';
FNumber := 1;
FMessage := '';
end;
destructor TPortalPulsaIntegration.Destroy;
begin
if Assigned(jsonData) then
jsonData.Free;
inherited Destroy;
end;
function TPortalPulsaIntegration.IsiPulsa(APhoneNumber: string;
AValue: string): boolean;
begin
Result := False;
FInquiry := 'I';
FCode := getPrefix(APhoneNumber) + AValue;
FPhoneNumber := APhoneNumber;
FNumber := 1;
if not customPost then
Exit;
if jsonGetData(jsonData, 'result') = 'success' then
begin
Result := True;
end;
end;
function TPortalPulsaIntegration.Status(ATransactionID: string): boolean;
begin
Result := False;
FInquiry := 'STATUS';
FTransactionID := ATransactionID;
if not customPost then
Exit;
if jsonGetData(jsonData, 'result') = 'success' then
begin
//todo: get status
FMessage := jsonGetData(jsonData, 'message/note');
Result := True;
end;
end;
function TPortalPulsaIntegration.getSaldo: double;
var
s: string;
begin
Result := 0;
if not canAccess then
Exit;
FInquiry := 'S';
if not customPost then
Exit;
if jsonGetData(jsonData, 'result') = 'success' then
begin
s := jsonGetData(jsonData, 'balance');
Result := s2f(s);
end;
end;
end.
|
unit DCPrc4;
{$MODE Delphi}
interface
uses
Classes, Sysutils, Crypto;
type
TCipherRC4= class(TCipher)
protected
KeyData, KeyOrg: array[0..255] of byte;
public
class function Algorithm: TCipherAlgorithm; override;
class function MaxKeySize: integer; override;
class function SelfTest: boolean; override;
procedure Init(const Key; Size: longword; InitVector: pointer); override;
procedure Reset; override;
procedure Burn; override;
procedure Encrypt(const InData; var OutData; Size: longword); override;
procedure Decrypt(const InData; var OutData; Size: longword); override;
end;
implementation
{$R-}{$Q-}
class function TCipherRC4.Algorithm: TCipherAlgorithm;
begin
Result:= caRC4;
end;
class function TCipherRC4.MaxKeySize: integer;
begin
Result:= 2048;
end;
class function TCipherRC4.SelfTest: boolean;
const
Key1: array[0..4] of byte= ($61,$8A,$63,$D2,$FB);
InData1: array[0..4] of byte= ($DC,$EE,$4C,$F9,$2C);
OutData1: array[0..4] of byte= ($F1,$38,$29,$C9,$DE);
var
Cipher: TCipherRC4;
Data: array[0..4] of byte;
begin
FillChar(Data, SizeOf(Data), 0);
Cipher:= TCipherRC4.Create;
Cipher.Init(Key1,Sizeof(Key1)*8,nil);
Cipher.Encrypt(InData1,Data,Sizeof(Data));
Result:= boolean(CompareMem(@Data,@OutData1,Sizeof(Data)));
Cipher.Reset;
Cipher.Decrypt(Data,Data,Sizeof(Data));
Result:= boolean(CompareMem(@Data,@InData1,Sizeof(Data))) and Result;
Cipher.Burn;
Cipher.Free;
end;
procedure TCipherRC4.Init(const Key; Size: longword; InitVector: pointer);
var
i, j, t: longword;
xKey: array[0..255] of byte;
begin
if fInitialized then
Burn;
inherited Init(Key,Size,nil);
Size:= Size div 8;
i:= 0;
while i< 255 do
begin
KeyData[i]:= i;
xKey[i]:= PByte(pointer(@Key)+(i mod Size))^;
KeyData[i+1]:= i+1;
xKey[i+1]:= PByte(pointer(@Key)+((i+1) mod Size))^;
KeyData[i+2]:= i+2;
xKey[i+2]:= PByte(pointer(@Key)+((i+2) mod Size))^;
KeyData[i+3]:= i+3;
xKey[i+3]:= PByte(pointer(@Key)+((i+3) mod Size))^;
KeyData[i+4]:= i+4;
xKey[i+4]:= PByte(pointer(@Key)+((i+4) mod Size))^;
KeyData[i+5]:= i+5;
xKey[i+5]:= PByte(pointer(@Key)+((i+5) mod Size))^;
KeyData[i+6]:= i+6;
xKey[i+6]:= PByte(pointer(@Key)+((i+6) mod Size))^;
KeyData[i+7]:= i+7;
xKey[i+7]:= PByte(pointer(@Key)+((i+7) mod Size))^;
Inc(i,8);
end;
j:= 0;
i:= 0;
while i< 255 do
begin
j:= (j+KeyData[i]+xKey[i]) and $FF;
t:= KeyData[i];
KeyData[i]:= KeyData[j];
KeyData[j]:= t;
j:= (j+KeyData[i+1]+xKey[i+1]) and $FF;
t:= KeyData[i+1];
KeyData[i+1]:= KeyData[j];
KeyData[j]:= t;
j:= (j+KeyData[i+2]+xKey[i+2]) and $FF;
t:= KeyData[i+2];
KeyData[i+2]:= KeyData[j];
KeyData[j]:= t;
j:= (j+KeyData[i+3]+xKey[i+3]) and $FF;
t:= KeyData[i+3];
KeyData[i+3]:= KeyData[j];
KeyData[j]:= t;
j:= (j+KeyData[i+4]+xKey[i+4]) and $FF;
t:= KeyData[i+4];
KeyData[i+4]:= KeyData[j];
KeyData[j]:= t;
j:= (j+KeyData[i+5]+xKey[i+5]) and $FF;
t:= KeyData[i+5];
KeyData[i+5]:= KeyData[j];
KeyData[j]:= t;
j:= (j+KeyData[i+6]+xKey[i+6]) and $FF;
t:= KeyData[i+6];
KeyData[i+6]:= KeyData[j];
KeyData[j]:= t;
j:= (j+KeyData[i+7]+xKey[i+7]) and $FF;
t:= KeyData[i+7];
KeyData[i+7]:= KeyData[j];
KeyData[j]:= t;
Inc(i,8);
end;
Move(KeyData,KeyOrg,Sizeof(KeyOrg));
end;
procedure TCipherRC4.Reset;
begin
Move(KeyOrg,KeyData,Sizeof(KeyData));
end;
procedure TCipherRC4.Burn;
begin
FillChar(KeyOrg,Sizeof(KeyOrg),$FF);
FillChar(KeyData,Sizeof(KeyData),$FF);
inherited Burn;
end;
procedure TCipherRC4.Encrypt(const InData; var OutData; Size: longword);
var
i, j, t, k: longword;
begin
if not fInitialized then
raise ECipher.Create('Cipher not initialized');
i:= 0; j:= 0;
for k:= 0 to Size-1 do
begin
i:= (i + 1) and $FF;
t:= KeyData[i];
j:= (j + t) and $FF;
KeyData[i]:= KeyData[j];
KeyData[j]:= t;
t:= (t + KeyData[i]) and $FF;
Pbytearray(@OutData)^[k]:= Pbytearray(@InData)^[k] xor KeyData[t];
end;
end;
procedure TCipherRC4.Decrypt(const InData; var OutData; Size: longword);
var
i, j, t, k: longword;
begin
if not fInitialized then
raise ECipher.Create('Cipher not initialized');
i:= 0; j:= 0;
for k:= 0 to Size-1 do
begin
i:= (i + 1) and $FF;
t:= KeyData[i];
j:= (j + t) and $FF;
KeyData[i]:= KeyData[j];
KeyData[j]:= t;
t:= (t + KeyData[i]) and $FF;
Pbytearray(@OutData)^[k]:= Pbytearray(@InData)^[k] xor KeyData[t];
end;
end;
end.
|
unit TextEditor.SpecialChars;
interface
uses
System.Classes, System.UITypes, TextEditor.SpecialChars.LineBreak, TextEditor.SpecialChars.Selection, TextEditor.Types;
type
TTextEditorSpecialChars = class(TPersistent)
strict private
FColor: TColor;
FLineBreak: TTextEditorSpecialCharsLineBreak;
FOnChange: TNotifyEvent;
FOptions: TTextEditorSpecialCharsOptions;
FSelection: TTextEditorSpecialCharsSelection;
FStyle: TTextEditorSpecialCharsStyle;
FVisible: Boolean;
procedure DoChange;
procedure SetColor(const AValue: TColor);
procedure SetLineBreak(const AValue: TTextEditorSpecialCharsLineBreak);
procedure SetOnChange(const AValue: TNotifyEvent);
procedure SetOptions(const AValue: TTextEditorSpecialCharsOptions);
procedure SetSelection(const AValue: TTextEditorSpecialCharsSelection);
procedure SetStyle(const AValue: TTextEditorSpecialCharsStyle);
procedure SetVisible(const AValue: Boolean);
public
constructor Create;
destructor Destroy; override;
procedure Assign(ASource: TPersistent); override;
procedure SetOption(const AOption: TTextEditorSpecialCharsOption; const AEnabled: Boolean);
property OnChange: TNotifyEvent read FOnChange write SetOnChange;
published
property Color: TColor read FColor write SetColor default TColors.Black;
property LineBreak: TTextEditorSpecialCharsLineBreak read FLineBreak write SetLineBreak;
property Options: TTextEditorSpecialCharsOptions read FOptions write SetOptions default [scoMiddleColor];
property Selection: TTextEditorSpecialCharsSelection read FSelection write SetSelection;
property Style: TTextEditorSpecialCharsStyle read FStyle write SetStyle default scsDot;
property Visible: Boolean read FVisible write SetVisible default False;
end;
implementation
constructor TTextEditorSpecialChars.Create;
begin
inherited;
FColor := TColors.Black;
FLineBreak := TTextEditorSpecialCharsLineBreak.Create;
FSelection := TTextEditorSpecialCharsSelection.Create;
FVisible := False;
FOptions := [scoMiddleColor];
FStyle := scsDot;
end;
destructor TTextEditorSpecialChars.Destroy;
begin
FLineBreak.Free;
FSelection.Free;
inherited Destroy;
end;
procedure TTextEditorSpecialChars.SetOnChange(const AValue: TNotifyEvent);
begin
FOnChange := AValue;
FLineBreak.OnChange := FOnChange;
FSelection.OnChange := FOnChange;
end;
procedure TTextEditorSpecialChars.Assign(ASource: TPersistent);
begin
if Assigned(ASource) and (ASource is TTextEditorSpecialChars) then
with ASource as TTextEditorSpecialChars do
begin
Self.FColor := FColor;
Self.FLineBreak.Assign(FLineBreak);
Self.FOptions := FOptions;
Self.FSelection.Assign(FSelection);
Self.FVisible := FVisible;
Self.DoChange;
end
else
inherited Assign(ASource);
end;
procedure TTextEditorSpecialChars.SetOption(const AOption: TTextEditorSpecialCharsOption; const AEnabled: Boolean);
begin
if AEnabled then
Include(FOptions, AOption)
else
Exclude(FOptions, AOption);
end;
procedure TTextEditorSpecialChars.DoChange;
begin
if Assigned(FOnChange) then
FOnChange(Self);
end;
procedure TTextEditorSpecialChars.SetColor(const AValue: TColor);
begin
if FColor <> AValue then
begin
FColor := AValue;
DoChange;
end;
end;
procedure TTextEditorSpecialChars.SetLineBreak(const AValue: TTextEditorSpecialCharsLineBreak);
begin
FLineBreak.Assign(AValue);
end;
procedure TTextEditorSpecialChars.SetSelection(const AValue: TTextEditorSpecialCharsSelection);
begin
FSelection.Assign(AValue);
end;
procedure TTextEditorSpecialChars.SetVisible(const AValue: Boolean);
begin
if FVisible <> AValue then
begin
FVisible := AValue;
DoChange;
end;
end;
procedure TTextEditorSpecialChars.SetStyle(const AValue: TTextEditorSpecialCharsStyle);
begin
if FStyle <> AValue then
begin
FStyle := AValue;
DoChange;
end;
end;
procedure TTextEditorSpecialChars.SetOptions(const AValue: TTextEditorSpecialCharsOptions);
var
LValue: TTextEditorSpecialCharsOptions;
begin
LValue := AValue;
if FOptions <> LValue then
begin
if scoTextColor in LValue then
Exclude(LValue, scoMiddleColor);
if scoMiddleColor in LValue then
Exclude(LValue, scoTextColor);
FOptions := LValue;
DoChange;
end;
end;
end.
|
{-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: JvWaitingProgress.PAS, released on 2001-02-28.
The Initial Developer of the Original Code is Sébastien Buysse [sbuysse att buypin dott com]
Portions created by Sébastien Buysse are Copyright (C) 2001 Sébastien Buysse.
All Rights Reserved.
Contributor(s): Michael Beck [mbeck att bigfoot dott com].
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.delphi-jedi.org
Known Issues:
-----------------------------------------------------------------------------}
// $Id: JvWaitingProgress.pas 13104 2011-09-07 06:50:43Z obones $
unit JvWaitingProgress;
{$I jvcl.inc}
interface
uses
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
SysUtils, Classes,
Messages, Graphics, Controls, Forms,
JvSpecialProgress, JvImageDrawThread, JvComponent;
const
WM_DELAYED_INTERNAL_ACTIVATE = WM_APP + 245;
WM_DELAYED_DO_ENDED = WM_APP + 246;
type
{$IFDEF RTL230_UP}
[ComponentPlatformsAttribute(pidWin32 or pidWin64)]
{$ENDIF RTL230_UP}
TJvWaitingProgress = class(TJvWinControl)
private
FActive: Boolean;
FRefreshInterval: Cardinal;
FLength: Cardinal;
FOnEnded: TNotifyEvent;
FWait: TJvImageDrawThread;
FProgress: TJvSpecialProgress;
FInOnScroll: Boolean;
function GetProgressColor: TColor;
procedure InternalActivate;
procedure SetActive(const Value: Boolean);
procedure SetLength(const Value: Cardinal);
procedure SetRefreshInterval(const Value: Cardinal);
procedure SetProgressColor(const Value: TColor);
procedure OnScroll(Sender: TObject);
procedure DoEnded;
//function GetBColor: TColor;
//procedure SetBColor(const Value: TColor);
protected
procedure BoundsChanged; override;
procedure ColorChanged; override;
procedure Loaded; override;
procedure WmDelayedInternalActivate(var Msg: TMessage); message WM_DELAYED_INTERNAL_ACTIVATE;
procedure WmDelayedDoEnded(var Msg: TMessage); message WM_DELAYED_DO_ENDED;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Active: Boolean read FActive write SetActive default False;
property Length: Cardinal read FLength write SetLength default 30000;
property RefreshInterval: Cardinal read FRefreshInterval write SetRefreshInterval default 500;
property ProgressColor: TColor read GetProgressColor write SetProgressColor default clBlack;
{(rb) no need to override Color property }
//property Color: TColor read GetBColor write SetBColor;
property Color;
property ParentColor;
property Height default 10;
property Width default 100;
property OnEnded: TNotifyEvent read FOnEnded write FOnEnded;
end;
{$IFDEF UNITVERSIONING}
const
UnitVersioning: TUnitVersionInfo = (
RCSfile: '$URL: https://jvcl.svn.sourceforge.net/svnroot/jvcl/branches/JVCL3_47_PREPARATION/run/JvWaitingProgress.pas $';
Revision: '$Revision: 13104 $';
Date: '$Date: 2011-09-07 08:50:43 +0200 (mer. 07 sept. 2011) $';
LogPath: 'JVCL\run'
);
{$ENDIF UNITVERSIONING}
implementation
uses
Windows;
constructor TJvWaitingProgress.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FActive := False;
FLength := 30000;
FRefreshInterval := 500;
// (rom) always set default values also
Height := 10;
Width := 100;
FWait := TJvImageDrawThread.Create(True);
FWait.FreeOnTerminate := False;
FWait.Delay := FRefreshInterval;
FWait.OnDraw := OnScroll;
FProgress := TJvSpecialProgress.Create(Self);
FProgress.Parent := Self;
FProgress.Maximum := FLength;
FProgress.Position := 0;
FProgress.StartColor := clBlack;
FProgress.EndColor := clBlack;
FProgress.Solid := True;
FProgress.Left := 0;
FProgress.Top := 0;
FProgress.Width := Width;
FProgress.Height := Height;
//inherited Color := FProgress.Color;
end;
destructor TJvWaitingProgress.Destroy;
begin
FWait.OnDraw := nil;
FWait.Terminate;
// FWait.WaitFor;
FreeAndNil(FWait);
FProgress.Free;
inherited Destroy;
end;
procedure TJvWaitingProgress.DoEnded;
begin
if Assigned(FOnEnded) then
FOnEnded(Self);
end;
procedure TJvWaitingProgress.Loaded;
begin
inherited Loaded;
if FActive then
InternalActivate;
end;
{function TJvWaitingProgress.GetBColor: TColor;
begin
Result := FProgress.Color;
end;}
function TJvWaitingProgress.GetProgressColor: TColor;
begin
Result := FProgress.StartColor;
end;
procedure TJvWaitingProgress.OnScroll(Sender: TObject);
begin
// Must exit because we are "Synchronized" and our parent is already
// partly destroyed. If we did not exit, we would get an AV.
if csDestroying in ComponentState then
Exit;
//Step
FInOnScroll := True;
try
if Integer(FProgress.Position) + Integer(FRefreshInterval) > Integer(FLength) then
begin
FProgress.Position := FLength;
SetActive(False);
PostMessage(Handle, WM_DELAYED_DO_ENDED, 0, 0);
end
else
FProgress.Position := FProgress.Position + Integer(FRefreshInterval);
finally
FInOnScroll := False;
end;
end;
procedure TJvWaitingProgress.InternalActivate;
begin
if FActive then
begin
FProgress.Position := 0;
FWait.Paused := False;
end
else
FWait.Paused := True;
end;
procedure TJvWaitingProgress.SetActive(const Value: Boolean);
begin
if FActive <> Value then
begin
FActive := Value;
if not (csLoading in ComponentState) then
if FInOnScroll then // OnScroll is "Synchronized", we must thus finish it before locking the thread
PostMessage(Handle, WM_DELAYED_INTERNAL_ACTIVATE, 0, 0)
else
InternalActivate;
end;
end;
{procedure TJvWaitingProgress.SetBColor(const Value: TColor);
begin
if FProgress.Color <> Value then
begin
FProgress.Color := Value;
inherited Color := Value;
end;
end;}
procedure TJvWaitingProgress.SetProgressColor(const Value: TColor);
begin
FProgress.StartColor := Value;
FProgress.EndColor := Value;
end;
procedure TJvWaitingProgress.SetLength(const Value: Cardinal);
begin
FLength := Value;
FProgress.Position := 0;
FProgress.Maximum := FLength;
end;
procedure TJvWaitingProgress.SetRefreshInterval(const Value: Cardinal);
begin
FRefreshInterval := Value;
FWait.Delay := FRefreshInterval;
end;
procedure TJvWaitingProgress.WmDelayedDoEnded(var Msg: TMessage);
begin
DoEnded;
end;
procedure TJvWaitingProgress.WmDelayedInternalActivate(var Msg: TMessage);
begin
InternalActivate;
end;
procedure TJvWaitingProgress.BoundsChanged;
begin
inherited BoundsChanged;
FProgress.Width := Width;
FProgress.Height := Height;
end;
procedure TJvWaitingProgress.ColorChanged;
begin
inherited ColorChanged;
FProgress.Color := Color;
end;
{$IFDEF UNITVERSIONING}
initialization
RegisterUnitVersion(HInstance, UnitVersioning);
finalization
UnregisterUnitVersion(HInstance);
{$ENDIF UNITVERSIONING}
end.
|
//*******************************************************
//
// Delphi DataSnap Framework
//
// Copyright(c) 1995-2012 Embarcadero Technologies, Inc.
//
//*******************************************************
unit DSRESTParameterMetaData;
interface
uses
SysUtils, Types, Classes, Variants, DSRestTypes;
type
TDSRESTParameterMetaData = class;
TDSRESTParameterMetaDataArray = array of TDSRESTParameterMetaData;
TDSRESTParameterMetaData = class
private
FName: String;
FDirection: TDSRESTParamDirection;
FDBXType: TDBXDataTypes;
FTypeName: string;
public
class procedure ReleaseArray(var aArr: TDSRESTParameterMetaDataArray);
class function CreateParam(Name: string; Direction: TDSRESTParamDirection;
DBXType: TDBXDataTypes; TypeName: String): TDSRESTParameterMetaData;
constructor Create(Name: string; Direction: TDSRESTParamDirection;
DBXType: TDBXDataTypes; TypeName: String); reintroduce; virtual;
property Direction: TDSRESTParamDirection read FDirection write FDirection;
property DBXType: TDBXDataTypes read FDBXType write FDBXType;
property TypeName: String read FTypeName write FTypeName;
end;
implementation
{ TDSRESTParameterMetaData }
constructor TDSRESTParameterMetaData.Create(Name: string;
Direction: TDSRESTParamDirection; DBXType: TDBXDataTypes; TypeName: String);
begin
inherited Create;
FName := Name;
FDirection := Direction;
FDBXType := DBXType;
FTypeName := TypeName;
end;
class function TDSRESTParameterMetaData.CreateParam(Name: string;
Direction: TDSRESTParamDirection; DBXType: TDBXDataTypes;
TypeName: String): TDSRESTParameterMetaData;
begin
Result := TDSRESTParameterMetaData.Create(Name, Direction, DBXType, TypeName);
end;
class procedure TDSRESTParameterMetaData.ReleaseArray
(var aArr: TDSRESTParameterMetaDataArray);
var
i: Integer;
begin
if Length(aArr) = 0 then
exit;
for i := 0 to Length(aArr) - 1 do
begin
aArr[i].Free;
aArr[i] := nil;
end;
SetLength(aArr, 0);
Finalize(aArr);
end;
end.
|
unit Model.Components.Connection.FireDac;
interface
uses FireDAC.Stan.Intf,
FireDAC.Stan.Option,
FireDAC.Stan.Error,
FireDAC.UI.Intf,
FireDAC.Phys.Intf,
FireDAC.Stan.Def,
FireDAC.Stan.Pool,
FireDAC.Stan.Async,
FireDAC.Phys,
FireDAC.Phys.MySQL,
FireDAC.Phys.MySQLDef,
FireDAC.VCLUI.Wait,
FireDAC.Stan.Param,
FireDAC.DatS,
FireDAC.DApt.Intf,
FireDAC.DApt,
FireDAC.Comp.DataSet,
FireDAC.Comp.Client,
FireDAC.Phys.FBDef,
FireDAC.Phys.IBBase,
FireDAC.Phys.FB,
FireDAC.FMXUI.Wait,
FireDAC.Comp.UI;
type
TModelComponentsConnectionFiredac = class
public
class function Connection:TFDConnection;
end;
implementation
Var FConnection :TFDConnection;
{ TModelComponentsConnectionFiredac }
class function TModelComponentsConnectionFiredac.Connection: TFDConnection;
begin
if not Assigned(FConnection) then
begin
FConnection := TFDConnection.Create(nil);
FConnection.Connected := False;
FConnection.Params.DriverID := 'FB';
FConnection.LoginPrompt := False;
FConnection.Params.Database := 'C:\Projetos\ERP\Banco\ERP.FDB';
FConnection.Params.UserName := 'SYSDBA';
FConnection.Params.Password := '';
FConnection.Connected := True;
end;
Result := FConnection;
end;
Initialization
Finalization;
if Assigned(FConnection) then
FConnection.Free;
end.
|
unit ClientesCadastro;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Buttons, StdCtrls, ORMUtils, ClientesORM;
const
tipoPessoa: array[0..1] of string = ('F','J');
type
TRetorno = (rtOk, rtCancel);
TFClientesCadastro = class(TForm)
lbClienteID: TLabel;
edClienteID: TEdit;
lbTipoPessoa: TLabel;
cbTipoPessoa: TComboBox;
lbCpfCnpj: TLabel;
edCpfCnpj: TEdit;
lbNome: TLabel;
edNome: TEdit;
lbCep: TLabel;
edCep: TEdit;
lbLogradouro: TLabel;
edLogradouro: TEdit;
lbNumero: TLabel;
edNumero: TEdit;
lbComplemento: TLabel;
edComplemento: TEdit;
lbReferencia: TLabel;
edReferencia: TEdit;
lbBairro: TLabel;
edBairro: TEdit;
lbCidade: TLabel;
edCidade: TEdit;
lbUf: TLabel;
edUf: TEdit;
lbCodigoIbge: TLabel;
edCodigoIbge: TEdit;
btnOk: TSpeedButton;
btnCancelar: TSpeedButton;
Panel1: TPanel;
btBuscaCep: TSpeedButton;
btFechar: TSpeedButton;
procedure FormCreate(Sender: TObject);
procedure btnOkClick(Sender: TObject);
procedure btnCancelarClick(Sender: TObject);
procedure DoKeyUpPadrao(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure edPrecoVendaKeyPress(Sender: TObject; var Key: Char);
procedure DoKeyPressOnlyNumber(Sender: TObject; var Key: Char);
procedure edCpfCnpjExit(Sender: TObject);
procedure edCepEnter(Sender: TObject);
procedure edCepExit(Sender: TObject);
procedure edCpfCnpjEnter(Sender: TObject);
procedure DoEnterPadrao(Sender: TObject);
procedure DoExitPadrao(Sender: TObject);
procedure btBuscaCepClick(Sender: TObject);
procedure btFecharClick(Sender: TObject);
private
{ Private declarations }
procedure Gravar;
procedure Cancelar;
procedure FormataCpfCnpj;
function ValidaCpfCnpj: Boolean;
function ChecaCamposObrigatorio: Boolean;
procedure ConfiguraObrigatorio;
public
{ Public declarations }
Acao: TAcao;
Cliente: TCliente;
Retorno: TRetorno;
procedure CarregaCadastro(ClienteID: Integer; Acao: TAcao);
procedure CarregaComponentes;
end;
var
FClientesCadastro: TFClientesCadastro;
function AbreCadastro(ClienteID: Integer; Acao: TAcao; out cliente: TCliente): Boolean;
implementation
uses StrUtils, MyStrUtils, DocumentosUtils, CepUtils, Constantes;
{$R *.dfm}
function AbreCadastro(clienteID: Integer; acao: TAcao; out cliente: TCliente): Boolean;
var clientesCadastro: TFClientesCadastro;
begin
Result := False;
clientesCadastro := TFClientesCadastro.Create(nil);
try
clientesCadastro.Acao := acao;
clientesCadastro.CarregaCadastro(clienteID, acao);
clientesCadastro.CarregaComponentes;
clientesCadastro.ShowModal;
if clientesCadastro.Retorno = rtOk then
begin
cliente := clientesCadastro.Cliente;
Result := True;
end;
finally
clientesCadastro.Free;
end;
end;
procedure TFClientesCadastro.ConfiguraObrigatorio;
begin
cbTipoPessoa.Color := corCampoObrigatorio;
edNome.Color := corCampoObrigatorio;
edCpfCnpj.Color := corCampoObrigatorio;
end;
procedure TFClientesCadastro.FormCreate(Sender: TObject);
begin
Retorno := rtCancel;
ConfiguraObrigatorio;
end;
procedure TFClientesCadastro.Cancelar;
begin
CarregaComponentes;
end;
procedure TFClientesCadastro.CarregaCadastro(ClienteID: Integer;
Acao: TAcao);
begin
Cliente := TCliente.Create(clienteID, acao)
end;
procedure TFClientesCadastro.CarregaComponentes;
begin
edClienteID.Text := IntToStr(Cliente.ClienteID);
cbTipoPessoa.ItemIndex := AnsiIndexStr(Cliente.TipoPessoa, tipoPessoa);
edCpfCnpj.Text := Cliente.CpfCnpj;
if (not IsEmpty(edCpfCnpj.Text)) then
FormataCpfCnpj;
edNome.Text := Cliente.Nome;
edCep.Text := FormataCep(Cliente.Cep);
edLogradouro.Text := Cliente.Logradouro;
edNumero.Text := Cliente.Numero;
edComplemento.Text := Cliente.Complemento;
edReferencia.Text := Cliente.Referencia;
edBairro.Text := Cliente.Bairro;
edCidade.Text := Cliente.Cidade;
edUf.Text := Cliente.Uf;
edCodigoIbge.Text := Cliente.CodigoIbge;
end;
function TFClientesCadastro.ChecaCamposObrigatorio: Boolean;
begin
Result := False;
if (cbTipoPessoa.ItemIndex = -1) then
raise exception.CreateFmt(exceptCampoNaoInformado,['Pessoa']);
if (IsEmpty(edCpfCnpj.Text)) then
raise exception.CreateFmt(exceptCampoNaoInformado,['CPF/CNPJ']);
if not ValidaCpfCnpj then
raise exception.create('O campo CPF/CNPJ é inválido!');
if (IsEmpty(edNome.Text)) then
raise exception.CreateFmt(exceptCampoNaoInformado,['Nome']);
Result := True;
end;
procedure TFClientesCadastro.Gravar;
begin
Cliente.TipoPessoa := tipoPessoa[cbTipoPessoa.ItemIndex];
Cliente.CpfCnpj := SomenteNumeros(edCpfCnpj.Text);
Cliente.Nome := edNome.Text;
Cliente.Cep := SomenteNumeros(edCep.Text);
Cliente.Logradouro := edLogradouro.Text;
Cliente.Numero := edNumero.Text;
Cliente.Complemento := edComplemento.Text;
Cliente.Referencia := edReferencia.Text;
Cliente.Bairro := edBairro.Text;
Cliente.Cidade := edCidade.Text;
Cliente.Uf := edUf.Text;
Cliente.CodigoIbge := edCodigoIbge.Text;
Cliente.Salvar;
end;
procedure TFClientesCadastro.btnOkClick(Sender: TObject);
begin
if not ChecaCamposObrigatorio then
Exit;
Gravar;
Retorno := rtOk;
end;
procedure TFClientesCadastro.btnCancelarClick(Sender: TObject);
begin
Cancelar;
end;
procedure TFClientesCadastro.DoKeyUpPadrao(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key = VK_RETURN) then
begin
Perform(CM_DIALOGKEY, VK_TAB, 0);
Key := 0;
end;
end;
procedure TFClientesCadastro.edPrecoVendaKeyPress(Sender: TObject;
var Key: Char);
begin
if not (Key in [#8, '0'..'9', '-', DecimalSeparator]) then
Key := #0
else if ((Key = DecimalSeparator) or (Key = '-')) and
(Pos(Key, (Sender as TEdit).Text) > 0)
then
Key := #0
else if (Key = '-') and ((Sender as TEdit).SelStart <> 0)
then
Key := #0;
end;
procedure TFClientesCadastro.DoKeyPressOnlyNumber(Sender: TObject;
var Key: Char);
const
CTRL_C = #3;
CTRL_V = #22;
BACK_SPACE = #8;
begin
if not (Key in [CTRL_C, CTRL_V]) then
begin
if not (Key in [BACK_SPACE, '0'..'9']) then
Key := #0;
end;
end;
procedure TFClientesCadastro.edCpfCnpjEnter(Sender: TObject);
begin
DoEnterPadrao(Sender);
edCpfCnpj.Text := SomenteNumeros(edCpfCnpj.Text);
end;
function TFClientesCadastro.ValidaCpfCnpj: Boolean;
const
tpFisica = 0;
var
cpfCnpj: String;
begin
Result := False;
cpfCnpj := SomenteNumeros(edCpfCnpj.Text);
if (cbTipoPessoa.ItemIndex = tpFisica) then
begin
if ValidaCpf(cpfCnpj) then
Result := True;
end
else
begin
if ValidaCnpj(cpfCnpj) then
Result := True;
end;
end;
procedure TFClientesCadastro.FormataCpfCnpj;
const
tpFisica = 0;
var
cpfCnpj: String;
begin
cpfCnpj := SomenteNumeros(edCpfCnpj.Text);
if (not IsEmpty(cpfCnpj)) then
begin
if (cbTipoPessoa.ItemIndex = tpFisica)
then edCpfCnpj.Text := FormataCpf(cpfCnpj)
else edCpfCnpj.Text := FormataCnpj(cpfCnpj);
end;
end;
procedure TFClientesCadastro.edCpfCnpjExit(Sender: TObject);
begin
DoExitPadrao(Sender);
if (not IsEmpty(edCpfCnpj.Text)) then
begin
FormataCpfCnpj;
if not ValidaCpfCnpj then
raise exception.create('CPF/CNPJ informado é inválida');
end;
end;
procedure TFClientesCadastro.edCepEnter(Sender: TObject);
begin
DoEnterPadrao(Sender);
edCep.Text := SomenteNumeros(edCep.Text);
end;
procedure TFClientesCadastro.edCepExit(Sender: TObject);
begin
DoExitPadrao(Sender);
edCep.Text := FormataCep(edCep.Text);
end;
procedure TFClientesCadastro.DoEnterPadrao(Sender: TObject);
begin
if Sender is TComboBox then
TComboBox(Sender).Font.Style := [fsBold];
if Sender is TEdit then
TEdit(Sender).Font.Style := [fsBold];
end;
procedure TFClientesCadastro.DoExitPadrao(Sender: TObject);
begin
if Sender is TComboBox then
TComboBox(Sender).Font.Style := [];
if Sender is TEdit then
TEdit(Sender).Font.Style := [];
end;
procedure TFClientesCadastro.btBuscaCepClick(Sender: TObject);
begin
if (IsEmpty(edCep.Text)) then
raise Exception.Create('Informe um CEP primeiro.');
try
with TEndereco.Create(edCep.Text) do
begin
edLogradouro.Text := Logradouro;
edBairro.Text := Bairro;
edCidade.Text := Cidade;
edUf.Text := Uf;
edCodigoIbge.Text := CodigoIbge;
end;
except
on e: exception do
raise exception.create(e.message)
end;
end;
procedure TFClientesCadastro.btFecharClick(Sender: TObject);
begin
Close;
end;
end.
|
unit uJustRightResponsibilities;
interface
type
IPrintable = interface
procedure Print(aString: string);
end;
TConsolePrinter = class(TInterfacedObject, IPrintable)
procedure Print(aString: string);
end;
IPageNumberSaver = interface
procedure Save(aPageNumber: integer);
end;
type
TBook = class
private
FCurrentPage: integer;
FTitle: string;
FAuthor: string;
procedure SetTitle(const Value: string);
procedure SetAuthor(const Value: string);
public
function TurnPage: integer;
procedure PrintCurrentPage(aPage: IPrintable);
procedure SavePageNumber(aPageNumberSaver: IPageNumberSaver);
property Title: string read FTitle write SetTitle;
property Author: string read FAuthor write SetAuthor;
end;
implementation
{ TBook }
procedure TBook.PrintCurrentPage(aPage: IPrintable);
begin
aPage.Print('Contents of current page');
end;
procedure TBook.SavePageNumber(aPageNumberSaver: IPageNumberSaver);
begin
aPageNumberSaver.Save(FCurrentPage);
end;
procedure TBook.SetAuthor(const Value: string);
begin
FAuthor := Value;
end;
procedure TBook.SetTitle(const Value: string);
begin
FTitle := Value;
end;
function TBook.TurnPage: integer;
begin
Inc(FCurrentPage);
Result := FCurrentPage;
end;
{ TConsolePrinter }
procedure TConsolePrinter.Print(aString: string);
begin
Writeln(aString);
end;
end.
|
unit mKinopoiskParser;
interface
uses
API_HTTP,
API_MVC,
eExtLink,
System.SysUtils;
type
TModelKPMovieParser = class(TModelAbstract)
private
FHTTP: THTTP;
public
inURL: string;
outGenreArr: TArray<string>;
outStoryline: string;
outTitle: string;
outTitleOrig: string;
outYear: Integer;
procedure Start; override;
end;
TModelKPSearchParser = class(TModelAbstract)
private
FCaptchaKey: string;
FHTTP: THTTP;
FRetpath: string;
function GetSearchResultArr(const aSearchString: string): TExtMovieSearchArr;
public
inAltSearchString: string;
inCookiesPath: string;
inPageNum: Integer;
inSearchString: string;
outCaptchaPicData: TBytes;
outSearchResultArr: TExtMovieSearchArr;
procedure PerformCaptchaReplay(const aCaptchaRep: string);
procedure Start; override;
end;
implementation
uses
API_Files,
API_Strings,
API_Types,
System.Classes;
procedure TModelKPSearchParser.PerformCaptchaReplay(const aCaptchaRep: string);
var
Page: string;
URL: string;
begin
FRetpath := FRetpath.Replace('%', '%25');
FRetpath := FRetpath.Replace(':', '%3A');
FRetpath := FRetpath.Replace('?', '%3F');
FRetpath := FRetpath.Replace('/', '%2F');
URL := Format('https://www.kinopoisk.ru/checkcaptcha?key=%s&retpath=%s&rep=%s', [
FCaptchaKey,
FRetpath,
aCaptchaRep
]);
Page := FHTTP.Get(URL);
end;
function TModelKPSearchParser.GetSearchResultArr(const aSearchString: string): TExtMovieSearchArr;
var
CaptchaLink: string;
CaptchaPicStream: TMemoryStream;
Page: string;
ItemBlock: string;
ItemBlockArr: TArray<string>;
SearchResult: TExtMovieSearchResult;
URL: string;
begin
Result := [];
URL := 'https://www.kinopoisk.ru/s/type/film/list/1/find/%s/';
URL := Format(URL, [aSearchString]);
Page := FHTTP.Get(URL);
//check captcha request
if Page.Contains('вашего IP-адреса поступило необычно много запросов') then
begin
CaptchaLink := TStrTool.CutByKey(Page, 'form__captcha" src="', '"');
CaptchaPicStream := FHTTP.GetStream(CaptchaLink);
try
outCaptchaPicData := TStreamEngine.GetBytes(CaptchaPicStream);
finally
CaptchaPicStream.Free;
end;
FCaptchaKey := TStrTool.CutByKey(Page, 'name="key" value="', '"');
FRetpath := TStrTool.CutByKey(Page, 'name="retpath" value="', '"');
SendMessage('OnCaptchaRequest', True);
end;
ItemBlockArr := TStrTool.CutArrayByKey(Page, 'div class="element"', 'div class="clear"');
for ItemBlock in ItemBlockArr do
begin
SearchResult.Title := TStrTool.CutByKey(ItemBlock, 'p class="name">', '</a>');
SearchResult.Title := TStrTool.HTMLToInnerText(SearchResult.Title);
SearchResult.TitleOrign := TStrTool.CutByKey(ItemBlock, 'class="gray">', '<');
SearchResult.TitleOrign := TStrTool.HTMLDecodeChars(SearchResult.TitleOrign);
SearchResult.Year := StrToIntDef(TStrTool.CutByKey(ItemBlock, 'class="year">', '<'), 0);
SearchResult.CoverLink := TStrTool.CutByKey(ItemBlock, 'title="/images/sm_film/', '"');
if SearchResult.CoverLink <> '' then
SearchResult.CoverLink := 'https://st.kp.yandex.net/images/sm_film/' + SearchResult.CoverLink;
SearchResult.Link := 'https://www.kinopoisk.ru' + TStrTool.CutByKey(ItemBlock, 'class="name"><a href="', '"');
SearchResult.ID := TStrTool.CutByKey(ItemBlock, 'data-id="', '"').ToInteger;
Result := Result + [SearchResult];
end;
end;
procedure TModelKPSearchParser.Start;
var
Page: string;
begin
FHTTP := THTTP.Create(True);
try
FHTTP.LoadCookies(inCookiesPath);
FHTTP.IdHTTP.Request.Host := 'www.kinopoisk.ru';
FHTTP.IdHTTP.Request.CacheControl := 'max-age=0';
FHTTP.IdHTTP.Request.Referer := 'https://www.kinopoisk.ru/';
FHTTP.SetHeaders('Upgrade-Insecure-Requests=1');
outSearchResultArr := GetSearchResultArr(inSearchString);
if not inAltSearchString.IsEmpty then
outSearchResultArr := outSearchResultArr + GetSearchResultArr(inAltSearchString);
finally
FHTTP.SaveCookies(inCookiesPath);
FHTTP.Free;
end;
end;
procedure TModelKPMovieParser.Start;
var
CaptchaLink: string;
CaptchaPicStream: TMemoryStream;
Page: string;
sGenres: string;
sYear: string;
begin
FHTTP := THTTP.Create(True);
try
Page := FHTTP.Get(inURL);
//check captcha request
{ if Page.Contains('вашего IP-адреса поступило необычно много запросов') then
begin
CaptchaLink := TStrTool.CutByKey(Page, 'form__captcha" src="', '"');
CaptchaPicStream := FHTTP.GetStream(CaptchaLink);
try
outCaptchaPicData := TStreamEngine.GetBytes(CaptchaPicStream);
finally
CaptchaPicStream.Free;
end;
FCaptchaKey := TStrTool.CutByKey(Page, 'name="key" value="', '"');
FRetpath := TStrTool.CutByKey(Page, 'name="retpath" value="', '"');
SendMessage('OnCaptchaRequest', True);
end; }
outTitle := TStrTool.CutByKey(Page, 'class="moviename-big" itemprop="name">', '<');
outTitleOrig := TStrTool.CutByKey(Page, 'itemprop="alternativeHeadline">', '<');
outTitleOrig := TStrTool.HTMLToInnerText(outTitleOrig);
sYear := TStrTool.CutByKey(Page, 'class="type">год', '</a>');
sYear := TStrTool.HTMLRemoveTags(sYear).Trim;
outYear := StrToIntDef(sYear, 0);
outStoryline := TStrTool.CutByKey(Page, 'itemprop="description">', '</div>');
outStoryline := TStrTool.HTMLToInnerText(outStoryline);
sGenres := TStrTool.CutByKey(Page, 'itemprop="genre">', '</span>');
outGenreArr := TStrTool.CutArrayByKey(sGenres, '">', '<');
finally
FHTTP.Free;
end;
end;
end.
|
program test_compoundparser;
{$APPTYPE CONSOLE}
{$IFDEF FPC}
{$linklib libxrl}
{$ENDIF}
{$mode objfpc}
{$h+}
uses xraylib, xrltest, Classes, SysUtils, fpcunit, testreport, testregistry;
type
TestCompoundParser = class(TTestCase)
private
procedure _test_bad_compound(compound: string);
published
procedure test_good_compounds;
procedure test_bad_compounds;
end;
type
TestSymbolToAtomicNumber = class(TTestCase)
private
procedure _test_bad_symbol;
published
procedure test_Fe;
procedure test_bad_symbol;
end;
type
TestAtomicNumberToSymbol = class(TTestCase)
private
procedure _test_bad_symbol1;
procedure _test_bad_symbol2;
published
procedure test_Fe;
procedure test_bad_symbol;
end;
type
TestCrossValidation = class(TTestCase)
published
procedure test;
end;
procedure TestCompoundParser.test_good_compounds;
begin
CompoundParser('C19H29COOH');
CompoundParser('C12H10');
CompoundParser('C12H6O2');
CompoundParser('C6H5Br');
CompoundParser('C3H4OH(COOH)3');
CompoundParser('HOCH2CH2OH');
CompoundParser('C5H11NO2');
CompoundParser('CH3CH(CH3)CH3');
CompoundParser('NH2CH(C4H5N2)COOH');
CompoundParser('H2O');
CompoundParser('Ca5(PO4)3F');
CompoundParser('Ca5(PO4)3OH');
CompoundParser('Ca5.522(PO4.48)3OH');
CompoundParser('Ca5.522(PO.448)3OH');
end;
procedure TestCompoundParser.test_bad_compounds;
begin
_test_bad_compound('0C');
_test_bad_compound('2O');
_test_bad_compound('13Li');
_test_bad_compound('2(NO3)');
_test_bad_compound('H(2)');
_test_bad_compound('Ba(12)');
_test_bad_compound('Cr(5)3');
_test_bad_compound('Pb(13)2');
_test_bad_compound('Au(22)11');
_test_bad_compound('Au11(H3PO4)2)');
_test_bad_compound('Au11(H3PO4))2');
_test_bad_compound('Au(11(H3PO4))2');
_test_bad_compound('Ca5.522(PO.44.8)3OH');
_test_bad_compound('Ba[12]');
_test_bad_compound('Auu1');
_test_bad_compound('AuL1');
_test_bad_compound(' ');
_test_bad_compound('\t');
_test_bad_compound('\n');
_test_bad_compound('Au L1');
_test_bad_compound('Au\tFe');
_test_bad_compound('CuI2ww');
end;
procedure TestCompoundParser._test_bad_compound(compound: string);
begin
try
CompoundParser(compound);
except
on E: EArgumentException do
begin
exit;
end;
end;
Fail('Expected exception was not raised for ' + compound);
end;
procedure TestSymbolToAtomicNumber.test_Fe;
begin
AssertEquals(SymbolToAtomicNumber('Fe'), 26);
end;
procedure TestSymbolToAtomicNumber._test_bad_symbol;
begin
SymbolToAtomicNumber('Uu');
end;
procedure TestSymbolToAtomicNumber.test_bad_symbol;
begin
AssertException(EArgumentException, @_test_bad_symbol);
end;
procedure TestAtomicNumberToSymbol.test_Fe;
begin
AssertEquals(AtomicNumberToSymbol(26), 'Fe');
end;
procedure TestAtomicNumberToSymbol._test_bad_symbol1;
begin
AtomicNumberToSymbol(-2);
end;
procedure TestAtomicNumberToSymbol._test_bad_symbol2;
begin
AtomicNumberToSymbol(108);
end;
procedure TestAtomicNumberToSymbol.test_bad_symbol;
begin
AssertException(EArgumentException, @_test_bad_symbol1);
AssertException(EArgumentException, @_test_bad_symbol2);
end;
procedure TestCrossValidation.test;
var
Z: integer;
begin
for Z := 1 to 107 do
begin
AssertEquals(SymbolToAtomicNumber(AtomicNumberToSymbol(Z)), Z);
end;
end;
var
App: TestRunner;
begin
RegisterTest(TestCompoundParser);
RegisterTest(TestSymbolToAtomicNumber);
RegisterTest(TestAtomicNumberToSymbol);
RegisterTest(TestCrossValidation);
App := TestRunner.Create(nil);
App.Initialize;
App.Run;
App.Free;
end.
|
unit uTradeClient;
interface
uses
Winapi.Windows, System.SysUtils, System.Classes,
System.Generics.Collections,
HPSocketSDKUnit,
uJsonClass,
uCommFuns,
uGlobal
;
type
TTradeClient = class
private
FAppState: EnAppState;
FClient: Pointer;
FListener: Pointer;
FPort: Word;
FHost: string;
public
constructor Create();
destructor Destroy; override;
function Start(): En_HP_HandleResult;
function Stop(): En_HP_HandleResult;
function DisConn(AConnID: DWORD): En_HP_HandleResult;
function SendString(AText: string): Boolean;
{$REGION '通讯'}
function PostStatus(A信息: string; const Args: array of const; ATaskState: TTaskState = tsNormal; AReStart: Boolean = True): Boolean;
function GetTask(AGroupName: string): Boolean;
function GetParam(AGroupName: string): Boolean;
function SendLog(AOrderItem: TOrderItem; ARoleIndex: Integer; AGroupName: string): Boolean;
/// <remarks>
/// 结束任务
/// </remarks>
function EndTask(AGroupName: string; AKey: string): Boolean;
function SendStatus(AOrderItem: TOrderItem; ARoleIndex: Integer; AGroupName: string): Boolean;
/// <remarks>
/// 子号告诉主号,自己的角色,要收多少货, 以及设置自己执行到哪一步了
/// </remarks>
function SetRoleStep(AGroupName:string; ARoleName: string; ARoleStep: Integer): Boolean;
function ReSetRoleStep(AGroupName: string; ARoleName: string; ATargetRoleName: string; ARoleStep: Integer): Boolean;
function GetRoleStep(AGroupName: string): TRoleStep;
function GetTargetRoleStep(AGroupName: string; ARoleName: string; ATargetRoleName: string): TRoleStep;
function SetMasterRecRoleName(AGroupName: string; AOrderNo: string; AMasterRoleName: string; ARecRoleName: string): Boolean;
function ClearRecvRoleName(AGroupName: string; AOrderNo: string; ARoleName: string): Boolean;
function GetMasterRecRoleName(AGroupName: string; AMasterRoleName: string): string;
function SuspendTask(AGroupName: string): Boolean;
{$ENDREGION}
property Host: string read FHost write FHost;
property Port: Word read FPort write FPort;
property AppState: EnAppState read FAppState write FAppState default ST_STOPED;
property Client: Pointer read FClient write FClient;
property Listener: Pointer read FListener write FListener;
end;
//--解析接收过来的数据
TDoCmd = class(TThread)
private
FCmd: string;
function StartTask(AJson: string): Boolean;
protected
procedure Execute; override;
public
constructor Create(ALen : Integer; AData: Pointer);
end;
var
TradeClient: TTradeClient;
implementation
uses
uAutoSend,
uCommand,
ManSoy.Encode,
ManSoy.Global
;
{ TTradeClient }
function OnConnect(dwConnID: DWORD): En_HP_HandleResult; stdcall;
begin
TradeClient.AppState := ST_STARTED;
Result := HP_HR_OK;
end;
function OnSend(dwConnID: DWORD; const pData: Pointer; iLength: Integer): En_HP_HandleResult; stdcall;
begin
//uGlobal.AddLogMsg(' > [%d,OnSend] -> (%d bytes)', [dwConnID, iLength]);
Result := HP_HR_OK;
{$IFDEF _MS_DEBUG}
//Inc(TradeClient.FSendCount);
//AddLogMsg('Send: %d Recv: %d', [TradeClient.SendCount, TradeClient.RecvCount]);
{$ENDIF}
end;
function OnReceive(dwConnID: DWORD; const pData: Pointer; iLength: Integer): En_HP_HandleResult; stdcall;
var
testString: AnsiString;
doRec : TDoCmd;
begin
//{$IFDEF _MS_DEBUG}
//Inc(TradeClient.FRecvCount);
//{$ENDIF}
//uGlobal.AddLogMsg(' > [%d,OnReceive] -> (%d bytes)', [dwConnID, iLength], True);
SetLength(testString, iLength);
Move(pData^, testString[1], iLength);
//uGlobal.AddLogMsg(' > [%d,OnReceive] -> %s', [dwConnId, testString], True);
doRec := TDoCmd.Create(iLength, pData);
doRec.Resume;
Result := HP_HR_OK;
end;
function OnCloseConn(dwConnID: DWORD): En_HP_HandleResult; stdcall;
begin
uGlobal.AddLogMsg(' > [%d,OnCloseConn]', [dwConnID], True);
TradeClient.AppState := ST_STOPED;
Result := HP_HR_OK;
end;
function OnError(dwConnID: DWORD; enOperation: En_HP_SocketOperation; iErrorCode: Integer): En_HP_HandleResult; stdcall;
begin
uGlobal.AddLogMsg('> [%d,OnError] -> OP:%d,CODE:%d', [dwConnID, Integer(enOperation), iErrorCode], True);
TradeClient.AppState := ST_STOPED;
Result := HP_HR_OK;
end;
constructor TTradeClient.Create;
begin
//{创建监听器对象}
FListener := Create_HP_TcpClientListener();
//{创建 Socket 对象}
FClient := Create_HP_TcpClient(FListener);
//{设置 Socket 监听器回调函数}
HP_Set_FN_Client_OnConnect(FListener, OnConnect);
HP_Set_FN_Client_OnSend(FListener, OnSend);
HP_Set_FN_Client_OnReceive(FListener, OnReceive);
HP_Set_FN_Client_OnClose(FListener, OnCloseConn);
HP_Set_FN_Client_OnError(FListener, OnError);
FAppState := ST_STOPED;
end;
destructor TTradeClient.Destroy;
begin
// 销毁 Socket 对象
Destroy_HP_TcpClient(FClient);
// 销毁监听器对象
Destroy_HP_TcpClientListener(FListener);
inherited;
end;
function TTradeClient.DisConn(AConnID: DWORD): En_HP_HandleResult;
begin
end;
function TTradeClient.SendString(AText: string): Boolean;
var
sText: AnsiString;
begin
sText := AnsiString(AText);
Result := HP_Client_Send(FClient, PAnsiChar(sText), Length(sText) + 1);
end;
{$REGION '通讯'}
function TTradeClient.PostStatus(A信息: string; const Args: array of const; ATaskState: TTaskState = tsNormal; AReStart: Boolean = True): Boolean;
var
sMsg: string;
sAccFlag: string;
begin
sMsg := System.SysUtils.Format(A信息, Args, FormatSettings);
AddLogMsg(sMsg, []);
GSharedInfo.OrderItem.roles[GSharedInfo.RoleIndex].taskState := Integer(ATaskState);
GSharedInfo.OrderItem.roles[GSharedInfo.RoleIndex].logMsg := sMsg;
if GSharedInfo.bReStart then
GSharedInfo.bReStart := AReStart;
PostLogFile('PostStatus: 内容[%s]状态[%d]重启[%s-%s]', [sMsg, Integer(ATaskState), BoolToStr(AReStart), BoolToStr(GSharedInfo.bReStart)]);
GSharedInfo.TaskStatus := ATaskState;
//---添加日志列表
uCommand.AddLogLst(sMsg);
GSharedInfo.bSuspendTask := GSharedInfo.TaskStatus = tsSuspend;
TradeClient.SendStatus(GSharedInfo.OrderItem, GSharedInfo.RoleIndex, GSharedInfo.ClientSet.GroupName);
Result := True;
end;
function TTradeClient.GetTask(AGroupName: string): Boolean;
begin
Result := uCommand.Cmd_GetTask(Client, AGroupName);
end;
function TTradeClient.GetParam(AGroupName: string): Boolean;
begin
Result := uCommand.Cmd_GetParam(Client, AGroupName);
end;
function TTradeClient.SendLog(AOrderItem: TOrderItem; ARoleIndex: Integer; AGroupName: string): Boolean;
var
sJson: string;
vLogItem: TLogItem;
sAccFlag: string;
begin
Result := false;
if AOrderItem = nil then Exit;
if Length(AOrderItem.roles) = 0 then Exit;
if ARoleIndex > Length(AOrderItem.roles) then ARoleIndex := High(AOrderItem.roles);
vLogItem := TLogItem.Create();
try
vLogItem.groupName := AGroupName;
vLogItem.detailNo := AOrderItem.roles[ARoleIndex].rowId;
vLogItem.orderNo := AOrderItem.orderNo;
vLogItem.logLevel := '1';
vLogItem.logType := IntToStr((AOrderItem.taskType + 1) * 10);
if AOrderItem.roles[ARoleIndex].isMain then
sAccFlag := '10'
else
sAccFlag := '20';
vLogItem.accFlag := sAccFlag;
vLogItem.ip := GSharedInfo.LocalIP;
vLogItem.content := AOrderItem.roles[ARoleIndex].logMsg;
sJson := TSerizalizes.AsJSON<TLogItem>(vLogItem);
{ TODO : TODO }
AddLogMsg(sJson, []);
Result := uCommand.Cmd_RetLog(Client, sJson);
if not Result then
begin
AddLogMsg('发送日志[%s]失败', [vLogItem.content]);
end;
finally
FreeAndNil(vLogItem);
end;
end;
function TTradeClient.SetRoleStep(AGroupName:string; ARoleName: string; ARoleStep: Integer): Boolean;
begin
Result := False;
GSharedInfo.bCmdOk := False;
while True do
try
Result := uCommand.Cmd_SetRoleStep(Client, AGroupName, ARoleName, ARoleStep);
Sleep(200);
if GSharedInfo.bCmdOk then
begin
Result := True;
Exit;
end;
except
end;
end;
function TTradeClient.ReSetRoleStep(AGroupName: string; ARoleName: string; ATargetRoleName: string; ARoleStep: Integer): Boolean;
begin
Result := False;
GSharedInfo.bCmdOk := False;
while True do
try
uCommand.Cmd_ReSetRoleStep(Client, AGroupName, ARoleName, ATargetRoleName, ARoleStep);
Sleep(200);
if GSharedInfo.bCmdOk then
begin
Result := True;
Exit;
end;
except
end;
end;
function TTradeClient.GetRoleStep(AGroupName: string): TRoleStep;
begin
Result := rsNormal;
GSharedInfo.bCmdOk := False;
while True do
try
uCommand.Cmd_GetRoleStep(Client, AGroupName);
Sleep(200);
if GSharedInfo.bCmdOk then
begin
Result := GSharedInfo.RoleStep;
Exit;
end;
except
end;
end;
function TTradeClient.GetTargetRoleStep(AGroupName: string; ARoleName: string; ATargetRoleName: string): TRoleStep;
begin
Result := rsNormal;
GSharedInfo.bCmdOk := False;
while True do
try
uCommand.Cmd_GetTargetRoleStep(Client, AGroupName, ARoleName, ATargetRoleName);
Sleep(200);
if GSharedInfo.bCmdOk then
begin
Result := GSharedInfo.RoleStep;
Exit;
end;
except
end;
end;
function TTradeClient.SetMasterRecRoleName(AGroupName: string; AOrderNo: string; AMasterRoleName: string; ARecRoleName: string): Boolean;
begin
Result := False;
GSharedInfo.bCmdOk := False;
while True do
try
uCommand.Cmd_SetMasterRecRoleName(Client, AGroupName, AOrderNo, AMasterRoleName, ARecRoleName);
Sleep(200);
if GSharedInfo.bCmdOk then
begin
Result := True;
Exit;
end;
except
end;
end;
function TTradeClient.ClearRecvRoleName(AGroupName: string; AOrderNo: string; ARoleName: string): Boolean;
begin
Result := False;
GSharedInfo.bCmdOk := False;
while True do
try
uCommand.Cmd_ClearRecvRoleName(Client, AGroupName, AOrderNo, ARoleName);
Sleep(200);
if GSharedInfo.bCmdOk then
begin
Result := True;
Exit;
end;
except
end;
end;
function TTradeClient.GetMasterRecRoleName(AGroupName: string; AMasterRoleName: string): string;
begin
Result := '';
GSharedInfo.bCmdOk := False;
while True do
try
uCommand.Cmd_GetMasterRecRoleName(Client, AGroupName, AMasterRoleName);
Sleep(200);
if GSharedInfo.bCmdOk then
begin
if GSharedInfo.RecvRoleName <> '' then
begin
if GSharedInfo.OrderItem.roles[GSharedInfo.RoleIndex].ReceiptRole <> GSharedInfo.RecvRoleName then
GSharedInfo.OrderItem.roles[GSharedInfo.RoleIndex].ReceiptRole := GSharedInfo.RecvRoleName;
end;
Result := GSharedInfo.RecvRoleName;
Exit;
end;
except
end;
end;
function TTradeClient.EndTask(AGroupName: string; AKey: string): Boolean;
begin
Result := uCommand.Cmd_EndTask(Client, AGroupName, AKey);
end;
function TTradeClient.SendStatus(AOrderItem: TOrderItem; ARoleIndex: Integer; AGroupName: string): Boolean;
var
sJson: string;
vStatusItem: TStatusItem;
begin
Result := false;
if AOrderItem = nil then Exit;
if Length(AOrderItem.roles) = 0 then Exit;
if ARoleIndex > Length(AOrderItem.roles) then ARoleIndex := High(AOrderItem.roles);
vStatusItem := TStatusItem.Create();
try
vStatusItem.groupName := AGroupName;
vStatusItem.rowId := AOrderItem.roles[ARoleIndex].rowId;
vStatusItem.orderNo := AOrderItem.orderNo;
vStatusItem.taskType := AOrderItem.taskType;
vStatusItem.roleId := AOrderItem.roles[ARoleIndex].roleID;
vStatusItem.state := AOrderItem.roles[ARoleIndex].taskState;
if AOrderItem.roles[ARoleIndex].logMsg = '' then
vStatusItem.reason := ''
else
vStatusItem.reason := ManSoy.Encode.StrToBase64(AOrderItem.roles[ARoleIndex].logMsg);
vStatusItem.stock := AOrderItem.roles[ARoleIndex].reStock;
sJson := TSerizalizes.AsJSON<TStatusItem>(vStatusItem);
Result := uCommand.Cmd_RetState(Client, sJson);
finally
FreeAndNil(vStatusItem);
end;
end;
function TTradeClient.SuspendTask(AGroupName: string): Boolean;
begin
Result := uCommand.Cmd_SuspendTask(Client, AGroupName);
end;
{$ENDREGION}
function TTradeClient.Start: En_HP_HandleResult;
begin
Result := HP_HR_OK;
// 异常检查自己做
if (Host = '') or (Port = 0) then
begin
uGlobal.AddLogMsg('启动失败, 请检查服务器IP是否已经设置', []);
Exit;
end;
// 写在这个位置是上面可能会异常
FAppState := ST_STARTING;
if not (HP_Client_Start(FClient, PWideChar(Host), Port, False)) then
begin
FAppState := ST_STOPED;
uGlobal.AddLogMsg('Client Start Error -> %s(%d)',
[
HP_Client_GetLastErrorDesc(FClient),
Integer( HP_Client_GetLastError(FClient))
]);
Exit;
end;
FAppState := ST_STARTED;
AddLogMsg('$Client Starting ... -> (%s:%d)', [Host, port], True);
end;
function TTradeClient.Stop: En_HP_HandleResult;
begin
Result := HP_HR_ERROR;
FAppState := ST_STOPING;
// 停止服务
if not (HP_Client_Stop(FClient)) then
begin
uGlobal.AddLogMsg('$Stop Error -> %s(%d)',
[
HP_Client_GetLastErrorDesc(FClient),
Integer(HP_Client_GetLastError(FClient))
]);
Exit;
end;
FAppState := ST_STOPED;
uGlobal.AddLogMsg('$Server Stop', [], True);
Result := HP_HR_OK;
end;
{ TDoCmd }
constructor TDoCmd.Create(ALen: Integer; AData: Pointer);
var
sCmd: AnsiString;
begin
inherited Create(True);
FreeOnTerminate := True;
// 以下是一个pData转字符串的演示
SetLength(sCmd, ALen);
Move(AData^, sCmd[1], ALen);
FCmd := Trim(string(sCmd));
end;
procedure TDoCmd.Execute;
var
vLst: TStrings;
sJson, sGroupName: string;
bResume, bOk: Boolean;
begin
//inherited;
if FCmd = '' then Exit;
{ TODO : 在这里处理,服务端请求 }
vLst := TStringList.Create;
try
vLst.DelimitedText := FCmd;
vLst.Delimiter := ',';
if vLst.Count = 0 then Exit;
if vLst.Values['cmd'] = '' then Exit;
if vLst.Values['cmd'] = 'RetTask' then
begin
// TODO : 获取到了新任务
vLst.SaveToFile(GSharedInfo.AppPath + '123.json');
sJson := Trim(ManSoy.Encode.Base64ToStr(vLst.Values['Json']));
if sJson = '' then Exit;
if sJson = 'nil' then Exit;
StartTask(sJson);
end else if vLst.Values['cmd'] = 'CmdOK' then
begin
GSharedInfo.bCmdOk := True;
end else if vLst.Values['cmd'] = 'RetConn' then
begin
bOk := StrToBoolDef(vLst.Values['IsOk'], False);
if not bOk then
begin
TradeClient.Stop;
GSharedInfo.bConnOK := False;
AddLogMsg('发货机名称重复...', []);
SendMessage(GSharedInfo.MainFormHandle, WM_DIS_CONN, 0, 0);
Exit;
end;
GSharedInfo.bConnOK := True;
end else if vLst.Values['cmd'] = 'RetRoleStep' then
begin
ManSoy.Global.DebugInf('MS - RetRoleStep: %s', [FCmd]);
GSharedInfo.RoleStep := TRoleStep(StrToIntDef(vLst.Values['RoleStep'], 0));
GSharedInfo.bCmdOk := True;
end else if vLst.Values['cmd'] = 'RetRecvRoleName' then
begin
ManSoy.Global.DebugInf('MS - RetRecvRoleName: %s', [FCmd]);
GSharedInfo.RecvRoleName := Trim(vLst.Values['RecvRoleName']);
GSharedInfo.bCmdOk := True;
end else if vLst.Values['cmd'] = 'SuspendTask' then
begin
AddLogMsg(vLst.Text, [], True);
sGroupName := vLst.Values['GroupName'];
if sGroupName <> GSharedInfo.ClientSet.GroupName then Exit;
GSharedInfo.bSuspendTask := True;
end else if vLst.Values['cmd'] = 'ResumeTask' then
begin
AddLogMsg(vLst.Text, [], True);
sGroupName := vLst.Values['GroupName'];
if sGroupName <> GSharedInfo.ClientSet.GroupName then Exit;
GSharedInfo.bSuspendTask := False;
end else if vLst.Values['cmd'] = 'StopTask' then
begin
AddLogMsg(vLst.Text, [], True);
sGroupName := vLst.Values['GroupName'];
if sGroupName <> GSharedInfo.ClientSet.GroupName then Exit;
GSharedInfo.bStopTask := True;
end else if vLst.Values['cmd'] = 'RetParam' then
begin
sJson := Trim(ManSoy.Encode.Base64ToStr(vLst.Values['Json']));
if sJson = '' then Exit;
if sJson = 'nil' then Exit;
if not TSerizalizes.AsType<TConsoleSet>(sJson, GConsoleSet) then Exit;
if GConsoleSet = nil then Exit;
end else if vLst.Values['cmd'] = 'Shutdown' then
begin
AddLogMsg(vLst.Text, [], True);
if GSharedInfo.bWork then Exit;
sGroupName := vLst.Values['GroupName'];
if sGroupName <> GSharedInfo.ClientSet.GroupName then Exit;
ExitWindowsEx(EWX_SHUTDOWN or EWX_FORCE, 0);
end else if vLst.Values['cmd'] = 'ReStart' then
begin
AddLogMsg(vLst.Text, [], True);
if GSharedInfo.bWork then Exit;
sGroupName := vLst.Values['GroupName'];
if sGroupName <> GSharedInfo.ClientSet.GroupName then Exit;
ExitWindowsEx(EWX_REBOOT or EWX_FORCE, 0);
end else if vLst.Values['cmd'] = 'Logout' then
begin
AddLogMsg(vLst.Text, [], True);
if GSharedInfo.bWork then Exit;
sGroupName := vLst.Values['GroupName'];
if sGroupName <> GSharedInfo.ClientSet.GroupName then Exit;
ExitWindowsEx(EWX_LOGOFF or EWX_FORCE, 0);
end;
finally
FreeAndNil(vLst);
end;
end;
function TDoCmd.StartTask(AJson: string): Boolean;
var
sJson: string;
vOrderItem: TOrderItem;
vRoleItem: TRoleItem;
bIsMain: Boolean;
I: Integer;
begin
Result := False;
try
if not TSerizalizes.AsType<TOrderItem>(AJson, vOrderItem) then Exit;
if vOrderItem = nil then Exit;
if Length(vOrderItem.roles) = 0 then Exit;
if GSharedInfo.bWork then Exit;
TAutoSend.Create(vOrderItem);
Result := True;
except
end;
end;
initialization
TradeClient := TTradeClient.Create;
finalization
if TradeClient.FAppState = ST_STARTED then
begin
TradeClient.Stop;
end;
FreeAndNil(TradeClient);
end.
|
unit uPapyrusDataView;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, uESSFile, ExtCtrls, VirtualTrees, GlassButton, ComCtrls,
Clipbrd;
type
PDataRec = ^TDataRec;
TDataRec = record
_Caption: WideString;
end;
type
TfPapyrusDataView = class(TForm)
pnMenu: TPanel;
lbSearch: TLabel;
edSearch: TEdit;
stNotFound: TStaticText;
procedure FormCreate(Sender: TObject);
procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure btnCloseClick(Sender: TObject);
procedure btnSearchClick(Sender: TObject);
procedure edSearchKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure edSearchChange(Sender: TObject);
procedure edSearchKeyPress(Sender: TObject; var Key: Char);
procedure vtKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure vtGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var Text: WideString);
procedure vtFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
private
btnClose, btnSearch: TGlassButton;
vtView: TVirtualStringTree;
Papyrus: PPapyrus;
ActiveData: PActiveData;
end;
procedure ShowActiveData(aCaption: string; var aActiveData: TActiveData; var aPapyrus: TPapyrus);
procedure ShowOtherData(aCaption: string; var aPapyrus: TPapyrus);
implementation
{$R *.dfm}
uses
uHelper, uMain, uViewer;
procedure ShowTreeActiveData(vtTMP: TVirtualStringTree; var aActiveData: TActiveData; var aPapyrus: TPapyrus); forward;
procedure ShowTreeOtherData(vtTMP: TVirtualStringTree; var aPapyrus: TPapyrus); forward;
procedure TfPapyrusDataView.FormCreate(Sender: TObject);
begin
btnClose := CreateButton('Close', True, clBlack, pnMenu.ClientWidth - 77, 2, 25, 75, 9, 0, [akRight, akTop], Self, pnMenu, fMain.imImages, btnCloseClick, nil);
btnSearch := CreateButton('Search', False, clBlack, edSearch.Left + edSearch.Width + 4, 2, 25, 75, 7, 2, [akLeft, akTop], Self, pnMenu, fMain.imImages, btnSearchClick, nil);
vtView := TVirtualStringTree.Create(Self);
with vtView do
begin
Parent := Self;
Align := alClient;
TabOrder := 1;
Color := $F7F7F7;
Colors.UnfocusedSelectionColor := clHighlight;
IncrementalSearch := isVisibleOnly;
NodeDataSize := SizeOf(TDataRec);
OnGetText := vtGetText;
OnFreeNode := vtFreeNode;
OnKeyUp := vtKeyUp;
end;
end;
procedure TfPapyrusDataView.edSearchChange(Sender: TObject);
begin
btnSearch.Enabled := Trim(edSearch.Text) <> '';
stNotFound.Visible := False;
end;
procedure TfPapyrusDataView.edSearchKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if (Key = VK_RETURN) and (Trim(edSearch.Text) <> '') then
btnSearch.Click;
end;
procedure TfPapyrusDataView.edSearchKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
Key := #0;
end;
procedure TfPapyrusDataView.btnSearchClick(Sender: TObject);
var
Node: PVirtualNode;
begin
if Trim(edSearch.Text) <> '' then
begin
if vtView.GetFirstSelected <> nil then
Node := vtView.GetFirstSelected
else
Node := vtView.RootNode;
try
Screen.Cursor := crHourGlass;
vtSearch(vtView, Node, edSearch.Text, stNotFound);
finally
Screen.Cursor := crDefault;
end;
end;
end;
const
VK_C = $43;
procedure TfPapyrusDataView.vtKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
var
Rec: PDataRec;
begin
if Sender is TVirtualStringTree then
with Sender as TVirtualStringTree do
case Key of
VK_C:
if (GetFirstSelected <> nil) and (ssCtrl in Shift) then
begin
Rec := GetNodeData(GetFirstSelected);
if Assigned(Rec) then
Clipboard.AsText := Rec^._Caption;
end;
end;
end;
procedure TfPapyrusDataView.vtGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var Text: WideString);
var
Rec: PDataRec;
begin
Rec := Sender.GetNodeData(Node);
Text := Rec^._Caption;
end;
procedure TfPapyrusDataView.vtFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
var
Rec: PDataRec;
begin
Rec := Sender.GetNodeData(Node);
Finalize(Rec^);
end;
const
VK_A = $41;
procedure TfPapyrusDataView.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
case Key of
VK_F3: if Trim(edSearch.Text) <> '' then
btnSearch.Click;
end;
end;
procedure TfPapyrusDataView.btnCloseClick(Sender: TObject);
begin
Close;
end;
function GetStringReference(aStr: Integer; var aPapyrus: TPapyrus): string;
begin
if aStr < Length(aPapyrus.yStrings) then
Result := '0x' + IntToHex(aStr, 4) + ' [' + IntToStr(aStr) + '] "' + aPapyrus.yStrings[aStr]^.sName + '"'
else
Result := '0x' + IntToHex(aStr, 4) + ' [' + IntToStr(aStr) + ']';
end;
function GetVariable(var aVariable: TMember; var aPapyrus: TPapyrus): string;
{$IF Defined(USEREGION)}{$REGION 'GetVariable'}{$IFEND}
begin
with aVariable, aPapyrus do
case iType of
0: Result := 'Null 0x' + IntToHex(iData, 8) + ' [' + IntToStr(iData) + ']';
1: Result := 'RefID Type ' + GetStringReference(iReference, aPapyrus) + ' ID 0x' + IntToHex(iData, 8) + ' [' + IntToStr(iData) + ']';
2: Result := 'String ' + GetStringReference(iReference, aPapyrus);
3: Result := 'Integer 0x' + IntToHex(iData, 8) + ' [' + IntToStr(iData) + ']';
4: Result := 'Float ' + FloatToStr(iData);
5: Result := 'Boolean 0x' + IntToHex(iData, 8) + ' [' + IntToStr(iData) + ']';
11: Result := 'RefID Array Type ' + GetStringReference(iReference, aPapyrus) + ' Array ID 0x' + IntToHex(iData, 8) + ' [' + IntToStr(iData) + ']';
12: Result := 'String Array ID: 0x' + IntToHex(iData, 8) + ' [' + IntToStr(iData) + ']';
13: Result := 'Integer Array ID: 0x' + IntToHex(iData, 8) + ' [' + IntToStr(iData) + ']';
14: Result := 'Float Array ID: 0x' + IntToHex(iData, 8) + ' [' + IntToStr(iData) + ']';
15: Result := 'Boolean Array ID: 0x' + IntToHex(iData, 8) + ' [' + IntToStr(iData) + ']';
else
Result := 'Unknown Type 0x' + IntToHex(iReference, 4) + ' [' + IntToStr(iReference) + '] Data 0x' + IntToHex(iData, 8) + ' [' + IntToStr(iData) + ']';
end;
end; {$IF Defined(USEREGION)}{$ENDREGION}{$IFEND}
function GetUnknown4(aType: Byte; var aName: string; var aVariable: TMember; var aRef: TRefID; var aStr: uint16; var aiUnk: uint32; var abUnk: uint8; var aPapyrus: TPapyrus): string;
{$IF Defined(USEREGION)}{$REGION 'GetUnknown4'}{$IFEND}
begin
Result := 'Type' + IntToStr(aType);
if aType = 2 then
Result := Result + ' variable: ' + GetVariable(aVariable, aPapyrus)
else
begin
Result := Result + ' "' + aName + '"';
aName := AnsiUpperCase(aName);
if (aName = AnsiUpperCase('QuestStage')) or (aName = AnsiUpperCase('ScenePhaseResults')) or (aName = AnsiUpperCase('SceneActionResults')) or (aName = AnsiUpperCase('SceneResults')) then
Result := Result + ' RefID ' + RefIDToString(aRef);
if aName = AnsiUpperCase('QuestStage') then
begin
Result := Result + ' String ' + GetStringReference(aStr, aPapyrus);
Result := Result + ' unknown 0x' + IntToHex(abUnk, 2) + ' [' + IntToStr(0) + ']';
end;
if (aName = AnsiUpperCase('ScenePhaseResults')) or (aName = AnsiUpperCase('SceneActionResults')) then
Result := Result + ' unknown 0x' + IntToHex(aiUnk, 8) + ' [' + IntToStr(aiUnk) + ']';
if aType = 3 then
Result := Result + ' variable: ' + GetVariable(aVariable, aPapyrus)
end;
end; {$IF Defined(USEREGION)}{$ENDREGION}{$IFEND}
function GetOpcode(Opcode: uint8): string;
{$IF Defined(USEREGION)}{$REGION 'GetOpcode'}{$IFEND}
begin
Result := '0x' + IntToHex(Opcode, 2);
case Opcode of
$00: Result := Result + ' NOOP';
$01: Result := Result + ' Iadd SII';
$02: Result := Result + ' Fadd SFF';
$03: Result := Result + ' Isubtract SII';
$04: Result := Result + ' Fsubtract SFF';
$05: Result := Result + ' IMultiply SII';
$06: Result := Result + ' FMultiply SFF';
$07: Result := Result + ' IDivide SII';
$08: Result := Result + ' FDivide SFF';
$09: Result := Result + ' Imod SII';
$0A: Result := Result + ' Not SA';
$0B: Result := Result + ' Inegate SI';
$0C: Result := Result + ' Fnegate SF';
$0D: Result := Result + ' Assign SA';
$0E: Result := Result + ' Cast SA';
$0F: Result := Result + ' CompareEQ SAA';
$10: Result := Result + ' CompareLT SAA';
$11: Result := Result + ' CompareLTE SAA';
$12: Result := Result + ' CompareGT SAA';
$13: Result := Result + ' CompareLTE SAA';
$14: Result := Result + ' Jump L';
$15: Result := Result + ' JumpT AL';
$16: Result := Result + ' JumpF AL';
$17: Result := Result + ' CallMethod NSS*';
$18: Result := Result + ' CallParent NS*';
$19: Result := Result + ' CallStatic NNS*';
$1A: Result := Result + ' Return A';
$1B: Result := Result + ' StrCat SQQ';
$1C: Result := Result + ' PropGet NSS';
$1D: Result := Result + ' PropSet NSA';
$1E: Result := Result + ' ArrayCreate Su';
$1F: Result := Result + ' ArrayLength SS';
$20: Result := Result + ' ArrayGetElement SSI';
$21: Result := Result + ' ArraySetElement SIA';
$22: Result := Result + ' ArrayFindelement SSAI';
$23: Result := Result + ' ArrayRFindElement SSAI';
$24: Result := Result + ' INVALID';
else
Result := Result + ' Unknown Opcode';
end;
end; {$IF Defined(USEREGION)}{$ENDREGION}{$IFEND}
procedure ShowActiveData(aCaption: string; var aActiveData: TActiveData; var aPapyrus: TPapyrus);
{$IF Defined(USEREGION)}{$REGION 'ShowActiveData'}{$IFEND}
begin
with TfPapyrusDataView.Create(Application) do
begin
Caption := aCaption;
Tag := 1;
Papyrus := @aPapyrus;
ActiveData := @aActiveData;
ShowTreeActiveData(vtView, ActiveData^, Papyrus^);
Show;
end;
end; {$IF Defined(USEREGION)}{$ENDREGION}{$IFEND}
procedure ShowOtherData(aCaption: string; var aPapyrus: TPapyrus);
{$IF Defined(USEREGION)}{$REGION 'ShowOtherData'}{$IFEND}
begin
with TfPapyrusDataView.Create(Application) do
begin
Caption := aCaption;
Tag := 2;
Papyrus := @aPapyrus;
ShowTreeOtherData(vtView, Papyrus^);
Show;
end;
end; {$IF Defined(USEREGION)}{$ENDREGION}{$IFEND}
function AddData(Tree: TVirtualStringTree; Node: PVirtualNode; Caption: string): PVirtualNode;
var
Rec: PDataRec;
begin
Result := Tree.AddChild(Node);
Rec := Tree.GetNodeData(Result);
Rec^._Caption := Caption;
end;
procedure ShowTreeActiveData(vtTMP: TVirtualStringTree; var aActiveData: TActiveData; var aPapyrus: TPapyrus);
{$IF Defined(USEREGION)}{$REGION 'ShowTreeActiveData'}{$IFEND}
var
Root, L1, L2, L3, L4, L5: PVirtualNode;
i, j, k: integer;
begin
vtTMP.Clear;
with vtTMP, aActiveData do
begin
BeginUpdate;
try
Root := AddData(vtTMP, nil, 'Active Script Data');
AddData(vtTmp, Root, 'ID: 0x' + IntToHex(iID, 8));
AddData(vtTmp, Root, 'Version: ' + IntToStr(iMajorVersion) + '.' + IntToStr(iMinorVersion));
AddData(vtTmp, Root, 'Unknown variable: ' + GetVariable(tUnknown, aPapyrus));
AddData(vtTmp, Root, 'Flag: 0x' + IntToHex(bFlag, 8) + ' bin ' + IntToBin(bFlag, 8));
AddData(vtTmp, Root, 'UnknownByte: 0x' + IntToHex(bUnknownByte, 2) + ' [' + IntToStr(bUnknownByte) + ']');
if (bFlag and $01) <> 0 then
AddData(vtTmp, Root, 'Unknown2: 0x' + IntToHex(iUnknown2, 8) + ' [' + IntToStr(iUnknown2) + ']');
AddData(vtTmp, Root, 'Unknown3: 0x' + IntToHex(iUnknown3, 2) + ' [' + IntToStr(iUnknown3) + ']');
if iUnknown3 in [1..3] then
with tUnknown4 do
AddData(vtTmp, Root, 'Unknown4: ' + GetUnknown4(iUnknown3, sName, tVariable, tRef, iStr, iUnk, bUnk, aPapyrus));
L1 := AddData(vtTmp, Root, 'Stack Frames (' + IntToStr(iStackframecount) + ')');
for i := 0 to iStackframecount- 1 do
with yStackframe[i] do
begin
L2 := AddData(vtTmp, L1, IntToStr(i));
AddData(vtTmp, L2, 'Variable Count: ' + IntToStr(iVariablecount));
AddData(vtTmp, L2, 'Flag: 0x' + IntToHex(bFlag, 8) + ' bin ' + IntToBin(bFlag, 8));
AddData(vtTmp, L2, 'Function Type: ' + IntToStr(bFunctionType));
AddData(vtTmp, L2, 'Script Name: ' + GetStringReference(iScriptName, aPapyrus));
AddData(vtTmp, L2, 'Script Base Name: ' + GetStringReference(iScriptBaseName, aPapyrus));
AddData(vtTmp, L2, 'Event: ' + GetStringReference(iEvent, aPapyrus));
if ((bFlag and $01) = 0) and (bFunctionType = 0) then
AddData(vtTmp, L2, 'Status: ' + GetStringReference(iStatus, aPapyrus));
AddData(vtTmp, L2, 'OpcodeVersion: ' + IntToStr(iOpcodeVersion) + '.' + IntToStr(iOpcodeMinorVersion));
AddData(vtTmp, L2, 'Return Type: ' + GetStringReference(iReturnType, aPapyrus));
AddData(vtTmp, L2, 'Function Doc String: ' + GetStringReference(iFunctionDocString, aPapyrus));
AddData(vtTmp, L2, 'Function Flags: 0x' + IntToHex(iFunctionFlags, 8) + ' [' + IntToStr(iFunctionFlags) + '] bin ' + IntToBin(iFunctionFlags, 32));
L3 := AddData(vtTmp, L2, 'Function Parameters (' + IntToStr(iFunctionParameterCount) + ')');
for j := 0 to iFunctionParameterCount - 1 do
with uFunctionParam[j] do
begin
L4 := AddData(vtTmp, L3, IntToStr(j));
AddData(vtTmp, L4, 'Name: ' + GetStringReference(iName, aPapyrus));
AddData(vtTmp, L4, 'Type: ' + GetStringReference(iType, aPapyrus));
end;
L3 := AddData(vtTmp, L2, 'Function Locals (' + IntToStr(iFunctionLocalsCount) + ')');
for j := 0 to iFunctionLocalsCount - 1 do
with yFunctionLocal[j] do
begin
L4 := AddData(vtTmp, L3, IntToStr(j));
AddData(vtTmp, L4, 'Name: ' + GetStringReference(iName, aPapyrus));
AddData(vtTmp, L4, 'Type: ' + GetStringReference(iType, aPapyrus));
end;
L3 := AddData(vtTmp, L2, 'Opcodes: (' + IntToStr(iOpcodeCount) + ')');
for j := 0 to iOpcodeCount - 1 do
with yOpcodeData[j] do
begin
L4 := AddData(vtTmp, L3, IntToStr(j));
L5 := AddData(vtTmp, L4, 'Opcode: ' + GetOpcode(iOpcode));
for k := 0 to Length(yParameter) - 1 do
with yParameter[k] do
case iType of
0: AddData(vtTmp, L5, IntToStr(k) + ' null');
1, 2: AddData(vtTmp, L5, IntToStr(k) + ' Reference: ' + GetStringReference(iData, aPapyrus));
3: AddData(vtTmp, L5, IntToStr(k) + ' int32: 0x' + IntToHex(iData, 8) + ' [' + IntToStr(iData) + ']');
4: AddData(vtTmp, L5, IntToStr(k) + ' float: ' + FloatToStr(fData));
5: AddData(vtTmp, L5, IntToStr(k) + ' uint8: 0x' + IntToHex(iData, 2) + ' [' + IntToStr(iData) + '] bin ' + IntToBin(bFlag, 8));
else
AddData(vtTmp, L5, IntToStr(k) + ' unknown type: ' + IntToStr(iType));
end;
end;
FullExpand(L3);
Expanded[L3] := False;
AddData(vtTmp, L2, 'Unknown3: 0x' + IntToHex(iUnknown3, 8) + ' [' + IntToStr(iUnknown3) + ']');
L3 := AddData(vtTmp, L2, 'Variables (' + IntToStr(iVariablecount + 1) + ')');
for j := 0 to iVariablecount do
AddData(vtTmp, L3, IntToStr(j) + ': ' + GetVariable(tUnknown[j], aPapyrus));
end;
if iStackframecount > 0 then
AddData(vtTmp, Root, 'Unknown5: 0x' + IntToHex(unknown5, 2) + ' [' + IntToStr(unknown5) + ']');
Expanded[Root] := True;
finally
EndUpdate;
end;
end;
end; {$IF Defined(USEREGION)}{$ENDREGION}{$IFEND}
procedure ShowTreeOtherData(vtTMP: TVirtualStringTree; var aPapyrus: TPapyrus);
{$IF Defined(USEREGION)}{$REGION 'ShowTreeOtherData'}{$IFEND}
var
Root, L1, L2, L3, L4, L5, L6, L7, L8: PVirtualNode;
i, j, k, l: integer;
procedure ShowMessageData(var MessageData: TFunctionMessageData; var aPapyrus: TPapyrus; var Root, L1, L2: PVirtualNode);
var
i: integer;
begin
with MessageData do
begin
L1 := AddData(vtTmp, Root, 'FunctionMessageData');
AddData(vtTmp, L1, 'unknown: 0x' + IntToHex(unknown, 2) + ' [' + IntToStr(unknown) + ']');
AddData(vtTmp, L1, 'Script Name: ' + GetStringReference(iScriptName, aPapyrus));
AddData(vtTmp, L1, 'Event: ' + GetStringReference(iEvent, aPapyrus));
AddData(vtTmp, L1, 'Unknow: ' + GetVariable(tUnknow, aPapyrus));
L2 := AddData(vtTmp, L1, 'Variables (' + IntToStr(iVariableCount) + ')');
for i := 0 to iVariableCount - 1 do
AddData(vtTmp, L2, 'unknown var' + IntToStr(i) + ': ' + GetVariable(yUnknown[i], aPapyrus));
end
end;
begin
vtTMP.Clear;
with vtTMP, aPapyrus do
begin
BeginUpdate;
try
Root := AddData(vtTMP, nil, 'Other Papyrus Data');
L1 := AddData(vtTmp, Root, 'Function Messages (' + IntToStr(iFunctionMessageCount) + ')');
for i := 0 to iFunctionMessageCount - 1 do
with yFunctionMessages[i]^ do
begin
L2 := AddData(vtTmp, L1, IntToStr(i));
AddData(vtTmp, L2, 'unknown: 0x' + IntToHex(unknown, 8) + ' bin ' + IntToBin(unknown, 8));
if unknown <= 2 then
begin
AddData(vtTmp, L2, 'ID: 0x' + IntToHex(iID, 8) + ' [' + IntToStr(iID) + ']');
AddData(vtTmp, L2, 'Flag: 0x' + IntToHex(iFlag, 8) + ' bin ' + IntToBin(iFlag, 8));
if iFlag > 0 then
ShowMessageData(tMessageData, aPapyrus, L2, L3, L4);
end;
end;
L1 := AddData(vtTmp, Root, 'Suspended Stacks 1 (' + IntToStr(iSuspendedStackCount1) + ')');
for i := 0 to iSuspendedStackCount1 - 1 do
with ySuspendedStacks1[i]^ do
begin
L2 := AddData(vtTmp, L1, IntToStr(i));
AddData(vtTmp, L2, 'ID: 0x' + IntToHex(iID, 8) + ' [' + IntToStr(iID) + ']');
AddData(vtTmp, L2, 'Flag: 0x' + IntToHex(iFlag, 8) + ' bin ' + IntToBin(iFlag, 8));
if iFlag > 0 then
ShowMessageData(tMessageData, aPapyrus, L2, L3, L4);
end;
L1 := AddData(vtTmp, Root, 'Suspended Stacks 2 (' + IntToStr(iSuspendedStackCount2) + ')');
for i := 0 to iSuspendedStackCount2 - 1 do
with ySuspendedStacks2[i]^ do
begin
L2 := AddData(vtTmp, L1, IntToStr(i));
AddData(vtTmp, L2, 'ID: 0x' + IntToHex(iID, 8) + ' [' + IntToStr(iID) + ']');
AddData(vtTmp, L2, 'Flag: 0x' + IntToHex(iFlag, 8) + ' bin ' + IntToBin(iFlag, 8));
if iFlag > 0 then
ShowMessageData(tMessageData, aPapyrus, L2, L3, L4);
end;
AddData(vtTmp, Root, 'Unknown1: 0x' + IntToHex(iUnknown1, 8) + ' [' + IntToStr(iUnknown1) + ']');
AddData(vtTmp, Root, 'Unknown2: 0x' + IntToHex(iUnknown2, 8) + ' [' + IntToStr(iUnknown2) + ']');
L1 := AddData(vtTmp, Root, 'Unknowns (' + IntToStr(iUnknownCount) + ')');
for i := 0 to iUnknownCount - 1 do
AddData(vtTmp, L1, 'Unknown [' + IntToStr(i) + ']: 0x' + IntToHex(tUnknown[i], 8) + ' [' + IntToStr(tUnknown[i]) + ']');
L1 := AddData(vtTmp, Root, 'Queued Unbind (' + IntToStr(iQueuedUnbindCount) + ')');
for i := 0 to iQueuedUnbindCount - 1 do
with yQueuedUnbinds[i] do
begin
L2 := AddData(vtTmp, L1, IntToStr(i));
AddData(vtTmp, L2, 'Unk 1: 0x' + IntToHex(iUnk1, 8) + ' [' + IntToStr(iUnk1) + ']');
AddData(vtTmp, L2, 'Unk 2: 0x' + IntToHex(iUnk2, 8) + ' [' + IntToStr(iUnk2) + ']');
end;
AddData(vtTmp, Root, 'Save File Version: ' + IntToStr(saveFileVersion) + ' bin ' + IntToBin(saveFileVersion, 8));
Expanded[Root] := True;
Root := AddData(vtTMP, nil, 'Another Recognized Data');
L1 := AddData(vtTmp, Root, 'Array 1 (' + IntToStr(iArrayCount1) + ')');
for i := 0 to iArrayCount1 - 1 do
with yArray1[i] do
begin
L2 := AddData(vtTmp, L1, IntToStr(i));
AddData(vtTmp, L2, 'Unk 1: 0x' + IntToHex(iUnk1, 8) + ' [' + IntToStr(iUnk1) + ']');
AddData(vtTmp, L2, 'Unk 2: 0x' + IntToHex(iUnk2, 8) + ' [' + IntToStr(iUnk2) + ']');
end;
AddData(vtTmp, Root, 'Array 1a (' + IntToStr(iArrayCount1a) + ')');
L1 := AddData(vtTmp, Root, 'Array 2 (' + IntToStr(iArrayCount2) + ')');
for i := 0 to iArrayCount2 - 1 do
with yArray2[i] do
begin
L2 := AddData(vtTmp, L1, IntToStr(i));
AddData(vtTmp, L2, 'Unk 1: 0x' + IntToHex(iUnk1, 8) + ' [' + IntToStr(iUnk1) + ']');
AddData(vtTmp, L2, 'Unk 2: 0x' + IntToHex(iUnk2, 8) + ' [' + IntToStr(iUnk2) + ']');
end;
L1 := AddData(vtTmp, Root, 'Array 3 (' + IntToStr(iArrayCount3) + ')');
for i := 0 to iArrayCount3 - 1 do
with yArray3[i] do
begin
L2 := AddData(vtTmp, L1, IntToStr(i));
AddData(vtTmp, L2, 'Type: ' + IntToStr(iType));
AddData(vtTmp, L2, 'Str1: ' + GetStringReference(iStr1, aPapyrus));
AddData(vtTmp, L2, 'Unk1: 0x' + IntToHex(iUnk1, 4) + ' [' + IntToStr(iUnk1) + ']');
AddData(vtTmp, L2, 'Str2: ' + GetStringReference(iStr2, aPapyrus));
AddData(vtTmp, L2, 'Unk2: 0x' + IntToHex(iUnk2, 8) + ' [' + IntToStr(iUnk2) + ']');
AddData(vtTmp, L2, 'Flag: 0x' + IntToHex(iFlag, 4) + ' [' + IntToStr(iFlag) + ']' + ' bin ' + IntToBin(iFlag, 16));
AddData(vtTmp, L2, 'Ref: ' + RefIDToString(tRef));
end;
L1 := AddData(vtTmp, Root, 'Array 4 (' + IntToStr(iArrayCount4) + ')');
for i := 0 to iArrayCount4 - 1 do
with yArray4[i] do
begin
L2 := AddData(vtTmp, L1, IntToStr(i));
AddData(vtTmp, L2, 'Str1: ' + GetStringReference(iStr1, aPapyrus));
AddData(vtTmp, L2, 'Unk1: 0x' + IntToHex(iUnk1, 4) + ' [' + IntToStr(iUnk1) + ']');
AddData(vtTmp, L2, 'Unk2: 0x' + IntToHex(iUnk2, 2) + ' [' + IntToStr(iUnk2) + ']');
AddData(vtTmp, L2, 'Str2: ' + GetStringReference(iStr2, aPapyrus));
AddData(vtTmp, L2, 'Unk3: 0x' + IntToHex(iUnk3, 8) + ' [' + IntToStr(iUnk3) + ']');
AddData(vtTmp, L2, 'Flag: 0x' + IntToHex(iFlag, 4) + ' [' + IntToStr(iFlag) + ']' + ' bin ' + IntToBin(iFlag, 16));
AddData(vtTmp, L2, 'Ref: ' + RefIDToString(tRef));
end;
L1 := AddData(vtTmp, Root, 'Script List (' + IntToStr(iScriptListCount) + ')');
for i := 0 to iScriptListCount - 1 do
AddData(vtTmp, L1, IntToStr(i) +': ' + yScriptList[i]);
AddData(vtTmp, Root, 'Array 4a (' + IntToStr(iArrayCount4a) + ')');
L1 := AddData(vtTmp, Root, 'Array 4b (' + IntToStr(iArrayCount4b) + ')');
for i := 0 to iArrayCount4b - 1 do
with yArray4b[i] do
begin
L2 := AddData(vtTmp, L1, IntToStr(i));
AddData(vtTmp, L2, 'Unk1: 0x' + IntToHex(iUnk1, 2) + ' [' + IntToStr(iUnk1) + ']');
AddData(vtTmp, L2, 'Unk2: 0x' + IntToHex(iUnk2, 4) + ' [' + IntToStr(iUnk2) + ']');
AddData(vtTmp, L2, 'Unk3: 0x' + IntToHex(iUnk3, 4) + ' [' + IntToStr(iUnk3) + ']');
AddData(vtTmp, L2, 'Ref1: ' + RefIDToString(tRef1));
AddData(vtTmp, L2, 'Ref2: ' + RefIDToString(tRef2));
AddData(vtTmp, L2, 'Ref3: ' + RefIDToString(tRef3));
AddData(vtTmp, L2, 'Ref4: ' + RefIDToString(tRef4));
end;
L1 := AddData(vtTmp, Root, 'Array 4c (' + IntToStr(iArrayCount4c) + ')');
for i := 0 to iArrayCount4c - 1 do
with yArray4c[i] do
begin
L2 := AddData(vtTmp, L1, IntToStr(i));
AddData(vtTmp, L2, 'Flag: 0x' + IntToHex(iFlag, 2) + ' [' + IntToStr(iFlag) + ']');
AddData(vtTmp, L2, 'Unk2: 0x' + IntToHex(iUnk2, 8) + ' [' + IntToStr(iUnk2) + ']');
AddData(vtTmp, L2, 'Ref1: ' + RefIDToString(tRef1));
if iFlag = 0 then
AddData(vtTmp, L2, 'Ref2: ' + RefIDToString(tRef2));
AddData(vtTmp, L2, 'Unk2: 0x' + IntToHex(iUnk2, 8) + ' [' + IntToStr(iUnk2) + ']');
AddData(vtTmp, L2, 'Unk3: 0x' + IntToHex(iUnk3, 8) + ' [' + IntToStr(iUnk3) + ']');
if iFlag = 0 then
AddData(vtTmp, L2, 'Unk4: 0x' + IntToHex(iUnk4, 4) + ' [' + IntToStr(iUnk4) + ']');
if iFlag = 0 then
AddData(vtTmp, L2, 'Unk5: 0x' + IntToHex(iUnk5, 4) + ' [' + IntToStr(iUnk5) + ']');
AddData(vtTmp, L2, 'Unk6: 0x' + IntToHex(iUnk6, 8) + ' [' + IntToStr(iUnk6) + ']');
if iFlag = 0 then
AddData(vtTmp, L2, 'Unk7: 0x' + IntToHex(iUnk7, 8) + ' [' + IntToStr(iUnk7) + ']');
if iFlag = 0 then
AddData(vtTmp, L2, 'Unk8: 0x' + IntToHex(iUnk8, 8) + ' [' + IntToStr(iUnk8) + ']');
if iFlag = 0 then
AddData(vtTmp, L2, 'Unk9: 0x' + IntToHex(iUnk9, 4) + ' [' + IntToStr(iUnk9) + ']');
end;
AddData(vtTmp, Root, 'Array 4d (' + IntToStr(iArrayCount4d) + ')');
L1 := AddData(vtTmp, Root, 'Array 5 (' + IntToStr(iArrayCount5) + ')');
for i := 0 to iArrayCount5 - 1 do
with yArray5[i] do
begin
L2 := AddData(vtTmp, L1, IntToStr(i));
AddData(vtTmp, L2, 'Unk1: 0x' + IntToHex(iUnk1, 4) + ' [' + IntToStr(iUnk1) + ']');
AddData(vtTmp, L2, 'Unk2: 0x' + IntToHex(iUnk2, 4) + ' [' + IntToStr(iUnk2) + ']');
AddData(vtTmp, L2, 'Ref1: ' + RefIDToString(tUnk3));
AddData(vtTmp, L2, 'Ref2: ' + RefIDToString(tUnk4));
AddData(vtTmp, L2, 'Ref3: ' + RefIDToString(tUnk5));
AddData(vtTmp, L2, 'Unk6: 0x' + IntToHex(iUnk6, 4) + ' [' + IntToStr(iUnk6) + ']');
end;
L1 := AddData(vtTmp, Root, 'Array 6 (' + IntToStr(iArrayCount6) + ')');
for i := 0 to iArrayCount6 - 1 do
with yArray6[i] do
begin
L2 := AddData(vtTmp, L1, IntToStr(i));
AddData(vtTmp, L2, 'Unk: 0x' + IntToHex(iUnk1, 4) + ' [' + IntToStr(iUnk1) + ']');
AddData(vtTmp, L2, 'Flag: 0x' + IntToHex(iFlag, 4) + ' [' + IntToStr(iFlag) + ']' + ' bin ' + IntToBin(iFlag, 16));
AddData(vtTmp, L2, 'Ref: ' + RefIDToString(tRef));
end;
L1 := AddData(vtTmp, Root, 'Array 7 (' + IntToStr(iArrayCount7) + ')');
for i := 0 to iArrayCount7 - 1 do
with yArray7[i] do
begin
L2 := AddData(vtTmp, L1, IntToStr(i));
AddData(vtTmp, L2, 'Unk: 0x' + IntToHex(iUnk1, 4) + ' [' + IntToStr(iUnk1) + ']');
AddData(vtTmp, L2, 'Flag: 0x' + IntToHex(iFlag, 4) + ' [' + IntToStr(iFlag) + ']' + ' bin ' + IntToBin(iFlag, 16));
AddData(vtTmp, L2, 'Ref: ' + RefIDToString(tRef));
end;
L1 := AddData(vtTmp, Root, 'Array 8 (' + IntToStr(iArrayCount8) + ')');
for i := 0 to iArrayCount8 - 1 do
with yArray8[i] do
begin
L2 := AddData(vtTmp, L1, IntToStr(i));
AddData(vtTmp, L2, 'Unk: 0x' + IntToHex(iUnk1, 4) + ' [' + IntToStr(iUnk1) + ']');
AddData(vtTmp, L2, 'Flag: 0x' + IntToHex(iType, 4) + ' [' + IntToStr(iType) + ']' + ' bin ' + IntToBin(iType, 16));
AddData(vtTmp, L2, 'Ref: ' + RefIDToString(tRef));
AddData(vtTmp, L2, 'Count 1: ' + IntToStr(iCount1));
AddData(vtTmp, L2, 'Count 2: ' + IntToStr(iCount2));
L3 := AddData(vtTmp, L2, 'References (' + IntToStr(Length(yRef)) + ')');
for j := 0 to Length(yRef) - 1 do
AddData(vtTmp, L3, 'Ref [' + IntToStr(j) + ']: ' + RefIDToString(yRef[j]));
end;
L1 := AddData(vtTmp, Root, 'Array 9 (' + IntToStr(iArrayCount9) + ')');
for i := 0 to iArrayCount9 - 1 do
AddData(vtTmp, L1, IntToStr(i) + ': ' + IntToHex(yArray9[i], 8) + ' [' + IntToStr(yArray9[i]) + ']');
L1 := AddData(vtTmp, Root, 'Array 10 (' + IntToStr(iArrayCount10) + ')');
for i := 0 to iArrayCount10 - 1 do
with yArray10[i] do
begin
L2 := AddData(vtTmp, L1, IntToStr(i));
AddData(vtTmp, L2, 'Array Ref: ' + RefIDToString(tArrayRef));
L3 := AddData(vtTmp, L2, 'Array (' + IntToStr(iArrayCount) + ')');
for j := 0 to iArrayCount - 1 do
with yArray[j] do
begin
L4 := AddData(vtTmp, L3, IntToStr(j));
AddData(vtTmp, L4, 'Name: ' + sName);
L5 := AddData(vtTmp, L4, 'Data 1 (' + IntToStr(iCount1) + ')');
for k := 0 to iCount1 - 1 do
with yData1[k] do
begin
L6 := AddData(vtTmp, L5, IntToStr(k));
L7 := AddData(vtTmp, L6, 'Data (' + IntToStr(iCount) + ')');
for l := 0 to iCount - 1 do
with yData[l] do
begin
L8 := AddData(vtTmp, L7, IntToStr(l));
AddData(vtTmp, L8, 'Str: ' + GetStringReference(iStr, aPapyrus));
AddData(vtTmp, L8, 'Flag: 0x' + IntToHex(iFlag, 4) + ' [' + IntToStr(iFlag) + ']' + ' bin ' + IntToBin(iFlag, 16));
end;
end;
L5 := AddData(vtTmp, L4, 'Data 2 (' + IntToStr(iCount2) + ')');
for k := 0 to iCount2 - 1 do
with yData2[k] do
begin
L6 := AddData(vtTmp, L5, IntToStr(k));
AddData(vtTmp, L6, 'Unk: 0x' + IntToHex(iUnk, 4) + ' [' + IntToStr(iUnk) + ']' + ' bin ' + IntToBin(iUnk, 16));
AddData(vtTmp, L6, 'Flag: 0x' + IntToHex(iFlag, 4) + ' [' + IntToStr(iFlag) + ']' + ' bin ' + IntToBin(iFlag, 16));
AddData(vtTmp, L6, 'Ref: ' + RefIDToString(tRef));
end;
end;
end;
L1 := AddData(vtTmp, Root, 'Array 11 (' + IntToStr(iArrayCount11) + ')');
for i := 0 to iArrayCount11 - 1 do
with yArray11[i] do
begin
L2 := AddData(vtTmp, L1, IntToStr(i));
AddData(vtTmp, L2, 'Unk1: 0x' + IntToHex(iUnk1, 8) + ' [' + IntToStr(iUnk1) + ']');
AddData(vtTmp, L2, 'Ref: ' + RefIDToString(tRef));
AddData(vtTmp, L2, 'Unk2: 0x' + IntToHex(iUnk2, 2) + ' [' + IntToStr(iUnk2) + ']' + ' bin ' + IntToBin(iUnk2, 8));
end;
L1 := AddData(vtTmp, Root, 'Array 12 (' + IntToStr(iArrayCount12) + ')');
for i := 0 to iArrayCount12 - 1 do
with yArray12[i] do
begin
L2 := AddData(vtTmp, L1, IntToStr(i));
AddData(vtTmp, L2, 'Unk1: 0x' + IntToHex(iUnk1, 2) + ' [' + IntToStr(iUnk1) + ']' + ' bin ' + IntToBin(iUnk1, 8));
AddData(vtTmp, L2, 'Unk2: 0x' + IntToHex(iUnk2, 4) + ' [' + IntToStr(iUnk2) + ']');
L3 := AddData(vtTmp, L2, 'Elements (' + IntToStr(iCount) + ')');
for j := 0 to iCount - 1 do
with yData[j] do
begin
L4 := AddData(vtTmp, L3, IntToStr(j));
AddData(vtTmp, L4, 'Unk1: 0x' + IntToHex(iUnk1, 8) + ' [' + IntToStr(iUnk1) + ']');
AddData(vtTmp, L4, 'Unk2: 0x' + IntToHex(iUnk1, 2) + ' [' + IntToStr(iUnk2) + ']' + ' bin ' + IntToBin(iUnk2, 8));
AddData(vtTmp, L4, 'Str: ' + GetStringReference(iStr, aPapyrus));
AddData(vtTmp, L4, 'Unk3: 0x' + IntToHex(iUnk3, 4) + ' [' + IntToStr(iUnk3) + ']');
end;
end;
L1 := AddData(vtTmp, Root, 'Array 13 (' + IntToStr(iArrayCount13) + ')');
for i := 0 to iArrayCount13 - 1 do
with yArray13[i] do
begin
L2 := AddData(vtTmp, L1, IntToStr(i));
AddData(vtTmp, L2, 'Ref: ' + RefIDToString(tRef));
L3 := AddData(vtTmp, L2, 'Elements 1 (' + IntToStr(iCount1) + ')');
for j := 0 to iCount1 - 1 do
AddData(vtTmp, L3, '[' + IntToStr(j) + ']: 0x' + IntToHex(yData1[j], 8) + ' [' + IntToStr(yData1[j]) + ']');
L3 := AddData(vtTmp, L2, 'Elements 2 (' + IntToStr(iCount2) + ')');
for j := 0 to iCount2 - 1 do
AddData(vtTmp, L3, '[' + IntToStr(j) + ']: 0x' + IntToHex(yData2[j], 8) + ' [' + IntToStr(yData2[j]) + ']');
L3 := AddData(vtTmp, L2, 'Elements 3 (' + IntToStr(iCount3) + ')');
for j := 0 to iCount3 - 1 do
AddData(vtTmp, L3, '[' + IntToStr(j) + ']: 0x' + IntToHex(yData3[j], 8) + ' [' + IntToStr(yData3[j]) + ']');
AddData(vtTmp, L2, 'Unk: 0x' + IntToHex(iUnk, 2) + ' [' + IntToStr(iUnk) + ']');
end;
L1 := AddData(vtTmp, Root, 'Array 14 (' + IntToStr(iArrayCount14) + ')');
for i := 0 to iArrayCount14 - 1 do
AddData(vtTmp, L1, IntToStr(i) + ': ' + IntToHex(yArray14[i], 8) + ' [' + IntToStr(yArray14[i]) + ']');
AddData(vtTmp, Root, 'Array 15 (' + IntToStr(iArrayCount15) + ')');
if iOther <> 0 then
AddData(vtTmp, Root, 'Other not recognized bytes: ' + IntToStr(iOther));
Expanded[Root] := True;
finally
EndUpdate;
end;
end;
end; {$IF Defined(USEREGION)}{$ENDREGION}{$IFEND}
end.
|
unit uCounseling;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxGraphics, cxLookAndFeels, cxLookAndFeelPainters, Menus, StdCtrls,
cxButtons, cxControls, cxContainer, cxEdit, dxSkinsCore, dxSkinCaramel,
dxSkinOffice2007Blue, cxMaskEdit, cxDropDownEdit, cxCalendar, cxTextEdit,
cxGroupBox, cxCheckBox, DB, ADODB, uGlobal, dxSkinBlack, dxSkinBlue,
dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide, dxSkinFoggy, dxSkinGlassOceans,
dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky,
dxSkinMcSkin, dxSkinMoneyTwins, dxSkinOffice2007Black, dxSkinOffice2007Green,
dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinPumpkin, dxSkinSeven,
dxSkinSharp, dxSkinSilver, dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008,
dxSkinsDefaultPainters, dxSkinValentine, dxSkinXmas2008Blue, ExtCtrls;
type
TfrmCounseling = class(TForm)
cxGroupBox4: TcxGroupBox;
txtPatientName: TcxTextEdit;
cxGroupBox6: TcxGroupBox;
txtSexAge: TcxTextEdit;
cxGroupBox5: TcxGroupBox;
cxDateInDate: TcxDateEdit;
cxGroupBox1: TcxGroupBox;
txtDiag: TcxTextEdit;
cxGroupBox2: TcxGroupBox;
txtDoctor: TcxTextEdit;
cxGroupBox9: TcxGroupBox;
cxDateMeetingDate: TcxDateEdit;
cxGroupBox7: TcxGroupBox;
chkA1: TcxCheckBox;
chkA2: TcxCheckBox;
chkA3: TcxCheckBox;
chkA4: TcxCheckBox;
chkA5: TcxCheckBox;
cxGroupBox3: TcxGroupBox;
chkB1: TcxCheckBox;
chkB2: TcxCheckBox;
chkB3: TcxCheckBox;
chkB4: TcxCheckBox;
chkB5: TcxCheckBox;
cxGroupBox8: TcxGroupBox;
chkC1: TcxCheckBox;
chkC2: TcxCheckBox;
chkC3: TcxCheckBox;
cxGroupBox10: TcxGroupBox;
chkD1: TcxCheckBox;
chkD2: TcxCheckBox;
cxGroupBox11: TcxGroupBox;
chkE1: TcxCheckBox;
chkE2: TcxCheckBox;
chkE3: TcxCheckBox;
chkE4: TcxCheckBox;
cxGroupBox12: TcxGroupBox;
chkF1: TcxCheckBox;
chkF2: TcxCheckBox;
cxGroupBox21: TcxGroupBox;
memoWorkerOpinion: TMemo;
btnSave: TcxButton;
cxButton3: TcxButton;
Panel6: TPanel;
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure FormShow(Sender: TObject);
procedure memoWorkerOpinionKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure btnSaveClick(Sender: TObject);
private
{ Private declarations }
procedure SetControls;
public
{ Public declarations }
adoInOut: TADOQuery;
adoCounseling: TAdoQuery;
EditMode: TEditMode;
end;
var
frmCounseling: TfrmCounseling;
implementation
uses uConfig, uDB;
{$R *.dfm}
procedure TfrmCounseling.btnSaveClick(Sender: TObject);
var
nInOutID, nSeq: integer;
sMeetingDate: string;
begin
if not adoCounseling.Active then Exit;
nInOutID := adoInOut.FieldByName('InOutID').AsInteger;
sMeetingDate := cxDateMeetingDate.Text;
if oGlobal.isNullStr(sMeetingDate) then
begin
oGlobal.Msg('상담일을 선택하십시오!');
Exit;
end;
if ((EditMode = emAppend) and dbMain.isExistCounselingMeetingDate(nInOutID, sMeetingDate)) or
((EditMode = emUpdate) and (sMeetingDate <> adoCounseling.FieldByName('MeetingDate').AsString) and
dbMain.isExistCounselingMeetingDate(nInOutID, sMeetingDate)) then
begin
oGlobal.Msg('해당 입력일에 이미 입력된 상담이 있습니다!');
Exit;
end;
if oGlobal.YesNo('저장하시겠습니까?') <> mrYes then Exit;
adoCounseling.DisableControls;
try
adoCounseling.Connection.BeginTrans;
if EditMode = emAppend then
begin
adoCounseling.Append;
adoCounseling.FieldByName('InOutID').AsInteger := adoInOut.FieldByName('InOutID').AsInteger;
adoCounseling.FieldByName('Seq').AsInteger := dbMain.GetLastCounselingSeq(adoInOut.FieldByName('InOutID').AsInteger) + 1;
end
else
adoCounseling.Edit;
adoCounseling.FieldByName('A1').AsBoolean := chkA1.Checked;
adoCounseling.FieldByName('A2').AsBoolean := chkA2.Checked;
adoCounseling.FieldByName('A3').AsBoolean := chkA3.Checked;
adoCounseling.FieldByName('A4').AsBoolean := chkA4.Checked;
adoCounseling.FieldByName('A5').AsBoolean := chkA5.Checked;
adoCounseling.FieldByName('B1').AsBoolean := chkB1.Checked;
adoCounseling.FieldByName('B2').AsBoolean := chkB2.Checked;
adoCounseling.FieldByName('B3').AsBoolean := chkB3.Checked;
adoCounseling.FieldByName('B4').AsBoolean := chkB4.Checked;
adoCounseling.FieldByName('B5').AsBoolean := chkB5.Checked;
adoCounseling.FieldByName('C1').AsBoolean := chkC1.Checked;
adoCounseling.FieldByName('C2').AsBoolean := chkC2.Checked;
adoCounseling.FieldByName('C3').AsBoolean := chkC3.Checked;
adoCounseling.FieldByName('D1').AsBoolean := chkD1.Checked;
adoCounseling.FieldByName('D2').AsBoolean := chkD2.Checked;
adoCounseling.FieldByName('E1').AsBoolean := chkE1.Checked;
adoCounseling.FieldByName('E2').AsBoolean := chkE2.Checked;
adoCounseling.FieldByName('E3').AsBoolean := chkE3.Checked;
adoCounseling.FieldByName('E4').AsBoolean := chkE4.Checked;
adoCounseling.FieldByName('F1').AsBoolean := chkF1.Checked;
adoCounseling.FieldByName('F2').AsBoolean := chkF2.Checked;
adoCounseling.FieldByName('WorkerOpinion').AsString := Trim(memoWorkerOpinion.Lines.Text);
if oGlobal.isNotNullStr(cxdateMeetingDate.Text) then
adoCounseling.FieldByName('MeetingDate').AsString := oGlobal.DateToString(cxDateMeetingDate.Date);
adoCounseling.FieldByName('WriteDate').AsString := oGlobal.DateToString(now);
adoCounseling.FieldByName('Writer').AsString := oConfig.User.UserID;
adoCounseling.Post;
adoCounseling.Connection.CommitTrans;
oGlobal.Msg('저장하였습니다!');
ModalResult := mrOK;
except
adoCounseling.Cancel;
adoCounseling.Connection.RollbackTrans;
oGlobal.Msg('저장에 실패했습니다!');
end;
nSeq := adoCounseling.FieldByName('Seq').AsInteger;
adoCounseling.Close;
if dbMain.RemakeCounselingOrder(nInOutID) then
nSeq := dbMain.GetCounselingSeq(nInOutID, sMeetingDate);
adoCounseling.Tag := cDoing;
adoCounseling.Open;
adoCounseling.Locate('Seq', nSeq, [loCaseInsensitive]);
adoCounseling.EnableControls;
adoCounseling.Tag := cDone;
end;
procedure TfrmCounseling.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_ESCAPE then Close;
end;
procedure TfrmCounseling.FormShow(Sender: TObject);
begin
oGlobal.ClearComponents(self);
SetControls;
end;
procedure TfrmCounseling.memoWorkerOpinionKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
if (Sender is TMemo) then
begin
if (Key = VK_RETURN) then
dbMain.SetCurrentKeyword(TMemo(Sender))
else if Key = VK_F1 then
oGlobal.GetKeywordContent(TMemo(Sender));
end;
end;
procedure TfrmCounseling.SetControls;
begin
txtPatientName.Text := adoInOut.FieldByName('PatientName').AsString;
txtSexAge.Text := oGlobal.GetAge(adoInOut.FieldByName('Birthday').AsString, adoInOut.FieldByName('InDate').AsString);
if adoInOut.FieldByName('Sex').AsString = cMale then
txtSexAge.Text := '남 (만' + txtSexAge.Text + '세)'
else
txtSexAge.Text := '여 (만' + txtSexAge.Text + '세)';
txtDiag.Text := adoInOut.FieldByName('DiagName').AsString;
txtDoctor.Text := adoInOut.FieldByName('DoctorName').AsString;
cxDateInDate.EditText := adoInOut.FieldByName('InDate').AsString;
if EditMode = emAppend then Exit;
if oGlobal.isDateString(adoCounseling.FieldByName('MeetingDate').AsString) then
cxDateMeetingDate.EditValue := adoCounseling.FieldByName('MeetingDate').AsString;
chkA1.Checked := adoCounseling.FieldByName('A1').AsBoolean;
chkA2.Checked := adoCounseling.FieldByName('A2').AsBoolean;
chkA3.Checked := adoCounseling.FieldByName('A3').AsBoolean;
chkA4.Checked := adoCounseling.FieldByName('A4').AsBoolean;
chkA5.Checked := adoCounseling.FieldByName('A5').AsBoolean;
chkB1.Checked := adoCounseling.FieldByName('B1').AsBoolean;
chkB2.Checked := adoCounseling.FieldByName('B2').AsBoolean;
chkB3.Checked := adoCounseling.FieldByName('B3').AsBoolean;
chkB4.Checked := adoCounseling.FieldByName('B4').AsBoolean;
chkB5.Checked := adoCounseling.FieldByName('B5').AsBoolean;
chkC1.Checked := adoCounseling.FieldByName('C1').AsBoolean;
chkC2.Checked := adoCounseling.FieldByName('C2').AsBoolean;
chkC3.Checked := adoCounseling.FieldByName('C3').AsBoolean;
chkD1.Checked := adoCounseling.FieldByName('D1').AsBoolean;
chkD2.Checked := adoCounseling.FieldByName('D2').AsBoolean;
chkE1.Checked := adoCounseling.FieldByName('E1').AsBoolean;
chkE2.Checked := adoCounseling.FieldByName('E2').AsBoolean;
chkE3.Checked := adoCounseling.FieldByName('E3').AsBoolean;
chkE4.Checked := adoCounseling.FieldByName('E4').AsBoolean;
chkF1.Checked := adoCounseling.FieldByName('F1').AsBoolean;
chkF2.Checked := adoCounseling.FieldByName('F2').AsBoolean;
memoWorkerOpinion.Lines.Text := adoCounseling.FieldByName('WorkerOpinion').AsString;
end;
end.
|
unit gapistattypes;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
type
{ TGAPIStat }
TGAPIStat = class(TObject)
function GAPIName: string; virtual;
function Version: String; virtual;
function Vendor: String; virtual;
function VideoCard: String; virtual;
end;
implementation
{ TGAPIStat }
function TGAPIStat.GAPIName: string;
begin
Result:='';
end;
function TGAPIStat.Version: String;
begin
Result:='';
end;
function TGAPIStat.Vendor: String;
begin
Result:='';
end;
function TGAPIStat.VideoCard: String;
begin
Result:='';
end;
end.
|
// Lemmatizer API wrapper for Delphi programming language
// (c) by Elijah Koziev, Solarix Intellectronix Project
//
// API manual page:
// http://www.solarix.ru/for_developers/api/lemmatizator_api.shtml
//
// CD->14.04.2010
// LC->04.04.2011
unit LemmatizatorEngineApi;
interface
uses SysUtils;
{ http://www.solarix.ru/api/en/sol_LoadLemmatizator.shtml }
function sol_LoadLemmatizatorW( DbPath: PWideChar; Flags: Integer ): PInteger {HLEMMA}; stdcall; external 'lemmatizator.dll' name 'sol_LoadLemmatizatorW';
function sol_LoadLemmatizatorA( DbPath: PAnsiChar; Flags: Integer ): PInteger {HLEMMA}; stdcall; external 'lemmatizator.dll' name 'sol_LoadLemmatizatorA';
const LEME_DEFAULT: Integer = 0;
const LEME_FASTER: Integer = 1;
const LEME_FASTEST: Integer = 2;
{ http://www.solarix.ru/api/en/sol_DeleteLemmatizator.shtml }
function sol_DeleteLemmatizator( hEngine: PInteger ): integer; stdcall; external 'lemmatizator.dll' name 'sol_DeleteLemmatizator';
{ http://www.solarix.ru/api/en/sol_GetLemma.shtml }
function sol_GetLemmaW( hEngine: PInteger; Wordform: PWideChar; LemmaBuffer: PWideChar; LemmaBufferSize: Integer ): integer; stdcall; external 'lemmatizator.dll' name 'sol_GetLemmaW';
function sol_GetLemmaA( hEngine: PInteger; Wordform: PAnsiChar; LemmaBuffer: PAnsiChar; LemmaBufferSize: Integer ): integer; stdcall; external 'lemmatizator.dll' name 'sol_GetLemmaA';
{ http://www.solarix.ru/api/en/sol_GetLemmas.shtml }
function sol_GetLemmasW( hEngine: PInteger; word: PWideChar ): PInteger; stdcall; external 'lemmatizator.dll' name 'sol_GetLemmasW';
function sol_GetLemmasA( hEngine: PInteger; word: PAnsiChar ): PInteger; stdcall; external 'lemmatizator.dll' name 'sol_GetLemmasA';
{ http://www.solarix.ru/api/en/sol_CountLemmas.shtml }
function sol_CountLemmas( hList: PInteger ): integer; stdcall; external 'lemmatizator.dll' name 'sol_CountLemmas';
{ http://www.solarix.ru/api/en/sol_GetLemmaString.shtml }
function sol_GetLemmaStringW( hList: PInteger; Index: Integer; result: PWideChar; bufsize: Integer ): integer; stdcall; external 'lemmatizator.dll' name 'sol_GetLemmaStringW';
function sol_GetLemmaStringA( hList: PInteger; Index: Integer; result: PAnsiChar; bufsize: Integer ): integer; stdcall; external 'lemmatizator.dll' name 'sol_GetLemmaStringA';
{ http://www.solarix.ru/api/en/sol_DeleteLemmas.shtml }
function sol_DeleteLemmas( hList: PInteger ): integer; stdcall; external 'lemmatizator.dll' name 'sol_DeleteLemmas';
implementation
end.
|
unit ToDoControllerU;
interface
uses MVCFramework,
MVCFramework.Commons,
MVCFramework.Logger,
dorm, //this sample requires DORM
dorm.Mappings,
dorm.loggers,
Web.HTTPApp;
type
[MVCPath('/todo')]
TToDoController = class(TMVCController)
strict private
FdormSession: TSession;
private
function GetdormSession: dorm.TSession;
protected
property dormSession: dorm.TSession read GetdormSession;
public
[MVCPath]
[MVCHTTPMethod([httpGET])]
procedure GetAllToDo(ctx: TWebContext);
[MVCPath('/($todoid)')]
[MVCHTTPMethod([httpGET])]
procedure GetToDo(ctx: TWebContext);
[MVCPath]
[MVCHTTPMethod([httpPUT])]
procedure UpdateToDo(ctx: TWebContext);
destructor Destroy; override;
end;
implementation
uses MVCFramework.Serializer.Commons,
Generics.Collections,
dorm.ObjectStatus,
dorm.Utils,
dorm.Commons,
ToDoBO,
{$IF CompilerVersion <= 27}
DATA.DBXJSON,
{$ELSE}
System.JSON,
{$ENDIF}
System.SysUtils;
{ TApp1MainController }
destructor TToDoController.Destroy;
begin
FdormSession.Free;
inherited;
end;
procedure TToDoController.GetAllToDo(ctx: TWebContext);
var
ToDos: TObjectList<TToDo>;
begin
ToDos := dormSession.LoadList<TToDo>();
try
RenderListAsProperty<TToDo>('todos', ToDos, false);
finally
ToDos.Free;
end;
end;
function TToDoController.GetdormSession: dorm.TSession;
begin
if not Assigned(FdormSession) then
begin
FdormSession := TSession.CreateConfigured('dorm.conf',
// {$IFDEF TEST}TdormEnvironment.deTest{$ENDIF}
TdormEnvironment.deDevelopment
// {$IFDEF RELEASE}TdormEnvironment.deRelease{$ENDIF}
);
end;
Result := FdormSession;
end;
procedure TToDoController.GetToDo(ctx: TWebContext);
var
Todo: TToDo;
ID: Integer;
begin
ID := ctx.Request.Params['todoid'].ToInteger;
Todo := dormSession.Load<TToDo>(ID);
try
Render(Todo, false);
finally
Todo.Free;
end;
end;
procedure TToDoController.UpdateToDo(ctx: TWebContext);
var
ToDos: TObjectList<TToDo>;
begin
if not Context.Request.ThereIsRequestBody then
raise Exception.Create('Invalid request: Expected request body');
if Context.Request.BodyAsJSONObject = nil then
raise Exception.Create('Invalid request, Missing JSON object in parameter');
ToDos := Mapper.JSONArrayToObjectList<TToDo>(ctx.Request.BodyAsJSONObject.Get('todos')
.JsonValue as TJSONArray, false);
try
dormSession.PersistCollection(ToDos);
Render(200, 'update ok');
finally
ToDos.Free;
end;
end;
end.
|
unit ReverseClient;
{
Copyright (c) 2011+, HL7 and Health Intersections Pty Ltd (http://www.healthintersections.com.au)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
}
interface
uses
SysUtils, Classes,
AdvObjects,
IdCustomHttpServer, IdContext, IdHttp;
Const
SECURE_TOKEN_HEADER = 'X-Proxy-SSL-Token';
Type
TReverseProxyInfo = class(TAdvObject)
private
Fpath: String;
Ftarget: String;
public
Constructor Create(path, target : String);
function link : TReverseProxyInfo; overload;
property path : String read Fpath write Fpath;
property target : String read Ftarget write Ftarget;
end;
TReverseClient = class (TAdvObject)
private
Frequest: TIdHTTPRequestInfo;
Fresponse: TIdHTTPResponseInfo;
Fcontext: TIdContext;
Fproxy: TReverseProxyInfo;
FSecureToken: String;
procedure Setproxy(const Value: TReverseProxyInfo);
function getOutput : TStream;
public
destructor Destroy; override;
property proxy: TReverseProxyInfo read Fproxy write Setproxy;
property context: TIdContext read Fcontext write Fcontext;
property request: TIdHTTPRequestInfo read Frequest write Frequest;
property response: TIdHTTPResponseInfo read Fresponse write Fresponse;
property SecureToken : String read FSecureToken write FSecureToken;
procedure execute;
end;
implementation
{ TReverseProxyInfo }
constructor TReverseProxyInfo.Create(path, target: String);
begin
inherited create;
FPath := path;
FTarget := target;
end;
function TReverseProxyInfo.link: TReverseProxyInfo;
begin
result := TReverseProxyInfo(inherited Link);
end;
{ TReverseClient }
destructor TReverseClient.Destroy;
begin
Fproxy.Free;
inherited;
end;
procedure TReverseClient.Setproxy(const Value: TReverseProxyInfo);
begin
Fproxy.Free;
Fproxy := Value;
end;
procedure TReverseClient.execute;
var
client : TIdCustomHTTP;
url, s : String;
begin
client := TIdCustomHTTP.Create(nil);
try
client.HTTPOptions := [hoNoProtocolErrorException, hoNoParseMetaHTTPEquiv, hoWaitForUnexpectedData {$IFNDEF VER260} , hoNoReadMultipartMIME, hoNoParseXmlCharset, hoWantProtocolErrorContent{$ENDIF}];
client.Request.Accept := request.Accept;
client.Request.AcceptCharSet := request.AcceptCharSet;
client.Request.AcceptEncoding := request.AcceptEncoding;
client.Request.AcceptLanguage := request.AcceptLanguage;
client.Request.BasicAuthentication := request.BasicAuthentication;
client.Request.Host := request.Host;
client.Request.From := request.From;
client.Request.Password := request.Password;
client.Request.Referer := request.Referer;
client.Request.UserAgent := request.UserAgent;
client.Request.Username := request.Username;
client.Request.ProxyConnection := request.ProxyConnection;
client.Request.Range := request.Range;
client.Request.Ranges := request.Ranges;
client.Request.MethodOverride := request.MethodOverride;
client.Request.CacheControl := request.CacheControl;
client.Request.CharSet := request.CharSet;
client.Request.Connection := request.Connection;
client.Request.ContentDisposition := request.ContentDisposition;
client.Request.ContentEncoding := request.ContentEncoding;
client.Request.ContentLanguage := request.ContentLanguage;
client.Request.ContentLength := request.ContentLength;
client.Request.ContentRangeEnd := request.ContentRangeEnd;
client.Request.ContentRangeStart := request.ContentRangeStart;
client.Request.ContentRangeInstanceLength := request.ContentRangeInstanceLength;
client.Request.ContentRangeUnits := request.ContentRangeUnits;
client.Request.ContentType := request.ContentType;
client.Request.ContentVersion := request.ContentVersion;
client.Request.CustomHeaders := request.CustomHeaders;
client.Request.Date := request.Date;
client.Request.ETag := request.ETag;
client.Request.Expires := request.Expires;
client.Request.LastModified := request.LastModified;
client.Request.Pragma := request.Pragma;
client.Request.TransferEncoding := request.TransferEncoding;
for s in request.CustomHeaders do
client.Request.CustomHeaders.Add(s);
if SecureToken <> '' then
client.Request.CustomHeaders.Add(SECURE_TOKEN_HEADER+': '+SecureToken);
s := request.RawHTTPCommand;
s := s.Substring(s.IndexOf(' ')+1);
s := s.substring(0, s.IndexOf(' '));
url := proxy.FTarget + s.Substring(proxy.path.Length);
try
case request.CommandType of
hcHEAD: client.Head(url);
hcGET: client.Get(url, getOutput);
hcPOST: client.Post(url, request.PostStream, getOutput);
hcTRACE: client.Trace(url, getOutput);
{$IFDEF VER260}
hcDELETE: client.Delete(url);
hcPUT: client.Put(url, request.PostStream); // broken...
hcOPTION: client.Options(url);
{$ELSE}
hcDELETE: client.Delete(url, getOutput);
hcPUT: client.Put(url, request.PostStream, getOutput);
hcOPTION: client.Options(url, getOutput);
// todo: patch...
{$ENDIF}
end;
except
on e : Exception do
response.ContentText := e.message;
end;
if assigned(response.ContentStream) then
response.ContentStream.Position := 0;
{$IFNDEF VER260} response.AcceptPatch := client.response.AcceptPatch; {$ENDIF}
response.AcceptRanges := client.response.AcceptRanges;
response.Location := client.response.Location;
response.ProxyConnection := client.response.ProxyConnection;
response.ProxyAuthenticate := client.response.ProxyAuthenticate;
response.Server := client.response.Server;
response.WWWAuthenticate := client.response.WWWAuthenticate;
response.CacheControl := client.response.CacheControl;
response.CharSet := client.response.CharSet;
response.Connection := client.response.Connection;
response.ContentDisposition := client.response.ContentDisposition;
response.ContentEncoding := client.response.ContentEncoding;
response.ContentLanguage := client.response.ContentLanguage;
response.ContentLength := client.response.ContentLength;
response.ContentRangeEnd := client.response.ContentRangeEnd;
response.ContentRangeStart := client.response.ContentRangeStart;
response.ContentRangeInstanceLength := client.response.ContentRangeInstanceLength;
response.ContentRangeUnits := client.response.ContentRangeUnits;
response.ContentType := client.response.ContentType;
response.ContentVersion := client.response.ContentVersion;
response.CustomHeaders := client.response.CustomHeaders;
response.Date := client.response.Date;
response.ETag := client.response.ETag;
response.Expires := client.response.Expires;
response.LastModified := client.response.LastModified;
response.Pragma := client.response.Pragma;
response.TransferEncoding := client.response.TransferEncoding;
if client.CookieManager <> nil then
response.Cookies.AddCookies(client.CookieManager.CookieCollection);
response.ServerSoftware := client.response.Server;
response.ResponseText := client.response.ResponseText;
response.ResponseNo := client.response.ResponseCode;
for s in client.response.CustomHeaders do
response.CustomHeaders.Add(s);
// response.AuthRealm := client.Response.AuthRealm;
// response.ResponseNo := client.Response.ResponseNo;
// !
// procedure Redirect(const AURL: string);
// procedure WriteHeader;
// procedure WriteContent;
// //
// function ServeFile(AContext: TIdContext; const AFile: String): Int64; virtual;
// function SmartServeFile(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; const AFile: String): Int64;
// //
// property CloseConnection: Boolean read FCloseConnection write SetCloseConnection;
// property ContentStream: TStream read FContentStream write FContentStream;
// property ContentText: string read FContentText write FContentText;
// property FreeContentStream: Boolean read FFreeContentStream write FFreeContentStream;
// // writable for isapi compatibility. Use with care
// property HeaderHasBeenWritten: Boolean read FHeaderHasBeenWritten write FHeaderHasBeenWritten;
// property HTTPServer: TIdCustomHTTPServer read FHTTPServer;
// property Session: TIdHTTPSession read FSession;
//
// response
// !
// client.url := request.Document; // todo
//
// property Method: TIdHTTPMethod read FMethod write FMethod;
// property Source: TStream read FSourceStream write FSourceStream;
// property UseProxy: TIdHTTPConnectionType read FUseProxy;
// property IPVersion: TIdIPversion read FIPVersion write FIPVersion;
// property Destination: string read FDestination write FDestination;
finally
client.Free;
end;;
end;
function TReverseClient.getOutput: TStream;
begin
response.ContentStream := TMemoryStream.create;
response.FreeContentStream := true;
result := response.ContentStream;
end;
end.
|
// Editor.pas (Part of NoDaveDemo.dpr)
//
// A program demonstrating the functionality of the TNoDave component.
// This unit implements the editor-form for a connection.
//
// (C) 2005 Gebr. Schmid GmbH + Co., Freudenstadt, Germany
//
// Author: Axel Kinting (akinting@schmid-online.de)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
unit Editor;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Spin, IniFiles, ComCtrls;
type
TConnectionEditor = class(TForm)
Protocol: TComboBox;
MPILocal: TSpinEdit;
MPIRemote: TSpinEdit;
CPURack: TSpinEdit;
CPUSlot: TSpinEdit;
MPISpeed: TComboBox;
Timeout: TSpinEdit;
IPAddress: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
OK: TButton;
Cancel: TButton;
Connection: TEdit;
Description: TEdit;
Label11: TLabel;
Label12: TLabel;
Interval: TSpinEdit;
Label10: TLabel;
COMPort: TEdit;
procedure FormCreate(Sender: TObject);
procedure ProtocolChange(Sender: TObject);
procedure OKClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
public
IniFile: TIniFile;
procedure DelConnection(Name: String);
procedure SetConnection(Name: String);
end;
var
ConnectionEditor: TConnectionEditor;
implementation
{$R *.dfm}
procedure TConnectionEditor.DelConnection(Name: String);
begin
If Name <> '' then
begin
IniFile.DeleteKey('Connections', Name);
IniFile.EraseSection(Name);
end;
end;
procedure TConnectionEditor.SetConnection(Name: String);
begin
Connection.Text:=Name;
If Name = '' then
begin
Description.Text:='';
CPURack.Value:=0;
CPUSlot.Value:=2;
COMPort.Text:='';
IPAddress.Text:='';
Timeout.Value:=100;
Interval.Value:=1000;
MPISpeed.ItemIndex:=2;
MPILocal.Value:=1;
MPIRemote.Value:=2;
end else begin
Description.Text:=IniFile.ReadString('Connections', Name, '');
Protocol.ItemIndex:=IniFile.ReadInteger(Name, 'Protocol', 3);
CPURack.Value:=IniFile.ReadInteger(Name, 'CPURack', 0);
CPUSlot.Value:=IniFile.ReadInteger(Name, 'CPUSlot', 2);
COMPort.Text:=IniFile.ReadString(Name, 'COMPort', '');
IPAddress.Text:=IniFile.ReadString(Name, 'IPAddress', '');
Timeout.Value:=IniFile.ReadInteger(Name, 'Timeout', 100000) div 1000;
Interval.Value:=IniFile.ReadInteger(Name, 'Interval', 1000);
MPISpeed.ItemIndex:=IniFile.ReadInteger(Name, 'MPISpeed', 2);
MPILocal.Value:=IniFile.ReadInteger(Name, 'MPILocal', 1);
MPIRemote.Value:=IniFile.ReadInteger(Name, 'MPIRemote', 2);
end;
Connection.Enabled:=(Name = '');
ProtocolChange(Self);
end;
procedure TConnectionEditor.FormCreate(Sender: TObject);
begin
IniFile:=TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
end;
procedure TConnectionEditor.ProtocolChange(Sender: TObject);
begin
COMPort.Enabled:=(Protocol.ItemIndex in [0,1,2,3,4,9,10]);
IPAddress.Enabled:=(Protocol.ItemIndex in [5,6,7,8,11]);
Timeout.Enabled:=(Protocol.ItemIndex in [5,6,7,8,9,11]);
MPISpeed.Enabled:=(Protocol.ItemIndex in [0,1,2,3,4,7,8,11]);
MPILocal.Enabled:=(Protocol.ItemIndex in [0,1,2,3,4,7,8,11]);
MPIRemote.Enabled:=(Protocol.ItemIndex in [0,1,2,3,4,7,8,9,11]);
end;
procedure TConnectionEditor.OKClick(Sender: TObject);
var
Name: String;
begin
Name:=Connection.Text;
If Name <> '' then
begin
IniFile.WriteString('Connections', Name, Description.Text);
IniFile.WriteInteger(Name, 'Protocol', Protocol.ItemIndex);
IniFile.WriteInteger(Name, 'CPURack', CPURack.Value);
IniFile.WriteInteger(Name, 'CPUSlot', CPUSlot.Value);
IniFile.WriteString(Name, 'COMPort', COMPort.Text);
IniFile.WriteString(Name, 'IPAddress', IPAddress.Text);
IniFile.WriteInteger(Name, 'Timeout', Timeout.Value * 1000);
IniFile.WriteInteger(Name, 'Interval', Interval.Value);
IniFile.WriteInteger(Name, 'MPISpeed', MPISpeed.ItemIndex);
IniFile.WriteInteger(Name, 'MPILocal', MPILocal.Value);
IniFile.WriteInteger(Name, 'MPIRemote', MPIRemote.Value);
ModalResult:=mrOK;
end else ModalResult:=mrCancel;
end;
procedure TConnectionEditor.FormShow(Sender: TObject);
begin
If Connection.Enabled then Connection.SetFocus else Protocol.SetFocus;
end;
end.
// 16.03.2005 11:29:35 [C:\Programme\Borland\Delphi6\User\GsfExperts\NoDave\Demo\Delphi\Editor.pas] Projekt Version: 1.0.0.1
// Created ! |
unit PASDataLink;
{
VirtualDBScroll Package
The MIT License (MIT)
Copyright (c) 2014 Jack D Linke
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
}
{$mode objfpc}{$H+}
{$DEFINE dbgDBScroll}
interface
uses
Classes, SysUtils, db, DBGrids, LazLogger;
type
{ TPASDataLink }
TPASDataLink = class(TDataLink)
private
FDataSet : TDataSet;
FDataSetName : string;
FModified : Boolean;
FOnActiveChanged : TDatasetNotifyEvent;
FOnDatasetChanged : TDatasetNotifyEvent;
FOnDataSetClose : TDataSetNotifyEvent;
FOnDataSetOpen : TDataSetNotifyEvent;
FOnDataSetScrolled : TDataSetScrolledEvent;
FOnEditingChanged : TDataSetNotifyEvent;
FOnInvalidDataSet : TDataSetNotifyEvent;
FOnInvalidDataSource : TDataSetNotifyEvent;
FOnLayoutChanged : TDataSetNotifyEvent;
FOnNewDataSet : TDataSetNotifyEvent;
FOnRecordChanged : TFieldNotifyEvent;
FOnUpdateData : TDataSetNotifyEvent;
FOnDataSetInactive : TDataSetNotifyEvent;
FOnDataSetBrowse : TDataSetNotifyEvent;
FOnDataSetEdit : TDataSetNotifyEvent;
FOnDataSetInsert : TDataSetNotifyEvent;
FOnDataSetSetKey : TDataSetNotifyEvent;
FOnDataSetCalcField : TDataSetNotifyEvent;
FOnDataSetFilter : TDataSetNotifyEvent;
FOnDataSetNewValue : TDataSetNotifyEvent;
FOnDataSetOldValue : TDataSetNotifyEvent;
FOnDataSetCurValue : TDataSetNotifyEvent;
FOnDataSetBlockRead : TDataSetNotifyEvent;
FOnDataSetInternalCalc : TDataSetNotifyEvent;
FOnDataSetOpening : TDataSetNotifyEvent;
function GetDataSetName : string;
function GetFields(Index : Integer) : TField;
procedure SetDataSetName(const AValue : string);
protected
procedure RecordChanged(Field : TField); override;
procedure DataSetChanged; override;
procedure ActiveChanged; override;
procedure LayoutChanged; override;
procedure DataSetScrolled(Distance : Integer); override;
procedure FocusControl(Field : TFieldRef); override;
procedure CheckBrowseMode; override;
procedure EditingChanged; override;
procedure UpdateData; override;
function MoveBy(Distance : Integer) : Integer; override;
property Modified : Boolean read FModified write FModified;
public
property OnRecordChanged : TFieldNotifyEvent read FOnRecordChanged write FOnRecordChanged;
property OnDataSetInactive : TDataSetNotifyEvent read FOnDataSetInactive write FOnDataSetInactive;
property OnDataSetBrowse : TDataSetNotifyEvent read FOnDataSetBrowse write FOnDataSetBrowse;
property OnDataSetEdit : TDataSetNotifyEvent read FOnDataSetEdit write FOnDataSetEdit;
property OnDataSetInsert : TDataSetNotifyEvent read FOnDataSetInsert write FOnDataSetInsert;
property OnDataSetSetKey : TDataSetNotifyEvent read FOnDataSetSetKey write FOnDataSetSetKey;
property OnDataSetCalcField : TDataSetNotifyEvent read FOnDataSetCalcField write FOnDataSetCalcField;
property OnDataSetFilter : TDataSetNotifyEvent read FOnDataSetFilter write FOnDataSetFilter;
property OnDataSetNewValue : TDataSetNotifyEvent read FOnDataSetNewValue write FOnDataSetNewValue;
property OnDataSetOldValue : TDataSetNotifyEvent read FOnDataSetOldValue write FOnDataSetOldValue;
property OnDataSetCurValue : TDataSetNotifyEvent read FOnDataSetCurValue write FOnDataSetCurValue;
property OnDataSetBlockRead : TDataSetNotifyEvent read FOnDataSetBlockRead write FOnDataSetBlockRead;
property OnDataSetInternalCalc : TDataSetNotifyEvent read FOnDataSetInternalCalc write FOnDataSetInternalCalc;
property OnDataSetOpening : TDataSetNotifyEvent read FOnDataSetOpening write FOnDataSetOpening;
property OnDataSetChanged : TDatasetNotifyEvent read FOnDatasetChanged write FOnDataSetChanged;
property OnActiveChanged : TDatasetNotifyEvent read FOnActiveChanged write FOnActiveChanged;
property OnNewDataSet : TDataSetNotifyEvent read FOnNewDataSet write FOnNewDataSet;
property OnDataSetOpen : TDataSetNotifyEvent read FOnDataSetOpen write FOnDataSetOpen;
property OnInvalidDataSet : TDataSetNotifyEvent read FOnInvalidDataSet write FOnInvalidDataSet;
property OnInvalidDataSource : TDataSetNotifyEvent read FOnInvalidDataSource write FOnInvalidDataSource;
property OnLayoutChanged : TDataSetNotifyEvent read FOnLayoutChanged write FOnLayoutChanged;
property OnDataSetClose : TDataSetNotifyEvent read FOnDataSetClose write FOnDataSetClose;
property OnDataSetScrolled : TDataSetScrolledEvent read FOnDataSetScrolled write FOnDataSetScrolled;
property OnEditingChanged : TDataSetNotifyEvent read FOnEditingChanged write FOnEditingChanged;
property OnUpdateData : TDataSetNotifyEvent read FOnUpdateData write FOnUpdateData;
property DataSetName : string read GetDataSetName write SetDataSetName;
property Fields[Index : Integer] : TField read GetFields;
property VisualControl;
end;
implementation
{ TPASDataLink }
function TPASDataLink.GetDataSetName: string;
begin
Result := FDataSetName;
if DataSet <> nil then
begin
Result := DataSet.Name;
end;
end;
function TPASDataLink.GetFields(Index: Integer): TField;
begin
if (index >= 0) and (index < DataSet.FieldCount) then
begin
result := DataSet.Fields[index];
end;
end;
procedure TPASDataLink.SetDataSetName(const AValue: string);
begin
if FDataSetName <> AValue then
begin
FDataSetName := AValue;
end;
end;
procedure TPASDataLink.RecordChanged(Field: TField);
begin
{$ifdef dbgDBScroll} DebugLn(ClassName,'.RecordChanged'); {$endif}
if Assigned(OnRecordChanged) then
OnRecordChanged(Field);
end;
procedure TPASDataLink.DataSetChanged;
begin
{$ifdef dbgDBScroll} DebugLn(ClassName,'.DataSetChanged, FirstRecord=', DbgS(FirstRecord)); {$Endif}
if Assigned(OnDataSetChanged) then
OnDataSetChanged(DataSet);
case DataSet.State of
dsInactive : begin
if Assigned(OnDataSetInactive) then OnDataSetInactive(DataSet);
{$ifdef dbgDBScroll} DebugLn(ClassName,'.DataSetChanged, DataSet.State = dsInactive'); {$Endif}
end;
dsBrowse : begin
if Assigned(OnDataSetBrowse) then OnDataSetBrowse(DataSet);
{$ifdef dbgDBScroll} DebugLn(ClassName,'.DataSetChanged, DataSet.State = dsBrowse'); {$Endif}
end;
dsEdit : begin
if Assigned(OnDataSetEdit) then OnDataSetEdit(DataSet);
{$ifdef dbgDBScroll} DebugLn(ClassName,'.DataSetChanged, DataSet.State = dsEdit'); {$Endif}
end;
dsInsert : begin
if Assigned(OnDataSetInsert) then OnDataSetInsert(DataSet);
{$ifdef dbgDBScroll} DebugLn(ClassName,'.DataSetChanged, DataSet.State = dsInsert'); {$Endif}
end;
dsSetKey : begin
if Assigned(OnDataSetSetKey) then OnDataSetSetKey(DataSet);
{$ifdef dbgDBScroll} DebugLn(ClassName,'.DataSetChanged, DataSet.State = dsSetKey'); {$Endif}
end;
dsCalcFields : begin
if Assigned(OnDataSetCalcField) then OnDataSetCalcField(DataSet);
{$ifdef dbgDBScroll} DebugLn(ClassName,'.DataSetChanged, DataSet.State = dsCalcFields'); {$Endif}
end;
dsFilter : begin
if Assigned(OnDataSetFilter) then OnDataSetFilter(DataSet);
{$ifdef dbgDBScroll} DebugLn(ClassName,'.DataSetChanged, DataSet.State = dsFilter'); {$Endif}
end;
dsNewValue : begin
if Assigned(OnDataSetNewValue) then OnDataSetNewValue(DataSet);
{$ifdef dbgDBScroll} DebugLn(ClassName,'.DataSetChanged, DataSet.State = dsNewValue'); {$Endif}
end;
dsOldValue : begin
if Assigned(OnDataSetOldValue) then OnDataSetOldValue(DataSet);
{$ifdef dbgDBScroll} DebugLn(ClassName,'.DataSetChanged, DataSet.State = dsOldValue'); {$Endif}
end;
dsCurValue : begin
if Assigned(OnDataSetCurValue) then OnDataSetCurValue(DataSet);
{$ifdef dbgDBScroll} DebugLn(ClassName,'.DataSetChanged, DataSet.State = dsCurValue'); {$Endif}
end;
dsBlockRead : begin
if Assigned(OnDataSetBlockRead) then OnDataSetBlockRead(DataSet);
{$ifdef dbgDBScroll} DebugLn(ClassName,'.DataSetChanged, DataSet.State = dsBlockRead'); {$Endif}
end;
dsInternalCalc : begin
if Assigned(OnDataSetInternalCalc) then OnDataSetInternalCalc(DataSet);
{$ifdef dbgDBScroll} DebugLn(ClassName,'.DataSetChanged, DataSet.State = dsInternalCalc'); {$Endif}
end;
dsOpening : begin
if Assigned(OnDataSetOpening) then OnDataSetOpening(DataSet);
{$ifdef dbgDBScroll} DebugLn(ClassName,'.DataSetChanged, DataSet.State = dsOpening'); {$Endif}
end;
end;
end;
procedure TPASDataLink.ActiveChanged;
begin
{$ifdef dbgDBScroll} DebugLnEnter(ClassName, '.ActiveChanged INIT'); {$endif}
if Active then
begin
if Assigned(OnActiveChanged) then OnActiveChanged(DataSet);
FDataSet := DataSet;
if DataSetName <> FDataSetName then
begin
FDataSetName := DataSetName;
if Assigned(FOnNewDataSet) then
begin
FOnNewDataSet(DataSet);
end;
end else
if Assigned(FOnDataSetOpen) then
begin
FOnDataSetOpen(DataSet);
end;
end else
begin
if Assigned(OnActiveChanged) then OnActiveChanged(DataSet);
BufferCount := 0;
if (DataSource = nil) then
begin
if Assigned(FOnInvalidDataSource) then
begin
FOnInvalidDataSource(FDataSet);
end;
FDataSet := nil;
FDataSetName := '[???]';
end else
begin
if (DataSet=nil) or (csDestroying in DataSet.ComponentState) then
begin
if Assigned(FOnInvalidDataSet) then
begin
FOnInvalidDataSet(FDataSet);
end;
FDataSet := nil;
FDataSetName := '[???]';
end else
begin
if Assigned(FOnDataSetClose) then
begin
FOnDataSetClose(DataSet);
{$ifdef dbgDBScroll} DebugLn(ClassName, '.ActiveChanged OnDataSetClose Called'); {$endif}
end;
if DataSet <> nil then
begin
FDataSetName := DataSetName;
end;
end;
end;
end;
{$ifdef dbgDBScroll} DebugLnExit(ClassName, '.ActiveChanged DONE'); {$endif}
end;
procedure TPASDataLink.LayoutChanged;
begin
{$ifdef dbgDBScroll} DebugLnEnter(ClassName, '.LayoutChanged INIT'); {$Endif}
if Assigned(OnLayoutChanged) then
begin
OnLayoutChanged(DataSet);
end;
{$ifdef dbgDBScroll} DebugLnExit(ClassName, '.LayoutChanged DONE'); {$Endif}
end;
procedure TPASDataLink.DataSetScrolled(Distance: Integer);
begin
{$ifdef dbgDBScroll} DebugLn(ClassName, '.DataSetScrolled Distance=',IntToStr(Distance)); {$endif}
if Assigned(OnDataSetScrolled) then
OnDataSetScrolled(DataSet, Distance);
end;
procedure TPASDataLink.FocusControl(Field: TFieldRef);
begin
{$ifdef dbgDBScroll} DebugLn(ClassName, '.FocusControl'); {$endif}
end;
procedure TPASDataLink.CheckBrowseMode;
begin
{$ifdef dbgDBScroll} DebugLn(ClassName, '.CheckBrowseMode'); {$endif}
inherited CheckBrowseMode;
end;
procedure TPASDataLink.EditingChanged;
begin
{$ifdef dbgDBScroll} DebugLn(ClassName, '.EditingChanged'); {$endif}
if Assigned(OnEditingChanged) then
OnEditingChanged(DataSet);
end;
procedure TPASDataLink.UpdateData;
begin
{$ifdef dbgDBScroll} DebugLn(ClassName, '.UpdateData'); {$endif}
if Assigned(OnUpdatedata) then
OnUpdateData(DataSet);
end;
function TPASDataLink.MoveBy(Distance: Integer): Integer;
begin
{$ifdef dbgDBScroll} DebugLnEnter(ClassName, '.MoveBy INIT Distance=', IntToStr(Distance)); {$endif}
Result := inherited MoveBy(Distance);
{$ifdef dbgDBScroll} DebugLnExit(ClassName, '.MoveBy DONE'); {$endif}
end;
end.
|
unit uBaseballGame;
interface
uses uObserverPatternInterfaces
, Generics.Collections
, uGameInfo
;
type
TBaseballGame = class(TInterfacedObject, ISubject)
private
FHomeTeam: string;
FAwayTeam: string;
FGameInfo: TGameInfo;
FObserverList: TList<IObserver>;
procedure NotifyObservers;
procedure GameChanged;
public
constructor Create(aHomeTeam: string; aAwayTeam: string);
destructor Destroy; override;
procedure RegisterObserver(aObserver: IObserver);
procedure RemoveObserver(aObserver: IObserver);
procedure SetInning(aInningNumber: TInningNumber; aInning: TInning);
procedure SetRuns(aRuns: TRuns);
procedure SetHits(aHits: THits);
procedure SetErrors(aErrors: TErrors);
property GameInfo: TGameInfo read FGameInfo write FGameInfo;
property HomeTeam: string read FHomeTeam;
property AwayTeam: string read FAwayTeam;
end;
implementation
{ TBaseballGame }
constructor TBaseballGame.Create(aHomeTeam: string; aAwayTeam: string);
begin
inherited Create;
FObserverList := TList<IObserver>.Create;
FHomeTeam := aHomeTeam;
FAwayTeam := aAwayTeam;
end;
destructor TBaseballGame.Destroy;
begin
FObserverList.Free;
inherited;
end;
procedure TBaseballGame.GameChanged;
begin
NotifyObservers;
end;
procedure TBaseballGame.NotifyObservers;
var
Observer: IObserver;
begin
for Observer in FObserverList do
begin
Observer.Update(GameInfo);
end;
end;
procedure TBaseballGame.RegisterObserver(aObserver: IObserver);
begin
FObserverList.Add(aObserver);
end;
procedure TBaseballGame.RemoveObserver(aObserver: IObserver);
begin
FObserverList.Remove(aObserver);
end;
procedure TBaseballGame.SetErrors(aErrors: TErrors);
begin
FGameInfo.Errors.Home := aErrors.Home;
FGameInfo.Errors.Away := aErrors.Away;
end;
procedure TBaseballGame.SetHits(aHits: THits);
begin
FGameInfo.Hits.Home := aHits.Home;
FGameInfo.Hits.Away := aHits.Away;
end;
procedure TBaseballGame.SetInning(aInningNumber: TInningNumber; aInning: TInning);
begin
FGameInfo.Innings[aInningNumber].Top := aInning.Top;
FGameInfo.Innings[aInningNumber].Bottom := aInning.Bottom;
GameChanged;
end;
procedure TBaseballGame.SetRuns(aRuns: TRuns);
begin
FGameInfo.Runs.Home := aRuns.Home;
FGameInfo.Runs.Away := aRuns.Away;
end;
end.
|
unit Helper_registry;
interface
uses Registry, Windows, System.SysUtils;
procedure WriteStringValueRunReg(rKey, rValue: string);
procedure DeleteStringValueRunReg(rKey: string);
procedure WriteStringValueReg(rKey, rValue: string);
procedure WriteIntegerValueReg(rKey: string; rValue: integer);
function ReadStringValueReg(rKey: string): string;
function ReadIntegerValueReg(rKey: string): integer;
implementation
procedure WriteStringValueRunReg(rKey, rValue: string);
var
reg: TRegistry;
begin
reg:= TRegistry.Create(KEY_WRITE);
reg.RootKey:= HKEY_LOCAL_MACHINE;
reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run\', True);
try
reg.WriteString(rKey, rValue);
except
raise Exception.Create('Nepavyko išsaugoti web serverio nustatymų!');
end;
reg.CloseKey();
reg.Free;
end;
procedure DeleteStringValueRunReg(rKey: string);
var
reg: TRegistry;
begin
reg:= TRegistry.Create(KEY_WRITE);
reg.RootKey:= HKEY_LOCAL_MACHINE;
if reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run\', True) then
try
reg.DeleteValue(rKey);
finally
reg.CloseKey();
reg.Free;
end;
end;
procedure WriteStringValueReg(rKey, rValue: string);
var
reg: TRegistry;
begin
reg:= TRegistry.Create(KEY_WRITE);
reg.RootKey:= HKEY_CURRENT_USER;
{
if not reg.KeyExists('Software\ePoint\eKeitykla\Parameters\') then
reg.Access:= KEY_WRITE;
}
reg.OpenKey('Software\ePoint\eKeitykla\Parameters\', True);
try
//reg.Access:= KEY_WRITE;
reg.WriteString(rKey, rValue);
except
raise Exception.Create('Nepavyko išsaugoti nustatymų!');
end;
reg.CloseKey();
reg.Free;
end;
procedure WriteIntegerValueReg(rKey: string; rValue: integer);
var
reg: TRegistry;
begin
reg:= TRegistry.Create(KEY_WRITE);
reg.RootKey:= HKEY_CURRENT_USER;
{
if not reg.KeyExists('Software\ePoint\eKeitykla\Parameters\') then
reg.Access:= KEY_WRITE;
}
reg.OpenKey('Software\ePoint\eKeitykla\Parameters\', True);
try
//reg.Access:= KEY_WRITE;
reg.WriteInteger(rKey, rValue);
except
raise Exception.Create('Nepavyko išsaugoti nustatymų!');
end;
reg.CloseKey();
reg.Free;
end;
function ReadStringValueReg(rKey: string): string;
var
reg: TRegistry;
begin
reg:= TRegistry.Create(KEY_READ);
reg.RootKey:= HKEY_CURRENT_USER;
if not reg.KeyExists('Software\ePoint\eKeitykla\Parameters\') then
Exit
else
reg.OpenKey('Software\ePoint\eKeitykla\Parameters\', True);
Result:= reg.ReadString(rKey);
reg.CloseKey();
reg.Free;
end;
function ReadIntegerValueReg(rKey: string): integer;
var
reg: TRegistry;
begin
reg:= TRegistry.Create(KEY_READ);
reg.RootKey:= HKEY_CURRENT_USER;
if not reg.KeyExists('Software\ePoint\eKeitykla\Parameters\') then
Exit
else
reg.OpenKey('Software\ePoint\eKeitykla\Parameters\', True);
try
Result:= reg.ReadInteger(rKey);
except
on E: Exception do
begin
Result:= 0;
reg.CloseKey();
reg.Free;
end;
end;
end;
end.
|
unit uHackrf;
interface
const
SAMPLES_PER_BLOCK = 8192;
BYTES_PER_BLOCK = 16384;
MAX_SWEEP_RANGES = 10;
type
hackrf_error = (
HACKRF_SUCCESS = 0,
HACKRF_TRUE = 1,
HACKRF_ERROR_INVALID_PARAM = -2,
HACKRF_ERROR_NOT_FOUND = -5,
HACKRF_ERROR_BUSY = -6,
HACKRF_ERROR_NO_MEM = -11,
HACKRF_ERROR_LIBUSB = -1000,
HACKRF_ERROR_THREAD = -1001,
HACKRF_ERROR_STREAMING_THREAD_ERR = -1002,
HACKRF_ERROR_STREAMING_STOPPED = -1003,
HACKRF_ERROR_STREAMING_EXIT_CALLED = -1004,
HACKRF_ERROR_USB_API_VERSION = -1005,
HACKRF_ERROR_NOT_LAST_DEVICE = -2000,
HACKRF_ERROR_OTHER = -9999
);
hackrf_board_id = (
BOARD_ID_JELLYBEAN = 0,
BOARD_ID_JAWBREAKER = 1,
BOARD_ID_HACKRF_ONE = 2,
BOARD_ID_RAD1O = 3,
BOARD_ID_INVALID = $FF
);
hackrf_usb_board_id = (
USB_BOARD_ID_JAWBREAKER = $604B,
USB_BOARD_ID_HACKRF_ONE = $6089,
USB_BOARD_ID_RAD1O = $CC15,
USB_BOARD_ID_INVALID = $FFFF
);
rf_path_filter = (
RF_PATH_FILTER_BYPASS = 0,
RF_PATH_FILTER_LOW_PASS = 1,
RF_PATH_FILTER_HIGH_PASS = 2
);
operacake_ports = (
OPERACAKE_PA1 = 0,
OPERACAKE_PA2 = 1,
OPERACAKE_PA3 = 2,
OPERACAKE_PA4 = 3,
OPERACAKE_PB1 = 4,
OPERACAKE_PB2 = 5,
OPERACAKE_PB3 = 6,
OPERACAKE_PB4 = 7
);
sweep_style = (
LINEAR = 0,
INTERLEAVED = 1
);
phackrf_device = ^hackrf_device;
hackrf_device = record
end;
phackrf_transfer = ^hackrf_transfer;
hackrf_transfer = record
device: phackrf_device;
buffer: PByte;
buffer_length: Integer;
valid_length: Integer;
rx_ctx: Pointer;
tx_ctx: Pointer;
end;
pread_partid_serialno_t = ^read_partid_serialno_t;
read_partid_serialno_t = record
part_id: array[0..1]of UInt32;
serial_no: array[0..3]of UInt32;
end;
phackrf_device_list_t = ^hackrf_device_list_t;
hackrf_device_list_t = record
serial_numbers: PPAnsiChar;
usb_board_ids: ^hackrf_usb_board_id;
usb_device_index: PInteger;
devicecount: Integer;
usb_devices: PPointer;
usb_devicecount: Integer;
end;
hackrf_sample_block_cb_fn = function(transfer: phackrf_transfer): Integer; cdecl;
function hackrf_init(): Integer; cdecl;
function hackrf_exit(): Integer; cdecl;
function hackrf_library_version(): PAnsiChar; cdecl;
function hackrf_library_release(): PAnsiChar; cdecl;
function hackrf_device_list(): phackrf_device_list_t; cdecl;
function hackrf_device_list_open(list: phackrf_device_list_t; idx: Integer; var device: phackrf_device): Integer; cdecl;
procedure hackrf_device_list_free(list: phackrf_device_list_t); cdecl;
function hackrf_open(var device: phackrf_device): Integer; cdecl;
function hackrf_open_by_serial(const desired_serial_number: PAnsiChar; var device: phackrf_device): Integer; cdecl;
function hackrf_close(device: phackrf_device): Integer; cdecl;
function hackrf_start_rx(device: phackrf_device; callback: hackrf_sample_block_cb_fn; rx_ctx: Pointer): Integer; cdecl;
function hackrf_stop_rx(device: phackrf_device): Integer; cdecl;
function hackrf_start_tx(device: phackrf_device; callback: hackrf_sample_block_cb_fn; tx_ctx: Pointer): Integer; cdecl;
function hackrf_stop_tx(device: phackrf_device): Integer; cdecl;
(* return HACKRF_TRUE if success *)
function hackrf_is_streaming(device: phackrf_device): Integer; cdecl;
function hackrf_max2837_read(device: phackrf_device; register_number: Byte; value: PWord): Integer; cdecl;
function hackrf_max2837_write(device: phackrf_device; register_number: Byte; value: Word): Integer; cdecl;
function hackrf_si5351c_read(device: phackrf_device; register_number: Word; value: PWord): Integer; cdecl;
function hackrf_si5351c_write(device: phackrf_device; register_number: Word; value: Word): Integer; cdecl;
function hackrf_set_baseband_filter_bandwidth(device: phackrf_device; const bandwidth_hz: UInt32): Integer; cdecl;
function hackrf_rffc5071_read(device: phackrf_device; register_number: Word; value: PWord): Integer; cdecl;
function hackrf_rffc5071_write(device: phackrf_device; register_number: Word; value: Word): Integer; cdecl;
function hackrf_spiflash_erase(device: phackrf_device): Integer; cdecl;
function hackrf_spiflash_write(device: phackrf_device; const address: UInt32; const length: Word; const data: PByte): Integer; cdecl;
function hackrf_spiflash_read(device: phackrf_device; const address: UInt32; const length: Word; data: PByte): Integer; cdecl;
function hackrf_spiflash_status(device: phackrf_device; data: PByte): Integer; cdecl;
function hackrf_spiflash_clear_status(device: phackrf_device): Integer; cdecl;
(* device will need to be reset after hackrf_cpld_write *)
function hackrf_cpld_write(device: phackrf_device; const data: PByte; const total_length: UInt32): Integer; cdecl;
function hackrf_board_id_read(device: phackrf_device; value: PByte): Integer; cdecl;
function hackrf_version_string_read(device: phackrf_device; version: PAnsiChar; length: Byte): Integer; cdecl;
function hackrf_usb_api_version_read(device: phackrf_device; version: PWord): Integer; cdecl;
function hackrf_set_freq(device: phackrf_device; const freq_hz: UInt64): Integer; cdecl;
function hackrf_set_freq_explicit(device: phackrf_device; const if_freq_hz: UInt64;
const lo_freq_hz: UInt64; path: rf_path_filter): Integer; cdecl;
(* currently 8-20Mhz - either as a fraction, i.e. freq 20000000hz divider 2 -> 10Mhz or as plain old 10000000hz (double)
preferred rates are 8, 10, 12.5, 16, 20Mhz due to less jitter *)
function hackrf_set_sample_rate_manual(device: phackrf_device; const freq_hz: UInt32; const divider: UInt32): Integer; cdecl;
function hackrf_set_sample_rate(device: phackrf_device; const freq_hz: Double): Integer; cdecl;
(* external amp, bool on/off *)
function hackrf_set_amp_enable(device: phackrf_device; value: Byte): Integer; cdecl;
function hackrf_board_partid_serialno_read(device: phackrf_device; read_partid_serialno: pread_partid_serialno_t): Integer; cdecl;
(* range 0-40 step 8d, IF gain in osmosdr *)
function hackrf_set_lna_gain(device: phackrf_device; value: UInt32): Integer; cdecl;
(* range 0-62 step 2db, BB gain in osmosdr *)
function hackrf_set_vga_gain(device: phackrf_device; value: UInt32): Integer; cdecl;
(* range 0-47 step 1db *)
function hackrf_set_txvga_gain(device: phackrf_device; value: UInt32): Integer; cdecl;
(* antenna port power control *)
function hackrf_set_antenna_enable(device: phackrf_device; const value: Byte): Integer; cdecl;
function hackrf_error_name(errcode: hackrf_error): PAnsiChar; cdecl;
function hackrf_board_id_name(board_id: hackrf_board_id): PAnsiChar; cdecl;
function hackrf_usb_board_id_name(usb_board_id: hackrf_usb_board_id): PAnsiChar; cdecl;
function hackrf_filter_path_name(const path: rf_path_filter): PAnsiChar; cdecl;
(* Compute nearest freq for bw filter (manual filter) *)
function hackrf_compute_baseband_filter_bw_round_down_lt(const bandwidth_hz: UInt32): UInt32; cdecl;
(* Compute best default value depending on sample rate (auto filter) *)
function hackrf_compute_baseband_filter_bw(const bandwidth_hz: UInt32): UInt32; cdecl;
(* All features below require USB API version 0x1002 or higher) *)
(* set hardware sync mode *)
function hackrf_set_hw_sync_mode(device: phackrf_device; const value: Byte): Integer; cdecl;
(* Start sweep mode *)
function hackrf_init_sweep(device: phackrf_device; const frequency_list: PWord;
const num_ranges: Integer; const num_bytes: UInt32; const step_width: UInt32;
const offset: UInt32; const style: sweep_style): Integer; cdecl;
(* Operacake functions *)
function hackrf_get_operacake_boards(device: phackrf_device; boards: PByte): Integer; cdecl;
function hackrf_set_operacake_ports(device: phackrf_device; address: Byte;
port_a: Byte; port_b: Byte): Integer; cdecl;
function hackrf_reset(device: phackrf_device): Integer; cdecl;
function hackrf_set_operacake_ranges(device: phackrf_device; ranges: PByte; num_ranges: Byte): Integer; cdecl;
function hackrf_set_clkout_enable(device: phackrf_device; const value: Byte): Integer; cdecl;
function hackrf_operacake_gpio_test(device: phackrf_device; address: Byte; test_result: PWord): Integer; cdecl;
function hackrf_cpld_checksum(device: phackrf_device; crc: PUint32): Integer; cdecl;
implementation
const
HACKRF_DLL = 'hackrf.dll';
function hackrf_init; external HACKRF_DLL;
function hackrf_exit; external HACKRF_DLL;
function hackrf_library_version; external HACKRF_DLL;
function hackrf_library_release; external HACKRF_DLL;
function hackrf_device_list; external HACKRF_DLL;
function hackrf_device_list_open; external HACKRF_DLL;
procedure hackrf_device_list_free; external HACKRF_DLL;
function hackrf_open; external HACKRF_DLL;
function hackrf_open_by_serial; external HACKRF_DLL;
function hackrf_close; external HACKRF_DLL;
function hackrf_start_rx; external HACKRF_DLL;
function hackrf_stop_rx; external HACKRF_DLL;
function hackrf_start_tx; external HACKRF_DLL;
function hackrf_stop_tx; external HACKRF_DLL;
function hackrf_is_streaming; external HACKRF_DLL;
function hackrf_max2837_read; external HACKRF_DLL;
function hackrf_max2837_write; external HACKRF_DLL;
function hackrf_si5351c_read; external HACKRF_DLL;
function hackrf_si5351c_write; external HACKRF_DLL;
function hackrf_set_baseband_filter_bandwidth; external HACKRF_DLL;
function hackrf_rffc5071_read; external HACKRF_DLL;
function hackrf_rffc5071_write; external HACKRF_DLL;
function hackrf_spiflash_erase; external HACKRF_DLL;
function hackrf_spiflash_write; external HACKRF_DLL;
function hackrf_spiflash_read; external HACKRF_DLL;
function hackrf_spiflash_status; external HACKRF_DLL;
function hackrf_spiflash_clear_status; external HACKRF_DLL;
function hackrf_cpld_write; external HACKRF_DLL;
function hackrf_board_id_read; external HACKRF_DLL;
function hackrf_version_string_read; external HACKRF_DLL;
function hackrf_usb_api_version_read; external HACKRF_DLL;
function hackrf_set_freq; external HACKRF_DLL;
function hackrf_set_freq_explicit; external HACKRF_DLL;
function hackrf_set_sample_rate_manual; external HACKRF_DLL;
function hackrf_set_sample_rate; external HACKRF_DLL;
function hackrf_set_amp_enable; external HACKRF_DLL;
function hackrf_board_partid_serialno_read; external HACKRF_DLL;
function hackrf_set_lna_gain; external HACKRF_DLL;
function hackrf_set_vga_gain; external HACKRF_DLL;
function hackrf_set_txvga_gain; external HACKRF_DLL;
function hackrf_set_antenna_enable; external HACKRF_DLL;
function hackrf_error_name; external HACKRF_DLL;
function hackrf_board_id_name; external HACKRF_DLL;
function hackrf_usb_board_id_name; external HACKRF_DLL;
function hackrf_filter_path_name; external HACKRF_DLL;
function hackrf_compute_baseband_filter_bw_round_down_lt; external HACKRF_DLL;
function hackrf_compute_baseband_filter_bw; external HACKRF_DLL;
function hackrf_set_hw_sync_mode; external HACKRF_DLL;
function hackrf_init_sweep; external HACKRF_DLL;
function hackrf_get_operacake_boards; external HACKRF_DLL;
function hackrf_set_operacake_ports; external HACKRF_DLL;
function hackrf_reset; external HACKRF_DLL;
function hackrf_set_operacake_ranges; external HACKRF_DLL;
function hackrf_set_clkout_enable; external HACKRF_DLL;
function hackrf_operacake_gpio_test; external HACKRF_DLL;
function hackrf_cpld_checksum; external HACKRF_DLL;
end.
|
unit uModule;
interface
uses uInterfaces, ComObj, Windows, TntSysUtils, ObjComAuto, SysUtils, Variants;
const
IID_IOSManModule: TGUID = '{E5B171BA-F29C-45E2-BDDA-51F2C0651A5D}';
type
IOSManModule = interface(IUnknown)
['{E5B171BA-F29C-45E2-BDDA-51F2C0651A5D}']
function getClasses(out ClassNames: OleVariant; out ClassGUIDS: OleVariant): HResult; stdcall;
function createObjectByCLSID(ClassGUID: TGUID; out rslt: IDispatch): HResult; stdcall;
function Get_appRef: IDispatch; stdcall;
procedure Set_appRef(Value: IDispatch); stdcall;
property appRef: IDispatch read Get_appRef write Set_appRef;
end;
{$TYPEINFO ON}
{$METHODINFO ON}
{$WARNINGS OFF}
TOSManObject = class(TObjectDispatch, IOSManAll)
protected
function getModuleName: WideString;
public
constructor Create; reintroduce; virtual;
destructor Destroy; override;
published
function toString: WideString; virtual;
//class
function getClassName: WideString; virtual;
end;
{$WARNINGS ON}
{$METHODINFO OFF}
{$TYPEINFO OFF}
TOSManClass = class of TOSManObject;
TOSManModuleFunc = function(const osmanApp:IDispatch;const IID: TGUID; out Module: IUnknown): HResult; stdcall;
function OSManModule(const osmanApp:IDispatch;const IID: TGUID; out Module: IUnknown): HResult; stdcall;
procedure OSManRegister(myClass: TOSManClass; const myClassGUID: TGUID);
procedure OSManLog(const msg: WideString);
procedure AppAddRef();
procedure AppRelease();
exports OSManModule;
implementation
type
TOSManModule = class(TInterfacedObject, IOSManModule)
protected
function _AddRef: Integer;stdcall;
function _Release: Integer;stdcall;
procedure OnUnload();
function getClasses(out ClassNames: OleVariant; out ClassGUIDS: OleVariant): HResult; stdcall;
function createObjectByCLSID(ClassGUID: TGUID; out rslt: IDispatch): HResult; stdcall;
function Get_appRef: IDispatch; stdcall;
procedure Set_appRef(Value: IDispatch); stdcall;
property appRef: IDispatch read Get_appRef write Set_appRef;
public
destructor Destroy; override;
end;
TOSManRegInfo = record
name: WideString;
id: TGUID;
classRef: TOSManClass;
end;
var
regInfo: array of TOSManRegInfo;
gAppRef:IDispatch;
gModRef:TOSManModule;
AppRefCount:integer;
procedure AppAddRef();
begin
if (AppRefCount=0) and assigned(gAppRef) then
gAppRef._AddRef();
inc(AppRefCount);
end;
procedure AppRelease();
begin
dec(AppRefCount);
if (AppRefCount=0) and assigned(gAppRef) then
gAppRef._Release();
end;
procedure OSManLog(const msg: WideString);
begin
if Assigned(gAppRef) then Variant(gAppRef).log(msg);
end;
function OSManModule(const osmanApp:IDispatch;const IID: TGUID; out Module: IUnknown): HResult;
begin
result := E_NOINTERFACE;
if IsEqualGUID(IID, IID_IOSManModule) then begin
try
if assigned(gModRef) then
OSManLog('OSManModule: module already assigned')
else
gModRef:=TOSManModule.Create();
Module := gModRef;
(Module as IOSManModule).appRef:=osmanApp;
result := S_OK;
except
result := E_UNEXPECTED;
end;
end;
end;
procedure OSManRegister(myClass: TOSManClass; const myClassGUID: TGUID);
var
i: Integer;
begin
i := length(regInfo);
setLength(regInfo, i + 1);
regInfo[i].name := copy(myClass.ClassName(), 2, maxint);
regInfo[i].id := myClassGUID;
regInfo[i].classRef := myClass;
end;
{ TOSManModule }
function TOSManModule.createObjectByCLSID(ClassGUID: TGUID;
out rslt: IDispatch): HResult;
var
i: Integer;
begin
rslt := nil;
result := E_NOTIMPL;
try
for i := 0 to high(regInfo) do begin
if IsEqualGUID(ClassGUID, regInfo[i].id) then begin
rslt := regInfo[i].classRef.Create();
result := S_OK;
break;
end;
end;
except
rslt := nil;
result := E_UNEXPECTED;
end;
end;
destructor TOSManModule.Destroy;
begin
onUnload();
inherited;
end;
function TOSManModule.getClasses(out ClassNames,
ClassGUIDS: OleVariant): HResult;
var
i: Integer;
begin
ClassNames := VarArrayCreate([low(regInfo), high(regInfo)], varVariant);
ClassGUIDS := VarArrayCreate([low(regInfo), high(regInfo)], varVariant);
for i := 0 to high(regInfo) do begin
VarArrayPut(Variant(ClassNames), regInfo[i].name, [i]);
VarArrayPut(Variant(ClassGUIDS), WideString(GUIDToString(regInfo[i].id)), [i]);
end;
result := S_OK;
end;
function TOSManModule.Get_appRef: IDispatch;
begin
result:=gAppRef;
end;
procedure TOSManModule.OnUnload;
var
v:Variant;
begin
gModRef:=nil;
if assigned(gAppRef) then begin
v:=gAppRef;
v.onModuleUnload(self as IUnknown);
end;
end;
procedure TOSManModule.Set_appRef(Value: IDispatch);
begin
gAppRef:=Value;
end;
function TOSManModule._AddRef: Integer;
begin
result := inherited _AddRef;
end;
function TOSManModule._Release: Integer;
begin
result := inherited _Release;
end;
{ TOSManObject }
constructor TOSManObject.Create;
begin
AppAddRef();
inherited Create(self, false);
end;
destructor TOSManObject.Destroy;
begin
inherited;
AppRelease();
end;
function TOSManObject.getClassName: WideString;
begin
result := copy(ClassName, 2, maxint);
end;
function TOSManObject.getModuleName: WideString;
var
l: DWord;
pwc: PWideChar;
begin
getmem(pwc, sizeof(WideChar) * MAX_PATH);
try
l := getModuleFileNameW(HInstance, pwc, MAX_PATH);
if l = 0 then
raise EOleError.Create('TOSManObject.getModuleName: ' + sysErrorMessage(getLastError()));
result := WideChangeFileExt(wideExtractFileName(pwc), '');
finally
freemem(pwc);
end;
end;
function TOSManObject.toString: WideString;
begin
result := Format('%s.%s.%p', [getModuleName(), getClassName(), pointer(self)]);
end;
initialization
DecimalSeparator := '.';
AppRefCount:=0;
if(GetStdHandle(STD_ERROR_HANDLE)<>INVALID_HANDLE_VALUE) then
IsConsole:=true;
finalization
if assigned(gModRef) then begin
gModRef.OnUnload();
end;
end.
|
unit HEdit;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls,
Vcl.StdCtrls, Vcl.Buttons, Vcl.ExtCtrls, HolderEdits, AdoDB, Contnrs, Data.DB;
type
TfrmHEdit = class(TForm)
Panel3: TPanel;
LblAangemaakDoor: TLabel;
lblAangemaaktOp: TLabel;
btnCancel: TBitBtn;
btnSave: TBitBtn;
btnReset: TBitBtn;
pnlLabels: TPanel;
pnlFields: TPanel;
CurrQuery: TADOQuery;
procedure btnSaveClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
procedure btnResetClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormKeyPress(Sender: TObject; var Key: Char);
// procedure cyBitBtn1Click(Sender: TObject);
private
sFieldName: String;
sFieldValue: String;
ID: Integer;
CurrTable: TADOTable;
MasterKey: String;
TableObjectList: TObjectList;
procedure fillCmb(cmb:TComboBox; def:String);
procedure ReadControlPlacement;
procedure WriteControlPlacement;
protected
function getFieldName(edtField: TControl):String;
function getFieldValue(edtField: TControl):String;
procedure loadField(eField: TControl);
procedure saveField(eField:TControl);
procedure loadEditField(edtField:TEdit);
procedure loadComboField(comboField:TComboBox);
procedure loadCurrencyField(currField:THCurrencyEdit);
procedure loadDateField(dateField:TDateTimePicker);
procedure loadMemoField(memoField:TMeMo);
procedure loadDetails();
procedure loadDetailsTables();
procedure loadFields();
procedure saveEditField(edtField:TEdit);
procedure saveComboField(comboField:TComboBox);
procedure saveCurrencyField(currField:THCurrencyEdit);
procedure saveDateField(dateField:TDateTimePicker);
procedure saveMemoField(memoField:TMeMo);
procedure saveFields();
procedure cancelFields();
procedure BeforeLoad(); virtual;
procedure AfterLoad(); virtual;
public
constructor Create(Owner: TComponent; ID: Integer; AdoTable: TADOTable); overload;
constructor Create(Owner: TComponent; ID: Integer; AdoTable: TADOTable; Key: String); overload;
end;
var
frmHEdit: TfrmHEdit;
implementation
uses Main, DateUtils, inifiles;
{$R *.dfm}
{ TfrmEditAlgemeen }
constructor TfrmHEdit.Create(Owner: TComponent; ID: Integer;
AdoTable: TADOTable);
begin
inherited Create(Owner);
TableObjectList := TObjectList.Create;
CurrTable := AdoTable;
CurrQuery.Connection := CurrTable.Connection;
BeforeLoad();
Self.Id := Id;
if Id = 0 then begin
CurrTable.Insert;
loadFields();
end
else if Id = -1 then begin
end
else begin
CurrTable.Locate('ID', ID, []);
loadFields();
loadDetailsTables();
loadDetails();
CurrTable.Edit;
end;
AfterLoad();
btnReset.Visible := not(Id = 0);
end;
procedure TfrmHEdit.btnCancelClick(Sender: TObject);
begin
cancelFields();
end;
procedure TfrmHEdit.btnResetClick(Sender: TObject);
begin
CurrTable.Cancel;
loadFields();
loadDetailsTables();
loadDetails();
CurrTable.edit;
end;
procedure TfrmHEdit.btnSaveClick(Sender: TObject);
begin
saveFields();
end;
procedure TfrmHEdit.cancelFields;
var I: Integer;
begin
for I := 0 to TableObjectList.Count -1 do begin
try
TADOTable(TableObjectList.Items[I]).CancelBatch;
except
on E: Exception do
//
end;
end;
CurrTable.Cancel;
end;
constructor TfrmHEdit.Create(Owner: TComponent; ID: Integer;
AdoTable: TADOTable; Key: String);
begin
inherited Create(Owner);
TableObjectList := TObjectList.Create;
CurrTable := AdoTable;
CurrQuery.Connection := CurrTable.Connection;
BeforeLoad();
Self.Id := Id;
MasterKey := Key;
if Id = 0 then begin
CurrTable.Insert;
loadFields();
end
else begin
loadFields();
loadDetailsTables();
loadDetails();
CurrTable.Edit;
end;
AfterLoad();
btnReset.Visible := not(Id = 0);
end;
//procedure TfrmHEdit.cyBitBtn1Click(Sender: TObject);
//begin
//if not cyResizer1.Active
// then begin
// cyResizer1.Activate(pnlFields);
// self.Caption := 'Deactivate designing mode';
// end
// else begin
// cyResizer1.Deactivate;
// self.Caption := 'Activate designing mode';
// end;
//end;
procedure TfrmHEdit.fillCmb(cmb: TComboBox; def: String);
var I: Integer;
table:String;
field:String;
begin
table := cmb.Hint;
field := cmb.TextHint;
CurrQuery.SQL.Clear;
CurrQuery.SQL.Add('Select * from '+ table);
CurrQuery.ExecSQL;
CurrQuery.Open;
CurrQuery.First;
for I := 0 to CurrQuery.RecordCount -1 do begin
cmb.AddItem(CurrQuery.FieldByName(field).AsString, Pointer(CurrQuery.FieldByName('Id').AsInteger));
if(CurrQuery.FieldByName(field).AsString = def) then begin
cmb.ItemIndex := I;
end;
CurrQuery.Next;
end;
if cmb.ItemIndex = -1 then
cmb.ItemIndex := 0;
end;
procedure TfrmHEdit.WriteControlPlacement;
var
iniFile : TIniFile;
idx : integer;
ctrl : TControl;
begin
iniFile := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini')) ;
try
for idx := 0 to -1 + Self.ComponentCount do
begin
if Components[idx] is TControl then
begin
ctrl := TControl(Components[idx]) ;
iniFile.WriteInteger(ctrl.Name,'Top',ctrl.Top) ;
iniFile.WriteInteger(ctrl.Name,'Left',ctrl.Left) ;
iniFile.WriteInteger(ctrl.Name,'Width',ctrl.Width) ;
iniFile.WriteInteger(ctrl.Name,'Height',ctrl.Height) ;
if ctrl is TEdit then
iniFile.WriteString(ctrl.Name,'FieldName',ctrl.HelpKeyword) ;
end;
end;
finally
FreeAndNil(iniFile) ;
end;
end;
procedure TfrmHEdit.ReadControlPlacement;
var
iniFile : TIniFile;
idx : integer;
ctrl : TControl;
begin
iniFile := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini')) ;
try
for idx := 0 to -1 + Self.ComponentCount do
begin
if Components[idx] is TControl then
begin
ctrl := TControl(Components[idx]) ;
ctrl.Top := iniFile.ReadInteger(ctrl.Name,'Top',ctrl.Top) ;
ctrl.Left := iniFile.ReadInteger(ctrl.Name,'Left',ctrl.Left) ;
ctrl.Width := iniFile.ReadInteger(ctrl.Name,'Width',ctrl.Width) ;
ctrl.Height := iniFile.ReadInteger(ctrl.Name,'Height',ctrl.Height) ;
if ctrl is TEdit then
iniFile.WriteString(ctrl.Name,'FieldName',ctrl.HelpKeyword) ;
end;
end;
finally
FreeAndNil(iniFile) ;
end;
end; (*ReadControlPlacement*)
procedure TfrmHEdit.FormClose(Sender: TObject; var Action: TCloseAction);
begin
//WriteControlPlacement;
end;
procedure TfrmHEdit.FormCreate(Sender: TObject);
begin
//ReadControlPlacement;
// cyRunTimeResize1.Control := Self;
end;
procedure TfrmHEdit.FormKeyPress(Sender: TObject; var Key: Char);
begin
if key = #27 then begin
CurrTable.Cancel;
Close
end;
end;
function TfrmHEdit.getFieldName(edtField: TControl): String;
var
edt: TEdit;
curr: THCurrencyEdit;
combo: TComboBox;
begin
if edtField is TEdit then begin
edt := TEdit(edtField);
Result := edt.HelpKeyword;
end
else if edtField is THCurrencyEdit then begin
curr := THCurrencyEdit(edtField);
Result := curr.HelpKeyword;
end
else if edtField is TComboBox then begin
combo := TComboBox(edtField);
Result := combo.HelpKeyword;
end;
end;
function TfrmHEdit.getFieldValue(edtField: TControl): String;
var
value: String;
edt: TEdit;
curr: THCurrencyEdit;
combo: TComboBox;
begin
if edtField is TEdit then begin
edt := TEdit(edtField);
value := edt.HelpKeyword;
end
else if edtField is THCurrencyEdit then begin
curr := THCurrencyEdit(edtField);
value := curr.HelpKeyword;
end
else if edtField is TComboBox then begin
combo := TComboBox(edtField);
value := combo.HelpKeyword;
end;
end;
procedure TfrmHEdit.loadComboField(comboField: TComboBox);
var
value: String;
begin
value := CurrTable.FieldByName(comboField.HelpKeyword).AsString;
fillCmb(comboField, value);
end;
procedure TfrmHEdit.loadCurrencyField(currField: THCurrencyEdit);
var
value: Double;
begin
value := CurrTable.FieldByName(currField.HelpKeyword).AsFloat;
currField.Value := value;
end;
procedure TfrmHEdit.loadDateField(dateField: TDateTimePicker);
var
value: TDateTime;
begin
value := CurrTable.FieldByName(dateField.HelpKeyword).AsDateTime;
if DateToStr(value) = '30-12-1899' then
value := Date;
dateField.Date := value;
end;
procedure TfrmHEdit.loadDetails;
var I: Integer;
begin
for I := 0 to TableObjectList.Count -1 do begin
TADOTable(TableObjectList.Items[I]).Filtered := False;
TADOTable(TableObjectList.Items[I]).Filter := Masterkey+ '= '+ IntToStr(Id);
TADOTable(TableObjectList.Items[I]).Filtered := True;
end;
// verder vullen bij kind
// frameDagen.lvwItems.Clear;
end;
procedure TfrmHEdit.loadDetailsTables;
begin
//vullen bij kind
// TDagen := TfrmMain.GetTableDagen;
// TableObjectList.Add(TDagen);
// frameDagen.FTable := TDagen;
end;
procedure TfrmHEdit.loadEditField(edtField: TEdit);
var
value: String;
begin
value := CurrTable.FieldByName(edtField.HelpKeyword).AsString;
edtField.Text := value;
end;
procedure TfrmHEdit.loadField(eField: TControl);
begin
if not(eField.Visible) then
exit;
if eField is TEdit then begin
loadEditField(TEdit(eField));
end
else if eField is THCurrencyEdit then begin
loadCurrencyField(THCurrencyEdit(eField));
end
else if eField is TComboBox then begin
loadComboField(TComboBox(eField));
end
else if eField is TDateTimePicker then begin
loadDateField(TDateTimePicker(eField));
end
else if eField is TMemo then begin
loadMemoField(TMemo(eField));
end;
end;
procedure TfrmHEdit.loadFields;
var I: Integer;
begin
for I := 0 to pnlFields.ControlCount - 1 do begin
loadField(pnlFields.Controls[I]);
end;
if not(CurrTable.FindField('AangemaaktDoor') = nil) then begin
LblAangemaakDoor.Caption := 'Aangemaakt door: ' + CurrTable.FieldByName('AangemaaktDoor').AsString ;
lblAangemaaktOp.Caption := 'Aangemaakt op: ' + CurrTable.FieldByName('AangemaaktOp').AsString;
end;
end;
procedure TfrmHEdit.loadMemoField(memoField: TMeMo);
var
value: String;
begin
value := CurrTable.FieldByName(memoField.HelpKeyword).AsString;
memoField.Lines.Text := value;
end;
procedure TfrmHEdit.AfterLoad;
begin
end;
procedure TfrmHEdit.BeforeLoad;
begin
end;
procedure TfrmHEdit.saveComboField(comboField: TComboBox);
var
field: String;
begin
field := comboField.HelpKeyword;
CurrTable.FieldByName(field).AsString := comboField.Text;
end;
procedure TfrmHEdit.saveCurrencyField(currField: THCurrencyEdit);
var
field: String;
begin
field := currField.HelpKeyword;
CurrTable.FieldByName(field).AsCurrency := currField.Value;
end;
procedure TfrmHEdit.saveDateField(dateField: TDateTimePicker);
var
field: String;
begin
field := dateField.HelpKeyword;
CurrTable.FieldByName(field).AsDateTime := dateField.DateTime;
if not(CurrTable.FindField('Dag') = nil) then begin
CurrTable.FieldByName('Dag').AsInteger := DayOfTheMonth(dateField.Date);
CurrTable.FieldByName('Maand').AsInteger := MonthOfTheYear(dateField.Date) ;
CurrTable.FieldByName('Jaar').AsFloat := YearOf(dateField.Date) ;
end;
end;
procedure TfrmHEdit.saveEditField(edtField: TEdit);
var
field: String;
begin
field := edtField.HelpKeyword;
CurrTable.FieldByName(field).AsString := edtField.Text;
end;
procedure TfrmHEdit.saveField(eField: TControl);
begin
if eField is TEdit then begin
saveEditField(TEdit(eField));
end
else if eField is THCurrencyEdit then begin
saveCurrencyField(THCurrencyEdit(eField));
end
else if eField is TComboBox then begin
saveComboField(TComboBox(eField));
end
else if eField is TDateTimePicker then begin
saveDateField(TDateTimePicker(eField));
end
else if eField is TMemo then begin
saveMemoField(TMemo(eField));
end;
end;
procedure TfrmHEdit.saveFields;
var I: Integer;
begin
for I := 0 to pnlFields.ControlCount - 1 do begin
saveField(pnlFields.Controls[I]);
end;
if not(CurrTable.FindField('AangemaaktDoor') = nil) then begin
if CurrTable.FieldByName('AangemaaktDoor').AsString = '' then begin
CurrTable.FieldByName('AangemaaktDoor').AsString := TfrmMain(Owner).user;
CurrTable.FieldByName('AangemaaktOp').AsDateTime := Date;
end;
end;
CurrTable.Post;
for I := 0 to TableObjectList.Count -1 do begin
TADOTable(TableObjectList.Items[I]).UpdateBatch;
end;
CurrTable.UpdateBatch;
end;
procedure TfrmHEdit.saveMemoField(memoField: TMeMo);
var
field: String;
begin
field := memoField.HelpKeyword;
CurrTable.FieldByName(field).AsString := memoField.Lines.Text;
end;
end.
|
{
List used entry points from perk records
Handly when you want to create a new perk in xEdit and need an example on how to use a particular entry point
}
unit ListPerkEntryPoints;
var
sl: TStringList;
function Initialize: integer;
begin
sl := TStringList.Create;
end;
function Process(e: IInterface): integer;
var
effects, effect: IInterface;
i: integer;
entry: string;
begin
if Signature(e) <> 'PERK' then
Exit;
effects := ElementByName(e, 'Effects');
for i := 0 to Pred(ElementCount(effects)) do begin
effect := ElementByIndex(effects, i);
if GetElementEditValues(effect, 'PRKE\Type') <> 'Entry Point' then
Continue;
entry := GetElementEditValues(effect, 'DATA\Entry Point\Entry Point');
sl.Values[entry] := sl.Values[entry] + #13#10 + Name(e);
end;
end;
function Finalize: integer;
var
i, j: integer;
lst: TStringList;
begin
if sl.Count <> 0 then begin
sl.Sort;
lst := TStringList.Create;
lst.Sorted := True;
lst.Duplicates := dupIgnore;
for i := 0 to Pred(sl.Count) do begin
AddMessage(sl.Names[i]);
lst.Text := sl.ValueFromIndex[i];
for j := 0 to Pred(lst.Count) do
if lst[j] <> '' then
AddMessage(' ' + lst[j]);
end;
lst.Free;
end;
sl.Free;
end;
end.
|
unit XTexObject;
interface
{ Wrapper class for OpenGL texture objects. Call Upload() to bind the image to
the texture object, then call Enable() or use glBindTexture() to enable the
texture. }
uses
CgTexture, GL;
type
TTexObject = class
public
Image: TCGTexture;
TexObject: Cardinal;
constructor Create;
destructor Destroy; override;
procedure Enable;
procedure Disable;
procedure Upload;
end;
implementation
constructor TTexObject.Create;
begin
inherited Create;
glGenTextures(1, @TexObject);
glBindTexture(GL_TEXTURE_2D, TexObject);
Image := TCGTexture.Create;
end;
destructor TTexObject.Destroy;
begin
glDeleteTextures(1, @TexObject);
inherited Destroy;
end;
procedure TTexObject.Disable;
begin
glBindTexture(GL_TEXTURE_2D, 0);
end;
procedure TTexObject.Enable;
begin
glBindTexture(GL_TEXTURE_2D, TexObject);
end;
procedure TTexObject.Upload;
begin
Image.HTile := TRUE;
Image.VTile := TRUE;
Image.Enable;
Disable;
end;
end.
|
unit InfraAspectIntf;
interface
uses
Classes,
InfraCommonIntf;
type
IInfraAspect = interface(IElement)
['{F0B6338B-4CA5-4142-9C2E-571F976AFC59}']
function Around(const Sender: IElement;
const Params: IInterfaceList): IInterface;
function Proceed: IInterface;
procedure After(const Sender: IElement; const Params: IInterfaceList);
procedure Before(const Sender: IElement; const Params: IInterfaceList);
end;
// A intercepted application's point
IInfraJointPoint = interface(IInterface)
['{E4EF3225-8558-4E70-A1A2-31312AFB5651}']
function GetAspectClass: TClass;
function GetMethodInfo: IMethodInfo;
function GetMethodIndex: Integer;
function GetParamsCount: Integer;
procedure SetAspectClass(Value: TClass);
procedure SetMethodInfo(const Value: IMethodInfo);
procedure SetMethodIndex(Value: integer);
// Aspect to be executed when program come in JoinPoint
property AspectClass: TClass read GetAspectClass write SetAspectClass;
// TypeInfo of Intercepted Method
property MethodInfo: IMethodInfo read GetMethodInfo write SetMethodInfo;
// Index of Stub Method on array of stubs
property MethodIndex: integer read GetMethodIndex write SetMethodIndex;
// Method's parameters Quatity
property ParamsCount: integer read GetParamsCount;
end;
// list of joint points
IInfraJointPoints = interface(IInterface)
['{18FE6D1B-6C49-4AD4-AD83-11A98E2406EF}']
function Add(const Item: IInfraJointPoint): Integer;
function NewIterator: IInfraIterator;
function First: IInfraJointPoint;
function GetCount: Integer;
function GetItem(Index: Integer): IInfraJointPoint;
function Last: IInfraJointPoint;
function IndexOf(const Item: IInfraJointPoint): Integer;
procedure SetItem(Index: Integer; const Value: IInfraJointPoint);
property Count: Integer read GetCount;
property Items[Index: Integer]: IInfraJointPoint read GetItem
write SetItem; default;
end;
IAspectPointcutEval = interface
['{072D8133-AC1D-422E-AD44-82C97F668542}']
function Evaluate(const TextToMatch, Expression: string): Boolean;
end;
// A item of stack that hold context between call advices
IInterceptedStackItem = interface
['{3227229C-0AE8-4CE6-B818-0C81C4CFFECE}']
function GetAspect: IInfraAspect;
function GetInstance: Pointer;
function GetJointPoint: IInfraJointPoint;
function GetRealMethodInfo: IMethodInfo;
function GetParams: IInterfaceList;
procedure SetAspect(const Value: IInfraAspect);
procedure SetInstance(const Value: Pointer);
procedure SetJointPoint(const Value: IInfraJointPoint);
procedure SetParams(const Value: IInterfaceList);
property Aspect: IInfraAspect read GetAspect write SetAspect;
property Instance: Pointer read GetInstance write SetInstance;
property JointPoint: IInfraJointPoint read GetJointPoint
write SetJointPoint;
property RealMethodInfo: IMethodInfo read GetRealMethodInfo;
property Params: IInterfaceList read GetParams write SetParams;
end;
// A stack to hold aspect context between call advices
IInterceptedStack = interface
['{AD375F4E-95C4-41B8-914A-DE3781D69A2E}']
function AtLeast(ACount: Integer): Boolean;
function GetCount: Integer;
function Peek: IInterceptedStackItem;
function Pop: IInterceptedStackItem;
function Push(AItem: IInterceptedStackItem): IInterceptedStackItem;
function NewIterator: IInfraIterator;
function NewInverseIterator: IInfraIterator;
property Count: Integer read GetCount;
end;
{ Service to mantain the intercepted joint points and execute the
aspects so that the program's flow reach some these joint points }
IInfraAspectService = interface(IBaseElement)
['{F1C7615D-BE6A-4638-ADF4-34528CB0CE9E}']
// Find and Register a Aspect to all Joint Points matching with Expression
procedure AddPointCut(const Expression: string; pAspectClass: TClass);
function GetJointPoints: IInfraJointPoints;
function Proceed: IInterface;
function CallAdvices(const pJointPoint: IInfraJointPoint;
pInstance: Pointer; const pParams: IInterfaceList): IInterface;
property JointPoints: IInfraJointPoints read GetJointPoints;
end;
function AspectService: IInfraAspectService;
implementation
function AspectService: IInfraAspectService;
begin
result := ApplicationContext as IInfraAspectService;
end;
end.
|
{ *******************************************************************************
Title: T2Ti ERP
Description: DataModule
The MIT License
Copyright: Copyright (C) 2015 T2Ti.COM
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
The author may be contacted at:
t2ti.com@gmail.com</p>
@author Albert Eije (t2ti.com@gmail.com)
@version 2.0
******************************************************************************* }
unit UDataModule;
interface
uses
SysUtils, Classes, DB, DBClient, Provider, ImgList, Controls, JvDataSource,
JvDBGridExport, JvComponentBase, Dialogs, JvPageList, Variants, Tipos,
Graphics,
ACBrBase, JvBaseDlg,
JvBrowseFolder, ACBrSpedFiscal, ACBrDFe,
ACBrSATExtratoClass, ACBrSATExtratoFortes, ACBrSATExtratoFortesFr, ACBrSAT;
type
TFDataModule = class(TDataModule)
ACBrSAT: TACBrSAT;
ACBrSATExtratoFortes: TACBrSATExtratoFortes;
procedure ACBrSATGetsignAC(var Chave: AnsiString);
procedure ACBrSATGetcodigoDeAtivacao(var Chave: AnsiString);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FDataModule: TFDataModule;
implementation
{$R *.dfm}
{ TFDataModule }
procedure TFDataModule.ACBrSATGetcodigoDeAtivacao(var Chave: AnsiString);
begin
Chave := '12345678';
end;
procedure TFDataModule.ACBrSATGetsignAC(var Chave: AnsiString);
begin
Chave := 'eije11111111111111111111111111111111111111111111111111111111111'+
'111111111111111111111111111111111111111111111111111111111111111'+
'111111111111111111111111111111111111111111111111111111111111111'+
'111111111111111111111111111111111111111111111111111111111111111'+
'111111111111111111111111111111111111111111111111111111111111111'+
'11111111111111111111111111111';
end;
end.
|
Unit Fields;
Interface
uses OpCrt;
Type FldRec=Record
FID,
XPos,
YPos,
FG,
BG,
Up,
Dn,
Lf,
Rt,
Enter,
Len:Byte;
Fld,
Hlp:String;
End;
Const MaxFields=50;
Type FieldArr=Array[1..MaxFields] Of FldRec;
Var Field:^FieldArr;
FieldCnt:Byte;
Procedure AddField(I,X,Y,F,B,U,D,L,R,Ent,Ln:Byte; Fd,H:String);
Procedure EditFields;
Implementation
Procedure BackSpace(X,Y,Int:Integer);
Var I:Integer;
Begin
GotoXY(X,Y);
For I:=1 to Int do Write(' ');
For I:=Int downto 1 do Write(^H);
End;
Function Edit(Var S:String; X,Y,F,B,Len:Byte; MultiFields:Boolean):Char;
Var Done,InsertMode:Boolean;
Ch:Char;
Holder:String;
CurPos:Integer;
Procedure StripEndSpaces;
Var Index:Byte;
Begin
Index:=Length(S);
While S[Index]=' ' Do
Begin
Delete(S,Index,1);
Dec(Index);
End;
End;
Procedure UpdateToEOL;
Var I:Byte;
Begin
For I:=CurPos To Length(S) Do Write(S[I]);
For I:=Length(S) To Len-1 Do Write(' ');
End;
Procedure Update;
Var I:Byte;
Begin
For I:=CurPos To Length(S) Do Write(S[I]);
End;
Procedure Back_Space;
Begin
If (CurPos>1) Then
Begin
Dec(CurPos);
Delete(S,CurPos,1);
Write(^H+' '+^H);
Update; Write(' ');
End;
End;
Procedure DelChar;
Begin
Delete(S,CurPos,1);
UpDate; Write(' ');
End;
Procedure UpDateCursorPos;
Begin
If CurPos<1 Then CurPos:=1;
If CurPos>Len Then CurPos:=Len;
GotoXY(CurPos+(X-1),Y);
End;
Procedure ClearLine;
Begin
CurPos:=1;
UpDateCursorPos; S:='';
UpDateToEOL;
End;
Procedure Typer;
Begin
If Length(S)<>Len Then
Begin
If InsertMode Then
Begin
Insert(Ch,S,CurPos);
Update;
End
Else
Begin
Write(Ch);
S[CurPos]:=Ch;
End;
If CurPos>=Length(S) Then S[0]:=Chr(CurPos);
Inc(CurPos);
End;
End;
Procedure ExitCode(C:Char);
Begin
Done:=True;
Edit:=C;
End;
Begin
Done:=False; InsertMode:=True;
Holder:=S;
CurPos:=1;
GotoXY(X,Y); TextColor(F);
TextBackGround(B);
UpdateToEol;
CurPos:=Length(S)+1;
UpdateCursorPos;
Repeat
Ch:=ReadKey;
If Ch=#0 Then
Begin
Ch:=ReadKey;
Case UpCase(Ch) Of
#80:ExitCode(#80); (*Up*)
#72:ExitCode(#72); (*Down*)
#71:CurPos:=1; (*Home*)
#75:Dec(CurPos); (*Left*)
#77:Inc(CurPos); (*Right*)
#79:CurPos:=Length(S)+1; (*End*)
#83:DelChar;
End;
End
Else
Case Ch Of
#1:CurPos:=1; (*Home*)
#8:Back_Space;
#13:ExitCode(#13);
#26:CurPos:=Length(S)+1; (*End*)
^Q:ExitCode(^Q);
^S:Dec(CurPos); (*Left*)
^D:Inc(CurPos); (*Right*)
^V,#82:InsertMode:=Not InsertMode;
^Y:ClearLine;
Else Typer;
End;
UpdateCursorPos;
Until (Done);
StripEndSpaces;
TextColor(7);
TextBackGround(0);
BackSpace(X,Y,Len);
Write(S);
End;
Procedure AddField(I,X,Y,F,B,U,D,L,R,Ent,Ln:Byte; Fd,H:String);
Begin
With Field^[I] Do
Begin
FID:=I;
XPos:=X;
YPos:=Y;
FG:=F;
BG:=B;
Up:=U;
Dn:=D;
Lf:=L;
Rt:=R;
Enter:=Ent;
Len:=Ln;
Fld:=Fd;
Hlp:=H;
End;
End;
Procedure EditFields;
Var C:Char;
CurField:Byte;
Quit:Boolean;
Begin
CurField:=1;
Quit:=False;
Repeat
With Field^[CurField] Do C:=Edit(Fld,Xpos,Ypos,Fg,Bg,Len,True);
Case C Of
#80:CurField:=Field^[CurField].Dn;
#72:CurField:=Field^[CurField].Up;
#77:CurField:=Field^[CurField].Rt;
#75:CurField:=Field^[CurField].Lf;
^Q:Quit:=Not Quit;
#13:CurField:=Field^[CurField].Enter;
End;
Until Quit;
End;
Begin
End. |
{$include kode.inc}
unit kode_widget_text;
//----------------------------------------------------------------------
interface
//----------------------------------------------------------------------
uses
kode_canvas,
kode_color,
kode_flags,
kode_rect,
kode_widget;
type
KWidget_Text = class(KWidget)
protected
FText : PChar;
FTextAlign : LongInt;
FTextColor : KColor;
FBackColor : KColor;
public
property _text : PChar read FText write FText;
public
constructor create(ARect:KRect; AText:PChar; AAlignment:LongWord=kwa_none);
constructor create(ARect:KRect; AText:PChar; ATextColor,ABackColor:KColor; AAlignment:LongWord=kwa_none);
destructor destroy; override;
public
procedure on_paint(ACanvas:KCanvas; ARect:KRect; AMode:LongWord=0); override;
end;
//----------------------------------------------------------------------
implementation
//----------------------------------------------------------------------
constructor KWidget_Text.create(ARect:KRect; AText:PChar; AAlignment:LongWord=kwa_none);
begin
inherited create(ARect,AAlignment);
FName := 'KWidget_Text';
FText := AText;
FTextAlign := kta_center;
FTextColor := KDarkGrey;
FBackColor := KLightGrey;
FCursor := kmc_Ibeam;
clearFlag(kwf_opaque);
end;
//----------
constructor KWidget_Text.create(ARect:KRect; AText:PChar; ATextColor,ABackColor:KColor; AAlignment:LongWord=kwa_none);
begin
create(ARect,AText,AAlignment);
FTextColor := ATextColor;
FBackColor := ABackColor;
end;
destructor KWidget_Text.destroy;
begin
inherited;
end;
//----------
procedure KWidget_Text.on_paint(ACanvas:KCanvas; ARect:KRect; AMode:LongWord=0);
begin
inherited;
ACanvas.setFillColor(FBackColor);
ACanvas.fillRect(FRect.x,FRect.y,FRect.x2,FRect.y2);
ACanvas.setTextColor(FTextColor);
ACanvas.drawText(FRect.x,FRect.y,FRect.x2,FRect.y2,FText,FTextAlign);
end;
//----------------------------------------------------------------------
end.
|
unit ACBrLFDDll;
{$mode delphi}
interface
uses
Classes, SysUtils,
ACBrLFD,
ACBrLFDBlocosDll,
ACBrLFDBlocos,
ACBrLFDBloco_0;
type TEventHandlers = class
OnErrorCallback : TStringCallback;
procedure OnError(const MsnError: AnsiString);
end;
{Handle para o componente TACBrSPEDFiscal}
type TLFDHandle = record
UltimoErro : String;
LFD : TACBrLFD;
EventHandlers : TEventHandlers;
end;
{Ponteiro para o Handle }
type PTFDHandle = ^TLFDHandle;
implementation
{%region Create/Destroy/Erro}
{
PADRONIZAÇÃO DAS FUNÇÕES:
PARÂMETROS:
Todas as funções recebem o parâmetro "handle" que é o ponteiro
para o componente instanciado; Este ponteiro deve ser armazenado
pela aplicação que utiliza a DLL;
RETORNO:
Todas as funções da biblioteca retornam um Integer com as possíveis Respostas:
MAIOR OU IGUAL A ZERO: SUCESSO
Outos retornos maior que zero indicam sucesso, com valor específico de cada função.
MENOR QUE ZERO: ERROS
-1 : Erro ao executar;
Vide UltimoErro
-2 : ACBr não inicializado.
Outros retornos negativos indicam erro específico de cada função;
A função "UltimoErro" retornará a mensagem da última exception disparada pelo componente.
}
{
CRIA um novo componente TACBrLFD retornando o ponteiro para o objeto criado.
Este ponteiro deve ser armazenado pela aplicação que utiliza a DLL e informado
em todas as chamadas de função relativas ao TACBrPAF.
}
Function LFD_Create(var lfdHandle: PTFDHandle): Integer; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
New(lfdHandle);
try
lfdHandle^.LFD := TACBrLFD.Create(nil);
lfdHandle^.EventHandlers := TEventHandlers.Create();
lfdHandle^.UltimoErro:= '';
Result := 0;
except
on exception : Exception do
begin
Result := -1;
lfdHandle^.UltimoErro := exception.Message;
end
end;
end;
{
DESTRÓI o objeto TACBrLFD e libera a memória utilizada.
Esta função deve SEMPRE ser chamada pela aplicação que utiliza a DLL
quando o componente não mais for utilizado.
}
Function LFD_Destroy(lfdHandle: PTFDHandle): Integer; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
lfdHandle^.LFD.Destroy();
lfdHandle^.LFD := nil;
Dispose(lfdHandle);
lfdHandle := nil;
Result := 0;
except
on exception : Exception do
begin
Result := -1;
lfdHandle^.UltimoErro := exception.Message;
end
end;
end;
Function LFD_GetUltimoErro(const lfdHandle: PTFDHandle; Buffer : pChar; const BufferLen : Integer) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
try
StrPLCopy(Buffer, lfdHandle^.UltimoErro, BufferLen);
Result := length(lfdHandle^.UltimoErro);
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
{%endregion}
{%region Funções mapeando as propriedades do componente }
Function LFD_GetAbout(const lfdHandle: PTFDHandle; Buffer : pChar; const BufferLen : Integer) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
var
StrTmp : String;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
StrTmp := lfdHandle^.LFD.About;
StrPLCopy(Buffer, StrTmp, BufferLen);
Result := length(StrTmp);
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_GetArquivo(const lfdHandle: PTFDHandle; Buffer : pChar; const BufferLen : Integer) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
var
StrTmp : String;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
StrTmp := lfdHandle^.LFD.Arquivo;
StrPLCopy(Buffer, StrTmp, BufferLen);
Result := length(StrTmp);
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_SetArquivo(const lfdHandle: PTFDHandle; Const Arquivo : pChar) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
lfdHandle^.LFD.Arquivo := Arquivo;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_GetCurMascara(const lfdHandle: PTFDHandle; Buffer : pChar; const BufferLen : Integer) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
var
StrTmp : String;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
StrTmp := lfdHandle^.LFD.CurMascara;
StrPLCopy(Buffer, StrTmp, BufferLen);
Result := length(StrTmp);
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_SetCurMascara(const lfdHandle: PTFDHandle; Const CurMascara : pChar) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
lfdHandle^.LFD.CurMascara := CurMascara;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_GetPath(const lfdHandle: PTFDHandle; Buffer : pChar; const BufferLen : Integer) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
var
StrTmp : String;
begin
if (LFDHandle = nil) then
begin
Result := -2;
Exit;
end;
try
StrTmp := lfdHandle^.LFD.Path;
StrPLCopy(Buffer, StrTmp, BufferLen);
Result := length(StrTmp);
except
on exception : Exception do
begin
LFDHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_SetPath(const lfdHandle: PTFDHandle; Const Path : pChar) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
lfdHandle^.LFD.Path := Path;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_GetDelimitador(const lfdHandle: PTFDHandle; Buffer : pChar; const BufferLen : Integer) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
var
StrTmp : String;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
StrTmp := lfdHandle^.LFD.Delimitador;
StrPLCopy(Buffer, StrTmp, BufferLen);
Result := length(StrTmp);
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_SetDelimitador(const lfdHandle: PTFDHandle; Const Delimitador : pChar) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
lfdHandle^.LFD.Delimitador := Delimitador;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_GetLinhasBuffer(const lfdHandle: PTFDHandle) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (LFDHandle = nil) then
begin
Result := -2;
Exit;
end;
try
Result := lfdHandle^.LFD.LinhasBuffer;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_SetLinhasBuffer(const lfdHandle: PTFDHandle; const Linhas: Integer) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (LFDHandle = nil) then
begin
Result := -2;
Exit;
end;
try
lfdHandle^.LFD.LinhasBuffer := Linhas;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_GetTrimString(const lfdHandle: PTFDHandle) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
if lfdHandle^.LFD.TrimString then
Result := 1
else
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_SetTrimString(const lfdHandle: PTFDHandle; const TrimString: Boolean) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
lfdHandle^.LFD.TrimString := TrimString;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
{%endregion}
{%region Funções mapeando as propriedades do componente não visiveis}
Function LFD_GetDT_INI(const lfdHandle: PTFDHandle; var Data : Double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
Data := Double(lfdHandle^.LFD.DT_INI);
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_SetDT_INI(const lfdHandle: PTFDHandle; const Data : Double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
lfdHandle^.LFD.DT_INI := Data;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_GetDT_FIN(const lfdHandle: PTFDHandle; var Data : Double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
Data := Double(lfdHandle^.LFD.DT_FIN);
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_SetDT_FIN(const lfdHandle: PTFDHandle; const Data : Double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
lfdHandle^.LFD.DT_FIN := Data;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
{%endregion}
{%region Methods }
Function LFD_IniciaGeracao(const lfdHandle: PTFDHandle) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
lfdHandle^.LFD.IniciaGeracao;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_SaveFileTXT(const lfdHandle: PTFDHandle) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
lfdHandle^.LFD.SaveFileTXT;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
{%endregion}
{%region Eventos }
procedure TEventHandlers.OnError(const MsnError: AnsiString);
begin
OnErrorCallback(pchar(MsnError));
end;
{%endregion Eventos }
{%region Set Eventos }
Function LFD_SetOnError(const lfdHandle: PTFDHandle; const method : TStringCallback) : Integer; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
if Assigned(method) then
begin
lfdHandle^.LFD.OnError := lfdHandle^.EventHandlers.OnError;
lfdHandle^.EventHandlers.OnErrorCallback := method;
Result := 0;
end
else
begin
lfdHandle^.LFD.OnError := nil;
lfdHandle^.EventHandlers.OnErrorCallback := nil;
Result := 0;
end;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
{%endregion Set Eventos }
{%region Bloco0}
Function LFD_Bloco_0_GetDT_INI(const lfdHandle: PTFDHandle; var dtIni : double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
dtIni := Double(lfdHandle^.LFD.Bloco_0.DT_INI);
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_0_SetDT_INI(const lfdHandle: PTFDHandle; const dtIni : double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
lfdHandle^.LFD.Bloco_0.DT_INI := TDateTime(dtIni);
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_0_GetDT_FIN(const lfdHandle: PTFDHandle; var dtFin : double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
dtFin := Double(lfdHandle^.LFD.Bloco_0.DT_FIN);
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_0_SetDT_FIN(const lfdHandle: PTFDHandle; const dtFin : double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
lfdHandle^.LFD.Bloco_0.DT_FIN := TDateTime(dtFin);
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_0_GetGravado(const lfdHandle: PTFDHandle) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
if lfdHandle^.LFD.Bloco_0.Gravado then
Result := 1
else
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_0_Registro0000New(const lfdHandle: PTFDHandle; const registro0000 : Bloco0Registro0000) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_0.Registro0000New do
BEGIN
COD_VER := TACBrLVersaoLeiaute(registro0000.COD_VER);
COD_FIN := TACBrLCodFinalidade(registro0000.COD_FIN);
DT_INI := TDateTime(registro0000.DT_INI);
DT_FIN := TDateTime(registro0000.DT_FIN);
NOME := registro0000.NOME;
CNPJ := registro0000.CNPJ;
UF := registro0000.UF;
IE := registro0000.IE;
COD_MUN := registro0000.COD_MUN;
IM := registro0000.IM;
SUFRAMA := registro0000.SUFRAMA;
COD_CONTEUDO := TACBrConteudoArquivo(registro0000.COD_CONTEUDO);
FANTASIA := registro0000.FANTASIA;
NIRE := registro0000.NIRE;
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_0_Registro0001New(const lfdHandle: PTFDHandle; const registro0001 : Bloco0Registro0001) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_0.Registro0001New do
begin
IND_MOV:= TACBrLIndicadorMovimento(registro0001.IND_MOV);
COD_MUN:= registro0001.COD_MUN;
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_0_Registro0005New(const lfdHandle: PTFDHandle; const registro0005 : Bloco0Registro0005) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_0.Registro0005New do
begin
NOMERESP := registro0005.NOMERESP;
COD_ASS := registro0005.COD_ASS;
CPFRESP := registro0005.CPFRESP;
CEP := registro0005.CEP;
ENDERECO := registro0005.ENDERECO;
NUM := registro0005.NUM;
COMPL := registro0005.COMPL;
BAIRRO := registro0005.BAIRRO;
CEP_CP := registro0005.CEP_CP;
CP := registro0005.CP;
FONE := registro0005.FONE;
FAX := registro0005.FAX;
EMAIL := registro0005.EMAIL;
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_0_Registro0025New(const lfdHandle: PTFDHandle; const registro0025 : Bloco0Registro0025) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_0.Registro0025New do
begin
CODBF_ICMS := TACBrCODBFICMS(registro0025.CODBF_ICMS);
CODBF_ISS := TACBrCODBFISS(registro0025.CODBF_ISS);
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_0_Registro0100New(const lfdHandle: PTFDHandle; const registro0100 : Bloco0Registro0100) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_0.Registro0100New do
begin
NOME := registro0100.NOME;
CPF := registro0100.CPF;
CRC := registro0100.CRC;
CNPJ := registro0100.CNPJ;
CEP := registro0100.CEP;
CEP_CF := registro0100.CEP_CP;
CP := registro0100.CP;
ENDERECO := registro0100.ENDERECO;
NUM := registro0100.NUM;
COMPL := registro0100.COMPL;
BAIRRO := registro0100.BAIRRO;
UF := registro0100.UF;
FONE := registro0100.FONE;
FAX := registro0100.FAX;
EMAIL := registro0100.EMAIL;
COD_MUN := registro0100.COD_MUN;
COD_ASS := registro0100.COD_ASS[0];
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_0_Registro0150New(const lfdHandle: PTFDHandle; const registro0150 : Bloco0Registro0150) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_0.Registro0150New do
begin
COD_PART := registro0150.COD_PART;
NOME := registro0150.NOME;
COD_PAIS := registro0150.COD_PAIS;
CNPJ := registro0150.CNPJ;
CPF := registro0150.CPF;
IE_ST := registro0150.IE_ST;
IE := registro0150.IE;
IM := registro0150.IM;
COD_MUN := registro0150.COD_MUN;
SUFRAMA := registro0150.SUFRAMA;
ENDERECO := registro0150.ENDERECO;
NUM := registro0150.NUM;
COMPL := registro0150.COMPL;
BAIRRO := registro0150.BAIRRO;
UF := registro0150.UF;
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_0_Registro0175New(const lfdHandle: PTFDHandle; const registro0175 : Bloco0Registro0175) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_0.Registro0175New do
begin
CEP := registro0175.CEP;
ENDERECO := registro0175.ENDERECO;
NUM := registro0175.NUM;
COMPL := registro0175.COMPL;
BAIRRO := registro0175.BAIRRO;
CEP_CP := registro0175.CEP_CP;
CP := registro0175.CP;
FONE := registro0175.FONE;
FAX := registro0175.FAX;
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_0_Registro0200New(const lfdHandle: PTFDHandle; const registro0200 : Bloco0Registro0200) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_0.Registro0200New do
begin
COD_ITEM := registro0200.COD_ITEM;
DESCR_ITEM := registro0200.DESCR_ITEM;
COD_GEN := registro0200.COD_GEN;
COD_LST := registro0200.COD_LST;
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_0_Registro0205New(const lfdHandle: PTFDHandle; const registro0205 : Bloco0Registro0205) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_0.Registro0205New do
begin
DESCR_ANT_ITEM := registro0205.DESCR_ANT_ITEM;
DT_INI := TDateTime(registro0205.DT_INI);
DT_FIN := TDateTime(registro0205.DT_FIN);
COD_ANT_ITEM := registro0205.COD_ANT_ITEM;
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_0_Registro0210New(const lfdHandle: PTFDHandle; const registro0210 : Bloco0Registro0210) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_0.Registro0210New do
begin
UNID_ITEM := registro0210.UNID_ITEM;
COD_ITEM_COMP := registro0210.COD_ITEM_COMP;
QTD_COMP := registro0210.QTD_COMP;
UNID_COMP := registro0210.UNID_COMP;
PERDA_COMP := registro0210.PERDA_COMP;
DT_INI_COMP := registro0210.DT_INI_COMP;
DT_FIN_COMP := registro0210.DT_FIN_COMP;
IND_ALT := TACBrIndAlteracao(registro0210.IND_ALT);
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_0_Registro0990_GetQTD_LIN_0(const lfdHandle: PTFDHandle) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
Result := lfdHandle^.LFD.Bloco_0.Registro0990.QTD_LIN_0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
{%endregion Bloco0}
{%region BlocoA}
Function LFD_Bloco_A_GetDT_INI(const lfdHandle: PTFDHandle; var dtIni : double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
dtIni := Double(lfdHandle^.LFD.Bloco_A.DT_INI);
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_A_SetDT_INI(const lfdHandle: PTFDHandle; const dtIni : double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
lfdHandle^.LFD.Bloco_A.DT_INI := TDateTime(dtIni);
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_A_GetDT_FIN(const lfdHandle: PTFDHandle; var dtFin : double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
dtFin := Double(lfdHandle^.LFD.Bloco_A.DT_FIN);
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_A_SetDT_FIN(const lfdHandle: PTFDHandle; const dtFin : double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
lfdHandle^.LFD.Bloco_A.DT_FIN := TDateTime(dtFin);
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_A_GetGravado(const lfdHandle: PTFDHandle) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
if lfdHandle^.LFD.Bloco_A.Gravado then
Result := 1
else
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_A_RegistroA001New(const lfdHandle: PTFDHandle; const registroA001 : BlocoARegistroA001) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_A.RegistroA001New do
begin
IND_MOV:= TACBrLIndicadorMovimento(registroA001.IND_MOV);
COD_MUN:= registroA001.COD_MUN;
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_A_RegistroA350New(const lfdHandle: PTFDHandle; const registroA350 : BlocoARegistroA350) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_A.RegistroA350New do
begin
CPF_CONS := registroA350.CPF_CONS;
CNPJ_CONS := registroA350.CNPJ_CONS;
COD_MOD := registroA350.COD_MOD;
COD_SIT := TACBrlSituacaoDocto(registroA350.COD_SIT);
ECF_CX := registroA350.ECF_CX;
ECF_FAB := registroA350.ECF_FAB;
CRO := registroA350.CRO;
CRZ := registroA350.CRZ;
NUM_DOC := registroA350.NUM_DOC;
DT_DOC := registroA350.DT_DOC;
COP := registroA350.COP;
VL_DOC := registroA350.VL_DOC;
VL_CANC_ISS := registroA350.VL_CANC_ISS;
VL_CANC_ICMS := registroA350.VL_CANC_ICMS;
VL_DESC_ISS := registroA350.VL_DESC_ISS;
VL_DESC_ICMS := registroA350.VL_DESC_ICMS;
VL_ACMO_ISS := registroA350.VL_ACMO_ISS;
VL_ACMO_ICMS := registroA350.VL_ACMO_ICMS;
VL_BC_ISS := registroA350.VL_BC_ISS;
VL_ISS := registroA350.VL_ISS;
VL_ISN_ISS := registroA350.VL_ISN_ISS;
VL_NT_ISS := registroA350.VL_NT_ISS;
VL_RET_ISS := registroA350.VL_RET_ISS;
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_A_RegistroA360New(const lfdHandle: PTFDHandle; const registroA360 : BlocoARegistroA360) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_A.RegistroA360New do
begin
NUM_ITEM := registroA360.NUM_ITEM;
COD_ITEM := registroA360.COD_ITEM;
UNID := registroA360.UNID;
VL_UNIT := registroA360.VL_UNIT;
QTD := registroA360.QTD;
QTDCANC := registroA360.QTDCANC;
VL_DESC_I := registroA360.VL_DESC_I;
VL_ACMO_I := registroA360.VL_ACMO_I;
VL_CANC_I := registroA360.VL_CANC_I;
VL_ITEM := registroA360.VL_ITEM;
CTISS := registroA360.CTISS;
VL_BC_ISS_I := registroA360.VL_BC_ISS_I;
ALIQ_ISS := registroA360.ALIQ_ISS;
VL_ISS_I := registroA360.VL_ISS_I;
VL_ISN_ISS_I := registroA360.VL_ISN_ISS_I;
VL_NT_ISS_I := registroA360.VL_NT_ISS_I;
VL_RT_ISS_I := registroA360.VL_RT_ISS_I;
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_A_RegistroA990_GetQTD_LIN_A(const lfdHandle: PTFDHandle) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
Result := lfdHandle^.LFD.Bloco_A.RegistroA990.QTD_LIN_A;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
{%endregion Bloco0}
{%region BlocoC}
Function LFD_Bloco_C_GetDT_INI(const lfdHandle: PTFDHandle; var dtIni : double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
dtIni := Double(lfdHandle^.LFD.Bloco_C.DT_INI);
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_C_SetDT_INI(const lfdHandle: PTFDHandle; const dtIni : double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
lfdHandle^.LFD.Bloco_C.DT_INI := TDateTime(dtIni);
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_C_GetDT_FIN(const lfdHandle: PTFDHandle; var dtFin : double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
dtFin := Double(lfdHandle^.LFD.Bloco_C.DT_FIN);
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_C_SetDT_FIN(const lfdHandle: PTFDHandle; const dtFin : double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
lfdHandle^.LFD.Bloco_0.DT_FIN := TDateTime(dtFin);
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_C_GetGravado(const lfdHandle: PTFDHandle) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
if lfdHandle^.LFD.Bloco_0.Gravado then
Result := 1
else
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_C_RegistroC001New(const lfdHandle: PTFDHandle; const registroC001 : BlocoCRegistroC001) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_C.RegistroC001New do
begin
IND_MOV:= TACBrLIndicadorMovimento(registroC001.IND_MOV);
COD_MUN:= registroC001.COD_MUN;
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_C_RegistroC020New(const lfdHandle: PTFDHandle; const registroC020 : BlocoCRegistroC020) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_C.RegistroC020New do
begin
IND_OPER := TACBrlTipoOperacao(registroC020.IND_OPER);
IND_EMIT := TACBrlEmitente(registroC020.IND_EMIT);
COD_PART := registroC020.COD_PART;
COD_MOD := registroC020.COD_MOD;
COD_SIT := TACBrlSituacaoDocto(registroC020.COD_SIT);
SER := registroC020.SER;
NUM_DOC := registroC020.NUM_DOC;
CHV_NFE := registroC020.CHV_NFE;
DT_EMIS := TDateTime(registroC020.DT_EMIS);
DT_DOC := TDateTime(registroC020.DT_DOC);
COD_NAT := registroC020.COD_NAT;
IND_PGTO := TACBrlTipoPagamento(registroC020.IND_PGTO);
VL_DOC := registroC020.VL_DOC;
VL_DESC := registroC020.VL_DESC;
VL_ACMO := registroC020.VL_ACMO;
VL_MERC := registroC020.VL_MERC;
IND_FRT := TACBrTipoFrete(registroC020.IND_FRT);
VL_FRT := registroC020.VL_FRT;
VL_SEG := registroC020.VL_SEG;
VL_OUT_DA := registroC020.VL_OUT_DA;
VL_BC_ICMS := registroC020.VL_BC_ICMS;
VL_ICMS := registroC020.VL_ICMS;
VL_BC_ST := registroC020.VL_BC_ST;
VL_ICMS_ST := registroC020.VL_ICMS_ST;
VL_AT := registroC020.VL_AT;
VL_IPI := registroC020.VL_IPI;
COD_INF_OBS := registroC020.COD_INF_OBS;
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_C_RegistroC550New(const lfdHandle: PTFDHandle; const registroC550 : BlocoCRegistroC550) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_C.RegistroC550New do
begin
CPF_CONS := registroC550.CPF_CONS;
CNPJ_CONS := registroC550.CNPJ_CONS;
COD_MOD := registroC550.COD_MOD;
COD_SIT := TACBrlSituacaoDocto(registroC550.COD_SIT);
SER := registroC550.SER;
SUB := registroC550.SUB;
NUM_DOC := registroC550.NUM_DOC;
DT_DOC := registroC550.DT_DOC;
COP := registroC550.COP;
VL_DOC := registroC550.VL_DOC;
VL_DESC := registroC550.VL_DESC;
VL_ACMO := registroC550.VL_ACMO;
VL_MERC := registroC550.VL_MERC;
VL_BC_ICMS := registroC550.VL_BC_ICMS;
VL_ICMS := registroC550.VL_ICMS;
COD_INF_OBS:= registroC550.COD_INF_OBS;
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_C_RegistroC555New(const lfdHandle: PTFDHandle; const registroC555 : BlocoCRegistroC555) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_C.RegistroC555New do
begin
NUM_ITEM := registroC555.NUM_ITEM;
COD_ITEM := registroC555.COD_ITEM;
UNID := registroC555.UNID;
VL_UNIT := registroC555.VL_UNIT;
QTD := registroC555.QTD;
VL_DESC_I := registroC555.VL_DESC_I;
VL_ACMO_I := registroC555.VL_ACMO_I;
VL_ITEM := registroC555.VL_ITEM;
CST := registroC555.CST;
CFOP := registroC555.CFOP;
VL_BC_ICMS_I := registroC555.VL_BC_ICMS_I;
ALIQ_ICMS := registroC555.ALIQ_ICMS;
VL_ICMS_I := registroC555.VL_ICMS_I;
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_C_RegistroC600New(const lfdHandle: PTFDHandle; const registroC600 : BlocoCRegistroC600) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_C.RegistroC600New do
begin
CPF_CONS := registroC600.CPF_CONS;
CNPJ_CONS := registroC600.CNPJ_CONS;
COD_MOD := registroC600.COD_MOD;
COD_SIT := TACBrlSituacaoDocto(registroC600.COD_SIT);
ECF_CX := registroC600.ECF_CX;
ECF_FAB := registroC600.ECF_FAB;
CRO := registroC600.CRO;
CRZ := registroC600.CRZ;
NUM_DOC := registroC600.NUM_DOC;
DT_DOC := registroC600.DT_DOC;
COP := registroC600.COP;
VL_DOC := registroC600.VL_DOC;
VL_CANC_ICMS := registroC600.VL_CANC_ICMS;
VL_DESC_ICMS := registroC600.VL_DESC_ICMS;
VL_ACMO_ICMS := registroC600.VL_ACMO_ICMS;
VL_CANC_ISS := registroC600.VL_CANC_ISS;
VL_DESC_ISS := registroC600.VL_DESC_ISS;
VL_ACMO_ISS := registroC600.VL_ACMO_ISS;
VL_BC_ICMS := registroC600.VL_BC_ICMS;
VL_ICMS := registroC600.VL_ICMS;
VL_ISN := registroC600.VL_ISN;
VL_NT := registroC600.VL_NT;
VL_ST := registroC600.VL_ST;
VL_ISS := registroC600.VL_ISS;
VL_ICMS_ST := registroC600.VL_ICMS_ST;
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_C_RegistroC605New(const lfdHandle: PTFDHandle; const registroC605 : BlocoCRegistroC605) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_C.RegistroC605New do
begin
NUM_ITEM := registroC605.NUM_ITEM;
COD_ITEM := registroC605.COD_ITEM;
UNID := registroC605.UNID;
VL_UNIT := registroC605.VL_UNIT;
QTD := registroC605.QTD;
QTD_CANC_I := registroC605.QTD_CANC_I;
VL_ITEM := registroC605.VL_ITEM;
VL_DESC_I := registroC605.VL_DESC_I;
VL_CANC_I := registroC605.VL_CANC_I;
VL_ACMO_I := registroC605.VL_ACMO_I;
VL_ISS := registroC605.VL_ISS;
CST := registroC605.CST;
CFOP := registroC605.CFOP;
VL_BC_ICMS_I := registroC605.VL_BC_ICMS_I;
ALIQ_ICMS := registroC605.ALIQ_ICMS;
VL_ICMS_I := registroC605.VL_ICMS_I;
VL_ISN_I := registroC605.VL_ISN_I;
VL_NT_I := registroC605.VL_NT_I;
VL_ST_I := registroC605.VL_ST_I;
VL_ICMS_ST_I := registroC605.VL_ICMS_ST_I;
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_C_RegistroC990_GetQTD_LIN_C(const lfdHandle: PTFDHandle) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
Result := lfdHandle^.LFD.Bloco_C.RegistroC990.QTD_LIN_C;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
{%endregion BlocoC}
{%region Bloco9}
Function LFD_Bloco_9_GetDT_INI(const lfdHandle: PTFDHandle; var dtIni : double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
dtIni := Double(lfdHandle^.LFD.Bloco_9.DT_INI);
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_9_SetDT_INI(const lfdHandle: PTFDHandle; const dtIni : double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
lfdHandle^.LFD.Bloco_9.DT_INI := TDateTime(dtIni);
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_9_GetDT_FIN(const lfdHandle: PTFDHandle; var dtFin : double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
dtFin := Double(lfdHandle^.LFD.Bloco_9.DT_FIN);
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_9_SetDT_FIN(const lfdHandle: PTFDHandle; const dtFin : double) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
lfdHandle^.LFD.Bloco_9.DT_FIN := TDateTime(dtFin);
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_9_GetGravado(const lfdHandle: PTFDHandle) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
if lfdHandle^.LFD.Bloco_9.Gravado then
Result := 1
else
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_9_Registro9001New(const lfdHandle: PTFDHandle; const registro9001 : Bloco9Registro9001) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_9.Registro9001 do
BEGIN
IND_MOV := TACBrLIndicadorMovimento(registro9001.IND_MOV);
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_9_Registro9900New(const lfdHandle: PTFDHandle; const registro9900 : Bloco9Registro9900) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
with lfdHandle^.LFD.Bloco_9.Registro9900.New do
BEGIN
REG_BLC := registro9900.REG_BLC;
QTD_REG_BLC := registro9900.QTD_REG_BLC;
end;
Result := 0;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_9_Registro9990_GetQTD_LIN_9(const lfdHandle: PTFDHandle) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
Result := lfdHandle^.LFD.Bloco_9.Registro9990.QTD_LIN_9;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
Function LFD_Bloco_9_Registro9999_GetQTD_LIN(const lfdHandle: PTFDHandle) : Integer ; {$IFDEF STDCALL} stdcall; {$ENDIF} {$IFDEF CDECL} cdecl; {$ENDIF} export;
begin
if (lfdHandle = nil) then
begin
Result := -2;
Exit;
end;
try
Result := lfdHandle^.LFD.Bloco_9.Registro9999.QTD_LIN;
except
on exception : Exception do
begin
lfdHandle^.UltimoErro := exception.Message;
Result := -1;
end
end;
end;
{%endregion Bloco9}
exports
{ Create/Destroy/Erro }
LFD_Create,
LFD_Destroy,
LFD_GetUltimoErro,
{ Funções mapeando as propriedades do componente }
LFD_GetAbout, LFD_GetArquivo, LFD_SetArquivo,
LFD_GetCurMascara, LFD_SetCurMascara, LFD_GetPath,
LFD_SetPath, LFD_GetDelimitador, LFD_SetDelimitador,
LFD_GetLinhasBuffer, LFD_SetLinhasBuffer, LFD_GetTrimString,
LFD_SetTrimString, LFD_GetDT_INI, LFD_SetDT_INI,
LFD_GetDT_FIN, LFD_SetDT_FIN,
{ Methods }
LFD_SaveFileTXT, LFD_IniciaGeracao,
{ Events }
LFD_SetOnError,
{%region Bloco0}
LFD_Bloco_0_GetDT_INI, LFD_Bloco_0_SetDT_INI,
LFD_Bloco_0_GetDT_FIN, LFD_Bloco_0_SetDT_FIN,
LFD_Bloco_0_GetGravado,
LFD_Bloco_0_Registro0000New,
LFD_Bloco_0_Registro0001New,
LFD_Bloco_0_Registro0005New,
LFD_Bloco_0_Registro0025New,
LFD_Bloco_0_Registro0100New,
LFD_Bloco_0_Registro0150New,
LFD_Bloco_0_Registro0175New,
LFD_Bloco_0_Registro0200New,
LFD_Bloco_0_Registro0205New,
LFD_Bloco_0_Registro0210New,
LFD_Bloco_0_Registro0990_GetQTD_LIN_0,
{%endregion Bloco0}
{%region BlocoA}
LFD_Bloco_A_GetDT_INI, LFD_Bloco_A_SetDT_INI,
LFD_Bloco_A_GetDT_FIN, LFD_Bloco_A_SetDT_FIN,
LFD_Bloco_A_GetGravado,
LFD_Bloco_A_RegistroA001New,
LFD_Bloco_A_RegistroA350New,
LFD_Bloco_A_RegistroA360New,
LFD_Bloco_A_RegistroA990_GetQTD_LIN_A,
{%endregion BlocoA}
{%region BlocoC}
LFD_Bloco_C_GetDT_INI, LFD_Bloco_C_SetDT_INI,
LFD_Bloco_C_GetDT_FIN, LFD_Bloco_C_SetDT_FIN,
LFD_Bloco_C_GetGravado,
LFD_Bloco_C_RegistroC001New,
LFD_Bloco_C_RegistroC020New,
LFD_Bloco_C_RegistroC550New,
LFD_Bloco_C_RegistroC555New,
LFD_Bloco_C_RegistroC600New,
LFD_Bloco_C_RegistroC605New,
LFD_Bloco_C_RegistroC990_GetQTD_LIN_C,
{%endregion BlocoC}
{%region Bloco9}
LFD_Bloco_9_GetDT_INI, LFD_Bloco_9_SetDT_INI,
LFD_Bloco_9_GetDT_FIN, LFD_Bloco_9_SetDT_FIN,
LFD_Bloco_9_GetGravado,
LFD_Bloco_9_Registro9001New,
LFD_Bloco_9_Registro9900New,
LFD_Bloco_9_Registro9990_GetQTD_LIN_9,
LFD_Bloco_9_Registro9999_GetQTD_LIN;
{%endregion Bloco9}
end.
|
unit Aurelius.Commands.TableCreator;
{$I Aurelius.inc}
interface
uses
Generics.Collections,
Aurelius.Commands.AbstractCommandPerformer,
Aurelius.Sql.Metadata;
type
TTableCreator = class(TAbstractCommandPerformer)
public
procedure CreateTable(Database: TDatabaseMetadata);
procedure CreateUniqueKeys(Database: TDatabaseMetadata);
end;
implementation
uses
Aurelius.Global.Config,
Aurelius.Mapping.Metadata,
Aurelius.Schema.Utils,
Aurelius.Sql.BaseTypes,
Aurelius.Sql.Interfaces;
{ TTableCreator }
procedure TTableCreator.CreateTable(Database: TDatabaseMetadata);
function IsPKColumn(Col: TColumn): boolean;
var
C: TColumn;
begin
Result := False;
for C in FPKColumns do
if C = Col then
Exit(True);
end;
var
Table: TTableMetadata;
Column: TColumnMetadata;
UniqueKey: TUniqueKeyMetadata;
C: TColumn;
MappedTable: TMetaTable;
begin
Table := TTableMetadata.Create(Database);
Database.Tables.Add(Table);
MappedTable := Explorer.GetTable(Self.Clazz);
Table.Name := MappedTable.Name;
Table.Schema := MappedTable.Schema;
for C in FColumns do
begin
if C.IsForeign then
Continue;
Column := TColumnMetadata.Create(Table);
Table.Columns.Add(Column);
BuildColumnMetadata(Column ,C);
if (TColumnProp.Unique in C.Properties) and not IsPKColumn(C) then
begin
UniqueKey := TUniqueKeyMetadata.Create(Table);
Table.UniqueKeys.Add(UniqueKey);
UniqueKey.Columns.Add(TSchemaUtils.GetColumn(Table, C.Name));
UniqueKey.Name := SQLGenerator.GetUniqueKeyName(UniqueKey); // Set the name only after all properties are set
end;
end;
end;
procedure TTableCreator.CreateUniqueKeys(Database: TDatabaseMetadata);
var
Table: TTableMetadata;
UniqueKey: TUniqueKeyMetadata;
C: TColumn;
MappedTable: TMetaTable;
UKs: TObjectList<TUniqueConstraint>;
UK: TUniqueConstraint;
FieldName: string;
begin
MappedTable := Explorer.GetTable(Self.Clazz);
Table := TSchemaUtils.GetTable(Database, MappedTable.Name, MappedTable.Schema);
// Add primary key
Table.IdColumns.Clear;
for C in FPKColumns do
Table.IdColumns.Add(TSchemaUtils.GetColumn(Table, C.Name));
// Add composite unique keys
UKs := Explorer.GetUniqueConstraints(Self.Clazz);
try
for UK in UKs do
begin
UniqueKey := TUniqueKeyMetadata.Create(Table);
Table.UniqueKeys.Add(UniqueKey);
for FieldName in UK.FieldNames do
UniqueKey.Columns.Add(TSchemaUtils.GetColumn(Table, FieldName));
UniqueKey.Name := SQLGenerator.GetUniqueKeyName(UniqueKey); // Set the name only after all properties are set
end;
finally
UKs.Free;
end;
end;
end.
|
{ *******************************************************************************
Title: T2Ti ERP
Description: Janela de Lançamento Orçado para o módulo Contabilidade
The MIT License
Copyright: Copyright (C) 2016 T2Ti.COM
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
The author may be contacted at:
t2ti.com@gmail.com</p>
@author Albert Eije (t2ti.com@gmail.com)
@version 2.0
******************************************************************************* }
unit UContabilLancamentoOrcado;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, UTelaCadastro, DB, DBClient, Menus, StdCtrls, ExtCtrls, Buttons, Grids,
DBGrids, JvExDBGrids, JvDBGrid, JvDBUltimGrid, ComCtrls, ContabilLancamentoOrcadoVO,
ContabilLancamentoOrcadoController, Tipos, Atributos, Constantes, LabeledCtrls, Mask,
JvExMask, JvToolEdit, JvBaseEdits, StrUtils, Controller;
type
[TFormDescription(TConstantes.MODULO_CONTABILIDADE, 'Lançamento Orçado')]
TFContabilLancamentoOrcado = class(TFTelaCadastro)
BevelEdits: TBevel;
PageControlItens: TPageControl;
tsMeses: TTabSheet;
PanelContas: TPanel;
GridMeses: TJvDBUltimGrid;
CDSMeses: TClientDataSet;
DSMeses: TDataSource;
EditIdContabilConta: TLabeledCalcEdit;
EditContabilConta: TLabeledEdit;
EditAno: TLabeledMaskEdit;
CDSMesesMES: TStringField;
CDSMesesVALOR: TFMTBCDField;
procedure FormCreate(Sender: TObject);
procedure GridDblClick(Sender: TObject);
procedure CDSMesesAfterPost(DataSet: TDataSet);
procedure EditIdContabilContaKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
procedure PopularGridMeses;
public
{ Public declarations }
procedure GridParaEdits; override;
procedure LimparCampos; override;
procedure ControlaBotoes; override;
procedure ControlaPopupMenu; override;
// Controles CRUD
function DoInserir: Boolean; override;
function DoEditar: Boolean; override;
function DoExcluir: Boolean; override;
function DoSalvar: Boolean; override;
end;
var
FContabilLancamentoOrcado: TFContabilLancamentoOrcado;
implementation
uses ContabilContaVO, ContabilContaController;
{$R *.dfm}
{$REGION 'Controles Infra'}
procedure TFContabilLancamentoOrcado.FormCreate(Sender: TObject);
begin
ClasseObjetoGridVO := TContabilLancamentoOrcadoVO;
ObjetoController := TContabilLancamentoOrcadoController.Create;
inherited;
end;
procedure TFContabilLancamentoOrcado.LimparCampos;
begin
inherited;
CDSMeses.EmptyDataSet;
end;
procedure TFContabilLancamentoOrcado.ControlaBotoes;
begin
inherited;
BotaoImprimir.Visible := False;
end;
procedure TFContabilLancamentoOrcado.ControlaPopupMenu;
begin
inherited;
MenuImprimir.Visible := False;
end;
{$ENDREGION}
{$REGION 'Controles CRUD'}
function TFContabilLancamentoOrcado.DoInserir: Boolean;
begin
Result := inherited DoInserir;
if Result then
begin
PopularGridMeses;
EditIdContabilConta.SetFocus;
end;
end;
function TFContabilLancamentoOrcado.DoEditar: Boolean;
begin
Result := inherited DoEditar;
if Result then
begin
PopularGridMeses;
EditIdContabilConta.SetFocus;
end;
end;
function TFContabilLancamentoOrcado.DoExcluir: Boolean;
begin
if inherited DoExcluir then
begin
try
TController.ExecutarMetodo('ContabilLancamentoOrcadoController.TContabilLancamentoOrcadoController', 'Exclui', [IdRegistroSelecionado], 'DELETE', 'Boolean');
Result := TController.RetornoBoolean;
except
Result := False;
end;
end
else
begin
Result := False;
end;
if Result then
TController.ExecutarMetodo('ContabilLancamentoOrcadoController.TContabilLancamentoOrcadoController', 'Consulta', [Trim(Filtro), Pagina.ToString, False], 'GET', 'Lista');
end;
function TFContabilLancamentoOrcado.DoSalvar: Boolean;
begin
Result := inherited DoSalvar;
if Result then
begin
try
if not Assigned(ObjetoVO) then
ObjetoVO := TContabilLancamentoOrcadoVO.Create;
TContabilLancamentoOrcadoVO(ObjetoVO).IdEmpresa := Sessao.Empresa.Id;
TContabilLancamentoOrcadoVO(ObjetoVO).IdContabilConta := EditIdContabilConta.AsInteger;
TContabilLancamentoOrcadoVO(ObjetoVO).ContabilConta := EditContabilConta.Text;
TContabilLancamentoOrcadoVO(ObjetoVO).Ano := EditAno.Text;
// Meses
CDSMeses.DisableControls;
CDSMeses.First;
while not CDSMeses.Eof do
begin
TContabilLancamentoOrcadoVO(ObjetoVO).Janeiro := CDSMesesVALOR.AsExtended;
CDSMeses.Next;
TContabilLancamentoOrcadoVO(ObjetoVO).Fevereiro := CDSMesesVALOR.AsExtended;
CDSMeses.Next;
TContabilLancamentoOrcadoVO(ObjetoVO).Marco := CDSMesesVALOR.AsExtended;
CDSMeses.Next;
TContabilLancamentoOrcadoVO(ObjetoVO).Abril := CDSMesesVALOR.AsExtended;
CDSMeses.Next;
TContabilLancamentoOrcadoVO(ObjetoVO).Maio := CDSMesesVALOR.AsExtended;
CDSMeses.Next;
TContabilLancamentoOrcadoVO(ObjetoVO).Junho := CDSMesesVALOR.AsExtended;
CDSMeses.Next;
TContabilLancamentoOrcadoVO(ObjetoVO).Julho := CDSMesesVALOR.AsExtended;
CDSMeses.Next;
TContabilLancamentoOrcadoVO(ObjetoVO).Agosto := CDSMesesVALOR.AsExtended;
CDSMeses.Next;
TContabilLancamentoOrcadoVO(ObjetoVO).Setembro := CDSMesesVALOR.AsExtended;
CDSMeses.Next;
TContabilLancamentoOrcadoVO(ObjetoVO).Outubro := CDSMesesVALOR.AsExtended;
CDSMeses.Next;
TContabilLancamentoOrcadoVO(ObjetoVO).Novembro := CDSMesesVALOR.AsExtended;
CDSMeses.Next;
TContabilLancamentoOrcadoVO(ObjetoVO).Dezembro := CDSMesesVALOR.AsExtended;
CDSMeses.Next;
end;
CDSMeses.First;
CDSMeses.EnableControls;
if StatusTela = stInserindo then
begin
TController.ExecutarMetodo('ContabilLancamentoOrcadoController.TContabilLancamentoOrcadoController', 'Insere', [TContabilLancamentoOrcadoVO(ObjetoVO)], 'PUT', 'Lista');
end
else if StatusTela = stEditando then
begin
if TContabilLancamentoOrcadoVO(ObjetoVO).ToJSONString <> StringObjetoOld then
begin
TController.ExecutarMetodo('ContabilLancamentoOrcadoController.TContabilLancamentoOrcadoController', 'Altera', [TContabilLancamentoOrcadoVO(ObjetoVO)], 'POST', 'Boolean');
end
else
Application.MessageBox('Nenhum dado foi alterado.', 'Mensagem do Sistema', MB_OK + MB_ICONINFORMATION);
end;
except
Result := False;
end;
end;
end;
{$ENDREGION}
{$REGION 'Controle de Grid'}
procedure TFContabilLancamentoOrcado.GridDblClick(Sender: TObject);
begin
inherited;
PopularGridMeses;
end;
procedure TFContabilLancamentoOrcado.GridParaEdits;
begin
inherited;
if not CDSGrid.IsEmpty then
begin
ObjetoVO := TContabilLancamentoOrcadoVO(TController.BuscarObjeto('ContabilLancamentoOrcadoController.TContabilLancamentoOrcadoController', 'ConsultaObjeto', ['ID=' + IdRegistroSelecionado.ToString], 'GET'));
end;
if Assigned(ObjetoVO) then
begin
EditIdContabilConta.AsInteger := TContabilLancamentoOrcadoVO(ObjetoVO).IdContabilConta;
EditContabilConta.Text := TContabilLancamentoOrcadoVO(ObjetoVO).ContabilConta;
EditAno.Text := TContabilLancamentoOrcadoVO(ObjetoVO).Ano;
// Serializa o objeto para consultar posteriormente se houve alterações
FormatSettings.DecimalSeparator := '.';
StringObjetoOld := ObjetoVO.ToJSONString;
FormatSettings.DecimalSeparator := ',';
end;
end;
procedure TFContabilLancamentoOrcado.PopularGridMeses;
var
i: Integer;
begin
for i := 1 to 12 do
begin
CDSMeses.Append;
case i of
1:
begin
CDSMesesMES.AsString := 'Janeiro';
if (StatusTela = stEditando) or (StatusTela = stNavegandoEdits) then
begin
CDSMesesVALOR.AsExtended := TContabilLancamentoOrcadoVO(ObjetoVO).Janeiro;
end;
end;
2:
begin
CDSMesesMES.AsString := 'Fevereiro';
if (StatusTela = stEditando) or (StatusTela = stNavegandoEdits) then
begin
CDSMesesVALOR.AsExtended := TContabilLancamentoOrcadoVO(ObjetoVO).Fevereiro;
end;
end;
3:
begin
CDSMesesMES.AsString := 'Março';
if (StatusTela = stEditando) or (StatusTela = stNavegandoEdits) then
begin
CDSMesesVALOR.AsExtended := TContabilLancamentoOrcadoVO(ObjetoVO).Marco;
end;
end;
4:
begin
CDSMesesMES.AsString := 'Abril';
if (StatusTela = stEditando) or (StatusTela = stNavegandoEdits) then
begin
CDSMesesVALOR.AsExtended := TContabilLancamentoOrcadoVO(ObjetoVO).Abril;
end;
end;
5:
begin
CDSMesesMES.AsString := 'Maio';
if (StatusTela = stEditando) or (StatusTela = stNavegandoEdits) then
begin
CDSMesesVALOR.AsExtended := TContabilLancamentoOrcadoVO(ObjetoVO).Maio;
end;
end;
6:
begin
CDSMesesMES.AsString := 'Junho';
if (StatusTela = stEditando) or (StatusTela = stNavegandoEdits) then
begin
CDSMesesVALOR.AsExtended := TContabilLancamentoOrcadoVO(ObjetoVO).Junho;
end;
end;
7:
begin
CDSMesesMES.AsString := 'Julho';
if (StatusTela = stEditando) or (StatusTela = stNavegandoEdits) then
begin
CDSMesesVALOR.AsExtended := TContabilLancamentoOrcadoVO(ObjetoVO).Julho;
end;
end;
8:
begin
CDSMesesMES.AsString := 'Agosto';
if (StatusTela = stEditando) or (StatusTela = stNavegandoEdits) then
begin
CDSMesesVALOR.AsExtended := TContabilLancamentoOrcadoVO(ObjetoVO).Agosto;
end;
end;
9:
begin
CDSMesesMES.AsString := 'Setembro';
if (StatusTela = stEditando) or (StatusTela = stNavegandoEdits) then
begin
CDSMesesVALOR.AsExtended := TContabilLancamentoOrcadoVO(ObjetoVO).Setembro;
end;
end;
10:
begin
CDSMesesMES.AsString := 'Outubro';
if (StatusTela = stEditando) or (StatusTela = stNavegandoEdits) then
begin
CDSMesesVALOR.AsExtended := TContabilLancamentoOrcadoVO(ObjetoVO).Outubro;
end;
end;
11:
begin
CDSMesesMES.AsString := 'Novembro';
if (StatusTela = stEditando) or (StatusTela = stNavegandoEdits) then
begin
CDSMesesVALOR.AsExtended := TContabilLancamentoOrcadoVO(ObjetoVO).Novembro;
end;
end;
12:
begin
CDSMesesMES.AsString := 'Dezembro';
if (StatusTela = stEditando) or (StatusTela = stNavegandoEdits) then
begin
CDSMesesVALOR.AsExtended := TContabilLancamentoOrcadoVO(ObjetoVO).Dezembro;
end;
end;
end;
CDSMeses.Post;
end;
CDSMeses.First;
end;
procedure TFContabilLancamentoOrcado.CDSMesesAfterPost(DataSet: TDataSet);
begin
if CDSMesesMES.AsString = '' then
CDSMeses.Delete;
end;
{$ENDREGION}
{$REGION 'Campos Transientes'}
procedure TFContabilLancamentoOrcado.EditIdContabilContaKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
var
Filtro: String;
begin
if Key = VK_F1 then
begin
if EditIdContabilConta.Value <> 0 then
Filtro := 'ID = ' + EditIdContabilConta.Text
else
Filtro := 'ID=0';
try
EditIdContabilConta.Clear;
EditContabilConta.Clear;
if not PopulaCamposTransientes(Filtro, TContabilContaVO, TContabilContaController) then
PopulaCamposTransientesLookup(TContabilContaVO, TContabilContaController);
if CDSTransiente.RecordCount > 0 then
begin
EditIdContabilConta.Text := CDSTransiente.FieldByName('ID').AsString;
EditContabilConta.Text := CDSTransiente.FieldByName('DESCRICAO').AsString;
end
else
begin
Exit;
EditAno.SetFocus;
end;
finally
CDSTransiente.Close;
end;
end;
end;
{$ENDREGION}
end.
|
unit modsimple_lib;
{$mode objfpc}{$H+}
interface
uses
Dialogs, Controls, LazarusPackageIntf, ProjectIntf, NewItemIntf, IDEMsgIntf,
Classes, SysUtils;
resourcestring
rs_Mod_Default_Name = 'Module Generator - Simple';
rs_Mod_Default_Description = 'Create FastPlaz simple module';
type
{ TFileDescDefaultModule }
TFileDescDefaultModule = class(TFileDescPascalUnit)
private
public
constructor Create; override;
function GetInterfaceUsesSection: string; override;
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
function GetUnitDirectives: string; virtual;
function GetInterfaceSource(const Filename, SourceName,
ResourceName: string): string;
override;
function GetImplementationSource(const Filename, SourceName,
ResourceName: string): string; override;
function GetResourceSource(const ResourceName: string): string; override;
function CreateSource(const Filename, SourceName, ResourceName: string): string;
override;
procedure UpdateDefaultPascalFileExtension(const DefPasExt: string); override;
end;
{ TFileRouteDescModule }
TFileRouteDescModule = class(TFileDescPascalUnit)
private
public
constructor Create; override;
function GetInterfaceUsesSection: string; override;
function GetImplementationSource(const Filename, SourceName,
ResourceName: string): string; override;
end;
implementation
uses fastplaz_tools_register, modsimple_wzd;
{ TFileRouteDescModule }
constructor TFileRouteDescModule.Create;
begin
inherited Create;
DefaultFilename := 'routes.pas';
DefaultFileExt := '.pas';
end;
function TFileRouteDescModule.GetInterfaceUsesSection: string;
begin
Result := inherited GetInterfaceUsesSection;
Result := Result + ', fastplaz_handler';
end;
function TFileRouteDescModule.GetImplementationSource(
const Filename, SourceName, ResourceName: string): string;
var
str: TStringList;
begin
Result := inherited GetImplementationSource(Filename, SourceName, ResourceName);
str := TStringList.Create;
with str do
begin
Add('uses info_controller, main;');
Add('');
Add('initialization');
Add(' Route.Add( ''main'', TMainModule);');
Add(' Route.Add( ''info'', TInfoModule);');
Add('');
end;
Result := str.Text;
FreeAndNil(str);
end;
{ TFileDescDefaultModule }
constructor TFileDescDefaultModule.Create;
begin
inherited Create;
//Name:=rs_Mod_Default_Name;
DefaultFileExt := '.pas';
VisibleInNewDialog := True;
end;
function TFileDescDefaultModule.GetInterfaceUsesSection: string;
begin
Result := inherited GetInterfaceUsesSection;
Result := Result + ', fpcgi, HTTPDefs, fastplaz_handler, html_lib, database_lib';
end;
function TFileDescDefaultModule.GetLocalizedName: string;
begin
Result := inherited GetLocalizedName;
Result := rs_Mod_Default_Name;
end;
function TFileDescDefaultModule.GetLocalizedDescription: string;
begin
Result := inherited GetLocalizedDescription;
Result := rs_Mod_Default_Description;
end;
function TFileDescDefaultModule.GetUnitDirectives: string;
begin
Result:='{$mode objfpc}{$H+}';
if Owner is TLazProject then
Result:=CompilerOptionsToUnitDirectives(TLazProject(Owner).LazCompilerOptions);
end;
function TFileDescDefaultModule.GetInterfaceSource(
const Filename, SourceName, ResourceName: string): string;
var
str: TStringList;
begin
//Result:=inherited GetInterfaceSource(Filename, SourceName, ResourceName);
str := TStringList.Create;
with str do
begin
Add('type');
Add(' ' + ModulTypeName + ' = class(TMyCustomWebModule)');
Add(' procedure RequestHandler(Sender: TObject; ARequest: TRequest; AResponse: TResponse; var Handled: boolean);');
Add(' private');
Add(' function Tag_MainContent_Handler(const TagName: string; Params: TStringList): string;');
Add(' public');
Add(' constructor CreateNew(AOwner: TComponent; CreateMode: integer); override;');
Add(' destructor Destroy; override;');
Add(' end;');
Add('');
end;
Result := str.Text;
FreeAndNil(str);
end;
function TFileDescDefaultModule.GetImplementationSource(
const Filename, SourceName, ResourceName: string): string;
var
str: TStringList;
begin
Result := inherited GetImplementationSource(FileName, SourceName, ResourceName);
str := TStringList.Create;
with str do
begin
Add('uses theme_controller, common;');
Add('');
Add('constructor ' + ModulTypeName +
'.CreateNew(AOwner: TComponent; CreateMode: integer);');
Add('Begin');
Add(' inherited CreateNew(AOwner, CreateMode);');
Add(' OnRequest := @RequestHandler;');
Add('End;');
Add('');
Add('destructor ' + ModulTypeName + '.Destroy;');
Add('Begin');
Add(' inherited Destroy;');
Add('End;');
Add('');
Add('procedure ' + ModulTypeName +
'.RequestHandler(Sender: TObject; ARequest: TRequest; AResponse: TResponse; var Handled: boolean);');
Add('Begin');
Add(' Tags[''$maincontent''] := @Tag_MainContent_Handler; //<<-- tag $maincontent handler');
Add(' Response.Content := ThemeUtil.Render();');
Add(' Handled := True;');
Add('End;');
Add('');
Add('function ' + ModulTypeName +
'.Tag_MainContent_Handler(const TagName: string; Params: TStringList): string;');
Add('Begin');
Add('');
Add(' // your code here');
Add(' Result:=h3(''Hello "' + ucwords(ResourceName) + '" Module ... FastPlaz !'');');
Add('');
Add('End;');
Add('');
Add('');
end;
Result := Result + str.Text;
FreeAndNil(str);
if not bCreateProject then
begin
Result := Result + LineEnding + 'initialization' + LineEnding +
' // -> http://yourdomainname/' + ResourceName + LineEnding +
' // The following line should be moved to a file "routes.pas"' +
LineEnding + ' Route.Add(''' + Permalink + ''',' + ModulTypeName +
');' + LineEnding + LineEnding;
end;
end;
function TFileDescDefaultModule.GetResourceSource(const ResourceName: string): string;
begin
Result := inherited GetResourceSource(ResourceName);
end;
function TFileDescDefaultModule.CreateSource(
const Filename, SourceName, ResourceName: string): string;
begin
if not bExpert then
begin;
Permalink := 'sample';
ModulTypeName := 'TSampleModule';
if not bCreateProject then
begin
with TfModuleSimpleWizard.Create(nil) do
begin
if ShowModal = mrOk then
begin
if edt_ModuleName.Text <> '' then
ModulTypeName := 'T' + StringReplace(UcWords(edt_ModuleName.Text),
' ', '', [rfReplaceAll]) + 'Module';
Permalink := edt_Permalink.Text;
if Permalink = '' then
begin
Permalink := StringReplace(UcWords(edt_ModuleName.Text),
' ', '', [rfReplaceAll]);
end;
end;
Free;
end;
end
else
begin
ModulTypeName := 'TMainModule';
Permalink := 'main';
end;
end;
Result := inherited CreateSource(Filename, SourceName, Permalink);
log('module "' + ModulTypeName + '" created');
end;
procedure TFileDescDefaultModule.UpdateDefaultPascalFileExtension(
const DefPasExt: string);
begin
inherited UpdateDefaultPascalFileExtension(DefPasExt);
end;
end.
|
unit uSync;
interface
uses Forms, Classes, Windows, Messages, SysUtils, imapsend, mimemess,
mimepart, smtpsend, ssl_openssl;
type TSyncParams = class
private
mGate: string;
mUserName: string;
mPassword: string;
mSMTP: string;
mSMTPPort: string;
mIMAP: string;
mIMAPPort: string;
procedure setGate(const Value: string);
procedure setIMAP(const Value: string);
procedure setIMAPPort(const Value: string);
procedure setPassword(const Value: string);
procedure setSMTP(const Value: string);
procedure setSMTPPort(const Value: string);
procedure setUserName(const Value: string);
public
property Gate: string read mGate write setGate;
property UserName: string read mUserName write setUserName;
property Password: string read mPassword write setPassword;
property SMTPHost: string read mSMTP write setSMTP;
property SMTPPort: string read mSMTPPort write setSMTPPort;
property IMAPHost: string read mIMAP write setIMAP;
property IMAPPort: string read mIMAPPort write setIMAPPort;
constructor Create();
end;
type TSync = class
private
log: TStringList;
msyncParams: TSyncParams;
mimap: TIMAPSend;
msmtp: TSMTPSend;
procedure OnReadFilter(Sender: TObject; var Value: AnsiString);
procedure setsyncParams(const Value: TSyncParams);
public
property SyncParams: TSyncParams read msyncParams write setsyncParams;
function send(const key, value: string): boolean;
function reciev(body: TStringList): boolean;
procedure saveLog();
constructor Create;
procedure Free;
end;
implementation
uses uData, SQLite3, SQLiteTable3, uGlobals;
{ TSync }
constructor TSync.Create;
begin
log := TStringList.Create;
mimap := TIMAPSend.Create;
msmtp := TSMTPSend.Create;
mimap.Timeout := 5000;
mimap.FullSSL := true;
mimap.Sock.OnReadFilter := OnReadFilter;
msmtp.Timeout := 5000;
msmtp.FullSSL := true;
msmtp.Sock.OnReadFilter := OnReadFilter;
end;
procedure TSync.Free;
begin
log.Free;
freeAndNil(msyncParams);
mimap.Free;
msmtp.Free;
end;
procedure TSync.OnReadFilter(Sender: TObject; var Value: AnsiString);
begin
log.Add(string(Value));
end;
procedure TSync.saveLog;
var logdir,logfile: string;
begin
logdir := GetEnvironmentVariable('LocalAppData') + '\OGE\';
if not DirectoryExists(logdir) then mkdir(logdir);
logfile := logdir + 'log.log';
log.SaveToFile(logfile);
end;
function TSync.reciev(body: TStringList): boolean;
var i,id: integer;
msgID, msg: TStringList;
flag: string;
begin
msgID := TStringList.Create;
msg := TstringList.Create;
try
if not mimap.Login then abort;
if not mimap.SelectFolder('INBOX') then abort;
mimap.SearchMess('UNSEEN SUBJECT SYNC', msgID);
// mimap.SearchMess('SUBJECT SYNC', msgID);
for i := 0 to msgID.Count - 1 do
begin
id := strToInt(msgID.Strings[i]);
flag := '';
mimap.GetFlagsMess(id, flag);
if (pos('RECENT', flag) > 0) then
begin
msg.clear;
mimap.FetchMess(id, msg);
extract(msg, 'OGE_SYNC', body);
// mimap.DeleteMess(id);
end;
end;
mimap.CloseFolder;
mimap.Logout;
finally
msgID.Free;
msg.Free;
end;
result := true;
end;
function TSync.send(const key, value: string): boolean;
var Msg : TMimeMess;
MIMEPart : TMimePart;
list: TStringList;
begin
list := TStringList.Create;
Msg := TMimeMess.Create;
try
list.Add('<OGE_SYNC>');
list.Add('<' + key + '>'); list.Add(value); list.Add('</' + key + '>');
list.Add('</OGE_SYNC>');
Msg.Header.Subject := 'SYNC';
Msg.Header.From := msyncParams.mGate;
Msg.Header.ToList.Add(msyncParams.mGate);
MIMEPart := Msg.AddPartMultipart('alternative', nil);
Msg.AddPartText(list, MIMEPart);
Msg.EncodeMessage;
if not msmtp.Login then abort;
if not msmtp.MailFrom(msyncParams.mGate, Length(Msg.Lines.Text)) then abort;
if not msmtp.MailTo(msyncParams.mGate) then abort;
if not msmtp.MailData(Msg.Lines) then abort;
finally
msmtp.Logout;
list.Free;
msg.Free;
end;
result := true;
end;
procedure TSync.setsyncParams(const Value: TSyncParams);
begin
msyncParams := Value;
msmtp.TargetHost := msyncParams.SMTPHost;
msmtp.TargetPort := msyncParams.SMTPPort;
msmtp.Username := msyncParams.UserName;
msmtp.Password := msyncParams.Password;
mimap.TargetHost := msyncParams.IMAPHost;
mimap.TargetPort := msyncParams.IMAPPort;
mimap.UserName := msyncParams.UserName;
mimap.Password := msyncParams.Password;
end;
{ TSyncParams }
constructor TSyncParams.Create;
var sql: TSTringList;
table: TSQLiteUniTable;
key: string;
begin
sql := TStringList.Create;
sql.Add('SELECT KEY_FIELD, VALUE_FIELD FROM PARAMS WHERE KEY_FIELD LIKE "%SYNC_%"');
table := TSQLiteUniTable.Create(dm.sqlite, ansistring(sql.Text));
while not table.EOF do
begin
key := table.FieldAsString(0);
if key = 'SYNC_GATE' then mGate := table.FieldAsString(1);
if key = 'SYNC_USERNAME' then mUserName := table.FieldAsString(1);
if key = 'SYNC_PASSWORD' then mPassword := table.FieldAsString(1);
if key = 'SYNC_SMTP' then mSMTP := table.FieldAsString(1);
if key = 'SYNC_SMTP_PORT' then mSMTPPort := table.FieldAsString(1);
if key = 'SYNC_IMAP' then mIMAP := table.FieldAsString(1);
if key = 'SYNC_IMAP_PORT' then mIMAPPort := table.FieldAsString(1);
table.Next;
end;
sql.Free;
table.Free;
if mGate = '' then mGate := 'OGESYNC@yandex.ru';
if mUserName = '' then mUserName := 'OGESYNC';
if mPassword = '' then mPassword := 'SYNCOGE';
if mSMTP = '' then mSMTP := 'smtp.yandex.ru';
if mSMTPPort = '' then mSMTPPort := '465';
if mIMAP = '' then mIMAP := 'imap.yandex.ru';
if mIMAPPort = '' then mIMAPPort := '993';
end;
procedure TSyncParams.setGate(const Value: string);
begin
mGate := Value;
dm.SaveParam('SYNC_GATE', mGate);
end;
procedure TSyncParams.setIMAP(const Value: string);
begin
mIMAP := Value;
dm.SaveParam('SYNC_IMAP', mIMAP);
end;
procedure TSyncParams.setIMAPPort(const Value: string);
begin
mIMAPPort := Value;
dm.SaveParam('SYNC_IMAP_PORT', mIMAPPort);
end;
procedure TSyncParams.setPassword(const Value: string);
begin
mPassword := Value;
dm.SaveParam('SYNC_PASSWORD', mPassword);
end;
procedure TSyncParams.setSMTP(const Value: string);
begin
mSMTP := Value;
dm.SaveParam('SYNC_SMTP', mSMTP);
end;
procedure TSyncParams.setSMTPPort(const Value: string);
begin
mSMTPPort := Value;
dm.SaveParam('SYNC_SMTP_PORT', mSMTPPort);
end;
procedure TSyncParams.setUserName(const Value: string);
begin
mUsername := Value;
dm.SaveParam('SYNC_USERNAME', mUsername);
end;
end.
|
unit guitextobject;
//renders a font.
//right now it just renders a single texture with the required text and updates it as needed
//todo: build a fontmap
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, graphics, guiobject, gamepanel, gl,glext,math, controls;
type
TTextAlign=(taLeft, taCenter, taRight);
TGUITextObject=class(TGuiObject)
private
ftext: string; //just as an indication if the texture needs to be updated
fbackgroundcolor: tcolor; //for anti alliasing
fforegroundcolor: tcolor;
ftexture: integer;
ffont: tfont;
fwidth, fheight: single;
fLineSpacing: integer;
fbackgroundAlpha: byte;
fKeepAspectRatio: boolean;
procedure setFont(f: tfont);
protected
function getTexture: integer; override;
function getWidth:single; override;
procedure setWidth(w: single); override;
function getHeight:single; override;
procedure setHeight(h:single); override;
public
minWidth: integer; //minimal pixel width for the texture
minheight: integer;
firstTextBecomesMinWidth: boolean;
textAlignment: TTextAlign;
procedure setText(text: string);
constructor create(owner: TGamePanel=nil);
destructor destroy; override;
property Text: string read ftext write setText;
property font: tfont read ffont write setFont;
property linespacing: integer read flinespacing write flinespacing;
property color: tcolor read fforegroundcolor write fforegroundcolor;
property bcolor: tcolor read fbackgroundcolor write fbackgroundcolor;
property backgroundAlpha: byte read fbackgroundAlpha write fbackgroundAlpha default 0;
property keepAspectRatio: boolean read fKeepAspectRatio write fkeepAspectRatio;
end;
implementation
function TGUITextObject.getTexture: integer;
begin
result:=ftexture;
end;
function TGUITextObject.getWidth:single;
begin
result:=fwidth;
end;
procedure TGUITextObject.setWidth(w: single);
begin
fwidth:=w;
end;
function TGUITextObject.getHeight:single;
begin
result:=fheight;
end;
procedure TGUITextObject.setHeight(h: single);
begin
fheight:=h;
end;
procedure TGUITextObject.setText(text: string);
var
img: TBitmap;
pp: pointer;
p: pdword;
th, tw,iw,ih: integer;
i: integer;
backgroundcolorbgr: dword;
sl: tstringlist;
ba: dword;
ar: single;
begin
if ftext<>text then
begin
sl:=TStringList.create;
sl.text:=text;
//update the texture
img:=TBitmap.Create;
img.PixelFormat:=pf32bit;
img.canvas.font:=font;
tw:=img.Canvas.TextWidth(text);
tw:=0;
th:=0;
for i:=0 to sl.Count-1 do
begin
if i>0 then inc(th, fLineSpacing);
inc(th,img.Canvas.TextHeight(sl[i]));
tw:=max(img.Canvas.TextWidth(sl[i]), tw);
end;
if (minwidth=0) and firstTextBecomesMinWidth then
minwidth:=tw;
if (minheight=0) and firstTextBecomesMinWidth then
minheight:=th;
if fKeepAspectRatio then
begin
tw:=max(minWidth,tw);
th:=max(minHeight,th);
//increase tw and th to the aspect ratio given
ar:=height/width;
i:=trunc(tw*ar);
th:=max(i,th);
ar:=width/height;
i:=trunc(th*ar);
tw:=max(i,tw);
img.width:=max(minWidth,tw);
img.Height:=max(minHeight,th);
end
else
begin
img.width:=max(minWidth,tw);
img.Height:=max(minHeight,th);
end;
img.canvas.font.Color:=fforegroundcolor;
img.canvas.Brush.Color:=fbackgroundcolor; //will be made transparant
img.Canvas.FillRect(0,0,img.width, img.height);
backgroundcolorbgr:=ColorToRGB(fbackgroundcolor);
backgroundcolorbgr:=((backgroundcolorbgr shr 16) and $ff)+((backgroundcolorbgr shl 16) and $ff0000)+(backgroundcolorbgr and $ff00);
// backgroundcolorbgr:=Swap(backgroundcolorbgr);
th:=0;
for i:=0 to sl.count-1 do
begin
tw:=img.Canvas.TextWidth(sl[i]);
case textAlignment of
taLeft: img.Canvas.TextOut(0,th,sl[i]);
taCenter: img.Canvas.TextOut((img.width div 2)-(tw div 2),th,sl[i]);
taRight: img.Canvas.TextOut(img.width-tw,th,sl[i]);
end;
inc(th,img.Canvas.TextHeight(sl[i])+fLineSpacing);
end;
iw:=img.width;
ih:=img.height;
glBindTexture(GL_TEXTURE_2D, ftexture);
glActiveTexture(GL_TEXTURE0);
pp:=img.RawImage.Data;
//FPC sets the alpha channel to 100% transparant by default
p:=pp;
i:=0;
ba:=backgroundAlpha shl 24;
while i<img.RawImage.DataSize do
begin
if p^=backgroundcolorbgr then
p^:=p^ or ba //0
else
p^:=p^ or $ff000000;
inc(i,4);
inc(p);
end;
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iw, ih, 0, GL_BGRA, GL_UNSIGNED_BYTE, pp);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
img.free;
end;
end;
procedure TGUITextObject.setFont(f: tfont);
begin
ffont.Assign(f);
end;
destructor TGUITextObject.destroy;
begin
glDeleteTextures(1,@ftexture);
inherited destroy;
end;
constructor TGUITextObject.create(owner: TGamePanel=nil);
begin
inherited create(owner);
textAlignment:=taCenter;
rotationpoint.x:=-1; //top left
rotationpoint.y:=-1;
glGenTextures(1, @ftexture);
fbackgroundcolor:=clRed;
fforegroundcolor:=clBlue;
ffont:=TFont.Create;
ffont.Quality:=fqNonAntialiased;
fkeepAspectRatio:=true;
backgroundAlpha:=0;
end;
end.
|
unit UxlGridEx;
interface
uses UxlGrid;
type
TxlGridEx = class (TxlGrid)
private
function GetSettings (): widestring;
procedure SetSettings (const value: widestring);
protected
function GetText (): widestring; override;
procedure SetText (const s_text: widestring); override;
public
property Settings: widestring read GetSettings write SetSettings;
end;
implementation
uses UxlList, UxlFunctions;
function TxlGridEx.GetText (): widestring;
var o_rows, o_cols: TxlStrList;
i, j, m, n: integer;
begin
SaveGrid;
o_rows := TxlStrList.Create();
o_cols := TxlStrList.Create();
o_cols.Separator := #9;
m := IfThen (FixedRow = frcAuto, 1, 0);
n := IfThen (FixedCol = frcAuto, 1, 0);
for i := m to RowCount - 1 do
begin
o_cols.Clear;
for j := n to ColCount - 1 do
o_cols.Add(Cells[i, j]);
o_rows.Add(o_cols.Text);
end;
result := o_rows.Text;
o_rows.Free;
o_cols.Free;
end;
procedure TxlGridEx.SetText (const s_text: widestring);
var o_rows, o_cols: TxlStrList;
i, j, m, n: integer;
begin
o_rows := TxlStrList.Create();
o_cols := TxlStrList.Create();
o_cols.Separator := #9;
o_rows.Text := s_text;
for i := o_rows.Low to o_rows.High do
begin
o_cols.Text := o_rows[i];
for j := o_cols.Low to o_cols.High do
begin
m := IfThen (FixedRow = frcAuto, i + 1, i);
n := IfThen (FixedCol = frcAuto, j + 1, j);
Cells[m, n] := o_cols[j];
end;
end;
o_rows.Free;
o_cols.free;
Redraw;
end;
function TxlGridEx.GetSettings (): widestring;
var o_list1: TxlStrList;
o_list2: TxlIntList;
i: integer;
begin
o_list1 := TxlStrList.Create();
o_list1.Separator := ';';
o_list2 := TxlIntList.Create();
o_list2.Separator := ',';
for i := 0 to RowCount - 1 do
o_list2.Add(RowHeight[i]);
o_list1.Add(o_list2.Text);
o_list2.Clear;
for i := 0 to ColCount - 1 do
o_list2.Add(ColWidth[i]);
o_list1.Add(o_list2.Text);
o_list1.Add(IntToStr(Ord(FixedRow)));
o_list1.Add(IntToStr(Ord(FixedCol)));
result := o_list1.Text;
o_list1.free;
o_list2.free;
end;
procedure TxlGridEx.SetSettings (const value: widestring);
var o_list1: TxlStrList;
o_list2: TxlIntList;
i: integer;
begin
o_list1 := TxlStrList.Create();
o_list1.Separator := ';';
o_list2 := TxlIntList.Create();
o_list2.Separator := ',';
o_list1.Text := value;
o_list2.Text := o_list1[0];
RowCount := o_list2.Count;
for i := o_list2.Low to o_list2.High do
RowHeight[i] := o_list2[i];
o_list2.Text := o_list1[1];
ColCount := o_list2.Count;
for i := o_list2.Low to o_list2.High do
ColWidth[i] := o_list2[i];
FixedRow := TFixedRowCol(StrToIntDef (o_list1[2]));
FixedCol := TFixedRowCol(StrToIntDef (o_list1[3]));
o_list1.free;
o_list2.free;
end;
end.
|
{
ORM Brasil é um ORM simples e descomplicado para quem utiliza Delphi
Copyright (c) 2016, Isaque Pinheiro
All rights reserved.
GNU Lesser General Public License
Versão 3, 29 de junho de 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
A todos é permitido copiar e distribuir cópias deste documento de
licença, mas mudá-lo não é permitido.
Esta versão da GNU Lesser General Public License incorpora
os termos e condições da versão 3 da GNU General Public License
Licença, complementado pelas permissões adicionais listadas no
arquivo LICENSE na pasta principal.
}
{ @abstract(ORMBr Framework.)
@created(20 Jul 2016)
@author(Isaque Pinheiro <isaquepsp@gmail.com>)
@author(Skype : ispinheiro)
ORM Brasil é um ORM simples e descomplicado para quem utiliza Delphi.
}
unit ormbr.command.factory;
interface
uses
DB,
Rtti,
Generics.Collections,
ormbr.command.selecter,
ormbr.command.inserter,
ormbr.command.deleter,
ormbr.command.updater,
dbebr.factory.interfaces,
dbcbr.mapping.classes,
dbcbr.types.mapping;
type
TDMLCommandFactoryAbstract = class abstract
protected
FDMLCommand: string;
public
constructor Create(const AObject: TObject; const AConnection: IDBConnection;
const ADriverName: TDriverName); virtual; abstract;
function GeneratorSelectAll(AClass: TClass;
APageSize: Integer): IDBResultSet; virtual; abstract;
function GeneratorSelectID(AClass: TClass;
AID: Variant): IDBResultSet; virtual; abstract;
function GeneratorSelect(ASQL: String;
APageSize: Integer): IDBResultSet; virtual; abstract;
function GeneratorSelectOneToOne(const AOwner: TObject; const AClass: TClass;
const AAssociation: TAssociationMapping): IDBResultSet; virtual; abstract;
function GeneratorSelectOneToMany(const AOwner: TObject; const AClass: TClass;
const AAssociation: TAssociationMapping): IDBResultSet; virtual; abstract;
function GeneratorSelectWhere(const AClass: TClass; const AWhere: string;
const AOrderBy: string; const APageSize: Integer): string; virtual; abstract;
function GeneratorNextPacket: IDBResultSet; overload; virtual; abstract;
function GeneratorNextPacket(const AClass: TClass;
const APageSize, APageNext: Integer): IDBResultSet; overload; virtual; abstract;
function GeneratorNextPacket(const AClass: TClass;
const AWhere, AOrderBy: String;
const APageSize, APageNext: Integer): IDBResultSet; overload; virtual; abstract;
function GetDMLCommand: string; virtual; abstract;
function ExistSequence: Boolean; virtual; abstract;
function GeneratorSelectAssociation(const AOwner: TObject; const AClass: TClass;
const AAssociation: TAssociationMapping): String; virtual; abstract;
procedure GeneratorUpdate(const AObject: TObject;
const AModifiedFields: TDictionary<string, string>); virtual; abstract;
procedure GeneratorInsert(const AObject: TObject); virtual; abstract;
procedure GeneratorDelete(const AObject: TObject); virtual; abstract;
end;
TDMLCommandFactory = class(TDMLCommandFactoryAbstract)
protected
FConnection: IDBConnection;
FCommandSelecter: TCommandSelecter;
FCommandInserter: TCommandInserter;
FCommandUpdater: TCommandUpdater;
FCommandDeleter: TCommandDeleter;
public
constructor Create(const AObject: TObject; const AConnection: IDBConnection;
const ADriverName: TDriverName); override;
destructor Destroy; override;
function GeneratorSelectAll(AClass: TClass;
APageSize: Integer): IDBResultSet; override;
function GeneratorSelectID(AClass: TClass;
AID: Variant): IDBResultSet; override;
function GeneratorSelect(ASQL: String;
APageSize: Integer): IDBResultSet; override;
function GeneratorSelectOneToOne(const AOwner: TObject; const AClass: TClass;
const AAssociation: TAssociationMapping): IDBResultSet; override;
function GeneratorSelectOneToMany(const AOwner: TObject; const AClass: TClass;
const AAssociation: TAssociationMapping): IDBResultSet; override;
function GeneratorSelectWhere(const AClass: TClass; const AWhere: string;
const AOrderBy: string; const APageSize: Integer): string; override;
function GeneratorNextPacket: IDBResultSet; overload; override;
function GeneratorNextPacket(const AClass: TClass;
const APageSize, APageNext: Integer): IDBResultSet; overload; override;
function GeneratorNextPacket(const AClass: TClass;
const AWhere, AOrderBy: String;
const APageSize, APageNext: Integer): IDBResultSet; overload; override;
function GetDMLCommand: string; override;
function ExistSequence: Boolean; override;
function GeneratorSelectAssociation(const AOwner: TObject; const AClass: TClass;
const AAssociation: TAssociationMapping): String; override;
procedure GeneratorUpdate(const AObject: TObject;
const AModifiedFields: TDictionary<string, string>); override;
procedure GeneratorInsert(const AObject: TObject); override;
procedure GeneratorDelete(const AObject: TObject); override;
end;
implementation
uses
ormbr.objects.helper,
ormbr.rtti.helper;
{ TDMLCommandFactory }
constructor TDMLCommandFactory.Create(const AObject: TObject;
const AConnection: IDBConnection; const ADriverName: TDriverName);
begin
inherited;
FConnection := AConnection;
FCommandSelecter := TCommandSelecter.Create(AConnection, ADriverName, AObject);
FCommandInserter := TCommandInserter.Create(AConnection, ADriverName, AObject);
FCommandUpdater := TCommandUpdater.Create(AConnection, ADriverName, AObject);
FCommandDeleter := TCommandDeleter.Create(AConnection, ADriverName, AObject);
end;
destructor TDMLCommandFactory.Destroy;
begin
FCommandSelecter.Free;
FCommandDeleter.Free;
FCommandInserter.Free;
FCommandUpdater.Free;
inherited;
end;
function TDMLCommandFactory.GetDMLCommand: string;
begin
Result := FDMLCommand;
end;
function TDMLCommandFactory.ExistSequence: Boolean;
begin
Result := False;
if FCommandInserter.AutoInc <> nil then
Exit(FCommandInserter.AutoInc.ExistSequence);
end;
procedure TDMLCommandFactory.GeneratorDelete(const AObject: TObject);
begin
FDMLCommand := FCommandDeleter.GenerateDelete(AObject);
// Envia comando para tela do monitor.
if FConnection.CommandMonitor <> nil then
FConnection.CommandMonitor.Command(FDMLCommand, FCommandDeleter.Params);
FConnection.ExecuteDirect(FDMLCommand, FCommandDeleter.Params);
end;
procedure TDMLCommandFactory.GeneratorInsert(const AObject: TObject);
begin
FDMLCommand := FCommandInserter.GenerateInsert(AObject);
// Envia comando para tela do monitor.
if FConnection.CommandMonitor <> nil then
FConnection.CommandMonitor.Command(FDMLCommand, FCommandInserter.Params);
FConnection.ExecuteDirect(FDMLCommand, FCommandInserter.Params);
end;
function TDMLCommandFactory.GeneratorNextPacket(const AClass: TClass;
const AWhere, AOrderBy: String; const APageSize, APageNext: Integer): IDBResultSet;
begin
FDMLCommand := FCommandSelecter.GenerateNextPacket(AClass, AWhere, AOrderBy, APageSize, APageNext);
// Envia comando para tela do monitor.
if FConnection.CommandMonitor <> nil then
FConnection.CommandMonitor.Command(FDMLCommand, FCommandSelecter.Params);
Result := FConnection.ExecuteSQL(FDMLCommand);
end;
function TDMLCommandFactory.GeneratorNextPacket(const AClass: TClass;
const APageSize, APageNext: Integer): IDBResultSet;
begin
FDMLCommand := FCommandSelecter.GenerateNextPacket(AClass, APageSize, APageNext);
// Envia comando para tela do monitor.
if FConnection.CommandMonitor <> nil then
FConnection.CommandMonitor.Command(FDMLCommand, FCommandSelecter.Params);
Result := FConnection.ExecuteSQL(FDMLCommand);
end;
function TDMLCommandFactory.GeneratorSelect(ASQL: String;
APageSize: Integer): IDBResultSet;
begin
FCommandSelecter.SetPageSize(APageSize);
FDMLCommand := ASQL;
// Envia comando para tela do monitor.
if FConnection.CommandMonitor <> nil then
FConnection.CommandMonitor.Command(FDMLCommand, FCommandSelecter.Params);
Result := FConnection.ExecuteSQL(ASQL);
end;
function TDMLCommandFactory.GeneratorSelectAll(AClass: TClass;
APageSize: Integer): IDBResultSet;
begin
FCommandSelecter.SetPageSize(APageSize);
FDMLCommand := FCommandSelecter.GenerateSelectAll(AClass);
// Envia comando para tela do monitor.
if FConnection.CommandMonitor <> nil then
FConnection.CommandMonitor.Command(FDMLCommand, FCommandSelecter.Params);
Result := FConnection.ExecuteSQL(FDMLCommand);
end;
function TDMLCommandFactory.GeneratorSelectAssociation(const AOwner: TObject;
const AClass: TClass; const AAssociation: TAssociationMapping): String;
begin
Result := FCommandSelecter.GenerateSelectOneToOne(AOwner, AClass, AAssociation);
end;
function TDMLCommandFactory.GeneratorSelectOneToOne(const AOwner: TObject;
const AClass: TClass; const AAssociation: TAssociationMapping): IDBResultSet;
begin
FDMLCommand := FCommandSelecter.GenerateSelectOneToOne(AOwner, AClass, AAssociation);
// Envia comando para tela do monitor.
if FConnection.CommandMonitor <> nil then
FConnection.CommandMonitor.Command(FDMLCommand, FCommandSelecter.Params);
Result := FConnection.ExecuteSQL(FDMLCommand);
end;
function TDMLCommandFactory.GeneratorSelectOneToMany(const AOwner: TObject;
const AClass: TClass; const AAssociation: TAssociationMapping): IDBResultSet;
begin
FDMLCommand := FCommandSelecter.GenerateSelectOneToMany(AOwner, AClass, AAssociation);
// Envia comando para tela do monitor.
if FConnection.CommandMonitor <> nil then
FConnection.CommandMonitor.Command(FDMLCommand, FCommandSelecter.Params);
Result := FConnection.ExecuteSQL(FDMLCommand);
end;
function TDMLCommandFactory.GeneratorSelectWhere(const AClass: TClass;
const AWhere: string; const AOrderBy: string; const APageSize: Integer): string;
begin
FCommandSelecter.SetPageSize(APageSize);
Result := FCommandSelecter.GeneratorSelectWhere(AClass, AWhere, AOrderBy);
end;
function TDMLCommandFactory.GeneratorSelectID(AClass: TClass;
AID: Variant): IDBResultSet;
begin
FDMLCommand := FCommandSelecter.GenerateSelectID(AClass, AID);
// Envia comando para tela do monitor.
if FConnection.CommandMonitor <> nil then
FConnection.CommandMonitor.Command(FDMLCommand, FCommandSelecter.Params);
Result := FConnection.ExecuteSQL(FDMLCommand);
end;
function TDMLCommandFactory.GeneratorNextPacket: IDBResultSet;
begin
FDMLCommand := FCommandSelecter.GenerateNextPacket;
// Envia comando para tela do monitor.
if FConnection.CommandMonitor <> nil then
FConnection.CommandMonitor.Command(FDMLCommand, FCommandSelecter.Params);
Result := FConnection.ExecuteSQL(FDMLCommand);
end;
procedure TDMLCommandFactory.GeneratorUpdate(const AObject: TObject;
const AModifiedFields: TDictionary<string, string>);
begin
FDMLCommand := FCommandUpdater.GenerateUpdate(AObject, AModifiedFields);
if FDMLCommand = '' then
Exit;
// Envia comando para tela do monitor.
if FConnection.CommandMonitor <> nil then
FConnection.CommandMonitor.Command(FDMLCommand, FCommandUpdater.Params);
FConnection.ExecuteDirect(FDMLCommand, FCommandUpdater.Params);
end;
end.
|
unit xxmUtilities;
interface
uses Windows, SysUtils, Classes;
procedure ListFilesInPath(FileList:TStringList;Path:string);
function GetInternalIdentifier(FileName:string;var cPathIndex,fExtIndex,fPathIndex:integer):string;
function Signature(Path:string):string;
function GetFileSize(Path:string):integer;
function GetSelfPath:string;
const
Hex:array[0..15] of char='0123456789ABCDEF';
XxmProjectFileName='Web.xxmp';
XxmModuleExtension='.xxl';
XxmProtoExtension='.proto.pas';
DelphiProjectExtension='.dpr';
DelphiExtension='.pas';
ProjectLogExtension='.log';
SignaturesExtension='.~db';
ProtoProjectDpr='Web.dpr';
ProtoProjectMask='Web.*';
ProtoProjectPas='xxmp.pas';
ProtoDirectory='proto';
SourceDirectory='src';
type
TXxmFileType=(
ftPage,
ftInclude,
ftProject,
//add new here
ft_Unknown
);
const
XxmFileExtension:array[TXxmFileType] of string=(
'.xxm',
'.xxmi',
'.xxmp',
//add new here
''
);
implementation
uses Registry;
procedure ListFilesInPath(FileList:TStringList;Path:string);
var
Dirs:TStringList;
fh:THandle;
fd:TWin32FindData;
CDir,s:string;
i:integer;
FirstLevel,AbandonDirectory:boolean;
ft:TXxmFileType;
begin
Dirs:=TStringList.Create;
try
Dirs.Add('');
FirstLevel:=true;
while not(Dirs.Count=0) do
begin
CDir:=Dirs[0];
AbandonDirectory:=false;
Dirs.Delete(0);
fh:=FindFirstFile(PChar(Path+CDir+'*.*'),fd);
if fh=INVALID_HANDLE_VALUE then RaiseLastOSError;
repeat
if not(string(fd.cFileName)='.') and not(string(fd.cFileName)='..') then
begin
if (fd.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY)=0 then
begin
s:=fd.cFileName;
i:=Length(s);
while not(i=0) and not(s[i]='.') do dec(i);
s:=LowerCase(Copy(s,i,Length(s)-i+1));
ft:=TXxmFileType(0);
while not(ft=ft_Unknown) and not(s=XxmFileExtension[ft]) do inc(ft);
case ft of
ftPage,ftInclude:
FileList.Add(CDir+fd.cFileName);
ftProject:
if FirstLevel then
begin
//create TXxmWebProject?
end
else
begin
//warning! sub-project, skip directory
AbandonDirectory:=true;
for i:=Dirs.Count-1 downto 0 do
if Copy(Dirs[i],1,Length(CDir))=CDir then Dirs.Delete(i);
for i:=FileList.Count-1 downto 0 do
if Copy(FileList[i],1,Length(CDir))=CDir then FileList.Delete(i);
//TODO: queue secondary process directory?
end;
//add new here
//else?
end;
end
else
Dirs.Add(CDir+fd.cFileName+PathDelim);
end;
until not(FindNextFile(fh,fd)) or AbandonDirectory;
Windows.FindClose(fh);
FirstLevel:=false;
end;
finally
Dirs.Free;
end;
end;
function IsReservedWord(x:string):boolean;
const
ResWordsCount=65;
ResWords:array[0..ResWordsCount-1] of string=(
'and', 'array', 'as', 'asm',
'begin', 'case', 'class', 'const',
'constructor', 'destructor', 'dispinterface', 'div',
'do', 'downto', 'else', 'end',
'except', 'exports', 'file', 'finalization',
'finally', 'for', 'function', 'goto',
'if', 'implementation', 'in', 'inherited',
'initialization', 'inline', 'interface', 'is',
'label', 'library', 'mod', 'nil',
'not', 'object', 'of', 'or',
'out', 'packed', 'procedure', 'program',
'property', 'raise', 'record', 'repeat',
'resourcestring', 'set', 'shl', 'shr',
'string', 'then', 'threadvar', 'to',
'try', 'type', 'unit', 'until',
'uses', 'var', 'while', 'with',
'xor'
);
ResWordMaxLength:array['A'..'Z'] of byte=(5,5,11,13,7,12,4,0,14,0,0,7,3,3,6,9,0,14,6,9,5,3,5,3,0,0);
var
c:char;
y:string;
i:integer;
begin
//assert not(x='')
c:=UpCase(x[1]);
//skip anything longer than longest word
if not(c in ['A'..'B']) or (Length(x)>ResWordMaxLength[c]) then Result:=false else
begin
y:=LowerCase(x);
i:=0;
while (i<ResWordsCount) and not(y=ResWords[i]) do inc(i);
Result:=i<ResWordsCount;
end;
end;
function Signature(Path:string):string;
var
fh:THandle;
fd:TWin32FindData;
begin
fh:=FindFirstFile(PChar(Path),fd);
if fh=INVALID_HANDLE_VALUE then Result:='' else
begin
//assert(fd.nFileSizeHigh=0
Result:=
IntToHex(fd.ftLastWriteTime.dwHighDateTime,8)+
IntToHex(fd.ftLastWriteTime.dwLowDateTime,8)+'_'+
IntToStr(fd.nFileSizeLow);
Windows.FindClose(fh);
end;
end;
function GetFileSize(Path:string):integer;
var
fh:THandle;
fd:TWin32FindData;
begin
fh:=FindFirstFile(PChar(Path),fd);
if fh=INVALID_HANDLE_VALUE then Result:=-1 else
begin
//assert(fd.nFileSizeHigh=0
Result:=fd.nFileSizeLow;
Windows.FindClose(fh);
end;
end;
function GetSelfPath:string;
var
i:integer;
begin
SetLength(Result,$400);
SetLength(Result,GetModuleFileName(HInstance,PChar(Result),$400));
i:=Length(Result);
while not(i=0) and not(Result[i]=PathDelim) do dec(i);
Result:=Copy(Result,1,i);
if Copy(Result,1,4)='\\?\' then Result:=Copy(Result,5,Length(Result)-4);
end;
function GetInternalIdentifier(FileName:string;var cPathIndex,fExtIndex,fPathIndex:integer):string;
var
i:integer;
begin
Result:='';
cPathIndex:=1;
fPathIndex:=0;
fExtIndex:=0;
for i:=1 to Length(FileName) do
case FileName[i] of
'\':
begin
Result:=Result+'__';
cPathIndex:=Length(Result)+1;
fPathIndex:=i;
end;
'.':
begin
Result:=Result+'_';
fExtIndex:=i;
end;
'A'..'Z':
Result:=Result+char(byte(FileName[i])+$20);
'0'..'9','_','a'..'z':
Result:=Result+FileName[i];
else
Result:=Result+'x'+Hex[byte(FileName[i]) shr 4]+Hex[byte(FileName[i]) and $F];
end;
//assert not(CID='')
if not(Result[1] in ['A'..'Z','a'..'z']) then Result:='x'+Result;
if IsReservedWord(Result) then
if LowerCase(Result)='or' then
Result:='x_'+Result
else
Result:='x'+Result;
end;
end.
|
unit HJYUpgrade;
interface
uses Windows, SysUtils, Forms;
const
UpgradeExeName = 'upgrade.exe';
UpdcheckDLL = 'updcheck.dll';
function CheckNewVersion: Boolean;
procedure StartUpgrade(AStartKind: string = 'A');
implementation
uses HJYUtils, HJYDataProviders;
function CheckNewVersion: Boolean;
type
TCheckNewVersion = function: Integer; stdcall;
var
lNewVer: TCheckNewVersion;
DLL: Cardinal;
lFileName: string;
begin
Result := False;
lFileName := DataProvider.AppPath + UpdcheckDLL;
DLL := LoadLibrary(PChar(lFileName));
if DLL = 0 then Exit;
try
lNewVer := GetProcAddress(DLL, 'CheckNewVersion');
if Assigned(lNewVer) then
Result := lNewVer = 1;
finally
FreeLibrary(DLL);
end;
end;
procedure StartUpgrade(AStartKind: string);
const
cParamStr = '"exe=%s;sk=%s;name=%s"';
var
lFileName: string;
lMainApp: string;
lParamStr: string;
begin
lFileName := DataProvider.AppPath + UpgradeExeName;
if IsRunning(lFileName) then
CloseExe(lFileName);
lMainApp := ExtractFileName(Application.ExeName);
(*
调用方式:exe=DataSub.exe;sk=A;name=财务数据实时在线报送系统
AStartKind参数描述:
A:升级完成后自动启动主程序,一般主程序启动发现需要升级时使用
C:启动完成后手动启动主程序,一般用在升级检测
*)
lParamStr := Format(cParamStr, [lMainApp, AStartKind, Application.Title]);
RunExe(lFileName, [lParamStr]);
end;
end.
|
unit ShareWin;
{$Define AlwaysShareRead}
interface
uses Windows,Messages,SysUtils,Classes,ShareSys, Comctrls, Forms;
const
HEAP_NO_SERIALIZE =$00000001;
HEAP_GROWABLE =$00000002;
HEAP_GENERATE_EXCEPTIONS =$00000004;
HEAP_ZERO_MEMORY =$00000008;
HEAP_REALLOC_IN_PLACE_ONLY =$00000010;
HEAP_TAIL_CHECKING_ENABLED =$00000020;
HEAP_FREE_CHECKING_ENABLED =$00000040;
HEAP_DISABLE_COALESCE_ON_FREE =$00000080;
HEAP_CREATE_ALIGN_16 =$00010000;
HEAP_CREATE_ENABLE_TRACING =$00020000;
HEAP_MAXIMUM_TAG =$0FFF;
HEAP_PSEUDO_TAG_FLAG =$8000;
HEAP_TAG_SHIFT =16;
//
// WARNING: these procs and TCommon32bArray can only be used
// in main thread because HEAP_NO_SERIALIZE is speciafied in every call
var
DynamicArrayHeap:THandle;
function DAHeapAlloc(dwBytes:u_Int32):Pointer;
function DAHeapReAlloc(lpMem:Pointer;dwBytes:u_Int32):Pointer;
function DAHeapFree(lpMem:Pointer):BOOL;
procedure DAHeapCompact();
function DAHeapAlloc0(dwBytes:u_Int32):Pointer; //zero mem
function DAHeapReAlloc0(lpMem:Pointer;dwBytes:u_Int32):Pointer;
type
TCommon32bArray=class(T32bArray)
protected
procedure ReAlloc(var MemPtr:Pointer;newCapacity:Integer);override;
public
procedure LoadFromStream(Stream:TStream);
procedure SaveToStream(Stream:TStream);
end;
const
faReadOnlyBitMask =$01;
faExclusiveBitMask =$02;
faTemporaryBitMask =$04;
faAutoDeleteBitMask =$08;
faTrucExistingBitMask =$10;
faRandomAccessBitMask =$20;
faSequentialScanBitMask =$40;
MightErrorReturn =$FFFFFFFF;
type
EWin32FileError=class(EOSError);
TWin32File=class(TComponent)
private
FFileHandle:THandle;
FSize:DWord;
FSizeHigh:DWord;
FPosition:DWord;
FPositionHigh:DWord;
FOnBeforeOpen: TNotifyEvent;
FOnAfterOpen: TNotifyEvent;
FOnBeforeClose: TNotifyEvent;
FOnAfterClose: TNotifyEvent;
function GetEof:Boolean;
function GetActive: Boolean;
procedure SetActive(const Value: Boolean);
procedure SetFileName(const Value: string);
function GetReadOnly: Boolean;
procedure SetReadOnly(const Value: Boolean);
function GetExclusive: Boolean;
procedure SetExclusive(const Value: Boolean);
function GetTemporary: Boolean;
procedure SetTemporary(const Value: Boolean);
function GetAutoDelete: Boolean;
procedure SetAutoDelete(const Value: Boolean);
function GetTrucExisting: Boolean;
procedure SetTrucExisting(const Value: Boolean);
function GetRandomAccess: Boolean;
procedure SetRandomAccess(const Value: Boolean);
function GetSequentialScan: Boolean;
procedure SetSequentialScan(const Value: Boolean);
protected
FFileName:string;
FFileAttributes:Integer;
procedure FileReadError;
procedure FileWriteError;
procedure FileSeekError;
procedure CheckFileOpened;
procedure CheckFileWritable;
procedure BeforeOpen;dynamic;
procedure AfterOpen;dynamic;
procedure BeforeClose;dynamic;
procedure AfterClose;dynamic;
property FileHandle:THandle read FFileHandle;
public
constructor Create(AOwner:TComponent);override;
destructor Destroy;override;
procedure AssignFileProp(Source:TWin32File);
procedure OpenFile(const FileName:string='';ReadOnly:Boolean=False;Exclusive:Boolean=True);
procedure Open;
procedure Close;
procedure DeleteFile();
procedure DeleteAndFree();
procedure ReadBuffer(var Buffer;Count:DWord);
procedure WriteBuffer(const Buffer;Count:DWord);
function Read(var Buffer;Count:DWord):DWord;virtual;
function Write(const Buffer;Count:DWord):DWord;virtual;
function Seek(Ofs,OfsHigh:LongInt;Origin:Word):DWord;virtual;
procedure SetSize(NewSize,NewSizeHigh:DWord);virtual;
procedure FlushBuffers();
function ReadInteger:LongInt;
procedure WriteInteger(const IntValue:LongInt);
function ReadString:string;
procedure WriteString(const str:string);
procedure SkipString;
function Readln:string;overload;
function Readln(var str:string):Integer;overload;
procedure Writeln(const str:string);overload;
procedure Writeln(const str:PChar);overload;
procedure WriteChar(ch:char;repCount:Integer=1);
property Eof:Boolean read GetEof;
property Size:DWord read FSize;
property SizeHigh:DWord read FSizeHigh;
property Position:DWord read FPosition;
property PositionHigh:DWord read FPositionHigh;
published
property Active:Boolean read GetActive write SetActive default False;
property FileName:string read FFileName write SetFileName;
property ReadOnly:Boolean read GetReadOnly write SetReadOnly default False;
property Exclusive:Boolean read GetExclusive write SetExclusive default True;
property Temporary:Boolean read GetTemporary write SetTemporary default False;
property AutoDelete:Boolean read GetAutoDelete write SetAutoDelete default False;
property TrucExisting:Boolean read GetTrucExisting write SetTrucExisting default False;
property RandomAccess:Boolean read GetRandomAccess write SetRandomAccess default False;
property SequentialScan:Boolean read GetSequentialScan write SetSequentialScan default False;
property OnBeforeOpen:TNotifyEvent read FOnBeforeOpen write FOnBeforeOpen;
property OnAfterOpen:TNotifyEvent read FOnAfterOpen write FOnAfterOpen;
property OnBeforeClose:TNotifyEvent read FOnBeforeClose write FOnBeforeClose;
property OnAfterClose:TNotifyEvent read FOnAfterClose write FOnAfterClose;
end;
Win32FileClass=class of TWin32File;
const
Win32FileBufferSize=$10000;
type
TBufferedWin32File=class(TWin32File)
private
FBuffer:Pointer;
FBufferSize:DWord;
FFilePos,FFilePosHigh:DWord;
FDirtyBytes,FBytesInBuf,FFilePtrInc:DWord;
function GetCountOf64KBuf: DWord;
procedure SetCountOf64KBuf(Value: DWord);
protected
procedure AfterOpen;override;
procedure BeforeClose;override;
procedure SetBufferPosition(newPos,newPosHigh:DWord);
public
constructor Create(AOwner:TComponent);override;
destructor Destroy;override;
function Seek(Ofs,OfsHigh:LongInt;Origin:Word):DWord;override;
function Read(var Buffer;Count:DWord):DWord;override;
function Write(const Buffer;Count:DWord):DWord;override;
procedure SetSize(NewSize,NewSizeHigh:DWord);override;
procedure FlushBuffer;
published
property CountOf64KBuf:DWord read GetCountOf64KBuf write SetCountOf64KBuf default 1;
end;
TWin32FileStream=class(TStream)
private
FWin32File:TWin32File;
function GetFileName: string;
function GetHandle: THandle;
public
function Read(var Buffer; Count: Longint): Longint; override;
function Write(const Buffer; Count: Longint): Longint; override;
function Seek(Offset: Longint; Origin: Word): Longint; override;
public
constructor Create;overload;
constructor Create(const FileName: string; Mode: Word);overload;
destructor Destroy; override;
property Handle:THandle read GetHandle;
property FileName:string read GetFileName;
property Win32File:TWin32File read FWin32File;
end;
procedure CheckFileHandle(hFile:THandle;const ErrorInfo:string);
function Win32Check(RetVal:BOOL;const ErrorMsg:string='系统调用失败'): BOOL;
procedure LastWin32CallCheck(const ErrorMsg:string);
function FileExists(const FileName:string):Boolean;
function FileCanOpen(const FileName:string;ReadOnly:Boolean=False):Boolean;
function sReadln(Stream:TWin32File;var str:string):Integer;
{ file search }
type
TFileProcessProc=procedure (const FileName:string);
TFileProcessMethod=procedure (const FileName:string)of object;
procedure AddPathSpr(var Path:string);
function DeleteTailPathSpr(const Path:string):string;
procedure ForAllFile(SearchDir:string;FileProcessProc:TFileProcessProc;
DoSubDir:Boolean=False;const FileNameMask:string='*.*');overload;
procedure ForAllFile(SearchDir:string;FileProcessProc:TFileProcessMethod;
DoSubDir:Boolean=False;const FileNameMask:string='*.*');overload;
procedure ListDirFiles(SearchDir:string;FileList:TStrings;
ListPath:Boolean=True;DoSubDir:Boolean=False;const FileNameMask:string='*.*');
procedure ListSubDirectories(SearchDir:string;DirList:TStrings;ListPath:Boolean=False;Recurse:Boolean=False);
procedure EmptyDirectory(Directory:string;IncludeSubDir:Boolean);
procedure RemoveDirectory(const Directory:string);
procedure CopyDirectory(SrcDir,DstDir:string;OverWrite:Boolean=True;DoSubDir:Boolean=True;ProgressBar:TProgressBar=nil);
function CalcDirectorySize(Directory:string;DoSubDir:Boolean=True;const FileNameMask:string='*.*'):Cardinal;
function WaitFor(Handle:THandle): Boolean;
function ShellAndWait(const sAppName,sCmdLine:string;Minimize:Boolean):Integer;
var
SystemPageSize:DWord=4096;
SystemMaxSectorSize:DWord=512;
SystemAllocGranularity:DWord=$00010000;
type
PVirtualBlockInfo=^TVirtualBlockInfo;
TVirtualBlockInfo=packed record
MemoryPtr :Pointer;
ReserveSize :u_Int32;
CommitSize :u_Int32;
UsedSize :u_Int32;
end;
const
VirtualBlockInfoSize=sizeof(TVirtualBlockInfo);
type
{
TMiniMemAllocator designed for alloc large number of small
memory blocks at a time, and free them at last at the same time.
this will gain more efficiency, and will save some of
system's memory spending.
WARNING:
it cannot be re entered. use it in a simple thread!
}
TMiniMemAllocator=class//(TSharedObject)
private
//FAllocBy:Integer;
FVBlockCount:Integer;
FVBlocksInfo:array of TVirtualBlockInfo;
protected
procedure CommitMore(NeedSize:uInt32;pMemInfo:PVirtualBlockInfo);
procedure ReserveAndCommit(NeedSize:uInt32);
property VBlockCount:Integer read FVBlockCount;
public
//constructor Create(AllocBy:Integer=4);
destructor Destroy;override;
function AllocMem(NeedSize:uInt32):Pointer;
procedure FreeAll;
//property AllocBy:Integer read FAllocBy;
end;
implementation
uses Consts,RTLConsts;
const
sCR=#13#10;
wCR:Word=$0A0D;
procedure AddPathSpr(var Path:string);
begin
if(AnsiLastChar(Path)<>Nil)and(AnsiLastChar(Path)^<>'\')then
Path:=Path+'\'
end;
function DeleteTailPathSpr(const Path:string):string;
begin
if(AnsiLastChar(Path)<>Nil)and(AnsiLastChar(Path)^='\')then
Result:=Copy(Path,1,Length(Path)-1)
else Result:=Path;
end;
function sReadln(Stream:TWin32File;var str:string):Integer;
const wCR=13;lf=10;BufSize=256;
var
i,c,sp,p,ss:Integer;
Buffer:array[0..BufSize] of BYTE;
begin
Result:=0;SetLength(str,Result);
sp:=Stream.Position;ss:=Stream.Size;
p:=sp;
while(p<ss)do begin
c:=BufSize;
if(p+c>ss)then c:=ss-p;
Stream.ReadBuffer(Buffer,c);
Buffer[c]:=wCR;
i:=0;while(Buffer[i]<>wCR)do Inc(i);
if(i<c)then begin
if(i<c-1)then begin
Inc(i);
if(Buffer[i]=lf)then Inc(i);
Stream.Seek(p+i,0,sofromBeginning);
c:=i-2;
if(c>0)then begin
SetLength(str,Result+c);
System.Move(Buffer,Pointer(@str[Result+1])^,c);
Inc(Result,c);
end;
Exit;
end else begin
p:=p+c;
c:=i-1;
if(c>0)then begin
SetLength(str,Result+c);
System.Move(Buffer,Pointer(@str[Result+1])^,c);
Inc(Result,c);
end;
if(p<ss)then begin
Stream.ReadBuffer(Buffer,1);
if(Buffer[0]<>lf)then Stream.Seek(-1,0,soFromCurrent);
end;
end;
Exit;
end else begin
Inc(p,i);//i=c
SetLength(str,p-sp);
System.Move(Buffer,Pointer(@str[Result+1])^,i);
Inc(Result,i);
{if(p=ss)then begin
Result:=0;str:='';
end;}
end;
end;
end;
{ TWin32File }
constructor TWin32File.Create(AOwner:TComponent);
begin
inherited;
Exclusive:=True;
end;
destructor TWin32File.Destroy;
begin
Close;
inherited;
end;
function TWin32File.GetReadOnly: Boolean;
begin
Result:=FFileAttributes and faReadOnlyBitMask<>0;
end;
procedure TWin32File.SetReadOnly(const Value: Boolean);
begin
Assert(not Active);
if(Value)then begin
AutoDelete:=False;TrucExisting:=False;
FFileAttributes:=FFileAttributes or faReadOnlyBitMask
end else begin
FFileAttributes:=FFileAttributes and not faReadOnlyBitMask;
end;
end;
function TWin32File.GetExclusive: Boolean;
begin
Result:=FFileAttributes and faExclusiveBitMask<>0;
end;
procedure TWin32File.SetExclusive(const Value: Boolean);
begin
Assert(not Active);
if(Value)then begin
FFileAttributes:=FFileAttributes or faExclusiveBitMask
end else begin
FFileAttributes:=FFileAttributes and not faExclusiveBitMask;
end;
end;
function TWin32File.GetTrucExisting: Boolean;
begin
Result:=FFileAttributes and faTrucExistingBitMask<>0;
end;
procedure TWin32File.SetTrucExisting(const Value: Boolean);
begin
Assert(not Active);
if(Value)then begin
ReadOnly:=False;
FFileAttributes:=FFileAttributes or faTrucExistingBitMask
end else begin
FFileAttributes:=FFileAttributes and not faTrucExistingBitMask;
end;
end;
function TWin32File.GetRandomAccess: Boolean;
begin
Result:=FFileAttributes and faRandomAccessBitMask<>0;
end;
procedure TWin32File.SetRandomAccess(const Value: Boolean);
begin
Assert(not Active);
if(Value)then begin
SequentialScan:=False;
FFileAttributes:=FFileAttributes or faRandomAccessBitMask
end else begin
FFileAttributes:=FFileAttributes and not faRandomAccessBitMask;
end;
end;
function TWin32File.GetSequentialScan: Boolean;
begin
Result:=FFileAttributes and faSequentialScanBitMask<>0;
end;
procedure TWin32File.SetSequentialScan(const Value: Boolean);
begin
Assert(not Active);
if(Value)then begin
RandomAccess:=False;
FFileAttributes:=FFileAttributes or faSequentialScanBitMask
end else begin
FFileAttributes:=FFileAttributes and not faSequentialScanBitMask;
end;
end;
function TWin32File.GetTemporary: Boolean;
begin
Result:=FFileAttributes and faTemporaryBitMask<>0;
end;
procedure TWin32File.SetTemporary(const Value: Boolean);
begin
Assert(not Active);
if(Value)then begin
FFileAttributes:=FFileAttributes or faTemporaryBitMask
end else begin
FFileAttributes:=FFileAttributes and not faTemporaryBitMask;
end;
end;
function TWin32File.GetAutoDelete: Boolean;
begin
Result:=FFileAttributes and faAutoDeleteBitMask<>0;
end;
procedure TWin32File.SetAutoDelete(const Value: Boolean);
begin
Assert(not Active);
if(Value)then begin
ReadOnly:=False;
FFileAttributes:=FFileAttributes or faAutoDeleteBitMask
end else begin
FFileAttributes:=FFileAttributes and not faAutoDeleteBitMask;
end;
end;
procedure TWin32File.SetFileName(const Value: string);
begin
Assert(not Active);
FFileName:=Value;
end;
function TWin32File.GetActive: Boolean;
begin
Result:=FFileHandle<>0;
end;
procedure TWin32File.AssignFileProp(Source:TWin32File);
begin
if(Source<>nil)then begin
FileName:=Source.FileName;
FFileAttributes:=Source.FFileAttributes;
OnBeforeOpen:=Source.OnBeforeOpen;
OnAfterOpen:=Source.OnAfterOpen;
OnBeforeClose:=Source.OnBeforeClose;
OnAfterClose:=Source.OnAfterClose;
end;
end;
procedure TWin32File.SetActive(const Value: Boolean);
begin
if(Value)and(FFileHandle=0)then Open
else if(not Value)and(FFileHandle<>0)then Close;
end;
procedure TWin32File.BeforeOpen;
begin
if(Assigned(OnBeforeOpen))then OnBeforeOpen(Self);
end;
procedure TWin32File.AfterOpen;
begin
if(Assigned(OnAfterOpen))then OnAfterOpen(Self);
end;
procedure TWin32File.OpenFile(const FileName: string; ReadOnly,
Exclusive: Boolean);
begin
if(Active)then
raise EWin32FileError.CreateFmt('文件 %s 已经打开',[FileName]);
FFileName:=FileName;
Self.ReadOnly:=ReadOnly;
Self.Exclusive:=Exclusive;
Open;
end;
procedure TWin32File.Open;
const
AccessModes:array[Boolean] of DWord=(GENERIC_READ or GENERIC_WRITE,GENERIC_READ);
ShareModes:array[Boolean]of DWord=(FILE_SHARE_READ,{$IFDEF AlwaysShareRead}FILE_SHARE_READ{$ELSE}0{$ENDIF});
CreationFlags:array[Boolean,Boolean]of DWord=
((OPEN_ALWAYS,OPEN_EXISTING),(Create_ALWAYS,OPEN_EXISTING));
RSeekFlags:array[Boolean]of DWord=(0,FILE_FLAG_RANDOM_ACCESS);
SSeekFlags:array[Boolean]of DWord=(0,FILE_FLAG_SEQUENTIAL_SCAN);
TempFlags:array[Boolean]of DWord=(0,FILE_ATTRIBUTE_TEMPORARY);
DeleteFlags:array[Boolean]of DWord=(0,FILE_FLAG_DELETE_ON_CLOSE);
begin
if(Active)then Exit;
if(FileName='')then
raise EWin32FileError.Create('文件名没有指定');
if(ReadOnly)and(not FileExists(FileName))then
raise EWin32FileError.CreateFmt('文件 %s 不存在',[FileName]);
BeforeOpen;
FSize:=0;FSizeHigh:=0;
FPosition:=0;FPositionHigh:=0;
FFileHandle:=CreateFile(PChar(FileName),AccessModes[ReadOnly],
ShareModes[Exclusive],nil,CreationFlags[TrucExisting,ReadOnly],
FILE_ATTRIBUTE_NORMAL
or TempFlags[Temporary] or DeleteFlags[AutoDelete]
or RSeekFlags[RandomAccess] or SSeekFlags[SequentialScan],
0);
if(FFileHandle=INVALID_HANDLE_VALUE)then FFileHandle:=0;
if(FFileHandle=0)then
LastWin32CallCheck(Format('打开文件 %s 错误',[FileName]));
try
FSize:=GetFileSize(FFileHandle,@FSizeHigh);
if(FSize=MightErrorReturn)then
LastWin32CallCheck(Format('获取文件 %s 大小错误',[FileName]));
except
CloseHandle(FFileHandle);
FFileHandle:=0;
raise ;
end;
AfterOpen;
end;
procedure TWin32File.BeforeClose;
begin
if(Assigned(OnBeforeClose))then OnBeforeClose(Self);
end;
procedure TWin32File.AfterClose;
begin
if(Assigned(OnAfterClose))then OnAfterClose(Self);
end;
procedure TWin32File.Close;
var
hFile:THandle;
begin
if(not Active)then Exit;
BeforeClose();
hFile:=FFileHandle;FFileHandle:=0;
if(CloseHandle(hFile)=FALSE)then
LastWin32CallCheck(Format('关闭文件 %s 错误',[FileName]));
AfterClose();
end;
procedure TWin32File.DeleteFile();
begin
if(Active)then
raise EWin32FileError.CreateFmt('文件 %s 已经打开',[FileName]);
if(FileName<>'')then Windows.DeleteFile(PChar(FileName));
end;
procedure TWin32File.DeleteAndFree();
begin
if(Self=nil)then Exit;
Close();
DeleteFile();
Destroy;
end;
function TWin32File.GetEof: Boolean;
begin
Result:=(FPositionHigh>FSizeHigh)or
((FPositionHigh=FSizeHigh)and(FPosition>=FSize));
end;
procedure TWin32File.SetSize(NewSize,NewSizeHigh: DWord);
begin
Seek(NewSize,NewSizeHigh,FILE_BEGIN);
if(SetEndOfFile(FFileHandle)=FALSE)then
LastWin32CallCheck(Format('设置文件 %s 大小错误',[FileName]));
FSize:=NewSize;FSizeHigh:=NewSizeHigh;
end;
procedure TWin32File.FileReadError;
begin
LastWin32CallCheck(Format('读文件 %s 错误',[FileName]));
end;
procedure TWin32File.FileWriteError;
begin
LastWin32CallCheck(Format('写文件 %s 错误',[FileName]));
end;
procedure TWin32File.FileSeekError;
begin
LastWin32CallCheck(Format('移动文件 %s 指针错误',[FileName]));
end;
procedure TWin32File.CheckFileOpened;
begin
if(not Active)then
raise EWin32FileError.CreateFmt('文件 %s 没有打开',[FileName]);
end;
procedure TWin32File.CheckFileWritable;
begin
if(ReadOnly)then
raise EWin32FileError.CreateFmt('文件 %s 以只读方式打开,不能写',[FileName]);
end;
function TWin32File.Seek(Ofs,OfsHigh:LongInt;Origin:Word): DWord;
var
newPos,newPosHigh:DWord;
begin
CheckFileOpened;
case Origin of
FILE_BEGIN:
begin
newPos:=Ofs;newPosHigh:=OfsHigh;
end;
FILE_CURRENT:
asm
MOV ECX,Self
MOV EAX,[ECX].FPosition
MOV EDX,[ECX].FPositionHigh
ADD EAX,Ofs
ADC EDX,OfsHigh
MOV newPos,EAX
MOV newPosHigh,EDX
end;
FILE_END:
asm
MOV ECX,Self
MOV EAX,[ECX].FSize
MOV EDX,[ECX].FSizeHigh
ADD EAX,Ofs
ADC EDX,OfsHigh
MOV newPos,EAX
MOV newPosHigh,EDX
end;
else raise EWin32FileError.Create('参数错误');
end;
if(FPosition<>newPos)or(FPositionHigh<>newPosHigh)then begin
if(MightErrorReturn=SetFilePointer(FFileHandle,Ofs,@OfsHigh,Origin))
then FileSeekError;
FPosition:=newPos;FPositionHigh:=newPosHigh;
end;
Result:=FPosition;
end;
procedure TWin32File.ReadBuffer(var Buffer;Count:DWord);
begin
if(Count<>0)and(Read(Buffer,Count)<>Count)then
raise EWin32FileError.CreateFmt('读文件 %s 长度不对',[FileName]);
end;
procedure TWin32File.WriteBuffer(const Buffer;Count:DWord);
begin
if(Count<>0)and(Write(Buffer,Count)<>Count)then
raise EWin32FileError.CreateFmt('写文件 %s 长度不对',[FileName]);
end;
function TWin32File.Read(var Buffer; Count: DWord): DWord;
begin
CheckFileOpened;
if(not ReadFile(FFileHandle,Buffer,Count,Result,nil))then
FileReadError;
asm
MOV ECX,Self
MOV EAX,[ECX].FPosition
MOV EDX,[ECX].FPositionHigh
ADD EAX,Result
ADC EDX,0
MOV [ECX].FPosition,EAX
MOV [ECX].FPositionHigh,EDX
end;
end;
function TWin32File.Write(const Buffer; Count: DWord): DWord;
begin
CheckFileOpened;
CheckFileWritable;
if(not WriteFile(FFileHandle,Buffer,Count,Result,nil))then
FileWriteError;
asm
MOV ECX,Self
MOV EAX,[ECX].FPosition
MOV EDX,[ECX].FPositionHigh
ADD EAX,Result
ADC EDX,0
MOV [ECX].FPosition,EAX
MOV [ECX].FPositionHigh,EDX
end;
if(FPositionHigh>FSizeHigh)or((FPositionHigh=FSizeHigh)
and(FPosition>FSize))then begin
FSize:=FPosition;
FSizeHigh:=FPositionHigh;
end;
end;
procedure TWin32File.FlushBuffers();
begin
FlushFileBuffers(FileHandle);
end;
function TWin32File.ReadInteger: LongInt;
begin
ReadBuffer(Result,sizeof(LongInt));
end;
procedure TWin32File.WriteInteger(const IntValue: Integer);
begin
WriteBuffer(IntValue,sizeof(LongInt));
end;
function TWin32File.ReadString: string;
var
sLen:LongInt;
begin
sLen:=ReadInteger;
if(sLen>0)then begin
SetString(Result,nil,sLen);
ReadBuffer(Pointer(Result)^,sLen);
end else
Result:='';
end;
procedure TWin32File.WriteString(const str: string);
var
sLen:LongInt;
begin
sLen:=Length(str);
WriteInteger(sLen);
if(sLen>0)then begin
WriteBuffer(Pointer(str)^,sLen);
end;
end;
procedure TWin32File.SkipString;
var
sLen:LongInt;
begin
sLen:=ReadInteger;
if(sLen>0)then begin
Seek(sLen,0,FILE_CURRENT);
end;
end;
function TWin32File.Readln:string;
begin
Readln(Result);
end;
function TWin32File.Readln(var str:string):Integer;
begin
//Result:=;
//raise EWin32FileError.Create('not finished');
Result:=ShareWin.sReadln(Self,str);
end;
procedure TWin32File.Writeln(const str: PChar);
var
sLen:LongInt;
begin
sLen:=StrLen(str);
if(sLen>0)then Write(str^,sLen);
Write(wCR,Sizeof(wCR));
end;
procedure TWin32File.Writeln(const str: string);
begin
if(str<>'')then
Write(Pointer(str)^,Length(str));
Write(wCR,Sizeof(wCR));
end;
procedure TWin32File.WriteChar(ch:char;repCount:Integer=1);
var
wc:Integer;
Buf:array[0..63] of char;
begin
if(repCount>sizeof(buf))then wc:=sizeof(buf) else wc:=repCount;
FillChar(Buf,wc,ch);
while(repCount>0)do begin
if(repCount>sizeof(buf))then wc:=sizeof(buf) else wc:=repCount;
Write(Buf,wc);
Dec(repCount,wc);
end;
end;
{ TBufferedWin32File }
constructor TBufferedWin32File.Create(AOwner:TComponent);
begin
inherited;
CountOf64KBuf:=1;
end;
destructor TBufferedWin32File.Destroy;
var
pBuf:Pointer;
begin
if(FBuffer<>nil)then begin
pBuf:=FBUffer;FBuffer:=nil;
if(VirtualFree(pBuf,0,MEM_DECOMMIT or MEM_RELEASE)=FALSE)then
LastWin32CallCheck('释放缓冲区异常');
end;
inherited;
end;
function TBufferedWin32File.GetCountOf64KBuf: DWord;
begin
Result:=FBufferSize div Win32FileBufferSize;
end;
procedure TBufferedWin32File.SetCountOf64KBuf(Value: DWord);
var
pBuf:Pointer;
begin
Assert(not Active);
if(Value=0)or(Value=CountOf64KBuf)then Exit;
if(Value>1024)then Value:=1024;//16M
FBufferSize:=Value*Win32FileBufferSize;
if(FBuffer<>nil)then begin
pBuf:=FBUffer;FBuffer:=nil;
if(VirtualFree(pBuf,0,MEM_DECOMMIT or MEM_RELEASE)=FALSE)then
LastWin32CallCheck('释放缓冲区异常');
end;
FBuffer:=VirtualAlloc(nil,FBufferSize,MEM_RESERVE or MEM_COMMIT,PAGE_READWRITE);
if(FBuffer=nil)then LastWin32CallCheck('无法分配缓冲区');
end;
procedure TBufferedWin32File.SetSize(NewSize, NewSizeHigh: DWord);
begin
FlushBuffer;
inherited;
end;
procedure TBufferedWin32File.AfterOpen;
begin
FDirtyBytes:=0;FFilePosHigh:=0;FFilePos:=FBufferSize;
SetBufferPosition(0,0);
end;
procedure TBufferedWin32File.BeforeClose;
begin
FlushBuffer;
end;
procedure TBufferedWin32File.SetBufferPosition(newPos,newPosHigh:DWord);
var
cbToRead:DWord;
begin
FlushBuffer;
newPos:=(newPos+Win32FileBufferSize-1)and not Win32FileBufferSize;
if(FFilePos<>newPos)or(FFilePosHigh<>newPosHigh)then begin
if(MightErrorReturn=SetFilePointer(FFileHandle,newPos,@newPosHigh,FILE_BEGIN))
then FileSeekError;
FFilePos:=newPos;FFilePosHigh:=newPosHigh;
end;
cbToRead:=FSize-newPos;
if(cbToRead>FBufferSize)or(FSizeHigh>FFilePosHigh)then cbToRead:=FBufferSize;
if(not ReadFile(FFileHandle,FBuffer^,cbToRead,FFilePtrInc,nil))then
FileReadError;
FBytesInBuf:=FFilePtrInc;
asm
MOV ECX,Self
MOV EAX,[ECX].FFilePos
MOV EDX,[ECX].FFilePosHigh
ADD EAX,[ECX].FFilePtrInc
ADC EDX,0
MOV [ECX].FFilePos,EAX
MOV [ECX].FFilePosHigh,EDX
end;
end;
procedure TBufferedWin32File.FlushBuffer;
begin
if(FDirtyBytes=0)then Exit;
asm
MOV ECX,Self
MOV EAX,[ECX].FFilePos
MOV EDX,[ECX].FFilePosHigh
SUB EAX,[ECX].FFilePtrInc
SBB EDX,0
MOV [ECX].FFilePos,EAX
MOV [ECX].FFilePosHigh,EDX
end;
if(MightErrorReturn=SetFilePointer(FFileHandle,FFilePos,@FFilePosHigh,FILE_BEGIN))
then FileSeekError;
if(not WriteFile(FFileHandle,FBuffer^,FDirtyBytes,FFilePtrInc,nil))then
FileWriteError;
asm
MOV ECX,Self
MOV EAX,[ECX].FFilePos
MOV EDX,[ECX].FFilePosHigh
ADD EAX,[ECX].FFilePtrInc
ADC EDX,0
MOV [ECX].FFilePos,EAX
MOV [ECX].FFilePosHigh,EDX
end;
FDirtyBytes:=0;
end;
function TBufferedWin32File.Seek(Ofs,OfsHigh:LongInt;Origin:Word):DWord;
begin
CheckFileOpened;
case Origin of
FILE_BEGIN:
begin
FPosition:=Ofs;FPositionHigh:=OfsHigh;
end;
FILE_CURRENT:
asm
MOV ECX,Self
MOV EAX,[ECX].FPosition
MOV EDX,[ECX].FPositionHigh
ADD EAX,Ofs
ADC EDX,OfsHigh
MOV [ECX].FPosition,EAX
MOV [ECX].FPositionHigh,EDX
end;
FILE_END:
asm
MOV EAX,[ECX].FSize
MOV EDX,[ECX].FSizeHigh
ADD EAX,Ofs
ADC EDX,OfsHigh
MOV [ECX].FPosition,EAX
MOV [ECX].FPositionHigh,EDX
end;
else raise EWin32FileError.Create('参数错误');
end;
Result:=FPosition;
end;
function TBufferedWin32File.Read(var Buffer;Count:DWord): DWord;
var
p:Pointer;
begin
CheckFileOpened;
raise EWin32FileError.Create('not finished');
if(FPositionHigh>FSizeHigh)then Count:=0
else if(FPositionHigh=FSizeHigh)then begin
if(FPosition>=FSize)then Count:=0
else if(FSize-FPosition>Count)then Count:=FSize-FPosition;
end;
Result:=Count;
if(Result=0)then Exit;
if(FPositionHigh=FFilePosHigh)and
(FPosition+Count<FFilePos-FFilePtrInc+FBytesInBuf)and
(FPosition>=FFilePos-FFilePtrInc)then begin
p:=Pointer(DWord(FBuffer)+FPosition-FFilePos+FFilePtrInc);
System.Move(p^,Buffer,Count);
asm
MOV ECX,Self
MOV EAX,[ECX].FPosition
MOV EDX,[ECX].FPositionHigh
ADD EAX,Result
ADC EDX,0
MOV [ECX].FPosition,EAX
MOV [ECX].FPositionHigh,EDX
end;
end else begin
end;
end;
function TBufferedWin32File.Write(const Buffer; Count: DWord): DWord;
begin
CheckFileOpened;
CheckFileWritable;
raise EWin32FileError.Create('not finished');
Result:=Count;
end;
{ TWin32FileStream }
constructor TWin32FileStream.Create;
begin
inherited Create();
FWin32File:=TWin32File.Create(nil);
end;
constructor TWin32FileStream.Create(const FileName: string; Mode: Word);
begin
inherited Create();
FWin32File:=TWin32File.Create(nil);
if(Mode=fmCreate)then begin
Win32File.ReadOnly:=False;
Win32File.Exclusive:=True;
Win32File.TrucExisting:=True;
end else begin
Win32File.ReadOnly:=Mode and (fmOpenWrite or fmOpenReadWrite)=0;
Win32File.Exclusive:=Mode and (fmShareExclusive or fmShareDenyWrite or fmShareDenyRead)<>0;
Win32File.TrucExisting:=False;
end;
if(FileName<>'')then begin
Win32File.FileName:=FileName;
Win32File.Open;
end;
end;
destructor TWin32FileStream.Destroy;
begin
Win32File.Free;
inherited;
end;
function TWin32FileStream.GetFileName: string;
begin
Result:=Win32File.FileName;
end;
function TWin32FileStream.GetHandle: THandle;
begin
Result:=Win32File.FileHandle;
end;
function TWin32FileStream.Read(var Buffer; Count: Integer): Longint;
begin
if(Count>0)then
Result:=Win32File.Read(Buffer,Count)
else Result:=0;
end;
function TWin32FileStream.Seek(Offset: Integer; Origin: Word): Longint;
begin
Result:=Win32File.Seek(Offset,0,Origin)
end;
function TWin32FileStream.Write(const Buffer; Count: Integer): Longint;
begin
if(Count>0)then
Result:=Win32File.Write(Buffer,Count)
else Result:=0;
end;
procedure CheckFileHandle(hFile:THandle;const ErrorInfo:string);
var
LastError: DWORD;
Error: EOSError;
begin
if(hFile=0)or(hFile=INVALID_HANDLE_VALUE)then begin
LastError := GetLastError;
Error:=EOSError.CreateFmt('%s%s错误号:%d%s错误信息:%s',
[ErrorInfo,sCR,LastError,sCR,SysErrorMessage(LastError)]);
Error.ErrorCode:=LastError;
raise Error;
end;
end;
function Win32Check(RetVal:BOOL;const ErrorMsg:string): BOOL;
var
LastError: DWORD;
Error: EOSError;
begin
if not RetVal then begin
LastError:=GetLastError;
Error:=EOSError.CreateFmt('%s%s错误号:%d%s错误信息:%s',
[ErrorMsg,sCR,LastError,sCR,SysErrorMessage(LastError)]);
Error.ErrorCode:=LastError;
raise Error;
end;
Result := RetVal;
end;
procedure LastWin32CallCheck(const ErrorMsg:string);
var
LastError: DWORD;
Error: EOSError;
begin
LastError:=GetLastError;
if(LastError=ERROR_SUCCESS)then Exit;
Error:=EOSError.CreateFmt('%s%s错误号:%d%s错误信息:%s',
[ErrorMsg,sCR,LastError,sCR,SysErrorMessage(LastError)]);
Error.ErrorCode:=LastError;
raise Error;
end;
function FileExists(const FileName:string):Boolean;
var
hFind:THandle;
FindData:_Win32_Find_Data;
begin
hFind:=Windows.FindFirstFile(PChar(FileName),FindData);
Result:=hFind<>Invalid_Handle_Value;
if(Result)then Windows.FindClose(hFind);
if(Result)and(FindData.dwFileAttributes and faDirectory
=faDirectory)then Result:=False;
end;
function FileCanOpen(const FileName:string;ReadOnly:Boolean):Boolean;
const
OpenFlags:array[Boolean] of DWord=(OF_READ or OF_WRITE,OF_READ);
var
hFile:THandle;
OD:OFSTRUCT;
begin
Result:=FileExists(FileName);
if(Result)then begin
FillChar(OD,sizeof(OFSTRUCT),0);
OD.cBytes:=sizeof(OFSTRUCT);
hFile:=Windows.OpenFile(PChar(FileName),OD,OpenFlags[ReadOnly]);
Result:=(hFile<>HFILE_ERROR)and(hFile<>0);
if(Result)then CloseHandle(hFile);
end;
end;
function AddTailPathSpr(const aPath:string):string;
var
pLast:PChar;
begin
pLast:=AnsiLastChar(aPath);
if(pLast<>nil)and(pLast^<>'\')then
Result:=aPath+'\'
else
Result:=aPath;
end;
function DelTailPathSpr(const aPath:string):string;
var
pLast:PChar;
begin
pLast:=AnsiLastChar(aPath);
if(pLast=nil)or(pLast^<>'\')then Result:=aPath
else Result:=Copy(aPath,1,Length(aPath)-1{Single Byte});
end;
function WaitFor(Handle:THandle): Boolean;
var
Msg: TMsg;
Ret: DWORD;
begin
if GetCurrentThreadID = MainThreadID then
begin
repeat
Ret := MsgWaitForMultipleObjects(1,Handle,False,3000,QS_PAINT);
if(Ret=WAIT_TIMEOUT)or(Ret=WAIT_OBJECT_0+1)then
begin
while(PeekMessage(Msg,0,0,0,PM_REMOVE))do
begin
if(Msg.message=WM_PAINT)then
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end;
end else
Break;
until False;
Result := Ret <> MAXDWORD;
end else
begin
Ret := WaitForSingleObject(Handle, INFINITE);
Result := Ret <> WAIT_FAILED;
end;
end;
function ShellAndWait(const sAppName,sCmdLine:string;Minimize:Boolean):Integer;
var
I,P,L:Integer;
ExitCode:DWord;
AppDir:string;
App,Cmd,Dir:PChar;
StartInfo:STARTUPINFO;
AppInfo:PROCESS_INFORMATION;
begin
FillChar(StartInfo,sizeof(StartInfo),0);
StartInfo.cb:=sizeof(StartInfo);
if(Minimize)then
StartInfo.wShowWindow:=SW_MINIMIZE;
FillChar(AppInfo,sizeof(AppInfo),0);
AppDir:='';
if(sAppName='')then App:=nil
else begin
App:=PChar(sAppName);
AppDir:=ExtractFilePath(sAppName);
end;
if(sCmdLine='')then Cmd:=nil else
begin
Cmd:=PChar(sCmdLine);
I:=1;L:=Length(sCmdLine);
while(I<=L)and(sCmdLine[I]=' ')do Inc(I);
if(I<L)then
begin
if(sCmdLine[I]='"')then
begin
P:=I+1;
while(I<=L)and(sCmdLine[I]<>'"')do Inc(I);
end else begin
P:=I;
while(I<=L)and(sCmdLine[I]<>' ')do Inc(I);
end;
AppDir:=ExtractFilePath(Copy(sCmdLine,P,I-P));
end;
end;
if(AppDir='')then Dir:=nil else Dir:=PChar(AppDir);
Win32Check(CreateProcess(App,Cmd,
nil,nil,False,NORMAL_PRIORITY_CLASS,
nil,Dir,StartInfo,AppInfo),'创建进程');
try
CloseHandle(AppInfo.hThread);
SetLastError(0);
if not WaitFor(AppInfo.hProcess) then
LastWin32CallCheck('等待进程结束');
while(GetExitCodeProcess(AppInfo.hProcess,ExitCode))
and(ExitCode=STILL_ACTIVE)do
Sleep(1);//Application.ProcessMessages;
Result:=ExitCode;
finally
CloseHandle(AppInfo.hProcess);
end;
end;
procedure ForAllFile(SearchDir:string;FileProcessProc:TFileProcessProc;
DoSubDir:Boolean=False;const FileNameMask:string='*.*');
var
Name:string;
hFind:THandle;
FindData:TWin32FindData;
begin
SearchDir:=AddTailPathSpr(SearchDir);
FillChar(FindData,sizeof(FindData),0);
hFind:=FindFirstFile(PChar(SearchDir+FileNameMask),FindData);
if(hFind<>INVALID_HANDLE_VALUE)then begin
repeat
Name:=StrPas(FindData.cFileName);
if(FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY=0)then
FileProcessProc(SearchDir+Name);
until (not FindNextFile(hFind,FindData));
Windows.FindClose(hFind);
end;
if(not DoSubDir)then Exit;
FillChar(FindData,sizeof(FindData),0);
hFind:=FindFirstFile(PChar(SearchDir+'*.*'),FindData);
if(hFind<>INVALID_HANDLE_VALUE)then begin
repeat
Name:=StrPas(FindData.cFileName);
if(FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY<>0)then begin
if(Name<>'.')and(Name<>'..')then
ForAllFile(SearchDir+Name,FileProcessProc,True,FileNameMask);
end;
until (not FindNextFile(hFind,FindData));
Windows.FindClose(hFind);
end;
end;
procedure ForAllFile(SearchDir:string;FileProcessProc:TFileProcessMethod;
DoSubDir:Boolean=False;const FileNameMask:string='*.*');
var
Name:string;
hFind:THandle;
FindData:TWin32FindData;
begin
SearchDir:=AddTailPathSpr(SearchDir);
FillChar(FindData,sizeof(FindData),0);
hFind:=FindFirstFile(PChar(SearchDir+FileNameMask),FindData);
if(hFind<>INVALID_HANDLE_VALUE)then begin
repeat
Name:=StrPas(FindData.cFileName);
if(FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY=0)then
FileProcessProc(SearchDir+Name);
until (not FindNextFile(hFind,FindData));
Windows.FindClose(hFind);
end;
if(not DoSubDir)then Exit;
FillChar(FindData,sizeof(FindData),0);
hFind:=FindFirstFile(PChar(SearchDir+'*.*'),FindData);
if(hFind<>INVALID_HANDLE_VALUE)then begin
repeat
Name:=StrPas(FindData.cFileName);
if(FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY<>0)then begin
if(Name<>'.')and(Name<>'..')then
ForAllFile(SearchDir+Name,FileProcessProc,True,FileNameMask);
end;
until (not FindNextFile(hFind,FindData));
Windows.FindClose(hFind);
end;
end;
type
TFileListor=class
private
FCopyStart:Integer;
FFileList:TStrings;
public
procedure AddFileToList(const FileName:string);
end;
procedure TFileListor.AddFileToList(const FileName:string);
begin
if(FCopyStart=0)then FFileList.Add(FileName)
else FFileList.Add(Copy(FileName,FCopyStart,MaxInt));
end;
procedure ListDirFiles(SearchDir:string;FileList:TStrings;
ListPath:Boolean;DoSubDir:Boolean;const FileNameMask:string);
var
Listor:TFileListor;
begin
FileList.BeginUpdate;
try
FileList.Clear;
Listor:=TFileListor.Create();
try
Listor.FFileList:=FileList;
if(not ListPath)then begin
SearchDir:=AddTailPathSpr(SearchDir);
Listor.FCopyStart:=Length(SearchDir)+1;
end;
ForAllFile(SearchDir,Listor.AddFileToList,DoSubDir,FileNameMask);
finally
Listor.Free;
end;
finally
FileList.EndUpdate;
end;
end;
procedure ListSubDirectories(SearchDir:string;DirList:TStrings;ListPath:Boolean;Recurse:Boolean);
var
Name:string;
hFind:THandle;
FindData:TWin32FindData;
begin
SearchDir:=AddTailPathSpr(SearchDir);
DirList.BeginUpdate;
try
FillChar(FindData,sizeof(FindData),0);
hFind:=FindFirstFile(PChar(SearchDir+'*.*'),FindData);
if(hFind<>INVALID_HANDLE_VALUE)then
begin
repeat
Name:=StrPas(FindData.cFileName);
if(FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY<>0)
and(Name<>'.')and(Name<>'..')then
begin
if(ListPath)then DirList.Add(SearchDir+Name) else DirList.Add(Name);
if(Recurse)then ListSubDirectories(SearchDir+Name,DirList,ListPath,True);
end;
until (not FindNextFile(hFind,FindData));
Windows.FindClose(hFind);
end;
finally
DirList.EndUpdate;
end;
end;
function DirectoryExists(const Name: string): Boolean;
var
Code: Integer;
begin
Code := GetFileAttributes(PChar(Name));
Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
end;
function ForceDirectories(Dir: string): Boolean;
begin
Result := True;
if Length(Dir) = 0 then
raise Exception.Create('创建目录失败');
Dir := ExcludeTrailingBackslash(Dir);
if (Length(Dir) < 3) or DirectoryExists(Dir)
or (ExtractFilePath(Dir) = Dir) then Exit; // avoid 'xyz:\' problem.
Result := ForceDirectories(ExtractFilePath(Dir)) and CreateDir(Dir);
end;
procedure EmptyDirectory(Directory:string;IncludeSubDir:Boolean);
var
Name:string;
hFind:THandle;
FindData:TWin32FindData;
begin
if(Directory='')then Exit;
Directory:=DelTailPathSpr(Directory);
FillChar(FindData,sizeof(FindData),0);
hFind:=FindFirstFile(PChar(Directory+'\*.*'),FindData);
if(hFind<>INVALID_HANDLE_VALUE)then begin
repeat
Name:=StrPas(FindData.cFileName);
if(FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY<>0)then begin
if(IncludeSubDir)and(Name<>'.')and(Name<>'..')then
RemoveDirectory(Directory+'\'+Name);
end else
DeleteFile(Directory+'\'+Name);
until (not FindNextFile(hFind,FindData));
Windows.FindClose(hFind);
end;
end;
procedure RemoveDirectory(const Directory:string);
begin
EmptyDirectory(Directory,True);
RemoveDir(Directory);
end;
procedure CopyDirectory(SrcDir,DstDir:string;OverWrite:Boolean=True;DoSubDir:Boolean=True;ProgressBar:TProgressBar=nil);
var
I:Integer;
CpyList:TStringList;
begin
CpyList:=TStringList.Create;
try
AddPathSpr(SrcDir);
AddPathSpr(DstDir);
ForceDirectories(DstDir);
if(DoSubDir)then begin
ListSubDirectories(SrcDir,CpyList);
for I:=0 to CpyList.Count-1 do
CopyDirectory(SrcDir+CpyList[I],DstDir+CpyList[I],OverWrite,DoSubDir,ProgressBar);
end;
ListDirFiles(SrcDir,CpyList,False);
if ProgressBar <> nil then
begin
ProgressBar.Max := CpyList.Count;
ProgressBar.Position := 0;
end;
for I:=0 to CpyList.Count-1 do
begin
CopyFile(PChar(SrcDir+CpyList[I]),PChar(DstDir+CpyList[I]),not OverWrite);
if ProgressBar <> nil then
begin
ProgressBar.Position := ProgressBar.Position + 1;
Application.ProcessMessages;
end;
end;
finally
CpyList.Free;
end;
end;
function CalcDirectorySize(Directory:string;DoSubDir:Boolean;const FileNameMask:string):Cardinal;
var
Name:string;
hFind:THandle;
FindData:TWin32FindData;
begin
Result:=0;
Directory:=AddTailPathSpr(Directory);
FillChar(FindData,sizeof(FindData),0);
hFind:=FindFirstFile(PChar(Directory+FileNameMask),FindData);
if(hFind<>INVALID_HANDLE_VALUE)then begin
repeat
Name:=StrPas(FindData.cFileName);
if(FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY=0)then
Result:=Result+FindData.nFileSizeLow;
until (not FindNextFile(hFind,FindData));
Windows.FindClose(hFind);
end;
if(not DoSubDir)then Exit;
FillChar(FindData,sizeof(FindData),0);
hFind:=FindFirstFile(PChar(Directory+'*.*'),FindData);
if(hFind<>INVALID_HANDLE_VALUE)then begin
repeat
Name:=StrPas(FindData.cFileName);
if(FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY<>0)then begin
if(Name<>'.')and(Name<>'..')then
Result:=Result+CalcDirectorySize(Directory+Name,True,FileNameMask);
end;
until (not FindNextFile(hFind,FindData));
Windows.FindClose(hFind);
end;
end;
function DAHeapAlloc(dwBytes:u_Int32):Pointer;
begin
Result:=HeapAlloc(
DynamicArrayHeap,
HEAP_GENERATE_EXCEPTIONS,
dwBytes);
end;
function DAHeapAlloc0(dwBytes:u_Int32):Pointer;
begin
Result:=HeapAlloc(
DynamicArrayHeap,
HEAP_GENERATE_EXCEPTIONS or HEAP_ZERO_MEMORY,
dwBytes);
end;
function DAHeapReAlloc(lpMem:Pointer;dwBytes:u_Int32):Pointer;
begin
Result:=HeapReAlloc(
DynamicArrayHeap,
HEAP_GENERATE_EXCEPTIONS,
lpMem,
dwBytes);
end;
function DAHeapReAlloc0(lpMem:Pointer;dwBytes:u_Int32):Pointer;
begin
Result:=HeapReAlloc(
DynamicArrayHeap,
HEAP_GENERATE_EXCEPTIONS or HEAP_ZERO_MEMORY,
lpMem,
dwBytes);
end;
function DAHeapFree(lpMem:Pointer):BOOL;
begin
Result:=HeapFree(DynamicArrayHeap,0,lpMem);
end;
procedure DAHeapCompact();
begin
HeapCompact(DynamicArrayHeap,0);
end;
{ TCommon32bArray }
procedure TCommon32bArray.LoadFromStream(Stream:TStream);
var
dwCount,dwCountH:u_Int32;
begin
Stream.ReadBuffer(dwCount,sizeof(dwCount));
Stream.ReadBuffer(dwCountH,sizeof(dwCountH));
if(u_Int32(Capacity)<dwCount)then Clear();
AdjustCount(dwCount,False);
Stream.ReadBuffer(Memory^,DataSize);
end;
procedure TCommon32bArray.SaveToStream(Stream: TStream);
var
dwCount:u_Int32;
begin
dwCount:=Count;
Stream.WriteBuffer(dwCount,sizeof(dwCount));
dwCount:=0;
Stream.WriteBuffer(dwCount,sizeof(dwCount));
Stream.WriteBuffer(Memory^,DataSize);
end;
procedure TCommon32bArray.ReAlloc(var MemPtr:Pointer;newCapacity:Integer);
begin
//Assert(newCapacity>0);
if(Capacity=0)then begin
MemPtr:=DAHeapAlloc(newCapacity shl 2);
end else if(newCapacity=0)then begin
DAHeapFree(MemPtr);MemPtr:=nil;
end else begin
MemPtr:=DAHeapReAlloc(MemPtr,newCapacity shl 2);
end;
end;
{ TMiniMemAllocator }
const
sVirtualAllocFailed='虚拟内存分配失败!';
sVirtualFreeFailed='虚拟内存释放失败!';
function TMiniMemAllocator.AllocMem(NeedSize:uInt32):Pointer;
asm
PUSH EBX
PUSH ESI
PUSH EDI
MOV EBX,EAX
{MOV EAX,[EBX].FAllocBy
DEC EAX}
MOV EAX,$3 ////FAllocBy////
ADD EDX,EAX
NOT EAX
AND EAX,EDX
JZ @@Exit //Zero Size,return nil
MOV EDX,EAX //NeedSize,in EDX
MOV ESI,[EBX].FVBlocksInfo
MOV ECX,[EBX].FVBlockCount
@@search:
DEC ECX
JL @@ReserveAndCommit
MOV EAX,[ESI].TVirtualBlockInfo.UsedSize
ADD EAX,EDX
CMP EAX,[ESI].TVirtualBlockInfo.CommitSize
JBE @@DoAlloc
CMP EAX,[ESI].TVirtualBlockInfo.ReserveSize
JBE @@CommitMore
ADD ESI,VirtualBlockInfoSize
JMP @@search
@@ReserveAndCommit:
PUSH EDX //NeedSize
MOV EAX,EBX
CALL ReserveAndCommit
POP EDX //NeedSize
MOV ESI,[EBX].FVBlocksInfo
MOV ECX,[EBX].FVBlockCount
DEC ECX
IMUL ECX,VirtualBlockInfoSize
ADD ESI,ECX
JMP @@DoAlloc
@@CommitMore:
PUSH EDX //NeedSize
MOV ECX,ESI
MOV EAX,EBX
CALL CommitMore
POP EDX //NeedSize
@@DoAlloc:
MOV EAX,[ESI].TVirtualBlockInfo.UsedSize
ADD EAX,[ESI].TVirtualBlockInfo.MemoryPtr
ADD [ESI].TVirtualBlockInfo.UsedSize,EDX
@@Exit:
POP EDI
POP ESI
POP EBX
end;
{constructor TMiniMemAllocator.Create(AllocBy:u_Int32);
begin
inherited Create;
FAllocBy:=AllocBy;
if(FAllocBy<=sizeof(Integer))then FAllocBy:=sizeof(Integer)
else begin
FAllocBy:=1 shl Trunc(Ln(FAllocBy)/Ln(2)+0.99999999);
if(FAllocBy>sizeof(Integer) shl 2)then
FAllocBy:=sizeof(Integer) shl 2;
end;
end;
}
destructor TMiniMemAllocator.Destroy;
begin
FreeAll();
inherited;
end;
procedure TMiniMemAllocator.FreeAll;
var
i:Integer;
begin
try
for i:=0 to FVBlockCount-1 do begin
with FVBlocksInfo[i] do begin
{$IFOPT D+}
Win32Check(VirtualFree(MemoryPtr,CommitSize,MEM_DECOMMIT),sVirtualFreeFailed);
Win32Check(VirtualFree(MemoryPtr,0,MEM_RELEASE),sVirtualFreeFailed);
{$ELSE}
VirtualFree(MemoryPtr,CommitSize,MEM_DECOMMIT);
VirtualFree(MemoryPtr,0,MEM_RELEASE);
{$ENDIF}
end;
end;
SetLength(FVBlocksInfo,0);
finally
FVBlockCount:=0;
end;
end;
procedure TMiniMemAllocator.CommitMore(NeedSize:uInt32;pMemInfo:PVirtualBlockInfo);
var
lpMem,lpResult:Pointer;
begin
with pMemInfo^ do begin
NeedSize:=NeedSize-CommitSize+UsedSize;
NeedSize:=(NeedSize+SystemPageSize-1) and not (SystemPageSize-1);
{$IFOPT D+}
Assert(CommitSize+NeedSize<=ReserveSize);
{$ENDIF}
lpMem:=Pointer(DWord(MemoryPtr)+CommitSize);
lpResult:=VirtualAlloc(lpMem,NeedSize,MEM_COMMIT,PAGE_EXECUTE_READWRITE);
if(lpResult=nil)then LastWin32CallCheck(sVirtualAllocFailed);
{$IFOPT D+}
Assert(lpResult=lpMem);
{$ENDIF}
CommitSize:=CommitSize+NeedSize;
end;
end;
procedure TMiniMemAllocator.ReserveAndCommit(NeedSize:uInt32);
var
RSize,CSize:Integer;
lpMem,lpResult:PChar;
begin
RSize:=((NeedSize+SystemAllocGranularity-1) div SystemAllocGranularity)*SystemAllocGranularity;
CSize:=(NeedSize+SystemPageSize-1) and not (SystemPageSize-1);
lpMem:=VirtualAlloc(nil,RSize,MEM_RESERVE,PAGE_EXECUTE_READWRITE);
if(lpMem=nil)then LastWin32CallCheck(sVirtualAllocFailed);
try
lpResult:=VirtualAlloc(lpMem,CSize,MEM_COMMIT,PAGE_EXECUTE_READWRITE);
if(lpResult=nil)then LastWin32CallCheck(sVirtualAllocFailed);
{$IFOPT D+}
Assert(lpResult=lpMem);
{$ENDIF}
except
VirtualFree(lpMem,0,MEM_RELEASE);
end;
if(VBlockCount and $3=0)then begin
SetLength(FVBlocksInfo,VBlockCount+4);
end;
with FVBlocksInfo[VBlockCount] do begin
MemoryPtr:=lpMem;
ReserveSize:=RSize;
CommitSize:=CSize;
UsedSize:=0;
end;
Inc(FVBlockCount);
end;
procedure ExtractSysInfo;
var
SectorSize:DWord;
R1,R2,R3:DWord;
DriveChar: Char;
DriveNum: Integer;
DriveBits: set of 0..25;
SysInfo:SYSTEM_INFO;
begin
GetSystemInfo(SysInfo);
SystemPageSize:=SysInfo.dwPageSize;
SystemAllocGranularity:=SysInfo.dwAllocationGranularity;
SystemMaxSectorSize:=0;
Integer(DriveBits) := GetLogicalDrives;
for DriveNum := 0 to 25 do begin
if not (DriveNum in DriveBits) then Continue;
DriveChar := Char(DriveNum + Ord('a'));
if(GetDriveType(PChar(DriveChar + ':\'))=DRIVE_FIXED)then begin
GetDiskFreeSpace(PChar(DriveChar + ':\'),R1,SectorSize,R2,R3);
if(SectorSize>SystemMaxSectorSize)then SystemMaxSectorSize:=SectorSize;
end;
end;
end;
initialization
ExtractSysInfo;
DynamicArrayHeap:=HeapCreate(HEAP_GENERATE_EXCEPTIONS,4096,0);
finalization
HeapDestroy(DynamicArrayHeap);
end.
|
unit test_tpCritSect;
(*
Permission is hereby granted, on 24-June-2017, free of charge, to any person
obtaining a copy of this file (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies of the
Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*)
interface
{$I hrefdefines.inc}
{
Master copy of hrefdefines.inc is versioned on Source Forge in the ZaphodsMap project:
https://sourceforge.net/p/zaphodsmap/code/HEAD/tree/trunk/ZaphodsMap/Source/hrefdefines.inc
}
uses
SysUtils, Types,
// Kylix: Libc,
DUnitX.TestFrameWork,
tpCritSect;
type
[TestFixture]
TTest_tpCritSect = class(TObject)
private
FCS: TtpCriticalSection;
public
[Setup]
procedure SetUp;
[TearDown]
procedure TearDown;
public
[Test]
procedure Test_tpCritSect_UseCriticalSection;
end;
implementation
procedure TTest_tpCritSect.SetUp;
begin
inherited;
FCS := TtpCriticalSection.Create;
end;
procedure TTest_tpCritSect.TearDown;
begin
inherited;
FreeAndNil(FCS);
end;
procedure TTest_tpCritSect.Test_tpCritSect_UseCriticalSection;
begin
try
FCS.Lock;
Assert.IsNotNull(FCS);
finally
FCS.UnLock;
end;
end;
initialization
TDUnitX.RegisterTestFixture(TTest_tpCritSect);
end.
|
unit FrmPortDetailsU;
interface
uses
Windows, Messages, SysUtils,
{$IFDEF Delphi6} Variants, {$ENDIF}
Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TFrmPortDetails = class(TForm)
lblName: TLabel;
edtName: TEdit;
rgrProtocol: TRadioGroup;
lblAddress: TLabel;
edtAddress: TEdit;
Label1: TLabel;
edtExternalPort: TEdit;
Label2: TLabel;
edtInternalPort: TEdit;
btnOk: TButton;
btnCancel: TButton;
procedure edtNameChange(Sender: TObject);
procedure edtNameKeyPress(Sender: TObject; var Key: Char);
private
procedure SetButtonsState;
{ Private declarations }
public
{ Public declarations }
procedure SetReadOnly;
end;
implementation
{$R *.dfm}
procedure TFrmPortDetails.SetButtonsState;
begin
btnOk.Enabled := (edtName.Text <> '') and
(edtAddress.Text <> '') and
(edtExternalPort.Text <> '') and
(edtInternalPort.Text <> '');
end;
procedure TFrmPortDetails.edtNameChange(Sender: TObject);
begin
SetButtonsState;
end;
procedure TFrmPortDetails.edtNameKeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9',
Char(VK_BACK),
Char(VK_DELETE),
Char(VK_LEFT),
Char(VK_RIGHT),
Char(VK_TAB)
]) then Key := #0;
end;
procedure TFrmPortDetails.SetReadOnly;
begin
edtName.ReadOnly := true;
edtName.ParentColor := true;
rgrProtocol.Enabled := false;
edtAddress.ReadOnly := true;
edtAddress.ParentColor := true;
edtExternalPort.ReadOnly := true;
edtExternalPort.ParentColor := true;
edtInternalPort.ReadOnly := true;
edtInternalPort.ParentColor := true;
end;
end.
|
unit Noise;
interface
uses
AvL, avlVectors, avlMath;
type
TPerlinNoise=class
private
FNormIndex: array[0..255, 0..255] of Byte;
FFreq: Single;
function Normal(X, Y: Integer): TVector3D;
public
constructor Create(Freq: Single; WrapAt: Integer = 256);
function Noise(X, Y: Integer): Single; {$IFDEF INLINE} inline; {$ENDIF}
end;
implementation
const
Step=2*pi/256;
var
Normals: array[0..255] of TVector3D;
constructor TPerlinNoise.Create(Freq: Single; WrapAt: Integer = 256);
function Wrap(Val, Max: Integer): Integer;
begin
Val:=Val mod Max;
if Val<0
then Result:=Max+Val
else Result:=Val;
end;
var
i, j: Integer;
begin
FFreq:=Freq;
for i:=0 to 255 do
for j:=0 to 255 do
if (i<WrapAt) and (j<WrapAt)
then FNormIndex[i, j]:=Random(256)
else FNormIndex[i, j]:=FNormIndex[Wrap(i, WrapAt), Wrap(j, WrapAt)];
end;
function TPerlinNoise.Noise(X, Y: Integer): Single;
var
Pos: TVector3D;
X0, X1, Y0, Y1: Integer;
N0, N1, N2, N3, D0, D1, D2, D3: TVector3D;
H0, H1, H2, H3, SX, SY, AvgX0, AvgX1: Single;
begin
Pos:=Vector3D(X*FFreq, Y*FFreq, 0);
X0:=Floor(Pos.X);
X1:=X0+1;
Y0:=Floor(Pos.Y);
Y1:=Y0+1;
N0:=Normal(X0, Y0);
N1:=Normal(X0, Y1);
N2:=Normal(X1, Y0);
N3:=Normal(X1, Y1);
D0:=Vector3D(Pos.X-X0, Pos.Y-Y0, 0);
D1:=Vector3D(Pos.X-X0, Pos.Y-Y1, 0);
D2:=Vector3D(Pos.X-X1, Pos.Y-Y0, 0);
D3:=Vector3D(Pos.X-X1, Pos.Y-Y1, 0);
H0:=VectorDotProduct(D0, N0);
H1:=VectorDotProduct(D1, N1);
H2:=VectorDotProduct(D2, N2);
H3:=VectorDotProduct(D3, N3);
SX:=6*IntPower(D0.X, 5)-15*IntPower(D0.X, 4)+10*IntPower(D0.X, 3);
SY:=6*IntPower(D0.Y, 5)-15*IntPower(D0.Y, 4)+10*IntPower(D0.Y, 3);
AvgX0:=H0+(SX*(H2-H0));
AvgX1:=H1+(SX*(H3-H1));
Result:=AvgX0+(SY*(AvgX1-AvgX0));
end;
function TPerlinNoise.Normal(X, Y: Integer): TVector3D;
begin
Result:=Normals[FNormIndex[X mod 256, Y mod 256]];
end;
var
i: Integer;
initialization
for i:=0 to 255 do
Normals[i]:=Vector3D(cos(Step*i), sin(Step*i), 0);
end.
|
unit PLAT_QuickLink;
//这是一个抽象类,不要实例化
interface
uses windows, Graphics, Classes, buttons;
type
TQuickLink = class
protected
FLeft: Integer;
FTop: Integer;
FCaption: string;
FDescription: string;
FIcon: HIcon;
FPNodeCaption: string; //用来记录当前结点的上级结点的标题信息 Hany an 2006.01.13
FPModCode: string; // 崔立国 2011.11.10 用来保存当前快捷方式对应菜单的模块名称。
private
procedure SetCaption(const Value: string);
procedure SetDescription(const Value: string);
procedure SetIcon(const Value: HIcon);
procedure SetLeft(const Value: Integer);
procedure SetTop(const Value: Integer);
public
procedure Execute; virtual; abstract;
procedure LoadFromStream(stream: TStream); virtual; abstract;
procedure SaveToStream(Stream: TStream); virtual; abstract;
procedure UpdateLinker(Linker: TObject); virtual;
property Caption: string read FCaption write SetCaption;
property Icon: HIcon read FIcon write SetIcon;
property Description: string read FDescription write SetDescription;
property Left: Integer read FLeft write SetLeft;
property Top: Integer read FTop write SetTop;
//用来记录当前结点的上级结点的标题信息的一个属性 Hany an 2006.01.13
property PNodeCaption: string read FPNodeCaption write FPNodeCaption;
// 崔立国 2011.11.10 用来保存当前快捷方式对应菜单的模块名称。
property PModCode: string read FPModCode write FPModCode;
end;
implementation
{ TQuickLink }
uses PLAT_QuickLinker;
procedure TQuickLink.SetCaption(const Value: string);
begin
FCaption := Value;
end;
procedure TQuickLink.SetDescription(const Value: string);
begin
FDescription := Value;
end;
procedure TQuickLink.SetIcon(const Value: HIcon);
begin
FIcon := Value;
end;
procedure TQuickLink.SetLeft(const Value: Integer);
begin
FLeft := Value;
end;
procedure TQuickLink.SetTop(const Value: Integer);
begin
FTop := Value;
end;
procedure TQuickLink.UpdateLinker(Linker: TObject);
begin
if Linker is TQuickLinker then
with (Linker as TQuickLinker) do
begin
//Bryan, 2004-12-15在外部统一折行处理
{if Length(self.Caption)>8 then
begin
Caption:=Copy(self.Caption,1,8) + #13#10 + Copy(self.Caption,9,MaxInt);
end
else}
Caption := self.Caption;
end;
end;
end.
|
unit Routing;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
type
TSegment = array[1..2]of TPoint;
TSegments = array of TSegment;
TRoute = array of TPoint;
TRoutes = array of TRoute;
TArea = array of TRect;
TIndex = Integer;
TIndexes = array of TIndex;
TAdjacenceGraph = array of TIndexes;
function Bounds(R: TRoute): TRect;
function Intersect(const S1, S2: TSegment): Boolean;
function Intersect(const S1: TSegment; S: TSegments): Boolean;
function Intersect(const S1: TSegment; S: TRoute): Boolean;
function Segment(const P1, P2: TPoint): TSegment;
function RectCenter(Rect: TRect): TPoint;
function Route(const P1, P2: TPoint; const Area: TArea; out ARoute: TRoute): Boolean;
procedure InsertRoute(const R: TRoute; var Routes: TRoutes);
procedure RemoveRoute(const R: TRoute; var Routes: Troutes);
procedure AddRect(var A: TArea; const R: TRect);
procedure RemoveRect(var A: TArea; n: TIndex);
procedure RemoveRect(var A: TArea; const R: TRect);
procedure RemoveRect(var A: TArea; n: TIndex; const R: TRect);
function RemoveRect(const B, R: TRect):TArea;
function Intersection(out I: TArea; const A: TArea; const P: TPoint): TIndexes;
function Intersection(out I: TArea; const A: TArea; const R: TRect): TIndexes;
function Containers(const A: TArea; P: TPoint): TIndexes;
function Adjacents(const A: TArea; n: TIndex): TIndexes;
function AdjacenceGraph(A: TArea): TAdjacenceGraph;
implementation
uses
Types;
function Bounds(R: TRoute): TRect;
var
i: Integer;
begin
with Result do begin
Top := MaxInt;
Left := MaxInt;
Bottom := 0;
Right := 0;
for i := Low(R) to High(R) do with R[i] do begin
if Left > x then
Left := x;
if Right < x then
Right := x;
if Top > y then
Top := y;
if Bottom < y then
Bottom := y;
end;
Right += 1;
Bottom += 1;
end;
end;
function Intersect(const S1, S2: TSegment): Boolean;
var
dx1, dx2, dy1, dy2, det, dx, dy: Integer;
a1, a2: Real;
begin
dx1 := S1[2].x - S1[1].x;
dy1 := S1[2].y - S1[1].y;
dx2 := S2[2].x - S2[1].x;
dy2 := S2[2].y - S2[1].y;
det := dx1 * dy2 - dy1 * dx2;
if det = 0 then
Exit(False);
dx := S2[1].x - S1[1].x;
dy := S2[1].y - S1[1].y;
a1 := (dx * dy2 - dy * dx2) / det;
a2 := (dx * dy1 - dy * dx1) / det;
result := (0 <= a1) and (a1 <= 1) and (0 <= a2) and (a2 <= 1);
end;
function Intersect(const S1: TSegment; S: TSegments): Boolean;
var
i: Integer;
begin
Result := False;
for i := Low(S) to High(S) do begin
if Intersect(S1, S[i]) then
Exit(True);
end;
end;
function Intersect(const S1: TSegment; S: TRoute): Boolean;
var
i: Integer;
begin
Result := False;
for i := Low(S) to High(S) - 1 do begin
if Intersect(S1, Segment(S[i], S[i + 1])) then
Exit(True);
end;
end;
function Segment(const P1, P2: TPoint): TSegment;
begin
Result[1] := P1;
Result[2] := P2;
end;
function RectCenter(Rect: TRect): TPoint;
begin
with Rect do begin
Result.x := (Left + Right) div 2;
Result.y := (Top + Bottom) div 2;
end;
end;
function Route(const P1, P2: TPoint; const Area: TArea; out ARoute: TRoute): Boolean;
begin
SetLength(ARoute, 4);
ARoute[0] := P1;
ARoute[3] := P2;
ARoute[1] := Point((ARoute[0].x + ARoute[3].x) div 2, ARoute[0].y);
ARoute[2] := Point((ARoute[0].x + ARoute[3].x) div 2, ARoute[3].y);
Result := True;
end;
procedure InsertRoute(const R: TRoute; var Routes: TRoutes);
begin
SetLength(Routes, Length(Routes) + 1);
Routes[Length(Routes) - 1] := R;
end;
procedure RemoveRoute(const R: TRoute; var Routes: TRoutes);
var
i, l, h: Integer;
begin
l := Length(Routes);
if l > 0 then begin
i := Low(Routes);
h := High(Routes);
while (i <= h) and (R <> Routes[i]) do begin
i += 1;
end;
while i < h do begin
Routes[i] := Routes[i+1];
end;
SetLength(Routes, l - 1);
end;
end;
function Intersection(out I: TArea; const A: TArea; const P: TPoint): TIndexes;
var
n: Integer;
l: Integer;
begin
l := 0;
SetLength(Result, l);
SetLength(I, 0);
for n := Low(A) to High(A) do begin
if PtInRect(A[n], P) then begin
AddRect(I, A[n]);
SetLength(Result, l + 1);
Result[l] := n;
l += 1;
end;
end;
end;
function Intersection(out I: TArea; const A: TArea; const R: TRect): TIndexes;
var
n: Integer;
l: Integer;
X: TRect;
begin
l := 0;
SetLength(Result, l);
SetLength(I, 0);
for n := Low(A) to High(A) do begin
if IntersectRect(X, A[n], R) then begin
AddRect(I, X);
SetLength(Result, l + 1);
Result[l] := n;
l += 1;
end;
end;
end;
procedure AddRect(var A: TArea; const R: TRect);
var
l: Integer;
begin
if not IsRectEmpty(R) then begin
l := Length(A);
SetLength(A, l + 1);
A[l] := R;
end;
end;
procedure RemoveRect(var A: TArea; n: TIndex);
var
p: TIndex;
begin
if(n >= Low(A)) and (n <= High(A)) then begin
for p := n to High(A) - 1 do begin
A[p] := A[p + 1];
end;
SetLength(A, Length(A) - 1);
end;
end;
procedure RemoveRect(var A: TArea; const R: TRect);
var
n: Integer;
I: TArea;
X: TIndexes;
begin
X := Intersection(I, A, R);
for n := Low(X) to High(X) do begin
RemoveRect(A, X[n], R);
end;
end;
procedure RemoveRect(var A: TArea; n: TIndex; const R: TRect);
var
B, S: TRect;
begin
B := A[n];
if IntersectRect(S, R, B) then begin
if EqualRect(S, B) then begin
RemoveRect(A, n);
end else begin
AddRect(A, Rect(B.Left, B.Top, B.Right, S.Top));
AddRect(A, Rect(S.Left, S.Top, B.Right, B.Bottom));
AddRect(A, Rect(B.Left, S.Top, S.Left, S.Bottom));
AddRect(A, Rect(B.Left, S.Bottom, B.Right, B.Bottom));
end;
end;
end;
function RemoveRect(const B, R: TRect): TArea;
begin
SetLength(Result, 1);
Result[0] := B;
RemoveRect(Result, 0, R);
end;
function Containers(const A: TArea; P: TPoint): TIndexes;
var
n: Integer;
l: Integer;
begin
l := 0;
SetLength(Result, l);
for n := Low(A) to High(A) do begin
if PtInRect(A[n], P) then begin
SetLength(Result, l + 1);
Result[l] := n;
l += 1;
end;
end;
end;
function Adjacents(const A: TArea; n: TIndex): TIndexes;
var
p: Integer;
l: Integer;
X: TRect;
begin
l := 0;
SetLength(Result, l);
for p := Low(A) to High(A) do begin
if(n <> p) and IntersectRect(X, A[p], A[n]) then begin
SetLength(Result, l + 1);
Result[l] := p;
l += 1;
end;
end;
end;
function AdjacenceGraph(A: TArea): TAdjacenceGraph;
var
n: TIndex;
begin
SetLength(Result, Length(A));
for n := Low(A) to High(A) do begin
Result[n] := Adjacents(A, n);
end;
end;
end.
|
unit ufrmMain;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, OpenGLContext, Forms, Controls, Graphics,
Dialogs, ComCtrls, ExtCtrls, StdCtrls, gl, uGLParticleEngine;
type
{ TfrmGLTester }
{ TglTexture }
TglTexture = class
public
Width,Height: longint;
Data : pointer;
destructor Destroy; override;
end;
TfrmGLTester = class(TForm)
btnResetMetrics: TButton;
chkLighting: TCheckBox;
chkMoveBackground: TCheckBox;
chkBlending: TCheckBox;
chkMoveCube: TCheckBox;
glControl: TOpenGLControl;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
GroupBox3: TGroupBox;
lblfps: TLabel;
lblMinFPS: TLabel;
lblMaxFPS: TLabel;
mmGLInfo: TMemo;
pnlControls: TPanel;
pnlScene: TPanel;
stsMain: TStatusBar;
procedure btnResetMetricsClick(Sender: TObject);
procedure chkLightingClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure glControlPaint(Sender: TObject);
private
lightamb, lightdif, lightpos, light2pos, light2dif,
light3pos, light3dif, light4pos, light4dif, fogcolor: array [0..3] of GLfloat;
timer: single;
FLastFrameTicks,FFrameCount, FLastMsecs: integer;
FminFPS, FmaxFPS : integer;
rx, ry, rz, rrx, rry, rrz: single;
textures : array [0..2] of GLuint; // Storage For 3 Textures
MyglTextures : array [0..2] of TglTexture;
CubeList, BackList: GLuint;
ParticleEngine : TParticleEngine;
function LoadFileToMemStream(const Filename: string): TMemoryStream;
function LoadglTexImage2DFromPNG(PNGFilename: string; Image: TglTexture
): boolean;
procedure LoadTextures;
procedure SetupGL_Lights;
procedure SetupGL_Shapes;
procedure SetupGL_ViewPort;
procedure DrawScene;
procedure UpdateFrameMetrics;
procedure UpdateGLInfo;
procedure OnIdle(Sender : TObject; var done:boolean);
public
{ public declarations }
end;
var
frmGLTester: TfrmGLTester;
const
GL_CLAMP_TO_EDGE = $812F;
implementation
uses IntfGraphics, FPimage, math;
{$R *.lfm}
{ TglTexture }
{ TfrmGLTester }
//----------------- GL Setup stuff ------------------
procedure TfrmGLTester.SetupGL_Lights;
begin
{init lighting variables}
{ambient color}
lightamb[0]:=0.5;
lightamb[1]:=0.5;
lightamb[2]:=0.5;
lightamb[3]:=1.0;
{diffuse color}
lightdif[0]:=0.8;
lightdif[1]:=0.0;
lightdif[2]:=0.0;
lightdif[3]:=1.0;
{diffuse position}
lightpos[0]:=0.0;
lightpos[1]:=0.0;
lightpos[2]:=3.0;
lightpos[3]:=1.0;
{diffuse 2 color}
light2dif[0]:=0.0;
light2dif[1]:=0.8;
light2dif[2]:=0.0;
light2dif[3]:=1.0;
{diffuse 2 position}
light2pos[0]:=3.0;
light2pos[1]:=0.0;
light2pos[2]:=3.0;
light2pos[3]:=1.0;
{diffuse 3 color}
light3dif[0]:=0.0;
light3dif[1]:=0.0;
light3dif[2]:=0.8;
light3dif[3]:=1.0;
{diffuse 3 position}
light3pos[0]:=-3.0;
light3pos[1]:=0.0;
light3pos[2]:=0.0;
light3pos[3]:=1.0;
{fog color}
fogcolor[0]:=0.5;
fogcolor[1]:=0.5;
fogcolor[2]:=0.5;
fogcolor[3]:=1.0;
glLightfv(GL_LIGHT0,GL_AMBIENT,lightamb);
glLightfv(GL_LIGHT1,GL_AMBIENT,lightamb);
glLightfv(GL_LIGHT2,GL_DIFFUSE,lightdif);
glLightfv(GL_LIGHT2,GL_POSITION,lightpos);
glLightfv(GL_LIGHT3,GL_DIFFUSE,light2dif);
glLightfv(GL_LIGHT3,GL_POSITION,light2pos);
glLightfv(GL_LIGHT4,GL_POSITION,light3pos);
glLightfv(GL_LIGHT4,GL_DIFFUSE,light3dif);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
glEnable(GL_LIGHT2);
glEnable(GL_LIGHT3);
glEnable(GL_LIGHT4);
end;
procedure TfrmGLTester.SetupGL_Shapes;
var
i: Integer;
begin
glGenTextures(3, @textures[0]);
for i:=0 to 2 do begin
glBindTexture(GL_TEXTURE_2D, Textures[i]);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D,0,3,MyglTextures[i].Width,MyglTextures[i].Height,0
,GL_RGB,GL_UNSIGNED_BYTE,MyglTextures[i].Data);
end;
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
{instead of GL_MODULATE you can try GL_DECAL or GL_BLEND}
glEnable(GL_TEXTURE_2D); // enables 2d textures
glClearColor(0.0,0.0,0.0,1.0); // sets background color
glClearDepth(1.0);
glDepthFunc(GL_LEQUAL); // the type of depth test to do
glEnable(GL_DEPTH_TEST); // enables depth testing
glShadeModel(GL_SMOOTH); // enables smooth color shading
{blending}
glColor4f(1.0,1.0,1.0,0.5); // Full Brightness, 50% Alpha ( NEW )
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
{}
glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
glHint(GL_POLYGON_SMOOTH_HINT,GL_NICEST);
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
// creating display lists
ParticleEngine.ParticleList :=glGenLists(1);
glNewList(ParticleEngine.ParticleList, GL_COMPILE);
glBindTexture(GL_TEXTURE_2D, textures[0]);
glBegin(GL_TRIANGLE_STRIP);
glNormal3f( 0.0, 0.0, 1.0);
glTexCoord2f( 1.0, 1.0); glVertex3f(+0.025, +0.025, 0);
glTexCoord2f( 0.0, 1.0); glVertex3f(-0.025, +0.025, 0);
glTexCoord2f( 1.0, 0.0); glVertex3f(+0.025, -0.025, 0);
glTexCoord2f( 0.0, 0.0); glVertex3f(-0.025, -0.025, 0);
glEnd;
glEndList;
BackList:=ParticleEngine.ParticleList+1;
glNewList(BackList, GL_COMPILE);
glBindTexture(GL_TEXTURE_2D, textures[2]);
glBegin(GL_QUADS);
{Front Face}
glNormal3f( 0.0, 0.0, 1.0);
glTexCoord2f( 1.0, 1.0); glVertex3f( 2.5, 2.5, 2.5);
glTexCoord2f( 0.0, 1.0); glVertex3f(-2.5, 2.5, 2.5);
glTexCoord2f( 0.0, 0.0); glVertex3f(-2.5,-2.5, 2.5);
glTexCoord2f( 1.0, 0.0); glVertex3f( 2.5,-2.5, 2.5);
{Back Face}
glNormal3f( 0.0, 0.0,-1.0);
glTexCoord2f( 0.0, 1.0); glVertex3f( 2.5, 2.5,-2.5);
glTexCoord2f( 0.0, 0.0); glVertex3f( 2.5,-2.5,-2.5);
glTexCoord2f( 1.0, 0.0); glVertex3f(-2.5,-2.5,-2.5);
glTexCoord2f( 1.0, 1.0); glVertex3f(-2.5, 2.5,-2.5);
{Left Face}
glNormal3f(-1.0, 0.0, 0.0);
glTexCoord2f( 1.0, 1.0); glVertex3f(-2.5, 2.5, 2.5);
glTexCoord2f( 0.0, 1.0); glVertex3f(-2.5, 2.5,-2.5);
glTexCoord2f( 0.0, 0.0); glVertex3f(-2.5,-2.5,-2.5);
glTexCoord2f( 1.0, 0.0); glVertex3f(-2.5,-2.5, 2.5);
{Right Face}
glNormal3f( 1.0, 0.0, 0.0);
glTexCoord2f( 1.0, 1.0); glVertex3f( 2.5, 2.5,-2.5);
glTexCoord2f( 0.0, 1.0); glVertex3f( 2.5, 2.5, 2.5);
glTexCoord2f( 0.0, 0.0); glVertex3f( 2.5,-2.5, 2.5);
glTexCoord2f( 1.0, 0.0); glVertex3f( 2.5,-2.5,-2.5);
{Top Face}
glNormal3f( 0.0, 1.0, 0.0);
glTexCoord2f( 1.0, 1.0); glVertex3f( 2.5, 2.5,-2.5);
glTexCoord2f( 0.0, 1.0); glVertex3f(-2.5, 2.5,-2.5);
glTexCoord2f( 0.0, 0.0); glVertex3f(-2.5, 2.5, 2.5);
glTexCoord2f( 1.0, 0.0); glVertex3f( 2.5, 2.5, 2.5);
{Bottom Face}
glNormal3f( 0.0,-1.0, 0.0);
glTexCoord2f( 1.0, 1.0); glVertex3f(-2.5,-2.5,-2.5);
glTexCoord2f( 0.0, 1.0); glVertex3f( 2.5,-2.5,-2.5);
glTexCoord2f( 0.0, 0.0); glVertex3f( 2.5,-2.5, 2.5);
glTexCoord2f( 1.0, 0.0); glVertex3f(-2.5,-2.5, 2.5);
glEnd;
glEndList;
CubeList:=BackList+1;
glNewList(CubeList, GL_COMPILE);
glBindTexture(GL_TEXTURE_2D, textures[1]);
glBegin(GL_QUADS);
{Front Face}
glNormal3f( 0.0, 0.0, 1.0);
glTexCoord2f( 1.0, 1.0); glVertex3f( 0.5, 0.5, 0.5);
glTexCoord2f( 0.0, 1.0); glVertex3f(-0.5, 0.5, 0.5);
glTexCoord2f( 0.0, 0.0); glVertex3f(-0.5,-0.5, 0.5);
glTexCoord2f( 1.0, 0.0); glVertex3f( 0.5,-0.5, 0.5);
{Back Face}
glNormal3f( 0.0, 0.0,-1.0);
glTexCoord2f( 0.0, 1.0); glVertex3f( 0.5, 0.5,-0.5);
glTexCoord2f( 0.0, 0.0); glVertex3f( 0.5,-0.5,-0.5);
glTexCoord2f( 1.0, 0.0); glVertex3f(-0.5,-0.5,-0.5);
glTexCoord2f( 1.0, 1.0); glVertex3f(-0.5, 0.5,-0.5);
glEnd;
glBindTexture(GL_TEXTURE_2D, textures[1]);
glBegin(GL_QUADS);
{Left Face}
glNormal3f(-1.0, 0.0, 0.0);
glTexCoord2f( 1.0, 1.0); glVertex3f(-0.5, 0.5, 0.5);
glTexCoord2f( 0.0, 1.0); glVertex3f(-0.5, 0.5,-0.5);
glTexCoord2f( 0.0, 0.0); glVertex3f(-0.5,-0.5,-0.5);
glTexCoord2f( 1.0, 0.0); glVertex3f(-0.5,-0.5, 0.5);
{Right Face}
glNormal3f( 1.0, 0.0, 0.0);
glTexCoord2f( 1.0, 1.0); glVertex3f( 0.5, 0.5,-0.5);
glTexCoord2f( 0.0, 1.0); glVertex3f( 0.5, 0.5, 0.5);
glTexCoord2f( 0.0, 0.0); glVertex3f( 0.5,-0.5, 0.5);
glTexCoord2f( 1.0, 0.0); glVertex3f( 0.5,-0.5,-0.5);
glEnd;
glBindTexture(GL_TEXTURE_2D, textures[2]);
glBegin(GL_QUADS);
{Top Face}
glNormal3f( 0.0, 1.0, 0.0);
glTexCoord2f( 1.0, 1.0); glVertex3f( 0.5, 0.5,-0.5);
glTexCoord2f( 0.0, 1.0); glVertex3f(-0.5, 0.5,-0.5);
glTexCoord2f( 0.0, 0.0); glVertex3f(-0.5, 0.5, 0.5);
glTexCoord2f( 1.0, 0.0); glVertex3f( 0.5, 0.5, 0.5);
{Bottom Face}
glNormal3f( 0.0,-1.0, 0.0);
glTexCoord2f( 1.0, 1.0); glVertex3f(-0.5,-0.5,-0.5);
glTexCoord2f( 0.0, 1.0); glVertex3f( 0.5,-0.5,-0.5);
glTexCoord2f( 0.0, 0.0); glVertex3f( 0.5,-0.5, 0.5);
glTexCoord2f( 1.0, 0.0); glVertex3f(-0.5,-0.5, 0.5);
glEnd;
glEndList;
end;
procedure TfrmGLTester.SetupGL_ViewPort;
begin
glMatrixMode (GL_PROJECTION); { prepare for and then }
glLoadIdentity (); { define the projection }
glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0); { transformation }
glMatrixMode (GL_MODELVIEW); { back to modelview matrix }
//glViewport (0, 0, glControl.Width, glControl.Height);
{ define the viewport }
end;
procedure TfrmGLTester.DrawScene;
var
CurTime: TDateTime;
MSecs: integer;
begin
UpdateFrameMetrics;
CurTime:=Now;
MSecs:=round(CurTime*86400*1000) mod 1000;
if MSecs<0 then MSecs:=1000+MSecs;
timer:=msecs-FLastMsecs;
if timer<0 then timer:=1000+timer;
FLastMsecs:=MSecs;
ParticleEngine.MoveParticles(timer);
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glLoadIdentity; { clear the matrix }
glTranslatef (0.0, 0.0,-3.0); // -2.5); { viewing transformation }
{rotate}
glPushMatrix;
if chkMoveBackground.Checked then
begin
rrx:=rrx-0.6*(timer/10);
rry:=rry-0.5*(timer/10);
rrz:=rrz-0.3*(timer/10);
end;
glRotatef(rrx,1.0,0.0,0.0);
glRotatef(rry,0.0,1.0,0.0);
glRotatef(rrz,0.0,0.0,1.0);
// draw background
if chkBlending.Checked then
begin
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
end;
glCallList(BackList);
glPopMatrix;
glPushMatrix;
if chkMoveCube.Checked then
begin
rx:=rx+0.5*(timer/10);
ry:=ry+0.25*(timer/10);
rz:=rz+0.8*(timer/10);
end;
glRotatef(rx,1.0,0.0,0.0);
glRotatef(ry,0.0,1.0,0.0);
glRotatef(rz,0.0,0.0,1.0);
// draw cube
glCallList(CubeList);
if chkBlending.Checked then
begin
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
end;
glPopMatrix;
if chkBlending.Checked then glEnable(GL_BLEND);
ParticleEngine.DrawParticles;
if chkBlending.Checked then glDisable(GL_BLEND);
//glFlush;
//glFinish;
// Swap backbuffer to front
glControl.SwapBuffers;
end;
procedure TfrmGLTester.UpdateFrameMetrics;
begin
inc(FFrameCount);
inc(FLastFrameTicks,glControl.FrameDiffTimeInMSecs);
if (FLastFrameTicks>=1000) then
begin
//a second has passed
if FMinFPS = -1 then
FMinFPS := FFrameCount
else
FminFPS := Min(FMinFPS,FFrameCount);
if FmaxFPS = -1 then
FmaxFPS := FFrameCount
else
FmaxFPS := max(FMaxFPS,FFrameCount);
lblFps.Caption := Format('current: %d fps',[FFrameCount]);
lblMinFPS.Caption := Format('min: %d fps',[FMinFPS]);
lblMaxFPS.Caption := Format('max: %d fps',[FmaxFPS]);;
dec(FLastFrameTicks,1000);
FFrameCount:=0;
end;
end;
procedure TfrmGLTester.UpdateGLInfo;
begin
mmGLInfo.Clear;
mmGLInfo.Lines.Add(Format('GL vendor: %s',[glGetString(GL_VENDOR)]));
mmGLInfo.Lines.Add(Format('GL renderer: %s',[glGetString(GL_RENDERER)]));
mmGLInfo.Lines.Add(Format('GL version: %s',[glGetString(GL_VERSION)]));
mmGLInfo.Lines.Add(Format('Supported Extensions: %s',[glGetString(GL_EXTENSIONS)]));
end;
procedure TfrmGLTester.LoadTextures;
procedure LoadglTexture(Filename:string; Image:TglTexture);
begin
Filename:=ExpandFileNameUTF8(Filename);
if not LoadglTexImage2DFromPNG(Filename,Image) then begin
MessageDlg('File not found',
'Image file not found: '+Filename,
mtError,[mbOk],0);
raise Exception.Create('Image file not found: '+Filename);
end;
end;
var
i: Integer;
begin
for i:=0 to 2 do begin
Textures[i]:=0;
MyglTextures[i]:=TglTexture.Create;
end;
{loading the texture and setting its parameters}
LoadglTexture('data/particle.png',MyglTextures[0]);
LoadglTexture('data/texture2.png',MyglTextures[1]);
LoadglTexture('data/texture3.png',MyglTextures[2]);
end;
//----------------- app plumbing ---------------------
procedure TfrmGLTester.FormShow(Sender: TObject);
begin
ParticleEngine:=TParticleEngine.Create;
btnResetMetricsClick(Sender);
glControl.MakeCurrent;
UpdateGLInfo;
LoadTextures;
SetupGL_Lights;
SetupGL_Shapes;
SetupGL_Viewport;
ParticleEngine.Start;
Application.OnIdle := @OnIdle;
end;
procedure TfrmGLTester.chkLightingClick(Sender: TObject);
begin
if chkLighting.checked then
glEnable(GL_LIGHTING)
else
glDisable(GL_LIGHTING);
end;
procedure TfrmGLTester.btnResetMetricsClick(Sender: TObject);
begin
FminFPS := -1;
FmaxFPS := -1;
end;
procedure TfrmGLTester.FormDestroy(Sender: TObject);
var i: integer;
begin
for i:=0 to 2 do begin
Textures[i]:=0;
FreeAndNil(MyglTextures[i]);
end;
FreeAndNil(ParticleEngine);
end;
procedure TfrmGLTester.FormResize(Sender: TObject);
begin
stsMain.SimpleText:= format('GL Scene (%dx%d)',[glControl.Width,glControl.Height]);
end;
procedure TfrmGLTester.OnIdle(Sender: TObject; var done: boolean);
begin
glControl.Invalidate;
done:=false; // tell lcl to handle messages and return immediatly
end;
procedure TfrmGLTester.glControlPaint(Sender: TObject);
begin
DrawScene;
end;
destructor TglTexture.Destroy;
begin
if Data<>nil then FreeMem(Data);
inherited Destroy;
end;
function TfrmGLTester.LoadFileToMemStream(const Filename: string): TMemoryStream;
var FileStream: TFileStream;
begin
Result:=TMemoryStream.Create;
try
FileStream:=TFileStream.Create(UTF8ToSys(Filename), fmOpenRead);
try
Result.CopyFrom(FileStream,FileStream.Size);
Result.Position:=0;
finally
FileStream.Free;
end;
except
Result.Free;
Result:=nil;
end;
end;
function TfrmGLTester.LoadglTexImage2DFromPNG(PNGFilename: string; Image: TglTexture
): boolean;
var
png: TPortableNetworkGraphic;
IntfImg: TLazIntfImage;
y: Integer;
x: Integer;
c: TFPColor;
p: PByte;
begin
Result:=false;
png:=TPortableNetworkGraphic.Create;
IntfImg:=nil;
try
png.LoadFromFile(PNGFilename);
IntfImg:=png.CreateIntfImage;
Image.Width:=IntfImg.Width;
Image.Height:=IntfImg.Height;
GetMem(Image.Data,Image.Width*Image.Height * 3);
p:=PByte(Image.Data);
for y:=0 to IntfImg.Height-1 do begin
for x:=0 to IntfImg.Width-1 do begin
c:=IntfImg.Colors[x,y];
p^:=c.red shr 8;
inc(p);
p^:=c.green shr 8;
inc(p);
p^:=c.blue shr 8;
inc(p);
end;
end;
finally
png.Free;
IntfImg.Free;
end;
Result:=true;
end;
end.
|
unit u_DroneMission;
interface
uses
t_DroneMission,
u_XmlReader;
type
TDroneConfig = record
InPath: string;
OutPath: string;
AppPath: string;
SkipExisting: Boolean;
end;
TDroneMission = record
private
class procedure ProcessFile(
const AFileName: string;
const AReader: TXmlReader;
const AConfig: TDroneConfig
); static;
public
class procedure Run; static;
end;
implementation
uses
Types,
SysUtils,
IOUtils,
u_FileWriter,
u_CsvWriter,
u_KmlWriter;
procedure OnLogEvent(const AMsg: string);
begin
Writeln(AMsg);
end;
{ TDroneMission }
class procedure TDroneMission.Run;
var
I: Integer;
VConfig: TDroneConfig;
VXmlFiles: TStringDynArray;
VXmlReader: TXmlReader;
begin
VConfig.SkipExisting := True;
VConfig.AppPath := ExtractFilePath(ParamStr(0));
VConfig.InPath := VConfig.AppPath + 'Input\';
if not DirectoryExists(VConfig.InPath) then begin
OnLogEvent('Input directory is not exists: ' + VConfig.InPath);
Exit;
end;
VConfig.OutPath := VConfig.AppPath + 'Output\';
if not DirectoryExists(VConfig.OutPath) then begin
if not ForceDirectories(VConfig.OutPath) then begin
RaiseLastOSError;
end;
end;
OnLogEvent('Scaning input directory...');
VXmlFiles := TDirectory.GetFiles(VConfig.InPath, '*.xml', IOUtils.TSearchOption.soAllDirectories);
I := Length(VXmlFiles);
if I > 0 then begin
OnLogEvent(Format('Found %d xml file(s)', [I]));
end else begin
OnLogEvent('Nothing to do: The input directory doesn''t contain any xml file!');
end;
VXmlReader := TXmlReader.Create(dvOmniXML, @OnLogEvent);
try
for I := Low(VXmlFiles) to High(VXmlFiles) do begin
ProcessFile(VXmlFiles[I], VXmlReader, VConfig);
end;
finally
VXmlReader.Free;
end;
OnLogEvent('Finished!');
end;
class procedure TDroneMission.ProcessFile(
const AFileName: string;
const AReader: TXmlReader;
const AConfig: TDroneConfig
);
function Relative(const AName, ABase: string): string;
begin
Result := StringReplace(AName, ABase, '', [rfIgnoreCase])
end;
procedure WriteFile(
const AWriterId: string;
const AWriterClass: TFileWriterClass;
const AFileNameForWriter: string;
const AMission: TMission
);
var
VRelative: string;
VWriter: TFileWriter;
begin
VRelative := Relative(AFileNameForWriter, AConfig.AppPath);
if AConfig.SkipExisting and FileExists(AFileNameForWriter) then begin
OnLogEvent(AWriterId + ' file already exists, skipping: ' + VRelative);
Exit;
end;
if not ForceDirectories(ExtractFileDir(AFileNameForWriter)) then begin
RaiseLastOSError;
end;
VWriter := AWriterClass.Create(AFileNameForWriter);
try
VWriter.DoWrite(AMission);
OnLogEvent(AWriterId + ' file saved to: ' + VRelative);
finally
VWriter.Free;
end;
end;
procedure WriteStat(const AMission: TMission);
var
I, J: Integer;
begin
J := 0;
for I := 0 to Length(AMission) - 1 do begin
Inc(J, Length(AMission[I]));
end;
//OnLogEvent('Routs: ' + IntToStr(Length(AMission)));
OnLogEvent('Points: ' + IntToStr(J));
end;
const
CWriterId: array [0..1] of string = ('CSV', 'KML');
CWriterClass: array [0..1] of TFileWriterClass = (TCsvWriter, TKmlWriter);
var
I: Integer;
VXmlName: string;
VFileName: string;
VMission: TMission;
begin
OnLogEvent('');
OnLogEvent('Processing xml file: ' + Relative(AFileName, AConfig.AppPath));
VMission := AReader.DoReadFile(AFileName);
VXmlName := Relative(AFileName, AConfig.InPath);
for I := 0 to Length(CWriterId) - 1 do begin
VFileName := ChangeFileExt(AConfig.OutPath + VXmlName, '.' + LowerCase(CWriterId[I]));
WriteFile(CWriterId[I], CWriterClass[I], VFileName, VMission);
end;
WriteStat(VMission);
OnLogEvent('');
end;
end.
|
unit Synchropts;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Windows, semaphores, fgl;
type
TManagedThread = class(TThread)
public
CategoryCode: Cardinal;
MySemaphore: TSemaphore; // do synchronizacji animacji
// jak watek juz na czyms nie wisi to zawisnie wlasnie na tym
// podczas normalnej pracy MySemaphore ma wartosc 0. W momencie kiedy
// watek chce sie na nim powiesic, P()uje go i sie wiesza
// watek glowny kiedys go odwiesi
procedure SignalStep; // watek wywoluje jesli wykonal jakis element pracy
constructor Create(CreateSuspended: Boolean);
end;
TManagedThreadList = specialize TFPGList<TManagedThread>;
var
ThreadList: TManagedThreadList;
procedure AddThread(t: TManagedThread); // dodaj watek do listy
procedure StartLockstep();
procedure EndLockstep();
implementation
constructor TManagedThread.Create(CreateSuspended: Boolean);
begin
MySemaphore := TSemaphore.Create();
FreeOnTerminate := false;
inherited Create(CreateSuspended);
end;
procedure AddThread(t: TManagedThread); // dodaj watek do listy
begin
ThreadList.Add(t);
end;
procedure StartLockstep();
var
i: Integer;
KilledADeadOne: Boolean;
c: TManagedThread;
begin
KilledADeadOne := true;
// w tym momencie wszyscy powinni wisiec. Zabij martwych.
while KilledADeadOne do
begin
KilledADeadOne := false;
for i := 0 to ThreadList.Count-1 do
if ThreadList[i].Terminated then
begin
c := ThreadList[i];
ThreadList.Delete(i);
KilledADeadOne := true;
c.Destroy;
break;
end;
end;
end;
procedure EndLockstep();
var
i: Integer;
begin
// odwies powieszonych na wlasnym semaforze
for i := 0 to ThreadList.Count-1 do ThreadList[i].MySemaphore.VIfLocked();
end;
procedure TManagedThread.SignalStep();
begin
MySemaphore.P(); // powies sie na wlasnym semaforze :D
end;
initialization
begin
ThreadList := TManagedThreadList.Create();
end;
end.
|
unit cmpRuler;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TRulerOrientation = (ruHorizontal, ruVertical);
TRuler = class(TCustomControl)
private
fSmallTickSpacing: Integer;
fSmallTickLength: Integer;
fSmallTicksPerLargeTick: Integer;
fLargeTickLength: Integer;
fDialogBox: HWND;
procedure SetLargeTickLength(const Value: Integer);
procedure SetOrientation(const Value: TRulerOrientation);
procedure SetSmallTickLength(const Value: Integer);
procedure SetSmallTickSpacing(const Value: Integer);
procedure SetSmallTicksperLargeTick(const Value: Integer);
function GetOrientation: TRulerOrientation;
procedure SetDialogBox(const Value: HWND);
{ Private declarations }
protected
procedure Loaded; override;
procedure Paint; override;
public
constructor Create (AOwner : TComponent); override;
property DialogBox : HWND read fDialogBox write SetDialogBox;
published
property Align;
property Anchors;
property BevelKind default bkTile;
property BevelInner default bvLowered;
property BevelOuter default bvLowered;
property BevelWidth;
property Color;
property Constraints;
property ParentColor;
property SmallTickSpacing : Integer read fSmallTickSpacing write SetSmallTickSpacing default 10;
property SmallTicksPerLargeTick : Integer read fSmallTicksPerLargeTick write SetSmallTicksperLargeTick default 5;
property SmallTickLength : Integer read fSmallTickLength write SetSmallTickLength default 5;
property LargeTickLength : Integer read fLargeTickLength write SetLargeTickLength default 10;
property Orientation : TRulerOrientation read GetOrientation write SetOrientation stored False;
end;
implementation
{ TRuler }
constructor TRuler.Create(AOwner: TComponent);
begin
inherited Create (AOwner);
Width := 180;
Height := 40;
BevelKind := bkTile;
BevelInner := bvLowered;
BevelOuter := bvLowered;
fLargeTickLength := 10;
fSmallTickLength := 5;
fSmallTicksPerLargeTick := 5;
fSmallTickSpacing := 10;
end;
function TRuler.GetOrientation: TRulerOrientation;
begin
if Width > Height then
result := ruHorizontal
else
result := ruVertical
end;
procedure TRuler.Loaded;
begin
inherited;
end;
procedure TRuler.Paint;
var
x, y : Integer;
w, h : Integer;
t : Integer;
sm : Integer;
r : TRect;
offset : Integer;
begin
Canvas.Brush.Color := Color;
Canvas.Font := Font;
w := ClientWidth;
h := ClientHeight;
if fDialogBox <> 0 then
sm := fSmallTickSpacing
else
sm := fSmallTickSpacing;
y := 0;
x := 0;
offset := 0;
t := 0;
if Orientation = ruHorizontal then
begin
repeat
Inc (offset, sm);
if fDialogBox <> 0 then
begin
r := Rect (0, 0, offset, 10);
MapDialogRect (fDialogBox, r);
x := r.Right
end
else
x := offset;
Inc (t);
if x < w then
begin
Canvas.MoveTo (x, y);
if t = fSmallTicksPerLargeTick then
begin
Canvas.LineTo (x, y + fLargeTickLength);
t := 0
end
else
Canvas.LineTo (x, y + fSmallTickLength)
end
until x >= w
end
else
begin
repeat
Inc (offset, sm);
if fDialogBox <> 0 then
begin
r := Rect (0, 0, 10, offset);
MapDialogRect (fDialogBox, r);
y := r.Bottom
end
else
y := offset;
Inc (t);
if y < h then
begin
Canvas.MoveTo (x, y);
if t = fSmallTicksPerLargeTick then
begin
Canvas.LineTo (x + fLargeTickLength, y);
t := 0
end
else
Canvas.LineTo (x + fSmallTickLength, y)
end
until y >= h
end
end;
procedure TRuler.SetDialogBox(const Value: HWND);
begin
fDialogBox := Value;
invalidate
end;
procedure TRuler.SetLargeTickLength(const Value: Integer);
begin
if value <> fLargeTickLength then
begin
fLargeTickLength := Value;
Invalidate
end
end;
procedure TRuler.SetOrientation(const Value: TRulerOrientation);
var
h : Integer;
begin
if value <> Orientation then
begin
h := Height;
Height := Width;
Width := h;
Invalidate
end
end;
procedure TRuler.SetSmallTickLength(const Value: Integer);
begin
if value <> fSmallTickLength then
begin
fSmallTickLength := Value;
Invalidate
end
end;
procedure TRuler.SetSmallTickSpacing(const Value: Integer);
begin
if value <> fSmallTickSpacing then
begin
fSmallTickSpacing := Value;
Invalidate
end
end;
procedure TRuler.SetSmallTicksperLargeTick(const Value: Integer);
begin
if value <> fSmallTicksPerLargeTick then
begin
fSmallTicksPerLargeTick := Value;
Invalidate
end
end;
end.
|
unit URecycleBin;
interface
uses UPageSuper, USysPageHandler, UGroupPage, UPageFactory, UTypeDef, UxlClasses, UxlExtClasses;
type
TRecycleBin = class (TGroupSuper)
public
class function PageType (): TPageType; override;
function ChildShowInTree (ptChild: TPageType): boolean; override;
class function SingleInstance (): boolean; override;
end;
TRecycleHandler = class (TSysPageHandlerSuper)
private
protected
function PageType (): TPageType; override;
function NameResource (): integer; override;
function MenuItem_Manage (): integer; override;
public
constructor Create (AParent: TPageSuper); override;
end;
implementation
uses UGlobalObj, ULangManager, UPageStore, UDeleteHandler, Resource;
class function TRecycleBin.PageType (): TPageType;
begin
result := ptRecycleBin;
end;
function TRecycleBin.ChildShowInTree (ptChild: TPageType): boolean;
begin
result := false;
end;
class function TRecycleBin.SingleInstance (): boolean;
begin
result := true;
end;
//----------------------
constructor TRecycleHandler.Create (AParent: TPageSuper);
begin
inherited Create (AParent);
DeleteHandler.SetRecycleBin (FPage);
end;
function TRecycleHandler.PageType (): TPageType;
begin
result := ptRecycleBin;
end;
function TRecycleHandler.NameResource (): integer;
begin
result := sr_RecycleBin;
end;
function TRecycleHandler.MenuItem_Manage (): integer;
begin
result := m_recyclebin;
end;
//---------------------
initialization
PageFactory.RegisterClass (TRecycleBin);
PageImageList.AddImageWithOverlay (ptRecycleBin, m_recyclebin);
finalization
end.
|
unit TextEditor.CodeFolding;
interface
uses
System.Classes, System.SysUtils, Vcl.Graphics, TextEditor.CodeFolding.Colors, TextEditor.CodeFolding.Hint,
TextEditor.TextFolding, TextEditor.Types;
const
TEXTEDITOR_CODE_FOLDING_DEFAULT_OPTIONS = [cfoAutoPadding, cfoAutoWidth, cfoHighlightIndentGuides, cfoHighlightMatchingPair, cfoShowIndentGuides,
cfoShowTreeLine, cfoExpandByHintClick];
type
TTextEditorCodeFolding = class(TPersistent)
strict private
FCollapsedRowCharacterCount: Integer;
FColors: TTextEditorCodeFoldingColors;
FDelayInterval: Cardinal;
FGuideLineStyle: TTextEditorCodeFoldingGuideLineStyle;
FHint: TTextEditorCodeFoldingHint;
FMarkStyle: TTextEditorCodeFoldingMarkStyle;
FMouseOverHint: Boolean;
FOnChange: TTextEditorCodeFoldingChangeEvent;
FOptions: TTextEditorCodeFoldingOptions;
FOutlining: Boolean;
FPadding: Integer;
FTextFolding: TTextEditorTextFolding;
FVisible: Boolean;
FWidth: Integer;
procedure DoChange;
procedure SetColors(const AValue: TTextEditorCodeFoldingColors);
procedure SetGuideLineStyle(const AValue: TTextEditorCodeFoldingGuideLineStyle);
procedure SetHint(const AValue: TTextEditorCodeFoldingHint);
procedure SetMarkStyle(const AValue: TTextEditorCodeFoldingMarkStyle);
procedure SetOptions(const AValue: TTextEditorCodeFoldingOptions);
procedure SetPadding(const AValue: Integer);
procedure SetTextFolding(const AValue: TTextEditorTextFolding);
procedure SetVisible(const AValue: Boolean);
procedure SetWidth(const AValue: Integer);
public
constructor Create;
destructor Destroy; override;
function GetWidth: Integer;
procedure Assign(ASource: TPersistent); override;
procedure ChangeScale(const AMultiplier, ADivider: Integer);
procedure SetOption(const AOption: TTextEditorCodeFoldingOption; const AEnabled: Boolean);
property MouseOverHint: Boolean read FMouseOverHint write FMouseOverHint;
published
property CollapsedRowCharacterCount: Integer read FCollapsedRowCharacterCount write FCollapsedRowCharacterCount default 20;
property Colors: TTextEditorCodeFoldingColors read FColors write SetColors;
property DelayInterval: Cardinal read FDelayInterval write FDelayInterval default 300;
property GuideLineStyle: TTextEditorCodeFoldingGuideLineStyle read FGuideLineStyle write SetGuideLineStyle default lsDot;
property Hint: TTextEditorCodeFoldingHint read FHint write SetHint;
property MarkStyle: TTextEditorCodeFoldingMarkStyle read FMarkStyle write SetMarkStyle default msSquare;
property OnChange: TTextEditorCodeFoldingChangeEvent read FOnChange write FOnChange;
property Options: TTextEditorCodeFoldingOptions read FOptions write SetOptions default TEXTEDITOR_CODE_FOLDING_DEFAULT_OPTIONS;
property Outlining: Boolean read FOutlining write FOutlining default False;
property Padding: Integer read FPadding write SetPadding default 2;
property TextFolding: TTextEditorTextFolding read FTextFolding write SetTextFolding;
property Visible: Boolean read FVisible write SetVisible default False;
property Width: Integer read FWidth write SetWidth default 14;
end;
implementation
uses
Winapi.Windows, System.Math;
constructor TTextEditorCodeFolding.Create;
begin
inherited;
FVisible := False;
FOptions := TEXTEDITOR_CODE_FOLDING_DEFAULT_OPTIONS;
FGuideLineStyle := lsDot;
FMarkStyle := msSquare;
FColors := TTextEditorCodeFoldingColors.Create;
FCollapsedRowCharacterCount := 20;
FHint := TTextEditorCodeFoldingHint.Create;
FPadding := 2;
FWidth := 14;
FDelayInterval := 300;
FOutlining := False;
FMouseOverHint := False;
FTextFolding := TTextEditorTextFolding.Create;
end;
destructor TTextEditorCodeFolding.Destroy;
begin
FColors.Free;
FHint.Free;
FTextFolding.Free;
inherited;
end;
procedure TTextEditorCodeFolding.Assign(ASource: TPersistent);
begin
if Assigned(ASource) and (ASource is TTextEditorCodeFolding) then
with ASource as TTextEditorCodeFolding do
begin
Self.FVisible := FVisible;
Self.FOptions := FOptions;
Self.FColors.Assign(FColors);
Self.FCollapsedRowCharacterCount := FCollapsedRowCharacterCount;
Self.FHint.Assign(FHint);
Self.FWidth := FWidth;
Self.FDelayInterval := FDelayInterval;
Self.FTextFolding.Assign(FTextFolding);
Self.FPadding := FPadding;
Self.DoChange;
end
else
inherited Assign(ASource);
end;
procedure TTextEditorCodeFolding.ChangeScale(const AMultiplier, ADivider: Integer);
begin
FWidth := MulDiv(FWidth, AMultiplier, ADivider);
FPadding := MulDiv(FPadding, AMultiplier, ADivider);
FHint.Indicator.Glyph.ChangeScale(AMultiplier, ADivider);
DoChange;
end;
procedure TTextEditorCodeFolding.DoChange;
begin
if Assigned(FOnChange) then
FOnChange(fcRefresh);
end;
procedure TTextEditorCodeFolding.SetGuideLineStyle(const AValue: TTextEditorCodeFoldingGuideLineStyle);
begin
if FGuideLineStyle <> AValue then
begin
FGuideLineStyle := AValue;
DoChange;
end;
end;
procedure TTextEditorCodeFolding.SetMarkStyle(const AValue: TTextEditorCodeFoldingMarkStyle);
begin
if FMarkStyle <> AValue then
begin
FMarkStyle := AValue;
DoChange;
end;
end;
procedure TTextEditorCodeFolding.SetVisible(const AValue: Boolean);
begin
if FVisible <> AValue then
begin
FVisible := AValue;
if Assigned(FOnChange) then
FOnChange(fcVisible);
end;
end;
procedure TTextEditorCodeFolding.SetOptions(const AValue: TTextEditorCodeFoldingOptions);
begin
FOptions := AValue;
DoChange;
end;
procedure TTextEditorCodeFolding.SetOption(const AOption: TTextEditorCodeFoldingOption; const AEnabled: Boolean);
begin
if AEnabled then
Include(FOptions, AOption)
else
Exclude(FOptions, AOption);
end;
procedure TTextEditorCodeFolding.SetColors(const AValue: TTextEditorCodeFoldingColors);
begin
FColors.Assign(AValue);
end;
procedure TTextEditorCodeFolding.SetHint(const AValue: TTextEditorCodeFoldingHint);
begin
FHint.Assign(AValue);
end;
procedure TTextEditorCodeFolding.SetTextFolding(const AValue: TTextEditorTextFolding);
begin
FTextFolding.Assign(AValue);
end;
procedure TTextEditorCodeFolding.SetPadding(const AValue: Integer);
begin
if FPadding <> AValue then
begin
FPadding := AValue;
DoChange;
end;
end;
function TTextEditorCodeFolding.GetWidth: Integer;
begin
if FVisible then
Result := FWidth
else
Result := 0;
end;
procedure TTextEditorCodeFolding.SetWidth(const AValue: Integer);
var
LValue: Integer;
begin
LValue := Max(0, AValue);
if FWidth <> LValue then
begin
FWidth := LValue;
DoChange;
end;
end;
end.
|
unit Calculadora.Helpers;
interface
uses
Controls;
type
TCaptionHelper = record helper for TCaption
function ToCurrency : Currency;
end;
TStrHelper = record helper for String
function ToCurrency : Currency;
end;
implementation
uses
System.SysUtils;
{ TCaptionHelper }
function TCaptionHelper.ToCurrency: Currency;
begin
Result := StrToCurr(Self);
end;
{ TStrHelper }
function TStrHelper.ToCurrency: Currency;
begin
Result := StrToCurr(Self);
end;
end.
|
unit Indicator;
interface
uses
System.SysUtils, System.Classes, Vcl.Controls, Vcl.ExtCtrls;
type
TIndicatorState = (isNone,isOn,isOff);
TIndicator = class(TShape)
private
FState: TIndicatorState;
procedure SetState(const Value: TIndicatorState);
{ Private declarations }
protected
{ Protected declarations }
public
constructor Create();
procedure SetOn();
procedure SetOff();
procedure Paint; override;
property State:TIndicatorState read FState write SetState;
{ Public declarations }
published
{ Published declarations }
end;
procedure Register;
implementation
uses
Vcl.Graphics;
procedure Register;
begin
RegisterComponents('Samples', [TIndicator]);
end;
{ TShape1 }
constructor TIndicator.Create;
begin
Brush.Color:=clGray;
end;
procedure TIndicator.Paint;
begin
inherited;
Shape:=stCircle;
case State of
isNone:
Brush.Color:=clGray;
isOn:
Brush.Color:=clRed;
isOff:
Brush.Color:=clWhite;
end;
end;
procedure TIndicator.SetOff;
begin
State:=isOff;
end;
procedure TIndicator.SetOn;
begin
State:=isOn;
end;
procedure TIndicator.SetState(const Value: TIndicatorState);
begin
FState := Value;
Paint;
end;
end.
|
unit Alarmpnl;
{
This component is a direct descendant of a TTimerPanel object. It displays
a 3D panel that flashes (reverses color and font.color) when enabled, and
resets to it's normal state on deactivation. In addition, it has two events:
OnAlarmActivate is triggered when Enabled is set to true and OnAlarmDeactivate
is triggered when Enabled is set to false. These do *not* trigger while in
design state.
Copyright (c) November, 1995 Gary D. Foster
Released under the provisions of the Gnu Public License.
Author: Gary D. Foster
Date: 11/9/95
Change Log:
* 11/10/95 -- Gary D. Foster
Moved FlashLabel, Reset, and SetEnabled from private to protected
status and made them virtual as appropriate.
* 11/13/95 -- Gary D. Foster
Fixed bug in the Reset routine that prevented the original colors
from being restored. Basically, if the alarm is saved in the
'disabled' state (not flashing), the FOriginalColor and
FOriginalFontColor values are used to restore the colors when
'reset' is called during object creation. This means that they
are both black (0) and therefore the colors are set to black on
black. Instead, we bail out of reset if the colors are equal
(no harm done, since if they're equal a reset is pointless anyway).
* 11/13/95 -- Gary D. Foster
Added the 'StringTag' property... designed to hold various information
that the OnAlarmActivate and Deactivate procedures can reference.
Specifically, I store DDE Address pointers into Allen Bradley PLC's
in this property. That way, with a bank of alarm panels, I only
have to have one SetAlarm and one ClearAlarm procedure.
* 11/13/95 -- Gary D. Foster
Restructured the OnAlarmActivate and Deactivate calls so that they
are called BEFORE enabling and AFTER disabling the flashing panel.
Makes it handy for changing colors and such.
}
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, ExtCtrls, Timerpnl;
type
TAlarmPanel = class(TTimerPanel)
private
FDoneCreating: Boolean;
FOriginalColor: TColor;
FOriginalFontColor: TColor;
FOnAlarmActivate: TNotifyEvent;
FOnAlarmDeactivate: TNotifyEvent;
FStringTag: String;
protected
procedure FlashLabel(Sender: TObject); virtual;
procedure Reset; virtual;
procedure SetEnabled(Value: Boolean); override;
procedure SetStringTag(Value: String); virtual;
public
constructor Create(AOwner: TComponent); override;
published
property Caption;
property StringTag: String read FStringTag write SetStringTag;
property OnAlarmActivate: TNotifyEvent read FOnAlarmActivate
write FOnAlarmActivate;
property OnAlarmDeactivate: TNotifyEvent read FOnAlarmDeactivate
write FOnAlarmDeactivate;
end;
implementation
procedure TAlarmPanel.SetEnabled(Value: Boolean);
begin
{ Call the inherited... }
if Enabled = Value then exit;
inherited SetEnabled(Value);
{ and then save the original colors so we can restore them }
if value = false then
begin
reset;
if not (csDesigning in ComponentState) and assigned(FOnAlarmDeActivate)then
FOnAlarmDeActivate(Self);
end
else
begin
if FDoneCreating then
begin
if not (csDesigning in ComponentState) and assigned(FOnAlarmActivate) then
FOnAlarmActivate(Self);
FOriginalColor := Color;
FOriginalFontColor := Font.Color;
end;
end;
end;
procedure TAlarmPanel.FlashLabel(Sender: TObject);
var
foo: TColor;
begin
if not Enabled then exit;
foo := Color;
Color := Font.Color;
Font.Color := Foo;
end;
constructor TAlarmPanel.Create(AOwner: TComponent);
begin
FDoneCreating := False;
inherited Create(AOwner);
ClockDriver.OnTimer := FlashLabel;
FDoneCreating := True;
end;
procedure TAlarmPanel.Reset;
begin
if FOriginalColor = FOriginalFontColor then exit;
Color := FOriginalColor;
Font.Color := FOriginalFontColor;
end;
procedure TAlarmPanel.SetStringTag(Value: String);
begin
FStringTag := Value;
end;
end.
|
unit TestInterval;
interface
uses Registrator, BaseObjects, ComCtrls, Classes,
BaseWellInterval, Straton, Parameter, Variants,
Fluid;
type
TTestIntervalFluidCharacteristic = class(TRegisteredIDObject)
private
FFluidType: TFluidType;
FFluidCharacteristics: TFluidCharacteristics;
function GetFluidCharacteristics: TFluidCharacteristics;
procedure SetFluidType(const Value: TFluidType);
protected
procedure AssignTo(Dest: TPersistent); override;
function GetPropertyValue(APropertyID: integer): OleVariant; override;
public
function List(AListOption: TListOption = loBrief): string; override;
property FluidType: TFluidType read FFluidType write SetFluidType;
property FluidCharacteristics: TFluidCharacteristics read GetFluidCharacteristics;
constructor Create(ACollection: TIDObjects); override;
end;
TTestIntervalFluidCharacteristics = class(TRegisteredIDObjects)
private
function GetItems(Index: integer): TTestIntervalFluidCharacteristic;
public
property Items[Index: integer]: TTestIntervalFluidCharacteristic read GetItems;
function GetCharacteristicByFluidType(AFluidType: TFluidType): TTestIntervalFluidCharacteristic;
function Add(AFluidType: TFluidType): TTestIntervalFluidCharacteristic;
constructor Create; override;
end;
TTestingAttitude = class(TRegisteredIDObject)
public
constructor Create(ACollection: TIDObjects); override;
end;
TTestingAttitudes = class(TRegisteredIDObjects)
private
function GetItems(Index: integer): TTestingAttitude;
public
property Items[Index: integer]: TTestingAttitude read GetItems;
constructor Create; override;
end;
TSimpleTestIntervalDepths = class(TDepths)
public
constructor Create; override;
end;
TSimpleTestInterval = class(TAbsoluteWellInterval)
private
FDescription: string;
FSimpleStraton: TSimpleStraton;
FTestingAttitude: TTestingAttitude;
FParameterValues: TParameterValues;
FTestIntervalCharacteristics: TTestIntervalFluidCharacteristics;
function GetParameterValues: TParameterValues;
function GetTestIntervalCharacteristics: TTestIntervalFluidCharacteristics;
protected
procedure AssignTo(Dest: TPersistent); override;
function GetPropertyValue(APropertyID: integer): OleVariant; override;
function GetDepths: TDepths; override;
public
property Description: string read FDescription write FDescription;
property Straton: TSimpleStraton read FSimpleStraton write FSimpleStraton;
property Attitude: TTestingAttitude read FTestingAttitude write FTestingAttitude;
property ParameterValues: TParameterValues read GetParameterValues;
property TestIntervalCharacteristics: TTestIntervalFluidCharacteristics read GetTestIntervalCharacteristics;
procedure Accept(Visitor: IVisitor); override;
function List(AListOption: TListOption = loBrief): string; override;
function Update(ACollection: TIDObjects = nil): integer; override;
constructor Create(ACollection: TIDObjects); override;
end;
TSimpleTestIntervals = class(TBaseWellIntervals)
private
function GetItems(Index: integer): TSimpleTestInterval;
public
property Items[Index: integer]: TSimpleTestInterval read GetItems;
constructor Create; override;
end;
TTestInterval = class(TSimpleTestInterval)
public
constructor Create(ACollection: TIDObjects); override;
end;
TTestIntervals = class(TSimpleTestIntervals)
private
function GetItems(Index: integer): TTestInterval;
public
property Items[Index: integer]: TTestInterval read GetItems;
constructor Create; override;
end;
implementation
uses Facade, TestIntervalPoster, SysUtils;
{ TSimpleTestIntervals }
constructor TSimpleTestIntervals.Create;
begin
inherited;
FObjectClass := TSimpleTestInterval;
Poster := TMainFacade.GetInstance.DataPosterByClassType[TTestIntervalDataPoster];
end;
function TSimpleTestIntervals.GetItems(
Index: integer): TSimpleTestInterval;
begin
Result := inherited Items[Index] as TSimpleTestInterval;
end;
{ TTestIntervals }
constructor TTestIntervals.Create;
begin
inherited;
FObjectClass := TTestInterval;
OwnsObjects := true;
end;
function TTestIntervals.GetItems(Index: integer): TTestInterval;
begin
Result := inherited Items[Index] as TTestInterval;
end;
{ TTestInterval }
procedure TSimpleTestInterval.Accept(Visitor: IVisitor);
begin
inherited;
IVisitor(Visitor).VisitTestInterval(Self);
end;
procedure TSimpleTestInterval.AssignTo(Dest: TPersistent);
begin
inherited;
(Dest as TTestInterval).Description := Description;
(Dest as TTestInterval).Straton := Straton;
(Dest as TTestInterval).Attitude := Attitude;
(Dest as TTestInterval).Depths.Assign(Depths);
(Dest as TTestInterval).TestIntervalCharacteristics.Assign(TestIntervalCharacteristics);
(Dest as TTestInterval).ParameterValues.Assign(ParameterValues);
end;
constructor TSimpleTestInterval.Create(ACollection: TIDObjects);
begin
inherited;
ClassIDString := 'Долбление';
FDataPoster := TMainFacade.GetInstance.DataPosterByClassType[TTestIntervalDataPoster];
FTestIntervalCharacteristics := nil;
end;
{ TTestInterval }
constructor TTestInterval.Create(ACollection: TIDObjects);
begin
inherited;
end;
{ TTestingAttitude }
constructor TTestingAttitude.Create(ACollection: TIDObjects);
begin
inherited;
ClassIDString := 'Характер опробования';
FDataPoster := TMainFacade.GetInstance.DataPosterByClassType[TTestingAttitudeDataPoster];
end;
{ TTestingAttitudes }
constructor TTestingAttitudes.Create;
begin
inherited;
FObjectClass := TTestingAttitude;
Poster := TMainFacade.GetInstance.DataPosterByClassType[TTestingAttitudeDataPoster];
end;
function TTestingAttitudes.GetItems(Index: integer): TTestingAttitude;
begin
Result := inherited Items[Index] as TTestingAttitude;
end;
function TSimpleTestInterval.GetDepths: TDepths;
begin
if not Assigned(FDepths) then
begin
FDepths := TSimpleTestIntervalDepths.Create;
FDepths.Owner := Self;
FDepths.Reload('TESTING_INTERVAL_UIN = ' + IntToStr(ID));
if FDepths.Count = 0 then FDepths.Add;
end;
Result := FDepths;
end;
function TSimpleTestInterval.GetParameterValues: TParameterValues;
begin
if not Assigned(FParameterValues) then
begin
FParameterValues := TParameterValues.Create;
FParameterValues.Owner := Self;
FParameterValues.Reload('Testing_Interval_UIN = ' + IntToStr(ID));
end;
Result := FParameterValues;
end;
function TSimpleTestInterval.GetPropertyValue(
APropertyID: integer): OleVariant;
begin
Result := null;
case APropertyID of
1: Result := Number;
2: Result := AbsoluteTop;
3: Result := AbsoluteBottom;
4: Result := List;
5: Result := Format('%.2f', [AbsoluteTop]) + ' - ' + Format('%.2f', [AbsoluteBottom]);
6: Result := Straton.List;
7: Result := Attitude.List;
8: Result := Description;
end;
end;
function TSimpleTestInterval.GetTestIntervalCharacteristics: TTestIntervalFluidCharacteristics;
begin
if not Assigned(FTestIntervalCharacteristics) then
begin
FTestIntervalCharacteristics := TTestIntervalFluidCharacteristics.Create;
FTestIntervalCharacteristics.OwnsObjects := false;
FTestIntervalCharacteristics.Owner := Self;
FTestIntervalCharacteristics.Reload('TESTING_INTERVAL_UIN = ' + IntToStr(ID), false);
end;
Result := FTestIntervalCharacteristics;
end;
function TSimpleTestInterval.List(AListOption: TListOption = loBrief): string;
var sInterval: string;
i: integer;
begin
Result := inherited List;
sInterval := '';
for i := 0 to Depths.Count - 1 do
sInterval := sInterval + '[' + Format('%.2f', [Depths.Items[i].AbsoluteTop]) + ' - ' + Format('%.2f', [Depths.Items[i].AbsoluteBottom]) + ']';
if AListOption <> loFull then
Result := Result + sInterval
else
Result := (Collection as TIDObjects).Owner.List + ' ' + Result + sInterval;
end;
function TSimpleTestInterval.Update(ACollection: TIDObjects = nil): integer;
begin
Result := inherited Update;
Depths.Update(ACollection);
TestIntervalCharacteristics.Update(nil);
ParameterValues.Update(nil);
end;
{ TSimpleTestIntervalDepths }
constructor TSimpleTestIntervalDepths.Create;
begin
inherited;
Poster := TMainFacade.GetInstance.DataPosterByClassType[TTestIntervalAdditionalDepthPoster];
end;
{ TTestIntervalFluidCharacteristic }
procedure TTestIntervalFluidCharacteristic.AssignTo(Dest: TPersistent);
var tifc: TTestIntervalFluidCharacteristic;
i: integer;
begin
inherited;
tifc := Dest as TTestIntervalFluidCharacteristic;
tifc.FluidType := FluidType;
for i := 0 to FluidCharacteristics.Count - 1 do
tifc.FluidCharacteristics.Add(FluidCharacteristics.Items[i], false, false);
end;
constructor TTestIntervalFluidCharacteristic.Create(
ACollection: TIDObjects);
begin
inherited;
ClassIDString := 'Характеристика типа флюида интервала опробования';
FDataPoster := TMainFacade.GetInstance.DataPosterByClassType[TTestingIntervalFluidCharacteristicDataPoster];
end;
function TTestIntervalFluidCharacteristic.GetFluidCharacteristics: TFluidCharacteristics;
begin
if not Assigned(FFluidCharacteristics) then
begin
FFluidCharacteristics := TFluidCharacteristics.Create;
FFluidCharacteristics.OwnsObjects := false;
FFluidCharacteristics.Owner := Self;
end;
Result := FFluidCharacteristics;
end;
function TTestIntervalFluidCharacteristic.GetPropertyValue(
APropertyID: integer): OleVariant;
begin
Result := null;
case APropertyID of
1: Result := FluidType.List(loBrief);
2: Result := FluidCharacteristics.List(loBrief);
end;
end;
function TTestIntervalFluidCharacteristic.List(
AListOption: TListOption): string;
begin
if Assigned(FFluidType) then Result := FluidType.List(loBrief)
else Result := inherited List(AListOption);
end;
procedure TTestIntervalFluidCharacteristic.SetFluidType(
const Value: TFluidType);
begin
if FFluidType <> Value then
begin
FFluidType := Value;
Registrator.Update(Self, Self.Collection.Owner, ukUpdate);
end;
end;
{ TTestIntervalFluidCharacteristics }
function TTestIntervalFluidCharacteristics.Add(
AFluidType: TFluidType): TTestIntervalFluidCharacteristic;
begin
Result := GetCharacteristicByFluidType(AFluidType);
if not Assigned(Result) then
begin
Result := inherited Add as TTestIntervalFluidCharacteristic;
Result.FluidType := AFluidType;
end;
end;
constructor TTestIntervalFluidCharacteristics.Create;
begin
inherited;
FObjectClass := TTestIntervalFluidCharacteristic;
Poster := TMainFacade.GetInstance.DataPosterByClassType[TTestingIntervalFluidCharacteristicDataPoster];
end;
function TTestIntervalFluidCharacteristics.GetCharacteristicByFluidType(
AFluidType: TFluidType): TTestIntervalFluidCharacteristic;
var i: integer;
begin
Result := nil;
for i := 0 to Count - 1 do
if Items[i].FluidType = AFluidType then
begin
Result := Items[i];
break;
end;
end;
function TTestIntervalFluidCharacteristics.GetItems(
Index: integer): TTestIntervalFluidCharacteristic;
begin
Result := inherited Items[Index] as TTestIntervalFluidCharacteristic;
end;
end.
|
unit MDIChildForm;
interface
uses
Forms, Classes, Messages, Storage;
type
TMDIChildStorage = class(TFormStorage)
public
procedure LoadAllColumns;
procedure SaveAllColumns;
end;
TMDIChildForm = class(TForm)
private
FOnMDIActivate: TNotifyEvent;
FOnMDIDeactivate: TNotifyEvent;
FOnChildDestroy: TNotifyEvent;
FOnCaptionChanged: TNotifyEvent;
FOrderNum: Integer;
procedure WMMDIActivate(var Message: TWMMDIActivate); message WM_MDIACTIVATE;
procedure WMCreate(var Message: TWMCreate); message WM_CREATE;
procedure WMDestroy(var Message: TWMDestroy); message WM_DESTROY;
procedure WMChar(var Message: TWMChar); message WM_CHAR;
protected
FCommonStorage: TMDIChildStorage;
procedure RefreshDataSets; dynamic;
public
class function IsCanCreate: boolean; dynamic;
procedure SetCaption(NewCaption: string);
published
property OnMDIActivate: TNotifyEvent read FOnMDIActivate write FOnMDIActivate;
property OnMDIDeactivate: TNotifyEvent read FOnMDIDeactivate write FOnMDIDeactivate;
property OnChildDestroy: TNotifyEvent read FOnChildDestroy write FOnChildDestroy;
property OnCaptionChanged: TNotifyEvent read FOnCaptionChanged write FOnCaptionChanged;
property OrderNum: Integer read FOrderNum write FOrderNum;
end;
TMDIFormClass = class of TMDIChildForm;
implementation
uses
DBGrids, DB, SysUtils, DBUtils, ADODB, Windows;
{ TMDIChildStorage }
procedure TMDIChildStorage.LoadAllColumns;
var
i: Integer;
begin
for i := 0 to FComponent.ComponentCount - 1 do
if FComponent.Components[i] is TDBGrid then
LoadCollectionItemsProp(TDBGrid(FComponent.Components[i]),
TDBGrid(FComponent.Components[i]).Columns, 'Width');
end;
procedure TMDIChildStorage.SaveAllColumns;
var
i: Integer;
begin
for i := 0 to FComponent.ComponentCount - 1 do
if FComponent.Components[i] is TDBGrid then
SaveCollectionItemsProp(TDBGrid(FComponent.Components[i]),
TDBGrid(FComponent.Components[i]).Columns, 'Width');
end;
{ TMDIChildForm }
procedure TMDIChildForm.WMCreate(var Message: TWMCreate);
begin
inherited;
FCommonStorage := TMDIChildStorage.Create(Self);
end;
procedure TMDIChildForm.WMDestroy(var Message: TWMDestroy);
begin
if Assigned(FOnChildDestroy) then
FOnChildDestroy(Self);
FCommonStorage.Free;
inherited;
end;
procedure TMDIChildForm.WMMDIActivate(var Message: TWMMDIActivate);
begin
inherited;
if Self.Handle = Message.ActiveWnd then
if Assigned(FOnMDIActivate) then
FOnMDIActivate(Self);
if Self.Handle = Message.DeactiveWnd then
if Assigned(FOnMDIDeactivate) then
FOnMDIDeactivate(Self);
end;
procedure TMDIChildForm.SetCaption(NewCaption: string);
begin
Caption := NewCaption;
if OrderNum > 1 then
Caption := Format('%s (%d)', [Caption, OrderNum]);
if Assigned(FOnCaptionChanged) then
FOnCaptionChanged(Self);
end;
class function TMDIChildForm.IsCanCreate: boolean;
begin
Result := true;
end;
procedure TMDIChildForm.WMChar(var Message: TWMChar);
begin
inherited;
end;
procedure TMDIChildForm.RefreshDataSets;
var
i: Integer;
begin
for i := 0 to ComponentCount - 1 do
if Components[i] is TCustomADODataSet then
if TCustomADODataSet(Components[i]).Active then
OpenBigDataSet(TCustomADODataSet(Components[i]));
end;
end.
|
unit UGlobalObj;
interface
uses Windows, UxlClasses, UxlExtClasses, UxlWinControl, UxlMiscCtrls, UDisplay, UDisplayManager;
type
TOptions = record
DisplayMode: TDisplayMode;
TwoLines: boolean;
WinColor: TColor;
WinFont: TxlFont;
Transparency: TTransparency;
DictFile: widestring;
StartHotKey: THotKey;
FullScreenHotKey: THotKey;
TrackMouseHotKey: THotKey;
AutoRun: boolean;
TrackXSpace: integer;
TrackYSpace: integer;
BoxSize: integer;
AutoNewBox: boolean;
NewBoxCycle: integer;
AutoTestMode: boolean;
TestModeCycle: integer;
RandomNewBox: boolean;
RandomSwitchWord: boolean;
SwitchWordInterval: integer;
TestModeType: TTestModeType;
TestModeDelay: integer;
end;
TOptionManager = class (TxlOption)
private
FOptions: TOptions;
protected
procedure OnCreate (); override;
procedure OnDestroy (); override;
procedure DoLoad (); override;
procedure DoSave (); override;
function DoSetOptions (WndParent: TxlWinControl): boolean; override;
public
property Options: TOptions read FOptions write FOptions;
end;
TMemoryManager = class (TxlMemory)
protected
procedure DoLoad (); override;
procedure DoSave (); override;
public
WinPos: TPoint;
SwitchCount: integer;
BoxIndex: integer;
WordIndex: integer;
Started: boolean;
TestMode: boolean;
TrackMouse: boolean;
end;
var
OptionMan: TOptionManager;
MemoryMan: TMemoryManager;
CommandMan: TxlCommandCenter;
ProgTip: TxlTrackingTip;
implementation
uses UxlIniFile, UxlFunctions, UDialogs, UxlStrUtils, UxlMath, UxlDialog;
procedure TOptionManager.OnCreate ();
begin
FOptions.WinFont := TxlFont.Create;
end;
procedure TOptionManager.OnDestroy ();
begin
FOptions.WinFont.free;
end;
procedure TOptionManager.DoLoad ();
var o_inifile: TxlIniFile;
s_seg: widestring;
begin
o_inifile := TxlIniFile.Create (ProgIni);
o_inifile.Cache.ReadSection ('Program');
with FOptions do
begin
DictFile := o_inifile.Cache.GetString ('DictFile', '');
if (DictFile = '') and PathFileExists (ProgDir + 'Demo.dwd') then
DictFile := 'Demo.dwd';
StartHotKey := o_inifile.Cache.GetInteger ('StartHotKey', 0);
FullScreenHotKey := o_inifile.Cache.GetInteger ('FullScreenHotKey', 0);
TrackMouseHotKey := o_inifile.Cache.GetInteger ('TrackMouseHotKey', 0);
end;
o_inifile.Cache.ReadSection ('Appearance');
with FOptions do
begin
DisplayMode := TDisplayMode(o_inifile.Cache.GetInteger ('DisplayMode', Ord(dmFixed)));
TwoLines := o_inifile.Cache.GetBool ('TwoLines', false);
WinColor := TColor (o_inifile.Cache.GetInteger ('WinColor', rgb(0,0,0))); //12319917
Transparency := o_inifile.Cache.GetInteger ('Transparency', 4);
TrackXSpace := o_inifile.Cache.GetInteger ('TrackXSpace', 20);
TrackYSpace := o_inifile.Cache.GetInteger ('TrackYSpace', 15);
end;
o_inifile.Cache.ReadSection ('WordBox');
with FOptions do
begin
BoxSize := o_inifile.Cache.GetInteger ('BoxSize', 50);
AutoNewBox := o_inifile.Cache.GetBool ('AutoNewBox', true);
NewBoxCycle := o_inifile.Cache.GetInteger ('NewBoxCycle', 3);
AutoTestMode := o_inifile.Cache.GetBool ('AutoTestMode', false);
TestModeCycle := o_inifile.Cache.GetInteger ('TestModeCycle', 2);
RandomNewBox := o_inifile.Cache.GetBool ('RandomNewBox', false);
RandomSwitchWord := o_inifile.Cache.GetBool ('RandomSwitchWord', false);
SwitchWordInterval := o_inifile.Cache.GetInteger ('SwitchWordInterval', 5);
TestModeType := TTestModeType (o_inifile.Cache.GetInteger ('TestModeType', Ord(tmtRandom)));
TestModeDelay := o_inifile.Cache.GetInteger ('TestModeDelay', 2);
end;
o_inifile.Cache.ReadSection ('Font');
with FOptions.WinFont do
begin
Name := o_inifile.Cache.GetString ('FontName', 'Arial');
color := o_inifile.Cache.GetInteger('FontColor', RGB(255, 255, 255));
Size := o_inifile.Cache.GetInteger('FontSize', 9);
Bold := o_inifile.Cache.GetBool ('FontBold', false);
Italic := o_inifile.Cache.GetBool ('FontItalic', false);
Underline := o_inifile.Cache.GetBool ('FontUnderline', false);
StrikeOut := o_inifile.Cache.GetBool ('FontStrikeOut', false);
end;
o_inifile.Free;
end;
procedure TOptionManager.DoSave ();
var s_seg: widestring;
o_inifile: TxlIniFile;
begin
o_inifile := TxlIniFile.Create (ProgIni);
with o_inifile.Cache do
begin
AddString ('DictFile', FOptions.DictFile);
AddInteger ('StartHotKey', FOptions.StartHotkey);
AddInteger ('FullScreenHotKey', FOptions.FullScreenHotkey);
AddInteger ('TrackMouseHotKey', FOptions.TrackMouseHotKey);
WriteSection ('Program');
AddInteger ('DisplayMode', Ord(FOptions.DisplayMode));
AddBool ('TwoLines', FOptions.TwoLines);
AddInteger ('WinColor', Ord(FOptions.WinColor));
AddInteger ('Transparency', FOptions.Transparency);
AddInteger ('TrackXSpace', FOptions.TrackXSpace);
AddInteger ('TrackYSpace', FOptions.TrackYSpace);
WriteSection ('Appearance');
AddInteger ('BoxSize', FOptions.BoxSize);
AddBool ('AutoNewBox', FOptions.AutoNewBox);
AddInteger ('NewBoxCycle', FOptions.NewBoxCycle);
AddBool ('AutoTestMode', FOptions.AutoTestMode);
AddInteger ('TestModeCycle', FOptions.TestModeCycle);
AddBool ('RandomNewBox', FOptions.RandomNewBox);
AddBool ('RandomSwitchWord', FOptions.RandomSwitchWord);
AddInteger ('SwitchWordInterval', FOptions.SwitchWordInterval);
AddInteger ('TestModeType', Ord(FOptions.TestModeType));
AddInteger ('TestModeDelay', FOptions.TestModeDelay);
WriteSection ('WordBox');
AddString ('FontName', FOptions.WinFont.name);
AddInteger ('FontColor', FOptions.WinFont.color);
AddInteger ('FontSize', FOptions.WinFont.size);
AddBool ('FontBold', FOptions.WinFont.bold);
AddBool ('FontItalic', FOptions.WinFont.italic);
AddBool ('FontUnderline', FOptions.WinFont.Underline );
AddBool ('FontStrikeOut', FOptions.WinFont.strikeout);
WriteSection ('Font');
end;
o_inifile.Free;
end;
function TOptionManager.DoSetOptions (WndParent: TxlWinControl): boolean;
var o_box: TOptionBox;
o_reg: TxlRegistry;
s: widestring;
begin
o_reg := Txlregistry.create (HKEY_LOCAL_MACHINE);
if o_reg.openkey ('Software\Microsoft\Windows\CurrentVersion\Run', false) then
begin
s := o_reg.ReadString ('DailyWord');
o_reg.closekey;
FOptions.AutoRun := IsSameStr (ProgExe, s);
end;
o_box := TOptionBox.Create (WndParent, dpScreenCenter);
o_box.Options := FOptions;
result := o_box.Execute();
if result then
begin
if o_box.Options.AutoRun <> FOptions.AutoRun then
begin
if o_reg.openkey ('Software\Microsoft\Windows\CurrentVersion\Run', false) then
begin
if o_box.Options.AutoRun then
o_reg.WriteString ('DailyWord', ProgExe)
else
o_reg.deletevalue ('DailyWord');
o_reg.closekey;
end;
end;
FOptions := o_box.options;
end;
o_box.Free;
o_reg.free;
end;
//--------------
procedure TMemoryManager.DoLoad ();
var o_inifile: TxlIniFile;
begin
o_inifile := TxlIniFile.Create (ProgIni);
with o_inifile.Cache do
begin
ReadSection ('Memory');
WinPos.X := GetInteger ('WinPosX', 200);
WinPos.Y := GetInteger ('WinPosY', 0);
SwitchCount := GetInteger ('SwitchCount', 0);
BoxIndex := GetInteger ('BoxIndex', -1);
WordIndex := GetInteger ('WordIndex', -1);
Started := GetBool ('Started', true);
TrackMouse := GetBool ('TrackMouse', false);
TestMode := GetBool ('TestMode', false);
end;
o_inifile.Free;
end;
procedure TMemoryManager.DoSave ();
var o_inifile: TxlIniFile;
begin
o_inifile := TxlIniFile.Create (ProgIni);
with o_inifile.Cache do
begin
AddInteger ('WinPosX', WinPos.X);
AddInteger ('WinPosY', WinPos.Y);
AddInteger ('SwitchCount', SwitchCount);
AddInteger ('BoxIndex', BoxIndex);
AddInteger ('WordIndex', WordIndex);
AddBool ('Started', Started);
AddBool ('TrackMouse', TrackMouse);
AddBool ('TestMode', TestMode);
WriteSection ('Memory');
end;
o_inifile.Free;
end;
initialization
OptionMan := TOptionManager.Create;
MemoryMan := TMemoryManager.Create;
CommandMan := TxlCommandCenter.Create;
finalization
OptionMan.Free;
MemoryMan.Free;
CommandMan.Free;
end.
|
{ Subroutine STRING_CMLINE_TOKEN (TOKEN, STAT)
*
* Fetch the next token from the command line. STRING_CMLINE_INIT must have been
* called once before this routine. If STRING_CMLINE_REUSE was called since the
* last call to this routine, then the last token will be returned again.
}
module string_cmline_token;
define string_cmline_token;
%include 'string2.ins.pas';
%include 'string_sys.ins.pas';
procedure string_cmline_token ( {get next token from command line}
in out token: univ string_var_arg_t; {returned token}
out stat: sys_err_t); {completion status, used to signal end}
begin
sys_error_none (stat); {init to no error}
if not cmline_reuse then begin {need to read new token from system ?}
if cmline_next_n >= cmline_n_args then begin {no more command line args ?}
sys_stat_set (string_subsys_k, string_stat_eos_k, stat);
token.len := 0;
cmline_token_last.len := 0; {the last token is now the empty token}
return; {return with END OF STRING status}
end;
string_vstring ( {copy command line arg into local buffer}
cmline_token_last, {var string top copy arg into}
cmline_argp_p^[cmline_next_n]^, {null terminated string to copy from}
-1); {indicate max string length not known}
cmline_next_n := cmline_next_n + 1; {make arg number for next time}
end; {new arg is sitting in CMLINE_TOKEN_LAST}
string_copy (cmline_token_last, token); {return token to caller}
cmline_reuse := false; {init to read fresh token next time}
end;
|
PROGRAM PrintCarName(INPUT, OUTPUT);
BEGIN {PrintCarName}
WRITELN('‹€„€')
END. {PrintCarName}
|
unit libeay32;
{
Import unit for the OpenSSL libeay32.dll library.
Originally based on the work by Marco Ferrante.
http://www.csita.unige.it/
http://www.disi.unige.it/
then on the Indy libraries
and, of course, the C source code from http://www.openssl.org
Only the parts that we need to use have been translated/imported. There are
a whole load of functions in the library that aren't included here
2010-03-11 Why re-invent the wheel. Indy has done a large chunk of this
already so use it - IdSSLOpenSSLHeaders
Now we generally just include stuff that isn't available in the Indy code.
Primarily encryption stuff rather than SSL stuff.
}
{
Copyright (c) 2017+, Health Intersections Pty Ltd (http://www.healthintersections.com.au)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
}
interface
uses
SysUtils, {$IFDEF MSWINDOWS} Windows, {$ENDIF}{mac-to-do}
IdSSLOpenSSLHeaders;
(*
const
{$IFDEF WIN64}
LIBEAY_DLL_NAME = 'libeay64.dll';
{$ELSE}
LIBEAY_DLL_NAME = 'libeay32.dll';
{$ENDIF}
(* PROC_ADD_ALL_ALGORITHMS_NOCONF = 'OPENSSL_add_all_algorithms_noconf';
PROC_ADD_ALL_ALGORITHMS = 'OpenSSL_add_all_algorithms';
EVP_PKEY_RSA = IdSSLOpenSSLHeaders.EVP_PKEY_RSA;
PKCS5_SALT_LEN = IdSSLOpenSSLHeaders.PKCS5_SALT_LEN;
EVP_MAX_KEY_LENGTH = IdSSLOpenSSLHeaders.EVP_MAX_KEY_LENGTH;
EVP_MAX_IV_LENGTH = IdSSLOpenSSLHeaders.EVP_MAX_IV_LENGTH;
EVP_MAX_MD_SIZE = IdSSLOpenSSLHeaders.EVP_MAX_MD_SIZE;
type
PEVP_PKEY = IdSSLOpenSSLHeaders.PEVP_PKEY;
PRSA = IdSSLOpenSSLHeaders.PRSA;
EVP_MD_CTX = IdSSLOpenSSLHeaders.EVP_MD_CTX;
EVP_CIPHER_CTX = IdSSLOpenSSLHeaders.EVP_CIPHER_CTX;
PEVP_CIPHER = IdSSLOpenSSLHeaders.PEVP_CIPHER;
PEVP_MD = IdSSLOpenSSLHeaders.PEVP_MD;
type
TSSLProgressCallbackFunction = procedure (status: integer; value: integer; cb_arg: pointer);
TSSLPasswordCallbackFunction = function (buffer: TBytes; size: integer; rwflag: integer; u: pointer): integer; cdecl;
TOpenSSL_InitFunction = procedure; cdecl;
type
PEK_ARRAY = ^EK_ARRAY;
EK_ARRAY = array of PByteArray;
PUBK_ARRAY = array of PEVP_PKEY;
PPUBK_ARRAY = ^PUBK_ARRAY;
function EVP_aes_256_cbc: PEVP_CIPHER; cdecl;
function EVP_md5: PEVP_MD; cdecl;
function EVP_sha1: PEVP_MD; cdecl;
function EVP_sha256: PEVP_MD; cdecl;
function EVP_PKEY_assign(pkey: PEVP_PKEY; key_type: integer; key: Pointer): integer; cdecl;
function EVP_PKEY_new: PEVP_PKEY; cdecl;
procedure EVP_PKEY_free(key: PEVP_PKEY); cdecl;
function EVP_PKEY_assign_RSA(pkey: PEVP_PKEY; key: PRSA): integer;
function EVP_PKEY_get1_DH(pkey: pEVP_PKEY): pDH; cdecl;
function EVP_PKEY_get1_DSA(pkey: pEVP_PKEY): pDSA; cdecl;
procedure EVP_CIPHER_CTX_init(a: PEVP_CIPHER_CTX); cdecl;
function EVP_CIPHER_CTX_cleanup(a: PEVP_CIPHER_CTX): integer; cdecl;
function EVP_CIPHER_CTX_block_size(ctx: PEVP_CIPHER_CTX): integer; cdecl;
procedure EVP_MD_CTX_init(ctx: PEVP_MD_CTX); cdecl;
function EVP_MD_CTX_cleanup(ctx: PEVP_MD_CTX): integer; cdecl;
function EVP_BytesToKey(cipher_type: PEVP_CIPHER; md: PEVP_MD; salt: PByte; data: PByte; datal: integer; count: integer; key: PByte; iv: PByte): integer; cdecl;
function EVP_EncryptInit_ex(ctx: PEVP_CIPHER_CTX; cipher_type: PEVP_CIPHER; impl: PENGINE; key: PByte; iv: PByte): integer; cdecl;
function EVP_EncryptInit(ctx: PEVP_CIPHER_CTX; cipher_type: PEVP_CIPHER; key: PByte; iv: PByte): integer; cdecl;
function EVP_EncryptUpdate(ctx: PEVP_CIPHER_CTX; data_out: PByte; var outl: integer; data_in: PByte; inl: integer): integer; cdecl;
function EVP_EncryptFinal(ctx: PEVP_CIPHER_CTX; data_out: PByte; var outl: integer): integer; cdecl;
function EVP_DecryptInit_ex(ctx: PEVP_CIPHER_CTX; cipher_type: PEVP_CIPHER; impl: PENGINE; key: PByte; iv: PByte): integer; cdecl;
function EVP_DecryptInit(ctx: PEVP_CIPHER_CTX; cipher_type: PEVP_CIPHER; key: PByte; iv: PByte): integer; cdecl;
function EVP_DecryptUpdate(ctx: PEVP_CIPHER_CTX; data_out: PByte; var outl: integer; data_in: PByte; inl: integer): integer; cdecl;
function EVP_DecryptFinal(ctx: PEVP_CIPHER_CTX; data_out: PByte; var outl: integer): integer; cdecl;
function EVP_SealInit(ctx: PEVP_CIPHER_CTX; cipher_type: PEVP_CIPHER; ek: PEK_ARRAY; ekl: PIntegerArray; iv: PByte; pubk: PPUBK_ARRAY; npubk: integer): integer; cdecl;
function EVP_SealUpdate(ctx: PEVP_CIPHER_CTX; data_out: PByte; var outl: integer; data_in: PByte; inl: integer): integer;
function EVP_SealFinal(ctx: PEVP_CIPHER_CTX; data_out: PByte; var outl: integer): integer; cdecl;
function EVP_OpenInit(ctx: PEVP_CIPHER_CTX; cipher_type: PEVP_CIPHER; ek: PByte; ekl: integer; iv: PByte; priv: PEVP_PKEY): integer; cdecl;
function EVP_OpenUpdate(ctx: PEVP_CIPHER_CTX; data_out: PByte; var outl: integer; data_in: PByte; inl: integer): integer;
function EVP_OpenFinal(ctx: PEVP_CIPHER_CTX; data_out: PByte; var outl: integer): integer; cdecl;
function EVP_DigestInit_ex(ctx: PEVP_MD_CTX; md: PEVP_MD; impl: PENGINE): integer; cdecl;
function EVP_DigestFinal(ctx: PEVP_MD_CTX; md: PByte; var s: cardinal): integer; cdecl;
function EVP_DigestFinal_ex(ctx: PEVP_MD_CTX; md: PByte; var s: cardinal): integer; cdecl;
function EVP_SignInit_ex(ctx: PEVP_MD_CTX; md: PEVP_MD; impl: PENGINE): integer;
function EVP_VerifyInit_ex(ctx: PEVP_MD_CTX; md: PEVP_MD; impl: PENGINE): integer;
procedure BIO_free_all(a: PBIO); cdecl;
function PEM_write_bio_RSA_PUBKEY(bp: PBIO; x: PRSA): integer; cdecl;
function PEM_write_bio_PUBKEY(bp: PBIO; x: PEVP_PKEY): integer; cdecl;
// EVP_PKEY *PEM_read_bio_PUBKEY(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u);
function PEM_read_bio_PUBKEY(bp: PBIO; x: PPEVP_PKEY; cb: TSSLPasswordCallbackFunction; u: pointer): PEVP_PKEY; cdecl;
// RSA *PEM_read_bio_RSA_PUBKEY(BIO *bp, RSA **x, pem_password_cb *cb, void *u);
function PEM_read_bio_RSA_PUBKEY(bp: PBIO; x: PPRSA; cb: TSSLPasswordCallbackFunction; u: pointer): PRSA; cdecl;
function RAND_load_file(const filename: PAnsiChar; max_bytes: longint): integer; cdecl;
function RAND_bytes(buf: PByte; num: integer): integer; cdecl;
function RAND_pseudo_bytes(buf: PByte; num: integer): integer; cdecl;
function RSA_generate_key(num: integer; e: Cardinal; cb: TSSLProgressCallbackFunction; cb_arg: pointer): PRSA; cdecl;
procedure RSA_free(r: PRSA); cdecl;
function BN_bn2hex(const n: pBIGNUM): PAnsiChar; cdecl;
function BN_bn2dec(const n: pBIGNUM): PAnsiChar; cdecl;
function BN_hex2bn(var n: pBIGNUM; const str: PAnsiChar): integer; cdecl;
function BN_dec2bn(var n: pBIGNUM; const str: PAnsiChar): integer; cdecl;
*)
function BN_num_bytes(const a: pBIGNUM): integer;
function GetSSLErrorMessage: string;
procedure EVP_SignInit(ctx: PEVP_MD_CTX; md: PEVP_MD);
function EVP_SignUpdate(ctx: PEVP_MD_CTX; data: PByte; cnt: integer): integer;
procedure EVP_VerifyInit(ctx: PEVP_MD_CTX; md: PEVP_MD);
function EVP_VerifyUpdate(ctx: PEVP_MD_CTX; data: PByte; cnt: integer): integer;
var
BN_num_bits : function (const a: pBIGNUM): integer cdecl = nil;
BN_bn2bin : function (const n: pBIGNUM; _to: pointer): integer cdecl = nil;
BN_bin2bn : function (const _from: pointer; len: integer; ret: pBIGNUM): pBIGNUM cdecl = nil;
X509_get_pubkey : function (cert: PX509): PEVP_PKEY cdecl = nil;
EVP_PKEY_get1_RSA : function (pkey: pEVP_PKEY): pRSA cdecl = nil;
EVP_PKEY_set1_RSA : function (pkey: PEVP_PKEY; key: PRSA): integer cdecl = nil;
EVP_PKEY_get1_DSA : function (pkey: pEVP_PKEY): pDSA cdecl = nil;
EVP_PKEY_set1_DSA : function (pkey: PEVP_PKEY; key: PDSA): integer cdecl = nil;
EVP_PKEY_size : function (pkey: PEVP_PKEY): integer cdecl = nil;
EVP_DigestInit : procedure (ctx: PEVP_MD_CTX; md: PEVP_MD) cdecl = nil;
EVP_DigestUpdate : function (ctx: PEVP_MD_CTX; data: PByte; cnt: integer): integer cdecl = nil;
EVP_SignFinal : function (ctx: PEVP_MD_CTX; sig: PByte; var s: integer; pkey: PEVP_PKEY): integer cdecl = nil;
EVP_VerifyFinal : function (ctx: PEVP_MD_CTX; sig: PByte; s: integer; pkey: PEVP_PKEY): integer cdecl = nil;
DSA_new: function: PDSA cdecl = nil;
DSA_free : procedure(rsa: PDSA) cdecl = nil;
function LoadEAYExtensions : boolean;
procedure UnloadEAYExtensions;
implementation
var
gLoadCount : Integer;
function DllPath : String;
var
TheFileName : array[0..MAX_PATH] of widechar;
begin
FillChar(TheFileName, sizeof(TheFileName), #0);
GetModuleFileName(GetCryptLibHandle, TheFileName, sizeof(TheFileName));
result := TheFileName;
end;
function LoadFunctionCLib(const FceName: {$IFDEF WINCE}TIdUnicodeString{$ELSE}string{$ENDIF}; const ACritical : Boolean = True): Pointer;
begin
Result := {$IFDEF WINDOWS}Windows.{$ENDIF}GetProcAddress(GetCryptLibHandle, {$IFDEF WINCE}PWideChar{$ELSE}PChar{$ENDIF}(FceName));
if (Result = nil) and ACritical then
begin
raise Exception.Create('Count not load '+FceName+' from '+DllPath);
end;
end;
function LoadEAYExtensions : boolean;
begin
inc(gLoadCount);
if gLoadCount = 1 then
begin
@BN_num_bits := LoadFunctionCLib('BN_num_bits');
@BN_bn2bin := LoadFunctionCLib('BN_bn2bin');
@BN_bin2bn := LoadFunctionCLib('BN_bin2bn');
@X509_get_pubkey := LoadFunctionCLib('X509_get_pubkey');
@EVP_PKEY_get1_RSA := LoadFunctionCLib('EVP_PKEY_get1_RSA');
@EVP_PKEY_set1_RSA := LoadFunctionCLib('EVP_PKEY_set1_RSA');
@EVP_PKEY_get1_DSA := LoadFunctionCLib('EVP_PKEY_get1_DSA');
@EVP_PKEY_set1_DSA := LoadFunctionCLib('EVP_PKEY_set1_DSA');
@EVP_PKEY_size := LoadFunctionCLib('EVP_PKEY_size');
@EVP_DigestInit := LoadFunctionCLib('EVP_DigestInit');
@EVP_DigestUpdate := LoadFunctionCLib('EVP_DigestUpdate');
@EVP_SignFinal := LoadFunctionCLib('EVP_SignFinal');
@EVP_VerifyFinal := LoadFunctionCLib('EVP_VerifyFinal');
@DSA_new := LoadFunctionCLib('DSA_new');
@DSA_free := LoadFunctionCLib('DSA_free');
end;
result := @BN_num_bits <> nil;
end;
procedure UnloadEAYExtensions;
begin
dec(gLoadCount);
if gLoadCount = 0 then
begin
@DES_ecb_encrypt := nil;
@BN_num_bits := nil;
@BN_bn2bin := nil;
@BN_bin2bn := nil;
@X509_get_pubkey := nil;
@EVP_PKEY_get1_RSA := nil;
@EVP_PKEY_set1_RSA := nil;
@EVP_PKEY_get1_DSA := nil;
@EVP_PKEY_set1_DSA := nil;
@EVP_PKEY_size := nil;
@EVP_DigestInit := nil;
@EVP_DigestUpdate := nil;
@EVP_SignFinal := nil;
@EVP_VerifyFinal := nil;
@DSA_new := nil;
@DSA_free := nil;
end;
end;
(*
resourcestring
sLibeay32NotLoaded = 'libeay32.dll not loaded';
sAddAllAlgorithmsProcNotFound = 'OpenSSL_add_all_algorithms procedure not defined in libeay32.dll';
function EVP_aes_256_cbc: PEVP_CIPHER; cdecl external LIBEAY_DLL_NAME;
function EVP_md5; cdecl external LIBEAY_DLL_NAME;
function EVP_sha1; cdecl external LIBEAY_DLL_NAME;
function EVP_sha256; cdecl external LIBEAY_DLL_NAME;
function EVP_PKEY_assign; cdecl external LIBEAY_DLL_NAME;
function EVP_PKEY_new; cdecl external LIBEAY_DLL_NAME;
procedure EVP_PKEY_free; cdecl external LIBEAY_DLL_NAME;
function EVP_PKEY_assign_RSA(pkey: PEVP_PKEY; key: PRSA): integer;
begin
// Implemented as a macro in evp.h
result := EVP_PKEY_assign(pkey, EVP_PKEY_RSA, PAnsiChar(key));
end;
function EVP_PKEY_size; cdecl external LIBEAY_DLL_NAME;
function EVP_PKEY_get1_DH(pkey: pEVP_PKEY): pDH; cdecl; external LIBEAY_DLL_NAME;
function EVP_PKEY_get1_DSA(pkey: pEVP_PKEY): pDSA; cdecl; external LIBEAY_DLL_NAME;
function EVP_PKEY_get1_RSA(pkey: pEVP_PKEY): pRSA; cdecl; external LIBEAY_DLL_NAME;
procedure EVP_CIPHER_CTX_init; cdecl external LIBEAY_DLL_NAME;
function EVP_CIPHER_CTX_cleanup; cdecl external LIBEAY_DLL_NAME;
function EVP_CIPHER_CTX_block_size; cdecl external LIBEAY_DLL_NAME;
function EVP_BytesToKey; cdecl external LIBEAY_DLL_NAME;
function EVP_EncryptInit_ex; cdecl external LIBEAY_DLL_NAME;
function EVP_EncryptInit; cdecl external LIBEAY_DLL_NAME;
function EVP_EncryptUpdate; cdecl external LIBEAY_DLL_NAME;
function EVP_EncryptFinal; cdecl external LIBEAY_DLL_NAME;
function EVP_DecryptInit_ex; cdecl external LIBEAY_DLL_NAME;
function EVP_DecryptInit; cdecl external LIBEAY_DLL_NAME;
function EVP_DecryptUpdate; cdecl external LIBEAY_DLL_NAME;
function EVP_DecryptFinal; cdecl external LIBEAY_DLL_NAME;
function EVP_SealInit; cdecl external LIBEAY_DLL_NAME;
function EVP_SealUpdate(ctx: PEVP_CIPHER_CTX; data_out: PByte; var outl: integer; data_in: PByte; inl: integer): integer;
begin
// EVP_SealUpdate is #defined to EVP_EncryptUpdate in evp.h
result := EVP_EncryptUpdate(ctx, data_out, outl, data_in, inl);
end;
function EVP_SealFinal; cdecl external LIBEAY_DLL_NAME;
function EVP_OpenInit; cdecl external LIBEAY_DLL_NAME;
function EVP_OpenUpdate(ctx: PEVP_CIPHER_CTX; data_out: PByte; var outl: integer; data_in: PByte; inl: integer): integer;
begin
// EVP_OpenUpdate is #defined to EVP_DecryptUpdate in evp.h
result := EVP_DecryptUpdate(ctx, data_out, outl, data_in, inl);
end;
function EVP_OpenFinal; cdecl external LIBEAY_DLL_NAME;
procedure EVP_MD_CTX_init; cdecl external LIBEAY_DLL_NAME;
function EVP_MD_CTX_cleanup; cdecl external LIBEAY_DLL_NAME;
procedure EVP_DigestInit; external LIBEAY_DLL_NAME;
function EVP_DigestInit_ex; external LIBEAY_DLL_NAME;
function EVP_DigestUpdate; external LIBEAY_DLL_NAME;
function EVP_DigestFinal; external LIBEAY_DLL_NAME;
function EVP_DigestFinal_ex; external LIBEAY_DLL_NAME;
procedure EVP_SignInit(ctx: PEVP_MD_CTX; md: PEVP_MD);
begin
// Defined as a macro in evp.h
EVP_DigestInit(ctx, md);
end;
function EVP_SignInit_ex(ctx: PEVP_MD_CTX; md: PEVP_MD; impl: PENGINE): integer;
begin
// Defined as a macro in evp.h
result := EVP_DigestInit_ex(ctx, md, impl);
end;
function EVP_SignFinal; cdecl external LIBEAY_DLL_NAME;
function EVP_VerifyFinal; cdecl external LIBEAY_DLL_NAME;
function X509_get_pubkey; cdecl; external LIBEAY_DLL_NAME;
procedure BIO_free_all; cdecl external LIBEAY_DLL_NAME;
function PEM_read_bio_RSA_PUBKEY; cdecl external LIBEAY_DLL_NAME;
function PEM_write_bio_RSA_PUBKEY; cdecl external LIBEAY_DLL_NAME;
function PEM_read_bio_PUBKEY; cdecl external LIBEAY_DLL_NAME;
function PEM_write_bio_PUBKEY; cdecl external LIBEAY_DLL_NAME;
function RAND_load_file; cdecl external LIBEAY_DLL_NAME;
function RAND_bytes; cdecl external LIBEAY_DLL_NAME;
function RAND_pseudo_bytes; cdecl external LIBEAY_DLL_NAME;
function RSA_generate_key; cdecl external LIBEAY_DLL_NAME;
procedure RSA_free; cdecl external LIBEAY_DLL_NAME;
function BN_bin2bn; cdecl; external LIBEAY_DLL_NAME;
function BN_bn2bin; cdecl; external LIBEAY_DLL_NAME;
function BN_bn2hex; cdecl; external LIBEAY_DLL_NAME;
function BN_bn2dec; cdecl; external LIBEAY_DLL_NAME;
function BN_hex2bn; cdecl; external LIBEAY_DLL_NAME;
function BN_dec2bn; cdecl; external LIBEAY_DLL_NAME;
function EVP_PKEY_set1_RSA; cdecl; external LIBEAY_DLL_NAME;
function BN_num_bits(const a: pBIGNUM): integer; cdecl; external LIBEAY_DLL_NAME;
*)
function GetSSLErrorMessage: string;
const
BUFF_SIZE = 128; // OpenSSL docs state should be >= 120 bytes
var
err: TBytes;
begin
SetLength(err, BUFF_SIZE);
ERR_error_string(ERR_get_error, @err[0]);
result := string(err);
end;
function BN_num_bytes(const a: pBIGNUM): integer;
begin
result := (BN_num_bits(a) + 7) div 8;
end;
procedure EVP_SignInit(ctx: PEVP_MD_CTX; md: PEVP_MD);
begin
// Defined as a macro in evp.h
EVP_DigestInit(ctx, md);
end;
function EVP_SignUpdate(ctx: PEVP_MD_CTX; data: PByte; cnt: integer): integer;
begin
// Defined as a macro in evp.h
result := EVP_DigestUpdate(ctx, data, cnt);
end;
procedure EVP_VerifyInit(ctx: PEVP_MD_CTX; md: PEVP_MD);
begin
// Defined as a macro in evp.h
EVP_DigestInit(ctx, md);
end;
function EVP_VerifyUpdate(ctx: PEVP_MD_CTX; data: PByte; cnt: integer): integer;
begin
// Defined as a macro in evp.h
result := EVP_DigestUpdate(ctx, data, cnt);
end;
end.
|
unit UTransferencia;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, UBasePesquisaSimples, Vcl.ExtCtrls,
Vcl.DBCtrls, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Param,
FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf,
FireDAC.Stan.Async, FireDAC.DApt, Data.DB, FireDAC.Comp.DataSet,
FireDAC.Comp.Client, Vcl.StdCtrls, Vcl.Grids, Vcl.DBGrids, Vcl.Buttons;
type
TF_transferencia = class(TF_baseTelaSimples)
pnlTopo: TPanel;
pnlRodape: TPanel;
pnlDados: TPanel;
pnlDadosHospede: TPanel;
pnlNomeHospede: TPanel;
pnlAptosOcupados: TPanel;
pnlProdutosConsumidos: TPanel;
lblNomeHospede: TLabel;
DBGridAptosOcupados: TDBGrid;
pnlAptosOcupados2: TPanel;
lblAptosOcupados: TLabel;
pnlProdutosConsumidos2: TPanel;
lblProdutosConsumidos: TLabel;
pnlAptosDisponiveis2: TPanel;
lbl: TLabel;
pnlAptosDisponiveis: TPanel;
pnlAptosDisponiveis3: TPanel;
pnlValores: TPanel;
gbxDiarias: TGroupBox;
lblTitulo: TLabel;
DS_aptosOcupados: TDataSource;
DS_aptosConsumo: TDataSource;
DS_aptosDisponiveis: TDataSource;
DBGridAptosDisponiveis: TDBGrid;
DBGridProdutosConsumidos: TDBGrid;
btnTransfere: TSpeedButton;
btnFocus: TButton;
lblTotalConsumo: TLabel;
lblVlrConsumo: TLabel;
lblVlrDiarias: TLabel;
lblTotalDiarias: TLabel;
QRY_pegaDados: TFDQuery;
QRY_pegaDadosENT_CODENTRADA: TIntegerField;
QRY_pegaDadosENT_CODAPARTAMENTO: TIntegerField;
QRY_pegaDadosENT_CODHOSPEDE: TIntegerField;
QRY_pegaDadosENT_DATAENTRADA: TDateField;
QRY_pegaDadosENT_QTD_DIARIA_NORMAL: TIntegerField;
QRY_pegaDadosENT_QTD_DIARIA_EXTRA: TIntegerField;
QRY_pegaDadosENT_VLR_G_DIARIA_EXTRA: TBCDField;
QRY_pegaDadosENT_VLR_G_DIARIA_NORMAL: TBCDField;
QRY_pegaDadosENT_VLR_DIARIA_EXTRA: TBCDField;
QRY_pegaDadosENT_DATASAIDA: TDateField;
QRY_pegaDadosENT_HORASAIDA: TTimeField;
QRY_pegaDadosENT_TOT_GERAL_BAR: TBCDField;
QRY_pegaDadosENT_TOT_GERAL_DIARIAS: TBCDField;
QRY_pegaDadosENT_TOT_GERAL_LICAGAO: TStringField;
QRY_pegaDadosENT_VLR_TOTAL_DIARIAS: TBCDField;
QRY_pegaDadosENT_QTD_TOTAL_DIARIAS: TIntegerField;
QRY_pegaDadosENT_PREVISAO: TDateField;
QRY_pegaDadosENT_DESCACRESCGERAL: TBCDField;
QRY_pegaDadosENT_TOTALPAGO: TBCDField;
QRY_pegaDadosENT_QTDADULTOS: TIntegerField;
QRY_pegaDadosENT_QTDCRIANCAS: TIntegerField;
QRY_pegaDadosENT_QTDPAGANTES: TIntegerField;
QRY_pegaDadosENT_PLACA: TStringField;
QRY_pegaDadosENT_MODELOVEICULO: TStringField;
QRY_pegaDadosENT_MARCAVEICULO: TStringField;
QRY_pegaDadosENT_FILIAL: TStringField;
QRY_pegaDadosENT_VLR_DIARIA_NORMAL: TBCDField;
QRY_pegaDadosENT_DATARESERVA: TDateField;
QRY_pegaDadosENT_HORARESERVA: TTimeField;
QRY_pegaDadosENT_USUARIORESERVOU: TIntegerField;
QRY_pegaDadosENT_DATAEFETIVARESERVA: TDateField;
QRY_pegaDadosENT_STATUS: TStringField;
QRY_pegaDadosENT_DATAPREVISAOEFETIVAR: TDateField;
QRY_pegaDadosENT_HORAENTRADA: TTimeField;
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure DBGridAptosOcupadosCellClick(Column: TColumn);
procedure btnTransfereClick(Sender: TObject);
procedure DBGridAptosDisponiveisCellClick(Column: TColumn);
private
{ Private declarations }
public
{ Public declarations }
var aptoOcupado, aptoDisponivel: String;
procedure GetProdutosConsumidos;
procedure GetHospedes;
procedure GetAptosOcupados;
procedure GetAptosDisponiveis;
end;
var
F_transferencia: TF_transferencia;
implementation
{$R *.dfm}
uses UDMConexao, UFunctions, UMsg, UDMTransferencia, UDMRackApto, UCheckIn,
UDMHospedes, URackApto;
procedure TF_transferencia.btnTransfereClick(Sender: TObject);
begin
inherited;
{Transferencia}
if aptoOcupado = ''then begin
TF_msg.Mensagem('Favor, escolha um Apto já ocupado para Transferir.','I',[mbOk]);
DBGridAptosOcupados.SetFocus;
exit;
end;
if aptoDisponivel = '' then begin
TF_msg.Mensagem('Favor, escolha um Apto Livre para Transferir.','I',[mbOk]);
DBGridAptosDisponiveis.SetFocus;
exit;
end;
{Aqui, caso da certo acima, faz a transferência. Deverá pedir a senha}
{pega os dados para update e insert baseado no apto selecionado no click acima}
with QRY_pegaDados do begin
Close;
SQL.Clear;
SQL.Add('select * from hotentrahospede where ent_codentrada = :codEntrada');
Params[0].Value := F_dmTransferencia.QRY_aptosOcupadosENT_CODENTRADA.AsInteger;
Open();
end;
try
F_dmConexao.FDConn.StartTransaction; {inicia a transação}
F_dmTransferencia.QRY_InsertHotTransferencia.Open();
F_dmTransferencia.QRY_InsertHotTransferencia.Append;
{passa os dados para a tabela transferencia}
F_dmTransferencia.QRY_InsertHotTransferenciaTR_APTO_ANTERIOR.AsInteger := QRY_pegaDadosENT_CODAPARTAMENTO.AsInteger;
F_dmTransferencia.QRY_InsertHotTransferenciaTR_NOVO_APTO.AsInteger := F_dmTransferencia.QRY_aptosDisponiveisAPA_CODAPARTAMENTO.AsInteger;
F_dmTransferencia.QRY_InsertHotTransferenciaTR_HRA_TRANSFERENCIA.AsDateTime := Time;
F_dmTransferencia.QRY_InsertHotTransferenciaTR_DTA_TRANSFERENCIA.AsDateTime := Date;
F_dmTransferencia.QRY_InsertHotTransferenciaTR_HISTORICO.AsString := 'TRANSFERENCIA DO APTO: '+F_dmTransferencia.QRY_aptosOcupadosAPA_APARTAMENTO.AsString
+' PARA O APTO: '+F_dmTransferencia.QRY_aptosDisponiveisAPA_APARTAMENTO.AsString;
F_dmTransferencia.QRY_InsertHotTransferenciaTR_USUARIO_TRANSFERIU.AsInteger := 1; {pegar o user logado do sistema}
F_dmTransferencia.QRY_InsertHotTransferenciaTR_COD_HOSPEDAGEM.AsInteger := QRY_pegaDadosENT_CODENTRADA.AsInteger;
F_dmTransferencia.QRY_InsertHotTransferenciaTR_VLR_DIARIA_N_ANTERIOR.AsCurrency := F_checkIn.vlrDNormal.Value;
F_dmTransferencia.QRY_InsertHotTransferenciaTR_VLR_DIARIA_E_ANTERIOR.AsCurrency := F_checkIn.vlrDExtra.Value;
//F_dmTransferencia.QRY_InsertHotTransferenciaTR_VLR_CONSUMO_ANTERIOR.AsCurrency := QRY_pegaDadosENT_TOT_GERAL_BAR.AsCurrency;
//F_dmTransferencia.QRY_InsertHotTransferenciaTR_VLR_OUTROS.AsCurrency := QRY_pegaDadosENT_TOT_GERAL_OUTROS.ASCurrency;
//F_dmTransferencia.QRY_InsertHotTransferenciaTR_QTD_DIARIA_N_ANTERIOR.AsString :=
F_dmTransferencia.QRY_InsertHotTransferenciaTR_QTD_DIARIA_N_ANTERIOR.Value := F_checkIn.edtQtdDNormal.Value;
F_dmTransferencia.QRY_InsertHotTransferenciaTR_QTD_DIARIA_E_ANTERIOR.Value := F_checkIn.edtQtdDExtra.Value;
{verificar se quer cobrar esse valor ou não. O cliente poderá mudar de apto sem que ele queira visto que as vezes foi por problemas. se isso acontecer
o hotel deverá manter os valores anterior para ele.}
F_dmTransferencia.QRY_InsertHotTransferenciaTR_VLR_GERAL_DIARIAS_ANTERIOR.Value := (F_checkIn.vlrDNormal.Value * F_checkIn.edtQtdDNormal.Value)
+ (F_checkIn.vlrDExtra.Value * F_checkIn.edtQtdDExtra.Value);
F_dmTransferencia.QRY_InsertHotTransferenciaTR_COD_HOSPEDE.AsInteger := F_checkIn.codHospede;
if F_dmTransferencia.QRY_aptosOcupadosENT_STATUS.AsString = 'RESERVADO' then begin
F_dmTransferencia.QRY_InsertHotTransferenciaTR_DTA_RESERVA_ANTERIOR.AsDateTime := QRY_pegaDadosENT_DATARESERVA.AsDateTime;
F_dmTransferencia.QRY_InsertHotTransferenciaTR_HRA_RESERVA_ANTERIOR.AsDateTime := QRY_pegaDadosENT_HORARESERVA.AsDateTime;
end
else begin
F_dmTransferencia.QRY_InsertHotTransferenciaTR_DTA_HOSPEDAGEM_ANTERIOR.AsDateTime := QRY_pegaDadosENT_DATAENTRADA.AsDateTime;
F_dmTransferencia.QRY_InsertHotTransferenciaTR_HRA_HOSPEDAGEM_ANTERIOR.AsDateTime := QRY_pegaDadosENT_HORAENTRADA.AsDateTime;
end;
F_dmTransferencia.QRY_InsertHotTransferencia.Post;
{Update o Status do Apto. Transferido}
with F_dmTransferencia.QRY_updateHotAptos do begin
Close;
SQL.Clear;
SQL.Add('update HOTAPARTAMENTO');
SQL.Add('set APA_SITUACAO = :situacao');
SQL.Add('where (APA_CODAPARTAMENTO = :codApto) ');
ParamByName('situacao').Value := 'LIVRE';
ParamByName('codApto').Value := F_dmTransferencia.QRY_aptosOcupadosAPA_CODAPARTAMENTO.AsInteger;
ExecSQL;
end;
{Update o Status do Novo Apto. Transferido}
if F_dmTransferencia.QRY_aptosOcupadosENT_STATUS.AsString = 'RESERVADO' then begin
with F_dmTransferencia.QRY_updateHotAptos do begin
Close;
SQL.Clear;
SQL.Add('update HOTAPARTAMENTO');
SQL.Add('set APA_SITUACAO = :situacao');
SQL.Add('where (APA_CODAPARTAMENTO = :codApto) ');
ParamByName('situacao').Value := 'RESERVADO';
ParamByName('codApto').Value := F_dmTransferencia.QRY_aptosDisponiveisAPA_CODAPARTAMENTO.AsInteger;
ExecSQL;
end;
end
else begin
with F_dmTransferencia.QRY_updateHotAptos do begin
Close;
SQL.Clear;
SQL.Add('update HOTAPARTAMENTO');
SQL.Add('set APA_SITUACAO = :situacao, APA_CODENTRADA = :codEntrada');
SQL.Add('where (APA_CODAPARTAMENTO = :codApto) ');
ParamByName('situacao').Value := 'OCUPADO';
ParamByName('codEntrada').Value := F_dmTransferencia.QRY_aptosOcupadosENT_CODENTRADA.AsInteger;
ParamByName('codApto').Value := F_dmTransferencia.QRY_aptosDisponiveisAPA_CODAPARTAMENTO.AsInteger;
ExecSQL;
end;
end;
{Update o Status da Reserva}
with F_dmTransferencia.QRY_updateHotEntraHospede do begin
{Mudar o codigo do Apto, mudar os valores das diarias normais e extra, qtd diaria normal e extra mantem a mesma por enquanto,
ent_vlr_total_diarias (valor total das diárias) recalcular. ex: pga a qtd de normais que é 1 e multiplica pelo valor da nova diaria. faz o mesmo com
as extras. pega a qtd de diarias extras que é a mesma e multiplica pelo novo valor da diaria extra. e soma as duas e grava no total.
qtd total de diarias é a mesma. Atualizar o ent_vlr_g_diaria_normal e extra.}
// verificar campos desnecessarios na tabela hotentrahospede
Close;
SQL.Clear;
SQL.Add('update hotentrahospede set ent_codapartamento = :codApto, ent_dataentrada = :dtaEntrada, ent_horaentrada = :hraEntrada, ');
SQL.Add('ent_vlr_diaria_extra = :vlrDiariaExtra, ent_vlr_g_diaria_extra = :vlrGDExtra, ent_vlr_g_diaria_normal = :vlrGDNormal, ');
SQL.Add('ent_vlr_diaria_normal = :vlrDNormal');
SQL.Add('where ent_codentrada = :codEntrada');
ParamByName('codApto').Value := F_dmTransferencia.QRY_aptosDisponiveisAPA_CODAPARTAMENTO.AsInteger;
ParamByName('dtaEntrada').Value := Date;
ParamByName('hraEntrada').Value := Time;
ParamByName('vlrDiariaExtra').Value := F_dmTransferencia.QRY_aptosDisponiveisCAT_VALORDIARIA2.AsCurrency;
ParamByName('vlrGDExtra').Value := 0;
ParamByName('vlrGDNormal').Value := 0;
ParamByName('vlrDNormal').Value := F_dmTransferencia.QRY_aptosDisponiveisCAT_VALORDIARIA1.AsCurrency;
ParamByName('codEntrada').Value := F_dmTransferencia.QRY_aptosOcupadosENT_CODENTRADA.AsInteger;
ExecSQL;
end;
{Update o Status da Reserva}
if F_dmTransferencia.QRY_aptosOcupadosENT_STATUS.AsString = 'RESERVADO' then begin
with F_dmTransferencia.QRY_updateHotEntraHospede do begin
Close;
SQL.Clear;
SQL.Add('update hotentrahospede set ent_status = ''RESERVADO'' where ent_codentrada = :codEntrada');
ParamByName('codEntrada').Value := F_dmTransferencia.QRY_aptosOcupadosENT_CODENTRADA.AsInteger;
ExecSQL;
end;
end
else begin
with F_dmTransferencia.QRY_updateHotEntraHospede do begin
Close;
SQL.Clear;
SQL.Add('update hotentrahospede set ent_status = ''OCUPADO'' where ent_codentrada = :codEntrada');
ParamByName('codEntrada').Value := F_dmTransferencia.QRY_aptosOcupadosENT_CODENTRADA.AsInteger;
ExecSQL;
end;
end;
F_dmTransferencia.QRY_InsertHotTransferencia.ApplyUpdates(0);
// F_dmTransferencia.QRY_updateHotAptos.ApplyUpdates(0);
F_dmConexao.FDConn.Commit; {se tudo der certo, commita a transação}
TF_msg.Mensagem('Apto Transferido com sucesso.','I',[mbOk]);
{Tem que fazer isso para não inserir novamente}
// F_dmTransferencia.QRY_InsertHotTransferencia.SQL.Clear;
// F_dmTransferencia.QRY_InsertHotTransferencia.Close;
F_checkIn.Close;
Self.Close;
OrdenaLista;
{limpa para não ficar com dados antigo na memória}
aptoOcupado := '';
aptoDisponivel := '';
{Faz um Refresh nas grids: Ocupados, Disponíveis e na grid Produtos.}
GetAptosOcupados;
GetAptosDisponiveis;
btnFocus.SetFocus; {so serve para o foco sair da grid.}
except on e:Exception do
begin
F_dmConexao.FDConn.Rollback;
TF_msg.Mensagem('Erro na Transferência do Apto. Verifique os Aptos corretamente.','I',[mbOk]);
exit;
end;
end;
end;
procedure TF_transferencia.DBGridAptosDisponiveisCellClick(Column: TColumn);
begin {ao clicar na grid dos disponiveis}
inherited;
aptoDisponivel := F_dmTransferencia.QRY_aptosDisponiveisAPA_APARTAMENTO.AsString;
end;
procedure TF_transferencia.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
FreeAndNil(F_dmTransferencia);
end;
procedure TF_transferencia.DBGridAptosOcupadosCellClick(Column: TColumn);
//var vlrTotal: Double;
begin {ao clicar na grid dos ocupados}
// inherited;
aptoOcupado := IntToStr(F_dmTransferencia.QRY_aptosOcupadosENT_CODENTRADA.AsInteger);
// {Pega os produtos consumidos baseado no apto. clicado}
// GetProdutosConsumidos;
//============================================deverá rever esses calculos=============================================.
// {soma os totais dos produtos}
// if F_dmTransferencia.QRY_aptosConsumo.RecordCount > 0 then begin
// vlrTotal := 0;
// F_dmTransferencia.QRY_aptosConsumo.First;
// while not F_dmTransferencia.QRY_aptosConsumo.Eof do begin
// vlrTotal := vlrTotal + F_dmTransferencia.QRY_aptosConsumoME2_VLRTOTAL.AsVariant;
// F_dmTransferencia.QRY_aptosConsumo.Next;
// end;
// lblTotalConsumo.Caption := FloatToStrF(vlrTotal, ffCurrency, 10,2);
// end
// else begin
// lblTotalConsumo.Caption := FloatToStrF(0, ffCurrency, 10,2);
// end;
//
// {Soma os totais das diárias}
// lblTotalDiarias.Caption := FloatToStrF(F_dmTransferencia.QRY_aptosOcupados, ffCurrency, 10,2);
end;
procedure TF_transferencia.FormShow(Sender: TObject);
begin {OnShow}
inherited;
{inicia vazio para nao correr o risco de ter lixo de memória nas variáveis}
// aptoOcupado := '';
// aptoDisponivel := '';
//
// {passa os valores das diarias e do consumo.}
// lblTotalDiarias.Caption := FloatToStrF(F_checkIn.vlrTotal.Value, ffCurrency, 10,2);
// lblTotalConsumo.Caption := FloatToStrF(F_checkIn.vlrConsumo.Value, ffCurrency, 10,2);
if F_dmTransferencia = nil then begin
Application.CreateForm(TF_dmTransferencia, F_dmTransferencia);
end;
{Pega o Hospede}
GetHospedes;
lblNomeHospede.Caption := 'HÓSPEDE: '+ F_dmTransferencia.QRY_hospedeCLI_RAZAO.AsString;
{Pega os Aptos. Ocupados}
GetAptosOcupados;
{Pega os Aptos. Disponíveis}
GetAptosDisponiveis;
{Pega os produtos dos aptos}
GetProdutosConsumidos;
end;
procedure TF_transferencia.GetAptosDisponiveis;
begin {GetAptosDisponiveis}
with F_dmTransferencia.QRY_aptosDisponiveis do begin
Close;
SQL.Clear;
SQL.Add('select ap.*, ct.cat_valordiaria1, ct.cat_valordiaria2, ct.cat_categoria from hotapartamento ap inner join');
SQL.Add('hotcategoria ct on (ap.apa_codcategoria = ct.cat_codcategoria) where apa_situacao = ''LIVRE''');
SQL.Add('order by ct.cat_categoria');
Open();
end;
end;
procedure TF_transferencia.GetAptosOcupados;
begin {GetAptosOcupados}
with F_dmTransferencia.QRY_aptosOcupados do begin
Close;
SQL.Clear;
SQL.Add('select eh.ent_codentrada, ap.apa_apartamento, eh.ent_status, eh.ent_dataentrada, eh.ent_horaentrada,');
SQL.Add(' ap.apa_codapartamento, eh.ent_horareserva, eh.ent_datareserva, eh.ent_codhospede from hotentrahospede eh');
SQL.Add(' inner join hotapartamento ap on (eh.ent_codapartamento = ap.apa_codapartamento)');
SQL.Add(' where eh.ent_codhospede = :codHospede and (eh.ent_status = :st1 or eh.ent_status = :st2)');
ParamByName('codHospede').Value := F_dmTransferencia.QRY_hospedeCLI_CODIGO.AsInteger; {pegar o codigo do Hospede que está hospedado no apto.}
ParamByName('st1').Value := 'OCUPADO';
ParamByName('st2').Value := 'RESERVADO';
Open();
end;
end;
procedure TF_transferencia.GetHospedes;
begin {GetHospedes}
with F_dmTransferencia.QRY_hospede do begin
Close;
SQL.Clear;
SQL.Add('select cl.cli_codigo, cl.cli_razao, cl.cli_fanta from cliente cl');
SQL.Add(' inner join hotentrahospede eh');
SQL.Add(' on (cl.cli_codigo = eh.ent_codhospede)');
SQL.Add(' where eh.ent_codapartamento = :codApto and eh.ent_status = :status');
Params[0].Value := CodApartamento;
Params[1].Value := 'OCUPADO';
Open();
end;
end;
procedure TF_transferencia.GetProdutosConsumidos;
begin {GetProdutosConsumidos}
with F_dmTransferencia.QRY_aptosConsumo do begin
Close;
SQL.Clear;
SQL.Add('select ME2_DOCTO, ME2_OPERACAO, ME2_DATA, ME2_QUATIDADE, ME2_VLRUNIT,');
SQL.Add('ME2_PRONOME, ME2_VLRTOTAL, ME2_DESCONTO, ME2_FUNCIONARIO, ME2_COMPLEMENTO, ME2_PRODUTO from mvestoque2');
SQL.Add('where me2_docto = :codEntrada');
ParamByName('codEntrada').Value := F_dmTransferencia.QRY_aptosOcupadosENT_CODENTRADA.AsInteger;
Open();
end;
if F_dmTransferencia.QRY_aptosConsumo.RecordCount < 1 then begin
F_dmTransferencia.QRY_aptosConsumo.Close;
end;
end;
end.
|
unit InfoPane;
interface
uses
Windows, Messages, AvL, avlEventBus, Utils, Aria2, UpdateThread;
type
TInfoPane = class;
TInfoPage = class(TSimplePanel)
protected
FGID: TAria2GID;
FParent: TInfoPane;
FUpdateKeys: TStringArray;
function GetName: string; virtual; abstract;
function GetUpdateKeys: TStringArray; virtual;
procedure SetGID(Value: TAria2GID); virtual;
public
constructor Create(Parent: TInfoPane); virtual;
destructor Destroy; override;
procedure Update(UpdateThread: TUpdateThread); virtual; abstract;
property Name: string read GetName;
property GID: TAria2GID read FGID write SetGID;
property UpdateKeys: TStringArray read GetUpdateKeys;
end;
TInfoPane = class(TTabControl)
Pages: array of TInfoPage;
private
FCurPage: TInfoPage;
procedure Resize(Sender: TObject);
function GetUpdateKeys: TStringArray;
function GetGID: TAria2GID;
procedure SetGID(const Value: TAria2GID);
procedure LoadSettings(Sender: TObject; const Args: array of const);
procedure SaveSettings(Sender: TObject; const Args: array of const);
procedure SetPage(Sender: TObject);
public
constructor Create(AParent: TWinControl);
destructor Destroy; override;
procedure Update(UpdateThread: TUpdateThread);
property GID: TAria2GID read GetGID write SetGID;
property UpdateKeys: TStringArray read GetUpdateKeys;
end;
implementation
uses
MainForm, PageInfo, PageFiles, PageSpeed;
type
TInfoPageClass = class of TInfoPage;
const
SInfoPage = 'InfoPage';
InfoPages: array[0..2] of TInfoPageClass = (TPageInfo, TPageFiles, TPageSpeed);
{ TInfoPane }
constructor TInfoPane.Create(AParent: TWinControl);
var
Page: Integer;
begin
inherited Create(AParent);
Style := tsTabs;
SetLength(Pages, Length(InfoPages));
for Page := Low(InfoPages) to High(InfoPages) do
begin
Pages[Page] := InfoPages[Page].Create(Self);
Pages[Page].BringToFront;
Pages[Page].Visible := false;
TabAdd(Pages[Page].Name);
end;
FCurPage := Pages[0];
FCurPage.Visible := true;
TabIndex := 0;
OnResize := Resize;
OnChange := SetPage;
EventBus.AddListener(EvLoadSettings, LoadSettings);
EventBus.AddListener(EvSaveSettings, SaveSettings);
end;
destructor TInfoPane.Destroy;
begin
EventBus.RemoveListeners([LoadSettings, SaveSettings]);
inherited;
end;
function TInfoPane.GetGID: TAria2GID;
begin
Result := FCurPage.GID;
end;
function TInfoPane.GetUpdateKeys: TStringArray;
begin
Result := FCurPage.UpdateKeys;
end;
procedure TInfoPane.LoadSettings(Sender: TObject; const Args: array of const);
begin
TabIndex := Settings.ReadInteger(Sender.ClassName, SInfoPage, 0);
SetPage(Self);
end;
procedure TInfoPane.Resize(Sender: TObject);
var
Page: Integer;
begin
for Page := 0 to High(Pages) do
with ClientRect do
Pages[Page].SetBounds(Left, Top, Right - Left, Bottom - Top);
end;
procedure TInfoPane.SaveSettings(Sender: TObject; const Args: array of const);
begin
Settings.WriteInteger(Sender.ClassName, SInfoPage, TabIndex);
end;
procedure TInfoPane.SetGID(const Value: TAria2GID);
begin
FCurPage.GID := Value;
end;
procedure TInfoPane.SetPage(Sender: TObject);
var
GID: TAria2GID;
begin
if (TabIndex < 0) or (TabIndex > High(Pages)) then Exit;
GID := FCurPage.GID;
FCurPage.Visible := false;
FCurPage := Pages[TabIndex];
FCurPage.GID := GID;
FCurPage.Visible := true;
end;
procedure TInfoPane.Update(UpdateThread: TUpdateThread);
begin
if Assigned(UpdateThread.Stats) and not Assigned(UpdateThread.Info) then
GID := '';
FCurPage.Update(UpdateThread);
end;
{ TInfoPage }
constructor TInfoPage.Create(Parent: TInfoPane);
begin
inherited Create(Parent, '');
FParent := Parent;
Border := 2;
end;
destructor TInfoPage.Destroy;
begin
Finalize(FUpdateKeys);
inherited;
end;
function TInfoPage.GetUpdateKeys: TStringArray;
begin
Result := FUpdateKeys;
end;
procedure TInfoPage.SetGID(Value: TAria2GID);
begin
FGID := Value;
end;
end.
|
unit ServerMethodsUnit1;
interface
uses
SysUtils, Classes, DSServer;
type
TServerMethods1 = class(TDSServerModule)
private
{ Private declarations }
public
{ Public declarations }
function EchoString(Value: string): string;
end;
implementation
{$R *.dfm}
function TServerMethods1.EchoString(Value: string): string;
begin
Result := Value;
end;
end.
|
PROGRAM ExprPrg;
TYPE
symbolCode = (
noSy,
eofSy,
plusSy, minusSy, timesSy, divSy,
leftParSy, rightParSy, numberSy
);
CONST
eofCh = Chr(0);
VAR
line : STRING;
cnr : INTEGER;
ch : CHAR;
sy : symbolCode;
numberVal : INTEGER;
success : BOOLEAN;
numberStr : STRING;
PROCEDURE NewCh;
BEGIN
IF cnr < Length(line) THEN BEGIN
Inc(cnr);
ch := Line[cnr];
END ELSE BEGIN
ch := eofCh;
END;
END;
PROCEDURE NewSy;
VAR
code : INTEGER;
BEGIN
WHILE ch = ' ' DO BEGIN
NewCh;
END;
CASE ch OF
eofCh : BEGIN
sy := eofSy;
END;
'+' : BEGIN
sy := plusSy; NewCh;
END;
'-' : BEGIN
sy := minusSy; NewCh;
END;
'*' : BEGIN
sy := timesSy; NewCh;
END;
'/' : BEGIN
sy := divSy; NewCh;
END;
'(' : BEGIN
sy := leftParSy; NewCh;
END;
')' : BEGIN
sy := rightParSy; NewCh;
END;
'0'..'9' : BEGIN
sy := numberSy;
numberStr := '';
WHILE (ch >= '0') AND (ch<= '9') DO BEGIN
numberStr := Concat(numberStr, ch);
Newch;
END;
END;
ELSE
sy := noSy;
END;
END;
PROCEDURE Expr(VAR e: STRING); FORWARD;
PROCEDURE Term(VAR t: STRING); FORWARD;
PROCEDURE Fact(VAR f: STRING); FORWARD;
PROCEDURE S;
VAR
e : STRING;
BEGIN
cnr := 0;
success := TRUE;
NewCh;
NewSy;
Expr(e);
IF sy <> eofSy THEN BEGIN
success := FALSE;
END;
(* SEM *)
IF success THEN BEGIN
WriteLn('result =', e);
END;
(* ENDSEM *)
END;
PROCEDURE Expr(VAR e: STRING);
VAR
t : STRING;
BEGIN
Term(e);
WHILE(success) AND ((sy = plusSy) OR (sy = minusSy)) DO BEGIN
CASE sy OF
plusSy : BEGIN
(* SEM *) e := '+' + e; (* ENDSEM *)
NewSy;
Term(t);
e := e + t;
END;
minusSy : BEGIN
(* SEM *) e := '-' + e; (* ENDSEM *)
NewSy;
Term(t);
e := e + t;
END;
END;
END;
END;
PROCEDURE Term(VAR t: STRING);
VAR
f : STRING;
BEGIN
Fact(t);
WHILE(success) AND ((sy = timesSy) OR (sy = divSy)) DO BEGIN
CASE sy OF
timesSy : BEGIN
t := '*' + t;
NewSy;
Fact(f);
(* SEM *) t := t + f; (*ENDSEM*)
END;
divSy : BEGIN
t := '/' + t;
NewSy;
Fact(f);
(* SEM *) t := t + f; (*ENDSEM*)
END;
END;
END;
END;
PROCEDURE Fact(VAR f: STRING);
BEGIN
CASE sy OF
numberSy : BEGIN
(* SEM *) f := numberStr; (* ENDSEM *)
NewSy;
END;
leftParSy : BEGIN
NewSy;
Expr(f);
IF (success) AND (sy <> rightParSy) THEN BEGIN
success := FALSE;
END;
IF (success) THEN BEGIN
NewSy;
END;
END;
ELSE
success := FALSE;
END;
END;
BEGIN
REPEAT
Write('enter arithmetic expression: ');
ReadLn(line);
IF Length(line) > 0 THEN BEGIN
S;
IF success THEN BEGIN
WriteLn('valid expression');
END ELSE BEGIN
WriteLn('error in column', cnr);
END;
END;
UNTIL Length(line) = 0;
END. |
unit xe_CUT1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, System.StrUtils,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics, cxControls, cxLookAndFeels,
cxLookAndFeelPainters, dxSkinsCore, dxSkinscxPCPainter,
dxBarBuiltInMenu, cxContainer, cxEdit, Vcl.Menus, Vcl.ComCtrls, dxCore,
cxDateUtils, cxStyles, cxCustomData, cxFilter, cxData, cxDataStorage,
cxNavigator, Data.DB, cxDBData, cxLabel, cxCurrencyEdit, cxCheckBox, System.Math,
cxDropDownEdit, cxImageComboBox, cxTL, cxTLdxBarBuiltInMenu, AdvProgressBar,
Vcl.OleCtrls, SHDocVw, Vcl.StdCtrls, cxCheckComboBox, cxGridBandedTableView,
cxSplitter, cxInplaceContainer, cxMemo, cxGridLevel, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxClasses, cxGridCustomView, cxGrid,
cxTextEdit, cxRadioGroup, cxMaskEdit, cxCalendar, cxButtons, cxGroupBox, Registry,
IniFiles, MSXML2_TLB, Vcl.ExtCtrls, cxPC, DateUtils, ComObj, cxScrollBox, dxDateRanges, dxSkinOffice2010Silver, dxSkinSharp, dxSkinMetropolisDark,
dxSkinOffice2007Silver, cxCustomListBox, cxListBox, Vcl.Samples.Gauges,
dxScrollbarAnnotations;
Type
TCuData = record
CuName : string;
CuMemo : string;
CuArea : string;
CuStart1: string;
CuStart2: string;
CuStart3: string;
CuAreaDetail: string;
CuXval: string;
CuYVal: string;
CuTelList: string;
end;
type
PTreeRec = ^TTreeRec;
TTreeRec = record
HDCode: string;
HDName: string;
BRCode: string;
BRName: string;
FIndex: integer;
end;
type
TFrm_CUT1 = class(TForm)
Pop_Ymd: TPopupMenu;
MenuItem33: TMenuItem;
MenuItem34: TMenuItem;
MenuItem35: TMenuItem;
MenuItem36: TMenuItem;
MenuItem37: TMenuItem;
pm_Date: TPopupMenu;
N_Today: TMenuItem;
N_Yesterday: TMenuItem;
N_Week: TMenuItem;
N_Month: TMenuItem;
N_1Start31End: TMenuItem;
pmCustMgr: TPopupMenu;
mniN9: TMenuItem;
mniN10: TMenuItem;
mniN8: TMenuItem;
cxStyleCustLevel: TcxStyleRepository;
stlCustLevelColor: TcxStyle;
pnl_Excel_OPT: TPanel;
cxGroupBox7: TcxGroupBox;
btnAll1: TcxButton;
btnAll2: TcxButton;
RdExcel1: TcxRadioButton;
RdExcel2: TcxRadioButton;
cxStyleRepository1: TcxStyleRepository;
cxStyle1: TcxStyle;
PopupMenu1: TPopupMenu;
MenuItem1: TMenuItem;
MenuItem6: TMenuItem;
MenuItem7: TMenuItem;
cxStyleRepository2: TcxStyleRepository;
cxStyle2: TcxStyle;
PopupMenu6: TPopupMenu;
MenuItem53: TMenuItem;
MenuItem54: TMenuItem;
MenuItem55: TMenuItem;
pmDetail: TPopupMenu;
mniDetailCustLevel: TMenuItem;
MenuItem71: TMenuItem;
cxPageControl1: TcxPageControl;
cxTabSheet12: TcxTabSheet;
cxTabSheet13: TcxTabSheet;
cxTabSheet14: TcxTabSheet;
cxTabSheet15: TcxTabSheet;
cxTabSheet16: TcxTabSheet;
cxTabSheet17: TcxTabSheet;
pnl_CUTB1: TPanel;
Panel2: TPanel;
Shape142: TShape;
cxGrid13: TcxGrid;
cxGridBebinList: TcxGridDBTableView;
cxGridDBColumnB0: TcxGridDBColumn;
cxGridDBColumnB29: TcxGridDBColumn;
cxGridDBColumnB1: TcxGridDBColumn;
cxGridDBColumnB2: TcxGridDBColumn;
cxGridDBColumnB3: TcxGridDBColumn;
cxGridDBColumnB4: TcxGridDBColumn;
cxGridDBColumnB5: TcxGridDBColumn;
cxGridDBColumnB6: TcxGridDBColumn;
cxGridDBColumnB7: TcxGridDBColumn;
cxGridDBColumnB8: TcxGridDBColumn;
cxGridDBColumnB9: TcxGridDBColumn;
cxGridDBColumnB12: TcxGridDBColumn;
cxGridDBColumnB13: TcxGridDBColumn;
cxGridDBColumnB14: TcxGridDBColumn;
cxGridDBColumnB15: TcxGridDBColumn;
cxGridDBColumnB16: TcxGridDBColumn;
cxGridDBColumnB17: TcxGridDBColumn;
cxGridDBColumnB18: TcxGridDBColumn;
cxGridDBColumnB19: TcxGridDBColumn;
cxGridDBColumnB20: TcxGridDBColumn;
cxGridDBColumnB21: TcxGridDBColumn;
cxGridDBColumnB22: TcxGridDBColumn;
cxGridDBColumnB23: TcxGridDBColumn;
cxGridDBColumnB24: TcxGridDBColumn;
cxGridDBColumnB25: TcxGridDBColumn;
cxGridDBColumnB26: TcxGridDBColumn;
cxGridDBColumnB27: TcxGridDBColumn;
cxGridDBColumnB28: TcxGridDBColumn;
cxGridLevel4: TcxGridLevel;
CustView12_1: TcxTreeList;
cxTreeList1cxTreeListColumn1: TcxTreeListColumn;
CustView8cxTreeListColumn1: TcxTreeListColumn;
cxTreeList1cxTreeListColumn2: TcxTreeListColumn;
cxTreeList1cxTreeListColumn3: TcxTreeListColumn;
cxTreeList1cxTreeListColumn6: TcxTreeListColumn;
cxtrlstclmnTreeList1cxTreeListColumn4: TcxTreeListColumn;
cxtrlstclmnTreeList1cxTreeListColumn5: TcxTreeListColumn;
cxtrlstclmnTreeList1cxTreeListColumn7: TcxTreeListColumn;
cxtrlstclmnCustView8cxTreeListColumn2: TcxTreeListColumn;
cxtrlstclmnCustView8cxTreeListColumn3: TcxTreeListColumn;
cxtrlstclmnCustView8cxTreeListColumn4: TcxTreeListColumn;
cxGroupBox42: TcxGroupBox;
Shape143: TShape;
Shape144: TShape;
Shape145: TShape;
Shape146: TShape;
cxLabel23: TcxLabel;
lbCustCompany12: TcxLabel;
cxLabel42: TcxLabel;
cbKeynumber12: TcxComboBox;
cxLabel199: TcxLabel;
cxLabel47: TcxLabel;
edBubinName01: TcxTextEdit;
btn_12_1: TcxButton;
btn_12_3: TcxButton;
btn_12_2: TcxButton;
btn_12_4: TcxButton;
cxLabel52: TcxLabel;
cb_Contract: TcxComboBox;
cxSplitter1: TcxSplitter;
pop_imtrgrd1: TPopupMenu;
N5: TMenuItem;
MenuItem2: TMenuItem;
N4: TMenuItem;
MenuItem3: TMenuItem;
N8: TMenuItem;
pnl_CUTB2: TPanel;
Panel9: TPanel;
Shape153: TShape;
CustView13_1: TcxTreeList;
cxTreeListColumn1: TcxTreeListColumn;
custview11cxTreeListColumn1: TcxTreeListColumn;
cxTreeListColumn2: TcxTreeListColumn;
cxTreeListColumn3: TcxTreeListColumn;
cxTreeListColumn4: TcxTreeListColumn;
cxTreeListColumn5: TcxTreeListColumn;
cxTreeListColumn7: TcxTreeListColumn;
cxGroupBox45: TcxGroupBox;
Shape154: TShape;
Shape155: TShape;
Shape156: TShape;
cxLabel32: TcxLabel;
cxLabel34: TcxLabel;
cxLabel121: TcxLabel;
cxLabel122: TcxLabel;
btn_13_1: TcxButton;
cbKeynumber13: TcxComboBox;
lbCustCompany13: TcxLabel;
cxTextEdit14: TcxTextEdit;
Panel21: TPanel;
Shape157: TShape;
cxGrid9: TcxGrid;
CustView13_2: TcxGridBandedTableView;
cxGridBandedColumn1: TcxGridBandedColumn;
cxGridBandedColumn2: TcxGridBandedColumn;
cxGridBandedColumn3: TcxGridBandedColumn;
cxGridBandedColumn4: TcxGridBandedColumn;
cxGridBandedColumn5: TcxGridBandedColumn;
cxGridBandedColumn6: TcxGridBandedColumn;
cxGridBandedColumn7: TcxGridBandedColumn;
cxGridBandedColumn8: TcxGridBandedColumn;
cxGridBandedColumn9: TcxGridBandedColumn;
cxGridBandedColumn10: TcxGridBandedColumn;
cxGridBandedColumn11: TcxGridBandedColumn;
cxGridBandedColumn12: TcxGridBandedColumn;
cxGridBandedColumn13: TcxGridBandedColumn;
cxGridBandedColumn14: TcxGridBandedColumn;
cxGridBandedColumn15: TcxGridBandedColumn;
cxGridBandedColumn16: TcxGridBandedColumn;
cxGridBandedColumn17: TcxGridBandedColumn;
cxGridBandedColumn18: TcxGridBandedColumn;
cxGridBandedColumn19: TcxGridBandedColumn;
cxGridBandedColumn20: TcxGridBandedColumn;
cxGridBandedColumn21: TcxGridBandedColumn;
cxGridBandedColumn22: TcxGridBandedColumn;
cxGridBandedColumn23: TcxGridBandedColumn;
cxGridBandedColumn24: TcxGridBandedColumn;
cxGridBandedColumn25: TcxGridBandedColumn;
cxGridBandedColumn26: TcxGridBandedColumn;
cxGridBandedColumn27: TcxGridBandedColumn;
cxGridBandedColumn28: TcxGridBandedColumn;
cxGridBandedColumn29: TcxGridBandedColumn;
cxGridBandedColumn30: TcxGridBandedColumn;
cxGridBandedColumn31: TcxGridBandedColumn;
cxGridBandedColumn32: TcxGridBandedColumn;
cxGridBandedColumn33: TcxGridBandedColumn;
cxGridBandedColumn34: TcxGridBandedColumn;
cxGridBandedColumn35: TcxGridBandedColumn;
cxGridBandedColumn36: TcxGridBandedColumn;
cxGridBandedColumn37: TcxGridBandedColumn;
cxGridBandedColumn38: TcxGridBandedColumn;
cxGridBandedColumn39: TcxGridBandedColumn;
cxGridBandedColumn40: TcxGridBandedColumn;
cxGridBandedColumn41: TcxGridBandedColumn;
cxGridBandedColumn42: TcxGridBandedColumn;
cxGridBandedColumn43: TcxGridBandedColumn;
cxGridBandedColumn44: TcxGridBandedColumn;
cxGridLevel2: TcxGridLevel;
cxGroupBox46: TcxGroupBox;
Shape158: TShape;
cxComboBox2: TcxComboBox;
cxComboBox3: TcxComboBox;
cxTextEdit21: TcxTextEdit;
btn_13_2: TcxButton;
btn_Date13_1: TcxButton;
chkCust13Type01: TcxCheckBox;
chkCust13Type02: TcxCheckBox;
cxDate13_1S: TcxDateEdit;
cxDate13_1E: TcxDateEdit;
cxSplitter3: TcxSplitter;
pnl_CUTB3: TPanel;
Shape159: TShape;
cxGrid7: TcxGrid;
cxGBubinStt: TcxGridBandedTableView;
cxGBubinSttColumn1: TcxGridBandedColumn;
cxGBubinSttColumn2: TcxGridBandedColumn;
cxGBubinSttColumn3: TcxGridBandedColumn;
cxGBubinSttColumn4: TcxGridBandedColumn;
cxGBubinSttColumn5: TcxGridBandedColumn;
cxGBubinSttColumn6: TcxGridBandedColumn;
cxGBubinSttColumn39: TcxGridBandedColumn;
cxGBubinSttColumn7: TcxGridBandedColumn;
cxGBubinSttColumn8: TcxGridBandedColumn;
cxGBubinSttColumn9: TcxGridBandedColumn;
cxGBubinSttColumn10: TcxGridBandedColumn;
cxGBubinSttColumn11: TcxGridBandedColumn;
cxGBubinSttColumn12: TcxGridBandedColumn;
cxGBubinSttColumn13: TcxGridBandedColumn;
cxGBubinSttColumn14: TcxGridBandedColumn;
cxGBubinSttColumn15: TcxGridBandedColumn;
cxGBubinSttColumn16: TcxGridBandedColumn;
cxGBubinSttColumn17: TcxGridBandedColumn;
cxGBubinSttColumn18: TcxGridBandedColumn;
cxGBubinSttColumn19: TcxGridBandedColumn;
cxGBubinSttColumn20: TcxGridBandedColumn;
cxGBubinSttColumn38: TcxGridBandedColumn;
cxGBubinSttColumn21: TcxGridBandedColumn;
cxGBubinSttColumn22: TcxGridBandedColumn;
cxGBubinSttColumn23: TcxGridBandedColumn;
cxGBubinSttColumn24: TcxGridBandedColumn;
cxGBubinSttColumn25: TcxGridBandedColumn;
cxGBubinSttColumn26: TcxGridBandedColumn;
cxGBubinSttColumn29: TcxGridBandedColumn;
cxGBubinSttColumn40: TcxGridBandedColumn;
cxGBubinSttColumn27: TcxGridBandedColumn;
cxGBubinSttColumn28: TcxGridBandedColumn;
cxGBubinSttColumn30: TcxGridBandedColumn;
cxGBubinSttColumn31: TcxGridBandedColumn;
cxGBubinSttColumn32: TcxGridBandedColumn;
cxGBubinSttColumn33: TcxGridBandedColumn;
cxGBubinSttColumn34: TcxGridBandedColumn;
cxGBubinSttColumn35: TcxGridBandedColumn;
cxGBubinSttColumn36: TcxGridBandedColumn;
cxGBubinSttColumn37: TcxGridBandedColumn;
cxGBubinSttColumn41: TcxGridBandedColumn;
cxGBubinSttColumn42: TcxGridBandedColumn;
cxGBubinSttColumn43: TcxGridBandedColumn;
cxGBubinSttColumn44: TcxGridBandedColumn;
cxGBubinSttColumn45: TcxGridBandedColumn;
cxGridLevel3: TcxGridLevel;
cxGroupBox47: TcxGroupBox;
Shape160: TShape;
Shape161: TShape;
Shape162: TShape;
Shape163: TShape;
Shape164: TShape;
Shape165: TShape;
Shape166: TShape;
Shape167: TShape;
Shape168: TShape;
btn_Date14_1: TcxButton;
btn_14_2: TcxButton;
btn_14_6: TcxButton;
btn_14_1: TcxButton;
btn_14_5: TcxButton;
cbBubinSttCondition: TcxComboBox;
cbKeynumber14: TcxComboBox;
btn_14_4: TcxButton;
btn_14_3: TcxButton;
chkCust14Type01: TcxCheckBox;
cxChkTitle: TcxCheckComboBox;
cxdBubinSttSearch: TcxTextEdit;
cxDate14_1E: TcxDateEdit;
cxDate14_1S: TcxDateEdit;
cxLabel124: TcxLabel;
cxLabel125: TcxLabel;
cxLabel126: TcxLabel;
cxLabel127: TcxLabel;
cxLabel142: TcxLabel;
cxLabel146: TcxLabel;
cxLabel147: TcxLabel;
cxLabel159: TcxLabel;
cxLabel160: TcxLabel;
cxLabel161: TcxLabel;
lbCustCompany14: TcxLabel;
Panel23: TPanel;
Shape169: TShape;
rbCust14Type01: TcxRadioButton;
rbCust14Type02: TcxRadioButton;
rbCust14Type03: TcxRadioButton;
Panel24: TPanel;
Shape170: TShape;
chkBubinSttTotal: TcxRadioButton;
chkBubinSttFinish: TcxRadioButton;
chkBubinSttNotFinish: TcxRadioButton;
chkBubinSttNotBubin: TcxRadioButton;
Panel25: TPanel;
Shape171: TShape;
rbCust14Type07: TcxRadioButton;
rbCust14Type08: TcxRadioButton;
rbCust14Type09: TcxRadioButton;
Panel26: TPanel;
Shape172: TShape;
Panel27: TPanel;
Shape173: TShape;
chkBubinSttPayTotal: TcxRadioButton;
chkBubinSttPayAfter: TcxRadioButton;
chkBubinSttPayTick: TcxRadioButton;
chkBubinSttPayCash: TcxRadioButton;
Panel28: TPanel;
Shape174: TShape;
rbCust14Type04: TcxRadioButton;
rbCust14Type05: TcxRadioButton;
rbCust14Type06: TcxRadioButton;
chkBubinStt: TCheckBox;
cxLabel162: TcxLabel;
pnlBubinAccPrt: TPanel;
cxGroupBox48: TcxGroupBox;
Shape175: TShape;
cxLabel163: TcxLabel;
cxLabel164: TcxLabel;
cxLabel165: TcxLabel;
cxLabel166: TcxLabel;
cxcbBubinAccPage: TcxComboBox;
btn_14_7: TcxButton;
btn_14_9: TcxButton;
btn_14_10: TcxButton;
btn_14_8: TcxButton;
lbbubinAccPrintList: TListBox;
Panel29: TPanel;
WebBrowser1: TWebBrowser;
pnl_BubinAccStatus: TPanel;
cxGroupBox49: TcxGroupBox;
Shape176: TShape;
Shape177: TShape;
Gauge1: TAdvProgressBar;
cxLabel167: TcxLabel;
cxLabel174: TcxLabel;
cxLabel175: TcxLabel;
cxLabel176: TcxLabel;
btnClose: TcxButton;
chkBubinSttOrdTotal: TcxRadioButton;
chkBubinSttOrdFinish: TcxRadioButton;
chkBubinSttOrdCancel: TcxRadioButton;
chkBubinSttOrdReq: TcxRadioButton;
pnl_CUTB4: TPanel;
pnl_CUTB4_1: TPanel;
Shape178: TShape;
cxGroupBox50: TcxGroupBox;
Shape179: TShape;
Shape180: TShape;
Shape181: TShape;
Shape182: TShape;
Shape183: TShape;
rbBubinAuth01: TcxRadioButton;
rbBubinAuth02: TcxRadioButton;
cxLabel218: TcxLabel;
lbCustCompany15: TcxLabel;
cxLabel219: TcxLabel;
cbKeynumber15: TcxComboBox;
cxLabel220: TcxLabel;
cxLabel221: TcxLabel;
cxDate22: TcxDateEdit;
cxLabel222: TcxLabel;
cxLabel223: TcxLabel;
cxDate23: TcxDateEdit;
cxLabel224: TcxLabel;
cbBubinWk: TcxComboBox;
edBubinSearch: TcxTextEdit;
Panel31: TPanel;
Shape184: TShape;
rbBubinAuthchkDate01: TcxRadioButton;
rbBubinAuthchkDate02: TcxRadioButton;
cbBubinArea: TcxComboBox;
edBubinArea: TcxTextEdit;
btn_15_1: TcxButton;
btn_15_2: TcxButton;
cxGrid12: TcxGrid;
cxGBubinAuth: TcxGridDBTableView;
cxGBubinAuthColumn1: TcxGridDBColumn;
cxGBubinAuthColumn2: TcxGridDBColumn;
cxGBubinAuthColumn3: TcxGridDBColumn;
cxGBubinAuthColumn4: TcxGridDBColumn;
cxGBubinAuthColumn5: TcxGridDBColumn;
cxGBubinAuthColumn6: TcxGridDBColumn;
cxGBubinAuthColumn7: TcxGridDBColumn;
cxGBubinAuthColumn8: TcxGridDBColumn;
cxGBubinAuthColumn9: TcxGridDBColumn;
cxGBubinAuthColumn10: TcxGridDBColumn;
cxGBubinAuthColumn11: TcxGridDBColumn;
cxGBubinAuthColumn12: TcxGridDBColumn;
cxGBubinAuthColumn13: TcxGridDBColumn;
cxGBubinAuthColumn14: TcxGridDBColumn;
cxGBubinAuthColumn15: TcxGridDBColumn;
cxGBubinAuthColumn16: TcxGridDBColumn;
cxGBubinAuthColumn17: TcxGridDBColumn;
cxGrid12Level1: TcxGridLevel;
pnl_CUTB5: TPanel;
Panel33: TPanel;
Shape185: TShape;
cxGroupBox51: TcxGroupBox;
Shape186: TShape;
Shape187: TShape;
Shape188: TShape;
Shape189: TShape;
cxLabel123: TcxLabel;
lbCustCompany16: TcxLabel;
cxDate16_1S: TcxDateEdit;
cxLabel263: TcxLabel;
cxLabel264: TcxLabel;
cxDate16_1E: TcxDateEdit;
cxLabel265: TcxLabel;
btn_16_1: TcxButton;
btn_16_2: TcxButton;
btn_Date16_1: TcxButton;
cxLabel269: TcxLabel;
cxComboBox5: TcxComboBox;
rbo_WKTOT: TcxRadioButton;
rbo_WKDayByDay: TcxRadioButton;
cxLabel179: TcxLabel;
cxGroupBox52: TcxGroupBox;
Shape190: TShape;
cxLabel262: TcxLabel;
cxComboBox4: TcxComboBox;
cxComboBox6: TcxComboBox;
cxGrid15: TcxGrid;
cxViewWithholdingTax: TcxGridDBTableView;
cxGridDBColumn40: TcxGridDBColumn;
cxGridDBColumn41: TcxGridDBColumn;
cxGridDBColumn42: TcxGridDBColumn;
cxGridDBColumn43: TcxGridDBColumn;
cxGridDBColumn44: TcxGridDBColumn;
cxGridDBColumn60: TcxGridDBColumn;
cxGridDBColumn61: TcxGridDBColumn;
cxGridDBColumn62: TcxGridDBColumn;
cxGridDBColumn63: TcxGridDBColumn;
cxGridDBColumn64: TcxGridDBColumn;
cxGridDBColumn65: TcxGridDBColumn;
cxGridDBColumn66: TcxGridDBColumn;
cxGridDBColumn67: TcxGridDBColumn;
cxGridDBColumn68: TcxGridDBColumn;
cxGridLevel9: TcxGridLevel;
cxBrNo12: TcxTextEdit;
cxHdNo12: TcxTextEdit;
cxBrNo13: TcxTextEdit;
cxHdNo13: TcxTextEdit;
cxBrNo14: TcxTextEdit;
cxHdNo14: TcxTextEdit;
cxBrNo15: TcxTextEdit;
cxHdNo15: TcxTextEdit;
cxBrNo16: TcxTextEdit;
cxHdNo16: TcxTextEdit;
pnl_CUTB6: TPanel;
Shape191: TShape;
cxGrid16: TcxGrid;
cgrid_CalMonth: TcxGridDBTableView;
cgrid_CalMonthColumn1: TcxGridDBColumn;
cgrid_CalMonthColumn2: TcxGridDBColumn;
cgrid_CalMonthColumn3: TcxGridDBColumn;
cgrid_CalMonthColumn4: TcxGridDBColumn;
cgrid_CalMonthColumn5: TcxGridDBColumn;
cgrid_CalMonthColumn6: TcxGridDBColumn;
cgrid_CalMonthColumn7: TcxGridDBColumn;
cgrid_CalMonthColumn8: TcxGridDBColumn;
cgrid_CalMonthColumn9: TcxGridDBColumn;
cgrid_CalMonthColumn10: TcxGridDBColumn;
cgrid_CalMonthColumn11: TcxGridDBColumn;
cgrid_CalMonthColumn12: TcxGridDBColumn;
cgrid_CalMonthColumn13: TcxGridDBColumn;
cgrid_CalMonthColumn24: TcxGridDBColumn;
cgrid_CalMonthColumn19: TcxGridDBColumn;
cgrid_CalMonthColumn20: TcxGridDBColumn;
cgrid_CalMonthColumn21: TcxGridDBColumn;
cgrid_CalMonthColumn14: TcxGridDBColumn;
cgrid_CalMonthColumn17: TcxGridDBColumn;
cgrid_CalMonthColumn15: TcxGridDBColumn;
cgrid_CalMonthColumn18: TcxGridDBColumn;
cgrid_CalMonthColumn16: TcxGridDBColumn;
cgrid_CalMonthColumn22: TcxGridDBColumn;
cgrid_CalMonthColumn23: TcxGridDBColumn;
cgrid_CalMonthColumn26: TcxGridDBColumn;
cgrid_CalMonthColumn27: TcxGridDBColumn;
cgrid_CalMonthColumn28: TcxGridDBColumn;
cgrid_CalMonthColumn29: TcxGridDBColumn;
cxGrid11Level: TcxGridLevel;
cxGroupBox53: TcxGroupBox;
Shape192: TShape;
Shape193: TShape;
Shape194: TShape;
Shape195: TShape;
btBubinSttExcel: TcxButton;
btn_AllProc2: TcxButton;
btBubinSttSearch: TcxButton;
btn_AllProc1: TcxButton;
cxComboBox1: TcxComboBox;
cbKeynumber17: TcxComboBox;
cxCheckBox1: TcxCheckBox;
cxTextEdit22: TcxTextEdit;
cxLabel177: TcxLabel;
cxLabel185: TcxLabel;
cxLabel186: TcxLabel;
lbCustCompany17: TcxLabel;
Panel30: TPanel;
Shape196: TShape;
chkCalAll: TcxRadioButton;
chkCalY: TcxRadioButton;
chkCalN: TcxRadioButton;
Panel32: TPanel;
Shape197: TShape;
chkBillAll: TcxRadioButton;
chkBillY: TcxRadioButton;
chkBillN: TcxRadioButton;
CheckBox1: TCheckBox;
cxLabel187: TcxLabel;
cb_CalMonth: TcxComboBox;
cxLabel188: TcxLabel;
cxLabel189: TcxLabel;
lb_Year: TcxLabel;
cxBrNo17: TcxTextEdit;
cxHdNo17: TcxTextEdit;
pnl_UseList: TPanel;
pnl_UseListTitle: TPanel;
cxButton2: TcxButton;
btBubinSttListExcel: TcxButton;
cxGrid17: TcxGrid;
cgrid_UseList: TcxGridDBTableView;
cgrid_UseListColumn1: TcxGridDBColumn;
cxGridDBColumn69: TcxGridDBColumn;
cxGridDBColumn70: TcxGridDBColumn;
cxGridDBColumn71: TcxGridDBColumn;
cxGridDBColumn72: TcxGridDBColumn;
cxGridDBColumn73: TcxGridDBColumn;
cxGridDBColumn74: TcxGridDBColumn;
cxGridDBColumn75: TcxGridDBColumn;
cxGridDBColumn76: TcxGridDBColumn;
cxGridDBColumn77: TcxGridDBColumn;
cxGridDBColumn78: TcxGridDBColumn;
cxGridDBColumn79: TcxGridDBColumn;
cxGridDBColumn80: TcxGridDBColumn;
cxGridDBColumn81: TcxGridDBColumn;
cxGridDBColumn82: TcxGridDBColumn;
cxGridDBColumn83: TcxGridDBColumn;
cxGridDBColumn84: TcxGridDBColumn;
cxGridDBColumn85: TcxGridDBColumn;
cxGridDBColumn86: TcxGridDBColumn;
cxGridLevel10: TcxGridLevel;
pnl_CalCampInfo: TPanel;
pnl_Title: TPanel;
cxButton3: TcxButton;
cxGroupBox55: TcxGroupBox;
Shape200: TShape;
Shape201: TShape;
Shape202: TShape;
Shape203: TShape;
Shape204: TShape;
Shape205: TShape;
Shape206: TShape;
Shape207: TShape;
Shape208: TShape;
Shape209: TShape;
Shape210: TShape;
cxLabel194: TcxLabel;
lb_CamInfo1: TcxLabel;
cxLabel195: TcxLabel;
lb_CamInfo2: TcxLabel;
cxLabel196: TcxLabel;
lb_CamInfo3: TcxLabel;
cxLabel197: TcxLabel;
lb_CamInfo4: TcxLabel;
cxLabel198: TcxLabel;
cxLabel200: TcxLabel;
lb_CamInfo6: TcxLabel;
edt_RowNum: TcxTextEdit;
cxGroupBox56: TcxGroupBox;
Shape211: TShape;
Shape212: TShape;
Shape213: TShape;
Shape214: TShape;
Shape215: TShape;
Shape216: TShape;
cxLabel201: TcxLabel;
lb_CalInfo1: TcxLabel;
cxLabel202: TcxLabel;
lb_CalInfo2: TcxLabel;
cxLabel203: TcxLabel;
lb_CalInfo3: TcxLabel;
cxGroupBox57: TcxGroupBox;
Shape217: TShape;
Shape218: TShape;
Shape219: TShape;
Shape220: TShape;
cxLabel204: TcxLabel;
cxLabel205: TcxLabel;
Panel35: TPanel;
rb_DepositY: TcxRadioButton;
rb_DepositN: TcxRadioButton;
Panel36: TPanel;
rb_BillY: TcxRadioButton;
rb_BillN: TcxRadioButton;
cxLabel206: TcxLabel;
lbDepositDate: TcxLabel;
cxLabel208: TcxLabel;
lbBillDate: TcxLabel;
btn_InfoSave: TcxButton;
btn_Close: TcxButton;
edtBubinCode: TcxTextEdit;
cxLabel209: TcxLabel;
cxLabel211: TcxLabel;
cxLabel212: TcxLabel;
edt_FinishCnt: TcxTextEdit;
edt_FinishTCharge: TcxTextEdit;
edt_OrderCnt: TcxTextEdit;
cxGroupBox58: TcxGroupBox;
Shape221: TShape;
Shape222: TShape;
Shape223: TShape;
Shape224: TShape;
Shape225: TShape;
btn_CashBill: TcxButton;
btn_Card: TcxButton;
cxLabel213: TcxLabel;
edt_CalMoney: TcxCurrencyEdit;
cxLabel214: TcxLabel;
lb_CalInfo4: TcxLabel;
cxLabel215: TcxLabel;
lb_CalInfo5: TcxLabel;
edt_CamInfo5: TcxTextEdit;
pm_excel8_1: TPopupMenu;
MenuItem4: TMenuItem;
pm_excel8_2: TPopupMenu;
MenuItem5: TMenuItem;
pm_excel8_3: TPopupMenu;
MenuItem8: TMenuItem;
menuCallBell: TMenuItem;
N1: TMenuItem;
chk_AllPrint: TcxCheckBox;
cxGrid1: TcxGrid;
cxGrid_Angel: TcxGridDBTableView;
cxGrid_AngelColumn1: TcxGridDBColumn;
cxGrid_AngelColumn2: TcxGridDBColumn;
cxGrid_AngelColumn3: TcxGridDBColumn;
cxGrid_AngelColumn4: TcxGridDBColumn;
cxGrid_AngelColumn5: TcxGridDBColumn;
cxGrid_AngelColumn6: TcxGridDBColumn;
cxGrid_AngelColumn7: TcxGridDBColumn;
cxGrid_AngelColumn8: TcxGridDBColumn;
cxGrid_AngelColumn9: TcxGridDBColumn;
cxGrid_AngelColumn10: TcxGridDBColumn;
cxGrid_AngelColumn11: TcxGridDBColumn;
cxGrid_AngelColumn12: TcxGridDBColumn;
cxGrid_AngelColumn13: TcxGridDBColumn;
cxGrid_AngelColumn14: TcxGridDBColumn;
cxGrid_AngelColumn15: TcxGridDBColumn;
cxGrid_AngelColumn16: TcxGridDBColumn;
cxGrid_AngelColumn17: TcxGridDBColumn;
cxGrid_AngelColumn18: TcxGridDBColumn;
cxGrid_AngelColumn19: TcxGridDBColumn;
cxGrid_AngelColumn20: TcxGridDBColumn;
cxGrid_AngelColumn21: TcxGridDBColumn;
cxGrid_AngelColumn22: TcxGridDBColumn;
cxGrid_AngelColumn23: TcxGridDBColumn;
cxGrid_AngelColumn24: TcxGridDBColumn;
cxGrid_AngelColumn25: TcxGridDBColumn;
cxGrid_AngelColumn26: TcxGridDBColumn;
cxGrid_AngelColumn27: TcxGridDBColumn;
cxGrid_AngelColumn28: TcxGridDBColumn;
cxGrid_AngelColumn29: TcxGridDBColumn;
cxGrid_AngelColumn30: TcxGridDBColumn;
cxGrid_AngelColumn31: TcxGridDBColumn;
cxGrid_AngelColumn32: TcxGridDBColumn;
cxGrid_AngelColumn35: TcxGridDBColumn;
cxGrid_AngelColumn36: TcxGridDBColumn;
cxGrid_AngelColumn37: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
cxGrid_AngelColumn33: TcxGridDBColumn;
cxGrid_AngelColumn34: TcxGridDBColumn;
cxGrid_AngelColumn38: TcxGridDBColumn;
cxGrid_AngelColumn39: TcxGridDBColumn;
cxGrid_AngelColumn40: TcxGridDBColumn;
cxGrid_AngelColumn41: TcxGridDBColumn;
cxGrid_AngelColumn42: TcxGridDBColumn;
cxGrid_AngelColumn43: TcxGridDBColumn;
cxGrid_AngelColumn44: TcxGridDBColumn;
cxGrid_AngelColumn45: TcxGridDBColumn;
cxGrid_AngelColumn46: TcxGridDBColumn;
cxGrid_AngelColumn47: TcxGridDBColumn;
btn_14_11: TcxButton;
cxGBubinSttColumn46: TcxGridBandedColumn;
cxGBubinSttColumn47: TcxGridBandedColumn;
cxGBubinSttColumn48: TcxGridBandedColumn;
cxGBubinSttColumn49: TcxGridBandedColumn;
cxGBubinSttColumn50: TcxGridBandedColumn;
cxGBubinSttColumn51: TcxGridBandedColumn;
cxGBubinSttColumn52: TcxGridBandedColumn;
cxGBubinSttColumn53: TcxGridBandedColumn;
cxGBubinSttColumn54: TcxGridBandedColumn;
cxGBubinSttColumn55: TcxGridBandedColumn;
cxGBubinSttColumn56: TcxGridBandedColumn;
cxGBubinSttColumn57: TcxGridBandedColumn;
cxGBubinSttColumn58: TcxGridBandedColumn;
cxGBubinSttColumn59: TcxGridBandedColumn;
cxGBubinSttColumn60: TcxGridBandedColumn;
cxGBubinSttColumn61: TcxGridBandedColumn;
cxTabSheet18: TcxTabSheet;
pnl_CUTB7: TPanel;
pnl_CUTB7Left: TPanel;
Shape20: TShape;
CustView18_1: TcxTreeList;
cxTreeListColumn8: TcxTreeListColumn;
cxTreeListColumn9: TcxTreeListColumn;
cxTreeListColumn10: TcxTreeListColumn;
cxGroupBox4: TcxGroupBox;
Shape23: TShape;
cxLabel26: TcxLabel;
edt_18_1: TcxTextEdit;
btn_18_3: TcxButton;
pnl_CUTB7Body: TPanel;
cxGrid3: TcxGrid;
cxGrid_Angel2: TcxGridDBTableView;
cxGridDBColumn1: TcxGridDBColumn;
cxGridDBColumn2: TcxGridDBColumn;
cxGridDBColumn3: TcxGridDBColumn;
cxGridDBColumn4: TcxGridDBColumn;
cxGridDBColumn5: TcxGridDBColumn;
cxGridDBColumn6: TcxGridDBColumn;
cxGridDBColumn7: TcxGridDBColumn;
cxGridDBColumn8: TcxGridDBColumn;
cxGridDBColumn12: TcxGridDBColumn;
cxGridDBColumn13: TcxGridDBColumn;
cxGridDBColumn14: TcxGridDBColumn;
cxGridDBColumn15: TcxGridDBColumn;
cxGridDBColumn16: TcxGridDBColumn;
cxGridDBColumn17: TcxGridDBColumn;
cxGridDBColumn18: TcxGridDBColumn;
cxGridDBColumn19: TcxGridDBColumn;
cxGridDBColumn20: TcxGridDBColumn;
cxGridDBColumn21: TcxGridDBColumn;
cxGridDBColumn22: TcxGridDBColumn;
cxGridDBColumn23: TcxGridDBColumn;
cxGridDBColumn26: TcxGridDBColumn;
cxGridDBColumn27: TcxGridDBColumn;
cxGridDBColumn28: TcxGridDBColumn;
cxGridDBColumn45: TcxGridDBColumn;
cxGridDBColumn46: TcxGridDBColumn;
cxGridDBColumn47: TcxGridDBColumn;
cxGridDBColumn48: TcxGridDBColumn;
cxGridDBColumn49: TcxGridDBColumn;
cxGridDBColumn50: TcxGridDBColumn;
cxGridDBColumn51: TcxGridDBColumn;
cxGridDBColumn52: TcxGridDBColumn;
cxGridDBColumn53: TcxGridDBColumn;
cxGridDBColumn54: TcxGridDBColumn;
cxGridDBColumn55: TcxGridDBColumn;
cxGridDBColumn56: TcxGridDBColumn;
cxGridDBColumn57: TcxGridDBColumn;
cxGridDBColumn58: TcxGridDBColumn;
cxGridDBColumn59: TcxGridDBColumn;
cxGridDBColumn87: TcxGridDBColumn;
cxGridDBColumn88: TcxGridDBColumn;
cxGridDBColumn89: TcxGridDBColumn;
cxGridDBColumn90: TcxGridDBColumn;
cxGridDBColumn91: TcxGridDBColumn;
cxGridDBColumn92: TcxGridDBColumn;
cxGridDBColumn93: TcxGridDBColumn;
cxGridDBColumn94: TcxGridDBColumn;
cxGridDBColumn95: TcxGridDBColumn;
cxGridLevel6: TcxGridLevel;
cxGroupBox1: TcxGroupBox;
Shape1: TShape;
btn_18_1: TcxButton;
btn_Date18_1: TcxButton;
cxDate18_1S: TcxDateEdit;
cxDate18_1E: TcxDateEdit;
cxLabel1: TcxLabel;
btn_18_2: TcxButton;
cxSplitter4: TcxSplitter;
cxTreeListColumn11: TcxTreeListColumn;
cxTreeListColumn12: TcxTreeListColumn;
lst_BRList: TcxListBox;
cxGridDBColumn96: TcxGridDBColumn;
cxGridDBColumn97: TcxGridDBColumn;
cxProgressBar1: TGauge;
cxStyle3: TcxStyle;
cxStyle4: TcxStyle;
pnl_Right: TPanel;
cxSplitter2: TcxSplitter;
Panel3: TPanel;
Shape147: TShape;
cxLabel207: TcxLabel;
btn_12_13: TcxButton;
btn_12_14: TcxButton;
cxGrid11: TcxGrid;
CustView12_3: TcxGridDBTableView;
cxGridDBColumn9: TcxGridDBColumn;
cxGridDBColumn10: TcxGridDBColumn;
CustView10Column3: TcxGridDBColumn;
CustView10Column4: TcxGridDBColumn;
CustView10Column10: TcxGridDBColumn;
CustView10Column12: TcxGridDBColumn;
CustView10Column11: TcxGridDBColumn;
CustView10Column5: TcxGridDBColumn;
CustView10Column6: TcxGridDBColumn;
CustView10Column7: TcxGridDBColumn;
CustView10Column8: TcxGridDBColumn;
CustView10Column9: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
cxGroupBox43: TcxGroupBox;
Shape148: TShape;
Shape149: TShape;
Shape150: TShape;
cxLabel63: TcxLabel;
cbGubun12_1: TcxComboBox;
cxLabel103: TcxLabel;
cxLabel108: TcxLabel;
edCustName05: TcxTextEdit;
edCustTel04: TcxTextEdit;
btn_12_11: TcxButton;
btn_12_12: TcxButton;
cxLabel216: TcxLabel;
Panel7: TPanel;
Shape151: TShape;
cxGridCustom: TcxGrid;
cxViewCustom: TcxGridDBTableView;
cxCol1: TcxGridDBColumn;
cxCol2: TcxGridDBColumn;
cxCol3: TcxGridDBColumn;
cxCol4: TcxGridDBColumn;
cxCol5: TcxGridDBColumn;
cxCol6: TcxGridDBColumn;
cxCol7: TcxGridDBColumn;
cxCol8: TcxGridDBColumn;
cxCol9: TcxGridDBColumn;
cxCol10: TcxGridDBColumn;
cxCol11: TcxGridDBColumn;
cxCol12: TcxGridDBColumn;
cxCol13: TcxGridDBColumn;
cxCol14: TcxGridDBColumn;
cxLevelCustom: TcxGridLevel;
cxGrid10: TcxGrid;
CustView12_2: TcxGridDBTableView;
cxGridDBColumn11: TcxGridDBColumn;
cxGridDBColumn24: TcxGridDBColumn;
cxGridDBColumn25: TcxGridDBColumn;
cxGridDBColumn29: TcxGridDBColumn;
cxGridDBColumn30: TcxGridDBColumn;
cxGridDBColumn31: TcxGridDBColumn;
cxGridDBColumn32: TcxGridDBColumn;
cxGridDBColumn33: TcxGridDBColumn;
cxGridDBColumn34: TcxGridDBColumn;
cxGridDBColumn35: TcxGridDBColumn;
cxGridDBColumn36: TcxGridDBColumn;
cxGridDBColumn37: TcxGridDBColumn;
cxGridDBColumn38: TcxGridDBColumn;
cxGridDBColumn39: TcxGridDBColumn;
cxGridLevel8: TcxGridLevel;
cxGroupBox44: TcxGroupBox;
Shape152: TShape;
edBubinName02: TcxTextEdit;
btn_12_6: TcxButton;
btn_12_5: TcxButton;
btn_12_7: TcxButton;
btn_12_8: TcxButton;
btn_12_9: TcxButton;
btn_12_10: TcxButton;
cbbResultSearch: TcxComboBox;
edtResultSearch: TcxTextEdit;
lbl2: TcxLabel;
cxTextEdit15: TcxTextEdit;
pnl_Top: TcxGroupBox;
cxLabel7: TcxLabel;
edName03: TcxTextEdit;
edName01: TcxTextEdit;
cxLabel6: TcxLabel;
cxLabel2: TcxLabel;
dtRegDate: TcxDateEdit;
cxLabel3: TcxLabel;
cxLabel8: TcxLabel;
cxButton1: TcxButton;
cxLabel19: TcxLabel;
edWebID: TcxTextEdit;
edWebPW: TcxTextEdit;
cxLabel20: TcxLabel;
btn_WebId: TcxButton;
btn_WebPw: TcxButton;
edCbCode: TEdit;
cxLimitCardVat: TcxComboBox;
cxButton5: TcxButton;
pnl_MakeId: TcxGroupBox;
cxLabel44: TcxLabel;
edt_WebIdFirst: TcxTextEdit;
cxLabel45: TcxLabel;
edt_WebPW1: TcxTextEdit;
cxLabel46: TcxLabel;
edt_WebPW2: TcxTextEdit;
btn_IdCheck: TcxButton;
btn_Confirm: TcxButton;
btn_IDCheckClose: TcxButton;
cxLabel4: TcxLabel;
cxLabel5: TcxLabel;
cxLabel9: TcxLabel;
cxLabel10: TcxLabel;
lb_Date01: TcxLabel;
lb_Date02: TcxLabel;
lb_UseCnt01: TcxLabel;
cxLabel29: TcxLabel;
cxLabel11: TcxLabel;
edtCustStateMemo: TcxTextEdit;
edtCustMemo: TcxTextEdit;
cxLabel12: TcxLabel;
cxLabel16: TcxLabel;
cxLabel27: TcxLabel;
dtFinDate: TcxDateEdit;
pnl_Bill: TPanel;
Shape2: TShape;
rbList01: TcxRadioButton;
rbList02: TcxRadioButton;
rbPayMethodPost: TcxRadioButton;
cxLabel15: TcxLabel;
pnl_Vat: TPanel;
rb_SurtaxY: TcxRadioButton;
rb_SurtaxN: TcxRadioButton;
cxLabel22: TcxLabel;
cb_Contract2: TcxComboBox;
Shape4: TShape;
btn_14_5_C: TcxButton;
Shape3: TShape;
chk_Masking: TcxCheckBox;
cxGrid2: TcxGrid;
cxGrid_Angel2_Masking: TcxGridDBTableView;
cxGridDBColumn98: TcxGridDBColumn;
cxGridDBColumn99: TcxGridDBColumn;
cxGridDBColumn100: TcxGridDBColumn;
cxGridDBColumn101: TcxGridDBColumn;
cxGridDBColumn102: TcxGridDBColumn;
cxGridDBColumn103: TcxGridDBColumn;
cxGridDBColumn104: TcxGridDBColumn;
cxGridDBColumn105: TcxGridDBColumn;
cxGridDBColumn106: TcxGridDBColumn;
cxGridDBColumn107: TcxGridDBColumn;
cxGridDBColumn108: TcxGridDBColumn;
cxGridDBColumn109: TcxGridDBColumn;
cxGridDBColumn110: TcxGridDBColumn;
cxGridDBColumn111: TcxGridDBColumn;
cxGridDBColumn112: TcxGridDBColumn;
cxGridDBColumn113: TcxGridDBColumn;
cxGridDBColumn114: TcxGridDBColumn;
cxGridDBColumn115: TcxGridDBColumn;
cxGridDBColumn116: TcxGridDBColumn;
cxGridDBColumn117: TcxGridDBColumn;
cxGridDBColumn118: TcxGridDBColumn;
cxGridDBColumn119: TcxGridDBColumn;
cxGridDBColumn120: TcxGridDBColumn;
cxGridDBColumn121: TcxGridDBColumn;
cxGridDBColumn122: TcxGridDBColumn;
cxGridDBColumn123: TcxGridDBColumn;
cxGridDBColumn124: TcxGridDBColumn;
cxGridDBColumn125: TcxGridDBColumn;
cxGridDBColumn126: TcxGridDBColumn;
cxGridDBColumn127: TcxGridDBColumn;
cxGridDBColumn128: TcxGridDBColumn;
cxGridDBColumn129: TcxGridDBColumn;
cxGridDBColumn130: TcxGridDBColumn;
cxGridDBColumn131: TcxGridDBColumn;
cxGridDBColumn132: TcxGridDBColumn;
cxGridDBColumn133: TcxGridDBColumn;
cxGridDBColumn134: TcxGridDBColumn;
cxGridDBColumn135: TcxGridDBColumn;
cxGridDBColumn136: TcxGridDBColumn;
cxGridDBColumn137: TcxGridDBColumn;
cxGridDBColumn138: TcxGridDBColumn;
cxGridDBColumn139: TcxGridDBColumn;
cxGridDBColumn140: TcxGridDBColumn;
cxGridDBColumn141: TcxGridDBColumn;
cxGridDBColumn142: TcxGridDBColumn;
cxGridDBColumn143: TcxGridDBColumn;
cxGridDBColumn144: TcxGridDBColumn;
cxGridDBColumn145: TcxGridDBColumn;
cxGridDBColumn146: TcxGridDBColumn;
cxGridLevel5: TcxGridLevel;
pm_excel8_7: TPopupMenu;
MenuItem9: TMenuItem;
cbWhere18: TcxComboBox;
edtKeyWord18: TcxTextEdit;
CustView12_2Column1: TcxGridDBColumn;
CustView12_3Column1: TcxGridDBColumn;
CustView13_2Column1: TcxGridBandedColumn;
cxViewCustomColumn1: TcxGridDBColumn;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure MenuItem33Click(Sender: TObject);
procedure MenuItem34Click(Sender: TObject);
procedure MenuItem35Click(Sender: TObject);
procedure MenuItem36Click(Sender: TObject);
procedure MenuItem37Click(Sender: TObject);
procedure RbButton1MouseDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure btnAll2Click(Sender: TObject);
procedure btn_Date2_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure btn_Date3_1Click(Sender: TObject);
procedure N_YesterdayClick(Sender: TObject);
procedure N_WeekClick(Sender: TObject);
procedure N_MonthClick(Sender: TObject);
procedure N_1Start31EndClick(Sender: TObject);
procedure N_TodayClick(Sender: TObject);
procedure btn_Date3_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure btn_Date3_2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure btn_Date9_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure btn_Date10_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure btn_Date11_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure cb_ContractClick(Sender: TObject);
procedure btn_12_2Click(Sender: TObject);
procedure btn_12_3Click(Sender: TObject);
procedure btn_12_4Click(Sender: TObject);
procedure CustView12_1SelectionChanged(Sender: TObject);
procedure btn_12_5Click(Sender: TObject);
procedure btn_12_6Click(Sender: TObject);
procedure btn_12_7Click(Sender: TObject);
procedure btn_12_8Click(Sender: TObject);
procedure btn_12_9Click(Sender: TObject);
procedure btn_12_10Click(Sender: TObject);
procedure cbbResultSearchPropertiesChange(Sender: TObject);
procedure CustView12_2CellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
procedure CustView12_2ColumnHeaderClick(Sender: TcxGridTableView;
AColumn: TcxGridColumn);
procedure CustView12_2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure CustView12_2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure edCustName05KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure btn_12_11Click(Sender: TObject);
procedure btn_12_12Click(Sender: TObject);
procedure CustView12_3CellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
procedure CustView12_3KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure CustView12_3MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure btn_13_1Click(Sender: TObject);
procedure btn_13_2Click(Sender: TObject);
procedure chkCust13Type01Click(Sender: TObject);
procedure btn_Date14_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure cxChkTitlePropertiesChange(Sender: TObject);
procedure cxdBubinSttSearchKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure btn_14_1Click(Sender: TObject);
procedure btn_14_2Click(Sender: TObject);
procedure btn_14_3Click(Sender: TObject);
procedure btn_14_4Click(Sender: TObject);
procedure btn_14_5Click(Sender: TObject);
procedure btn_14_6Click(Sender: TObject);
procedure cxGBubinSttCellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
procedure btn_14_7Click(Sender: TObject);
procedure btn_14_8Click(Sender: TObject);
procedure btn_14_9Click(Sender: TObject);
procedure btn_14_10Click(Sender: TObject);
procedure cxGroupBox48MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure cxGroupBox49MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure btnCloseClick(Sender: TObject);
procedure btn_15_1Click(Sender: TObject);
procedure rbBubinAuthchkDate01Click(Sender: TObject);
procedure btn_15_2Click(Sender: TObject);
procedure btn_Date16_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure btn_16_1Click(Sender: TObject);
procedure btn_16_2Click(Sender: TObject);
procedure chkCalAllClick(Sender: TObject);
procedure chkBillAllClick(Sender: TObject);
procedure btBubinSttSearchClick(Sender: TObject);
procedure btn_AllProc2Click(Sender: TObject);
procedure btBubinSttExcelClick(Sender: TObject);
procedure btn_AllProc1Click(Sender: TObject);
procedure rb_DepositYClick(Sender: TObject);
procedure rb_BillYClick(Sender: TObject);
procedure btn_InfoSaveClick(Sender: TObject);
procedure btn_CloseClick(Sender: TObject);
procedure cxButton2Click(Sender: TObject);
procedure btn_CardClick(Sender: TObject);
procedure btn_CashBillClick(Sender: TObject);
procedure cbKeynumber01Click(Sender: TObject);
procedure btn_12_13Click(Sender: TObject);
procedure btn_12_14Click(Sender: TObject);
procedure cxPageControl1Change(Sender: TObject);
procedure cxGridBebinListCellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
procedure cxColGLColorStylesGetContentStyle(Sender: TcxCustomGridTableView;
ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem;
var AStyle: TcxStyle);
procedure cxColCGColorStylesGetContentStyle(Sender: TcxCustomGridTableView;
ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem;
var AStyle: TcxStyle);
procedure Label7Click(Sender: TObject);
procedure cgrid_CalMonthCellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
procedure cxButton3Click(Sender: TObject);
procedure btn_Date1_2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure btn_Date1_3MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure btn_Date1_4MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure btn_Date1_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure btn_Date4_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure btn_Date13_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure MenuItem4Click(Sender: TObject);
procedure MenuItem5Click(Sender: TObject);
procedure cxGBubinSttBands1HeaderClick(Sender: TObject);
procedure chkCust14Type01Click(Sender: TObject);
procedure cxGBubinSttBands0HeaderClick(Sender: TObject);
procedure cxGBubinSttBands2HeaderClick(Sender: TObject);
procedure cxGBubinSttBands3HeaderClick(Sender: TObject);
procedure cxGBubinSttBands4HeaderClick(Sender: TObject);
procedure cxGBubinSttBands6HeaderClick(Sender: TObject);
procedure cxGBubinSttBands32HeaderClick(Sender: TObject);
procedure cxGBubinSttBands33HeaderClick(Sender: TObject);
procedure cxGBubinSttBands7HeaderClick(Sender: TObject);
procedure cxGBubinSttBands8HeaderClick(Sender: TObject);
procedure cxGBubinSttBands9HeaderClick(Sender: TObject);
procedure cxGBubinSttBands10HeaderClick(Sender: TObject);
procedure cxGBubinSttBands11HeaderClick(Sender: TObject);
procedure cxGBubinSttBands12HeaderClick(Sender: TObject);
procedure cxGBubinSttBands13HeaderClick(Sender: TObject);
procedure cxGBubinSttBands14HeaderClick(Sender: TObject);
procedure cxGBubinSttBands15HeaderClick(Sender: TObject);
procedure cxGBubinSttBands16HeaderClick(Sender: TObject);
procedure cxGBubinSttBands17HeaderClick(Sender: TObject);
procedure cxGBubinSttBands18HeaderClick(Sender: TObject);
procedure cxGBubinSttBands19HeaderClick(Sender: TObject);
procedure cxGBubinSttBands47HeaderClick(Sender: TObject);
procedure cxGBubinSttBands48HeaderClick(Sender: TObject);
procedure cxGBubinSttBands21HeaderClick(Sender: TObject);
procedure cxGBubinSttBands22HeaderClick(Sender: TObject);
procedure cxGBubinSttBands23HeaderClick(Sender: TObject);
procedure cxGBubinSttBands24HeaderClick(Sender: TObject);
procedure cxGBubinSttBands25HeaderClick(Sender: TObject);
procedure cxGBubinSttBands34HeaderClick(Sender: TObject);
procedure cxGBubinSttBands35HeaderClick(Sender: TObject);
procedure cxGBubinSttBands36HeaderClick(Sender: TObject);
procedure cxGBubinSttBands39HeaderClick(Sender: TObject);
procedure cxGBubinSttBands40HeaderClick(Sender: TObject);
procedure cxGBubinSttBands37HeaderClick(Sender: TObject);
procedure cxGBubinSttBands38HeaderClick(Sender: TObject);
procedure cxGBubinSttBands41HeaderClick(Sender: TObject);
procedure cxGBubinSttBands42HeaderClick(Sender: TObject);
procedure cxGBubinSttBands43HeaderClick(Sender: TObject);
procedure cxGBubinSttBands44HeaderClick(Sender: TObject);
procedure cxGBubinSttBands28HeaderClick(Sender: TObject);
procedure cxGBubinSttBands45HeaderClick(Sender: TObject);
procedure cxGBubinSttBands46HeaderClick(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure MenuItem2Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure MenuItem3Click(Sender: TObject);
procedure N8Click(Sender: TObject);
procedure MenuItem8Click(Sender: TObject);
procedure cxcbBubinAccPagePropertiesChange(Sender: TObject);
procedure edBubinName01KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure edtResultSearchKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormShow(Sender: TObject);
procedure btn_14_11Click(Sender: TObject);
procedure btn_12_1Click(Sender: TObject);
procedure btn_18_3Click(Sender: TObject);
procedure edt_18_1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure edt_18_1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure edt_18_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure lst_BRListDblClick(Sender: TObject);
procedure lst_BRListExit(Sender: TObject);
procedure lst_BRListKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure edt_18_1Enter(Sender: TObject);
procedure edt_18_1Exit(Sender: TObject);
procedure btn_18_1Click(Sender: TObject);
procedure cxDate18_1SKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cxDate18_1EKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure btn_18_2Click(Sender: TObject);
procedure btn_Date18_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure cxGrid_Angel2DataControllerSortingChanged(Sender: TObject);
procedure cxGrid_Angel2ColumnHeaderClick(Sender: TcxGridTableView;
AColumn: TcxGridColumn);
procedure CustView12_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure CustView12_1Click(Sender: TObject);
procedure CustView12_1FocusedColumnChanged(Sender: TcxCustomTreeList;
APrevFocusedColumn, AFocusedColumn: TcxTreeListColumn);
procedure btn_WebIdClick(Sender: TObject);
procedure btn_WebPwClick(Sender: TObject);
procedure edt_WebPW1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure edt_WebPW2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure edt_WebPW2KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure btn_IdCheckClick(Sender: TObject);
procedure btn_ConfirmClick(Sender: TObject);
procedure btn_IDCheckCloseClick(Sender: TObject);
procedure edt_WebIdFirstKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cxButton5Click(Sender: TObject);
procedure CustView12_1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure MenuItem9Click(Sender: TObject);
procedure pm_excel8_7Popup(Sender: TObject);
procedure cxButton1Click(Sender: TObject);
procedure cxGBubinSttDataControllerSortingChanged(Sender: TObject);
procedure cbWhere18PropertiesChange(Sender: TObject);
procedure edtKeyWord18KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure cxGBubinSttKeyPress(Sender: TObject; var Key: Char);
procedure cxGBubinSttCellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
procedure CustView12_2DataControllerSortingChanged(Sender: TObject);
procedure CustView12_3DataControllerSortingChanged(Sender: TObject);
procedure CustView12_3ColumnHeaderClick(Sender: TcxGridTableView;
AColumn: TcxGridColumn);
private
{ Private declarations }
UsrNameReg: TRegistry;
sFooter, sHeader : string;
gbControlKeyDown: Boolean;
// 엑셀다운 내용(조회시 조회조건 기록)
FExcelDownBubin,
FExcelDownBubinCust,
FExcelDownBubinNormal,
FExcelDownBubinUsed,
FExcelDownBubinDaily,
FExcelDownBubinAuth,
FExcelDownWithHolding: string;
FHdNo, FBrNo : string;
gIndex : Integer;
iFinishCnt, iOrderCnt, iFinishCharge, iFinishTCharge, iRealCharge, iDeposit, iBill, iBCode, iHdNo, iBrNo : integer;
giCustView12_1_SelCell : integer; //법인리스트 선택 cell 20210706 KHS
gsCustViewParam : string;
searchBRlist: TStringList; //좌측 지사명 검색 시 인덱스 저장 2017.09.16 KHS
bRightClick : Boolean; //우클릭의 경우 소속고객리스트 조회 막음 20210705 KHS 1577요청
gbCustView12_1_SetFocus : Boolean; //법인리스트에서 커서이동시 검색결과이후 포커스 이동을 막기위해 사용 20210728 KHS
procedure proc_SND_SMS(sGrid: TcxGridDBTableView; ASubscribe: Boolean = True);
procedure cxGridCopy(ASource, ATarget: TcxGridDBTableView; AKeyIndex: Integer; AKeyValue: string);
procedure RequestData(AData: string);
function GetActiveDateControl(AIndex : integer; var AStDt, AEdDt: TcxDateEdit): Boolean;
procedure CustSetDateControl(AGubun: Integer; AStDt, AEdDt: TcxDateEdit);
procedure proc_delete_gbroup(sCode: string);
procedure proc_BubinCust_Search(iType: Integer);
procedure proc_NotBubinCust_Search;
procedure proc_BubinCust_HIS;
procedure proc_BubinManage2;
procedure proc_bubinHis;
procedure proc_BubinStt_Select(iRow: Integer);
procedure proc_SaveBubinDate(AYyMm, AHdNo, ABrNo, ABubinCode, ADeposit, ABill, AFinishCnt, AFinishCharge, AOrderCnt : string);
procedure proc_cust_bubin_Modify(iType: Integer; advGrid:TcxGridDBTableView);
procedure proc_BubinList;
procedure proc_BrList(AStr : string);
procedure SetTree_ListItem(sHdcd, sBrcd: String; idx: Integer);
function func_BrNameList_Search: boolean;
function Func_CheckBrNo : string;
procedure proc_init;
procedure proc_search_bubin_id;
procedure proc_search_bubin(ACbCode, ABrNo : string);
procedure proc_Set_ExcelMasking;
public
{ Public declarations }
ABubinParam : string; //카드결제시 법인정보
BBINCardPayInfo, BBINCardPaySeq, BBINCardTranNo : string;
procedure proc_BrNameSet;
procedure proc_Branch_Change;
procedure proc_BubinManage;
// 전문 응답 처리
procedure proc_recieve(slList: TStringList);
function func_buninSearch(sBrNo, sKeyNum, sCode: string): string;
function GetDeptCustomerCount(AHdNo, ABrNo, ADeptCode: string): Integer;
procedure proc_bubinSttSearch(vType : Integer = 0; vSlip : String = '');
end;
var
Frm_CUT1: TFrm_CUT1;
implementation
{$R *.dfm}
uses Main, xe_Dm, xe_Func, xe_GNL, xe_gnl2, xe_gnl3, xe_Lib, xe_Msg, xe_Query,
xe_packet, xe_xml, xe_CUT012, xe_CUT011, xe_Flash, xe_SMS, xe_structure,
xe_CUT03, xe_CUT02, xe_CUT07 , xe_CUT09, xe_CUT013, xe_CUT019,
xe_Jon03, xe_JON51, xe_BTN01, xe_BTN, xe_SearchWord, xe_JON34B;
procedure TFrm_CUT1.btBubinSttExcelClick(Sender: TObject);
begin
if cgrid_CalMonth.DataController.RecordCount = 0 then
begin
GMessagebox('자료가 없습니다.', CDMSE);
Exit;
end;
if GT_USERIF.Excel_Use = 'n' then
begin
ShowMessage('[엑셀다운로드허용] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
if TCK_USER_PER.COM_CustExcelDown <> '1' then
begin
ShowMessage('[조회고객엑셀다운] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
if TcxButton(sender).Tag = 0 then
begin
Frm_Main.sgExcel := '법인_월정산.xls';
Frm_Main.sgRpExcel := Format('법인>월정산]%s건/%s', [GetMoneyStr(cgrid_CalMonth.DataController.RecordCount), FExcelDownWithHolding]);
Frm_Main.cxGridExcel := cxGrid16;
end else
if TcxButton(sender).Tag = 1 then
begin
Frm_Main.sgExcel := '법인_월정산 이용 내역 리스트.xls';
Frm_Main.sgRpExcel := Format('법인>월정산 이용 내역 리스트]%s건/%s', [GetMoneyStr(cgrid_UseList.DataController.RecordCount), FExcelDownWithHolding]);
Frm_Main.cxGridExcel := cxGrid17;
end;
Frm_Main.bgExcelOPT := False;
Frm_Main.proc_excel(0);
end;
procedure TFrm_CUT1.btBubinSttSearchClick(Sender: TObject);
var
ls_TxLoad: string;
slRcvList: TStringList;
rv_str, ls_rxxml: string;
xdom: MSDomDocument;
lst_Result: IXMLDomNodeList;
I, ErrCode, iRow : Integer;
ls_MSG_Err: string;
ls_Rcrd: TStringList;
begin
if (GT_SEL_BRNO.GUBUN <> '1') and (cxPageControl1.ActivePageIndex <> 6) then
begin
GMessagebox('법인업체 조회는 지사를 선택하셔야 합니다.', CDMSE);
Exit;
end;
Try
Screen.Cursor := crHourGlass;
slRcvList := TStringList.Create;
ls_TxLoad := GTx_UnitXmlLoad('ACC12010.xml');
case cb_CalMonth.ItemIndex of
0 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '01');
1 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '02');
2 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '03');
3 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '04');
4 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '05');
5 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '06');
6 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '07');
7 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '08');
8 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '09');
9 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '10');
10: ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '11');
11: ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '12');
end;
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strPayment' , chkCalAll.Hint);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strBill', chkBillAll.Hint);
if ( GT_USERIF.Family = 'y' ) And ( GT_USERIF.LV = '60' ) then // 20120629 LYB
begin
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strHdNo' , GT_SEL_BRNO.HDNO);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strBrNo' , GT_SEL_BRNO.BrNo);
end else
begin
if GT_SEL_BRNO.GUBUN = '0' then
begin
ls_TxLoad := StringReplace(ls_TxLoad, 'strHdNo', GT_USERIF.HD, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'strBrNo', GT_USERIF.BR, [rfReplaceAll]);
end else
begin
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strHdNo' , GT_SEL_BRNO.HDNO);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strBrNo' , GT_SEL_BRNO.BrNo);
end;
end;
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strCorpName' , cxTextEdit22.Text);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'UserIDString' , GT_USERIF.ID);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'ClientVerString', VERSIONINFO);
Screen.Cursor := crHourGlass;
cxGroupBox53.Enabled := False;
try
if dm.SendSock(ls_TxLoad, slRcvList, ErrCode, False, 30000) then
begin
rv_str := slRcvList[0];
if rv_str <> '' then
begin
ls_rxxml := rv_str;
xdom := CoMSDomDocument.Create;
try
ls_Msg_Err := GetXmlErrorCode(ls_rxxml);
if not xdom.loadXML(ls_rxxml) then
begin
cxGroupBox53.Enabled := True;
Exit;
end;
cgrid_CalMonth.DataController.SetRecordCount(0);
lst_Result := xdom.documentElement.selectNodes('/cdms/Service/Data');
ls_Rcrd := TStringList.Create;
cgrid_CalMonth.BeginUpdate;
try
for I := 0 to lst_Result.length - 1 do
begin
GetTextSeperationEx2('│', lst_Result.item[I].attributes.getNamedItem('Value').Text, ls_Rcrd);
iRow := cgrid_CalMonth.DataController.AppendRecord;
cgrid_CalMonth.DataController.Values[iRow, 0] := inttostr(iRow + 1);
cgrid_CalMonth.DataController.Values[iRow, 1] := False;
if ls_Rcrd[2] = 'y' then
cgrid_CalMonth.DataController.Values[iRow, 2] := '마감'
else
cgrid_CalMonth.DataController.Values[iRow, 2] := '진행중';
cgrid_CalMonth.DataController.Values[iRow, 3] := ls_Rcrd[10]; //본사코드
cgrid_CalMonth.DataController.Values[iRow, 4] := scb_HdNm[scb_HdNo.IndexOf(ls_Rcrd[10])]; //본사명
cgrid_CalMonth.DataController.Values[iRow, 5] := ls_Rcrd[11]; //지사코드
cgrid_CalMonth.DataController.Values[iRow, 6] := scb_BranchName[scb_BranchCode.IndexOf(ls_Rcrd[11])]; //지사명
cgrid_CalMonth.DataController.Values[iRow, 7] := ls_Rcrd[0]; //법인코드
cgrid_CalMonth.DataController.Values[iRow, 8] := ls_Rcrd[1]; //법인명
cgrid_CalMonth.DataController.Values[iRow, iFinishCnt] := ls_Rcrd[3]; //이용횟수 9
cgrid_CalMonth.DataController.Values[iRow, iFinishCharge] := ls_Rcrd[4]; //이용금액 10
if ls_Rcrd[20] = 'y' then
begin
cgrid_CalMonth.DataController.Values[iRow, iFinishTCharge] := ls_Rcrd[6]; //총합계 12
cgrid_CalMonth.DataController.Values[iRow,11] := ls_Rcrd[5]; //부가세
cgrid_CalMonth.DataController.Values[iRow,13] := '적용'; //부가세적용여부
cgrid_CalMonth.DataController.Values[iRow,iRealCharge] := StrToIntDef(ls_Rcrd[4],0) + StrToIntDef(ls_Rcrd[5],0); //실정산금액 14
end else
begin
cgrid_CalMonth.DataController.Values[iRow, iFinishTCharge] := ls_Rcrd[4]; //총합계 12
cgrid_CalMonth.DataController.Values[iRow,11] := 0; //부가세
cgrid_CalMonth.DataController.Values[iRow,13] := '미적용'; //부가세적용여부
cgrid_CalMonth.DataController.Values[iRow,iRealCharge] := ls_Rcrd[4]; //실정산금액 14
end;
if ls_Rcrd[13] = '0' then
cgrid_CalMonth.DataController.Values[iRow,15] := '현금' //결제구분(0.현금, 1.카드)
else if ls_Rcrd[13] = '1' then
cgrid_CalMonth.DataController.Values[iRow,15] := '카드' //결제구분(0.현금, 1.카드)
else
cgrid_CalMonth.DataController.Values[iRow,15] := ''; //결제구분(0.현금, 1.카드)
cgrid_CalMonth.DataController.Values[iRow, 16] := ls_Rcrd[12]; //결제번호
if ls_Rcrd[8] = 'y' then
cgrid_CalMonth.DataController.Values[iRow,iDeposit] := '입금' //17
else
cgrid_CalMonth.DataController.Values[iRow,iDeposit] := '미입금';
cgrid_CalMonth.DataController.Values[iRow, 18] := ls_Rcrd[22]; //입금처리일자
if ls_Rcrd[7] = 'y' then
cgrid_CalMonth.DataController.Values[iRow,iBill] := '발행' //19
else
cgrid_CalMonth.DataController.Values[iRow,iBill] := '미발행';
cgrid_CalMonth.DataController.Values[iRow, 20] := ls_Rcrd[21]; //계산서발행처리일자
cgrid_CalMonth.DataController.Values[iRow, iOrderCnt] := ls_Rcrd[9]; //누락건수 21
cgrid_CalMonth.DataController.Values[iRow, 22] := ls_Rcrd[19]; //정산기간 22
if ls_Rcrd[18] = '말일' then
cgrid_CalMonth.DataController.Values[iRow, 23] := ls_Rcrd[18]
else if ls_Rcrd[18] = '' then
cgrid_CalMonth.DataController.Values[iRow, 23] := ''
else
cgrid_CalMonth.DataController.Values[iRow, 23] := ls_Rcrd[18] + '일'; //정산일자 23
cgrid_CalMonth.DataController.Values[iRow, 24] := ls_Rcrd[16]; //E-mail 24
cgrid_CalMonth.DataController.Values[iRow, 25] := ls_Rcrd[14]; //담당자 25
cgrid_CalMonth.DataController.Values[iRow, 26] := StrToCall(ls_Rcrd[15]); //담당자연락처 26
cgrid_CalMonth.DataController.Values[iRow, 27] := ls_Rcrd[17]; //사업자번호 27
end;
finally
cgrid_CalMonth.EndUpdate;
ls_Rcrd.Free;
Screen.Cursor := crDefault;
Frm_Flash.Hide;
end;
if cgrid_CalMonth.DataController.RecordCount = 0 then
begin
GMessagebox('검색된 내용이 없습니다.', CDMSE);
end;
finally
Screen.Cursor := crDefault;
xdom := Nil;
end;
end;
end;
finally
slRcvList.Free;
Screen.Cursor := crDefault;
cxGroupBox53.Enabled := True;
end;
except
on e: exception do
begin
Screen.Cursor := crDefault;
cxGroupBox53.Enabled := True;
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.btnAll2Click(Sender: TObject);
begin
pnl_Excel_OPT.Visible := False;
end;
procedure TFrm_CUT1.btnCloseClick(Sender: TObject);
var
i: Integer;
begin
if Gauge1.Max <> Gauge1.Position then
begin
if GMessagebox('아직 작업진행 중입니다.' + #13#10 + '이후 작업을 종료하시겠습니까?', CDMSQ) = IDOK then
begin
cxGBubinStt.BeginUpdate;
for i := 0 to cxGBubinStt.DataController.RecordCount - 1 do
begin
cxGBubinStt.DataController.Values[i, 1] := '0';
end;
cxGBubinStt.EndUpdate;
pnl_BubinAccStatus.Visible := False;
end;
end else
begin
pnl_BubinAccStatus.Visible := False;
end;
end;
procedure TFrm_CUT1.cbbResultSearchPropertiesChange(Sender: TObject);
begin
edtResultSearch.Enabled := (TcxComboBox(Sender).Text <> '전체');
if edtResultSearch.Enabled then
edtResultSearch.SetFocus;
end;
procedure TFrm_CUT1.cbKeynumber01Click(Sender: TObject);
var
sName, sBrName, sHdNo, sBrNo: string;
iIdx: Integer;
begin
if TcxComboBox(Sender).Tag = 1 then Exit;
if GT_USERIF.LV = '60' then
begin
if GT_SEL_BRNO.GUBUN <> '1' then
begin
if TcxComboBox(Sender).Text = '전체' then
begin
sName := '[' + GT_SEL_BRNO.HDNO + '] 전체';
sHdNo := GT_SEL_BRNO.HDNO;
sBrNo := '';
end else
begin
sHdNo := GT_SEL_BRNO.HDNO;
if cxPageControl1.ActivePageIndex in [11, 10] then
begin
sBrNo := GT_SEL_BRNO.BrNo;
end else
begin
if (TcxComboBox(Sender).Properties.Items.Count > 1) and (TcxComboBox(Sender).ItemIndex > 0) then
begin
if ( GT_USERIF.Family = 'y' ) And ( GT_USERIF.LV = '60' ) then // 20120629 LYB
sBrNo := scb_DsBranchCode.Strings[scb_KeyNumber.IndexOf(TcxComboBox(Sender).Text)]
else
sBrNo := scb_DsBranchCode.Strings[TcxComboBox(Sender).ItemIndex - 1]
end else
begin
if ( GT_USERIF.Family = 'y' ) And ( GT_USERIF.LV = '60' ) then // 20120629 LYB
sBrNo := scb_DsBranchCode.Strings[scb_KeyNumber.IndexOf(TcxComboBox(Sender).Text)]
else
sBrNo := scb_DsBranchCode.Strings[TcxComboBox(Sender).ItemIndex];
end;
end;
iIdx := scb_BranchCode.IndexOf(sBrNo);
if iIdx >= 0 then
sBrName := scb_BranchName[iIdx]
else
sBrName := '';
sName := '[' + sHdNo + '] - [' + sBrNo + ']' + sBrName;
end;
end else
begin
sHdNo := GT_SEL_BRNO.HDNO;
sBrNo := GT_SEL_BRNO.BrNo;
iIdx := scb_BranchCode.IndexOf(sBrNo);
if iIdx >= 0 then
sBrName := scb_BranchName[iIdx]
else
sBrName := '';
sName := '[' + sHdNo + '] - [' + sBrNo + ']' + sBrName;
end;
end else
begin
sHdNo := GT_SEL_BRNO.HDNO;
sBrNo := GT_SEL_BRNO.BrNo;
iIdx := scb_BranchCode.IndexOf(sBrNo);
if iIdx >= 0 then
sBrName := scb_BranchName[iIdx]
else
sBrName := '';
sName := '[' + sHdNo + '] - [' + sBrNo + ']' + sBrName;
end;
case cxPageControl1.ActivePageIndex of
0:
begin
lbCustCompany12.Caption := sName;
cxHdNo12.Text := sHdNo;
cxBrNo12.Text := sBrNo;
CustView12_1.Root.TreeList.Clear;
proc_BubinManage;
CustView12_3.DataController.SetRecordCount(0);
cxGridBebinList.DataController.SetRecordCount(0);
end;
1:
begin
lbCustCompany13.Caption := sName;
cxHdNo13.Text := sHdNo;
cxBrNo13.Text := sBrNo;
CustView13_1.Root.TreeList.Clear;
proc_BubinManage2;
end;
2:
begin
lbCustCompany14.Caption := sName;
cxHdNo14.Text := sHdNo;
cxBrNo14.Text := sBrNo;
end;
3:
begin
lbCustCompany15.Caption := sName;
cxHdNo15.Text := sHdNo;
cxBrNo15.Text := sBrNo;
end;
4:
begin
lbCustCompany16.Caption := sName;
cxHdNo16.Text := sHdNo;
cxBrNo16.Text := sBrNo;
end;
end;
end;
procedure TFrm_CUT1.cbWhere18PropertiesChange(Sender: TObject);
begin
if cbWhere18.ItemIndex = 0 then
begin
edtKeyWord18.Clear;
edtKeyWord18.Enabled := False;
end else edtKeyWord18.Enabled := True;
end;
procedure TFrm_CUT1.cb_ContractClick(Sender: TObject);
begin
proc_BubinManage;
end;
procedure TFrm_CUT1.cgrid_CalMonthCellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
var
iCol, iChoiceRow: Integer;
Param, sYearMm : string;
iRow, i, ErrCode: Integer;
xdom: MSDomDocument;
XmlData, ErrMsg: string;
lst_Result, lst_Count: IXMLDomNodeList;
ls_Rcrd: TStringList;
begin
SetDebugeWrite('Frm_CUT1.cgrid_CalMonthCellDblClick');
try
if (AShift = [ssright]) then Exit;
iCol := ACellViewInfo.Item.FocusedCellViewInfo.Item.Index;
iChoiceRow := cgrid_CalMonth.DataController.FocusedRecordIndex;
FHdNo := cgrid_CalMonth.DataController.Values[iChoiceRow, iHDNo];
FBrNo := cgrid_CalMonth.DataController.Values[iChoiceRow, iBrNo];
case cb_CalMonth.ItemIndex of
0 : sYearMm := lb_Year.Caption + '01';
1 : sYearMm := lb_Year.Caption + '02';
2 : sYearMm := lb_Year.Caption + '03';
3 : sYearMm := lb_Year.Caption + '04';
4 : sYearMm := lb_Year.Caption + '05';
5 : sYearMm := lb_Year.Caption + '06';
6 : sYearMm := lb_Year.Caption + '07';
7 : sYearMm := lb_Year.Caption + '08';
8 : sYearMm := lb_Year.Caption + '09';
9 : sYearMm := lb_Year.Caption + '10';
10: sYearMm := lb_Year.Caption + '11';
11: sYearMm := lb_Year.Caption + '12';
end;
ABubinParam:= FHdNo;
ABubinParam:= ABubinParam + '│' + FBrNo;
ABubinParam:= ABubinParam + '│' + sYearMm;
ABubinParam:= ABubinParam + '│' + cgrid_CalMonth.DataController.Values[iChoiceRow, iBCode];
Case iCol of
9 , 21: //이용횟수9, 누락건수21
begin
Param := cgrid_CalMonth.DataController.Values[iChoiceRow, iBCode];
Param := Param + '│' + sYearMm;
Param := Param + '│' + FHdNo;
Param := Param + '│' + FBrNo;
if iCol = 9 then
begin
Param := Param + '│' + 'y';
pnl_UseListTitle.Caption := sYearMm + '[' + cgrid_CalMonth.DataController.Values[iChoiceRow, 8] + ']이용내역 리스트(이용횟수)';
end else
begin
Param := Param + '│' + 'n';
pnl_UseListTitle.Caption := sYearMm + '[' + cgrid_CalMonth.DataController.Values[iChoiceRow, 8] + ']이용내역 리스트(누락횟수)';
end;
if not RequestBase(GetSel06('GET_CUST_BGROUP_STT_SEARCH', 'MNG_BGROUP.GET_CUST_BGROUP_STT_SEARCH', '10000', Param), XmlData, ErrCode, ErrMsg) then
begin
GMessagebox(Format('이용횟수 조회 중 오류발생'#13#10'[%d]%s', [ErrCode, ErrMsg]), CDMSE);
Exit;
end;
xdom := ComsDomDocument.Create;
try
if not xdom.loadXML(XmlData) then
begin
Screen.Cursor := crDefault;
Exit;
end;
lst_Count := xdom.documentElement.selectNodes('/cdms/Service/Data');
if StrToIntDef(lst_Count.item[0].attributes.getNamedItem('Count').Text, 0) > 0 then
begin
pnl_UseList.Left := (Width - pnl_UseList.Width) div 2;
pnl_UseList.top := (Height - pnl_UseList.Height) div 2;
pnl_UseList.Visible := True;
cgrid_UseList.DataController.SetRecordCount(0);
lst_Result := xdom.documentElement.selectNodes('/cdms/Service/Data/Result');
ls_Rcrd := TStringList.Create;
cgrid_UseList.BeginUpdate;
try
for I := 0 to lst_Result.length - 1 do
begin
GetTextSeperationEx2('│', lst_Result.item[I].attributes.getNamedItem('Value').Text, ls_Rcrd);
iRow := cgrid_UseList.DataController.AppendRecord;
cgrid_UseList.DataController.Values[iRow, 0] := inttostr(iRow + 1);
cgrid_UseList.DataController.Values[iRow, 1] := ls_Rcrd[21]; //완료일자
cgrid_UseList.DataController.Values[iRow, 2] := ls_Rcrd[0]; //지사명
cgrid_UseList.DataController.Values[iRow, 3] := ls_Rcrd[1]; // 대표번호
cgrid_UseList.DataController.Values[iRow, 4] := ''; //오더상태
cgrid_UseList.DataController.Values[iRow, 5] := ls_Rcrd[2]; //접수번호
cgrid_UseList.DataController.Values[iRow, 6] := ls_Rcrd[3]; //고객명
cgrid_UseList.DataController.Values[iRow, 7] := StrToCall(ls_Rcrd[4]); //고객번호
cgrid_UseList.DataController.Values[iRow, 8] := ls_Rcrd[ 5] + ' ' + ls_Rcrd[6] + ' ' + ls_Rcrd[7] + ' ' + ls_Rcrd[8] + ' ' + ls_Rcrd[9]; //출발지1-5
cgrid_UseList.DataController.Values[iRow, 9] := ls_Rcrd[10] + ' ' + ls_Rcrd[11]+ ' ' + ls_Rcrd[12] + ' ' + ls_Rcrd[13] + ' ' + ls_Rcrd[14]; //도착지1-5
cgrid_UseList.DataController.Values[iRow, 10] := ls_Rcrd[15] + ' ' + ls_Rcrd[16]+ ' ' + ls_Rcrd[17] + ' ' + ls_Rcrd[18] + ' ' + ls_Rcrd[19]; //경유지1-5
cgrid_UseList.DataController.Values[iRow, 11] := ls_Rcrd[20]; ; //대기시간
cgrid_UseList.DataController.Values[iRow, 12] := '';
cgrid_UseList.DataController.Values[iRow, 13] := ls_Rcrd[22]; //거리
cgrid_UseList.DataController.Values[iRow, 14] := ls_Rcrd[23]; //접수요금
cgrid_UseList.DataController.Values[iRow, 15] := ls_Rcrd[24]; //기사수수료
cgrid_UseList.DataController.Values[iRow, 16] := ls_Rcrd[25]; //실지급액
cgrid_UseList.DataController.Values[iRow, 17] := ls_Rcrd[26]; //보정요금
cgrid_UseList.DataController.Values[iRow, 18] := ls_Rcrd[27]; //기본요금
end;
finally
cgrid_UseList.EndUpdate;
ls_Rcrd.Free;
Screen.Cursor := crDefault;
Frm_Flash.Hide;
xdom := Nil;
end;
end;
except
cgrid_UseList.EndUpdate;
ls_Rcrd.Free;
Screen.Cursor := crDefault;
Frm_Flash.Hide;
end;
end else
begin
////////////////////////////////////////////////////////////선택정보로 창오픈//////////////////////////////////////////
pnl_CalCampInfo.Left := (Width - pnl_CalCampInfo.Width) div 2;
pnl_CalCampInfo.top := (Height - pnl_CalCampInfo.Height) div 2;
pnl_CalCampInfo.Visible := True;
edtBubinCode.Text := cgrid_CalMonth.DataController.Values[iChoiceRow, 7];
pnl_Title.Caption := '[' + cgrid_CalMonth.DataController.Values[iChoiceRow, 8] + '] 월 정산 상세 수정';
lb_CamInfo1.Caption := cgrid_CalMonth.DataController.Values[iChoiceRow, 25]; //계산서담당자
lb_CamInfo2.Caption := StrToCall(cgrid_CalMonth.DataController.Values[iChoiceRow, 26]); //계산서담당자 연락처
lb_CamInfo3.Caption := ''; //메모
lb_CamInfo4.Caption := ''; //주소
edt_CamInfo5.Text := cgrid_CalMonth.DataController.Values[iChoiceRow, 24];
lb_CamInfo6.Caption := cgrid_CalMonth.DataController.Values[iChoiceRow, 27];
lb_CalInfo1.Caption := cgrid_CalMonth.DataController.Values[iChoiceRow, 23];
lb_CalInfo2.Caption := cgrid_CalMonth.DataController.Values[iChoiceRow, 22];
lb_CalInfo3.Caption := '부가세 ' + cgrid_CalMonth.DataController.Values[iChoiceRow, 13];
if cgrid_CalMonth.DataController.Values[iChoiceRow,iDeposit] = '입금' then rb_DepositY.Checked := True
else rb_DepositN.Checked := True;
if cgrid_CalMonth.DataController.Values[iChoiceRow,iBill] = '발행' then rb_BillY.Checked := True
else rb_BillN.Checked := True;
lb_CalInfo4.Caption := cgrid_CalMonth.DataController.Values[iChoiceRow, 15]; //결제구분
lb_CalInfo5.Caption := cgrid_CalMonth.DataController.Values[iChoiceRow, 16]; //결제일련번호
BBINCardPaySeq := cgrid_CalMonth.DataController.Values[iChoiceRow, 16]; //결제일련번호
lbDepositDate.Caption := cgrid_CalMonth.DataController.Values[iChoiceRow, 18];
lbBillDate.Caption := cgrid_CalMonth.DataController.Values[iChoiceRow, 20];
edt_FinishCnt.Text := cgrid_CalMonth.DataController.Values[iChoiceRow, iFinishCnt];
edt_FinishTCharge.Text:= cgrid_CalMonth.DataController.Values[iChoiceRow, iFinishTCharge];
edt_CalMoney.Text := cgrid_CalMonth.DataController.Values[iChoiceRow, iFinishCharge];
edt_OrderCnt.Text := cgrid_CalMonth.DataController.Values[iChoiceRow, iOrderCnt];
edt_RowNum.Text := IntToStr(iChoiceRow);
proc_SaveBubinDate(sYearMm
, FHdNo
, FBrNo
, cgrid_CalMonth.DataController.Values[iChoiceRow, iBCode]
, IfThen(cgrid_CalMonth.DataController.Values[iChoiceRow, iDeposit] = '입금', 'y', 'n')
, IfThen(cgrid_CalMonth.DataController.Values[iChoiceRow, iBill] = '발행', 'y', 'n')
, cgrid_CalMonth.DataController.Values[iChoiceRow, iFinishCnt]
, cgrid_CalMonth.DataController.Values[iChoiceRow, iFinishCharge]
, cgrid_CalMonth.DataController.Values[iChoiceRow, iOrderCnt] );
////////////////////////////////////////////////////////////선택정보로 창오픈//////////////////////////////////////////
end;
end;
finally
end;
end;
procedure TFrm_CUT1.chkBillAllClick(Sender: TObject);
begin
if chkBillAll.Checked then chkBillAll.Hint := '';
if chkBillY.Checked then chkBillAll.Hint := 'y';
if chkBillN.Checked then chkBillAll.Hint := 'n';
end;
procedure TFrm_CUT1.chkCalAllClick(Sender: TObject);
begin
if chkCalAll.Checked then chkCalAll.Hint := '';
if chkCalY.Checked then chkCalAll.Hint := 'y';
if chkCalN.Checked then chkCalAll.Hint := 'n';
end;
procedure TFrm_CUT1.chkCust13Type01Click(Sender: TObject);
begin
if chkCust13Type01.Checked then
begin
cxDate13_1S.Enabled := True;
cxDate13_1E.Enabled := True;
btn_Date13_1.Enabled := True;
end else
begin
cxDate13_1S.Enabled := False;
cxDate13_1E.Enabled := False;
btn_Date13_1.Enabled := False;
end;
end;
procedure TFrm_CUT1.chkCust14Type01Click(Sender: TObject);
var
i: Integer;
ln_env: TIniFile;
begin
try
if cxCheckBox1.Tag = 1 then
exit;
if cxCheckBox1.Checked then
begin
cxChkTitle.Tag := 1;
ln_Env := TIniFile.Create(ENVPATHFILE);
ln_env.EraseSection('ACCBubinList');
cxGBubinStt.BeginUpdate;
for i := 0 to 30 do
begin
cxGBubinStt.Bands[i].Visible := True;
cxChkTitle.SetItemState(i, cbsChecked);
end;
cxChkTitle.Tag := 0;
FreeAndNil(ln_env);
cxGBubinStt.EndUpdate;
end;
except
end;
end;
procedure TFrm_CUT1.CustSetDateControl(AGubun: Integer; AStDt,
AEdDt: TcxDateEdit);
begin
case AGubun of
0: //오늘
begin
AStDt.Date := StrToDate(Date8to10(copy(StartDateTime('yyyymmddhhmmss'), 1, 8)));
AEdDt.Date := AStDt.Date + 1;
end;
1: //어제
begin
AStDt.Date := StrToDate(Date8to10(copy(StartDateTime('yyyymmddhhmmss'), 1, 8))) - 1;
AEdDt.Date := AStDt.Date + 1;
end;
2: //최근일주일
begin
AStDt.Date := StrToDate(Date8to10(copy(StartDateTime('yyyymmddhhmmss'), 1, 8))) - 7;
AEdDt.Date := AStDt.Date + 7;
end;
3: //1~31일
begin
AStDt.Date := StartOfTheMonth(now);
AEdDt.Date := EndOfTheMonth(Now);
end;
11: //최근한달
begin
AStDt.Date := StrToDate(Date8to10(copy(StartDateTime('yyyymmddhhmmss'), 1, 8))) - 31;
AEdDt.Date := AStDt.Date + 31;
end;
12: //3개월
begin
AStDt.Date := StrToDate(Date8to10(copy(StartDateTime('yyyymmddhhmmss'), 1, 8))) - 91;
AEdDt.Date := AStDt.Date + 91;
end;
13: //6개월
begin
AStDt.Date := StrToDate(Date8to10(copy(StartDateTime('yyyymmddhhmmss'), 1, 8))) - 181;
AEdDt.Date := AStDt.Date + 181;
end;
14: //1년
begin
AStDt.Date := StrToDate(Date8to10(copy(StartDateTime('yyyymmddhhmmss'), 1, 8))) - 365;
AEdDt.Date := AStDt.Date + 365;
end;
end;
end;
procedure TFrm_CUT1.CustView12_1Click(Sender: TObject);
var iTmp : integer;
Node: TcxTreeListNode;
begin
if CustView12_1.SelectionCount > 0 then
begin
// iTmp := Node.
if giCustView12_1_SelCell = 2 then //법인명 (원)클릭시 고객리스트 조회
begin
if bRightClick then Exit;
if CustView12_1.SelectionCount > 0 then
begin
proc_search_bubin(CustView12_1.Selections[0].Values[7], cxBrNo12.Text);
btn_12_8.Click;
end
else
CustView12_2.DataController.SetRecordCount(0);
end else
if giCustView12_1_SelCell = 3 then //부서명 (원)클릭시 법인 수정창 팝업
begin
if ( Not Assigned(Frm_CUT09) ) Or ( Frm_CUT09 = Nil ) then Frm_CUT09 := TFrm_CUT09.Create(Nil);
Frm_CUT09.PnlTitle.Caption := '법인(업체) 세부 수정하기';
Frm_CUT09.Tag := 1;
Frm_CUT09.edCbCode.Text := CustView12_1.Selections[0].Values[7];
Frm_CUT09.edBrNo.Text := cxBrNo12.Text;
Frm_CUT09.proc_init;
Frm_CUT09.Show;
end;
{ end else
begin
GMessagebox('부서를 선택하시고 수정 바랍니다.', CDMSE); }
end;
end;
procedure TFrm_CUT1.CustView12_1FocusedColumnChanged(Sender: TcxCustomTreeList;
APrevFocusedColumn, AFocusedColumn: TcxTreeListColumn);
begin
giCustView12_1_SelCell := AFocusedColumn.ItemIndex;
end;
procedure TFrm_CUT1.CustView12_1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var iTmp : integer;
Node: TcxTreeListNode;
begin
if (key = vk_UP) or (key = vk_DOWN) then
begin
gbCustView12_1_SetFocus := True;
if CustView12_1.SelectionCount > 0 then
begin
proc_search_bubin(CustView12_1.Selections[0].Values[7], cxBrNo12.Text);
btn_12_8.Click;
end else CustView12_2.DataController.SetRecordCount(0);
end;
end;
procedure TFrm_CUT1.CustView12_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
bRightClick := False; //우클릭의 경우 소속고객리스트 조회 막음 20210705 KHS 1577요청
if (Shift = [ssright]) then bRightClick := True;
end;
procedure TFrm_CUT1.CustView12_1SelectionChanged(Sender: TObject);
begin
{ if bRightClick then Exit;
if CustView12_1.SelectionCount > 0 then
btn_12_8.Click
else
CustView12_2.DataController.SetRecordCount(0); }
end;
procedure TFrm_CUT1.CustView12_2CellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
begin
btn_12_7Click(btn_12_7);
end;
procedure TFrm_CUT1.CustView12_2ColumnHeaderClick(Sender: TcxGridTableView;
AColumn: TcxGridColumn);
begin
gIndex := AColumn.Index;
end;
procedure TFrm_CUT1.CustView12_2DataControllerSortingChanged(Sender: TObject);
begin
gfSetIndexNo(CustView12_2, gIndex, GS_SortNoChange);
end;
procedure TFrm_CUT1.CustView12_2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_CONTROL then
begin
gbControlKeyDown := True;
CustView12_2.OptionsSelection.CellMultiSelect := False;
CustView12_2.OptionsSelection.CellSelect := False;
CustView12_2.OptionsSelection.MultiSelect := True;
end;
end;
procedure TFrm_CUT1.CustView12_2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (gbControlKeyDown = False) and (Button = mbLeft) then
begin
CustView12_2.OptionsSelection.CellMultiSelect := True;
CustView12_2.OptionsSelection.CellSelect := True;
CustView12_2.OptionsSelection.MultiSelect := True;
end;
end;
procedure TFrm_CUT1.CustView12_3CellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
var
iKeyNum, iSeq, iRow: Integer;
sBrNo, sKeyNum, sSeq: string;
begin
// 권한 적용 (지호 2008-08-19)
if TCK_USER_PER.COM_CustModify <> '1' then
begin
GMessagebox('고객 수정권한이 없습니다.', CDMSE);
Exit;
end;
iRow := CustView12_3.DataController.FocusedRecordIndex;
if iRow = -1 then
Exit;
iKeyNum := CustView12_3.GetColumnByFieldName('대표번호').Index;
iSeq := CustView12_3.GetColumnByFieldName('고객코드').Index;
sBrNo := cxBrNo12.Text;
sKeyNum := CustView12_3.DataController.Values[iRow, iKeyNum];
sKeyNum := StringReplace(sKeyNum, '-', '', [rfReplaceAll]);
sSeq := CustView12_3.DataController.Values[iRow, iSeq];
// 6 : 수정창에서 고객수정 4 : 접수창에서 고객수정
if ( Not Assigned(Frm_CUT011) ) Or ( Frm_CUT011 = Nil ) then Frm_CUT011 := TFrm_CUT011.Create(Nil);
Frm_CUT011.Tag := 6;
Frm_CUT011.Hint := IntToStr(Self.Tag);
Frm_CUT011.clbCuSeq.Caption := sSeq;
Frm_CUT011.proc_search_brKeyNum(sBrNo, sKeyNum);
Frm_CUT011.Show;
Frm_CUT011.proc_cust_Intit;
end;
procedure TFrm_CUT1.CustView12_3ColumnHeaderClick(Sender: TcxGridTableView;
AColumn: TcxGridColumn);
begin
gIndex := AColumn.Index;
end;
procedure TFrm_CUT1.CustView12_3DataControllerSortingChanged(Sender: TObject);
begin
gfSetIndexNo(CustView12_3, gIndex, GS_SortNoChange);
end;
procedure TFrm_CUT1.CustView12_3KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_CONTROL then
begin
gbControlKeyDown := True;
CustView12_3.OptionsSelection.CellMultiSelect := False;
CustView12_3.OptionsSelection.CellSelect := False;
CustView12_3.OptionsSelection.MultiSelect := True;
end;
end;
procedure TFrm_CUT1.CustView12_3MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (gbControlKeyDown = False) and (Button = mbLeft) then
begin
CustView12_3.OptionsSelection.CellMultiSelect := True;
CustView12_3.OptionsSelection.CellSelect := True;
CustView12_3.OptionsSelection.MultiSelect := True;
end;
end;
procedure TFrm_CUT1.btn_AllProc1Click(Sender: TObject);
var
iRow, i, ErrCode: Integer;
sCmpCode, sCmpNM, sFinishCnt, sFinishCharge, sOrderCnt: string;
ls_TxLoad: string;
xdom: MSDomDocument;
ls_MSG_Err: string;
ls_rxxml, rv_str: string;
iGubun : integer;
slRcvList : TStringList;
begin
try
iGubun := TcxButton(sender).Tag;
iRow := 0;
case iGubun of
0:
begin
rb_DepositY.Hint := 'y';
rb_BillY.Hint := '';
end;
1:
begin
rb_DepositY.Hint := '';
rb_BillY.Hint := 'y';
end;
end;
for i := 0 to cgrid_CalMonth.DataController.RecordCount - 1 do
begin
if (cgrid_CalMonth.DataController.Values[i, 1] = True) then
begin
Inc(iRow);
end;
end;
if ( cgrid_CalMonth.DataController.RecordCount = 0 ) Or ( iRow = 0 ) then
begin
GMessagebox('선택된 오더가 없습니다.', CDMSE);
Exit;
end;
cxLabel175.Caption := IntToStr(iRow);
cxLabel176.Caption := '0';
Gauge1.Max := iRow;
Gauge1.Position := 0;
iRow := 0;
if Gauge1.Max > 1 then
begin
pnl_BubinAccStatus.Left := frm_Main.Left + ((frm_Main.Width - pnl_BubinAccStatus.Width) div 2);
pnl_BubinAccStatus.Top := 100;
pnl_BubinAccStatus.Visible := True;
pnl_BubinAccStatus.BringToFront;
end;
Screen.Cursor := crHourGlass;
slRcvList := TStringList.Create;
cgrid_CalMonth.DataController.BeginUpdate;
for i := 0 to cgrid_CalMonth.DataController.RecordCount - 1 do
begin
if cgrid_CalMonth.DataController.Values[i, 1] = True then
begin
Inc(iRow);
cxLabel176.Caption := IntToStr(iRow);
Gauge1.Position := iRow;
sCmpNM := cgrid_CalMonth.DataController.Values[i, 8];
sCmpCode := cgrid_CalMonth.DataController.Values[i, 7];
sFinishCnt := FloatToStr(cgrid_CalMonth.DataController.Values[i, iFinishCnt]);
sFinishCharge := FloatToStr(cgrid_CalMonth.DataController.Values[i, iFinishCharge]);
sOrderCnt := FloatToStr(cgrid_CalMonth.DataController.Values[i, iOrderCnt]);
ls_TxLoad := GTx_UnitXmlLoad('ACC12020.xml');
case cb_CalMonth.ItemIndex of
0 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '01');
1 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '02');
2 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '03');
3 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '04');
4 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '05');
5 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '06');
6 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '07');
7 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '08');
8 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '09');
9 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '10');
10: ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '11');
11: ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '12');
end;
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strCbCode' , sCmpCode);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strHdNo' , cgrid_CalMonth.DataController.Values[i, iHdNo]);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strBrNo' , cgrid_CalMonth.DataController.Values[i, iBrNo]);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strPaymentYn' , rb_DepositY.Hint);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strBillYn' , rb_BillY.Hint);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strFinishCnt' , sFinishCnt);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strFinishCharge', sFinishCharge);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strOrderCnt' , sOrderCnt);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'UserIDString' , GT_USERIF.ID);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'ClientVerString', VERSIONINFO);
try
if dm.SendSock(ls_TxLoad, slRcvList, ErrCode, False, 30000) then
begin
rv_str := slRcvList[0];
if rv_str <> '' then
begin
ls_rxxml := rv_str;
xdom := CoMSDomDocument.Create;
try
xdom.loadXML(ls_rxxml);
ls_MSG_Err := GetXmlErrorCode(ls_rxxml);
if ('0000' <> ls_MSG_Err) then
begin
GMessagebox('['+sCmpNM+']처리 오류 : '+ls_Msg_Err, CDMSE);
cgrid_CalMonth.DataController.EndUpdate;
Exit;
end else
begin
if iGubun = 0 then
cgrid_CalMonth.DataController.Values[i, iDeposit] := '입금'
else if iGubun = 1 then
cgrid_CalMonth.DataController.Values[i, iBill] := '발행';
end;
finally
xdom := Nil;
end;
end;
end;
except
slRcvList.Free;
Screen.Cursor := crDefault;
cgrid_CalMonth.DataController.EndUpdate;
end;
end;
end;
slRcvList.Free;
Screen.Cursor := crDefault;
cgrid_CalMonth.DataController.EndUpdate;
except
on e: exception do
begin
Screen.Cursor := crDefault;
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.btn_AllProc2Click(Sender: TObject);
var
iRow, i, ErrCode: Integer;
sCmpCode, sCmpNM, sFinishCnt, sFinishCharge, sOrderCnt: string;
ls_TxLoad: string;
xdom: MSDomDocument;
ls_MSG_Err: string;
ls_rxxml, rv_str: string;
iGubun : integer;
slRcvList : TStringList;
begin
try
iGubun := TcxButton(sender).Tag;
iRow := 0;
case iGubun of
0:
begin
rb_DepositY.Hint := 'y';
rb_BillY.Hint := '';
end;
1:
begin
rb_DepositY.Hint := '';
rb_BillY.Hint := 'y';
end;
end;
for i := 0 to cgrid_CalMonth.DataController.RecordCount - 1 do
begin
if (cgrid_CalMonth.DataController.Values[i, 1] = True) then
begin
Inc(iRow);
end;
end;
if ( cgrid_CalMonth.DataController.RecordCount = 0 ) Or ( iRow = 0 ) then
begin
GMessagebox('선택된 오더가 없습니다.', CDMSE);
Exit;
end;
cxLabel175.Caption := IntToStr(iRow);
cxLabel176.Caption := '0';
Gauge1.Max := iRow;
Gauge1.Position := 0;
iRow := 0;
if Gauge1.Max > 1 then
begin
pnl_BubinAccStatus.Left := frm_Main.Left + ((frm_Main.Width - pnl_BubinAccStatus.Width) div 2);
pnl_BubinAccStatus.Top := 100;
pnl_BubinAccStatus.Visible := True;
pnl_BubinAccStatus.BringToFront;
end;
Screen.Cursor := crHourGlass;
slRcvList := TStringList.Create;
cgrid_CalMonth.DataController.BeginUpdate;
for i := 0 to cgrid_CalMonth.DataController.RecordCount - 1 do
begin
if cgrid_CalMonth.DataController.Values[i, 1] = True then
begin
Inc(iRow);
cxLabel176.Caption := IntToStr(iRow);
Gauge1.Position := iRow;
sCmpNM := cgrid_CalMonth.DataController.Values[i, 8];
sCmpCode := cgrid_CalMonth.DataController.Values[i, 7];
sFinishCnt := FloatToStr(cgrid_CalMonth.DataController.Values[i, iFinishCnt]);
sFinishCharge := FloatToStr(cgrid_CalMonth.DataController.Values[i, iFinishCharge]);
sOrderCnt := FloatToStr(cgrid_CalMonth.DataController.Values[i, iOrderCnt]);
ls_TxLoad := GTx_UnitXmlLoad('ACC12020.xml');
case cb_CalMonth.ItemIndex of
0 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '01');
1 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '02');
2 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '03');
3 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '04');
4 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '05');
5 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '06');
6 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '07');
7 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '08');
8 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '09');
9 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '10');
10: ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '11');
11: ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '12');
end;
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strCbCode' , sCmpCode);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strHdNo' , cgrid_CalMonth.DataController.Values[i, iHdNo]);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strBrNo' , cgrid_CalMonth.DataController.Values[i, iBrNo]);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strPaymentYn' , rb_DepositY.Hint);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strBillYn' , rb_BillY.Hint);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strFinishCnt' , sFinishCnt);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strFinishCharge', sFinishCharge);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strOrderCnt' , sOrderCnt);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'UserIDString' , GT_USERIF.ID);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'ClientVerString', VERSIONINFO);
try
if dm.SendSock(ls_TxLoad, slRcvList, ErrCode, False, 30000) then
begin
rv_str := slRcvList[0];
if rv_str <> '' then
begin
ls_rxxml := rv_str;
xdom := CoMSDomDocument.Create;
try
xdom.loadXML(ls_rxxml);
ls_MSG_Err := GetXmlErrorCode(ls_rxxml);
if ('0000' <> ls_MSG_Err) then
begin
GMessagebox('['+sCmpNM+']처리 오류 : '+ls_Msg_Err, CDMSE);
cgrid_CalMonth.DataController.EndUpdate;
Exit;
end else
begin
if iGubun = 0 then
cgrid_CalMonth.DataController.Values[i, iDeposit] := '입금'
else if iGubun = 1 then
cgrid_CalMonth.DataController.Values[i, iBill] := '발행';
end;
finally
xdom := Nil;
end;
end;
end;
except
slRcvList.Free;
Screen.Cursor := crDefault;
cgrid_CalMonth.DataController.EndUpdate;
end;
end;
end;
slRcvList.Free;
Screen.Cursor := crDefault;
cgrid_CalMonth.DataController.EndUpdate;
except
on e: exception do
begin
Screen.Cursor := crDefault;
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.btn_CardClick(Sender: TObject);
begin
// // 카드결제 창 오픈. 2011-10-13.
// if not Assigned(Frm_JON34B) then
// begin
// Frm_JON34B := TFrm_JON34B.Create(self);
// end;
//
// Frm_JON34B.cxCurDecRate_Cash.Properties.AssignedValues.MaxValue := False;
// Frm_JON34B.cxCurDRate.Properties.AssignedValues.MaxValue := False;
// Frm_JON34B.cxCurDecRate.Properties.AssignedValues.MaxValue := False;
//
// Frm_JON34B.pnlTitle.Caption := ' 카드결제';
// Frm_JON34B.Card_Gubun := 11;
// Frm_JON34B.proc_init;
// if (GT_SEL_BRNO.HDNO = 'A1531') or (GT_SEL_BRNO.HDNO = 'A100') then
// begin
// Frm_JON34B.pnl1.Visible := True; //카드결제 판넬
// Frm_JON34B.pnl3.Visible := False; //현금영수증 판넬
// Frm_JON34B.Constraints.MinHeight := 375 - 33;
// Frm_JON34B.Height := 375 - 33;
// end else
// begin
// Frm_JON34B.pnl1.Visible := False; //카드결제 판넬
// Frm_JON34B.pnl3.Visible := False; //현금영수증 판넬
// Frm_JON34B.Constraints.MinHeight := 375 - (33 + 33);
// Frm_JON34B.Height := 375 - (33 + 33);
// end;
// Frm_JON34B.pnl4.Left := 400;
// Frm_JON34B.pnl6.Left := 400;
// Frm_JON34B.cxCurDRate.Value := edt_CalMoney.Value; // 요금.
//
// //공통사항///////////////////
// Frm_JON34B.lcBRNO := GT_SEL_BRNO.BrNo; // 지사코드 정보를 읽는다.
// Frm_JON34B.lcMainNum := ''; // 대표번호 정보를 읽는다.
// Frm_JON34B.lcCustTel := ''; // 고객전화번호.
// Frm_JON34B.lcCustSeq := ''; // 고객 시퀀스.
// //공통사항///////////////////
//
// if Frm_JON34B.rbConfigVATset1.Checked then
// Frm_JON34B.cxCurDecRate.Value := edt_CalMoney.Value
// else
// if Frm_JON34B.rbConfigVATset2.Checked then
// // 결제요금. 설정된 부가세 적용.
// Frm_JON34B.cxCurDecRate.Value := edt_CalMoney.Value + (edt_CalMoney.Value * (StrToFloatDef(Frm_JON34B.cxCurVATvalue.Text, 0.0) / 100))
// else
// if Frm_JON34B.rbConfigVATset3.Checked then
// begin
// Frm_JON34B.cxCurDecRate.Value := Frm_JON34B.proc_getSvrCardCharge(Frm_JON34B.lcBRNO, edt_CalMoney.Value);
// end;
//
// Frm_JON34B.lcJON_IDX := Self.Tag; // 접수창의 index 값 저장.
//
// // 기 결제 정보가 있으면, 해당 값을 넣어준다.
// if Length(BBINCardPayInfo) > 10 then
// begin
// try
// lsTemp := TStringList.Create;
// lsTemp.Delimiter := '|';
// lsTemp.DelimitedText := BBINCardPayInfo;
//
// Frm_JON34B.cxCurDRate.Text := lsTemp[0];
// Frm_JON34B.cxCurDecRate.Text := lsTemp[1];
// Frm_JON34B.cxCurTerm.Text := lsTemp[2];
// Frm_JON34B.lblCardStatus.Caption := lsTemp[3]; // 상태
// if lsTemp.Count = 6 then
// begin
// Frm_JON34B.medCardNum.Text := lsTemp[4];
// Frm_JON34B.medLimiteDate.text := lsTemp[5];
// end;
//
// // 카드결제정보 조회
// if (BBINCardPaySeq <> '') then
// Frm_JON34B.ProCardInfoSelect(BBINCardPaySeq);
//
// if Frm_JON34B.lblCardStatus.Caption = '결제완료' then
// begin
// // 카드결제 승인 취소 할 준비.
// Frm_JON34B.sb_ApproveReq.Enabled := False;
// Frm_JON34B.sb_ApproveOK.Enabled := False;
// Frm_JON34B.sb_ApproveCancle.Enabled := True;
// Frm_JON34B.sb_ApproveReceipt.Enabled := True;
//
// Frm_JON34B.medCardNum.Enabled := False;
// Frm_JON34B.medLimiteDate.Enabled := False;
// Frm_JON34B.cxCurDRate.Enabled := False;
// Frm_JON34B.cxCurDecRate.Enabled := False;
// Frm_JON34B.cxCurTerm.Enabled := False;
// end else
// if Frm_JON34B.lblCardStatus.Caption = '결제요청완료' then
// begin
// // 카드결제 승인 취소 할 준비.
// Frm_JON34B.sb_ApproveReq.Enabled := False;
// Frm_JON34B.sb_ApproveOK.Enabled := False;
// Frm_JON34B.sb_ApproveCancle.Enabled := False;
// Frm_JON34B.sb_ApproveReceipt.Enabled := False;
//
// Frm_JON34B.medCardNum.Enabled := False;
// Frm_JON34B.medLimiteDate.Enabled := False;
// Frm_JON34B.cxCurDRate.Enabled := False;
// Frm_JON34B.cxCurDecRate.Enabled := False;
// Frm_JON34B.cxCurTerm.Enabled := False;
// end else
// begin
// // 카드결제 승인 할 준비.
// Frm_JON34B.sb_ApproveReq.Enabled := True;
// Frm_JON34B.sb_ApproveOK.Enabled := False;
// Frm_JON34B.sb_ApproveCancle.Enabled := False;
// Frm_JON34B.sb_ApproveReceipt.Enabled := False;
//
// Frm_JON34B.medCardNum.Enabled := True;
// Frm_JON34B.medLimiteDate.Enabled := True;
// Frm_JON34B.cxCurDRate.Enabled := True;
// Frm_JON34B.cxCurDecRate.Enabled := True;
// Frm_JON34B.cxCurTerm.Enabled := True;
//
// Frm_JON34B.rb_Card1.Enabled := True;
// Frm_JON34B.rb_BaRo_Card1.Enabled := True;
// end;
//
// Frm_JON34B.lcPaySeq := BBINCardPaySeq; // 결제일련번호
// Frm_JON34B.lcTranNo := BBINCardTranNo; // 거래번호
//
// Frm_JON34B.lblPaySeq.Caption := BBINCardPaySeq;
// Frm_JON34B.lblTranNo.Caption := BBINCardTranNo;
// finally
// FreeAndNil(lsTemp);
// end;
// end else
// if Length(BBINCardPaySeq) > 1 then
// begin
// Frm_JON34B.lcPaySeq := BBINCardPaySeq; // 결제일련번호 만 있으면 승인취소 가능 함.
// Frm_JON34B.lblPaySeq.Caption := BBINCardPaySeq;
//
// Frm_JON34B.ProCardInfoSelect(BBINCardPaySeq); // 카드결제 정보를 조회 한다.
//
// if Frm_JON34B.lblCardStatus.Caption = '결제완료' then
// begin
// // 카드결제 승인 취소 할 준비.
// Frm_JON34B.sb_ApproveReq.Enabled := False;
// Frm_JON34B.sb_ApproveOK.Enabled := False;
// Frm_JON34B.sb_ApproveCancle.Enabled := True;
// Frm_JON34B.sb_ApproveReceipt.Enabled := True;
//
// Frm_JON34B.medCardNum.Enabled := False;
// Frm_JON34B.medLimiteDate.Enabled := False;
// Frm_JON34B.cxCurDRate.Enabled := False;
// Frm_JON34B.cxCurDecRate.Enabled := False;
// Frm_JON34B.cxCurTerm.Enabled := False;
// end else
// if Frm_JON34B.lblCardStatus.Caption = '결제요청완료' then
// begin
// // 카드결제 승인 취소 할 준비.
// Frm_JON34B.sb_ApproveReq.Enabled := False;
// Frm_JON34B.sb_ApproveOK.Enabled := False;
// Frm_JON34B.sb_ApproveCancle.Enabled := False;
// Frm_JON34B.sb_ApproveReceipt.Enabled := False;
//
// Frm_JON34B.medCardNum.Enabled := False;
// Frm_JON34B.medLimiteDate.Enabled := False;
// Frm_JON34B.cxCurDRate.Enabled := False;
// Frm_JON34B.cxCurDecRate.Enabled := False;
// Frm_JON34B.cxCurTerm.Enabled := False;
// end else
// begin
// // 카드결제 승인 할 준비.
// Frm_JON34B.sb_ApproveReq.Enabled := True;
// Frm_JON34B.sb_ApproveOK.Enabled := False;
// Frm_JON34B.sb_ApproveCancle.Enabled := False;
// Frm_JON34B.sb_ApproveReceipt.Enabled := False;
//
// Frm_JON34B.medCardNum.Enabled := True;
// Frm_JON34B.medLimiteDate.Enabled := True;
// Frm_JON34B.cxCurDRate.Enabled := True;
// Frm_JON34B.cxCurDecRate.Enabled := True;
// Frm_JON34B.cxCurTerm.Enabled := True;
// Frm_JON34B.rb_Card1.Enabled := True;
// Frm_JON34B.rb_BaRo_Card1.Enabled := True;
// end;
// end else
// begin
// // 카드결제 승인 할 준비.
// Frm_JON34B.sb_ApproveReq.Enabled := True;
// Frm_JON34B.sb_ApproveOK.Enabled := False;
// Frm_JON34B.sb_ApproveCancle.Enabled := False;
// Frm_JON34B.sb_ApproveReceipt.Enabled := False;
//
// Frm_JON34B.medCardNum.Enabled := True;
// Frm_JON34B.medLimiteDate.Enabled := True;
// Frm_JON34B.cxCurDRate.Enabled := True;
// Frm_JON34B.cxCurDecRate.Enabled := True;
// Frm_JON34B.cxCurTerm.Enabled := True;
// Frm_JON34B.rb_Card1.Enabled := True;
// Frm_JON34B.rb_BaRo_Card1.Enabled := True;
// end;
//
// if Assigned(Frm_JON34B) then
// begin
// Frm_JON34B.Left := pnl_CalCampInfo.Left + (pnl_CalCampInfo.Width + 1);
// Frm_JON34B.Top := pnl_CalCampInfo.Top;
// end;
//
// Frm_JON34B.Show;
end;
procedure TFrm_CUT1.btn_CashBillClick(Sender: TObject);
begin
// if not Assigned(Frm_JON34B) then
// begin
// Frm_JON34B := TFrm_JON34B.Create(self);
// end;
//
// Frm_JON34B.cxCurDecRate_Cash.Properties.AssignedValues.MaxValue := False;
// Frm_JON34B.cxCurDRate.Properties.AssignedValues.MaxValue := False;
// Frm_JON34B.cxCurDecRate.Properties.AssignedValues.MaxValue := False;
// Frm_JON34B.pnlTitle.Caption := ' 현금영수증(지출증빙) 발급';
// // 카드결제 창 오픈. 2011-10-13.
// Frm_JON34B.Card_Gubun := 10; //현금영수증
// Frm_JON34B.proc_init;
// Frm_JON34B.pnl1.Visible := False;
// Frm_JON34B.pnl3.Visible := True;
// Frm_JON34B.pnl4.Visible := True;
// Frm_JON34B.pnl6.Visible := False;
// Frm_JON34B.pnl4.Left := 0;
// Frm_JON34B.pnl4.Top := 1;
// Frm_JON34B.Constraints.MinHeight := 375 - 33;
// Frm_JON34B.Height := 375 - 33;
//
// Frm_JON34B.cxCurDecRate_Cash.Value := edt_CalMoney.Value; // 요금(현금영수증)
//
// //공통사항///////////////////
// Frm_JON34B.lcBRNO := GT_SEL_BRNO.BrNo; // 지사코드 정보를 읽는다.
// Frm_JON34B.lcMainNum := ''; // 대표번호 정보를 읽는다.
// Frm_JON34B.lcCustTel := ''; // 고객전화번호.
// Frm_JON34B.medtCashCardNum.Text := '';
// Frm_JON34B.lcCustSeq := ''; // 고객 시퀀스.
// //공통사항///////////////////
//
// Frm_JON34B.lcJON_IDX := Self.Tag; // 접수창의 index 값 저장.
//
// // 기 결제 정보가 있으면, 해당 값을 넣어준다.
// if Length(BBINCardPayInfo) > 10 then
// begin
// try
// Frm_JON34B.lcCustTel := ''; // 고객전화번호.
//
// lsTemp := TStringList.Create;
// lsTemp.Delimiter := '|';
// lsTemp.DelimitedText := BBINCardPayInfo;
//
// Frm_JON34B.cxCurDecRate_Cash.Text := lsTemp[0];
// Frm_JON34B.lblCardStatus_Cash.Caption := lsTemp[1]; // 상태
// if lsTemp.Count = 3 then
// begin
// Frm_JON34B.medtCashCardNum.Text := lsTemp[2];
// end;
//
// // 접수번호가 있을경우만 서버에서 재조회 한다. 2011-10-27
// if (BBINCardPaySeq <> '') then
// Frm_JON34B.ProCardInfoSelect(BBINCardPaySeq); // 카드결제 정보를 조회 한다.
//
// if Frm_JON34B.lblCardStatus_Cash.Caption = '증빙완료' then
// begin
// // 카드결제 승인 취소 할 준비.
// Frm_JON34B.sb_ApproveReq.Enabled := False;
// Frm_JON34B.sb_ApproveOK.Enabled := False;
// Frm_JON34B.sb_ApproveCancle.Enabled := True;
// Frm_JON34B.sb_ApproveReceipt.Enabled := False;
// Frm_JON34B.medtCashCardNum.Enabled := False;
// Frm_JON34B.cxCurDecRate_Cash.Enabled := False;
// end else
// if Frm_JON34B.lblCardStatus_Cash.Caption = '증빙요청완료' then
// begin
// // 카드결제 승인 취소 할 준비.
// Frm_JON34B.sb_ApproveReq.Enabled := False;
// Frm_JON34B.sb_ApproveOK.Enabled := False;
// Frm_JON34B.sb_ApproveCancle.Enabled := False;
// Frm_JON34B.sb_ApproveReceipt.Enabled := False;
// Frm_JON34B.medtCashCardNum.Enabled := False;
// Frm_JON34B.cxCurDecRate_Cash.Enabled := False;
// end else
// begin
// // 카드결제 승인 할 준비.
// Frm_JON34B.sb_ApproveReq.Enabled := True;
// Frm_JON34B.cxButton1.Enabled := False;
// Frm_JON34B.sb_ApproveOK.Enabled := False;
// Frm_JON34B.sb_ApproveCancle.Enabled := False;
// Frm_JON34B.sb_ApproveReceipt.Enabled := False;
// Frm_JON34B.medtCashCardNum.Enabled := True;
// Frm_JON34B.cxCurDecRate_Cash.Enabled := True;
//
// Frm_JON34B.rg_charge_ser2.Enabled := True;
// Frm_JON34B.rg_charge_ser1.Enabled := True;
// end;
//
// Frm_JON34B.lcPaySeq := BBINCardPaySeq; // 결제일련번호
// Frm_JON34B.lcTranNo := BBINCardTranNo; // 거래번호
//
// Frm_JON34B.lblPaySeq_Cash.Caption := BBINCardPaySeq;
// Frm_JON34B.lblTranNo_Cash.Caption := BBINCardTranNo;
// finally
// FreeAndNil(lsTemp);
// end;
// end else
// if Length(BBINCardPaySeq) > 1 then
// begin
// Frm_JON34B.lcCustTel := ''; // 고객전화번호.
// Frm_JON34B.lcPaySeq := BBINCardPaySeq; // 결제일련번호 만 있으면 승인취소 가능 함.
// Frm_JON34B.lblPaySeq_Cash.Caption := BBINCardPaySeq;
//
// Frm_JON34B.ProCardInfoSelect(BBINCardPaySeq); // 카드결제 정보를 조회 한다.
//
// if Frm_JON34B.lblCardStatus_Cash.Caption = '증빙완료' then
// begin
// // 카드결제 승인 취소 할 준비.
// Frm_JON34B.sb_ApproveReq.Enabled := False;
// Frm_JON34B.sb_ApproveOK.Enabled := False;
// Frm_JON34B.sb_ApproveCancle.Enabled := True;
// Frm_JON34B.sb_ApproveReceipt.Enabled := False;
// Frm_JON34B.medtCashCardNum.Enabled := False;
// Frm_JON34B.cxCurDecRate_cash.Enabled := False;
// end else
// if Frm_JON34B.lblCardStatus_Cash.Caption = '증빙요청완료' then
// begin
// // 카드결제 승인 취소 할 준비.
// Frm_JON34B.sb_ApproveReq.Enabled := False;
// Frm_JON34B.sb_ApproveOK.Enabled := False;
// Frm_JON34B.sb_ApproveCancle.Enabled := False;
// Frm_JON34B.sb_ApproveReceipt.Enabled := False;
// Frm_JON34B.medtCashCardNum.Enabled := False;
// Frm_JON34B.cxCurDecRate_cash.Enabled := False;
// end else
// begin
// // 카드결제 승인 할 준비.
// Frm_JON34B.sb_ApproveReq.Enabled := True;
// Frm_JON34B.sb_ApproveOK.Enabled := False;
// Frm_JON34B.sb_ApproveCancle.Enabled := False;
// Frm_JON34B.sb_ApproveReceipt.Enabled := False;
//
// Frm_JON34B.medtCashCardNum.Enabled := True;
// Frm_JON34B.cxCurDecRate_cash.Enabled := True;
// Frm_JON34B.rg_charge_ser2.Enabled := True;
// Frm_JON34B.rg_charge_ser1.Enabled := True;
// end;
// end else
// begin
// // 카드결제 승인 할 준비.
// Frm_JON34B.sb_ApproveReq.Enabled := True;
// Frm_JON34B.sb_ApproveOK.Enabled := False;
// Frm_JON34B.sb_ApproveCancle.Enabled := False;
// Frm_JON34B.sb_ApproveReceipt.Enabled := False;
// Frm_JON34B.medtCashCardNum.Enabled := True;
// Frm_JON34B.cxCurDecRate_cash.Enabled := True;
// Frm_JON34B.rg_charge_ser2.Enabled := True;
// Frm_JON34B.rg_charge_ser1.Enabled := True;
// end;
//
// if Assigned(Frm_JON34B) then
// begin
// {Frm_JON34B.Left := Self.Left - (Frm_JON34B.Width + 1);
// Frm_JON34B.Top := Self.Top + 320; }
// Frm_JON34B.Left := pnl_CalCampInfo.Left + (pnl_CalCampInfo.Width + 1);
// Frm_JON34B.Top := pnl_CalCampInfo.Top;
// end;
// Frm_JON34B.Show;
end;
procedure TFrm_CUT1.btn_CloseClick(Sender: TObject);
begin
pnl_CalCampInfo.Visible := False;
end;
procedure TFrm_CUT1.btn_ConfirmClick(Sender: TObject);
begin
if (pnl_Makeid.tag = 1) and (btn_Confirm.Tag = 0) then //ID생성인데 중복체크 안함
begin
GMessagebox('ID 중복확인을 진행하여 주십시오', CDMSE);
btn_Confirm.click;
Exit;
end;
if edt_WebPW1.Text <> edt_WebPW2.Text then
begin
GMessagebox('비밀번호가 일치하지 않습니다', CDMSE);
edt_WebPW2.Text := '';
edt_WebPW2.SetFocus;
end else
begin
{ if (length(edt_WebIDFirst.Text) < 4) and (pnl_makeid.Tag = 1) then //신규ID일 경우에만 체크
begin
GMessagebox('WebID는 4자 이상만 가능 합니다', CDMSE);
edt_WebIDFirst.SetFocus;
end else
if (length(edt_WebIDFirst.Text) > 20) then
begin
GMessagebox('WebID는 20자 이하만 가능 합니다', CDMSE);
edt_WebIDFirst.SetFocus;
end else }
if (length(edt_WebPW1.Text) < 4) then
begin
GMessagebox('비밀번호는 4자 이상만 가능 합니다', CDMSE);
edt_WebPW1.Text := '';
edt_WebPW2.Text := '';
edt_WebPW1.SetFocus;
end else
if (length(edt_WebPW1.Text) > 20) then
begin
GMessagebox('비밀번호는 20자 이하만 가능 합니다', CDMSE);
edt_WebPW1.Text := '';
edt_WebPW2.Text := '';
edt_WebPW1.SetFocus;
end else
begin
if pnl_Makeid.Tag = 1 then
begin
edWebID.text := edt_WebIDFirst.Text;
edWebPW.text := edt_WebPW1.Text;
end else
if pnl_Makeid.Tag = 2 then
begin
edWebPW.text := edt_WebPW1.Text;
end;
btn_IDCheckClose.click;
end;
end;
end;
procedure TFrm_CUT1.btn_Date2_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
pm_Date.Tag := TcxButton(Sender).Tag;
end;
procedure TFrm_CUT1.btn_Date3_1Click(Sender: TObject);
begin
pm_Date.Tag := TcxButton(Sender).Tag;
end;
procedure TFrm_CUT1.btn_Date3_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
pm_Date.Tag := TcxButton(Sender).Tag;
end;
procedure TFrm_CUT1.btn_Date3_2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Pop_Ymd.Tag := TcxButton(Sender).Tag;
end;
procedure TFrm_CUT1.btn_Date4_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
pm_Date.Tag := TcxButton(Sender).Tag;
end;
procedure TFrm_CUT1.btn_Date9_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
pm_Date.Tag := TcxButton(Sender).Tag;
end;
procedure TFrm_CUT1.btn_IdCheckClick(Sender: TObject);
begin
if (length(edt_WebIDFirst.Text) < 4) and (pnl_makeid.Tag = 1) then //신규ID일 경우에만 체크
begin
GMessagebox('WebID는 4자 이상만 가능 합니다', CDMSE);
edt_WebIDFirst.SetFocus;
end else
if (length(edt_WebIDFirst.Text) > 20) then
begin
GMessagebox('WebID는 20자 이하만 가능 합니다', CDMSE);
edt_WebIDFirst.SetFocus;
end else
proc_search_bubin_id;
end;
procedure TFrm_CUT1.btn_IDCheckCloseClick(Sender: TObject);
begin
btn_Confirm.Tag := 0;
pnl_MakeId.Visible := False;
end;
procedure TFrm_CUT1.btn_InfoSaveClick(Sender: TObject);
var
ls_TxLoad: string;
ls_rxxml: string;
xdom: MSDomDocument;
ErrCode, iRow : Integer;
ls_MSG_Err, rv_str: string;
slRcvList : TStringList;
begin
Try
Screen.Cursor := crHourGlass;
ls_TxLoad := GTx_UnitXmlLoad('ACC12020.xml');
slRcvList := TStringList.Create;
case cb_CalMonth.ItemIndex of
0 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '01');
1 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '02');
2 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '03');
3 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '04');
4 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '05');
5 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '06');
6 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '07');
7 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '08');
8 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '09');
9 : ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '10');
10: ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '11');
11: ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , lb_Year.Caption + '12');
end;
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strCbCode' , edtBubinCode.Text);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strHdNo' , FHdNo);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strBrNo' , FBrNo);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strPaymentYn' , rb_DepositY.Hint);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strBillYn' , rb_BillY.Hint);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strFinishCnt' , edt_FinishCnt.Text);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strFinishCharge', edt_CalMoney.Text);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strOrderCnt' , edt_OrderCnt.Text);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'UserIDString' , GT_USERIF.ID);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'ClientVerString', VERSIONINFO);
try
if dm.SendSock(ls_TxLoad, slRcvList, ErrCode, False, 30000) then
begin
rv_str := slRcvList[0];
if rv_str <> '' then
begin
ls_rxxml := rv_str;
xdom := CoMSDomDocument.Create;
try
xdom.loadXML(ls_rxxml);
ls_MSG_Err := GetXmlErrorCode(ls_rxxml);
if ('0000' <> ls_MSG_Err) then
begin
GMessagebox('저장 오류 : '+ls_Msg_Err, CDMSE);
Exit;
end else
begin
GMessagebox('저장 완료', CDMSE);
iRow := StrToIntDef(edt_RowNum.Text, -1);
if iRow > -1 then
begin
if rb_DepositY.Hint = 'y' then
cgrid_CalMonth.DataController.Values[iRow,iDeposit] := '입금'
else
cgrid_CalMonth.DataController.Values[iRow,iDeposit] := '미입금';
if rb_BillY.Hint = 'y' then
cgrid_CalMonth.DataController.Values[iRow,iBill] := '발행'
else
cgrid_CalMonth.DataController.Values[iRow,iBill] := '미발행';
end;
end;
finally
xdom := Nil;
slRcvList.Free;
Screen.Cursor := crDefault;
end;
end;
end;
except
slRcvList.Free;
Screen.Cursor := crDefault;
end;
except
on e: exception do
begin
Screen.Cursor := crDefault;
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.btn_WebIdClick(Sender: TObject);
begin
if (length(edWebID.Text) < 4) then // and (pnl_makeid.Tag = 1) then //신규ID일 경우에만 체크
begin
GMessagebox('WebID는 4자 이상만 가능 합니다', CDMSE);
edWebID.SetFocus;
end else
if (length(edWebID.Text) > 20) then
begin
GMessagebox('WebID는 20자 이하만 가능 합니다', CDMSE);
edWebID.SetFocus;
end else
proc_search_bubin_id;
{ if edCbCode.text = '' then exit;
edt_WebIdFirst.text := '';
edt_WebPW1.text := '';
edt_WebPW2.text := '';
edt_WebIdFirst.Enabled := True;
btn_IdCheck.Enabled := True;
edt_WebPW1.Enabled := False;
edt_WebPW2.Enabled := False;
btn_Confirm.Enabled := False;
pnl_MakeId.visible := True;
edt_WebIdFirst.SetFocus;
pnl_MakeId.Left := 690;
pnl_MakeId.Top := 10;
pnl_Makeid.tag := 1;
btn_Confirm.Tag := 0; //중복체크 안함 }
end;
procedure TFrm_CUT1.btn_WebPwClick(Sender: TObject);
begin
if edCbCode.text = '' then exit;
if edWebId.text = '' then
begin
btn_WebId.Click;
end else
begin
edt_WebIdFirst.text := edWebId.text;
edt_WebPW1.text := '';
edt_WebPW2.text := '';
btn_IdCheck.Enabled := False;
edt_WebPW1.Enabled := True;
edt_WebPW2.Enabled := True;
btn_Confirm.Enabled := True;
pnl_MakeId.visible := True;
edt_WebIdFirst.Enabled := False;
pnl_MakeId.Left := 690;
pnl_MakeId.Top := 10;
pnl_Makeid.tag := 2;
end;
end;
procedure TFrm_CUT1.btn_Date10_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
pm_Date.Tag := TcxButton(Sender).Tag;
end;
procedure TFrm_CUT1.btn_Date11_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
pm_Date.Tag := TcxButton(Sender).Tag;
end;
procedure TFrm_CUT1.btn_Date13_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
pm_Date.Tag := TcxButton(Sender).Tag;
end;
procedure TFrm_CUT1.btn_Date14_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
pm_Date.Tag := TcxButton(Sender).Tag;
end;
procedure TFrm_CUT1.btn_Date16_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
pm_Date.Tag := TcxButton(Sender).Tag;
end;
procedure TFrm_CUT1.btn_Date18_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
pm_Date.Tag := TcxButton(Sender).Tag;
end;
procedure TFrm_CUT1.btn_Date1_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
pm_Date.Tag := 11;
end;
procedure TFrm_CUT1.btn_Date1_2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
pop_Ymd.Tag := 12;
end;
procedure TFrm_CUT1.btn_Date1_3MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
pop_Ymd.Tag := 13;
end;
procedure TFrm_CUT1.btn_Date1_4MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
pop_Ymd.Tag := 14;
end;
procedure TFrm_CUT1.btn_12_10Click(Sender: TObject);
var
KeyIndex: Integer;
KeyValue: string;
begin
if CustView12_2.DataController.RecordCount = 0 then
begin
GMessagebox('검색 대상 고객정보가 없습니다.', CDMSE);
Exit;
end;
// 전체 : -1
KeyIndex := -1;
if Assigned(CustView12_2.GetColumnByFieldName(cbbResultSearch.Text)) then
KeyIndex := CustView12_2.GetColumnByFieldName(cbbResultSearch.Text).Index;
KeyValue := edtResultSearch.Text;
cxViewCustom.DataController.RecordCount := 0;
cxGridCopy(CustView12_2, cxViewCustom, KeyIndex, KeyValue);
if cxViewCustom.DataController.RecordCount = 0 then
begin
if KeyIndex >= 0 then
GMessagebox('검색 결과가 없습니다.', CDMSE);
cxGridCustom.Visible := False;
cxGrid10.Visible := True;
end else
begin
cxGridCustom.Visible := True;
cxGrid10.Visible := False;
end;
end;
procedure TFrm_CUT1.btn_12_11Click(Sender: TObject);
begin
CustView12_3.DataController.SetRecordCount(0);
proc_NotBubinCust_Search;
end;
procedure TFrm_CUT1.btn_12_12Click(Sender: TObject);
const
ls_Param = '<param>ParamString</param>';
var
rv_str, ls_TxLoad, ls_Msg_Err, sMsg, sBrNo: string;
sParam, sTemp, sKeynum, sCustTel: string;
ls_rxxml: WideString;
iIdx: Integer;
slReceive: TStringList;
ErrCode: integer;
begin
if (CustView12_3.DataController.RecordCount = 0) or
(CustView12_3.DataController.GetSelectedCount =
0) then
begin
GMessagebox('조회후 고객을 삭제하세요!', CDMSE);
Exit;
end;
iIdx := CustView12_3.DataController.FocusedRecordIndex;
sBrNo := cxBrNo12.Text;
sKeynum := StringReplace(cbKeynumber12.Text, '-', '', [rfReplaceAll]);
sCustTel := CustView12_3.DataController.Values[iIdx, 4];
//GMessagebox('본사코드 : ' + GT_USERIF.HD + #13#10 + '지사코드 : '+sBrNo+#13#10+'전화번호 : ' + sCustTel + #13#10 + '대표번호 : ' + sKeynum, CDMSE);
if GMessagebox('삭제고객번호 : ' + sCustTel + #13#10 +
'삭제시 고객정보와 이용횟수, 마일리지가 삭제됩니다.' + #13#10 +
'삭제하시겠습니까?', CDMSQ) <> idok then
Exit;
sKeynum := StringReplace(sKeynum, '-', '', [rfReplaceAll]);
sCustTel := StringReplace(sCustTel, '-', '', [rfReplaceAll]);
ls_TxLoad := GTx_UnitXmlLoad('CALLABLE.xml');
sTemp := 'PROC_DELETE_CUSTOMER(?,?,?,?,?)';
sParam := StringReplace(ls_Param, 'ParamString', cxHdNo12.Text, [rfReplaceAll]);
sParam := sParam + StringReplace(ls_Param, 'ParamString', sBrNo, [rfReplaceAll]);
sParam := sParam + StringReplace(ls_Param, 'ParamString', sKeynum, [rfReplaceAll]);
sParam := sParam + StringReplace(ls_Param, 'ParamString', sCustTel, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'UserIDString', En_Coding(GT_USERIF.ID), [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientVerString', VERSIONINFO, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientKeyString', 'DELETECUST', [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'CallString', sTemp, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'CountString', IntToStr(4), [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ParamString', sParam, [rfReplaceAll]);
slReceive := TStringList.Create;
try
if dm.SendSock(ls_TxLoad, slReceive, ErrCode, False) then
begin
rv_str := slReceive[0];
if rv_str <> '' then
begin
ls_rxxml := rv_str;
try
ls_Msg_Err := GetXmlErrorCode(ls_rxxml);
sMsg := GetXmlErrorMsg(ls_rxxml);
if ('0000' = ls_Msg_Err) and ('1' = sMsg) then
begin
GMessagebox('성공하였습니다.', CDMSI);
//proc_search_bubin;
btn_12_11Click(btn_12_11);
end else
if ('0000' = ls_Msg_Err) and ('0' = sMsg) then
begin
GMessagebox('실패하였습니다.' + #13#10 + '다시 한번 시도해 보세요', CDMSE);
end else
begin
GMessagebox('실패하였습니다.' + #13#10 + '다시 한번 시도해 보세요', CDMSE);
end;
except
GMessagebox('실패하였습니다.' + #13#10 + '다시 한번 시도해 보세요', CDMSE);
end;
end;
end;
finally
FreeAndNil(slReceive);
Screen.Cursor := crDefault;
Frm_Flash.Hide;
end;
end;
procedure TFrm_CUT1.btn_12_13Click(Sender: TObject);
var
iRow: Integer;
sCustYn, sUseYn : string;
begin
iRow := GT_BUBIN_INFO.cbcode.IndexOf(cxTextEdit15.Text + ',' + cxBrNo12.Text);
if iRow = -1 then
begin
GMessagebox('일단 법인업체를 먼저 선택하셔야 합니다.', CDMSE);
Exit;
end;
sCustYn := GT_BUBIN_INFO.cbCustYn.Strings[iRow];
sUseYn := GT_BUBIN_INFO.cbUseYn.Strings[iRow];
if sCustYn = 'n' then
begin
GMessagebox('선택 법인업체는 고객을 추가할수 없습니다.', CDMSE);
Exit;
end;
if sUseYn = 'n' then
begin
GMessagebox('선택 법인업체는 사용업체가 아닙니다.', CDMSE);
Exit;
end;
proc_cust_bubin_Modify(0, CustView12_3);
end;
procedure TFrm_CUT1.btn_12_14Click(Sender: TObject);
var
iRow: Integer;
begin
iRow := GT_BUBIN_INFO.cbcode.IndexOf(cxTextEdit15.Text + ',' + cxBrNo12.Text);
if iRow = -1 then
begin
GMessagebox('일단 법인업체를 먼저 선택하셔야 합니다.', CDMSE);
Exit;
end;
if cxGridCustom.Visible then
proc_cust_bubin_Modify(1, cxViewCustom)
else
proc_cust_bubin_Modify(1, CustView12_2);
end;
procedure TFrm_CUT1.btn_12_1Click(Sender: TObject);
begin
proc_BubinManage;
end;
procedure TFrm_CUT1.btn_12_2Click(Sender: TObject);
var
sBrNo: string;
begin
sBrNo := cxBrNo12.Text;
if sBrNo= '' then
begin
GMessagebox('지사를 먼저 선택하세요.', CDMSE);
Exit;
end;
if ( Not Assigned(Frm_CUT09) ) Or ( Frm_CUT09 = Nil ) then Frm_CUT09 := TFrm_CUT09.Create(Nil);
Frm_CUT09.PnlTitle.Caption := ' 법인(업체) 세부 등록하기';
Frm_CUT09.Tag := 0;
Frm_CUT09.proc_init;
Frm_CUT09.edKeyNum.Text := StringReplace(cbKeynumber12.Text, '-', '', [rfReplaceAll]);
Frm_CUT09.edHdNo.Text := cxHdNo12.Text;
Frm_CUT09.edBrNo.Text := cxBrNo12.Text;
Frm_CUT09.Show;
end;
procedure TFrm_CUT1.btn_12_3Click(Sender: TObject);
begin
if CustView12_1.SelectionCount > 0 then
begin
if ( Not Assigned(Frm_CUT09) ) Or ( Frm_CUT09 = Nil ) then Frm_CUT09 := TFrm_CUT09.Create(Nil);
Frm_CUT09.PnlTitle.Caption := '법인(업체) 세부 수정하기';
Frm_CUT09.Tag := 1;
Frm_CUT09.edCbCode.Text := CustView12_1.Selections[0].Values[7];
Frm_CUT09.edBrNo.Text := cxBrNo12.Text;
Frm_CUT09.proc_init;
Frm_CUT09.Show;
end else
begin
GMessagebox('부서를 선택하시고 수정 바랍니다.', CDMSE);
end;
end;
procedure TFrm_CUT1.btn_12_4Click(Sender: TObject);
begin
if CustView12_1.SelectionCount > 0 then
begin
proc_delete_gbroup(CustView12_1.Selections[0].Values[7]);
end;
end;
procedure TFrm_CUT1.btn_12_5Click(Sender: TObject);
var
iSeq : Integer;
sSeq: string;
begin
if ( Not Assigned(Frm_CUT011) ) Or ( Frm_CUT011 = Nil ) then Frm_CUT011 := TFrm_CUT011.Create(Nil);
Frm_CUT011.Tag := 5;
Frm_CUT011.FControlInitial(False);
Frm_CUT011.cboBranch.Tag := 5;
Frm_CUT011.Hint := IntToStr(Self.Tag);
Frm_CUT011.clbCuSeq.Caption := '';
Frm_CUT011.proc_search_brKeyNum(cxBrNo12.Text, StringReplace(cbKeynumber12.Text, '-', '', [rfReplaceAll]));
Frm_CUT011.Left := (Screen.Width - Frm_CUT011.Width) div 2;
Frm_CUT011.top := (Screen.Height - Frm_CUT011.Height) div 2;
if Frm_CUT011.top <= 10 then Frm_CUT011.top := 10;
Frm_CUT011.Show;
Frm_CUT011.proc_cust_Intit;
Frm_CUT011.rdoCuGb3.Checked := True;
if cxTextEdit15.Text <> '' then
begin
sSeq := cxTextEdit15.Text;
// 권한 적용 (지호 2008-08-19)
iSeq := Frm_CUT011.cboBubinCode.Properties.Items.IndexOf(sSeq + ',' + cxBrNo12.Text);
if iSeq >= 0 then
begin
Frm_CUT011.cboCuBubin.Enabled := False;
Frm_CUT011.cboCuBubin.ItemIndex := iSeq;
end;
end else
begin
Frm_CUT011.cboCuBubin.Enabled := True;
Frm_CUT011.cboCuBubin.ItemIndex := 0;
end;
end;
procedure TFrm_CUT1.btn_12_6Click(Sender: TObject);
begin
if ( Not Assigned(Frm_CUT013) ) Or ( Frm_CUT013 = Nil ) then Frm_CUT013 := TFrm_CUT013.Create(Nil);
Frm_CUT013.FControlInitial(False);
Frm_CUT013.cboBranch.Tag := 5;
Frm_CUT013.proc_search_brKeyNum(cxBrNo12.Text, StringReplace(cbKeynumber12.Text, '-', '', [rfReplaceAll]));
Frm_CUT013.Show;
Frm_CUT013.proc_bubin_init;
end;
procedure TFrm_CUT1.btn_12_7Click(Sender: TObject);
var
iKeyNum, iSeq, iRow: Integer;
sBrNo, sKeyNum, sSeq: string;
AView: TcxGridDBTableView;
begin
// 권한 적용 (지호 2008-08-19)
if TCK_USER_PER.COM_CustModify <> '1' then
begin
GMessagebox('고객 수정권한이 없습니다.', CDMSE);
Exit;
end;
if cxGridCustom.Visible then
AView := cxViewCustom
else
AView := CustView12_2;
iRow := AView.DataController.FocusedRecordIndex;
if iRow = -1 then
Exit;
iKeyNum := AView.GetColumnByFieldName('대표번호').Index;
iSeq := AView.GetColumnByFieldName('고객코드').Index;
sBrNo := cxBrNo12.Text;
sKeyNum := AView.DataController.Values[iRow, iKeyNum];
sKeyNum := StringReplace(sKeyNum, '-', '', [rfReplaceAll]);
sSeq := AView.DataController.Values[iRow, iSeq];
// 6 : 수정창에서 고객수정 4 : 접수창에서 고객수정
if ( Not Assigned(Frm_CUT011) ) Or ( Frm_CUT011 = Nil ) then Frm_CUT011 := TFrm_CUT011.Create(Nil);
Frm_CUT011.Tag := 6;
Frm_CUT011.FControlInitial(False);
Frm_CUT011.Hint := IntToStr(Self.Tag);
Frm_CUT011.clbCuSeq.Caption := sSeq;
Frm_CUT011.proc_search_brKeyNum(sBrNo, sKeyNum);
Frm_CUT011.Left := (Screen.Width - Frm_CUT011.Width) div 2;
Frm_CUT011.top := (Screen.Height - Frm_CUT011.Height) div 2;
if Frm_CUT011.top <= 10 then Frm_CUT011.top := 10;
Frm_CUT011.Show;
Frm_CUT011.proc_cust_Intit;
end;
procedure TFrm_CUT1.btn_12_8Click(Sender: TObject);
begin
if CustView12_1.SelectionCount = 0 then
begin
GMessagebox('일단 법인 업체먼저 선택을 하셔야 합니다.', CDMSE);
Exit;
end;
CustView12_2.DataController.SetRecordCount(0);
cxGrid10.Visible := True;
cxGridCustom.Visible := False;
proc_BubinCust_Search(0);
end;
procedure TFrm_CUT1.btn_12_9Click(Sender: TObject);
begin
CustView12_2.DataController.SetRecordCount(0);
cxGrid10.Visible := True;
cxGridCustom.Visible := False;
proc_BubinCust_Search(1);
end;
procedure TFrm_CUT1.btn_13_1Click(Sender: TObject);
begin
CustView13_1.Root.TreeList.Clear;
proc_BubinManage2;
end;
procedure TFrm_CUT1.btn_13_2Click(Sender: TObject);
begin
if custview13_1.SelectionCount = 0 then
begin
GMessagebox('일단 법인 업체먼저 선택을 하셔야 합니다.', CDMSE);
Exit;
end;
CustView13_2.DataController.SetRecordCount(0);
proc_BubinCust_HIS;
end;
procedure TFrm_CUT1.btn_14_10Click(Sender: TObject);
begin
pnlBubinAccPrt.Visible := False;
end;
procedure TFrm_CUT1.btn_14_11Click(Sender: TObject);
begin
if cxGrid_Angel.DataController.RecordCount = 0 then
begin
GMessagebox('자료가 없습니다.', CDMSE);
Exit;
end;
if GT_USERIF.Excel_Use = 'n' then
begin
ShowMessage('[엑셀다운로드허용] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
if TCK_USER_PER.COM_CustExcelDown <> '1' then
begin
ShowMessage('[조회고객엑셀다운] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
Frm_Main.sgExcel := '고객_법인일일정산전용.xls';
Frm_Main.sgRpExcel := Format('법인>법인일일정-산전용]%s건/%s', [GetMoneyStr(cxGrid_Angel.DataController.RecordCount), FExcelDownBubinDaily]);
Frm_Main.cxGridExcel := cxGrid1;
Frm_Main.bgExcelOPT := False;
Frm_Main.proc_excel(0);
end;
procedure TFrm_CUT1.btn_14_1Click(Sender: TObject);
begin
if (GT_SEL_BRNO.GUBUN = '0') and (not Check_ALLHD(GT_SEL_BRNO.HDNO)) then
begin
GMessagebox('해당본사에 대한 전체 권한이 없습니다.' + #13#10 + '지사를 선택하여 주십시오.', CDMSE);
Exit;
end;
proc_bubinSttSearch;
end;
procedure TFrm_CUT1.btn_14_2Click(Sender: TObject);
begin
if cxGBubinStt.DataController.RecordCount = 0 then
begin
GMessagebox('자료가 없습니다.', CDMSE);
Exit;
end;
if GT_USERIF.Excel_Use = 'n' then
begin
ShowMessage('[엑셀다운로드허용] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
if TCK_USER_PER.COM_CustExcelDown <> '1' then
begin
ShowMessage('[조회고객엑셀다운] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
Frm_Main.sgExcel := '고객_법인일일정산.xls';
Frm_Main.sgRpExcel := Format('법인>법인일일정산]%s건/%s', [GetMoneyStr(cxGBubinStt.DataController.RecordCount), FExcelDownBubinDaily]);
Frm_Main.cxGridExcel := cxGrid7;
Frm_Main.bgExcelOPT := False;
Frm_Main.proc_excel(0);
end;
procedure TFrm_CUT1.btn_14_3Click(Sender: TObject);
var
IE: variant;
begin
IE := CreateOleObject('InternetExplorer.Application');
IE.left := 0;
IE.top := 0;
IE.Width := Screen.Width;
IE.Height := Screen.Height;
IE.Navigate(GS_BUBIN_URL);
if (GS_PRJ_AREA = 'S') then IE.Navigate(GS_BUBIN_URL) else
if (GS_PRJ_AREA = 'O') then IE.Navigate(GS_BUBIN_URL_JI);
IE.Visible := true;
end;
procedure TFrm_CUT1.btn_14_4Click(Sender: TObject);
var
i, iRow, iChkCnt: Integer;
sSlip, ls_TxQry, ls_TxLoad, rv_str, sQueryTemp : string;
xdom: msDomDocument;
ls_rxxml: wideString;
slReceive: TStringList;
ErrCode: integer;
begin
iRow := 0;
iChkCnt := 0;
for i := 0 to cxGBubinStt.DataController.RecordCount - 1 do
begin
if (cxGBubinStt.DataController.Values[i, 1] = '1') and (cxGBubinStt.DataController.Values[i,6] = '불가') and (cxGBubinStt.DataController.Values[i, 5] = '완료') then
begin
Inc(iRow);
end;
if (cxGBubinStt.DataController.Values[i, 1] = '1') then inc(iChkCnt);
end;
if ( cxGBubinStt.DataController.RecordCount = 0 ) or (iChkCnt < 1) then
begin
GMessagebox('선택된 오더가 없습니다.', CDMSE);
exit;
end;
if ( iRow = 0 ) then
begin
GMessagebox('웹열람권한은 [정산-완료]오더만 가능합니다.', CDMSE);
Exit;
end;
cxLabel175.Caption := IntToStr(iRow);
cxLabel176.Caption := '0';
Gauge1.Max := iRow;
Gauge1.Position := 0;
iRow := 0;
if Gauge1.Max > 1 then
begin
pnl_BubinAccStatus.Left := pnl_CUTB3.Left + ((pnl_CUTB3.Width - pnl_BubinAccStatus.Width) div 2);
pnl_BubinAccStatus.Top := 150;
pnl_BubinAccStatus.Visible := True;
pnl_BubinAccStatus.BringToFront;
Application.ProcessMessages;
end;
for i := 0 to cxGBubinStt.DataController.RecordCount - 1 do
begin
if (cxGBubinStt.DataController.Values[i, 1] = '1') and (cxGBubinStt.DataController.Values[i, 6] = '불가') and (cxGBubinStt.DataController.Values[i, 5] = '완료') then
begin
Application.ProcessMessages;
sSlip := cxGBubinStt.DataController.Values[i, 4];
//QUERY.XML 전문을 사용하여 업데이트 한다.
ls_TxLoad := GTx_UnitXmlLoad('QUERY.XML');
fGet_BlowFish_Query(GSQ_CUST_BUBIN_ACCWEBVIEWUPDATE, sQueryTemp);
ls_TxQry := Format(sQueryTemp, [sSlip]);
ls_TxLoad := StringReplace(ls_TxLoad, 'UserIDString', GT_USERIF.ID, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientVerString', VERSIONINFO, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientKeyString', 'ACCWEBVIEWUPDATE', [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'QueryString', ls_TxQry, [rfReplaceAll]);
slReceive := TStringList.Create;
try
if dm.SendSock(ls_TxLoad, slReceive, ErrCode, False) then
begin
rv_str := slReceive[0];
if rv_str <> '' then
begin
ls_rxxml := rv_str;
Application.ProcessMessages;
xdom := ComsDomDocument.Create;
try
if xdom.loadXML(ls_rxxml) then
begin
if (0 < GetXmlRecordCount(ls_rxxml)) then
begin
Inc(iRow);
cxLabel176.Caption := IntToStr(iRow);
Gauge1.Position := iRow;
cxGBubinStt.DataController.Values[i, 1] := '0';
cxGBubinStt.DataController.Values[i, 6] := '가능';
end;
end;
finally
xdom := Nil;
end;
end;
end;
finally
FreeAndNil(slReceive);
Frm_Flash.Hide;
end;
end;
cxGBubinStt.DataController.Values[i, 1] := '0';
end;
if (cxLabel175.Caption <> cxLabel176.Caption) then
begin
GMessagebox('실패한 웹보기 권한이 있습니다.' + #13#10 +
'다시한번 웹보기 권한주기 버튼을 눌러주세요', CDMSE);
pnl_BubinAccStatus.Visible := False;
end else
begin
GMessagebox('완료 하였습니다.', CDMSI);
pnl_BubinAccStatus.Visible := False;
end;
end;
procedure TFrm_CUT1.btn_14_5Click(Sender: TObject);
var
i, iRow, iSupply, iTag, iChkCnt : Integer;
sCharge, sAddCharge, sBaseCharge, sPassCharge, sWaitCharge, sCommission, sSum, sEtcCharge, sSupply, sTax,
sSlip, ls_TxQry, ls_TxLoad, rv_str, bTax, sQueryTemp, sGubun1, sGubun2, sGubun3, sTmp, sMsg, sBtnName : string;
xdom: msDomDocument;
ls_rxxml: wideString;
slReceive: TStringList;
ErrCode: integer;
bTmp : Boolean;
begin
iTag := TcxButton(Sender).Tag;
sBtnName := TcxButton(Sender).Caption;
if iTag = 0 then
begin
sGubun1 := '미정산'; //리스트 에서 대상조건
sTmp := '완료'; //update 후 리스트에 명칭 변경
sMsg := '일괄정산' // 완료 후 메세지
end else
if iTag = 1 then
begin
sGubun1 := '완료' ;
sGubun2 := '개인정산'; //리스트 에서 대상조건
sGubun3 := '불가' ;
sTmp := '미정산';
sMsg := '일괄정산취소' // 완료 후 메세지
end;
iRow := 0;
iChkCnt := 0;
for i := 0 to cxGBubinStt.DataController.RecordCount - 1 do
begin
if iTag = 0 then //일괄정산처리
begin
if (cxGBubinStt.DataController.Values[i, 1] = '1') and (cxGBubinStt.DataController.Values[i, 5] = sGubun1) then
begin
Inc(iRow);
end;
end else
if iTag = 1 then //일괄정산처리 취소
begin
if (cxGBubinStt.DataController.Values[i, 1] = '1') and
((cxGBubinStt.DataController.Values[i, 5] = sGubun1) or (cxGBubinStt.DataController.Values[i, 5] = sGubun2)){ and
(cxGBubinStt.DataController.Values[i, 6] = sGubun3) } //완료 or 개인정산 중 웹열람 불가인 오더만
//일괄취소 시 웹열람도 불가로 변경 20210818 KHS.팀장님 지시
then
begin
Inc(iRow);
end;
end;
if (cxGBubinStt.DataController.Values[i, 1] = '1') then inc(iChkCnt);
end;
if ( cxGBubinStt.DataController.RecordCount = 0 ) or (iChkCnt < 1) then
begin
GMessagebox('선택된 오더가 없습니다.', CDMSE);
exit;
end;
if ( iRow = 0 ) then
begin
GMessagebox('선택된 오더가 모두 [' + sTmp + ']오더 입니다.' + #13#10 + #13#10
+ sBtnName + ' 하시려면 [' + sGubun1 + ']오더를 선택하여 주십시오', CDMSE);
Exit;
end;
cxLabel175.Caption := IntToStr(iRow);
cxLabel176.Caption := '0';
Gauge1.Max := iRow;
Gauge1.Position := 0;
iRow := 0;
if Gauge1.Max > 1 then
begin
{ pnl_BubinAccStatus.Left := frm_Main.Left + ((frm_Main.Width - pnl_BubinAccStatus.Width) div 2);
pnl_BubinAccStatus.Top := 150;
pnl_BubinAccStatus.Visible := True;
pnl_BubinAccStatus.BringToFront; }
// pnl_BubinAccStatus.Left := frm_Main.Left + ((frm_Main.Width - pnl_BubinAccStatus.Width) div 2);
pnl_BubinAccStatus.Left := pnl_CUTB3.Left + ((pnl_CUTB3.Width - pnl_BubinAccStatus.Width) div 2);
pnl_BubinAccStatus.Top := 150;
pnl_BubinAccStatus.Visible := True;
pnl_BubinAccStatus.BringToFront;
end;
for i := 0 to cxGBubinStt.DataController.RecordCount - 1 do
begin
bTmp := False;
if iTag = 0 then
begin
if (cxGBubinStt.DataController.Values[i, 1] = '1') and (cxGBubinStt.DataController.Values[i,5] = sGubun1) then bTmp := True;
end else
if iTag = 1 then
begin
if (cxGBubinStt.DataController.Values[i, 1] = '1') and
((cxGBubinStt.DataController.Values[i, 5] = sGubun1) or (cxGBubinStt.DataController.Values[i, 5] = sGubun2)) {and
(cxGBubinStt.DataController.Values[i, 6] = sGubun3) } //완료 or 개인정산 중 웹열람 불가인 오더만
//일괄취소 시 웹열람도 불가로 변경 20210818 KHS.팀장님 지시
then bTmp := True;
end;
if bTmp then
begin
Application.ProcessMessages;
sSlip := cxGBubinStt.DataController.Values[i, 4];
sCharge := cxGBubinStt.DataController.Values[i, 25]; //접수요금
sAddCharge := cxGBubinStt.DataController.Values[i, 28]; //보정요금
sPassCharge := cxGBubinStt.DataController.Values[i, 30]; //경유요금
sWaitCharge := cxGBubinStt.DataController.Values[i, 31]; //대기요금
sBaseCharge := IntToStr(StrToIntDef(sCharge, 0) - StrToIntDef(sAddCharge, 0)
- StrToIntDef(sPassCharge, 0) - StrToIntDef(sWaitCharge, 0));
sCommission := cxGBubinStt.DataController.Values[i, 26]; //기사수수료
bTax := cxGBubinStt.DataController.Values[i, 43];
iSupply := StrToIntDef(sBaseCharge, 0) + StrToIntDef(sPassCharge, 0) + StrToIntDef(sWaitCharge, 0);
if bTax <> 'n' then
sTax := FloatToStr(iSupply * 0.1)
else
sTax := '0';
sSupply := IntToStr(iSupply);
sEtcCharge := cxGBubinStt.DataController.Values[i, 34];
sSum := IntToStr(iSupply + StrToIntDef(sTax, 0) + StrToIntDef(sEtcCharge, 0));
//QUERY.XML 전문을 사용하여 업데이트 한다.
ls_TxLoad := GTx_UnitXmlLoad('QUERY.XML');
fGet_BlowFish_Query(GSQ_CUST_BUBIN_ACCUPDATE, sQueryTemp);
ls_TxQry := Format(sQueryTemp, [sSupply, sTax, sBaseCharge, sSlip]);
//일괄정산취소 20210714KHS
if iTag = 1 then
begin
ls_TxQry := StringReplace(ls_TxQry, 'APPROVAL_YN=''y''', 'APPROVAL_YN=''n''', [rfReplaceAll]);
//웹열람불가처리 추가 20210818KHS 팀장님 지시
ls_TxQry := StringReplace(ls_TxQry, 'APPROVAL_YN=''n''', 'APPROVAL_YN=''n'', WEBVIEW_YN = ''n''', [rfReplaceAll]);
end;
ls_TxLoad := StringReplace(ls_TxLoad, 'UserIDString', GT_USERIF.ID, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientVerString', VERSIONINFO, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientKeyString', 'BUBINACCUPDATE', [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'QueryString', ls_TxQry, [rfReplaceAll]);
slReceive := TStringList.Create;
try
if dm.SendSock(ls_TxLoad, slReceive, ErrCode, False) then
begin
rv_str := slReceive[0];
if rv_str <> '' then
begin
ls_rxxml := rv_str;
xdom := ComsDomDocument.Create;
try
if xdom.loadXML(ls_rxxml) then
begin
if (0 < GetXmlRecordCount(ls_rxxml)) then
begin
Inc(iRow);
cxLabel176.Caption := IntToStr(iRow);
Gauge1.Position := iRow;
cxGBubinStt.DataController.Values[i, 1] := '0';
cxGBubinStt.DataController.Values[i, 5] := sTmp;
if iTag = 1 then cxGBubinStt.DataController.Values[i, 6] := sGubun3; //일괄취소일때만 웹열람 불가로 표기
cxGBubinStt.DataController.Values[i, 29] := sBaseCharge;
cxGBubinStt.DataController.Values[i, 32] := sSupply;
cxGBubinStt.DataController.Values[i, 33] := sTax;
cxGBubinStt.DataController.Values[i, 35] := sSum;
end;
end;
finally
xdom := Nil;
end;
end;
end;
finally
FreeAndNil(slReceive);
Frm_Flash.Hide;
end;
end;
cxGBubinStt.DataController.Values[i, 1] := '0';
end;
if (cxLabel175.Caption <> cxLabel176.Caption) then
begin
GMessagebox('실패한 정산이 있습니다.' + #13#10 + '다시한번 ' + sMsg + '을 눌러주세요', CDMSE);
pnl_BubinAccStatus.Visible := False;
end else
begin
GMessagebox(sMsg + ' 완료 하였습니다.', CDMSI);
pnl_BubinAccStatus.Visible := False;
end;
end;
procedure TFrm_CUT1.btn_14_6Click(Sender: TObject);
var
slList: TStringList;
sUrl, sSlip: string;
iRow, i: Integer;
begin
lbbubinAccPrintList.Items.Clear;
slList := TStringList.Create;
try
slList.Clear;
for i := 0 to cxGBubinStt.DataController.RecordCount - 1 do
begin
if (cxGBubinStt.DataController.Values[i, 1] = '1') then
begin
sSlip := cxGBubinStt.DataController.Values[i, 4];
if slList.Count <= 2 then
slList.Add(sSlip)
else
begin
slList.CommaText := slList.CommaText + '/3';
lbbubinAccPrintList.Items.Add(slList.CommaText);
slList.Clear;
slList.Add(sSlip);
end;
end;
end;
if slList.Count > 0 then
begin
slList.CommaText := slList.CommaText + '/' + IntToStr(slList.Count);
lbbubinAccPrintList.Items.Add(slList.CommaText);
end;
if lbbubinAccPrintList.Items.Count > 0 then
begin
iRow := lbbubinAccPrintList.Items.count - 1;
cxcbBubinAccPage.Tag := 99;
cxcbBubinAccPage.Properties.Items.Clear;
for i := 0 to iRow do
cxcbBubinAccPage.Properties.Items.Add(IntToStr(i + 1) + ' Page');
cxcbBubinAccPage.ItemIndex := 0;
cxcbBubinAccPage.Tag := 0;
if (GS_PRJ_AREA = 'S') then sUrl := Format(GS_BUBIN_URL_PRINT, [lbbubinAccPrintList.Items.Strings[cxcbBubinAccPage.ItemIndex]]) else
if (GS_PRJ_AREA = 'O') then sUrl := Format(GS_BUBIN_URL_PRINT_JI, [lbbubinAccPrintList.Items.Strings[cxcbBubinAccPage.ItemIndex]]);
WebBrowser1.Navigate(sUrl);
cxLabel165.Caption := IntToStr(lbbubinAccPrintList.Items.count);
pnlBubinAccPrt.Left := (Self.Width - pnlBubinAccPrt.Width) div 2;
pnlBubinAccPrt.Left := ((Self.Height - pnlBubinAccPrt.Height) div 2) - 30;
pnlBubinAccPrt.Visible := True;
pnlBubinAccPrt.BringToFront;
end else
begin
GMessagebox('선택된 오더가 없습니다.', CDMSE);
end;
finally
slList.Free;
end;
end;
procedure TFrm_CUT1.btn_14_7Click(Sender: TObject);
begin
try
WebBrowser1.ExecWB(OLECMDID_PRINTPREVIEW, OLECMDEXECOPT_DONTPROMPTUSER);
finally
end;
end;
procedure TFrm_CUT1.btn_14_8Click(Sender: TObject);
procedure PrintPage;
begin
Application.ProcessMessages;
WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER);
end;
var i : integer;
begin
try
if chk_AllPrint.checked then //전체출력 기능테스트. 페이징 되는 시점에 비해 출력이 너무빨리 진행됨. 2019.04.02 KHS
begin
Frm_Flash.Show;
Sleep(10);
Frm_Flash.BringToFront;
Frm_Flash.cxPBar1.Properties.Max := cxcbBubinAccPage.properties.items.count -1;
Frm_Flash.cxPBar1.Position := 0;
cxcbBubinAccPage.Tag := 99;
cxcbBubinAccPage.ItemIndex := -1;
cxcbBubinAccPage.Tag := 0;
for i := 0 to cxcbBubinAccPage.properties.items.count -1 do
begin
Frm_Flash.cxPBar1.Position := I + 1;
Frm_Flash.lblCnt.Caption := IntToStr(I + 1) + '/' + IntToStr(cxcbBubinAccPage.properties.items.count);
Application.ProcessMessages;
cxcbBubinAccPage.ItemIndex := i;
if i = cxcbBubinAccPage.properties.items.count -1 then
sleep(500);
end;
Frm_Flash.Hide;
if cxcbBubinAccPage.properties.items.count > 0 then GMessagebox('인쇄를 요청했습니다.', CDMSI);
end else //개별출력
begin
WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER);
GMessagebox('인쇄를 요청했습니다.', CDMSI);
end;
finally
end;
end;
procedure TFrm_CUT1.btn_14_9Click(Sender: TObject);
begin
try
WebBrowser1.ExecWB(OLECMDID_SAVEAS, OLECMDEXECOPT_PROMPTUSER);
finally
end;
end;
procedure TFrm_CUT1.btn_15_1Click(Sender: TObject);
var
sHdNo, sBrNo, sWhere, sQry, sTable, ls_TxQry, ls_TxLoad, sQueryTemp: string; // XML File Load
slReceive : TStringList;
ErrCode: integer;
begin
if (GT_SEL_BRNO.GUBUN = '0') and (not Check_ALLHD(GT_SEL_BRNO.HDNO)) then
begin
GMessagebox('해당본사에 대한 전체 권한이 없습니다.' + #13#10 + '지사를 선택하여 주십시오.', CDMSE);
Exit;
end;
if (GT_USERIF.LV = '10') and ((GT_SEL_BRNO.GUBUN <> '1') or (GT_SEL_BRNO.BrNo <> GT_USERIF.BR)) then
begin
GMessagebox('상담원 권한은 소속 지사만 조회할수 있습니다.', CDMSE);
Exit;
end;
if fGetChk_Search_HdBrNo('법인인증') then Exit;
if GT_USERIF.LV = '60' then
begin
if GT_SEL_BRNO.GUBUN <> '1' then
begin
sHdNo := GT_SEL_BRNO.HDNO;
sBrNo := '';
end else
if GT_SEL_BRNO.GUBUN = '1' then
begin
sHdNo := GT_SEL_BRNO.HDNO;
sBrNo := GT_SEL_BRNO.BrNo;
end;
end else
begin
sHdNo := GT_USERIF.HD;
sBrNo := GT_USERIF.BR;
end;
//////////////////////////////////////////////////////////////////////////////
// 법인>법인인증]1000건/A100-B100/요청리스트/대표번호:전체/이용기간:20100101~20100131
FExcelDownBubinAuth := Format('%s/%s/대표번호:%s/이용기간:%s~%s',
[
GetSelBrInfo
, IfThen(rbBubinAuth01.Checked, rbBubinAuth01.Caption, rbBubinAuth02.Caption)
, cbKeynumber15.Text
, cxDate22.Text, cxDate23.Text
]);
//////////////////////////////////////////////////////////////////////////////
sWhere := '';
if sBrNo <> '' then
sWhere := Format(' AND A.CONF_HEAD = ''%s'' AND A.CONF_BRCH = ''%s'' ',[sHdNo, sBrNo])
else
sWhere := Format(' AND A.CONF_HEAD = ''%s'' ',[sHdNo]);
if (cbKeynumber15.Text <> '전체') and (cbKeynumber15.Text <> '') then
sWhere := sWhere + format(' AND (A.KEY_NUMBER = ''%s'') ',[StringReplace(cbKeynumber15.Text,'-','',[rfReplaceAll])]);
if rbBubinAuthchkDate02.Checked then
sWhere := sWhere + format(' AND TO_CHAR(A.IN_DATE,''YYYYMMDDHH24MISS'') BETWEEN ''%s090000'' AND ''%s090000'' ', [formatdatetime('yyyymmdd',cxDate22.Date),formatdatetime('yyyymmdd',cxDate23.Date)]);
if edBubinSearch.Text <> '' then
begin
case cbBubinWk.ItemIndex of
0 : sQry := ' AND A.CONF_WK_SABUN || A.CONF_WORKER ';
1 : sQry := ' AND A.CONF_USER ';
2 : sQry := ' AND A.CONF_CUST_TEL ';
3 : sQry := ' AND A.CONF_SLIP ';
4 :
begin
if rbBubinAuth01.Checked then
sQry := ' AND A.CONF_INFO '
else if rbBubinAuth02.Checked then
sQry := ' AND B.CONF_INFO ';
end;
end;
sWhere := sWhere + sQry + Format('LIKE ''%s%s%s'' ', ['%', Param_Filtering(edBubinSearch.Text), '%']);
end;
if rbBubinAuth01.Checked then
begin
if (edBubinArea.Text <> '') and (cbBubinArea.ItemIndex = 0) then
sWhere := sWhere + format(' AND A.CONF_AREA || A.CONF_AREA2 || A.CONF_AREA3 || A.CONF_AREA5 LIKE ''%s%s%s'' ',['%', Param_Filtering(edBubinArea.Text), '%'])
else if (edBubinArea.Text <> '') and (cbBubinArea.ItemIndex = 1) then
sWhere := sWhere + format(' AND A.CONF_EDAREA || A.CONF_EDAREA2 || A.CONF_EDAREA3 || A.CONF_EDAREA5 LIKE ''%s%s%s'' ',['%', Param_Filtering(edBubinArea.Text),'%']);
end else if rbBubinAuth02.Checked then
begin
if (edBubinArea.Text <> '') and (cbBubinArea.ItemIndex = 0) then
sWhere := sWhere + format(' AND B.DEPART LIKE ''%s%s%s'' ',['%', Param_Filtering(edBubinArea.Text),'%'])
else if (edBubinArea.Text <> '') and (cbBubinArea.ItemIndex = 1) then
sWhere := sWhere + format(' AND B.DEST LIKE ''%s%s%s'' ',['%', Param_Filtering(edBubinArea.Text),'%']);
end;
if rbBubinAuthchkDate01.Checked then
sTable := 'CDMS_A01_TODAY '
else if rbBubinAuthchkDate02.Checked then
sTable := 'CDMS_A01 ';
ls_TxLoad := GTx_UnitXmlLoad('SEL02.XML');
if rbBubinAuth01.Checked then
begin
fGet_BlowFish_Query(GSQ_BUBIN_REQ, sQueryTemp);
ls_TxQry := Format(sQueryTemp, [sTable, sWhere]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientKeyString', 'BREQL00020', [rfReplaceAll]);
end else
if rbBubinAuth02.Checked then
begin
fGet_BlowFish_Query(GSQ_BUBIN_ACC, sQueryTemp);
ls_TxQry := Format(sQueryTemp, [sTable, sWhere]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientKeyString', 'BACCL00021', [rfReplaceAll]);
end;
ls_TxLoad := StringReplace(ls_TxLoad, 'UserIDString', '', [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientVerString', VERSIONINFO, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'QueryString', ls_TxQry, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'PagingString', '5000', [rfReplaceAll]);
Screen.Cursor := crHourGlass;
cxPageControl1.Enabled := False;
slReceive := TStringList.Create;
try
frm_Main.proc_SocketWork(False);
if dm.SendSock(ls_TxLoad, slReceive, ErrCode, False, 30000) then
begin
Application.ProcessMessages;
proc_recieve(slReceive);
Screen.Cursor := crDefault;
end;
finally
frm_Main.proc_SocketWork(True);
FreeAndNil(slReceive);
Screen.Cursor := crDefault;
cxPageControl1.Enabled := True;
Frm_Flash.Hide;
end;
end;
procedure TFrm_CUT1.btn_15_2Click(Sender: TObject);
begin
if cxGBubinAuth.DataController.RecordCount = 0 then
begin
GMessagebox('자료가 없습니다.', CDMSE);
Exit;
end;
if GT_USERIF.Excel_Use = 'n' then
begin
ShowMessage('[엑셀다운로드허용] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
if TCK_USER_PER.COM_CustExcelDown <> '1' then
begin
ShowMessage('[조회고객엑셀다운] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
Frm_Main.sgExcel := '고객_법인인증.xls';
Frm_Main.sgRpExcel := Format('법인>법인인증]%s건/%s', [GetMoneyStr(cxGBubinAuth.DataController.RecordCount), FExcelDownBubinAuth]);
Frm_Main.cxGridExcel := cxGrid12;
Frm_Main.bgExcelOPT := False;
Frm_Main.proc_excel(0);
end;
procedure TFrm_CUT1.btn_16_1Click(Sender: TObject);
var
XmlData, Param, ErrMsg, sHdNo, sBrNo : string;
xdom: msDomDocument;
lst_Count, lst_Result: IXMLDomNodeList;
ls_Rcrd : TStringList;
i, ErrCode, iRow : Integer;
begin
if fGetChk_Search_HdBrNo('기사원천징수현황') then Exit;
try
Param := '';
Param := Param + FormatDateTime('yyyymmdd', cxDate16_1S.Date) + '│';
Param := Param + FormatDateTime('yyyymmdd', cxDate16_1E.Date) + '│';
Param := Param + IntToStr(cxComboBox4.ItemIndex) + '│';
if GT_USERIF.LV = '60' then
begin
if GT_SEL_BRNO.GUBUN <> '1' then
begin
sHdNo := GT_SEL_BRNO.HDNO;
sBrNo := '';
end else
if GT_SEL_BRNO.GUBUN = '1' then
begin
sHdNo := GT_SEL_BRNO.HDNO;
sBrNo := GT_SEL_BRNO.BrNo;
end;
end else
begin
sHdNo := GT_USERIF.HD;
sBrNo := GT_USERIF.BR;
end;
Param := Param + sHdNo + '│' + sBrNo + '│';
Param := Param + IntToStr(cxComboBox5.ItemIndex) + '│';
if rbo_WKTOT.Checked then
Param := Param + '0' + '│'
else
if rbo_WKDayByDay.Checked then
Param := Param + '1' + '│';
Param := Param + IntToStr(cxComboBox6.ItemIndex);
Screen.Cursor := crHourGlass;
cxPageControl1.Enabled := False;
if not RequestBase(GetSel05('MNG_CALC', 'MNG_CALC.LIST_TAX_STATS_KEYNUM', '10000', Param), XmlData, ErrCode, ErrMsg) then
begin
GMessagebox(Format('기사원천징수현황 조회 중 오류발생'#13#10'[%d]%s', [ErrCode, ErrMsg]), CDMSE);
cxPageControl1.Enabled := True;
Exit;
end;
xdom := ComsDomDocument.Create;
try
xdom.loadXML(XmlData);
if not xdom.loadXML(XmlData) then
begin
cxPageControl1.Enabled := True;
Exit;
end;
lst_Count := xdom.documentElement.selectNodes('/cdms/Service/Data');
if StrToIntDef(lst_Count.item[0].attributes.getNamedItem('Count').Text,0) > 0 then
begin
if rbo_WKTOT.Checked then
begin
cxViewWithholdingTax.Columns[7].Visible := False;
cxViewWithholdingTax.Columns[8].Visible := False;
end
else if rbo_WKDayByDay.Checked then
begin
cxViewWithholdingTax.Columns[7].Visible := True;
cxViewWithholdingTax.Columns[8].Visible := True;
end;
cxViewWithholdingTax.DataController.SetRecordCount(0);
lst_Result := xdom.documentElement.selectNodes('/cdms/Service/Data/Result');
ls_Rcrd := TStringList.Create;
cxViewWithholdingTax.BeginUpdate;
try
cxViewWithholdingTax.Columns[0].SortOrder := soAscending;
cxViewWithholdingTax.Columns[0].SortIndex := 0;
for I := 0 to lst_Result.length - 1 do
begin
GetTextSeperationEx2('│', lst_Result.item[I].attributes.getNamedItem('Value').Text, ls_Rcrd);
iRow := cxViewWithholdingTax.DataController.AppendRecord;
cxViewWithholdingTax.DataController.Values[iRow, 0] := inttostr(iRow + 1);
cxViewWithholdingTax.DataController.Values[iRow, 1] := ls_Rcrd[0];
cxViewWithholdingTax.DataController.Values[iRow, 2] := ls_Rcrd[1];
cxViewWithholdingTax.DataController.Values[iRow, 3] := ls_Rcrd[2];
if Length(ls_Rcrd[3]) > 7 then
cxViewWithholdingTax.DataController.Values[iRow, 4] := Copy(ls_Rcrd[3], 1, 6) + '-' + Copy(ls_Rcrd[3], 7, 7)
else
cxViewWithholdingTax.DataController.Values[iRow, 4] := ls_Rcrd[3];
cxViewWithholdingTax.DataController.Values[iRow, 5] := ls_Rcrd[4];
if rbo_WKTOT.Checked then
begin
cxViewWithholdingTax.DataController.Values[iRow, 6] := ls_Rcrd[10];
cxViewWithholdingTax.DataController.Values[iRow, 7] := '';
cxViewWithholdingTax.DataController.Values[iRow, 8] := '';
cxViewWithholdingTax.DataController.Values[iRow, 9] := ls_Rcrd[5];
cxViewWithholdingTax.DataController.Values[iRow,10] := StrToIntDef(ls_rcrd[6], 0);
cxViewWithholdingTax.DataController.Values[iRow,11] := StrToIntDef(ls_rcrd[7], 0);
cxViewWithholdingTax.DataController.Values[iRow,12] := StrToIntDef(ls_rcrd[8], 0);
cxViewWithholdingTax.DataController.Values[iRow,13] := StrToIntDef(ls_rcrd[9], 0);
end else
if rbo_WKDayByDay.Checked then
begin
cxViewWithholdingTax.DataController.Values[iRow, 6] := ls_Rcrd[12];
cxViewWithholdingTax.DataController.Values[iRow, 7] := ls_Rcrd[10];
cxViewWithholdingTax.DataController.Values[iRow, 8] := ls_Rcrd[11];
cxViewWithholdingTax.DataController.Values[iRow, 9] := ls_Rcrd[5];
cxViewWithholdingTax.DataController.Values[iRow,10] := StrToIntDef(ls_rcrd[6], 0);
cxViewWithholdingTax.DataController.Values[iRow,11] := StrToIntDef(ls_rcrd[7], 0);
cxViewWithholdingTax.DataController.Values[iRow,12] := StrToIntDef(ls_rcrd[8], 0);
cxViewWithholdingTax.DataController.Values[iRow,13] := StrToIntDef(ls_rcrd[9], 0);
end;
end;
finally
cxViewWithholdingTax.EndUpdate;
ls_Rcrd.Free;
Screen.Cursor := crDefault;
Frm_Flash.Hide;
end;
end else
cxViewWithholdingTax.DataController.SetRecordCount(0);
finally
Screen.Cursor := crDefault;
cxPageControl1.Enabled := True;
xdom := Nil;
end;
except
on e: exception do
begin
Screen.Cursor := crDefault;
cxPageControl1.Enabled := True;
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.btn_16_2Click(Sender: TObject);
begin
if cxViewWithholdingTax.DataController.RecordCount = 0 then
begin
GMessagebox('자료가 없습니다.', CDMSE);
Exit;
end;
if GT_USERIF.Excel_Use = 'n' then
begin
ShowMessage('[엑셀다운로드허용] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
if TCK_USER_PER.COM_CustExcelDown <> '1' then
begin
ShowMessage('[조회고객엑셀다운] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
Frm_Main.sgExcel := '법인_기사원천징수.xls';
Frm_Main.sgRpExcel := Format('법인>기사원천징수]%s건/%s', [GetMoneyStr(cxViewWithholdingTax.DataController.RecordCount), FExcelDownWithHolding]);
Frm_Main.cxGridExcel := cxGrid15;
Frm_Main.bgExcelOPT := False;
Frm_Main.proc_excel(0);
end;
procedure TFrm_CUT1.btn_18_1Click(Sender: TObject);
var sBrNo : String;
ErrCode, iRow, i, j, iCnt: integer;
Param, ErrMsg, XmlData: string;
xdom: MSDomDocument;
ls_MSG_Err: string;
ls_Rcrd, slList: TStringList;
ls_rxxml, sTmp: string;
lst_Count, lst_Result: IXMLDomNodeList;
begin
Try
sBrNo := Func_CheckBrNo;
if StartDateTime('yyyymmdd') = FormatDateTime('yyyymmdd', cxDate18_1S.Date) then
Param := 'CDMS_A01_TODAY'
else
Param := 'CDMS_A01';
Param := Param + '│' + FormatDateTime('yyyymmdd', cxDate18_1S.Date) + '090000';
Param := Param + '│' + FormatDateTime('yyyymmdd', cxDate18_1E.Date) + '090000';
Param := Param + '│' + sBrNo;
if cbWhere18.ItemIndex = 0 then Param := Param + '││'
else Param := Param + '│' + IntToStr(cbWhere18.ItemIndex) + '│' + edtKeyword18.Text;
cxPageControl1.Enabled := False;
Screen.Cursor := crHourGlass;
slList := TStringList.Create;
Try
if not RequestBasePaging(GetSEL06('GET_BGROUP_ORDER_DAYCLOSE', 'MNG_BGROUP.GET_BGROUP_ORDER_DAYCLOSE', '1000', Param), slList, ErrCode, ErrMsg) then
begin
GMessagebox(Format('일마감 조회 오류'#13#10'[%d]%s', [ErrCode, ErrMsg]), CDMSE);
Screen.Cursor := crDefault;
cxPageControl1.Enabled := True;
FreeAndNil(slList);
Exit;
end;
xdom := ComsDomDocument.Create;
try
Frm_Flash.cxPBar1.Properties.Max := slList.Count;
Frm_Flash.cxPBar1.Position := 0;
cxGrid_Angel2.DataController.SetRecordCount(0);
for i := 0 to cxGrid_Angel2.ColumnCount - 1 do
begin
cxGrid_Angel2.Columns[i].SortIndex := -1;
cxGrid_Angel2.Columns[i].SortOrder := soNone;
end;
for j := 0 to slList.Count - 1 do
begin
Frm_Flash.cxPBar1.Position := j + 1;
Frm_Flash.lblCnt.Caption := IntToStr(j + 1) + '/' + IntToStr(slList.Count);
Application.ProcessMessages;
xmlData := slList.Strings[j];
xdom.loadXML(XmlData);
lst_Count := xdom.documentElement.selectNodes('/cdms/Service/Data');
if StrToIntDef(lst_Count.item[0].attributes.getNamedItem('Count').Text, 0) > 0 then
begin
lst_Result := xdom.documentElement.selectNodes('/cdms/Service/Data/Result');
ls_Rcrd := TStringList.Create;
cxGrid_Angel2.BeginUpdate;
try
for I := 0 to lst_Result.length - 1 do
begin
GetTextSeperationEx2('│', lst_Result.item[I].attributes.getNamedItem('Value').Text, ls_Rcrd);
///////////////////////////정산전용 엑셀//////////////////////////////
iRow := cxGrid_Angel2.DataController.AppendRecord;
ls_Rcrd.Insert(0, IntToStr(iRow + 1));
cxGrid_Angel2.DataController.Values[iRow, 0] := ls_Rcrd[ 0]; //순번
cxGrid_Angel2.DataController.Values[iRow, 1] := ls_Rcrd[ 1]; //접수번호
//영업일일자 계산
//ls_Rcrd[44] //접수일자
sTmp := StringReplace(ls_Rcrd[44], ' ', '', [rfReplaceAll]); //in_date 기준으로 변경 20210707KHS 이병규이사요청
sTmp := StringReplace(sTmp, '-', '', [rfReplaceAll]);
sTmp := StringReplace(sTmp, ':', '', [rfReplaceAll]);
sTmp := func_JON03SalesDate(sTmp);
cxGrid_Angel2.DataController.Values[iRow, 2] := sTmp; //영업일
cxGrid_Angel2.DataController.Values[iRow, 3] := ls_Rcrd[ 2]; //접수일시-최초접수일시
cxGrid_Angel2.DataController.Values[iRow, 4] := ls_Rcrd[ 3]; //지사명
if ls_Rcrd[ 4] = 'y' then sTmp := '탁송' else sTmp := '대리';
cxGrid_Angel2.DataController.Values[iRow, 5] := sTmp; //서비스명
if ls_Rcrd[ 5] = '2' then sTmp := '완료' else
if ls_Rcrd[ 5] = '4' then sTmp := '문의' else
if ls_Rcrd[ 5] = '8' then sTmp := '취소' else
if ls_Rcrd[ 5] = '0' then sTmp := '접수' else
if ls_Rcrd[ 5] = '1' then sTmp := '배차' else
if ls_Rcrd[ 5] = '3' then sTmp := '강제' else
if ls_Rcrd[ 5] = '5' then sTmp := '대기' else
if ls_Rcrd[ 5] = 'R' then sTmp := '예약';
cxGrid_Angel2.DataController.Values[iRow, 6] := sTmp ; //접수상태- 오더상태
cxGrid_Angel2.DataController.Values[iRow, 7] := '법인'; //법인/일반 무조건 법인만 조회된다고 함. 서승우과장
cxGrid_Angel2.DataController.Values[iRow, 8] := ls_Rcrd[ 6]; //고객명
cxGrid_Angel2.DataController.Values[iRow, 9] := ls_Rcrd[ 7]; //고객직책
cxGrid_Angel2.DataController.Values[iRow, 10] := strtocall(ls_Rcrd[ 8]); //고객전화번호
cxGrid_Angel2.DataController.Values[iRow, 11] := ls_Rcrd[ 9]; //업체 ID-법인코드
cxGrid_Angel2.DataController.Values[iRow, 12] := ls_Rcrd[10]; //업체명
cxGrid_Angel2.DataController.Values[iRow, 13] := ls_Rcrd[11]; //접수자
cxGrid_Angel2.DataController.Values[iRow, 14] := ls_Rcrd[12]; //접수취소사유
cxGrid_Angel2.DataController.Values[iRow, 15] := ls_Rcrd[13]; //기사ID
cxGrid_Angel2.DataController.Values[iRow, 16] := ls_Rcrd[14]; //기사사번
cxGrid_Angel2.DataController.Values[iRow, 17] := ls_Rcrd[15]; //기사명
//본사5개소속이면 자기사(Y) 아님 타기사(N) "/"
//법인orKM프미기사(Y), 일반orKM일반기사(N)
//1. 콜마너 시스템에 등록된 엔젤소속(5개본사)된 기사들에 대해서는 "자기사(Y)" 로 처리 하고, 그외는 "타기사(N)" 그리고 콜마너 프리미엄기사는 Y 일반기사는 N 임.
//2. KM의 프리미엄기사가 배차 받았을때 "자기사(Y)" 이고 "법인기사(Y)" 임..
// ''/'/3. KM의 일반기사가 배차 받았을때 "자기사(N)" 이고 "법인기사(N)" 임..
// 5개본사 그외 KM프리미엄 KM일반기사
//자.타구분 Y N Y N
//법인구분 + Y Y Y
// - N N N
if ls_Rcrd[13] = '' then
cxGrid_Angel2.DataController.Values[iRow, 18] := ''
else
cxGrid_Angel2.DataController.Values[iRow, 18] := ls_Rcrd[16]; //자/타기사 구분
//기사없음일 경우 관련 항목 보무 빈값처리 20210329KHS 팀장님 지시
if ls_Rcrd[15] = '기사없음' then
begin
cxGrid_Angel2.DataController.Values[iRow, 15] := ''; //기사ID
cxGrid_Angel2.DataController.Values[iRow, 16] := ''; //기사사번
cxGrid_Angel2.DataController.Values[iRow, 17] := ''; //기사명
cxGrid_Angel2.DataController.Values[iRow, 18] := '';
end;
cxGrid_Angel2.DataController.Values[iRow, 19] := ls_Rcrd[17]; //배차시간
cxGrid_Angel2.DataController.Values[iRow, 20] := ls_Rcrd[18]; //대기시간
cxGrid_Angel2.DataController.Values[iRow, 21] := ls_Rcrd[19]; //운행종료시간
cxGrid_Angel2.DataController.Values[iRow, 22] := ls_Rcrd[20]; //출발지 POI
cxGrid_Angel2.DataController.Values[iRow, 23] := ls_Rcrd[21] + ' ' + ls_Rcrd[22] + ' ' + ls_Rcrd[23];//출발주소
cxGrid_Angel2.DataController.Values[iRow, 24] := ls_Rcrd[21]; //출발지 시/도
cxGrid_Angel2.DataController.Values[iRow, 25] := ls_Rcrd[22]; //출발지 구/군
cxGrid_Angel2.DataController.Values[iRow, 26] := ls_Rcrd[23]; //출발지 동/리
cxGrid_Angel2.DataController.Values[iRow, 27] := ls_Rcrd[24]; //도착지 POI
cxGrid_Angel2.DataController.Values[iRow, 28] := ls_Rcrd[25] + ' ' + ls_Rcrd[26] + ' ' + ls_Rcrd[27];//도착주소
cxGrid_Angel2.DataController.Values[iRow, 29] := ls_Rcrd[25]; //도착지 시/도
cxGrid_Angel2.DataController.Values[iRow, 30] := ls_Rcrd[26]; //도착지 구/군
cxGrid_Angel2.DataController.Values[iRow, 31] := ls_Rcrd[27]; //도착지 동/리
//<COL>^정자푸르지오시티3차오피스텔</COL><COL>^래미안강남힐즈아파트</COL>
sTmp := ls_Rcrd[28];
sTmp := StringReplace(sTmp, '<COL>', '', [rfReplaceAll]);
sTmp := StringReplace(sTmp, '</COL>', '', [rfReplaceAll]);
if Copy(sTmp, 1,1) = '^' then sTmp := Copy(sTmp, 2, Length(sTmp));
cxGrid_Angel2.DataController.Values[iRow, 32] := sTmp; //경유지
cxGrid_Angel2.DataController.Values[iRow, 33] := ls_Rcrd[29]; //주행거리
// 결제방식.[0현금, 2후불, 4외상, 3모바일(미사용), 7후불(카드), 8후불(마일), 9복합 ]
if ls_Rcrd[30] = '0' then sTmp := '현금' else
if ls_Rcrd[30] = '1' then sTmp := '마일리지' else
if ls_Rcrd[30] = '2' then sTmp := '후불' else
if ls_Rcrd[30] = '3' then sTmp := '모바일결제' else
if ls_Rcrd[30] = '4' then sTmp := '외상' else
if ls_Rcrd[30] = '5' then sTmp := '카드' else
if ls_Rcrd[30] = '6' then sTmp := '즉불' else
if ls_Rcrd[30] = '7' then sTmp := '후불(카드)' else
if ls_Rcrd[30] = '8' then sTmp := '후불(마일)' else
if ls_Rcrd[30] = '9' then sTmp := '복합' else sTmp := ls_Rcrd[30];
cxGrid_Angel2.DataController.Values[iRow, 34] := sTmp; //지불유형 //2
cxGrid_Angel2.DataController.Values[iRow, 35] := StrToIntDef(ls_Rcrd[31],0); //접수요금
cxGrid_Angel2.DataController.Values[iRow, 36] := StrToIntDef(ls_Rcrd[32],0); //경유요금
cxGrid_Angel2.DataController.Values[iRow, 37] := StrToIntDef(ls_Rcrd[33],0); //대기요금
cxGrid_Angel2.DataController.Values[iRow, 38] := StrToIntDef(ls_Rcrd[34],0); //기타비용
cxGrid_Angel2.DataController.Values[iRow, 39] := StrToIntDef(ls_Rcrd[35],0); //지원금
cxGrid_Angel2.DataController.Values[iRow, 40] := StrToIntDef(ls_Rcrd[36],0); //보정금
cxGrid_Angel2.DataController.Values[iRow, 41] := StrToIntDef(ls_Rcrd[37],0); //현금결제액
cxGrid_Angel2.DataController.Values[iRow, 42] := StrToIntDef(ls_Rcrd[38],0); //카드결제액
cxGrid_Angel2.DataController.Values[iRow, 43] := StrToIntDef(ls_Rcrd[39],0); //기사수수료
cxGrid_Angel2.DataController.Values[iRow, 44] := '20%'; //기사수수료율
cxGrid_Angel2.DataController.Values[iRow, 45] := ls_Rcrd[40]; //기사메모
cxGrid_Angel2.DataController.Values[iRow, 46] := ls_Rcrd[41]; //고객메모
cxGrid_Angel2.DataController.Values[iRow, 47] := ls_Rcrd[42]; //적요1
cxGrid_Angel2.DataController.Values[iRow, 48] := ls_Rcrd[43]; //적요2
end;
finally
ls_Rcrd.Free;
cxGrid_Angel2.EndUpdate;
end;
end else
begin
GMessagebox('검색된 내용이 없습니다.', CDMSE);
end;
end;
finally
xdom := Nil;
Frm_Flash.hide;
Screen.Cursor := crDefault;
cxPageControl1.Enabled := True;
FreeAndNil(slList);
end;
Finally
slList.Free;
End;
except
on E: Exception do
begin
FreeAndNil(slList);
Screen.Cursor := crDefault;
cxPageControl1.Enabled := True;
Assert(False, E.Message);
Frm_Flash.Hide;
end;
end;
end;
procedure TFrm_CUT1.btn_18_2Click(Sender: TObject);
begin
if cxGrid_Angel2.DataController.RecordCount = 0 then
begin
GMessagebox('자료가 없습니다.', CDMSE);
Exit;
end;
if GT_USERIF.Excel_Use = 'n' then
begin
ShowMessage('[엑셀다운로드허용] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
if TCK_USER_PER.COM_CustExcelDown <> '1' then
begin
ShowMessage('[조회고객엑셀다운] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
if chk_masking.checked then
begin
proc_Set_ExcelMasking;
Frm_Main.sgExcel := '법인_일마감.xlsx';
Frm_Main.sgRpExcel := Format('법인>일마감-엑셀출력]%s건/%s', [GetMoneyStr(cxGrid_Angel2_Masking.DataController.RecordCount), FExcelDownBubinDaily]);
Frm_Main.cxGridExcel := cxGrid2;
Frm_Main.cxGridDBViewExcel := cxGrid_Angel2_Masking;
Frm_Main.bgExcelOPT := False;
Frm_Main.proc_excel(8);
end else
begin
Frm_Main.sgExcel := '법인_일마감.xlsx';
Frm_Main.sgRpExcel := Format('법인>일마감-엑셀출력]%s건/%s', [GetMoneyStr(cxGrid_Angel2.DataController.RecordCount), FExcelDownBubinDaily]);
Frm_Main.cxGridExcel := cxGrid3;
Frm_Main.cxGridDBViewExcel := cxGrid_Angel2;
Frm_Main.bgExcelOPT := False;
Frm_Main.proc_excel(8);
end;
end;
procedure TFrm_CUT1.btn_18_3Click(Sender: TObject);
begin
proc_BrList(edt_18_1.Text);
end;
procedure TFrm_CUT1.cxButton1Click(Sender: TObject);
var ErrCode: integer;
Param, ErrMsg, XmlData, sTmp : string;
begin
if gsCustViewParam = '' then exit;
// if (Trim(edWebID.text) <> '') and (btn_WebId.Tag = 99) then
// begin
// GMessagebox('WebID 성성시 아이디체크를 하여야 합니다', CDMSE);
// btn_WebId.SetFocus;
// exit;
// end;
// if (length(edWebPW.Text) < 4) then
// begin
// GMessagebox('비밀번호는 4자 이상만 가능 합니다', CDMSE);
// edWebPW.SetFocus;
// exit;
// end else
// if (length(edWebPW.Text) > 20) then
// begin
// GMessagebox('비밀번호는 20자 이하만 가능 합니다', CDMSE);
// edWebPW.SetFocus;
// exit;
// end;
// if (Trim(edWebID.text) = '') and (length(edWebPW.Text) > 0) then
// begin
// GMessagebox('WebID를 먼저 생성하세요', CDMSE);
// edWebID.SetFocus;
// exit;
// end;
gsCustViewParam := StringReplace(gsCustViewParam, '<법인명]', Trim(edName01.Text), [rfReplaceAll]);
gsCustViewParam := StringReplace(gsCustViewParam, '<부서명]', Trim(edName03.text), [rfReplaceAll]);
gsCustViewParam := StringReplace(gsCustViewParam, '<법인상태메모]', Trim(edtCustStateMemo.Text), [rfReplaceAll]);
gsCustViewParam := StringReplace(gsCustViewParam, '<법인고객메모]', Trim(edtCustMemo.text), [rfReplaceAll]);
gsCustViewParam := StringReplace(gsCustViewParam, '<계약여부]', IntToStr(cb_Contract2.itemindex), [rfReplaceAll]);
gsCustViewParam := StringReplace(gsCustViewParam, '<계약일]', Trim(dtRegDate.text), [rfReplaceAll]);
gsCustViewParam := StringReplace(gsCustViewParam, '<계약종료일]', Trim(dtFinDate.text), [rfReplaceAll]);
if rb_SurtaxY.Checked then sTmp := 'y' else sTmp := 'n';
gsCustViewParam := StringReplace(gsCustViewParam, '<부가세포함]', Trim(sTmp), [rfReplaceAll]);
if rbList02.Checked then sTmp := '1' else if rbPayMethodPost.Checked then sTmp := '2' else sTmp := '0';
gsCustViewParam := StringReplace(gsCustViewParam, '<요금지불방식]', Trim(sTmp), [rfReplaceAll]);
gsCustViewParam := StringReplace(gsCustViewParam, '<아이디]', Trim(edWebID.text), [rfReplaceAll]);
gsCustViewParam := StringReplace(gsCustViewParam, '<비밀번호]', Trim(edWebPW.text), [rfReplaceAll]);
if not RequestBase(GetCallable06('SET_CUST_BGROUP', 'MNG_BGROUP.SET_CUST_BGROUP', En_Coding(gsCustViewParam)), XmlData, ErrCode, ErrMsg) then
begin
GMessagebox(Format('법인정보 저장중 오류가 발생하였습니다.'#13#10'[%d]%s', [ErrCode, ErrMsg]), CDMSE);
Exit;
end;
Frm_main.proc_bubinlist_insert; // 저장 후 법인 정보 재조회
GMessagebox('저장되었습니다.', CDMSI);
end;
procedure TFrm_CUT1.cxButton2Click(Sender: TObject);
begin
pnl_UseList.Visible := False;
end;
procedure TFrm_CUT1.cxButton3Click(Sender: TObject);
begin
pnl_CalCampInfo.Visible := False;
end;
procedure TFrm_CUT1.cxButton5Click(Sender: TObject);
var
IE: variant;
begin
IE := CreateOleObject('InternetExplorer.Application');
IE.left := 0;
IE.top := 0;
IE.Width := Screen.Width;
IE.Height := Screen.Height;
if (GS_PRJ_AREA = 'S') then IE.Navigate(GS_BUBIN_URL) else
if (GS_PRJ_AREA = 'O') then IE.Navigate(GS_BUBIN_URL_JI);
IE.Visible := true;
end;
procedure TFrm_CUT1.cxcbBubinAccPagePropertiesChange(Sender: TObject);
Var sUrl : String;
begin
if cxcbBubinAccPage.Tag = 99 then Exit;
if (GS_PRJ_AREA = 'S') then sUrl := Format(GS_BUBIN_URL_PRINT, [lbbubinAccPrintList.Items.Strings[cxcbBubinAccPage.ItemIndex]]) else
if (GS_PRJ_AREA = 'O') then sUrl := Format(GS_BUBIN_URL_PRINT_JI, [lbbubinAccPrintList.Items.Strings[cxcbBubinAccPage.ItemIndex]]);
WebBrowser1.Navigate(sUrl);
end;
procedure TFrm_CUT1.cxChkTitlePropertiesChange(Sender: TObject);
var
i: Integer;
ln_env: TIniFile;
sTemp: string;
begin
try
if TcxCheckComboBox(Sender).Tag = 1 then
Exit;
ln_Env := TIniFile.Create(ENVPATHFILE);
ln_env.EraseSection('ACCBubinList');
cxGBubinStt.BeginUpdate;
for i := 0 to cxChkTitle.Properties.Items.Count - 1 do
begin
sTemp := cxChkTitle.Properties.Items[i].Description;
if cxChkTitle.GetItemState(i) = cbsUnchecked then
begin
ln_env.WriteString('ACCBubinList', sTemp, '1');
cxGBubinStt.Bands[i].Visible := False;
chkCust14Type01.Tag := 1;
chkCust14Type01.Checked := False;
chkCust14Type01.Tag := 0;
end else
begin
cxGBubinStt.Bands[i].Visible := True;
end;
end;
FreeAndNil(ln_env);
cxGBubinStt.EndUpdate;
except
end;
end;
procedure TFrm_CUT1.cxColCGColorStylesGetContentStyle(
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
AItem: TcxCustomGridTableItem; var AStyle: TcxStyle);
var
Idx: Integer;
begin
Idx := Sender.DataController.GetRowInfo(ARecord.Index).RecordIndex;
AStyle := stlCustLevelColor;
AStyle.Color := Hex6ToColor(Sender.DataController.Values[Idx, AItem.Index]);
end;
procedure TFrm_CUT1.cxColGLColorStylesGetContentStyle(
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
AItem: TcxCustomGridTableItem; var AStyle: TcxStyle);
var
Idx: Integer;
begin
Idx := Sender.DataController.GetRowInfo(ARecord.Index).RecordIndex;
if Sender.DataController.Values[Idx, AItem.Index] = Null then
Exit;
AStyle := stlCustLevelColor;
AStyle.Color := Hex6ToColor(Sender.DataController.Values[Idx, AItem.Index]);
end;
procedure TFrm_CUT1.cxDate18_1EKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key = vk_Return then btn_18_1.click;
end;
procedure TFrm_CUT1.cxDate18_1SKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key = vk_Return then cxDate18_1E.SetFocus;
end;
procedure TFrm_CUT1.cxdBubinSttSearchKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Ord(Key) = VK_RETURN then
btn_14_1Click(btn_14_1);
end;
procedure TFrm_CUT1.cxGBubinSttBands0HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 0 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[0].SortOrder = soNone) or
(cxGBubinStt.Columns[0].SortOrder =
soDescending) then
cxGBubinStt.Columns[0].SortOrder := soAscending
else
if cxGBubinStt.Columns[0].SortOrder = soAscending then
cxGBubinStt.Columns[0].SortOrder := soDescending;
cxGBubinStt.Columns[0].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands10HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 11 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[11].SortOrder = soNone) or
(cxGBubinStt.Columns[11].SortOrder = soDescending) then
cxGBubinStt.Columns[11].SortOrder := soAscending
else
if cxGBubinStt.Columns[11].SortOrder = soAscending then
cxGBubinStt.Columns[11].SortOrder := soDescending;
cxGBubinStt.Columns[11].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands11HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 12 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[12].SortOrder = soNone) or
(cxGBubinStt.Columns[12].SortOrder =
soDescending) then
cxGBubinStt.Columns[12].SortOrder := soAscending
else
if cxGBubinStt.Columns[12].SortOrder = soAscending then
cxGBubinStt.Columns[12].SortOrder := soDescending;
cxGBubinStt.Columns[12].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands12HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 13 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[13].SortOrder = soNone) or
(cxGBubinStt.Columns[13].SortOrder =
soDescending) then
cxGBubinStt.Columns[13].SortOrder := soAscending
else
if cxGBubinStt.Columns[13].SortOrder = soAscending then
cxGBubinStt.Columns[13].SortOrder := soDescending;
cxGBubinStt.Columns[13].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands13HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 14 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[14].SortOrder = soNone) or
(cxGBubinStt.Columns[14].SortOrder =
soDescending) then
cxGBubinStt.Columns[14].SortOrder := soAscending
else
if cxGBubinStt.Columns[14].SortOrder = soAscending then
cxGBubinStt.Columns[14].SortOrder := soDescending;
cxGBubinStt.Columns[14].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands14HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 15 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[15].SortOrder = soNone) or
(cxGBubinStt.Columns[15].SortOrder =
soDescending) then
cxGBubinStt.Columns[15].SortOrder := soAscending
else
if cxGBubinStt.Columns[15].SortOrder = soAscending then
cxGBubinStt.Columns[15].SortOrder := soDescending;
cxGBubinStt.Columns[15].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands15HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 16 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[16].SortOrder = soNone) or
(cxGBubinStt.Columns[16].SortOrder =
soDescending) then
cxGBubinStt.Columns[16].SortOrder := soAscending
else
if cxGBubinStt.Columns[16].SortOrder = soAscending then
cxGBubinStt.Columns[16].SortOrder := soDescending;
cxGBubinStt.Columns[16].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands16HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 17 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[17].SortOrder = soNone) or
(cxGBubinStt.Columns[17].SortOrder =
soDescending) then
cxGBubinStt.Columns[17].SortOrder := soAscending
else
if cxGBubinStt.Columns[17].SortOrder = soAscending then
cxGBubinStt.Columns[17].SortOrder := soDescending;
cxGBubinStt.Columns[17].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands17HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 18 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[18].SortOrder = soNone) or
(cxGBubinStt.Columns[18].SortOrder =
soDescending) then
cxGBubinStt.Columns[18].SortOrder := soAscending
else
if cxGBubinStt.Columns[18].SortOrder = soAscending then
cxGBubinStt.Columns[18].SortOrder := soDescending;
cxGBubinStt.Columns[18].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands18HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 19 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[19].SortOrder = soNone) or
(cxGBubinStt.Columns[19].SortOrder =
soDescending) then
cxGBubinStt.Columns[19].SortOrder := soAscending
else
if cxGBubinStt.Columns[19].SortOrder = soAscending then
cxGBubinStt.Columns[19].SortOrder := soDescending;
cxGBubinStt.Columns[19].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands19HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 42 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[42].SortOrder = soNone) or
(cxGBubinStt.Columns[42].SortOrder =
soDescending) then
cxGBubinStt.Columns[42].SortOrder := soAscending
else
if cxGBubinStt.Columns[42].SortOrder = soAscending then
cxGBubinStt.Columns[42].SortOrder := soDescending;
cxGBubinStt.Columns[42].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands1HeaderClick(Sender: TObject);
var
i: Integer;
begin
if chkBubinStt.Checked then
begin
chkBubinStt.Checked := False;
end else
begin
chkBubinStt.Checked := True;
end;
cxGBubinStt.BeginUpdate;
for i := 0 to cxGBubinStt.DataController.RecordCount - 1 do
begin
if chkBubinStt.Checked then
cxGBubinStt.DataController.Values[i, 1] := '1'
else
cxGBubinStt.DataController.Values[i, 1] := '0';
end;
cxGBubinStt.EndUpdate;
end;
procedure TFrm_CUT1.cxGBubinSttBands21HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 20 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[20].SortOrder = soNone) or
(cxGBubinStt.Columns[20].SortOrder =
soDescending) then
cxGBubinStt.Columns[20].SortOrder := soAscending
else
if cxGBubinStt.Columns[20].SortOrder = soAscending then
cxGBubinStt.Columns[20].SortOrder := soDescending;
cxGBubinStt.Columns[20].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands22HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 21 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[21].SortOrder = soNone) or
(cxGBubinStt.Columns[21].SortOrder =
soDescending) then
cxGBubinStt.Columns[21].SortOrder := soAscending
else
if cxGBubinStt.Columns[21].SortOrder = soAscending then
cxGBubinStt.Columns[21].SortOrder := soDescending;
cxGBubinStt.Columns[21].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands23HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 22 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[22].SortOrder = soNone) or
(cxGBubinStt.Columns[22].SortOrder =
soDescending) then
cxGBubinStt.Columns[22].SortOrder := soAscending
else
if cxGBubinStt.Columns[22].SortOrder = soAscending then
cxGBubinStt.Columns[22].SortOrder := soDescending;
cxGBubinStt.Columns[22].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands24HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 23 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[23].SortOrder = soNone) or
(cxGBubinStt.Columns[23].SortOrder =
soDescending) then
cxGBubinStt.Columns[23].SortOrder := soAscending
else
if cxGBubinStt.Columns[23].SortOrder = soAscending then
cxGBubinStt.Columns[23].SortOrder := soDescending;
cxGBubinStt.Columns[23].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands25HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 24 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[24].SortOrder = soNone) or
(cxGBubinStt.Columns[24].SortOrder =
soDescending) then
cxGBubinStt.Columns[24].SortOrder := soAscending
else
if cxGBubinStt.Columns[24].SortOrder = soAscending then
cxGBubinStt.Columns[24].SortOrder := soDescending;
cxGBubinStt.Columns[24].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands28HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 36 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[36].SortOrder = soNone) or
(cxGBubinStt.Columns[36].SortOrder =
soDescending) then
cxGBubinStt.Columns[36].SortOrder := soAscending
else
if cxGBubinStt.Columns[36].SortOrder = soAscending then
cxGBubinStt.Columns[36].SortOrder := soDescending;
cxGBubinStt.Columns[36].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands2HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 2 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[2].SortOrder = soNone) or
(cxGBubinStt.Columns[2].SortOrder =
soDescending) then
cxGBubinStt.Columns[2].SortOrder := soAscending
else
if cxGBubinStt.Columns[2].SortOrder = soAscending then
cxGBubinStt.Columns[2].SortOrder := soDescending;
cxGBubinStt.Columns[2].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands32HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 5 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[5].SortOrder = soNone) or
(cxGBubinStt.Columns[5].SortOrder =
soDescending) then
cxGBubinStt.Columns[5].SortOrder := soAscending
else
if cxGBubinStt.Columns[5].SortOrder = soAscending then
cxGBubinStt.Columns[5].SortOrder := soDescending;
cxGBubinStt.Columns[5].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands33HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 6 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[6].SortOrder = soNone) or
(cxGBubinStt.Columns[6].SortOrder =
soDescending) then
cxGBubinStt.Columns[6].SortOrder := soAscending
else
if cxGBubinStt.Columns[6].SortOrder = soAscending then
cxGBubinStt.Columns[6].SortOrder := soDescending;
cxGBubinStt.Columns[6].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands34HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 25 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[25].SortOrder = soNone) or
(cxGBubinStt.Columns[25].SortOrder =
soDescending) then
cxGBubinStt.Columns[25].SortOrder := soAscending
else
if cxGBubinStt.Columns[25].SortOrder = soAscending then
cxGBubinStt.Columns[25].SortOrder := soDescending;
cxGBubinStt.Columns[25].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands35HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 26 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[26].SortOrder = soNone) or
(cxGBubinStt.Columns[26].SortOrder =
soDescending) then
cxGBubinStt.Columns[26].SortOrder := soAscending
else
if cxGBubinStt.Columns[26].SortOrder = soAscending then
cxGBubinStt.Columns[26].SortOrder := soDescending;
cxGBubinStt.Columns[26].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands36HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 27 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[27].SortOrder = soNone) or
(cxGBubinStt.Columns[27].SortOrder =
soDescending) then
cxGBubinStt.Columns[27].SortOrder := soAscending
else
if cxGBubinStt.Columns[27].SortOrder = soAscending then
cxGBubinStt.Columns[27].SortOrder := soDescending;
cxGBubinStt.Columns[27].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands37HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 30 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[30].SortOrder = soNone) or
(cxGBubinStt.Columns[30].SortOrder =
soDescending) then
cxGBubinStt.Columns[30].SortOrder := soAscending
else
if cxGBubinStt.Columns[30].SortOrder = soAscending then
cxGBubinStt.Columns[30].SortOrder := soDescending;
cxGBubinStt.Columns[30].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands38HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 31 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[31].SortOrder = soNone) or
(cxGBubinStt.Columns[31].SortOrder =
soDescending) then
cxGBubinStt.Columns[31].SortOrder := soAscending
else
if cxGBubinStt.Columns[31].SortOrder = soAscending then
cxGBubinStt.Columns[31].SortOrder := soDescending;
cxGBubinStt.Columns[31].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands39HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 28 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[28].SortOrder = soNone) or
(cxGBubinStt.Columns[28].SortOrder =
soDescending) then
cxGBubinStt.Columns[28].SortOrder := soAscending
else
if cxGBubinStt.Columns[28].SortOrder = soAscending then
cxGBubinStt.Columns[28].SortOrder := soDescending;
cxGBubinStt.Columns[28].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands3HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 3 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[3].SortOrder = soNone) or
(cxGBubinStt.Columns[3].SortOrder =
soDescending) then
cxGBubinStt.Columns[3].SortOrder := soAscending
else
if cxGBubinStt.Columns[3].SortOrder = soAscending then
cxGBubinStt.Columns[3].SortOrder := soDescending;
cxGBubinStt.Columns[3].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands40HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 29 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[29].SortOrder = soNone) or
(cxGBubinStt.Columns[29].SortOrder =
soDescending) then
cxGBubinStt.Columns[29].SortOrder := soAscending
else
if cxGBubinStt.Columns[29].SortOrder = soAscending then
cxGBubinStt.Columns[29].SortOrder := soDescending;
cxGBubinStt.Columns[29].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands41HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 32 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[32].SortOrder = soNone) or
(cxGBubinStt.Columns[32].SortOrder =
soDescending) then
cxGBubinStt.Columns[32].SortOrder := soAscending
else
if cxGBubinStt.Columns[32].SortOrder = soAscending then
cxGBubinStt.Columns[32].SortOrder := soDescending;
cxGBubinStt.Columns[32].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands42HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 33 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[33].SortOrder = soNone) or
(cxGBubinStt.Columns[33].SortOrder =
soDescending) then
cxGBubinStt.Columns[33].SortOrder := soAscending
else
if cxGBubinStt.Columns[33].SortOrder = soAscending then
cxGBubinStt.Columns[33].SortOrder := soDescending;
cxGBubinStt.Columns[33].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands43HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 34 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[34].SortOrder = soNone) or
(cxGBubinStt.Columns[34].SortOrder =
soDescending) then
cxGBubinStt.Columns[34].SortOrder := soAscending
else
if cxGBubinStt.Columns[34].SortOrder = soAscending then
cxGBubinStt.Columns[34].SortOrder := soDescending;
cxGBubinStt.Columns[34].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands44HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 35 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[35].SortOrder = soNone) or
(cxGBubinStt.Columns[35].SortOrder =
soDescending) then
cxGBubinStt.Columns[35].SortOrder := soAscending
else
if cxGBubinStt.Columns[35].SortOrder = soAscending then
cxGBubinStt.Columns[35].SortOrder := soDescending;
cxGBubinStt.Columns[35].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands45HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 37 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[37].SortOrder = soNone) or
(cxGBubinStt.Columns[37].SortOrder =
soDescending) then
cxGBubinStt.Columns[37].SortOrder := soAscending
else
if cxGBubinStt.Columns[37].SortOrder = soAscending then
cxGBubinStt.Columns[37].SortOrder := soDescending;
cxGBubinStt.Columns[37].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands46HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 38 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[38].SortOrder = soNone) or
(cxGBubinStt.Columns[38].SortOrder =
soDescending) then
cxGBubinStt.Columns[38].SortOrder := soAscending
else
if cxGBubinStt.Columns[38].SortOrder = soAscending then
cxGBubinStt.Columns[38].SortOrder := soDescending;
cxGBubinStt.Columns[38].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands47HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 40 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[40].SortOrder = soNone) or
(cxGBubinStt.Columns[40].SortOrder =
soDescending) then
cxGBubinStt.Columns[40].SortOrder := soAscending
else
if cxGBubinStt.Columns[40].SortOrder = soAscending then
cxGBubinStt.Columns[40].SortOrder := soDescending;
cxGBubinStt.Columns[40].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands48HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 41 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[41].SortOrder = soNone) or
(cxGBubinStt.Columns[41].SortOrder =
soDescending) then
cxGBubinStt.Columns[41].SortOrder := soAscending
else
if cxGBubinStt.Columns[41].SortOrder = soAscending then
cxGBubinStt.Columns[41].SortOrder := soDescending;
cxGBubinStt.Columns[41].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands4HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 4 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[4].SortOrder = soNone) or
(cxGBubinStt.Columns[4].SortOrder =
soDescending) then
cxGBubinStt.Columns[4].SortOrder := soAscending
else
if cxGBubinStt.Columns[4].SortOrder = soAscending then
cxGBubinStt.Columns[4].SortOrder := soDescending;
cxGBubinStt.Columns[4].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands6HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 7 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[7].SortOrder = soNone) or
(cxGBubinStt.Columns[7].SortOrder =
soDescending) then
cxGBubinStt.Columns[7].SortOrder := soAscending
else
if cxGBubinStt.Columns[7].SortOrder = soAscending then
cxGBubinStt.Columns[7].SortOrder := soDescending;
cxGBubinStt.Columns[7].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands7HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 8 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[8].SortOrder = soNone) or
(cxGBubinStt.Columns[8].SortOrder =
soDescending) then
cxGBubinStt.Columns[8].SortOrder := soAscending
else
if cxGBubinStt.Columns[8].SortOrder = soAscending then
cxGBubinStt.Columns[8].SortOrder := soDescending;
cxGBubinStt.Columns[8].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands8HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 9 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[9].SortOrder = soNone) or
(cxGBubinStt.Columns[9].SortOrder =
soDescending) then
cxGBubinStt.Columns[9].SortOrder := soAscending
else
if cxGBubinStt.Columns[9].SortOrder = soAscending then
cxGBubinStt.Columns[9].SortOrder := soDescending;
cxGBubinStt.Columns[9].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttBands9HeaderClick(Sender: TObject);
var
i: Integer;
sTemp: string;
begin
try
for i := 0 to cxGBubinStt.ColumnCount - 1 do
begin
if i <> 10 then
begin
cxGBubinStt.Columns[i].SortIndex := -1;
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
end;
if (cxGBubinStt.Columns[10].SortOrder = soNone) or
(cxGBubinStt.Columns[10].SortOrder =
soDescending) then
cxGBubinStt.Columns[10].SortOrder := soAscending
else
if cxGBubinStt.Columns[10].SortOrder = soAscending then
cxGBubinStt.Columns[10].SortOrder := soDescending;
cxGBubinStt.Columns[10].SortIndex := 0;
cxGBubinStt.DataController.FocusedRowIndex := 0;
except
on e: exception do
begin
sTemp := 'Tfrm_CUT.cxGBubinSttBands0HeaderClick:' + e.Message;
ShowMessage(sTemp);
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.cxGBubinSttCellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
var
I, Row, Col: Integer;
begin
Row := cxGBubinStt.DataController.FocusedRecordIndex;
if (Row > -1) then
begin
if cxGBubinStt.DataController.Values[Row, 1] = '0' then cxGBubinStt.DataController.Values[Row, 1] := '1'
else cxGBubinStt.DataController.Values[Row, 1] := '0';
end;
end;
procedure TFrm_CUT1.cxGBubinSttCellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
var
iRow: Integer;
begin
iRow := cxGBubinStt.DataController.FocusedRecordIndex;
if iRow < 0 then Exit;
proc_BubinStt_Select(iRow);
end;
procedure TFrm_CUT1.cxGBubinSttDataControllerSortingChanged(Sender: TObject);
begin
gfSetIndexNo(cxGBubinStt, True);
end;
procedure TFrm_CUT1.cxGBubinSttKeyPress(Sender: TObject; var Key: Char);
Var i : Integer;
begin
if Key = ^A then
begin
cxGBubinStt.BeginUpdate;
try
for i := 0 to cxGBubinStt.DataController.RecordCount - 1 do
begin
cxGBubinStt.DataController.Values[i, 1] := '1'
end;
finally
cxGBubinStt.EndUpdate;
end;
chkBubinStt.Checked := True;
Key := #0;
end;
end;
procedure TFrm_CUT1.cxGridBebinListCellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
var
iKeyNum, iSeq, iRow: Integer;
sBrNo, sKeyNum, sSeq: string;
begin
// 권한 적용 (지호 2008-08-19)
if TCK_USER_PER.COM_CustModify <> '1' then
begin
GMessagebox('고객 수정권한이 없습니다.', CDMSE);
Exit;
end;
iRow := CustView12_3.DataController.FocusedRecordIndex;
if iRow = -1 then
Exit;
iKeyNum := CustView12_3.GetColumnByFieldName('대표번호').Index;
iSeq := CustView12_3.GetColumnByFieldName('고객코드').Index;
sBrNo := cxBrNo12.Text;
sKeyNum := CustView12_3.DataController.Values[iRow, iKeyNum];
sKeyNum := StringReplace(sKeyNum, '-', '', [rfReplaceAll]);
sSeq := CustView12_3.DataController.Values[iRow, iSeq];
// 6 : 수정창에서 고객수정 4 : 접수창에서 고객수정
if ( Not Assigned(Frm_CUT011) ) Or ( Frm_CUT011 = Nil ) then Frm_CUT011 := TFrm_CUT011.Create(Nil);
Frm_CUT011.Tag := 6;
Frm_CUT011.Hint := IntToStr(Self.Tag);
Frm_CUT011.clbCuSeq.Caption := sSeq;
Frm_CUT011.proc_search_brKeyNum(sBrNo, sKeyNum);
Frm_CUT011.Show;
Frm_CUT011.proc_cust_Intit;
end;
procedure TFrm_CUT1.cxGridCopy(ASource, ATarget: TcxGridDBTableView;
AKeyIndex: Integer; AKeyValue: string);
var
I, J, Row: Integer;
KeyData: string;
begin
if AKeyIndex < 0 then
Exit;
if Trim(AKeyValue) = '' then
Exit;
for I := 0 to ASource.DataController.RecordCount - 1 do
begin
KeyData := CallToStr(ASource.DataController.GetValue(I, AKeyIndex));
if Pos(AKeyValue, KeyData) > 0 then
begin
Row := ATarget.DataController.AppendRecord;
ATarget.DataController.Values[Row, 0] := Row + 1;
for J := 1 to ASource.ColumnCount - 1 do
ATarget.DataController.Values[Row, J] := ASource.DataController.GetValue(I, J);
end;
end;
end;
procedure TFrm_CUT1.cxGrid_Angel2ColumnHeaderClick(Sender: TcxGridTableView;
AColumn: TcxGridColumn);
begin
gIndex := AColumn.Index;
end;
procedure TFrm_CUT1.cxGrid_Angel2DataControllerSortingChanged(Sender: TObject);
begin
gfSetIndexNo(cxGrid_Angel2, gIndex, GS_SortNoChange);
end;
procedure TFrm_CUT1.cxGroupBox48MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
ReleaseCapture;
PostMessage(TcxGroupBox(Sender).Parent.Handle, WM_SYSCOMMAND, $F012, 0);
end;
procedure TFrm_CUT1.cxGroupBox49MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
ReleaseCapture;
PostMessage(TcxGroupBox(Sender).Parent.Handle, WM_SYSCOMMAND, $F012, 0);
end;
procedure TFrm_CUT1.cxPageControl1Change(Sender: TObject);
Var iTag : Integer;
begin
if (cxPageControl1.Tag = 1) or (cxPageControl1.ActivePageIndex = -1) then Exit;
iTag := cxPageControl1.Pages[cxPageControl1.ActivePageIndex].Tag;
if Assigned(Frm_JON51) then
if TCK_USER_PER.BTM_MENUSCH = '1' then Frm_JON51.Menu_Use_Mark('ADD', iTag);
case cxPageControl1.ActivePageIndex of
0:
begin
if ((GT_USERIF.LV = '10')) and (GT_SEL_BRNO.GUBUN <> '1') then//(GT_USERIF.LV = '60') or
begin
cbKeynumber12.Properties.Items.Clear;
GMessagebox('법인업체 조회는 지사를 선택하셔야 합니다.', CDMSE);
end else
begin
cbKeynumber12.ItemIndex := 0;
cbKeynumber01Click(cbKeynumber12);
end;
end;
1:
begin
if ((GT_USERIF.LV = '10')) and (GT_SEL_BRNO.GUBUN <> '1') then//(GT_USERIF.LV = '60') or
begin
cbKeynumber13.Properties.Items.Clear;
GMessagebox('법인업체 조회는 지사를 선택하셔야 합니다.', CDMSE);
end else
begin
cbKeynumber13.ItemIndex := 0;
cbKeynumber01Click(cbKeynumber13);
end;
end;
6:
begin
btn_18_3Click(btn_18_3);
end;
end;
end;
procedure TFrm_CUT1.edBubinName01KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = vk_Return then btn_12_1Click(btn_12_1);
end;
procedure TFrm_CUT1.edCustName05KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Ord(Key) = VK_RETURN) then
btn_12_11Click(btn_12_11);
end;
procedure TFrm_CUT1.edtKeyWord18KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if key = VK_RETURN then btn_18_1.Click;
end;
procedure TFrm_CUT1.edtResultSearchKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = vk_Return then btn_12_10Click(btn_12_10);
end;
procedure TFrm_CUT1.edt_18_1Enter(Sender: TObject);
begin
// lst_BRList.Visible := False;
end;
procedure TFrm_CUT1.edt_18_1Exit(Sender: TObject);
begin
// lst_BRList.Visible := (edt_18_1.Text = '');
end;
procedure TFrm_CUT1.edt_18_1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
Var slTmp : TStringList;
begin
SetDebugeWrite('TFrm_CUT1.edt_18_1KeyDown');
if Key = VK_BACK then
begin
if (Length(edt_18_1.Text) <= 1) then
begin
lst_BRList.Items.Clear;
searchBRlist.Clear;
lst_BRList.Visible := False;
Exit;
end;
end else
if Key = VK_DOWN then
begin
if lst_BRLIst.ItemIndex < 0 then lst_BRLIst.ItemIndex := 0;
if lst_BRList.Visible then lst_BRList.SetFocus;
end else
if Key = VK_RETURN then
begin
slTmp := TStringList.Create;
Try
slTmp.Delimiter := '|';
slTmp.DelimitedText := searchBRlist[0];
if slTmp.Count = 3 then
SetTree_ListItem(slTmp[0], slTmp[1], StrToInt(slTmp[2]));
lst_BRList.Visible := False;
Finally
slTmp.Free;
End;
lst_BRList.Visible := False;
end;
end;
procedure TFrm_CUT1.edt_18_1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
var i : integer;
begin
SetDebugeWrite('TFrm_CUT1.edt_18_1KeyUp');
// if (key <> 229) then // 20191224 한컴입력기 에서는 모든 한글이 229로 넘어옴 그래서 삭제 KHS
begin
if Trim(edt_18_1.Text) = '' then
begin
edt_18_1.SetFocus;
Exit;
end;
if Length(Trim(edt_18_1.Text)) >= 1 then
begin
// lst_BRList.Visible := True;
// 지사명으로 조회.. CDS. 080818.
if not func_BrNameList_Search then Exit;
end;
end;
end;
procedure TFrm_CUT1.edt_18_1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
SetDebugeWrite('TFrm_CUT1.edt_18_1MouseDown');
if lst_BRList.Items.Count > 30 then
lst_BRList.Height := 500
else
lst_BRList.Height := lst_BRList.Items.Count * 18;
lst_BRList.Left := 78;
lst_BRList.Top := 34;
lst_BRList.Visible := True;
end;
procedure TFrm_CUT1.edt_WebIdFirstKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key = vk_Return then btn_IdCheck.Click;
end;
procedure TFrm_CUT1.edt_WebPW1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key = vk_Return then edt_WebPW2.SetFocus;
end;
procedure TFrm_CUT1.edt_WebPW2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key = vk_Return then btn_Confirm.SetFocus;
end;
procedure TFrm_CUT1.edt_WebPW2KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
btn_Confirm.enabled := True;
end;
procedure TFrm_CUT1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
UsrNameReg.WriteString('footer', sFooter);
UsrNameReg.WriteString('header', sHeader);
UsrNameReg.CloseKey;
if Assigned(searchBRlist) then FreeAndNil(searchBRlist);
FreeAndNil(UsrNameReg);
Action := caFree;
end;
procedure TFrm_CUT1.FormCreate(Sender: TObject);
var i : Integer;
begin
try
// 날짜형식이 'yy/mm/dd'일경우 오류 발생 가능성으로 인해 자체 Display 포맷 변경
for i := 0 to ComponentCount - 1 do
begin
if Components[i] is TcxDateEdit then
begin
(Components[i] as TcxDateEdit).Properties.DisplayFormat := 'yyyy/mm/dd';
(Components[i] as TcxDateEdit).Properties.EditFormat := 'yyyy/mm/dd';
end;
end;
except
end;
searchBRlist := TStringList.Create;
proc_init;
cxPageControl1.ActivePageIndex := -1;
cxPageControl1.Tag := 1;
cxPageControl1.Pages[0].TabVisible := (TCK_USER_PER.CUR_BubinMng = '1') or (TCK_USER_PER.CUR_BubinMngModify = '1'); // 501.법인관리
cxPageControl1.Pages[1].TabVisible := (TCK_USER_PER.CUR_BubinHis = '1'); // 502.법인이용내역
cxPageControl1.Pages[2].TabVisible := (TCK_USER_PER.CUR_BubinAcc = '1'); // 503.법인일일정산
cxPageControl1.Pages[3].TabVisible := (TCK_USER_PER.CUR_BubinAuth = '1'); // 504.법인인증
cxPageControl1.Tag := 0;
UsrNameReg := TRegistry.Create;
UsrNameReg.RootKey := HKEY_CURRENT_USER;
UsrNameReg.OpenKey('Software\Microsoft\Internet Explorer\PageSetup', True);
if UsrNameReg.KeyExists('footer') then
begin
sFooter := UsrNameReg.ReadString('footer');
UsrNameReg.WriteString('footer', '');
end else
begin
UsrNameReg.CreateKey('footer');
UsrNameReg.WriteString('footer', '');
sFooter := '&u&b&d';
end;
if UsrNameReg.KeyExists('header') then
begin
sHeader := UsrNameReg.ReadString('header');
UsrNameReg.WriteString('header', '');
end else
begin
UsrNameReg.CreateKey('header');
UsrNameReg.WriteString('header', '');
sHeader := '&w&bPage &p of &P';
end;
end;
procedure TFrm_CUT1.FormDestroy(Sender: TObject);
begin
Frm_CUT1 := Nil;
end;
procedure TFrm_CUT1.FormShow(Sender: TObject);
Var i : Integer;
begin
fSetFont(Frm_CUT1, GS_FONTNAME);
for i := 0 to pred(cxStyleCustLevel.Count) do
begin
TcxStyle(cxStyleCustLevel.Items[i]).Font.Name := GS_FONTNAME;
end;
for i := 0 to pred(cxStyleRepository1.Count) do
begin
TcxStyle(cxStyleRepository1.Items[i]).Font.Name := GS_FONTNAME;
end;
for i := 0 to pred(cxStyleRepository2.Count) do
begin
TcxStyle(cxStyleRepository2.Items[i]).Font.Name := GS_FONTNAME;
end;
end;
function TFrm_CUT1.func_BrNameList_Search: boolean;
var
iOldIdx: integer;
bRlt: boolean;
sKey: string;
i, j : Integer;
LeftTreePtrA, LeftTreePtrB : PTreeRec;
begin
SetDebugeWrite('TFrm_CUT1.func_BrNameList_Search');
try
bRlt := False;
lst_BRList.Items.Clear;
searchBRlist.Clear;
sKey := edt_18_1.text; // 조회할 지사명 읽기.
lst_BRList.Items.BeginUpdate;
for i := 0 to CustView18_1.Count - 1 do
begin
LeftTreePtrA := CustView18_1.Items[i].Data;
if (Pos(sKey, LeftTreePtrA^.HDName) > 0) then
begin
lst_BRList.Items.Add(LeftTreePtrA^.HDName);
searchBRlist.Add(LeftTreePtrA^.HDCode + '|' + LeftTreePtrA^.BrCode + '|' + IntToStr(LeftTreePtrA^.FIndex));
bRlt := True;
end;
for j := 0 to CustView18_1.Items[i].Count - 1 do
begin
LeftTreePtrB := CustView18_1.Items[i].Items[j].Data;
if (Pos(sKey, LeftTreePtrB^.BRName) > 0) then
begin
lst_BRList.Items.Add(LeftTreePtrB^.BRName);
searchBRlist.Add(LeftTreePtrB^.HDCode + '|' + LeftTreePtrB^.BrCode + '|' + IntToStr(LeftTreePtrB^.FIndex));
bRlt := True;
end;
end;
end;
lst_BRList.Items.EndUpdate;
lst_BRList.Visible := True;
if lst_BRList.Items.Count > 30 then
lst_BRList.Height := 500
else
lst_BRList.Height := lst_BRList.Items.Count * 18;
Result := bRlt;
Except
on e: exception do
begin
Log('proc_BrNameList_Search Error :' + E.Message, LOGDATAPATHFILE);
Assert(False, 'proc_BrNameList_Search Error :' + E.Message);
end;
end;
end;
function TFrm_CUT1.func_buninSearch(sBrNo, sKeyNum, sCode: string): string;
var
i: Integer;
begin
Result := '';
for i := 0 to GT_BUBIN_INFO.brNo_KeyNum.Count - 1 do
begin
if (GT_BUBIN_INFO.brNo_KeyNum.Strings[i] = Rpad(sbrNo, 5, ' ') +
Rpad(StringReplace(sKeyNum,
'-', '', [rfReplaceAll]), 15, ' '))
and (GT_BUBIN_INFO.cbcode[i] = sCode + ',' + sBrNo) then
begin
Result := Trim(GT_BUBIN_INFO.cbCorpNm.Strings[i]) + ' / ' +
Trim(GT_BUBIN_INFO.cbDeptNm.Strings[i]);
Break;
end;
end;
end;
function TFrm_CUT1.Func_CheckBrNo: string;
procedure _PushTag(AStatus: string; var Value: string);
begin
if Value <> '' then
Value := Value + ',';
Value := Value + AStatus;
end;
Var i, j : Integer;
LeftTreePtr : PTreeRec;
sTmp : String;
begin
SetDebugeWrite('TFrm_CUT1.Func_CheckBrNo');
Result := '';
try
for i := 0 to CustView18_1.Count - 1 do
begin
for j := 0 to CustView18_1.Items[i].Count - 1 do
begin
if CustView18_1.Items[i].Items[j].Checked then
begin
LeftTreePtr := CustView18_1.Items[i].Items[j].Data;
_PushTag(LeftTreePtr^.BRCode, sTmp );
end;
end;
end;
Result := sTmp;
except
Result := '';
end;
end;
function TFrm_CUT1.GetActiveDateControl(AIndex : integer; var AStDt, AEdDt: TcxDateEdit): Boolean;
begin
Result := True;
case AIndex of
131: begin
AStDt := cxDate13_1S;
AEdDt := cxDate13_1E;
end;
141: begin
AStDt := cxDate14_1S;
AEdDt := cxDate14_1E;
end;
161: begin
AStDt := cxDate16_1S;
AEdDt := cxDate16_1E;
end;
181: begin
AStDt := cxDate18_1S;
AEdDt := cxDate18_1E;
end;
end;
end;
function TFrm_CUT1.GetDeptCustomerCount(AHdNo, ABrNo,
ADeptCode: string): Integer;
var
xdom: msDomDocument;
lst_Result: IXMLDomNodeList;
ls_TxLoad, ls_TxQry, sQueryTemp,
XmlStr, ErrorCode: string;
StrList: TStringList;
ErrCode: Integer;
begin
Result := -1;
ls_TxLoad := GTx_UnitXmlLoad('SEL02.XML');
fGet_BlowFish_Query(GSQ_CUST_BUBIN_COUNT_SEARCH, sQueryTemp);
ls_TxQry := Format(sQueryTemp, [AHdNo, ABrNo, ADeptCode]);
ls_TxLoad := StringReplace(ls_TxLoad, 'UserIDString', En_Coding(GT_USERIF.ID), [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientVerString', VERSIONINFO, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientKeyString', self.Caption + '14', [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'QueryString', ls_TxQry, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'PagingString', '500', [rfReplaceAll]);
StrList := TStringList.Create;
try
if dm.SendSock(ls_TxLoad, StrList, ErrCode, False, 30000) then
begin
Application.ProcessMessages;
xdom := ComsDomDocument.Create;
try
XmlStr := StrList[0];
if not xdom.loadXML(XmlStr) then
Exit;
ErrorCode := GetXmlErrorCode(XmlStr);
if ('0000' = ErrorCode) then
begin
lst_Result := xdom.documentElement.selectNodes('/cdms/Service/Data/Result');
Result := StrToIntDef(GetTextSeperationFirst('│', lst_Result.item[0].attributes.getNamedItem('Value').Text), -1);
end;
finally
xdom := Nil;
end;
end;
finally
Frm_Flash.Hide;
FreeAndNil(StrList);
end;
end;
procedure TFrm_CUT1.Label7Click(Sender: TObject);
procedure RunDownload;
var
IE: Variant;
EHWND: THandle;
begin
try
IE := CreateOleObject('InternetExplorer.Application');
IE.height := 100;
IE.width := 100;
IE.left := 0;
IE.top := 0;
IE.MenuBar := False;
IE.AddressBar := True;
IE.Resizable := False;
IE.StatusBar := False;
IE.ToolBar := False;
IE.Silent := false;
sleep(1);
IE.Navigate('http://www.callmaner.com/download/콜마너_고객등급변경신청서.xls');
IE.Visible := True;
Application.ProcessMessages;
sleep(1);
except on E: Exception do
GMessagebox(Format('신청서 다운로드 시 오류(Err: %s)가 발생하였습니다.'#13#10
+ '(다시시도 바랍니다.)' , [E.Message]), CDMSE);
end;
end;
begin
RunDownload;
end;
procedure TFrm_CUT1.lst_BRListDblClick(Sender: TObject);
var slTmp : TStringList;
i : integer;
begin
SetDebugeWrite('TFrm_CUT1.lst_BRListDblClick');
slTmp := TStringList.Create;
Try
slTmp.Delimiter := '|';
slTmp.DelimitedText := searchBRlist[lst_BRList.ItemIndex];
if slTmp.Count = 3 then
SetTree_ListItem(slTmp[0], slTmp[1], StrToInt(slTmp[2]));
lst_BRList.Visible := False;
Finally
slTmp.Free;
End;
end;
procedure TFrm_CUT1.lst_BRListExit(Sender: TObject);
begin
SetDebugeWrite('TFrm_CUT1.lst_BRListExit');
lst_BRList.Visible := False;
end;
procedure TFrm_CUT1.lst_BRListKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var slTmp : TStringList;
begin
SetDebugeWrite('TFrm_Main.lst_BRListKeyDown');
if key = vk_Return then
begin
if lst_BRList.ItemIndex < 0 then exit;
slTmp := TStringList.Create;
Try
slTmp.Delimiter := '|';
slTmp.DelimitedText := searchBRlist[lst_BRList.ItemIndex];
if slTmp.Count = 3 then
SetTree_ListItem(slTmp[0], slTmp[1], StrToInt(slTmp[2]));
lst_BRList.Visible := False;
Finally
slTmp.Free;
End;
end else
if Key = VK_UP then
begin
if lst_BRlist.Selected[0] then edt_18_1.SetFocus;
end;
end;
procedure TFrm_CUT1.N4Click(Sender: TObject);
begin
if Length(CustView12_1.Selections[0].Values[7]) >= 9 then
begin
GMessagebox('서브는 2단계까지만 등록됩니다.', CDMSE);
Exit;
end;
if ( Not Assigned(Frm_CUT09) ) Or ( Frm_CUT09 = Nil ) then Frm_CUT09 := TFrm_CUT09.Create(Nil);
Frm_CUT09.PnlTitle.Caption := ' 법인(업체) 세부 등록하기';
Frm_CUT09.Tag := 2;
Frm_CUT09.edCbCode.Text := CustView12_1.Selections[0].Values[7];
Frm_CUT09.edBrNo.Text := cxBrNo12.Text;
Frm_CUT09.edHdNo.Text := cxHdNo12.Text;
Frm_CUT09.edKeyNum.Text := StringReplace(cbKeynumber12.Text, '-', '', [rfReplaceAll]);
Frm_CUT09.proc_init;
Frm_CUT09.Show;
end;
procedure TFrm_CUT1.N5Click(Sender: TObject);
begin
if CustView12_1.SelectionCount > 0 then
begin
if ( Not Assigned(Frm_CUT09) ) Or ( Frm_CUT09 = Nil ) then Frm_CUT09 := TFrm_CUT09.Create(Nil);
Frm_CUT09.PnlTitle.Caption := ' 법인(업체) 세부 수정하기';
Frm_CUT09.Tag := 1;
Frm_CUT09.edCbCode.Text := CustView12_1.Selections[0].Values[7];
Frm_CUT09.edBrNo.Text := cxBrNo12.Text;
Frm_CUT09.proc_init;
Frm_CUT09.Show;
end;
end;
procedure TFrm_CUT1.N8Click(Sender: TObject);
begin
proc_BubinList;
if cxGridBebinList.DataController.RecordCount = 0 then
begin
GMessagebox('자료가 없습니다.', CDMSE);
Exit;
end;
if GT_USERIF.Excel_Use = 'n' then
begin
ShowMessage('[엑셀다운로드허용] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
if TCK_USER_PER.COM_CustExcelDown <> '1' then
begin
ShowMessage('[조회고객엑셀다운] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
Frm_Main.sgExcel := '고객_법인관리.xls';
Frm_Main.sgRpExcel := Format('법인>법인관리>법인업체]%s건/%s', [GetMoneyStr(CustView12_1.Count), FExcelDownBubin]);
Frm_Main.cxGridExcel := cxGrid13;
Frm_Main.bgExcelOPT := False;
Frm_Main.proc_excel(0);
end;
procedure TFrm_CUT1.MenuItem8Click(Sender: TObject);
begin
if custview13_2.DataController.RecordCount = 0 then
begin
GMessagebox('자료가 없습니다.', CDMSE);
Exit;
end;
if GT_USERIF.Excel_Use = 'n' then
begin
ShowMessage('[엑셀다운로드허용] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
if TCK_USER_PER.COM_CustExcelDown <> '1' then
begin
ShowMessage('[조회고객엑셀다운] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
Frm_Main.sgExcel := '고객_법인관리_법인이용내역.xls';
Frm_Main.sgRpExcel := Format('법인>법인이용내역]%s건/%s', [GetMoneyStr(custview13_2.DataController.RecordCount), FExcelDownBubinUsed]);
Frm_Main.cxGridExcel := cxGrid9;
Frm_Main.bgExcelOPT := False;
Frm_Main.proc_excel(0);
end;
procedure TFrm_CUT1.MenuItem9Click(Sender: TObject);
begin
btn_18_2.click;
end;
procedure TFrm_CUT1.N_TodayClick(Sender: TObject);
var
StDt, EdDt: TcxDateEdit;
begin
if GetActiveDateControl(pm_Date.Tag, StDt, EdDt) then
CustSetDateControl(0, StDt, EdDt);
end;
procedure TFrm_CUT1.N_YesterdayClick(Sender: TObject);
var
StDt, EdDt: TcxDateEdit;
begin
if GetActiveDateControl(pm_Date.Tag, StDt, EdDt) then
CustSetDateControl(1, StDt, EdDt);
end;
procedure TFrm_CUT1.N_WeekClick(Sender: TObject);
var
StDt, EdDt: TcxDateEdit;
begin
if GetActiveDateControl(pm_Date.Tag, StDt, EdDt) then
CustSetDateControl(2, StDt, EdDt);
end;
procedure TFrm_CUT1.N_MonthClick(Sender: TObject);
var
StDt, EdDt: TcxDateEdit;
begin
if GetActiveDateControl(pm_Date.Tag, StDt, EdDt) then
CustSetDateControl(11, StDt, EdDt);
end;
procedure TFrm_CUT1.N_1Start31EndClick(Sender: TObject);
var
StDt, EdDt: TcxDateEdit;
begin
if GetActiveDateControl(pm_Date.Tag, StDt, EdDt) then
CustSetDateControl(3, StDt, EdDt);
end;
procedure TFrm_CUT1.MenuItem2Click(Sender: TObject);
begin
btn_12_2Click(btn_12_2);
end;
procedure TFrm_CUT1.MenuItem33Click(Sender: TObject);
var
StDt, EdDt: TcxDateEdit;
begin
if GetActiveDateControl(Pop_Ymd.Tag, StDt, EdDt) then //오늘
CustSetDateControl(0, StDt, EdDt);
end;
procedure TFrm_CUT1.MenuItem34Click(Sender: TObject);
var
StDt, EdDt: TcxDateEdit;
begin
if GetActiveDateControl(Pop_Ymd.Tag, StDt, EdDt) then //1개월
CustSetDateControl(11, StDt, EdDt);
end;
procedure TFrm_CUT1.MenuItem35Click(Sender: TObject);
var
StDt, EdDt: TcxDateEdit;
begin
if GetActiveDateControl(Pop_Ymd.Tag, StDt, EdDt) then //3개월
CustSetDateControl(12, StDt, EdDt);
end;
procedure TFrm_CUT1.MenuItem36Click(Sender: TObject);
var
StDt, EdDt: TcxDateEdit;
begin
if GetActiveDateControl(Pop_Ymd.Tag, StDt, EdDt) then //6개월
CustSetDateControl(13, StDt, EdDt);
end;
procedure TFrm_CUT1.MenuItem37Click(Sender: TObject);
var
StDt, EdDt: TcxDateEdit;
begin
if GetActiveDateControl(Pop_Ymd.Tag, StDt, EdDt) then //1년
CustSetDateControl(14, StDt, EdDt);
end;
procedure TFrm_CUT1.MenuItem3Click(Sender: TObject);
begin
if GT_USERIF.Excel_Use = 'n' then
begin
ShowMessage('[엑셀다운로드허용] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
if TCK_USER_PER.COM_CustExcelDown <> '1' then
begin
ShowMessage('[조회고객엑셀다운] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
Frm_Main.sgExcel := '고객_법인관리.xls';
Frm_Main.sgRpExcel := Format('법인>법인관리>법인업체]%s건/%s', [GetMoneyStr(CustView12_1.Count), FExcelDownBubin]);
Frm_Main.cxTreeView := CustView12_1;
Frm_Main.bgExcelOPT := False;
Frm_Main.proc_excel(2);
end;
procedure TFrm_CUT1.MenuItem4Click(Sender: TObject);
begin
if CustView12_2.DataController.RecordCount = 0 then
begin
GMessagebox('자료가 없습니다.', CDMSE);
Exit;
end;
if GT_USERIF.Excel_Use = 'n' then
begin
ShowMessage('[엑셀다운로드허용] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
if TCK_USER_PER.COM_CustExcelDown <> '1' then
begin
ShowMessage('[조회고객엑셀다운] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
Frm_Main.sgExcel := '고객_법인관리_법인고객.xls';
Frm_Main.sgRpExcel := Format('법인>법인관리>소속고객]%s건/%s', [GetMoneyStr(IfThen(CustView12_2.Visible, CustView12_2.DataController.RecordCount, cxViewCustom.DataController.RecordCount)), FExcelDownBubinCust]);
if CustView12_2.Visible then
Frm_Main.cxGridExcel := cxGrid10
else
Frm_Main.cxGridExcel := cxGridCustom;
Frm_Main.bgExcelOPT := False;
Frm_Main.proc_excel(0);
end;
procedure TFrm_CUT1.MenuItem5Click(Sender: TObject);
begin
if CustView12_3.DataController.RecordCount = 0 then
begin
GMessagebox('자료가 없습니다.', CDMSE);
Exit;
end;
if GT_USERIF.Excel_Use = 'n' then
begin
ShowMessage('[엑셀다운로드허용] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
if TCK_USER_PER.COM_CustExcelDown <> '1' then
begin
ShowMessage('[조회고객엑셀다운] 권한이 없습니다. 관리자에게 문의(권한요청) 바랍니다.');
Exit;
end;
Frm_Main.sgExcel := '고객_법인관리_일반고객.xls';
Frm_Main.sgRpExcel := Format('법인>법인관리>일반고객]%s건/%s', [GetMoneyStr(CustView12_3.DataController.RecordCount), FExcelDownBubinNormal]);
Frm_Main.cxGridExcel := cxGrid11;
Frm_Main.bgExcelOPT := False;
Frm_Main.proc_excel(0);
end;
procedure TFrm_CUT1.pm_excel8_7Popup(Sender: TObject);
begin
MenuItem9.visible := False;
if cxGrid_Angel2.DataController.RecordCount > 0 then
begin
MenuItem9.visible := True;
end;
end;
procedure TFrm_CUT1.proc_Branch_Change;
begin
proc_BrNameSet;
end;
procedure TFrm_CUT1.proc_BrList(AStr: string);
var i, iHdNode, iTmp, iNodNo : integer;
sHd, sBr, sTmp : String;
aNode, bNode: TcxTreeListNode;
LeftTreePtr : PTreeRec;
begin
SetDebugeWrite('TFrm_CUT1.proc_BrList');
Try
CustView18_1.Root.TreeList.Clear;
CustView18_1.Root.CheckGroupType := ncgCheckGroup;
CustView18_1.BeginUpdate;
iHdNode := -1;
i := 0; iNodNo:= -1;
while i <= scb_BranchCode.Count -1 do
begin
inc(iNodNo);
if sHd <> scb_HdCode[i] then
begin
{ inc(iHdNode);
sHd := scb_HdCode[i];
iTmp := scb_HdNo.Indexof(sHd);
sTmp := scb_HdNm[iTmp];
New(LeftTreePtr);
LeftTreePtr^.HDCode := sHd; // 본사코드
LeftTreePtr^.HDName := sTmp;
LeftTreePtr^.BRCode := ''; // 지사코드
LeftTreePtr^.BRName := '';
LeftTreePtr^.FIndex := iHdNode;
aNode := CustView18_1.Add(nil, LeftTreePtr);
aNode.CheckGroupType := ncgCheckGroup;
// aNode.Values[0] := True;
aNode.Texts[1] := LeftTreePtr.HDName; }
inc(iHdNode);
sHd := scb_HdCode[i];
iTmp := scb_HdNo.Indexof(sHd);
sTmp := scb_HdNm[iTmp];
New(LeftTreePtr);
LeftTreePtr^.HDCode := sHd; // 본사코드
LeftTreePtr^.HDName := sTmp;
LeftTreePtr^.BRCode := ''; // 지사코드
LeftTreePtr^.BRName := '';
LeftTreePtr^.FIndex := iNodNo;
aNode := CustView18_1.Add(nil, LeftTreePtr);
// aNode := CustView18_1.Root.AddChild;
aNode.CheckGroupType := ncgCheckGroup;
aNode.Checked := True;
iTmp := scb_HdNo.Indexof(sHd);
sTmp := scb_HdNm[iTmp];
aNode.Values[0] := sTmp;
aNode.Values[1] := '';//scb_BranchName[i]; // 법인명
aNode.Values[2] := '';//scb_BranchName[i]; // 부서명
aNode.Values[3] := sHd;
aNode.Values[4] := IntToStr(iNodNo);
end else
if sHd = scb_HdCode[i] then
begin
iTmp := scb_HdNo.Indexof(sHd);
sTmp := scb_HdNm[iTmp];
New(LeftTreePtr);
LeftTreePtr^.HDCode := sHd; // 본사코드
LeftTreePtr^.HDName := sTmp;
LeftTreePtr^.BRCode := scb_BranchCode[i]; // 지사코드
LeftTreePtr^.BRName := scb_BranchName[i];
LeftTreePtr^.FIndex := iNodNo;
bNode := CustView18_1.AddChild(aNode, LeftTreePtr);
// bNode := aNode.AddChild;
bNode.Checked := True;
bNode.Values[0] := '';
bNode.Values[1] := scb_BranchName[i]; // 법인명
bNode.Values[2] := scb_BranchCode[i]; // 부서명 }
bNode.Values[3] := sHd;
bNode.Values[4] := IntToStr(iNodNo);
inc(i);
end;
end;
CustView18_1.EndUpdate;
CustView18_1.FullExpand;
// if CustView18_1.Items[i].Level = 0 then
// CustView18_1.Items[i].Expand(True);
Except
on e: exception do
begin
Assert(False, 'proc_BrList Error :' + E.Message);
end;
end;
end;
procedure TFrm_CUT1.proc_BrNameSet;
var
sName, sBrNo, sHdNo, sTemp: string;
StrList: TStringList;
begin
sTemp := copy(GetPlusCallYN(GT_SEL_BRNO.BRNO),3,1);
if sTemp = 'y' then
cxPageControl1.Pages[4].TabVisible := TCK_USER_PER.CUR_WithHolding = '1'
else
cxPageControl1.Pages[4].TabVisible := False;
StrList := TStringList.Create;
try
if ((GT_USERIF.LV = '60') or (GT_USERIF.LV = '10')) and (GT_SEL_BRNO.GUBUN <> '1') then
begin
GetBrTelList(GT_SEL_BRNO.HDNO, StrList);
cbKeynumber14.Properties.Items.Assign(StrList);
sHdNo := GT_SEL_BRNO.HDNO;
sBrNo := '';
end else
begin
GetBrTelList(GT_SEL_BRNO.BrNo, StrList);
cbKeynumber14.Properties.Items.Assign(StrList);
sHdNo := GT_SEL_BRNO.HDNO;
sBrNo := GT_SEL_BRNO.BrNo;
end;
finally
StrList.Free;
end;
sName := GetSosokInfo;
cxHdNo12.Text := sHdNo;
cxBrNo12.Text := sBrNo;
cxHdNo13.Text := sHdNo;
cxBrNo13.Text := sBrNo;
cxHdNo14.Text := sHdNo;
cxBrNo14.Text := sBrNo;
cxHdNo15.Text := sHdNo;
cxBrNo15.Text := sBrNo;
cxHdNo16.Text := sHdNo;
cxBrNo16.Text := sBrNo;
cxHdNo17.Text := sHdNo;
cxBrNo17.Text := sBrNo;
lbCustCompany12.Caption := sName;
lbCustCompany13.Caption := sName;
lbCustCompany14.Caption := sName;
lbCustCompany15.Caption := sName;
lbCustCompany16.Caption := sName;
lbCustCompany17.Caption := sName;
{ TODO : 법인관리 }
if cbKeynumber14.Properties.Items.Count > 0 then
begin
if GT_SEL_BRNO.GUBUN = '1' then
begin
cbKeynumber12.Properties.Items.Assign(cbKeynumber14.Properties.Items);
cbKeynumber13.Properties.Items.Assign(cbKeynumber14.Properties.Items);
end else
begin
cbKeynumber12.Properties.Items.Clear;
cbKeynumber13.Properties.Items.Clear;
end;
end;
if cbKeynumber14.Properties.Items.Count >= 1 then
cbKeynumber14.Properties.Items.Insert(0, '전체');
cbKeynumber15.Properties.Items.Assign(cbKeynumber14.Properties.Items);
cbKeynumber17.Properties.Items.Assign(cbKeynumber14.Properties.Items);
cbKeynumber12.Tag := 1;
cbKeynumber13.Tag := 1;
cbKeynumber14.Tag := 1;
cbKeynumber15.Tag := 1;
cbKeynumber17.Tag := 1;
cbKeynumber12.ItemIndex := 0;
cbKeynumber13.ItemIndex := 0;
cbKeynumber14.ItemIndex := 0;
cbKeynumber15.ItemIndex := 0;
cbKeynumber17.ItemIndex := 0;
cbKeynumber12.Tag := 0;
cbKeynumber13.Tag := 0;
cbKeynumber14.Tag := 0;
cbKeynumber15.Tag := 0;
cbKeynumber17.Tag := 0;
end;
procedure TFrm_CUT1.proc_BubinCust_HIS;
var
sWhere, sTable, sCbCode: string;
ls_TxQry, ls_TxLoad, sQueryTemp: string; // XML File Load
slReceive: TStringList;
ErrCode: integer;
begin
if (GT_USERIF.LV = '10') and ((GT_SEL_BRNO.GUBUN <> '1') or (GT_SEL_BRNO.BrNo <> GT_USERIF.BR)) then
begin
GMessagebox('상담원 권한은 소속 지사만 조회할수 있습니다.', CDMSE);
Exit;
end;
if fGetChk_Search_HdBrNo('법인이용내역(법인고객)') then Exit;
//////////////////////////////////////////////////////////////////////////////
// 법인>법인이용내역]1000건/A100-B100/대표번호:12345/부서:셀런SN|모바일개발팀/이용기간:20100101~20100131
FExcelDownBubinUsed := Format('%s/대표번호:%s/부서:%s%s',
[
GetSelBrInfo
, cbKeynumber13.Text
, IfThen(chkCust13Type02.Checked, '법인전체', CustView13_1.Selections[0].Values[2] + ',' + CustView13_1.Selections[0].Values[3])
, IfThen(chkCust13Type01.Checked, Format('/이용기간:%s~%s', [cxDate13_1S.Text, cxDate13_1E.Text]), '')
]);
//////////////////////////////////////////////////////////////////////////////
sWhere := '';
if CustView13_1.Count > 0 then
begin
sCbCode := CustView13_1.Selections[0].Values[6];
if (chkCust13Type01.Checked) and (cxDate13_1S.Text <> '') then
begin
if (StartDateTime('yyyymmdd') = FormatDateTime('yyyymmdd', cxDate13_1S.Date)) then
sTable := 'CDMS_A01_TODAY'
else
begin
sTable := 'CDMS_A01';
sWhere := sWhere +
Format(' AND A.IN_DATE BETWEEN TO_DATE (''%s'', ''YYYYMMDDHH24MISS'') '
+ ' AND TO_DATE (''%s'', ''YYYYMMDDHH24MISS'') '
, [FormatDateTime('yyyymmdd', cxDate13_1S.Date) + '090000'
, FormatDateTime('yyyymmdd', cxDate13_1E.Date) + '090000']);
end;
end
else
sTable := 'CDMS_A01';
sWhere := sWhere + ' AND A.CONF_HEAD = ''' + cxHdNo13.Text + ''' AND A.CONF_BRCH = ''' +
cxBrNo13.Text + ''' ';
case cxComboBox3.ItemIndex of
0: sWhere := sWhere + ' AND A.CONF_STATUS IN (''2'',''8'',''4'') ';
1: sWhere := sWhere + ' AND A.CONF_STATUS = ''2'' ';
2: sWhere := sWhere + ' AND A.CONF_STATUS = ''8'' ';
3: sWhere := sWhere + ' AND A.CONF_STATUS = ''4'' ';
end;
if chkCust13Type02.Checked then
begin
sWhere := sWhere + ' AND A.CB_CODE IS NOT NULL ';
end else
begin
sWhere := sWhere + ' AND A.CB_CODE = ''' + sCbCode + ''' ';
end;
if cxTextEdit21.Text <> '' then
begin
if cxComboBox2.ItemIndex = 0 then
sWhere := sWhere + ' AND A.CONF_USER LIKE ''%' + Param_Filtering(cxTextEdit21.Text) + '%'' '
else
if cxComboBox2.ItemIndex = 1 then
sWhere := sWhere + ' AND A.CONF_CUST_TEL LIKE ''%' + StringReplace(Param_Filtering(cxTextEdit21.Text), '-', '', [rfReplaceAll]) + '%'' ';
end;
ls_TxLoad := GTx_UnitXmlLoad('SEL02.XML');
fGet_BlowFish_Query(GSQ_CUST_BUBIN_STT_SEARCH, sQueryTemp);
ls_TxQry := Format(sQueryTemp, [sTable, sWhere]);
ls_TxLoad := StringReplace(ls_TxLoad, 'UserIDString', En_Coding(GT_USERIF.ID), [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientVerString', VERSIONINFO, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientKeyString', self.Caption + '17', [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'QueryString', ls_TxQry, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'PagingString', '500', [rfReplaceAll]);
Screen.Cursor := crHourGlass;
cxPageControl1.Enabled := False;
slReceive := TStringList.Create;
try
frm_Main.proc_SocketWork(False);
if dm.SendSock(ls_TxLoad, slReceive, ErrCode, False, 30000) then
begin
Application.ProcessMessages;
proc_recieve(slReceive);
end;
finally
frm_Main.proc_SocketWork(True);
FreeAndNil(slReceive);
Screen.Cursor := crDefault;
cxPageControl1.Enabled := True;
Frm_Flash.Hide;
end;
end;
end;
procedure TFrm_CUT1.proc_BubinCust_Search(iType: Integer);
function _GetRootBubinName: string;
var
Node: TcxTreeListNode;
begin
Node := CustView12_1.Selections[0];
Result := Node.Values[2] + ',' + Node.Values[3];
OutputDebugString(PChar(Result));
while Node.Level > 0 do
begin
Node := Node.Parent;
Result := Node.Values[2] + ',' + Node.Values[3];
OutputDebugString(PChar(Result));
end;
end;
var
sWhere, sCbcode: string;
ls_TxQry, ls_TxLoad, sQueryTemp: string; // XML File Load
slReceive: TStringList;
ErrCode: integer;
begin
if CustView12_2.DataController.RecordCount > 0 then
Exit;
if CustView12_1.SelectionCount = 0 then
begin
GMessagebox('법인업체를 선택하셔야 합니다.', CDMSE);
Exit;
end;
if (GT_USERIF.LV = '10') and ((GT_SEL_BRNO.GUBUN <> '1') or (GT_SEL_BRNO.BrNo <> GT_USERIF.BR)) then
begin
GMessagebox('상담원 권한은 소속 지사만 조회할수 있습니다.', CDMSE);
Exit;
end;
if fGetChk_Search_HdBrNo('법인관리(소속고객)') then Exit;
//////////////////////////////////////////////////////////////////////////////
// 법인>법인관리>소속고객]10건/A100-B100/대표번호:16886618/부서:테크노-모바일사업팀
FExcelDownBubinCust := Format('%s/대표번호:%s/법인부서:%s',
[
GetSelBrInfo
, cbKeynumber12.Text
, IfThen(iType = 1, _GetRootBubinName + ' 전체', CustView12_1.Selections[0].Values[2] + '-' + CustView12_1.Selections[0].Values[3])
]);
//////////////////////////////////////////////////////////////////////////////
sCbcode := CustView12_1.Selections[0].Values[7];
edBubinName02.Text := CustView12_1.Selections[0].Values[2] + '/' + CustView12_1.Selections[0].Values[3];
cxTextEdit15.Text := sCbcode;
if iType = 1 then
begin
sCbcode := Copy(sCbcode, 1, 5);
sWhere := Format(' AND CU.BR_NO = ''%s'' AND CU.CB_CODE LIKE ''%s%%''', [cxBrNo12.Text, sCbcode]);
// sWhere := ' AND CU.BR_NO = ''' + cxBrNo8.Text + ''' AND CU.CB_CODE LIKE ''' + sCbcode + '%'' ';
end else
if iType = 0 then
begin
sWhere := Format('AND CU.BR_NO = ''%s'' AND CU.CB_CODE = ''%s''', [cxBrNo12.Text, sCbcode]);
// sWhere := ' AND CU.BR_NO = ''' + cxBrNo8.Text + ''' AND CU.CB_CODE = ''' + sCbcode + ''' ';
end;
ls_TxLoad := GTx_UnitXmlLoad('SEL02.XML');
fGet_BlowFish_Query(GSQ_CUST_BUBIN_SEARCH, sQueryTemp);
ls_TxQry := Format(sQueryTemp, [cxHdNo12.Text, sWhere]);
ls_TxLoad := StringReplace(ls_TxLoad, 'UserIDString', En_Coding(GT_USERIF.ID), [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientVerString', VERSIONINFO, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientKeyString', self.Caption + '14', [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'QueryString', ls_TxQry, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'PagingString', '500', [rfReplaceAll]);
Screen.Cursor := crHourGlass;
slReceive := TStringList.Create;
try
frm_Main.proc_SocketWork(False);
if dm.SendSock(ls_TxLoad, slReceive, ErrCode, False, 30000) then
begin
Application.ProcessMessages;
proc_recieve(slReceive);
end;
finally
frm_Main.proc_SocketWork(True);
FreeAndNil(slReceive);
Screen.Cursor := crDefault;
Frm_Flash.Hide;
end;
end;
procedure TFrm_CUT1.proc_bubinHis;
begin
CustView13_1.Root.TreeList.Clear;
proc_BubinManage2;
end;
procedure TFrm_CUT1.proc_BubinList;
var XmlData, Param, ErrMsg: string;
ErrCode: Integer;
lst_Result, lst_Count: IXMLDomNodeList;
I, j: Integer;
iRow: integer;
slList, ls_Rcrd: TStringList;
xdom: MSDomDocument;
begin
Param := GT_SEL_BRNO.HDNO + '│' + GT_SEL_BRNO.BrNo + '│' + StringReplace(cbKeynumber12.Text, '-', '', [rfReplaceAll]);
slList := TStringList.Create;
Screen.Cursor := crHourGlass;
try
if not RequestBasePaging(GetSel06('GET_CUST_LIST', 'MNG_BGROUP.GET_CUST_LIST', '100', Param), slList, ErrCode, ErrMsg) then
begin
GMessageBox(Format('[%d] %s', [ErrCode, ErrMsg]), CDMSE);
Screen.Cursor := crDefault;
FreeAndNil(slList);
Exit;
end;
xdom := ComsDomDocument.Create;
try
Frm_Flash.cxPBar1.Properties.Max := slList.Count;
Frm_Flash.cxPBar1.Position := 0;
cxGridBebinList.DataController.SetRecordCount(0);
cxGridBebinList.BeginUpdate;
for j := 0 to slList.Count - 1 do
begin
Frm_Flash.cxPBar1.Position := j + 1;
Frm_Flash.lblCnt.Caption := IntToStr(j + 1) + '/' + IntToStr(slList.Count);
Application.ProcessMessages;
xmlData := slList.Strings[j];
xdom.loadXML(XmlData);
lst_Count := xdom.documentElement.selectNodes('/cdms/Service/Data');
if StrToIntDef(lst_Count.item[0].attributes.getNamedItem('Count').Text, 0) > 0 then
begin
lst_Result := xdom.documentElement.selectNodes('/cdms/Service/Data/Result');
ls_Rcrd := TStringList.Create;
try
for I := 0 to lst_Result.length - 1 do
begin
GetTextSeperationEx2('│', lst_Result.item[I].attributes.getNamedItem('Value').Text, ls_Rcrd);
iRow := cxGridBebinList.DataController.AppendRecord;
SetGridData(cxGridBebinList, iRow, 0, IntToStr(iRow+1));
SetGridData(cxGridBebinList, iRow, 1, ls_Rcrd[0]);
SetGridData(cxGridBebinList, iRow, 2, ls_Rcrd[1]);
SetGridData(cxGridBebinList, iRow, 3, ls_Rcrd[2]);
SetGridData(cxGridBebinList, iRow, 4, ls_Rcrd[3]);
SetGridData(cxGridBebinList, iRow, 5, ls_Rcrd[4]);
SetGridData(cxGridBebinList, iRow, 6, ls_Rcrd[5]);
SetGridData(cxGridBebinList, iRow, 7, ls_Rcrd[6]);
SetGridData(cxGridBebinList, iRow, 8, ls_Rcrd[7]);
SetGridData(cxGridBebinList, iRow, 9, ls_Rcrd[8]);
SetGridData(cxGridBebinList, iRow,10, ls_Rcrd[9]);
SetGridData(cxGridBebinList, iRow,11, ls_Rcrd[10]);
SetGridData(cxGridBebinList, iRow,12, ls_Rcrd[11]);
SetGridData(cxGridBebinList, iRow,13, ls_Rcrd[12]);
SetGridData(cxGridBebinList, iRow,14, ls_Rcrd[13]);
SetGridData(cxGridBebinList, iRow,15, ls_Rcrd[14]);
SetGridData(cxGridBebinList, iRow,16, ls_Rcrd[15]);
SetGridData(cxGridBebinList, iRow,17, ls_Rcrd[16]);
SetGridData(cxGridBebinList, iRow,18, ls_Rcrd[17]);
SetGridData(cxGridBebinList, iRow,19, ls_Rcrd[18]);
SetGridData(cxGridBebinList, iRow,20, ls_Rcrd[19]);
SetGridData(cxGridBebinList, iRow,21, ls_Rcrd[20]);
SetGridData(cxGridBebinList, iRow,22, ls_Rcrd[21]);
SetGridData(cxGridBebinList, iRow,23, ls_Rcrd[22]);
SetGridData(cxGridBebinList, iRow,24, ls_Rcrd[23]);
SetGridData(cxGridBebinList, iRow,25, ls_Rcrd[24]);
SetGridData(cxGridBebinList, iRow,26, ls_Rcrd[25]);
SetGridData(cxGridBebinList, iRow,27, ls_Rcrd[26]);
end;
finally
ls_Rcrd.Free;
end;
end;
end;
finally
xdom := Nil;
cxGridBebinList.EndUpdate;
Frm_Flash.hide;
Screen.Cursor := crDefault;
FreeAndNil(slList);
end;
except
on E: Exception do
begin
FreeAndNil(slList);
Screen.Cursor := crDefault;
Assert(False, E.Message);
Frm_Flash.Hide;
end;
end;
end;
procedure TFrm_CUT1.proc_BubinManage;
var
ls_TxLoad, sNode, sWhere, msg: string;
ls_rxxml: WideString;
xdom: msDomDocument;
lst_Node: IXMLDOMNodeList;
lst_clon: IXMLDOMNode;
slReceive: TStringList;
ErrCode: integer;
begin
if (GT_SEL_BRNO.GUBUN <> '1') and (cxPageControl1.ActivePageIndex <> 6) then
begin
GMessagebox('법인업체 조회는 지사를 선택하셔야 합니다.', CDMSE);
//- Panel14.Enabled := False;
// Panel15.Enabled := False;
// Panel16.Enabled := False;
Exit;
end;
if (GT_USERIF.LV = '10') and (not IsPassedManagementCu(GT_SEL_BRNO.BrNo)) then
begin
msg := '[%s(%s)] 지사에서 고객관련 관리권한 이관(콜센터 상담원)을 설정 하지 않았습니다.'
+ #13#10'(해당 지사관리자에게 관리권한 이관[회사>지사관리>상세설정]을 요청바랍니다.)';
GMessagebox(Format(msg, [GT_SEL_BRNO.BrNo, GT_SEL_BRNO.BrName]), CDMSE);
//- Panel14.Enabled := False;
// Panel15.Enabled := False;
// Panel16.Enabled := False;
Exit;
end;
if fGetChk_Search_HdBrNo('법인관리(법인업체)') then Exit;
//- Panel14.Enabled := True;
// Panel15.Enabled := True;
// Panel16.Enabled := True;
if (cbKeynumber12.Text = '') then
begin
CustView12_1.Root.TreeList.Clear;
edBubinName02.Clear;
cxTextEdit15.Clear;
CustView12_2.DataController.SetRecordCount(0);
cxViewCustom.DataController.SetRecordCount(0);
Exit;
end;
ls_rxxml := GTx_UnitXmlLoad('SEL04.XML');
xdom := ComsDomDocument.Create;
try
if (not xdom.loadXML(ls_rxxml)) then
begin
Screen.Cursor := crDefault;
ShowMessage('전문 Error입니다. 다시조회하여주십시요.');
Exit;
end;
//////////////////////////////////////////////////////////////////////////////
// 법인>법인관리>법인업체]10건/A100-B100/대표번호:16886618/법인,부서명:테크노
FExcelDownBubin := Format('%s/대표번호:%s%s',
[
GetSelBrInfo
, cbKeynumber12.Text
, IfThen(edBubinName01.Text = '', '', Format('/법인,부서명:%s', [edBubinName01.Text]))
]);
//////////////////////////////////////////////////////////////////////////////
if edBubinName01.Text <> '' then
sWhere := ' AND ((CB_CORP_NAME LIKE ''%' + En_Coding(Param_Filtering(edBubinName01.Text)) +
'%'') OR (CB_DEPT_NAME LIKE ''%' + En_Coding(Param_Filtering(edBubinName01.Text)) +
'%'')) ';
case cb_Contract.ItemIndex of
1: sWhere := sWhere + ' AND TAX_TYPE = ''0'' ';
2: sWhere := sWhere + ' AND TAX_TYPE = ''1'' ';
3: sWhere := sWhere + ' AND TAX_TYPE = ''2'' ';
end;
sWhere := sWhere + ' ORDER BY CB_CODE ';
sNode := '/cdms/header/UserID';
lst_Node := xdom.documentElement.selectNodes(sNode);
lst_Node.item[0].attributes.getNamedItem('Value').Text := En_Coding(GT_USERIF.ID);
sNode := '/cdms/header/ClientVer';
lst_Node := xdom.documentElement.selectNodes(sNode);
lst_Node.item[0].attributes.getNamedItem('Value').Text := VERSIONINFO;
sNode := '/cdms/header/ClientKey';
lst_Node := xdom.documentElement.selectNodes(sNode);
lst_Node.item[0].attributes.getNamedItem('Value').Text := self.Caption + '13';
sNode := '/cdms/Service/Data/Query';
lst_Node := xdom.documentElement.selectNodes(sNode);
lst_Node.item[0].attributes.getNamedItem('Key').Text := 'CUSTGROUP1';
lst_Node.item[0].attributes.getNamedItem('Backward').Text := sWhere;
sNode := '/cdms/Service/Data/Query/Param';
lst_Node := xdom.documentElement.selectNodes(sNode);
lst_clon := lst_node.item[0].cloneNode(True);
sNode := '/cdms/Service/Data/Query';
lst_Node := xdom.documentElement.selectNodes(sNode);
lst_Node.item[0].appendChild(lst_clon);
sNode := '/cdms/Service/Data/Query/Param';
lst_Node := xdom.documentElement.selectNodes(sNode);
lst_clon := lst_node.item[0].cloneNode(True);
sNode := '/cdms/Service/Data/Query';
lst_Node := xdom.documentElement.selectNodes(sNode);
lst_Node.item[0].appendChild(lst_clon);
sNode := '/cdms/Service/Data/Query/Param';
lst_Node := xdom.documentElement.selectNodes(sNode);
lst_Node.item[0].attributes.getNamedItem('Seq').Text := '1';
lst_Node.item[0].attributes.getNamedItem('Value').Text := cxHdNo12.Text;
lst_Node.item[1].attributes.getNamedItem('Seq').Text := '2';
lst_Node.item[1].attributes.getNamedItem('Value').Text := cxBrNo12.Text;
lst_Node.item[2].attributes.getNamedItem('Seq').Text := '3';
lst_Node.item[2].attributes.getNamedItem('Value').Text := StringReplace(cbKeynumber12.Text, '-', '', [rfReplaceAll]);
ls_TxLoad := '<?xml version="1.0" encoding="euc-kr"?>' + #13#10 + xDom.documentElement.xml;
Screen.Cursor := crHourGlass;
slReceive := TStringList.Create;
try
frm_Main.proc_SocketWork(False);
if dm.SendSock(ls_TxLoad, slReceive, ErrCode, False, 30000) then
begin
CustView12_1.Root.TreeList.Clear;
Application.ProcessMessages;
proc_recieve(slReceive);
edBubinName02.Clear;
cxTextEdit15.Clear;
CustView12_2.DataController.SetRecordCount(0);
cxViewCustom.DataController.SetRecordCount(0);
end;
finally
frm_Main.proc_SocketWork(True);
FreeAndNil(slReceive);
Screen.Cursor := crDefault;
Frm_Flash.Hide;
end;
finally
xdom := Nil;
end;
end;
procedure TFrm_CUT1.proc_BubinManage2;
var
ls_TxLoad, sNode, sWhere, msg: string;
ls_rxxml: WideString;
xdom: msDomDocument;
lst_Node: IXMLDOMNodeList;
lst_clon: IXMLDOMNode;
slReceive: TStringList;
ErrCode: integer;
begin
if (GT_SEL_BRNO.GUBUN <> '1') and (cxPageControl1.ActivePageIndex <> 6) then
begin
GMessagebox('법인업체 조회는 지사를 선택하셔야 합니다.', CDMSE);
//- Panel17.Enabled := False;
Exit;
end;
if (GT_USERIF.LV = '10') and (not IsPassedManagementCu(GT_SEL_BRNO.BrNo)) then
begin
msg := '[%s(%s)] 지사에서 고객관련 관리권한 이관(콜센터 상담원)을 설정 하지 않았습니다.'
+ #13#10'(해당 지사관리자에게 관리권한 이관[회사>지사관리>상세설정]을 요청바랍니다.)';
GMessagebox(Format(msg, [GT_SEL_BRNO.BrNo, GT_SEL_BRNO.BrName]), CDMSE);
//- Panel17.Enabled := False;
Exit;
end;
if fGetChk_Search_HdBrNo('법인이용내역(법인업체)') then Exit;
//- Panel17.Enabled := True;
ls_rxxml := GTx_UnitXmlLoad('SEL04.XML');
xdom := ComsDomDocument.Create;
try
if (not xdom.loadXML(ls_rxxml)) then
begin
Screen.Cursor := crDefault;
ShowMessage('전문 Error입니다. 다시조회하여주십시요.');
Exit;
end;
if cxTextEdit14.Text <> '' then
sWhere := ' AND ((CB_CORP_NAME LIKE ''%' + En_Coding(Param_Filtering(cxTextEdit14.Text)) +
'%'') OR (CB_DEPT_NAME LIKE ''%' + En_Coding(Param_Filtering(cxTextEdit14.Text)) +
'%'')) ';
sWhere := sWhere + ' ORDER BY CB_CODE ';
sNode := '/cdms/header/UserID';
lst_Node := xdom.documentElement.selectNodes(sNode);
lst_Node.item[0].attributes.getNamedItem('Value').Text :=
En_Coding(GT_USERIF.ID);
sNode := '/cdms/header/ClientVer';
lst_Node := xdom.documentElement.selectNodes(sNode);
lst_Node.item[0].attributes.getNamedItem('Value').Text := VERSIONINFO;
sNode := '/cdms/header/ClientKey';
lst_Node := xdom.documentElement.selectNodes(sNode);
lst_Node.item[0].attributes.getNamedItem('Value').Text := self.Caption + '16';
sNode := '/cdms/Service/Data/Query';
lst_Node := xdom.documentElement.selectNodes(sNode);
lst_Node.item[0].attributes.getNamedItem('Key').Text := 'CUSTGROUP1';
lst_Node.item[0].attributes.getNamedItem('Backward').Text := sWhere;
sNode := '/cdms/Service/Data/Query/Param';
lst_Node := xdom.documentElement.selectNodes(sNode);
lst_clon := lst_node.item[0].cloneNode(True);
sNode := '/cdms/Service/Data/Query';
lst_Node := xdom.documentElement.selectNodes(sNode);
lst_Node.item[0].appendChild(lst_clon);
sNode := '/cdms/Service/Data/Query/Param';
lst_Node := xdom.documentElement.selectNodes(sNode);
lst_clon := lst_node.item[0].cloneNode(True);
sNode := '/cdms/Service/Data/Query';
lst_Node := xdom.documentElement.selectNodes(sNode);
lst_Node.item[0].appendChild(lst_clon);
sNode := '/cdms/Service/Data/Query/Param';
lst_Node := xdom.documentElement.selectNodes(sNode);
lst_Node.item[0].attributes.getNamedItem('Seq').Text := '1';
lst_Node.item[0].attributes.getNamedItem('Value').Text := cxHdNo13.Text;
lst_Node.item[1].attributes.getNamedItem('Seq').Text := '2';
lst_Node.item[1].attributes.getNamedItem('Value').Text := GT_SEL_BRNO.BrNo;
lst_Node.item[2].attributes.getNamedItem('Seq').Text := '3';
lst_Node.item[2].attributes.getNamedItem('Value').Text := StringReplace(cbKeynumber13.Text, '-', '', [rfReplaceAll]);
ls_TxLoad := '<?xml version="1.0" encoding="euc-kr"?>' + #13#10 + xDom.documentElement.xml;
ls_TxLoad := StringReplace(ls_TxLoad, 'QeuryForwardString' , '' , [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'QeuryBackwardString', '' , [rfReplaceAll]);
Screen.Cursor := crHourGlass;
slReceive := TStringList.Create;
try
frm_Main.proc_SocketWork(False);
if dm.SendSock(ls_TxLoad, slReceive, ErrCode, False, 30000) then
begin
Application.ProcessMessages;
proc_recieve(slReceive);
end;
finally
frm_Main.proc_SocketWork(True);
FreeAndNil(slReceive);
Screen.Cursor := crDefault;
Frm_Flash.Hide;
end;
finally
xdom := Nil;
end;
end;
procedure TFrm_CUT1.proc_bubinSttSearch(vType : Integer; vSlip : String);
var
msg: string;
ErrCode, iRow, i, j, iCnt, index : integer;
Param, ErrMsg, XmlData: string;
xdom: MSDomDocument;
ls_MSG_Err: string;
ls_Rcrd, slList : TStringList;
sTmp : string;
lst_Result: IXMLDomNodeList;
begin
if (GT_USERIF.LV = '10') and (not IsPassedManagementCu(GT_SEL_BRNO.BrNo)) then
begin
msg := '[%s(%s)] 지사에서 고객관련 관리권한 이관(콜센터 상담원)을 설정 하지 않았습니다.'
+ #13#10'(해당 지사관리자에게 관리권한 이관[회사>지사관리>상세설정]을 요청바랍니다.)';
GMessagebox(Format(msg, [GT_SEL_BRNO.BrNo, GT_SEL_BRNO.BrName]), CDMSE);
Exit;
end;
if fGetChk_Search_HdBrNo('법인일일정산') then Exit;
//////////////////////////////////////////////////////////////////////////////
// 법인>법인일일정산]1000건/A100-B100/이용기간:20100101~20100131/오더상태:완료
FExcelDownBubinDaily := Format('%s/대표번호:%s/이용기간:%s~%s/오더상태:%s',
[
GetSelBrInfo
, cbKeynumber14.Text
, cxDate14_1S.Text, cxDate14_1E.Text
, IfThen(chkBubinSttOrdTotal.Checked, '전체', IfThen(chkBubinSttOrdFinish.Checked, '완료', IfThen(chkBubinSttOrdCancel.Checked, '취소', '문의')))
]);
//////////////////////////////////////////////////////////////////////////////
Param := '';
Param := GT_USERIF.LV;
if GT_SEL_BRNO.GUBUN <> '1' then
begin
if GT_USERIF.LV = '60' then
Param := Param + '│' + GT_SEL_BRNO.HDNO + '│' + ''
else if GT_USERIF.LV = '40' then
Param := Param + '│' + GT_USERIF.HD + '│' + GT_USERIF.BR
else if GT_USERIF.LV = '10' then
Param := Param + '│' + GT_USERIF.HD + '│' + GT_USERIF.BR
end else
if GT_SEL_BRNO.GUBUN = '1' then
begin
Param := Param + '│' + GT_SEL_BRNO.HDNO + '│' + GT_SEL_BRNO.BrNo
end;
Param := Param + '│' + GT_SEL_BRNO.GUBUN ;
if StartDateTime('yyyymmdd') = FormatDateTime('yyyymmdd', cxDate14_1S.Date) then
Param := Param + '│' + 'CDMS_A01_TODAY'
else
Param := Param + '│' + 'CDMS_A01';
Param := Param + '│' + FormatDateTime('yyyymmdd', cxDate14_1S.Date) + '090000';
Param := Param + '│' + FormatDateTime('yyyymmdd', cxDate14_1E.Date) + '090000';
if chkBubinSttOrdTotal.Checked then Param := Param + '│' + '0' else
if chkBubinSttOrdFinish.Checked then Param := Param + '│' + '1' else
if chkBubinSttOrdCancel.Checked then Param := Param + '│' + '2' else
if chkBubinSttOrdReq.Checked then Param := Param + '│' + '3';
if rbCust14Type02.Checked then Param := Param + '│' + 'y' else
if rbCust14Type03.Checked then Param := Param + '│' + 'n'
else Param := Param + '│' + '';
if rbCust14Type08.Checked then Param := Param + '│' + 'y' else
if rbCust14Type09.Checked then Param := Param + '│' + 'n'
else Param := Param + '│' + '';
if cbKeynumber14.Text <> '전체' then
Param := Param + '│' + StringReplace(cbKeynumber14.Text, '-', '', [rfReplaceAll])
else
Param := Param + '│' + '';
if vType = 0 then
begin
Param := Param + '│' + StringReplace(cxdBubinSttSearch.Text, '-', '', [rfReplaceAll]);
Param := Param + '│' + IntToStr(cbBubinSttCondition.ItemIndex);
end else
if vType = 1 then // 수정된 자료 1개만 가져올경우 사용
begin
Param := Param + '│' + vSlip;
Param := Param + '│' + '0';
end;
if chkBubinSttFinish.Checked then Param := Param + '│' + 'y' else
if chkBubinSttNotFinish.Checked then Param := Param + '│' + 'n' else
if chkBubinSttNotBubin.Checked then Param := Param + '│' + 'n'
else Param := Param + '│' + '';
if chkBubinSttPayAfter.Checked then Param := Param + '│' + '0' else
if chkBubinSttPayTick.Checked then Param := Param + '│' + '1' else
if chkBubinSttPayCash.Checked then Param := Param + '│' + '2'
else Param := Param + '│' + '';
if rbCust14Type05.Checked then Param := Param + '│' + 'y' else
if rbCust14Type06.Checked then Param := Param + '│' + 'n'
else Param := Param + '│' + '';
if chkBubinSttFinish.Checked then Param := Param + '│' + 'y' else
if chkBubinSttNotFinish.Checked then Param := Param + '│' + 'y' else
if chkBubinSttNotBubin.Checked then Param := Param + '│' + 'n'
else Param := Param + '│' + '';
cxPageControl1.Enabled := False;
Screen.Cursor := crHourGlass;
slList := TStringList.Create;
try
if not RequestBasePaging(GetSel06('GET_BGROUP_ORDER_LIST', 'MNG_BGROUP.GET_BGROUP_ORDER_LIST', '1000', Param), slList, ErrCode, ErrMsg) then
begin
GMessagebox(Format('법인 일일 정산 조회중 오류가 발생하였습니다.'#13#10'[%d]%s', [ErrCode, ErrMsg]), CDMSE);
cxPageControl1.Enabled := True;
Screen.Cursor := crDefault;
Exit;
end;
if vType = 0 then
begin
cxGBubinStt.DataController.SetRecordCount(0);
cxGrid_Angel.DataController.SetRecordCount(0);
for i := 0 to cxGBubinStt.ColumnCount - 1 do
cxGBubinStt.Columns[i].SortOrder := soNone;
end;
Frm_Flash.cxPBar1.Properties.Max := slList.Count;
Frm_Flash.cxPBar1.Position := 0;
for j := 0 to slList.Count - 1 do
begin
Frm_Flash.lblCnt.Visible := True;
Frm_Flash.lblDescription.Visible := True;
Frm_Flash.cxPBar1.Position := j + 1;
Frm_Flash.lblCnt.Caption := IntToStr(j + 1) + '/' + IntToStr(slList.Count);
Application.ProcessMessages;
xmlData := slList.Strings[j];
xdom := ComsDomDocument.Create;
try
if not xdom.loadXML(XmlData) then
begin
cxPageControl1.Enabled := True;
Screen.Cursor := crDefault;
Exit;
end;
iCnt := GetXmlRecordCount(XmlData);
if iCnt > 0 then
begin
lst_Result := xdom.documentElement.selectNodes('/cdms/Service/Data/Result');
ls_MSG_Err := GetXmlErrorCode(XmlData);
if ('0000' = ls_MSG_Err) then
begin
frm_Main.sbar_Message.Panels[4].Text := '';
cxGBubinStt.BeginUpdate;
cxGrid_Angel.BeginUpdate;
chkBubinStt.Checked := False;
ls_Rcrd := TStringList.Create;
try
for i := 0 to iCnt - 1 do
begin
Application.ProcessMessages;
GetTextSeperationEx('│', lst_Result.item[i].attributes.getNamedItem('Value').Text, ls_Rcrd);
if vType = 0 then
begin
ls_Rcrd.Insert(0, '0');
iRow := cxGBubinStt.DataController.AppendRecord;
end else
if vType = 1 then
begin
if (vSlip <> ls_Rcrd[2]) then Continue;
iRow := cxGBubinStt.DataController.FindRecordIndexByText(0, 4, vSlip, False, True, True);
if iRow < 0 then Continue;
ls_Rcrd.Insert(0, cxGBubinStt.DataController.Values[iRow, 0]);
end;
// 1 Record 추가
ls_Rcrd.Insert(0, IntToStr(iRow + 1));
sTmp := ls_Rcrd[11];
if sTmp <> '' then
ls_Rcrd[11] := Copy(sTmp, 1, 10) + ' ' + Copy(sTmp, 11, 8);
sTmp := ls_Rcrd[21];
if sTmp <> '' then
ls_Rcrd[21] := Copy(sTmp, 1, 10) + ' ' + Copy(sTmp, 11, 8);
sTmp := ls_Rcrd[22];
if StrToFloatDef(sTmp, -9) = -9 then
ls_Rcrd[22] := '0.0';
cxGBubinStt.DataController.Values[iRow, 0] := ls_Rcrd[0]; //0-순번
cxGBubinStt.DataController.Values[iRow, 1] := ls_Rcrd[1]; //1-선택
cxGBubinStt.DataController.Values[iRow, 2] := ls_Rcrd[2]; //2-오더상태
cxGBubinStt.DataController.Values[iRow, 3] := ls_Rcrd[3]; //3-결제방식
cxGBubinStt.DataController.Values[iRow, 4] := ls_Rcrd[4]; //4-접수번호
if ls_Rcrd[44] = 'n' then
cxGBubinStt.DataController.Values[iRow, 5] := '개인정산'
else
cxGBubinStt.DataController.Values[iRow, 5] := ls_Rcrd[5]; //5-정산여부
cxGBubinStt.DataController.Values[iRow, 6] := ls_Rcrd[6]; //6-웹열람
cxGBubinStt.DataController.Values[iRow, 7] := ls_Rcrd[7]; //7-법인명
cxGBubinStt.DataController.Values[iRow, 8] := ls_Rcrd[8]; //8-부서명
cxGBubinStt.DataController.Values[iRow, 9] := ls_Rcrd[9]; //9-고객명
cxGBubinStt.DataController.Values[iRow, 10] := strtocall(ls_Rcrd[10]); //10-전화번호
cxGBubinStt.DataController.Values[iRow, 11] := ls_Rcrd[11]; //11-최초접수일시
cxGBubinStt.DataController.Values[iRow, 12] := ls_Rcrd[12]; //12-출시도
cxGBubinStt.DataController.Values[iRow, 13] := ls_Rcrd[13]; //13-출시군구
cxGBubinStt.DataController.Values[iRow, 14] := ls_Rcrd[14]; //14-출읍면동
cxGBubinStt.DataController.Values[iRow, 15] := ls_Rcrd[15]; //15-출입력
cxGBubinStt.DataController.Values[iRow, 16] := ls_Rcrd[16]; //16-도시도
cxGBubinStt.DataController.Values[iRow, 17] := ls_Rcrd[17]; //17-도시군구
cxGBubinStt.DataController.Values[iRow, 18] := ls_Rcrd[18]; //18-도읍면동
cxGBubinStt.DataController.Values[iRow, 19] := ls_Rcrd[19]; //19-도입력
cxGBubinStt.DataController.Values[iRow, 20] := ls_Rcrd[20]; //20-대기시간
cxGBubinStt.DataController.Values[iRow, 21] := ls_Rcrd[21]; //21-완료시간
cxGBubinStt.DataController.Values[iRow, 22] := ls_Rcrd[22]; //22-거리
cxGBubinStt.DataController.Values[iRow, 23] := ls_Rcrd[23]; //23-적요1
cxGBubinStt.DataController.Values[iRow, 24] := ls_Rcrd[24]; //24적요2
cxGBubinStt.DataController.Values[iRow, 25] := StrToIntDef(ls_Rcrd[25],0); //25-접수요금
cxGBubinStt.DataController.Values[iRow, 26] := StrToIntDef(ls_Rcrd[26],0); //26-기사수수료
cxGBubinStt.DataController.Values[iRow, 27] := StrToIntDef(ls_Rcrd[27],0); //27-실지급액
cxGBubinStt.DataController.Values[iRow, 28] := StrToIntDef(ls_Rcrd[28],0); //28-보정금액
cxGBubinStt.DataController.Values[iRow, 29] := StrToIntDef(ls_Rcrd[29],0); //29-기본요금
cxGBubinStt.DataController.Values[iRow, 30] := StrToIntDef(ls_Rcrd[30],0); //30-경유요금
cxGBubinStt.DataController.Values[iRow, 31] := StrToIntDef(ls_Rcrd[31],0); //31-대기요금
cxGBubinStt.DataController.Values[iRow, 32] := StrToIntDef(ls_Rcrd[32],0); //32-공급가
cxGBubinStt.DataController.Values[iRow, 33] := StrToIntDef(ls_Rcrd[33],0); //33-부가세
cxGBubinStt.DataController.Values[iRow, 34] := StrToIntDef(ls_Rcrd[34],0); //34-기타지급금
cxGBubinStt.DataController.Values[iRow, 35] := StrToIntDef(ls_Rcrd[35],0); //35-합계
cxGBubinStt.DataController.Values[iRow, 36] := ls_Rcrd[36]; //36-기타사유
cxGBubinStt.DataController.Values[iRow, 37] := ls_Rcrd[37]; //37-서명
cxGBubinStt.DataController.Values[iRow, 38] := ls_Rcrd[38]; //38-승인
cxGBubinStt.DataController.Values[iRow, 39] := ls_Rcrd[39]; //39-소속
cxGBubinStt.DataController.Values[iRow, 40] := ls_Rcrd[40]; //40-기사명
cxGBubinStt.DataController.Values[iRow, 41] := ls_Rcrd[41]; //41-기사사번
cxGBubinStt.DataController.Values[iRow, 42] := ls_Rcrd[42]; //42-경유지
cxGBubinStt.DataController.Values[iRow, 43] := ls_Rcrd[43]; //43-부가세포함
//BGROUP Y/n ls_Rcrd[44]
cxGBubinStt.DataController.Values[iRow, 44] := ls_Rcrd[45]; //44-날씨
//지사코드 ls_Rcrd[46];
if ls_Rcrd[47] = 'y' then sTmp := '탁송' else sTmp := '대리';
cxGBubinStt.DataController.Values[iRow, 45] := sTmp; //45-서비스명
cxGBubinStt.DataController.Values[iRow, 46] := ls_Rcrd[48]; //46-고객직책
cxGBubinStt.DataController.Values[iRow, 47] := ls_Rcrd[49]; //47-기사사번(자체사번)
cxGBubinStt.DataController.Values[iRow, 48] := ls_Rcrd[50]; //48-오더 취소사유
cxGBubinStt.DataController.Values[iRow, 49] := ls_Rcrd[51]; //49-자/타기사 구분
cxGBubinStt.DataController.Values[iRow, 50] := copy(ls_Rcrd[52], 1, 10) + ' ' + copy(ls_Rcrd[52], 11, 8); //50-배차시간 '2021-02-2318:18:43'
cxGBubinStt.DataController.Values[iRow, 51] := StrToIntDef(ls_Rcrd[54], 0); //51-기타비용
cxGBubinStt.DataController.Values[iRow, 52] := StrToIntDef(ls_Rcrd[55], 0); //52-지원금
cxGBubinStt.DataController.Values[iRow, 53] := StrToIntDef(ls_Rcrd[56], 0); //53-현금결제액
cxGBubinStt.DataController.Values[iRow, 54] := StrToIntDef(ls_Rcrd[57], 0); //54-카드결제액
cxGBubinStt.DataController.Values[iRow, 55] := ls_Rcrd[58]; //55-기사메모
cxGBubinStt.DataController.Values[iRow, 56] := ls_Rcrd[59]; //56-고객메모
cxGBubinStt.DataController.Values[iRow, 57] := ls_Rcrd[60]; //57-고객구분 : 법인/개인/업소
cxGBubinStt.DataController.Values[iRow, 58] := ls_Rcrd[61]; //58-접수자: 상담원명/ID
cxGBubinStt.DataController.Values[iRow, 59] := ls_Rcrd[62]; //59-법인코드
cxGBubinStt.DataController.Values[iRow, 60] := ls_Rcrd[53]; //60-결제구분(사용안함)
//추가요청한 값은 ls_Rcrd[47] 부터시작
//ls_Rcrd[47] 서비스명
//48 고객직책
//49 기사사번(자체사번)
//50 오더 취소사유
//51 자/타기사 구분
//52 배차시간
//53 결제구분
//54 기타비용
//55 지원금
//56 현금결제액
//57 카드결제액
//58 기사메모
//59 고객메모
//60 고객구분 : 법인/개인/업소
//61 접수자: 상담원명/ID
//62 법인코드
///////////////////////////정산전용 엑셀//////////////////////////////
iRow := cxGrid_Angel.DataController.AppendRecord;
cxGrid_Angel.DataController.Values[iRow, 0] := ls_Rcrd[ 0]; //순번
cxGrid_Angel.DataController.Values[iRow, 1] := ls_Rcrd[ 4]; //접수번호
//영업일일자 계산
sTmp := StringReplace(ls_Rcrd[11], ' ', '', [rfReplaceAll]);
sTmp := StringReplace(sTmp, '-', '', [rfReplaceAll]);
sTmp := StringReplace(sTmp, ':', '', [rfReplaceAll]);
sTmp := func_JON03SalesDate(sTmp);
cxGrid_Angel.DataController.Values[iRow, 2] := sTmp; //영업일
cxGrid_Angel.DataController.Values[iRow, 3] := ls_Rcrd[11]; //접수일시-최초접수일시
cxGrid_Angel.DataController.Values[iRow, 4] := ls_Rcrd[60]; //지사명
if ls_Rcrd[47] = 'y' then sTmp := '탁송' else sTmp := '대리';
cxGrid_Angel.DataController.Values[iRow, 5] := sTmp; //서비스명
if ls_Rcrd[ 2] = '2' then sTmp := '완료' else
if ls_Rcrd[ 2] = '4' then sTmp := '문의' else
if ls_Rcrd[ 2] = '8' then sTmp := '취소' else
if ls_Rcrd[ 2] = '0' then sTmp := '접수' else
if ls_Rcrd[ 2] = '1' then sTmp := '배차' else
if ls_Rcrd[ 2] = '3' then sTmp := '강제' else
if ls_Rcrd[ 2] = '5' then sTmp := '대기' else
if ls_Rcrd[ 2] = 'R' then sTmp := '예약';
cxGrid_Angel.DataController.Values[iRow, 6] := sTmp ; //접수상태- 오더상태
cxGrid_Angel.DataController.Values[iRow, 7] := '법인'; //법인/일반 무조건 법인만 조회된다고 함. 서승우과장
cxGrid_Angel.DataController.Values[iRow, 8] := ls_Rcrd[ 9]; //고객명
cxGrid_Angel.DataController.Values[iRow, 9] := ls_Rcrd[48]; //고객직책
cxGrid_Angel.DataController.Values[iRow, 10] := strtocall(ls_Rcrd[10]); //고객전화번호
cxGrid_Angel.DataController.Values[iRow, 11] := ls_Rcrd[62]; //업체 ID-법인코드
cxGrid_Angel.DataController.Values[iRow, 12] := ls_Rcrd[ 7]; //업체명
cxGrid_Angel.DataController.Values[iRow, 13] := ls_Rcrd[61]; //접수자
cxGrid_Angel.DataController.Values[iRow, 14] := ls_Rcrd[50]; //접수취소사유
cxGrid_Angel.DataController.Values[iRow, 15] := ls_Rcrd[41]; //기사ID
cxGrid_Angel.DataController.Values[iRow, 16] := ls_Rcrd[49]; //기사사번
cxGrid_Angel.DataController.Values[iRow, 17] := ls_Rcrd[40]; //기사명
cxGrid_Angel.DataController.Values[iRow, 18] := ls_Rcrd[51]; //자/타기사 구분
cxGrid_Angel.DataController.Values[iRow, 19] := copy(ls_Rcrd[52], 1, 10) + ' ' + copy(ls_Rcrd[52], 11, 8); //배차시간
cxGrid_Angel.DataController.Values[iRow, 20] := ls_Rcrd[20]; //대기시간
cxGrid_Angel.DataController.Values[iRow, 21] := ls_Rcrd[21]; //운행종료시간
cxGrid_Angel.DataController.Values[iRow, 22] := ls_Rcrd[15]; //출발지 POI
cxGrid_Angel.DataController.Values[iRow, 23] := ls_Rcrd[12] + ' ' + ls_Rcrd[13] + ' ' + ls_Rcrd[14];//출발주소
cxGrid_Angel.DataController.Values[iRow, 24] := ls_Rcrd[12]; //출발지 시/도
cxGrid_Angel.DataController.Values[iRow, 25] := ls_Rcrd[13]; //출발지 구/군
cxGrid_Angel.DataController.Values[iRow, 26] := ls_Rcrd[14]; //출발지 동/리
cxGrid_Angel.DataController.Values[iRow, 27] := ls_Rcrd[15]; //도착지 POI
cxGrid_Angel.DataController.Values[iRow, 28] := ls_Rcrd[16] + ' ' + ls_Rcrd[17] + ' ' + ls_Rcrd[18];//도착주소
cxGrid_Angel.DataController.Values[iRow, 29] := ls_Rcrd[16]; //도착지 시/도
cxGrid_Angel.DataController.Values[iRow, 30] := ls_Rcrd[17]; //도착지 구/군
cxGrid_Angel.DataController.Values[iRow, 31] := ls_Rcrd[18]; //도착지 동/리
cxGrid_Angel.DataController.Values[iRow, 32] := ls_Rcrd[42]; //경유지
cxGrid_Angel.DataController.Values[iRow, 33] := ls_Rcrd[22]; //주행거리
if ls_Rcrd[53] = '0' then sTmp := '현금' else
if ls_Rcrd[53] = '1' then sTmp := '마일리지' else
if ls_Rcrd[53] = '2' then sTmp := '후불' else
if ls_Rcrd[53] = '3' then sTmp := '모바일결제' else
if ls_Rcrd[53] = '4' then sTmp := '외상' else
if ls_Rcrd[53] = '5' then sTmp := '카드' else
if ls_Rcrd[53] = '6' then sTmp := '즉불' else
if ls_Rcrd[53] = '7' then sTmp := '후불(카드)' else
if ls_Rcrd[53] = '8' then sTmp := '후불(마일)';
cxGrid_Angel.DataController.Values[iRow, 34] := sTmp; //지불유형 //2
cxGrid_Angel.DataController.Values[iRow, 35] := StrToIntDef(ls_Rcrd[25],0); //접수요금
cxGrid_Angel.DataController.Values[iRow, 36] := StrToIntDef(ls_Rcrd[30],0); //경유요금
cxGrid_Angel.DataController.Values[iRow, 37] := StrToIntDef(ls_Rcrd[31],0); //대기요금
cxGrid_Angel.DataController.Values[iRow, 38] := StrToIntDef(ls_Rcrd[54],0); //기타비용
cxGrid_Angel.DataController.Values[iRow, 39] := StrToIntDef(ls_Rcrd[55],0); //지원금
cxGrid_Angel.DataController.Values[iRow, 40] := StrToIntDef(ls_Rcrd[28],0); //보정금
cxGrid_Angel.DataController.Values[iRow, 41] := StrToIntDef(ls_Rcrd[56],0); //현금결제액
cxGrid_Angel.DataController.Values[iRow, 42] := StrToIntDef(ls_Rcrd[57],0); //카드결제액
cxGrid_Angel.DataController.Values[iRow, 43] := StrToIntDef(ls_Rcrd[26],0); //기사수수료
cxGrid_Angel.DataController.Values[iRow, 44] := '20%'; //기사수수료율
cxGrid_Angel.DataController.Values[iRow, 45] := ls_Rcrd[58]; //기사메모
cxGrid_Angel.DataController.Values[iRow, 46] := ls_Rcrd[59]; //고객메모
end;
Except
ls_Rcrd.Free;
Screen.Cursor := crDefault;
cxPageControl1.Enabled := True;
cxGBubinStt.EndUpdate;
cxGrid_Angel.EndUpdate;
Frm_Flash.Hide;
GMessagebox(MSG012 + CRLF + ls_MSG_Err, CDMSE);
end;
ls_Rcrd.Free;
Screen.Cursor := crDefault;
cxPageControl1.Enabled := True;
cxGBubinStt.EndUpdate;
cxGrid_Angel.EndUpdate;
// 최초접수일시로 오름차순 처리
cxGBubinStt.Columns[11].SortOrder := soAscending;
gfSetIndexNo(cxGBubinStt, True);
frm_Main.sbar_Message.Panels[4].Text := '';
end;
end else
begin
GMessagebox('검색된 내용이 없습니다.', CDMSE);
cxPageControl1.Enabled := True;
Screen.Cursor := crDefault;
end;
finally
xdom := Nil;
end;
end;
finally
cxPageControl1.Enabled := True;
Screen.Cursor := crDefault;
Frm_Flash.lblCnt.Visible := False;
Frm_Flash.lblDescription.Visible := False;
Frm_Flash.Hide;
FreeAndNil(slList);
end;
end;
procedure TFrm_CUT1.proc_BubinStt_Select(iRow: Integer);
begin
if iRow >= 0 then
begin
if ( Not Assigned(Frm_CUT019) ) Or ( Frm_CUT019 = Nil ) then Frm_CUT019 := TFrm_CUT019.Create(Nil);
Frm_CUT019.lbSosokCaption.Caption := cxGBubinStt.DataController.Values[iRow, 39];
Frm_CUT019.cxlbConfSlip.Caption := cxGBubinStt.DataController.Values[iRow, 4];
Frm_CUT019.cxlbFirstTime.Caption := cxGBubinStt.DataController.Values[iRow, 11];
Frm_CUT019.cxlbFinish.Caption := cxGBubinStt.DataController.Values[iRow, 21];
if cxGBubinStt.DataController.Values[iRow, 3] = '후불' then
Frm_CUT019.chkBubinSttPayAfter.Checked := True
else if cxGBubinStt.DataController.Values[iRow, 3] = '외상' then
Frm_CUT019.chkBubinSttPayTick.Checked := True
else Frm_CUT019.chkBubinSttPayCash.Checked := True;
if cxGBubinStt.DataController.Values[iRow, 2] = '취소' then
Frm_CUT019.chkBubinSttOrdCancel.Checked := True
else if cxGBubinStt.DataController.Values[iRow, 2] = '문의' then
Frm_CUT019.chkBubinSttOrdReq.Checked := True
else
Frm_CUT019.chkBubinSttOrdFinish.Checked := True;
if cxGBubinStt.DataController.Values[iRow, 5] = '완료' then
Frm_CUT019.chkBubinSttFinish.Checked := True
else if cxGBubinStt.DataController.Values[iRow, 5] = '미정산' then
Frm_CUT019.chkBubinSttNotFinish.Checked := True
else if cxGBubinStt.DataController.Values[iRow, 5] = '개인정산' then
Frm_CUT019.chkBubinSttNotBubin.Checked := True;
if cxGBubinStt.DataController.Values[iRow, 6] = '가능' then
Frm_CUT019.chkBubinSttWebView.Checked := True
else
Frm_CUT019.chkBubinSttWebViewNo.Checked := True;
if cxGBubinStt.DataController.Values[iRow, 37] = 'YES' then
begin
Frm_CUT019.cxRadioButton1.Checked := True;
Frm_CUT019.Panel8.Color := $00F3D9BE;
Frm_CUT019.Panel8.Enabled := False;
end else
if cxGBubinStt.DataController.Values[iRow, 37] = '서명대체' then
begin
Frm_CUT019.Panel8.Enabled := True;
Frm_CUT019.Panel8.Color := clWhite;
Frm_CUT019.cxRadioButton3.checked := True;
end else
begin
Frm_CUT019.cxRadioButton2.Checked := True;
Frm_CUT019.Panel8.Color := clWhite;
Frm_CUT019.Panel8.Enabled := True;
end;
if cxGBubinStt.DataController.Values[iRow, 38] = '승인' then
Frm_CUT019.chkBubinSttAuth.Checked := True
else
Frm_CUT019.chkBubinSttNotAuth.Checked := True;
if cxGBubinStt.DataController.Values[iRow, 43] = 'n' then
Frm_CUT019.cxRadioButton5.Checked := True
else
Frm_CUT019.cxRadioButton4.Checked := True;
if Frm_CUT019.cbBubinSttWether.Properties.Items.IndexOf(cxGBubinStt.DataController.Values[iRow, 44]) > -1 then
Frm_CUT019.cbBubinSttWether.ItemIndex := Frm_CUT019.cbBubinSttWether.Properties.Items.IndexOf(cxGBubinStt.DataController.Values[iRow, 44]);
Frm_CUT019.cxlbuser.Text := cxGBubinStt.DataController.Values[iRow, 9];
Frm_CUT019.cxlbCuTel.Text := cxGBubinStt.DataController.Values[iRow, 10];
Frm_CUT019.cxlbBubin.Caption := cxGBubinStt.DataController.Values[iRow, 7] + ' / ' + cxGBubinStt.DataController.Values[iRow, 8];
Frm_CUT019.cxtStartAreaDetail.Text := cxGBubinStt.DataController.Values[iRow, 15];
Frm_CUT019.lblStartAreaName1.Text := cxGBubinStt.DataController.Values[iRow, 12];
Frm_CUT019.lblStartAreaName2.Text := cxGBubinStt.DataController.Values[iRow, 13];
Frm_CUT019.lblStartAreaName3.Text := cxGBubinStt.DataController.Values[iRow, 14];
Frm_CUT019.cxtEndAreaDetail.Text := cxGBubinStt.DataController.Values[iRow, 19];
Frm_CUT019.lblEndAreaName1.Text := cxGBubinStt.DataController.Values[iRow, 16];
Frm_CUT019.lblEndAreaName2.Text := cxGBubinStt.DataController.Values[iRow, 17];
Frm_CUT019.lblEndAreaName3.Text := cxGBubinStt.DataController.Values[iRow, 18];
Frm_CUT019.cxtViaAreaDetail.Text := cxGBubinStt.DataController.Values[iRow, 42];
Frm_CUT019.cxlbWkName.Caption := cxGBubinStt.DataController.Values[iRow, 40];
Frm_CUT019.cxlbWkSabun.Caption := cxGBubinStt.DataController.Values[iRow, 41];
Frm_CUT019.cxlbCharge.Caption := FormatFloat('#,##0', cxGBubinStt.DataController.Values[iRow, 25]);
Frm_CUT019.cxtDis.Text := cxGBubinStt.DataController.Values[iRow, 22];
Frm_CUT019.cxlbCommission.Caption := FormatFloat('#,##0', cxGBubinStt.DataController.Values[iRow, 26]);
Frm_CUT019.cxlbRealCharge.Caption := FormatFloat('#,##0', cxGBubinStt.DataController.Values[iRow, 27]);
Frm_CUT019.cxtBaseCharge.Text := cxGBubinStt.DataController.Values[iRow, 29];
Frm_CUT019.cxtWaitTime.Text := cxGBubinStt.DataController.Values[iRow, 20];
Frm_CUT019.cxtWaitCharge.Text := cxGBubinStt.DataController.Values[iRow, 31];
Frm_CUT019.cxtPassCharge.Text := cxGBubinStt.DataController.Values[iRow, 30];
Frm_CUT019.cxtAddCharge.Text := cxGBubinStt.DataController.Values[iRow, 28]; //경유요금
Frm_CUT019.lb_OTHER_CHARGE.Caption := FormatFloat('#,##0', cxGBubinStt.DataController.Values[iRow, 51]); //기타지급금
Frm_CUT019.lb_SUPPORT_CHARGE.Caption := FormatFloat('#,##0', cxGBubinStt.DataController.Values[iRow, 52]); //지원금
Frm_CUT019.meoInfo1.Text := cxGBubinStt.DataController.Values[iRow, 23];
Frm_CUT019.meoInfo2.Text := cxGBubinStt.DataController.Values[iRow, 24];
Frm_CUT019.cxtCharge1.Text := cxGBubinStt.DataController.Values[iRow, 32];
Frm_CUT019.cxtTax.Text := cxGBubinStt.DataController.Values[iRow, 33];
Frm_CUT019.cxtEtc.Text := cxGBubinStt.DataController.Values[iRow, 34];
Frm_CUT019.cxtSum.Text := cxGBubinStt.DataController.Values[iRow, 35];
Frm_CUT019.meoEtc.Text := cxGBubinStt.DataController.Values[iRow, 36];
Frm_CUT019.Show;
Frm_CUT019.btnCalc.Click;
end;
end;
procedure TFrm_CUT1.proc_cust_bubin_Modify(iType: Integer;
advGrid: TcxGridDBTableView);
var
ls_rxxml: WideString;
ls_TxLoad, rv_str, ls_TxQry, sQueryTemp: string;
sSet, sCbCode, sWhere, sMsg, ls_Msg_Err: string;
i, iCnt, sCnt, fCnt, iCuseq: Integer;
slReceive: TStringList;
ErrCode: integer;
begin
sCbCode := cxTextEdit15.Text;
if iType = 0 then
begin
sSet := 'CU_TYPE = ''3'', CB_CODE = ''' + sCbCode + ''' ';
sMsg := '[%s]법인에 %s명을 등록 하시겠습니까?';
end else
begin
sSet := 'CU_TYPE = ''0'', CB_CODE = '''' ';
sMsg := '[%s]법인에서 %s명을 삭제 하시겠습니까?';
end;
iCnt := advGrid.DataController.GetSelectedCount;
iCuseq := advGrid.GetColumnByFieldName('고객코드').Index;
sWhere := '';
if iCnt < 1 then
begin
GMessagebox('선택된 고객이 없습니다.' + #13#10 +
'먼저 고객을 선택하세요!', CDMSE);
Exit;
end;
sMsg := Format(sMsg, [sCbCode, IntToStr(iCnt)]);
if GMessagebox(sMsg, CDMSQ) <> IDOK then
Exit;
Screen.Cursor := crHandPoint;
sCnt := 0;
fCnt := 0;
try
for I := 0 to advGrid.DataController.RecordCount - 1 do
begin
if advGrid.ViewData.Records[I].Selected then
begin
sWhere := advGrid.ViewData.Records[I].Values[iCuseq];
advGrid.ViewData.Records[I].Selected := False;
ls_TxLoad := GTx_UnitXmlLoad('QUERY.XML');
fGet_BlowFish_Query(GSQ_CUSTOMER_BUBIN_MODIFY, sQueryTemp);
ls_TxQry := Format(sQueryTemp, [sSet, sWhere]);
ls_TxLoad := StringReplace(ls_TxLoad, 'UserIDString', GT_USERIF.ID, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientVerString', VERSIONINFO, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientKeyString', 'CUSTBUBINMOD', [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'QueryString', ls_TxQry, [rfReplaceAll]);
slReceive := TStringList.Create;
try
if dm.SendSock(ls_TxLoad, slReceive, ErrCode, False) then
begin
rv_str := slReceive[0];
if rv_str <> '' then
begin
ls_rxxml := rv_str;
ls_Msg_Err := GetXmlErrorCode(ls_rxxml);
if ('0000' = ls_Msg_Err) then
begin
sCnt := sCnt + 1; //성공건수
end else
begin
fCnt := fCnt + 1; //실패건수
end;
end;
end;
finally
FreeAndNil(slReceive);
Screen.Cursor := crDefault;
Frm_Flash.Hide;
end;
end;
end;
except
end;
btn_12_8Click(btn_12_8);
Sleep(1000);
GMessagebox('성공건수 : ' + IntToStr(sCnt) + #13#10 + '실패건수 : ' +
IntToStr(fCnt), CDMSI);
Screen.Cursor := crDefault;
end;
procedure TFrm_CUT1.proc_delete_gbroup(sCode: string);
const
ls_Param = '<param>ParamString</param>';
var
rv_str, ls_TxLoad, ls_Msg_Err, sMsg, sBrNo: string;
sParam, sTemp: string;
ls_rxxml: WideString;
slReceive: TStringList;
ErrCode: integer;
CustomerCount: Integer;
begin
if CustView12_1.Selections[0].HasChildren then
begin
GMessagebox('서브 법인(업체)가 있으면 삭제할 수 업습니다.', CDMSE);
Exit;
end;
sBrNo := cxBrNo12.Text;
sTemp := CustView12_1.Selections[0].Values[7];
CustomerCount := GetDeptCustomerCount(cxHdNo12.Text, cxBrNo12.Text, sTemp);
case CustomerCount of
-1:
begin
GMessagebox('실패하였습니다.' + #13#10 + '다시 한번 시도해 보세요', CDMSE);
Exit;
end;
0:
;
else
begin
GMessagebox(Format('법인 부서에 소속된 고객수가 [%d]명 존재합니다.', [CustomerCount]) + #13#10
+ '해당 고객을 부서변경/삭제 후 부서 삭제를 시도 바랍니다.', CDMSE);
Exit;
end;
end;
if GMessagebox('삭제하시겠습니까?', CDMSQ) = IDCANCEL then Exit;
ls_TxLoad := GTx_UnitXmlLoad('CALLABLE.xml');
sTemp := 'DELETE_CUST_BGROUP(?,?,?,?)';
sParam := StringReplace(ls_Param, 'ParamString', sCode, [rfReplaceAll]);
sParam := sParam + StringReplace(ls_Param, 'ParamString', sBrNo, [rfReplaceAll]);
sParam := sParam + StringReplace(ls_Param, 'ParamString', cxHdNo12.Text, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'UserIDString', En_Coding(GT_USERIF.ID), [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientVerString', VERSIONINFO, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientKeyString', Self.Caption + '14', [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'CallString', sTemp, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'CountString', IntToStr(3), [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ParamString', sParam, [rfReplaceAll]);
Screen.Cursor := crHandPoint;
slReceive := TStringList.Create;
try
if dm.SendSock(ls_TxLoad, slReceive, ErrCode, False) then
begin
rv_str := slReceive[0];
if rv_str <> '' then
begin
ls_rxxml := rv_str;
try
ls_Msg_Err := GetXmlErrorCode(ls_rxxml);
sMsg := GetXmlErrorMsg(ls_rxxml);
if ('0000' = ls_Msg_Err) and ('1' = sMsg) then
begin
GMessagebox('성공하였습니다.', CDMSI);
CustView12_1.Root.TreeList.Clear;
proc_BubinManage;
CustView12_2.DataController.SetRecordCount(0);
end else
if ('0000' = ls_Msg_Err) and ('2' = sMsg) then
begin
GMessagebox('서브 법인(업체)이 있으면 삭제할 수 없습니다.' + #13#10 +
'먼저 서브 법인(업체)을 삭제하세요!', CDMSE);
end else
begin
GMessagebox('실패하였습니다.' + #13#10 + '다시 한번 시도해 보세요', CDMSE);
end;
except
GMessagebox('실패하였습니다.' + #13#10 + '다시 한번 시도해 보세요', CDMSE);
end;
end;
end;
finally
Frm_Main.proc_bubinlist_insert;
FreeAndNil(slReceive);
Screen.Cursor := crDefault;
Frm_Flash.Hide;
end;
end;
procedure TFrm_CUT1.proc_init;
var
i, iCol : Integer;
ln_env: TIniFile;
sTemp: string;
slHidn: TStringList;
begin
proc_BrNameSet;
//12 B-1//
if TCK_USER_PER.CUR_BubinMngModify = '1' then
begin
btn_12_2.Enabled := True;
btn_12_4.Enabled := True;
btn_12_13.Enabled := True;
btn_12_14.Enabled := True;
end else
begin
btn_12_2.Enabled := False;
btn_12_4.Enabled := False;
btn_12_13.Enabled := False;
btn_12_14.Enabled := False;
end;
gsCustViewParam := '';
edCbCode.text := '';
lb_Date01.caption := '';
lb_Date02.caption := '';
lb_UseCnt01.caption := '';
edName01.Text := '';
edName03.Text := '';
edtCustStateMemo.Text := '';
edtCustMemo.Text := '';
cb_Contract2.ItemIndex := -1;
dtRegDate.Text := '';
dtFinDate.Text := '';
edWebID.Text := '';
edWebPW.Text := '';
edName01.enabled := false;
edName03.enabled := false;
edtCustStateMemo.enabled := false;
edtCustMemo.enabled := false;
cb_Contract2.enabled := false;
dtRegDate.enabled := false;
dtFinDate.enabled := false;
pnl_Vat.enabled := false;
pnl_Bill.enabled := false;
edWebPW.enabled := false;
for i := 0 to cxGridBebinList.ColumnCount - 1 do
begin
cxGridBebinList.Columns[i].DataBinding.ValueType := 'String';
end;
cxGridBebinList.DataController.SetRecordCount(0);
edBubinName01.Text := '';
cbGubun12_1.ItemIndex := 0;
edCustName05.Text := '';
edCustTel04.Text := '';
edBubinName02.Text := '';
cxTextEdit15.Text := '';
for i := 0 to CustView12_1.ColumnCount - 1 do
CustView12_1.Columns[i].DataBinding.ValueType := 'String';
CustView12_1.Columns[1].DataBinding.ValueType := 'Integer';
CustView12_2.Columns[0].DataBinding.ValueType := 'Integer';
for i := 1 to CustView12_2.ColumnCount - 1 do
CustView12_2.Columns[i].DataBinding.ValueType := 'String';
iCol := CustView12_2.GetColumnByFieldName('적립마일리지').Index;
CustView12_2.Columns[iCol].DataBinding.ValueType := 'Currency';
cxViewCustom.Columns[0].DataBinding.ValueType := 'Integer';
for i := 1 to cxViewCustom.ColumnCount - 1 do
cxViewCustom.Columns[i].DataBinding.ValueType := 'String';
iCol := cxViewCustom.GetColumnByFieldName('적립마일리지').Index;
cxViewCustom.Columns[iCol].DataBinding.ValueType := 'Currency';
CustView12_3.Columns[0].DataBinding.ValueType := 'Integer';
for i := 1 to CustView12_3.ColumnCount - 1 do
CustView12_3.Columns[i].DataBinding.ValueType := 'String';
iCol := CustView12_3.GetColumnByFieldName('적립마일리지').Index;
CustView12_3.Columns[iCol].DataBinding.ValueType := 'Currency';
//12 B-1//
//13 B-2//
cxDate13_1S.Date := StrToDate(Date8to10(copy(StartDateTime('yyyymmddhhmmss'), 1, 8)));
cxDate13_1E.Date := cxDate13_1S.Date + 1;
cxTextEdit21.Text := '';
cxComboBox2.ItemIndex := 0;
cxTextEdit14.Text := '';
cxComboBox3.ItemIndex := 0;
chkCust13Type01.Checked := True;
chkCust13Type01Click(chkCust13Type01);
chkCust13Type02.Checked := False;
for i := 0 to custview13_1.ColumnCount - 1 do
custview13_1.Columns[i].DataBinding.ValueType := 'String';
custview13_1.Columns[1].DataBinding.ValueType := 'Integer';
custview13_2.Columns[0].DataBinding.ValueType := 'Integer';
for i := 1 to custview13_2.ColumnCount - 1 do
custview13_2.Columns[i].DataBinding.ValueType := 'String';
//13 B-2//
//14 B-3//
cxDate14_1S.Date := StrToDate(Date8to10(copy(StartDateTime('yyyymmddhhmmss'), 1, 8)));
cxDate14_1E.Date := cxDate14_1S.Date + 1;
chkBubinSttOrdFinish.Checked := True;
cbBubinSttCondition.ItemIndex := 0;
chkBubinSttTotal.Checked := True;
chkBubinSttPayTotal.Checked := True;
cxGBubinStt.Columns[0].DataBinding.ValueType := 'Integer';
for i := 1 to cxGBubinStt.ColumnCount - 1 do
begin
cxGBubinStt.Columns[i].DataBinding.ValueType := 'String';
end;
cxGBubinStt.Columns[25].DataBinding.ValueType := 'Currency';
cxGBubinStt.Columns[26].DataBinding.ValueType := 'Currency';
cxGBubinStt.Columns[27].DataBinding.ValueType := 'Currency';
cxGBubinStt.Columns[28].DataBinding.ValueType := 'Currency';
cxGBubinStt.Columns[29].DataBinding.ValueType := 'Currency';
cxGBubinStt.Columns[30].DataBinding.ValueType := 'Currency';
cxGBubinStt.Columns[31].DataBinding.ValueType := 'Currency';
cxGBubinStt.Columns[32].DataBinding.ValueType := 'Currency';
cxGBubinStt.Columns[33].DataBinding.ValueType := 'Currency';
cxGBubinStt.Columns[34].DataBinding.ValueType := 'Currency';
cxGBubinStt.Columns[35].DataBinding.ValueType := 'Currency';
cxGBubinStt.Columns[51].DataBinding.ValueType := 'Currency';
cxGBubinStt.Columns[52].DataBinding.ValueType := 'Currency';
cxGBubinStt.Columns[53].DataBinding.ValueType := 'Currency';
cxGBubinStt.Columns[54].DataBinding.ValueType := 'Currency';
cxGBubinStt.DataController.SetRecordCount(0);
try
cxChkTitle.Tag := 1;
slHidn := TStringList.Create;
ln_Env := TIniFile.Create(ENVPATHFILE);
ln_env.ReadSection('ACCBubinList', slHidn);
cxGBubinStt.BeginUpdate;
for i := 0 to cxChkTitle.Properties.Items.Count - 1 do
begin
sTemp := cxChkTitle.Properties.Items[i].Description;
if slHidn.IndexOf(sTemp) = -1 then
begin
cxChkTitle.SetItemState(i, cbsChecked);
cxGBubinStt.Bands[i].Visible := True;
end else
begin
cxChkTitle.SetItemState(i, cbsUnchecked);
cxGBubinStt.Bands[i].Visible := False;
end;
end;
FreeAndNil(slHidn);
FreeAndNil(ln_env);
cxGBubinStt.EndUpdate;
cxChkTitle.Tag := 0;
chkCust14Type01.Tag := 1;
chkCust14Type01.Checked := False;
chkCust14Type01.Tag := 0;
rbCust14Type05.Checked := True;
except
end;
//정산용엑셀
for i := 0 to cxGrid_Angel.ColumnCount - 1 do
begin
case i of
35..43 : cxGrid_Angel.Columns[i].DataBinding.ValueType := 'Currency';
else cxGrid_Angel.Columns[i].DataBinding.ValueType := 'String';
end;
end;
cxGrid_Angel.Columns[0].DataBinding.ValueType := 'Integer';
cxGrid_Angel.DataController.SetRecordCount(0);
//14 B-3//
//15 B-4//
cxDate22.Date := StrToDate(Date8to10(copy(StartDateTime('yyyymmddhhmmss'), 1, 8)));
cxDate23.Date := cxDate22.Date + 1;
for i := 0 to cxGBubinAuth.ColumnCount - 1 do
cxGBubinAuth.columns[i].databinding.valuetype := 'String';
//15 B-4//
//16 B-5//
cxDate16_1S.Date := StrToDate(Date8to10(copy(StartDateTime('yyyymmddhhmmss'), 1, 8))) - 7;
cxDate16_1E.Date := StrToDate(Date8to10(copy(StartDateTime('yyyymmddhhmmss'), 1, 8))) + 1;
cxViewWithholdingTax.Columns[0].DataBinding.ValueType := 'Integer';
for i := 1 to cxViewWithholdingTax.ColumnCount - 1 do
begin
case I of
9..13:
begin
cxViewWithholdingTax.Columns[i].DataBinding.ValueType := 'Currency';
end;
else
cxViewWithholdingTax.Columns[I].DataBinding.ValueTypeClass := TcxStringValueType;
end;
end;
//16 B-5//
//17 B-6//
cb_CalMonth.Text := IntToStr(StrToInt(copy(StartDateTime('yyyymmdd'), 5, 2)))+ '월';
lb_Year.Caption := copy(StartDateTime('yyyymmdd'), 1, 4);
cgrid_CalMonth.Columns[0].DataBinding.ValueType := 'Integer';
iFinishCnt := cgrid_CalMonth.GetColumnByFieldName('이용횟수').Index;
iOrderCnt := cgrid_CalMonth.GetColumnByFieldName('누락건수').Index;
iFinishCharge := cgrid_CalMonth.GetColumnByFieldName('이용금액').Index;
iFinishTCharge:= cgrid_CalMonth.GetColumnByFieldName('총합계').Index;
iRealCharge := cgrid_CalMonth.GetColumnByFieldName('실정산금액').Index;
iDeposit := cgrid_CalMonth.GetColumnByFieldName('입금여부').Index;
iBill := cgrid_CalMonth.GetColumnByFieldName('계산서발행').Index;
iBCode := cgrid_CalMonth.GetColumnByFieldName('법인코드').Index;
iBrNo := cgrid_CalMonth.GetColumnByFieldName('지사코드').Index;
iHdNo := cgrid_CalMonth.GetColumnByFieldName('본사코드').Index;
for i := 1 to cgrid_CalMonth.ColumnCount - 1 do
cgrid_CalMonth.Columns[i].DataBinding.ValueType := 'String';
cgrid_CalMonth.Columns[iFinishCnt].DataBinding.ValueType := 'Integer';
cgrid_CalMonth.Columns[iFinishCharge].DataBinding.ValueType := 'Currency';
cgrid_CalMonth.Columns[iFinishCharge+1].DataBinding.ValueType := 'Currency'; //부가세액
cgrid_CalMonth.Columns[iFinishTCharge].DataBinding.ValueType := 'Currency';
cgrid_CalMonth.Columns[iRealCharge].DataBinding.ValueType := 'Currency'; //실정산금액
cgrid_CalMonth.Columns[iOrderCnt].DataBinding.ValueType := 'Integer';
cgrid_UseList.Columns[0].DataBinding.ValueType := 'Integer';
for i := 1 to cgrid_UseList.ColumnCount - 1 do
cgrid_UseList.Columns[i].DataBinding.ValueType := 'String';
cgrid_UseList.Columns[13].DataBinding.ValueType := 'Currency';
cgrid_UseList.Columns[14].DataBinding.ValueType := 'Currency';
cgrid_UseList.Columns[15].DataBinding.ValueType := 'Currency';
cgrid_UseList.Columns[16].DataBinding.ValueType := 'Currency';
cgrid_UseList.Columns[17].DataBinding.ValueType := 'Currency';
cgrid_UseList.Columns[18].DataBinding.ValueType := 'Currency';
//17 B-6//
//18 B-7//
cxDate18_1S.Date := StrToDate(Date8to10(copy(StartDateTime('yyyymmddhhmmss'), 1, 8)))-1;
cxDate18_1E.Date := cxDate18_1S.Date + 1;
for i := 0 to cxGrid_Angel2.ColumnCount - 1 do
begin
case i of
35..43 : cxGrid_Angel2.Columns[i].DataBinding.ValueType := 'Currency';
else cxGrid_Angel2.Columns[i].DataBinding.ValueType := 'String';
end;
end;
cxGrid_Angel2.Columns[0].DataBinding.ValueType := 'Integer';
cxGrid_Angel2.DataController.SetRecordCount(0);
for i := 0 to cxGrid_Angel2_Masking.ColumnCount - 1 do
begin
case i of
35..43 : cxGrid_Angel2_Masking.Columns[i].DataBinding.ValueType := 'Currency';
else cxGrid_Angel2_Masking.Columns[i].DataBinding.ValueType := 'String';
end;
end;
cxGrid_Angel2_Masking.Columns[0].DataBinding.ValueType := 'Integer';
cxGrid_Angel2_Masking.DataController.SetRecordCount(0);
for i := 0 to CustView18_1.ColumnCount - 1 do
CustView18_1.Columns[i].DataBinding.ValueType := 'String';
// CustView18_1.Columns[0].DataBinding.ValueType := 'Boolean';
CustView18_1.Root.TreeList.Clear;
edt_18_1.text := '';
end;
procedure TFrm_CUT1.proc_NotBubinCust_Search;
var
sWhere : string;
ls_TxQry, ls_TxLoad, sQueryTemp: string; // XML File Load
slReceive: TStringList;
ErrCode: integer;
begin
if CustView12_3.DataController.RecordCount > 0 then Exit;
if cbKeynumber12.Text = '' then
begin
GMessagebox('대표번호를 선택해 주세요.', CDMSE);
Exit;
end;
if (GT_USERIF.LV = '10') and ((GT_SEL_BRNO.GUBUN <> '1') or (GT_SEL_BRNO.BrNo <> GT_USERIF.BR)) then
begin
GMessagebox('상담원 권한은 소속 지사만 조회할수 있습니다.', CDMSE);
Exit;
end;
if fGetChk_Search_HdBrNo('법인관리(일반고객)') then Exit;
//////////////////////////////////////////////////////////////////////////////
// 법인>법인관리>일반고객]10건/A100-B100/대표번호:16886618/고객구분:전체/고객명:홍길동/전화:011
FExcelDownBubinNormal := Format('%s/대표번호:%s/고객구분:%s%s%s',
[
GetSelBrInfo
, cbKeynumber12.Text
, cbGubun12_1.Text
, IfThen(edCustName05.Text = '', '', '/고객명:' + edCustName05.Text)
, IfThen(edCustTel04.Text = '', '', '/전화:' + edCustTel04.Text)
]);
//////////////////////////////////////////////////////////////////////////////
sWhere := ' AND CU.BR_NO = ''' + cxBrNo12.Text + ''' AND CU.CB_CODE IS NULL ';
case cbGubun12_1.ItemIndex of
1: sWhere := sWhere + ' AND CU.CU_TYPE = ''0'' ';
2: sWhere := sWhere + ' AND CU.CU_TYPE = ''1'' ';
3: sWhere := sWhere + ' AND CU.CU_TYPE = ''3'' ';
end;
if edCustName05.Text <> '' then
sWhere := sWhere + ' AND CU.CMP_NM LIKE ''%' + Param_Filtering(edCustName05.Text) + '%'' ';
if edCustTel04.Text <> '' then
sWhere := sWhere +
' AND CU.CU_SEQ IN (SELECT CU_SEQ FROM CDMS_CUSTOMER_TEL WHERE CU_TEL LIKE ''' +
StringReplace(Param_Filtering(edCustTel04.Text), '-', '', [rfReplaceAll]) + '%'') ';
sWhere := sWhere + ' AND KEY_NUMBER = ''' + cbKeynumber12.Text + '''';
ls_TxLoad := GTx_UnitXmlLoad('SEL02.XML');
fGet_BlowFish_Query(GSQ_CUST_NOT_BUBIN_SEARCH, sQueryTemp);
ls_TxQry := Format(sQueryTemp, [cxHdNo12.Text, sWhere]);
ls_TxLoad := StringReplace(ls_TxLoad, 'UserIDString', En_Coding(GT_USERIF.ID), [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientVerString', VERSIONINFO, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientKeyString', self.Caption + '15', [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'QueryString', ls_TxQry, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'PagingString', '500', [rfReplaceAll]);
Screen.Cursor := crHourGlass;
slReceive := TStringList.Create;
cxPageControl1.Enabled := False;
try
frm_Main.proc_SocketWork(False);
if dm.SendSock(ls_TxLoad, slReceive, ErrCode, False, 30000) then
begin
Application.ProcessMessages;
proc_recieve(slReceive);
end;
finally
frm_Main.proc_SocketWork(True);
FreeAndNil(slReceive);
Screen.Cursor := crDefault;
cxPageControl1.Enabled := True;
Frm_Flash.Hide;
end;
end;
procedure TFrm_CUT1.proc_recieve(slList: TStringList);
var
xdom: msDomDocument;
ls_ClientKey, ClientKey, ls_Msg_Err, sEndDate, sTemp : string;
lst_Result: IXMLDomNodeList;
ls_Rcrd : TStringList;
i, j, k, iRow, iIdx, iCnt : Integer;
Node: TcxTreeListNode;
bCheck: Boolean;
ls_rxxml: WideString;
begin
try
xdom := ComsDomDocument.Create;
Screen.Cursor := crHourGlass;
try
ls_rxxml := slList[0];
if not xdom.loadXML(ls_rxxml) then
begin
Exit;
end;
ls_MSG_Err := GetXmlErrorCode(ls_rxxml);
if ('0000' = ls_MSG_Err) then
begin
frm_Main.sbar_Message.Panels[4].Text := '';
ls_ClientKey := GetXmlClientKey(ls_rxxml);
ClientKey := ls_ClientKey;
ls_ClientKey := Copy(ls_ClientKey, 6, Length(ls_ClientKey) - 5);
case StrToIntDef(ls_ClientKey, 1) of
13:
begin
CustView12_1.BeginUpdate;
iCnt := 0;
try
Frm_Flash.cxPBar1.Properties.Max := slList.Count;
Frm_Flash.cxPBar1.Position := 0;
for j := 0 to slList.Count - 1 do
begin
Frm_Flash.cxPBar1.Position := j + 1;
Frm_Flash.lblCnt.Caption := IntToStr(j + 1) + '/' + IntToStr(slList.Count);
Application.ProcessMessages;
ls_rxxml := slList.Strings[j];
if not xdom.loadXML(ls_rxxml) then
begin
continue;
end;
if (0 < GetXmlRecordCount(ls_rxxml)) then
begin
lst_Result := xdom.documentElement.selectNodes('/cdms/Service/Data/Result');
ls_Rcrd := TSTringList.Create;
try
for i := 0 to lst_Result.length - 1 do
begin
Application.ProcessMessages;
GetTextSeperationEx('│', lst_Result.item[i].attributes.getNamedItem('Value').Text, ls_Rcrd);
case length(ls_Rcrd[5]) of
5:
begin
Node := CustView12_1.Root.AddChild;
end;
8:
begin
bCheck := False;
for iIdx := 0 to
CustView12_1.Root.Count - 1 do
begin
if CustView12_1.Root.Items[iIdx].Values[7] =
copy(ls_Rcrd[5], 1, 5) then
begin
Node := CustView12_1.Root.Items[iIdx].AddChild;
bCheck := True;
break;
end;
end;
if not bCheck then
Node := CustView12_1.Root.AddChild;
end;
11:
begin
bCheck := False;
for k := 0 to CustView12_1.Root.Count - 1 do
begin
if CustView12_1.Root.Items[k].HasChildren then
begin
for iIdx := 0 to CustView12_1.Root.Items[k].Count - 1 do
begin
if CustView12_1.Root.Items[k].Items[iIdx].Values[7] = copy(ls_Rcrd[5], 1, 8) then
begin
Node := CustView12_1.Root.Items[k].Items[iIdx].AddChild;
bCheck := True;
break;
end;
end;
end;
end;
if not bCheck then
Node := CustView12_1.Root.AddChild;
end;
end;
iCnt := iCnt + 1;
// 법인명, 부서명, 담당자명, 연락처, 법인코드, 요금타입,
// Node := Node.AddChild;
Node.Values[0] := ''; // IntToStr(i+1);
Node.Values[1] := IntToStr(iCnt);
Node.Values[2] := ls_Rcrd[0]; // 법인명
Node.Values[3] := ls_Rcrd[1]; // 부서명
Node.Values[4] := ls_Rcrd[4]; // 요금타입
Node.Values[5] := ls_Rcrd[2]; // 담당자
Node.Values[6] := ls_Rcrd[3]; // 연락처
Node.Values[7] := ls_Rcrd[5]; // 법인코드
Node.Values[8] := ls_Rcrd[6]; // 정산일
Node.Values[9] := ls_Rcrd[7]; // 계약일
Node.Values[10] := ls_Rcrd[8]; // 종료일
end;
finally
ls_Rcrd.Free;
end;
end else
begin
GMessagebox('검색된 내용이 없습니다.', CDMSE);
end;
end;
finally
CustView12_1.EndUpdate;
CustView12_1.FullExpand;
frm_Main.sbar_Message.Panels[4].Text := '';
end;
end;
14:
begin
CustView12_2.BeginUpdate;
try
Frm_Flash.cxPBar1.Properties.Max := slList.Count;
Frm_Flash.cxPBar1.Position := 0;
for j := 0 to slList.Count - 1 do
begin
Frm_Flash.cxPBar1.Position := j + 1;
Frm_Flash.lblCnt.Caption := IntToStr(j + 1) + '/' + IntToStr(slList.Count);
Application.ProcessMessages;
ls_rxxml := slList.Strings[j];
if not xdom.loadXML(ls_rxxml) then
begin
continue;
end;
if (0 < GetXmlRecordCount(ls_rxxml)) then
begin
lst_Result := xdom.documentElement.selectNodes('/cdms/Service/Data/Result');
ls_Rcrd := TStringList.Create;
try
for i := 0 to lst_Result.length - 1 do
begin
Application.ProcessMessages;
GetTextSeperationEx('│', lst_Result.item[i].attributes.getNamedItem('Value').Text, ls_Rcrd);
iRow := CustView12_2.DataController.AppendRecord;
CustView12_2.DataController.Values[iRow, 0] := iRow + 1;
CustView12_2.DataController.Values[iRow, 1] := ls_rcrd[2];
CustView12_2.DataController.Values[iRow, 2] := ls_rcrd[3];
CustView12_2.DataController.Values[iRow, 3] := ls_rcrd[4];
CustView12_2.DataController.Values[iRow, 4] := ls_rcrd[13]; // 직책
CustView12_2.DataController.Values[iRow, 5] := strtocall(ls_rcrd[5]);
CustView12_2.DataController.Values[iRow, 6] := ls_rcrd[6];
CustView12_2.DataController.Values[iRow, 7] := ls_rcrd[7];
if StrToIntDef(ls_Rcrd[8], 0) = 0 then
ls_Rcrd[8] := '0';
CustView12_2.DataController.Values[iRow, 8] := ls_rcrd[8];
sEndDate := ls_rcrd[9];
if Trim(sEndDate) <> '' then
CustView12_2.DataController.Values[iRow, 9] := copy(sEndDate, 1, 4) +
'-' + copy(sEndDate, 5, 2) + '-' + copy(sEndDate, 7, 2)
else
CustView12_2.DataController.Values[iRow, 9] := '';
CustView12_2.DataController.Values[iRow, 10] := ls_rcrd[10];
CustView12_2.DataController.Values[iRow, 11] := ls_rcrd[11];
CustView12_2.DataController.Values[iRow, 12] := ls_rcrd[12];
CustView12_2.DataController.Values[iRow, 13] := ls_rcrd[0];
CustView12_2.DataController.Values[iRow, 14] := strtocall(ls_rcrd[1]);
end;
finally
ls_Rcrd.Free;
end;
end else
begin
// GMessagebox('검색된 내용이 없습니다.', CDMSE); //불필요삭제 20210727 KHS 팀장님 지시
end;
end;
finally
CustView12_2.EndUpdate;
frm_Main.sbar_Message.Panels[4].Text := '';
end;
if gbCustView12_1_SetFocus then
begin
gbCustView12_1_SetFocus := False;
CustView12_1.SetFocus;
end;
end;
15:
begin
CustView12_3.BeginUpdate;
try
Frm_Flash.cxPBar1.Properties.Max := slList.Count;
Frm_Flash.cxPBar1.Position := 0;
for j := 0 to slList.Count - 1 do
begin
Frm_Flash.cxPBar1.Position := j + 1;
Frm_Flash.lblCnt.Caption := IntToStr(j + 1) + '/' + IntToStr(slList.Count);
Application.ProcessMessages;
ls_rxxml := slList.Strings[j];
if not xdom.loadXML(ls_rxxml) then
begin
continue;
end;
if (0 < GetXmlRecordCount(ls_rxxml)) then
begin
lst_Result := xdom.documentElement.selectNodes('/cdms/Service/Data/Result');
ls_Rcrd := TStringList.Create;
try
for i := 0 to lst_Result.length - 1 do
begin
Application.ProcessMessages;
GetTextSeperationEx('│', lst_Result.item[i].attributes.getNamedItem('Value').Text, ls_Rcrd);
iRow := CustView12_3.DataController.AppendRecord;
CustView12_3.DataController.Values[iRow, 0] := iRow + 1;
CustView12_3.DataController.Values[iRow, 1] := ls_rcrd[2];
CustView12_3.DataController.Values[iRow, 2] := ls_rcrd[11]; // 직책
CustView12_3.DataController.Values[iRow, 3] := strtocall(ls_rcrd[3]);
CustView12_3.DataController.Values[iRow, 4] := ls_rcrd[4];
CustView12_3.DataController.Values[iRow, 5] := ls_rcrd[5];
CustView12_3.DataController.Values[iRow, 6] := ls_rcrd[6];
if StrToIntDef(ls_Rcrd[7], 0) = 0 then
ls_Rcrd[7] := '0';
CustView12_3.DataController.Values[iRow, 7] := ls_rcrd[7];
sEndDate := ls_rcrd[8];
if Trim(sEndDate) <> '' then
CustView12_3.DataController.Values[iRow, 8] := copy(sEndDate, 1, 4) +
'-' + copy(sEndDate, 5, 2) + '-' + copy(sEndDate, 7, 2)
else
CustView12_3.DataController.Values[iRow, 8] := '';
CustView12_3.DataController.Values[iRow, 9] := ls_rcrd[9];
CustView12_3.DataController.Values[iRow, 10] := ls_rcrd[10];
CustView12_3.DataController.Values[iRow, 11] := ls_rcrd[0];
CustView12_3.DataController.Values[iRow, 12] := strtocall(ls_rcrd[1]);
end;
finally
ls_Rcrd.Free;
end;
end else
begin
// GMessagebox('검색된 내용이 없습니다.', CDMSE); //불필요삭제 20210727 KHS 팀장님 지시
end;
end;
finally
CustView12_3.EndUpdate;
frm_Main.sbar_Message.Panels[4].Text := '';
end;
end;
16:
begin
CustView13_1.BeginUpdate;
iCnt := 0;
try
Frm_Flash.cxPBar1.Properties.Max := slList.Count;
Frm_Flash.cxPBar1.Position := 0;
for j := 0 to slList.Count - 1 do
begin
Frm_Flash.cxPBar1.Position := j + 1;
Frm_Flash.lblCnt.Caption := IntToStr(j + 1) + '/' + IntToStr(slList.Count);
Application.ProcessMessages;
ls_rxxml := slList.Strings[j];
if not xdom.loadXML(ls_rxxml) then
begin
continue;
end;
if (0 < GetXmlRecordCount(ls_rxxml)) then
begin
lst_Result := xdom.documentElement.selectNodes('/cdms/Service/Data/Result');
ls_Rcrd := TStringList.Create;
try
for i := 0 to lst_Result.length - 1 do
begin
Application.ProcessMessages;
GetTextSeperationEx('│', lst_Result.item[i].attributes.getNamedItem('Value').Text, ls_Rcrd);
case length(ls_Rcrd[5]) of
5:
begin
Node := CustView13_1.Root.AddChild;
end;
8:
begin
bCheck := False;
for iIdx := 0 to CustView13_1.Root.Count - 1 do
begin
if CustView13_1.Root.Items[iIdx].Values[6] = copy(ls_Rcrd[5], 1, 5) then
begin
Node := CustView13_1.Root.Items[iIdx].AddChild;
bCheck := True;
break;
end;
end;
if not bCheck then
Node := CustView13_1.Root.AddChild;
end;
11:
begin
bCheck := False;
for k := 0 to CustView13_1.Root.Count - 1 do
begin
if CustView13_1.Root.Items[k].HasChildren then
begin
for iIdx := 0 to CustView13_1.Root.Items[k].Count - 1 do
begin
if CustView13_1.Root.Items[k].Items[iIdx].Values[6] = copy(ls_Rcrd[5], 1, 8) then
begin
Node := CustView13_1.Root.Items[k].Items[iIdx].AddChild;
bCheck := True;
break;
end;
end;
end;
end;
if not bCheck then
Node := CustView13_1.Root.AddChild;
end;
end;
iCnt := iCnt + 1;
Node.Values[0] := '';
Node.Values[1] := IntToStr(iCnt);
Node.Values[2] := ls_Rcrd[0];
Node.Values[3] := ls_Rcrd[1];
Node.Values[4] := ls_Rcrd[2];
Node.Values[5] := ls_Rcrd[3];
Node.Values[6] := ls_Rcrd[5];
end;
finally
ls_Rcrd.Free;
end;
end else
begin
GMessagebox('검색된 내용이 없습니다.', CDMSE);
end;
end;
finally
CustView13_1.EndUpdate;
CustView13_1.FullExpand;
frm_Main.sbar_Message.Panels[4].Text := '';
end;
end;
17:
begin
CustView13_2.BeginUpdate;
try
Frm_Flash.cxPBar1.Properties.Max := slList.Count;
Frm_Flash.cxPBar1.Position := 0;
for j := 0 to slList.Count - 1 do
begin
Frm_Flash.cxPBar1.Position := j + 1;
Frm_Flash.lblCnt.Caption := IntToStr(j + 1) + '/' + IntToStr(slList.Count);
Application.ProcessMessages;
ls_rxxml := slList.Strings[j];
if not xdom.loadXML(ls_rxxml) then
begin
continue;
end;
if (0 < GetXmlRecordCount(ls_rxxml)) then
begin
lst_Result := xdom.documentElement.selectNodes('/cdms/Service/Data/Result');
ls_Rcrd := TStringList.Create;
try
for i := 0 to lst_Result.length - 1 do
begin
GetTextSeperationEx('│', lst_Result.item[i].attributes.getNamedItem('Value').Text, ls_Rcrd);
ls_Rcrd.Insert(0, 'n');
iRow := CustView13_2.DataController.AppendRecord;
// 1 Record 추가
ls_Rcrd.Insert(0, IntToStr(iRow + 1));
sTemp := ls_Rcrd[11];
if sTemp <> '' then
ls_Rcrd[11] := Copy(sTemp, 1, 10) + ' ' + Copy(sTemp, 11, 8);
sTemp := ls_Rcrd[21];
if sTemp <> '' then
ls_Rcrd[21] := Copy(sTemp, 1, 10) + ' ' + Copy(sTemp, 11, 8);
sTemp := ls_Rcrd[22];
if StrToFloatDef(sTemp, -9) = -9 then
ls_Rcrd[22] := '0.0';
CustView13_2.DataController.Values[iRow, 0] := ls_Rcrd[0];
CustView13_2.DataController.Values[iRow, 1] := ls_Rcrd[1];
CustView13_2.DataController.Values[iRow, 2] := ls_Rcrd[2];
CustView13_2.DataController.Values[iRow, 3] := ls_Rcrd[3];
CustView13_2.DataController.Values[iRow, 4] := ls_Rcrd[4];
CustView13_2.DataController.Values[iRow, 5] := ls_Rcrd[5];
CustView13_2.DataController.Values[iRow, 6] := ls_Rcrd[6];
CustView13_2.DataController.Values[iRow, 7] := ls_Rcrd[7];
CustView13_2.DataController.Values[iRow, 8] := ls_Rcrd[8];
CustView13_2.DataController.Values[iRow, 9] := ls_Rcrd[9];
CustView13_2.DataController.Values[iRow, 10] := ls_Rcrd[44]; // 직책
CustView13_2.DataController.Values[iRow, 11] := strtocall(ls_Rcrd[10]);
CustView13_2.DataController.Values[iRow, 12] := ls_Rcrd[11];
CustView13_2.DataController.Values[iRow, 13] := ls_Rcrd[12];
CustView13_2.DataController.Values[iRow, 14] := ls_Rcrd[13];
CustView13_2.DataController.Values[iRow, 15] := ls_Rcrd[14];
CustView13_2.DataController.Values[iRow, 16] := ls_Rcrd[15];
CustView13_2.DataController.Values[iRow, 17] := ls_Rcrd[16];
CustView13_2.DataController.Values[iRow, 18] := ls_Rcrd[17];
CustView13_2.DataController.Values[iRow, 19] := ls_Rcrd[18];
CustView13_2.DataController.Values[iRow, 20] := ls_Rcrd[19];
CustView13_2.DataController.Values[iRow, 21] := ls_Rcrd[20];
CustView13_2.DataController.Values[iRow, 22] := ls_Rcrd[21];
CustView13_2.DataController.Values[iRow, 23] := ls_Rcrd[22];
CustView13_2.DataController.Values[iRow, 24] := ls_Rcrd[23];
CustView13_2.DataController.Values[iRow, 25] := ls_Rcrd[24];
CustView13_2.DataController.Values[iRow, 26] := ls_Rcrd[25];
CustView13_2.DataController.Values[iRow, 27] := ls_Rcrd[26];
CustView13_2.DataController.Values[iRow, 28] := ls_Rcrd[27];
CustView13_2.DataController.Values[iRow, 29] := ls_Rcrd[28];
CustView13_2.DataController.Values[iRow, 30] := ls_Rcrd[29];
CustView13_2.DataController.Values[iRow, 31] := ls_Rcrd[30];
CustView13_2.DataController.Values[iRow, 32] := ls_Rcrd[31];
CustView13_2.DataController.Values[iRow, 33] := ls_Rcrd[32];
CustView13_2.DataController.Values[iRow, 34] := ls_Rcrd[33];
CustView13_2.DataController.Values[iRow, 35] := ls_Rcrd[34];
CustView13_2.DataController.Values[iRow, 36] := ls_Rcrd[35];
CustView13_2.DataController.Values[iRow, 37] := ls_Rcrd[36];
CustView13_2.DataController.Values[iRow, 38] := ls_Rcrd[37];
CustView13_2.DataController.Values[iRow, 39] := ls_Rcrd[38];
CustView13_2.DataController.Values[iRow, 40] := ls_Rcrd[39];
CustView13_2.DataController.Values[iRow, 41] := ls_Rcrd[40];
CustView13_2.DataController.Values[iRow, 42] := ls_Rcrd[41];
CustView13_2.DataController.Values[iRow, 43] := ls_Rcrd[42];
CustView13_2.DataController.Values[iRow, 44] := ls_Rcrd[43];
end;
finally
ls_Rcrd.Free;
end;
end else
begin
GMessagebox('검색된 내용이 없습니다.', CDMSE);
end;
end;
finally
btn_13_2.Enabled := True;
CustView13_2.EndUpdate;
frm_Main.sbar_Message.Panels[4].Text := '';
end;
end;
20:
begin
//법인인증 요청
cxGBubinAuth.BeginUpdate;
cxGBubinAuth.DataController.SetRecordCount(0);
try
Frm_Flash.cxPBar1.Properties.Max := slList.Count;
Frm_Flash.cxPBar1.Position := 0;
for j := 0 to slList.Count - 1 do
begin
Frm_Flash.cxPBar1.Position := j + 1;
Frm_Flash.lblCnt.Caption := IntToStr(j + 1) + '/' + '/' + IntToStr(slList.Count);
Application.ProcessMessages;
ls_rxxml := slList.Strings[j];
if not xdom.loadXML(ls_rxxml) then
begin
continue;
end;
if (0 < GetXmlRecordCount(ls_rxxml)) then
begin
lst_Result := xdom.documentElement.selectNodes('/cdms/Service/Data/Result');
ls_Rcrd := TStringList.Create;
try
for i := 0 to lst_Result.length - 1 do
begin
GetTextSeperationEx('│', lst_Result.item[i].attributes.getNamedItem('Value').Text, ls_Rcrd);
iRow := cxGBubinAuth.DataController.AppendRecord;
cxGBubinAuth.DataController.Values[iRow,0] := ls_Rcrd[0]; //지사명
cxGBubinAuth.DataController.Values[iRow,1] := ls_Rcrd[1]; //대표번호
cxGBubinAuth.DataController.Values[iRow,2] := ls_Rcrd[2]; //고객명
cxGBubinAuth.DataController.Values[iRow,3] := ls_Rcrd[3]; //고객번호
cxGBubinAuth.DataController.Values[iRow,4] := ls_Rcrd[20]; //인증여부
//인증시간
if ls_Rcrd[21] <> '' then
cxGBubinAuth.DataController.Values[iRow, 5] := copy(ls_Rcrd[21],1,10) + ' ' + copy(ls_Rcrd[21],11,18)
else
cxGBubinAuth.DataController.Values[iRow,5] := ls_Rcrd[21];
//접수시간
if ls_Rcrd[4] <> '' then
cxGBubinAuth.DataController.Values[iRow, 6] := copy(ls_Rcrd[4],1,10) + ' ' + copy(ls_Rcrd[4],11,18)
else
cxGBubinAuth.DataController.Values[iRow,6] := ls_Rcrd[21];
//배차시간
if ls_Rcrd[5] <> '' then
cxGBubinAuth.DataController.Values[iRow, 7] := copy(ls_Rcrd[5],1,10) + ' ' + copy(ls_Rcrd[5],11,18)
else
cxGBubinAuth.DataController.Values[iRow,7] := ls_Rcrd[5];
//완료시간
if ls_Rcrd[6] <> '' then
cxGBubinAuth.DataController.Values[iRow, 8] := copy(ls_Rcrd[6],1,10) + ' ' + copy(ls_Rcrd[6],11,18)
else
cxGBubinAuth.DataController.Values[iRow,8] := ls_Rcrd[6];
cxGBubinAuth.DataController.Values[iRow,9] := ls_Rcrd[7] + ' ' + ls_Rcrd[8] + ' ' + ls_Rcrd[9] + ' ' + ls_Rcrd[10]; //출발지
cxGBubinAuth.DataController.Values[iRow,10] := ls_Rcrd[11] + ' ' + ls_Rcrd[12] + ' ' + ls_Rcrd[13] + ' ' + ls_Rcrd[14]; //도착지
cxGBubinAuth.DataController.Values[iRow,11] := ls_Rcrd[15]; //적요
cxGBubinAuth.DataController.Values[iRow,12] := ls_Rcrd[16]; //요금
cxGBubinAuth.DataController.Values[iRow,13] := ls_Rcrd[17]; //운행기사소속
cxGBubinAuth.DataController.Values[iRow,14] := ls_Rcrd[18]; //기사명
cxGBubinAuth.DataController.Values[iRow,15] := ls_Rcrd[19]; //기사사번
cxGBubinAuth.DataController.Values[iRow,16] := ls_Rcrd[22]; //접수번호
end;
finally
ls_Rcrd.Free;
end;
end else
begin
GMessagebox('검색된 내용이 없습니다.', CDMSE);
end;
end;
finally
cxGBubinAuth.EndUpdate;
frm_Main.sbar_Message.Panels[4].Text := '';
end;
end;
21:
begin
//법인인증 승인
cxGBubinAuth.BeginUpdate;
cxGBubinAuth.DataController.SetRecordCount(0);
try
Frm_Flash.cxPBar1.Properties.Max := slList.Count;
Frm_Flash.cxPBar1.Position := 0;
for j := 0 to slList.Count - 1 do
begin
Frm_Flash.cxPBar1.Position := j + 1;
Frm_Flash.lblCnt.Caption := IntToStr(j + 1) + '/' + '/' + IntToStr(slList.Count);
Application.ProcessMessages;
ls_rxxml := slList.Strings[j];
if not xdom.loadXML(ls_rxxml) then
begin
continue;
end;
if (0 < GetXmlRecordCount(ls_rxxml)) then
begin
lst_Result := xdom.documentElement.selectNodes('/cdms/Service/Data/Result');
ls_Rcrd := TStringList.Create;
try
for i := 0 to lst_Result.length - 1 do
begin
GetTextSeperationEx('│', lst_Result.item[i].attributes.getNamedItem('Value').Text, ls_Rcrd);
iRow := cxGBubinAuth.DataController.AppendRecord;
cxGBubinAuth.DataController.Values[iRow,0] := ls_Rcrd[0]; //지사명
cxGBubinAuth.DataController.Values[iRow,1] := ls_Rcrd[1]; //대표번호
cxGBubinAuth.DataController.Values[iRow,2] := ls_Rcrd[2]; //고객명
cxGBubinAuth.DataController.Values[iRow,3] := ls_Rcrd[3]; //고객번호
cxGBubinAuth.DataController.Values[iRow,4] := ls_Rcrd[14]; //인증여부
//인증시간
if ls_Rcrd[15] <> '' then
cxGBubinAuth.DataController.Values[iRow, 5] := copy(ls_Rcrd[15],1,10) + ' ' + copy(ls_Rcrd[15],11,18)
else
cxGBubinAuth.DataController.Values[iRow,5] := ls_Rcrd[15];
//접수시간
if ls_Rcrd[4] <> '' then
cxGBubinAuth.DataController.Values[iRow, 6] := copy(ls_Rcrd[4],1,10) + ' ' + copy(ls_Rcrd[4],11,18)
else
cxGBubinAuth.DataController.Values[iRow,6] := ls_Rcrd[4];
//배차시간
if ls_Rcrd[5] <> '' then
cxGBubinAuth.DataController.Values[iRow, 7] := copy(ls_Rcrd[5],1,10) + ' ' + copy(ls_Rcrd[5],11,18)
else
cxGBubinAuth.DataController.Values[iRow,7] := ls_Rcrd[5];
//완료시간
if ls_Rcrd[6] <> '' then
cxGBubinAuth.DataController.Values[iRow, 8] := copy(ls_Rcrd[6],1,10) + ' ' + copy(ls_Rcrd[6],11,18)
else
cxGBubinAuth.DataController.Values[iRow,8] := ls_Rcrd[6];
cxGBubinAuth.DataController.Values[iRow,9] := ls_Rcrd[7]; //출발지
cxGBubinAuth.DataController.Values[iRow,10] := ls_Rcrd[8]; //도착지
cxGBubinAuth.DataController.Values[iRow,11] := ls_Rcrd[9]; //적요
cxGBubinAuth.DataController.Values[iRow,12] := ls_Rcrd[10]; //요금
cxGBubinAuth.DataController.Values[iRow,13] := ls_Rcrd[11]; //운행기사소속
cxGBubinAuth.DataController.Values[iRow,14] := ls_Rcrd[12]; //기사명
cxGBubinAuth.DataController.Values[iRow,15] := ls_Rcrd[13]; //기사사번
cxGBubinAuth.DataController.Values[iRow,16] := ls_Rcrd[16]; //접수번호
end;
finally
ls_Rcrd.Free;
end;
end else
begin
GMessagebox('검색된 내용이 없습니다.', CDMSE);
end;
end;
finally
cxGBubinAuth.EndUpdate;
frm_Main.sbar_Message.Panels[4].Text := '';
end;
end;
end;
end else
begin
Screen.Cursor := crDefault;
GMessagebox(MSG012 + CRLF + ls_MSG_Err, CDMSE);
end;
finally
Screen.Cursor := crDefault;
xdom := Nil;
end;
except
on e: exception do
begin
cxPageControl1.Enabled := True;
Screen.Cursor := crDefault;
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.proc_SaveBubinDate(AYyMm, AHdNo, ABrNo, ABubinCode, ADeposit,
ABill, AFinishCnt, AFinishCharge, AOrderCnt: string);
var
ls_TxLoad: string;
ls_rxxml: string;
xdom: MSDomDocument;
ErrCode : Integer;
ls_MSG_Err, rv_str: string;
slRcvList : TStringList;
begin
Try
if ABubinCode = '' then Exit;
Screen.Cursor := crHourGlass;
ls_TxLoad := GTx_UnitXmlLoad('ACC12020.xml');
slRcvList := TStringList.Create;
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strMonth' , AYyMm);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strHdNo' , AHdNo);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strBrNo' , ABrNo);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strCbCode' , ABubinCode);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strPaymentYn' , ADeposit);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strBillYn' , ABill);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strFinishCnt' , AFinishCnt);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strFinishCharge', AFinishCharge);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'strOrderCnt' , AOrderCnt);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'UserIDString' , GT_USERIF.ID);
ls_TxLoad := ReplaceAll(ls_TxLoad, 'ClientVerString', VERSIONINFO);
try
if dm.SendSock(ls_TxLoad, slRcvList, ErrCode, False, 30000) then
begin
rv_str := slRcvList[0];
if rv_str <> '' then
begin
ls_rxxml := rv_str;
xdom := CoMSDomDocument.Create;
try
xdom.loadXML(ls_rxxml);
ls_MSG_Err := GetXmlErrorCode(ls_rxxml);
if ('0000' <> ls_MSG_Err) then
begin
GMessagebox('법인 상세 조회시 오류발생 : '+ls_Msg_Err, CDMSE);
Exit;
end;
finally
xdom := Nil;
slRcvList.Free;
Screen.Cursor := crDefault;
end;
end;
end;
except
slRcvList.Free;
Screen.Cursor := crDefault;
end;
except
on e: exception do
begin
Screen.Cursor := crDefault;
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.proc_search_bubin(ACbCode, ABrNo : string);
var
XmlData, Param, ErrMsg : string;
xdom: msDomDocument;
lst_Count, lst_Result: IXMLDomNodeList;
ls_Rcrd : TStringList;
i, j, ErrCode : Integer;
sDate: string;
DateTime: TDateTime;
sParam : string;
begin
try
gsCustViewParam := '';
edCbCode.text := '';
lb_Date01.caption := '';
lb_Date02.caption := '';
lb_UseCnt01.caption := '';
edName01.Text := '';
edName03.Text := '';
edtCustStateMemo.Text := '';
edtCustMemo.Text := '';
cb_Contract2.ItemIndex := -1;
dtRegDate.Text := '';
dtFinDate.Text := '';
edWebID.Text := '';
edWebPW.Text := '';
edCbCode.Text := ACbCode;
pnl_makeId.visible := false;
Param := '';
Param := ACbCode + '│' + ABrNo;
if not RequestBase(GetSel06('INFO_CUST_BGROUP', 'MNG_BGROUP.INFO_CUST_BGROUP', '10', Param), XmlData, ErrCode, ErrMsg) then
begin
GMessagebox(Format('법인정보 조회 중 오류발생'#13#10'[%d]%s', [ErrCode, ErrMsg]), CDMSE);
Exit;
end;
xdom := ComsDomDocument.Create;
try
xdom.loadXML(XmlData);
if not xdom.loadXML(XmlData) then
begin
Exit;
end;
lst_Count := xdom.documentElement.selectNodes('/cdms/Service/Data');
if StrToIntDef(lst_Count.item[0].attributes.getNamedItem('Count').Text,0) > 0 then
begin
lst_Result := xdom.documentElement.selectNodes('/cdms/Service/Data/Result');
ls_Rcrd := TStringList.Create;
try
edName01.enabled := True;
edName03.enabled := True;
edtCustStateMemo.enabled := True;
edtCustMemo.enabled := True;
cb_Contract2.enabled := True;
dtRegDate.enabled := True;
dtFinDate.enabled := True;
pnl_Vat.enabled := True;
pnl_Bill.enabled := True;
edWebPW.enabled := True;
for I := 0 to lst_Result.length - 1 do
begin
GetTextSeperationEx2('│', lst_Result.item[I].attributes.getNamedItem('Value').Text, ls_Rcrd);
///////////////원본
sDate := ls_Rcrd[9];
if sDate <> '' then
begin
sDate := StringReplace(sDate, ':', '', [rfReplaceAll]);
sDate := StringReplace(sDate, '-', '', [rfReplaceAll]);
sDate := StringReplace(sDate, ' ', '', [rfReplaceAll]);
sDate := copy(sDate, 1, 4) + '-' + Copy(sDate, 5, 2) + '-' +
Copy(sDate, 7, 2);
lb_Date01.caption := sDate;
end{ else
lb_Date01.caption := FormatDateTime('yyyy-mm-dd', now)};
sDate := ls_Rcrd[11];
if sDate <> '' then
begin
sDate := StringReplace(sDate, ':', '', [rfReplaceAll]);
sDate := StringReplace(sDate, '-', '', [rfReplaceAll]);
sDate := StringReplace(sDate, ' ', '', [rfReplaceAll]);
sDate := copy(sDate, 1, 4) + '-' + Copy(sDate, 5, 2) + '-' +
Copy(sDate, 7, 2);
lb_Date02.caption := sDate;
end{ else
lb_Date02.caption := FormatDateTime('yyyy-mm-dd', now)};
lb_UseCnt01.caption := ls_Rcrd[12];
edName01.Text := ls_Rcrd[0];
edName03.Text := ls_Rcrd[1];
edtCustStateMemo.Text := ls_Rcrd[35];
edtCustMemo.Text := ls_Rcrd[23];
if TryStrToDate(ls_Rcrd[21], DateTime) then
dtRegDate.Text := ls_Rcrd[21];
if TryStrToDate(ls_Rcrd[22], DateTime) then
dtFinDate.Text := ls_Rcrd[22];
cb_Contract2.ItemIndex := StrToIntDef(ls_Rcrd[34], 0);
if ls_Rcrd[19] = 'y' then
rb_SurtaxY.Checked := True
else
rb_SurtaxN.Checked := True;
rbList01.Tag := 1;
if ls_Rcrd[6] = '0' then
rbList01.Checked := True
else if ls_Rcrd[6] = '2' then
rbPayMethodPost.Checked := True
else
rbList02.Checked := True;
rbList01.Tag := 0;
edWebID.Text := ls_Rcrd[7];
if edWebID.Text = '' then
begin
edWebID.Enabled := True;
btn_WebId.Enabled := True;
btn_WebId.caption := '아이디체크';
btn_WebId.Tag := 99;
end else
begin
edWebID.Enabled := False;
btn_WebId.Enabled := False;
btn_WebId.caption := '아이디체크';
btn_WebId.Tag := 0;
end;
edWebPW.Text := ls_Rcrd[8];
//41 카드결제수수료타입{0:미적용, 1:대리요금,2:기사입금액,3:카드결제금액}
//42 카드결제수수료값
if ls_Rcrd[41] = '0' then cxLimitCardVat.ItemIndex := 0 else
if ( ls_Rcrd[41] = '1' ) And ( ls_Rcrd[42] = '2' ) then cxLimitCardVat.ItemIndex := 1 else
if ( ls_Rcrd[41] = '1' ) And ( ls_Rcrd[42] = '3' ) then cxLimitCardVat.ItemIndex := 2 else
if ( ls_Rcrd[41] = '1' ) And ( ls_Rcrd[42] = '10' ) then cxLimitCardVat.ItemIndex := 3 else
if ( ls_Rcrd[41] = '2' ) And ( ls_Rcrd[42] = '10' ) then cxLimitCardVat.ItemIndex := 4
else cxLimitCardVat.ItemIndex := 0;
//저장을 위해 조회내용 저장
Param := '1'; // 0
Param := Param + '│' + '0'; // 1
Param := Param + '│' + edCbCode.Text; // 2
Param := Param + '│' + '<법인명]'; //저장 시 변경가능 // 3
Param := Param + '│' + '<부서명]'; //저장 시 변경가능 // 4
Param := Param + '│' + ls_Rcrd[2]; // 5
Param := Param + '│' + ls_Rcrd[3]; // 6
Param := Param + '│' + ls_Rcrd[4]; // 7
Param := Param + '│' + ls_Rcrd[5]; // 8
Param := Param + '│' + '<요금지불방식]'; // 9 rbList02.Checked
Param := Param + '│' + '<아이디]'; //저장 시 변경가능 //10
Param := Param + '│' + '<비밀번호]'; //저장 시 변경가능 //11
Param := Param + '│' + En_Coding(GT_USERIF.ID); //12
Param := Param + '│' + ls_Rcrd[13]; //13
Param := Param + '│' + ls_Rcrd[14]; //14
Param := Param + '│' + ls_Rcrd[10]; //15
Param := Param + '│' + 'y'; //16
Param := Param + '│' + ls_Rcrd[16]; //17 rbList05
Param := Param + '│' + ls_Rcrd[17]; //18
Param := Param + '│' + ls_Rcrd[18]; //19
Param := Param + '│' + '<부가세포함]'; //20 rb_SurtaxY
Param := Param + '│' + ls_Rcrd[20]; //21
Param := Param + '│' + '<계약일]'; //22 dtRegDate.Text
Param := Param + '│' + '<계약종료일]'; //23 dtFinDate.Text
Param := Param + '│' + '<법인고객메모]'; //24 edtCustMemo
Param := Param + '│' + ls_Rcrd[24]; //25 cbbTaxDate
Param := Param + '│' + ls_Rcrd[25]; //26 edtTaxMName
Param := Param + '│' + ls_Rcrd[26]; //27 edtTaxOwner
Param := Param + '│' + ls_Rcrd[27]; //28 edtTaxSNo
Param := Param + '│' + ls_Rcrd[28]; //29 edtTaxUpTae
Param := Param + '│' + ls_Rcrd[29]; //30 edtTaxUpJong
Param := Param + '│' + ls_Rcrd[30]; //31 edtTaxAddr
Param := Param + '│' + ls_Rcrd[31]; //32 cb_CalFrom
Param := Param + '│' + ls_Rcrd[32]; //33 cb_CalTo
Param := Param + '│' + ls_Rcrd[33]; //34 rb_TaxBill
Param := Param + '│' + '<계약여부]'; //35 cb_Contract
Param := Param + '│' + '<법인상태메모]'; //36 edtCustStateMemo
Param := Param + '│' + ls_Rcrd[36]; //37 chkLimitUse
Param := Param + '│' + ls_Rcrd[37]; //38 cbLimitBaseDay
Param := Param + '│' + ls_Rcrd[38]; //39 cedtLimitCount
Param := Param + '│' + ls_Rcrd[39]; //40 cedtLimitAmt
Param := Param + '│' + ls_Rcrd[40]; //41 chkLimitOver
if Pos('대리', cxLimitCardVat.Text) > 0 then Param := Param + '│' + '1' else //43 카드결제수수료타입{0:미적용, 1:대리요금,2:기사입금액,3:카드결제금액}
if Pos('기사', cxLimitCardVat.Text) > 0 then Param := Param + '│' + '2' else
if Pos('카드', cxLimitCardVat.Text) > 0 then Param := Param + '│' + '3'
else Param := Param + '│' + '0';
Param := Param + '│' + IntToStr(StrToIntRltDef(cxLimitCardVat.Text)); //44 카드결제수수료값
gsCustViewParam := Param;
{
edName01.Text := ls_Rcrd[0]; //3
edName03.Text := ls_Rcrd[1]; //4
edText01.Text := ls_Rcrd[2]; //5
edText02.Text := strtocall(ls_Rcrd[3]); //6
edText03.Text := ls_Rcrd[4]; //7
edText04.Text := ls_Rcrd[5]; //8
rbList01.Tag := 1;
if ls_Rcrd[6] = '0' then //9
rbList01.Checked := True
else if ls_Rcrd[6] = '2' then
rbPayMethodPost.Checked := True
else
rbList02.Checked := True;
rbList01.Tag := 0;
edWebID.Text := ls_Rcrd[7]; //10
edWebPW.Text := ls_Rcrd[8]; //11
// En_Coding(GT_USERIF.ID); //12
// edHdNo.Text := ls_Rcrd[13]; //13
// edBrNo.Text := ls_Rcrd[14]; //14
// edKeyNum.Text := ls_Rcrd[10]; //15
// 'y' //16
// ls_Rcrd[16] //17 rbList05.Checked := True
// edName02.Text := ls_Rcrd[17]; //18
// edName04.Text := ls_Rcrd[18]; //19
// ls_Rcrd[19] = 'y' then //20 rb_SurtaxY.Checked := True
// edtEmail.Text := ls_Rcrd[20]; //21
// ls_Rcrd[21], DateTime) then //22 dtRegDate.Text
// ls_Rcrd[22], DateTime) then //23 dtFinDate.Text
// edtCustMemo.Text := ls_Rcrd[23]; //24
// ls_Rcrd[24] then //25 cbbTaxDate.Text
// edtTaxMName.Text := ls_Rcrd[25]; //26
// edtTaxOwner.Text := ls_Rcrd[26]; //27
// edtTaxSNo.Text := ls_Rcrd[27]; //28
// edtTaxUpTae.Text := ls_Rcrd[28]; //29
// edtTaxUpJong.Text := ls_Rcrd[29]; //30
// edtTaxAddr.Text := ls_Rcrd[30]; //31
// cb_CalFrom.ItemIndex := StrToIntDef(ls_Rcrd[31],0) //32
// cb_CalTo.ItemIndex := StrToIntDef(ls_Rcrd[32],0) //33
// ls_Rcrd[33], 0) //34 rb_TaxBill.Checked
// cb_Contract.ItemIndex := StrToIntDef(ls_Rcrd[34], 0); //35 cb_Contract.itemindex
// edtCustStateMemo.Text := ls_Rcrd[35]; //36
// if ls_Rcrd[36] = 'y' then chkLimitUse.Checked := True //37
// cbLimitBaseDay.Text := ls_Rcrd[37]; //38
// cedtLimitCount.Value := StrToFloatDef(ls_Rcrd[38], 0); //39
// cedtLimitAmt.Value := StrToFloatDef(ls_Rcrd[39], 0); //40
// if ls_Rcrd[40] = 'y' then chkLimitOver.Checked := True //41
// Pos('대리', cxLimitCardVat.Text) > 0 then Param := Param + '│' + '1' else //42
// Pos('기사', cxLimitCardVat.Text) > 0 then Param := Param + '│' + '2' else
// Pos('카드', cxLimitCardVat.Text) > 0 then Param := Param + '│' + '3'
// if ls_Rcrd[41] = '0' then cxLimitCardVat.ItemIndex := 0 //42 }
{ if Pos('대리', cxLimitCardVat.Text) > 0 then Param := Param + '│' + '1' else //43 카드결제수수료타입(0:미적용, 1:대리요금,2:기사입금액,3:카드결제금액)
if Pos('기사', cxLimitCardVat.Text) > 0 then Param := Param + '│' + '2' else
if Pos('카드', cxLimitCardVat.Text) > 0 then Param := Param + '│' + '3'
else Param := Param + '│' + '0';
Param := Param + '│' + IntToStr(StrToIntRltDef(cxLimitCardVat.Text)); //44 카드결제수수료값 }
end;
finally
ls_Rcrd.Free;
Screen.Cursor := crDefault;
Frm_Flash.Hide;
end;
end;
finally
Screen.Cursor := crDefault;
xdom := Nil;
end;
except
on e: exception do
begin
Screen.Cursor := crDefault;
Assert(False, E.Message);
end;
end;
end;
procedure TFrm_CUT1.proc_search_bubin_id;
var
ls_TxQry, ls_TxLoad, sQueryTemp: string;
rv_str : string;
ls_rxxml: WideString;
slReceive: TStringList;
ErrCode: integer;
xdom: msDomDocument;
ls_ClientKey, ls_Msg_Err : string;
lst_Result: IXMLDomNodeList;
ls_Rcrd: TStringList;
begin
//2008-09-02 작성자 : 임창기 (SELECT 전문으로 입력한 아이디가 등록되어있는지 체크한다.)
//CDMS_CUST_BGROUP 테이블에 CB_WEB_ID 컬럼 조회
try
ls_TxLoad := GTx_UnitXmlLoad('SEL01.XML');
fGet_BlowFish_Query(GSQ_BUBIN_ID_SEARCH, sQueryTemp);
ls_TxQry := Format(sQueryTemp, [edWebID{edt_WebIDFirst}.text]);
ls_TxLoad := StringReplace(ls_TxLoad, 'UserIDString', GT_USERIF.ID, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientVerString', VERSIONINFO, [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'ClientKeyString', 'BUBINIDCHK', [rfReplaceAll]);
ls_TxLoad := StringReplace(ls_TxLoad, 'QueryString', ls_TxQry, [rfReplaceAll]);
slReceive := TStringList.Create;
try
if dm.SendSock(ls_TxLoad, slReceive, ErrCode, False) then
begin
rv_str := slReceive[0];
if rv_str <> '' then
begin
ls_rxxml := rv_str;
Application.ProcessMessages;
xdom := ComsDomDocument.Create;
try
if not xdom.loadXML(ls_rxxml) then
Exit;
ls_ClientKey := GetXmlClientKey(ls_rxxml);
ls_Msg_Err := GetXmlErrorCode(ls_rxxml);
if ('0000' = ls_Msg_Err) then
begin
if (0 < GetXmlRecordCount(ls_rxxml)) then
begin
lst_Result := xdom.documentElement.selectNodes('/cdms/Service/Data/Result');
ls_Rcrd := TStringList.Create;
try
GetTextSeperationEx('│', lst_Result.item[0].attributes.getNamedItem('Value').Text, ls_Rcrd);
// ls_Rcrd := GetTextSeperation('│', lst_Result.item[0].attributes.getNamedItem('Value').Text);
if ls_Rcrd[0] = '0' then
begin
GMessagebox('사용 가능한 아이디 입니다.', CDMSE);
btn_WebId.Tag := 0;
{ edt_WebPW1.Enabled := True;
edt_WebPW2.Enabled := True;
edt_WebPW1.SetFocus;
btn_Confirm.Tag := 1; //중복체크 함 }
end
else
begin
GMessagebox('사용중인 아이디 입니다.', CDMSE);
edWebID{edt_WebIdFirst}.SetFocus;
end;
finally
ls_Rcrd.Free;
end;
end;
end;
finally
xdom := Nil;
end;
end else
begin
end;
end;
finally
Frm_Flash.Hide;
FreeAndNil(slReceive);
end;
except
end;
end;
procedure TFrm_CUT1.proc_Set_ExcelMasking;
var iRow, i: integer;
begin
Try
Try
cxGrid_Angel2_Masking.DataController.SetRecordCount(0);
cxGrid_Angel2_Masking.beginUpdate;
for i := 0 to cxGrid_Angel2.DataController.Recordcount - 1 do
begin
iRow := cxGrid_Angel2_Masking.DataController.AppendRecord;
cxGrid_Angel2_Masking.DataController.Values[iRow, 0] := cxGrid_Angel2.DataController.Values[i, 0]; //순번
cxGrid_Angel2_Masking.DataController.Values[iRow, 1] := cxGrid_Angel2.DataController.Values[i, 1]; //접수번호
cxGrid_Angel2_Masking.DataController.Values[iRow, 2] := cxGrid_Angel2.DataController.Values[i, 2]; //영업일
cxGrid_Angel2_Masking.DataController.Values[iRow, 3] := cxGrid_Angel2.DataController.Values[i, 3]; //접수일시-최초접수일시
cxGrid_Angel2_Masking.DataController.Values[iRow, 4] := cxGrid_Angel2.DataController.Values[i, 4]; //지사명
cxGrid_Angel2_Masking.DataController.Values[iRow, 5] := cxGrid_Angel2.DataController.Values[i, 5]; //서비스명
cxGrid_Angel2_Masking.DataController.Values[iRow, 6] := cxGrid_Angel2.DataController.Values[i, 6]; //접수상태- 오더상태
cxGrid_Angel2_Masking.DataController.Values[iRow, 7] := cxGrid_Angel2.DataController.Values[i, 7]; //법인/일반 무조건 법인만 조회된다고 함. 서승우과장
cxGrid_Angel2_Masking.DataController.Values[iRow, 8] := cxGrid_Angel2.DataController.Values[i, 8]; //고객명
cxGrid_Angel2_Masking.DataController.Values[iRow, 9] := cxGrid_Angel2.DataController.Values[i, 9]; //고객직책
cxGrid_Angel2_Masking.DataController.Values[iRow, 10] := StrToCallMasking(cxGrid_Angel2.DataController.Values[i, 10], 2); //고객전화번호
cxGrid_Angel2_Masking.DataController.Values[iRow, 11] := cxGrid_Angel2.DataController.Values[i, 11]; //업체 ID-법인코드
cxGrid_Angel2_Masking.DataController.Values[iRow, 12] := cxGrid_Angel2.DataController.Values[i, 12]; //업체명
cxGrid_Angel2_Masking.DataController.Values[iRow, 13] := cxGrid_Angel2.DataController.Values[i, 13]; //접수자
cxGrid_Angel2_Masking.DataController.Values[iRow, 14] := cxGrid_Angel2.DataController.Values[i, 14]; //접수취소사유
cxGrid_Angel2_Masking.DataController.Values[iRow, 15] := cxGrid_Angel2.DataController.Values[i, 15]; //기사ID
cxGrid_Angel2_Masking.DataController.Values[iRow, 16] := cxGrid_Angel2.DataController.Values[i, 16]; //기사사번
cxGrid_Angel2_Masking.DataController.Values[iRow, 17] := cxGrid_Angel2.DataController.Values[i, 17]; //기사명
cxGrid_Angel2_Masking.DataController.Values[iRow, 18] := cxGrid_Angel2.DataController.Values[i, 18]; //자/타기사 구분
cxGrid_Angel2_Masking.DataController.Values[iRow, 19] := cxGrid_Angel2.DataController.Values[i, 19]; //배차시간
cxGrid_Angel2_Masking.DataController.Values[iRow, 20] := cxGrid_Angel2.DataController.Values[i, 20]; //대기시간
cxGrid_Angel2_Masking.DataController.Values[iRow, 21] := cxGrid_Angel2.DataController.Values[i, 21]; //운행종료시간
cxGrid_Angel2_Masking.DataController.Values[iRow, 22] := cxGrid_Angel2.DataController.Values[i, 22]; //출발지 POI
cxGrid_Angel2_Masking.DataController.Values[iRow, 23] := cxGrid_Angel2.DataController.Values[i, 23];//출발주소
cxGrid_Angel2_Masking.DataController.Values[iRow, 24] := cxGrid_Angel2.DataController.Values[i, 24]; //출발지 시/도
cxGrid_Angel2_Masking.DataController.Values[iRow, 25] := cxGrid_Angel2.DataController.Values[i, 25]; //출발지 구/군
cxGrid_Angel2_Masking.DataController.Values[iRow, 26] := cxGrid_Angel2.DataController.Values[i, 26]; //출발지 동/리
cxGrid_Angel2_Masking.DataController.Values[iRow, 27] := cxGrid_Angel2.DataController.Values[i, 27]; //도착지 POI
cxGrid_Angel2_Masking.DataController.Values[iRow, 28] := cxGrid_Angel2.DataController.Values[i, 28];//도착주소
cxGrid_Angel2_Masking.DataController.Values[iRow, 29] := cxGrid_Angel2.DataController.Values[i, 29]; //도착지 시/도
cxGrid_Angel2_Masking.DataController.Values[iRow, 30] := cxGrid_Angel2.DataController.Values[i, 30]; //도착지 구/군
cxGrid_Angel2_Masking.DataController.Values[iRow, 31] := cxGrid_Angel2.DataController.Values[i, 31]; //도착지 동/리
cxGrid_Angel2_Masking.DataController.Values[iRow, 32] := cxGrid_Angel2.DataController.Values[i, 32]; //경유지
cxGrid_Angel2_Masking.DataController.Values[iRow, 33] := cxGrid_Angel2.DataController.Values[i, 33]; //주행거리
cxGrid_Angel2_Masking.DataController.Values[iRow, 34] := cxGrid_Angel2.DataController.Values[i, 34]; //지불유형 //2
cxGrid_Angel2_Masking.DataController.Values[iRow, 35] := cxGrid_Angel2.DataController.Values[i, 35]; //접수요금
cxGrid_Angel2_Masking.DataController.Values[iRow, 36] := cxGrid_Angel2.DataController.Values[i, 36]; //경유요금
cxGrid_Angel2_Masking.DataController.Values[iRow, 37] := cxGrid_Angel2.DataController.Values[i, 37]; //대기요금
cxGrid_Angel2_Masking.DataController.Values[iRow, 38] := cxGrid_Angel2.DataController.Values[i, 38]; //기타비용
cxGrid_Angel2_Masking.DataController.Values[iRow, 39] := cxGrid_Angel2.DataController.Values[i, 39]; //지원금
cxGrid_Angel2_Masking.DataController.Values[iRow, 40] := cxGrid_Angel2.DataController.Values[i, 40]; //보정금
cxGrid_Angel2_Masking.DataController.Values[iRow, 41] := cxGrid_Angel2.DataController.Values[i, 41]; //현금결제액
cxGrid_Angel2_Masking.DataController.Values[iRow, 42] := cxGrid_Angel2.DataController.Values[i, 42]; //카드결제액
cxGrid_Angel2_Masking.DataController.Values[iRow, 43] := cxGrid_Angel2.DataController.Values[i, 43]; //기사수수료
cxGrid_Angel2_Masking.DataController.Values[iRow, 44] := cxGrid_Angel2.DataController.Values[i, 44]; //기사수수료율
cxGrid_Angel2_Masking.DataController.Values[iRow, 45] := cxGrid_Angel2.DataController.Values[i, 45]; //기사메모
cxGrid_Angel2_Masking.DataController.Values[iRow, 46] := cxGrid_Angel2.DataController.Values[i, 46]; //고객메모
cxGrid_Angel2_Masking.DataController.Values[iRow, 47] := cxGrid_Angel2.DataController.Values[i, 47]; //적요1
cxGrid_Angel2_Masking.DataController.Values[iRow, 48] := cxGrid_Angel2.DataController.Values[i, 48]; //적요2
end;
finally
cxGrid_Angel2_Masking.EndUpdate;
end;
except
on E: Exception do
begin
Screen.Cursor := crDefault;
cxPageControl1.Enabled := True;
Assert(False, E.Message);
Frm_Flash.Hide;
end;
end;
end;
procedure TFrm_CUT1.proc_SND_SMS(sGrid: TcxGridDBTableView; ASubscribe: Boolean);
var
i, iBrNo, iCustTel, iCustName, iKeyNum, iCnt, RowIdx, iRow, KeyRow, ikey_cnt, iMile, iSmsYn: Integer;
sCustTel, sSmsYn: string;
slTmp : THashedStringList;
begin
GS_CUTSMS := True;
iBrNo := sGrid.GetColumnByFieldName('지사코드').Index;
iCustTel := sGrid.GetColumnByFieldName('고객번호').Index;
iCustName := sGrid.GetColumnByFieldName('고객명').Index;
iKeyNum := sGrid.GetColumnByFieldName('대표번호').Index;
iMile := sGrid.GetColumnByFieldName('마일리지').Index;
iSmsYn := sGrid.GetColumnByFieldName('SMS수신거부').Index;
iCnt := 0;
Frm_Main.procMenuCreateActive(1001, 'SMS발송');
Frm_SMS.chkBalsin.Enabled := True;
Frm_SMS.cxViewSms.DataController.SetRecordCount(0);
Frm_SMS.cxViewKeyNum.DataController.SetRecordCount(0);
Frm_SMS.cxViewSms.BeginUpdate;
Frm_SMS.cxViewKeyNum.BeginUpdate;
slTmp := THashedStringList.Create;
Try
Screen.Cursor := crHourGlass;
for I := 0 to sGrid.DataController.RecordCount - 1 do
begin
if sGrid.ViewData.Records[i].Selected then
begin
sCustTel := StringReplace(sGrid.ViewData.Records[I].Values[iCustTel], '-', '', [rfreplaceAll]);
if slTmp.IndexOf(sCustTel) > -1 then Continue;
slTmp.add(sCustTel);
if ASubscribe and (iSmsYn <> -1) then
sSmsYn := sGrid.ViewData.Records[I].Values[iSmsYn]
else
sSmsYn := 'y';
if (Copy(sCustTel, 1, 2) = '01') and (Length(sCustTel) in [10, 11]) and
((sSmsYn = 'y') or (sSmsYn = '수신')) then
begin
// 전송내역 구성
RowIdx := Frm_SMS.cxViewSms.DataController.AppendRecord;
// 0, 지사코드
Frm_SMS.cxViewSms.DataController.Values[RowIdx, 0] := sGrid.ViewData.Records[I].Values[iBrNo];
// 1, 대표번호
Frm_SMS.cxViewSms.DataController.Values[RowIdx, 1] := StringReplace(sGrid.ViewData.Records[I].Values[iKeyNum], '-', '', [rfreplaceAll]);
// 2, 고객번호
Frm_SMS.cxViewSms.DataController.Values[RowIdx, 2] := StringReplace(sGrid.ViewData.Records[I].Values[iCustTel], '-', '', [rfreplaceAll]);
// 3, 고객명
Frm_SMS.cxViewSms.DataController.Values[RowIdx, 3] := sGrid.ViewData.Records[I].Values[iCustName];
// 4, 마일리지
Frm_SMS.cxViewSms.DataController.Values[RowIdx, 6] := sGrid.ViewData.Records[I].Values[iMile];
Inc(icnt);
// 대표전화별 전송수 카운팅
iRow := Frm_SMS.cxViewKeyNum.DataController.FindRecordIndexByText(0, 1,
Frm_SMS.cxViewSms.DataController.Values[RowIdx, 1], True, True, True);
if iRow = -1 then
begin
KeyRow := Frm_SMS.cxViewKeyNum.DataController.AppendRecord;
Frm_SMS.cxViewKeyNum.DataController.Values[KeyRow, 0] := Frm_SMS.cxViewSms.DataController.Values[RowIdx, 0];
Frm_SMS.cxViewKeyNum.DataController.Values[KeyRow, 1] := Frm_SMS.cxViewSms.DataController.Values[RowIdx, 1];
Frm_SMS.cxViewKeyNum.DataController.Values[KeyRow, 2] := 1;
end else
begin
ikey_cnt := Integer(Frm_SMS.cxViewKeyNum.DataController.Values[iRow, 2]);
Inc(ikey_cnt);
Frm_SMS.cxViewKeyNum.DataController.SetValue(iRow, 2, ikey_cnt);
end;
end;
end;
end;
Frm_SMS.cxViewSms.EndUpdate;
Frm_SMS.cxViewKeyNum.EndUpdate;
Frm_SMS.cxViewSms.Columns[1].SortOrder := soAscending;
Frm_SMS.mmoAfter.Text := IntToStr(iCnt);
// 외부에서 호출함수
Frm_SMS.proc_branch_sms;
Frm_SMS.Show;
Frm_SMS.cxBtnHelp.Click;
Finally
Screen.Cursor := crDefault;
slTmp.Free;
End;
end;
procedure TFrm_CUT1.rbBubinAuthchkDate01Click(Sender: TObject);
begin
if rbBubinAuthchkDate01.Checked then
begin
cxDate22.Date := StrToDate(Date8to10(copy(StartDateTime('yyyymmddhhmmss'), 1, 8)));
cxDate23.Date := cxDate22.Date + 1;
cxDate22.Enabled := False;
cxDate23.Enabled := False;
end else
if rbBubinAuthchkDate02.Checked then
begin
cxDate22.Date := now - 1;
cxDate23.Date := now;
cxDate22.Enabled := True;
cxDate23.Enabled := True;
end;
end;
procedure TFrm_CUT1.RbButton1MouseDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
pm_Date.Popup(Mouse.CursorPos.X, Mouse.CursorPos.y);
end;
procedure TFrm_CUT1.rb_BillYClick(Sender: TObject);
begin
if rb_BillY.Checked then rb_BillY.Hint := 'y';
if rb_BillN.Checked then rb_BillY.Hint := 'n';
end;
procedure TFrm_CUT1.rb_DepositYClick(Sender: TObject);
begin
if rb_DepositY.Checked then rb_DepositY.Hint := 'y';
if rb_DepositN.Checked then rb_DepositY.Hint := 'n';
end;
procedure TFrm_CUT1.RequestData(AData: string);
var
ReceiveStr: string;
StrList: TStringList;
ErrCode: integer;
begin
StrList := TStringList.Create;
Screen.Cursor := crHandPoint;
try
if dm.SendSock(AData, StrList, ErrCode, False) then
begin
ReceiveStr := StrList[0];
if trim(ReceiveStr) <> '' then
begin
Application.ProcessMessages;
proc_recieve(StrList);
end;
end;
finally
Screen.Cursor := crDefault;
StrList.Free;
Frm_Flash.Hide;
end;
end;
procedure TFrm_CUT1.SetTree_ListItem(sHdcd, sBrcd: String; idx: Integer);
var
i, j : Integer;
LeftTreePtr : PTreeRec;
begin
SetDebugeWrite('Main.SetTree_LeftItem');
try
for i := 0 to CustView18_1.Count - 1 do
begin
LeftTreePtr := CustView18_1.Items[i].Data;
if ( LeftTreePtr^.HDCode = sHdcd ) And ( LeftTreePtr^.BrCode = sBrcd ) And ( LeftTreePtr^.FIndex = idx ) then
begin
CustView18_1.Items[i].Selected := True;
CustView18_1.Items[i].Checked := True;
CustView18_1.Setfocus;
CustView18_1.Items[i].MakeVisible;
Break;
end;
for j := 0 to CustView18_1.Items[i].Count - 1 do
begin
LeftTreePtr := CustView18_1.Items[i].Items[j].Data;
if ( LeftTreePtr^.HDCode = sHdcd ) And ( LeftTreePtr^.BrCode = sBrcd ) And ( LeftTreePtr^.FIndex = idx ) then
begin
CustView18_1.Setfocus;
CustView18_1.Items[i].Items[j].Selected := True;
CustView18_1.Items[i].Items[j].Checked := True;
CustView18_1.Items[i].Expand(True);
CustView18_1.Items[i].Items[j].MakeVisible;
Break;
end;
end;
end;
except on E: Exception do
Assert(False, E.Message);
end;
end;
end.
|
unit UCL.SystemSettings;
interface
uses
UCL.Classes,
System.Win.Registry,
Winapi.Windows,
VCL.Graphics;
function GetAccentColor: TColor;
function GetColorOnBorderEnabled: Boolean;
function GetAppTheme: TUTheme;
implementation
function GetAccentColor: TColor;
var
Reg: TRegistry;
ARGB: Cardinal;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
try
Reg.OpenKeyReadOnly('Software\Microsoft\Windows\DWM\');
ARGB := Reg.ReadInteger('AccentColor');
Result := ARGB mod $FF000000; // ARGB to RGB
except
Result := $D77800; // Default blue
end;
finally
Reg.Free;
end;
end;
function GetColorOnBorderEnabled: Boolean;
var
Reg: TRegistry;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
try
Reg.OpenKeyReadOnly('Software\Microsoft\Windows\DWM\');
Result := Reg.ReadInteger('ColorPrevalence') <> 0;
except
Result := false;
end;
finally
Reg.Free;
end;
end;
function GetAppTheme: TUTheme;
var
Reg: TRegistry;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
try
Reg.OpenKeyReadOnly('Software\Microsoft\Windows\CurrentVersion\Themes\Personalize\');
if Reg.ReadInteger('AppsUseLightTheme') = 0 then
Result := utDark
else
Result := utLight;
except
Result := utLight;
// Apply this fix
Reg.CloseKey;
Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Themes\Personalize\', true);
Reg.WriteInteger('AppsUseLightTheme', 1);
end;
finally
Reg.Free;
end;
end;
end.
|
{
Build a list of interior cells in csv format
}
unit SkyrimListInteriorCells;
var
CountRef, CountRefPersistent, CountRefDeleted, CountRefDisabled: integer;
CountNAVM, CountSpawn, CountLight, CountSound: integer;
CountFurniture, CountContainer: integer;
slCells: TStringList;
slSpawns: TStringList;
procedure ClearCellData;
begin
CountRef := 0;
CountRefPersistent := 0;
CountRefDeleted := 0;
CountRefDisabled := 0;
CountNAVM := 0;
CountSpawn := 0;
slSpawns.Clear;
CountLight := 0;
CountSound := 0;
CountFurniture := 0;
CountContainer := 0;
end;
function Initialize: integer;
begin
slCells := TStringList.Create;
slCells.Add('FormID;Block;Sub-Block;EditorID;Name;Ownership;Location;LightingTemplate;ImageSpace;AcousticSpace;Music;Navmeshes;References;Persistent;Deleted;Disabled;Spawns;SpawnsList;Lights;Sounds;Furnitures;Containers');
slSpawns := TStringList.Create; slSpawns.Sorted := True; slSpawns.Duplicates := dupIgnore;
ClearCellData;
end;
function Process(e: IInterface): integer;
var
sig, sigbase, s: string;
block, subblock: integer;
r: IInterface;
begin
sig := Signature(e);
if (sig = 'REFR')
or (sig = 'ACHR')
or (sig = 'PARW')
or (sig = 'PBAR')
or (sig = 'PBEA')
or (sig = 'PCON')
or (sig = 'PFLA')
or (sig = 'PHZD')
or (sig = 'PMIS') then begin
Inc(CountRef);
if GetIsPersistent(e) then Inc(CountRefPersistent);
if GetIsDeleted(e) then Inc(CountRefDeleted);
if GetIsinitiallyDisabled(e) then Inc(CountRefDisabled);
r := BaseRecord(e);
sigbase := Signature(r);
if sig = 'ACHR' then begin
Inc(CountSpawn);
slSpawns.Add(EditorID(r));
end;
if sigbase = 'LIGH' then Inc(CountLight)
else if sigbase = 'SOUN' then Inc(CountSound)
else if sigbase = 'FURN' then Inc(CountFurniture)
else if sigbase = 'CONT' then Inc(CountContainer);
end
else if sig = 'NAVM' then begin
if not GetIsDeleted(e) then Inc(CountNAVM);
end
else if sig = 'CELL' then begin
// only for interior cells
if GetElementNativeValues(e, 'DATA') and 1 > 0 then begin
s := IntToStr(FormID(e) and $FFFFFF);
block := StrToInt(s[length(s)]);
subblock := StrToInt(s[length(s)-1]);
slCells.Add(Format('%s;%d;%d;%s;%s;%s;%s;%s;%s;%s;%s;%d;%d;%d;%d;%d;%d;%s;%d;%d;%d;%d', [
'[' + IntToHex(FormID(e), 8) + ']', // add [] to prevent Excel from treating FormID as a number
block,
subblock,
EditorID(e),
GetElementEditValues(e, 'FULL'),
EditorID(LinksTo(ElementByPath(e, 'Ownership\XOWN'))),
EditorID(LinksTo(ElementBySignature(e, 'XLCN'))),
EditorID(LinksTo(ElementBySignature(e, 'LTMP'))),
EditorID(LinksTo(ElementBySignature(e, 'XCIM'))),
EditorID(LinksTo(ElementBySignature(e, 'XCAS'))),
EditorID(LinksTo(ElementBySignature(e, 'XCMO'))),
CountNAVM,
CountRef,
CountRefPersistent,
CountRefDeleted,
CountRefDisabled,
CountSpawn,
slSpawns.CommaText,
CountLight,
CountSound,
CountFurniture,
CountContainer
]));
end;
ClearCellData;
end;
end;
function Finalize: integer;
var
fname: string;
begin
if slCells.Count > 1 then begin
fname := ScriptsPath + 'Cells.csv';
AddMessage('Saving report to ' + fname);
slCells.SaveToFile(fname);
end else
AddMessage('No cells found in selection.');
slSpawns.Free;
slCells.Free;
end;
end.
|
unit ImageToTilesTypes;
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}
interface
uses
{$IFNDEF FPC}
Vcl.Graphics, System.Generics.Collections;
{$ELSE}
Graphics, Generics.Collections, Generics.Defaults;
{$ENDIF}
const
LIT_TOK_V4TLIMG_MAGICI = 'V4TI';
VAL_SIZ_TILEPIX_LENGTH = 8;
VAL_SIZ_TILEPIX_TLRGBD = VAL_SIZ_TILEPIX_LENGTH * VAL_SIZ_TILEPIX_LENGTH * 3;
VAL_SIZ_TILEPIX_TLPALD = VAL_SIZ_TILEPIX_LENGTH * VAL_SIZ_TILEPIX_LENGTH;
VAL_CLR_TILEPAL_BACKGD = -1;
VAL_CLR_TILEPAL_FOREGD = -2;
VAL_CLR_TILEPAL_UNKNWN = -3;
type
TColourRec = packed record
case Boolean of
True: (
R, G, B, A: Byte
);
False: (
C: TColor)
end;
TMD5 = array[0..15] of Byte;
PRGBPixel = ^TRGBPixel;
TRGBPixel = packed record
B, G, R: Byte;
end;
//dengland I'm making this an integer so that foreground and background can be
// explicitly signalled. Must be SmallInt because we also need the value $FF.
PPaletteColour = ^TPaletteColour;
TPaletteColour = SmallInt;
TPaletteInfo = record
Colour: TPaletteColour;
Count: Integer;
end;
PRGBPixelArr = ^TRGBPixelArr;
TRGBPixelArr = array[0..4095] of TRGBPixel;
TTileRGBData = array[0..VAL_SIZ_TILEPIX_TLRGBD - 1] of Byte;
TTileMaskData = array[0..VAL_SIZ_TILEPIX_TLPALD - 1] of Byte;
TTilePalData = array[0..VAL_SIZ_TILEPIX_TLPALD - 1] of TPaletteColour;
TTilePalDataRaw = array[0..VAL_SIZ_TILEPIX_TLPALD - 1] of Byte;
TTilePaletteInfo = array[0..VAL_SIZ_TILEPIX_TLPALD - 1] of TPaletteInfo;
TTile = class
public
Index: Integer;
Count: Integer;
Padding: Boolean;
EndMarker: Boolean;
SegTile: Integer;
Segment: Integer;
RGBData: TTileRGBData;
MaskData: TTileMaskData;
//fixme I should carry this data in processing logic. I don't.
PalData: TTilePalData;
Foreground: TPaletteColour;
ColCount: Integer;
end;
TTileList = TList<TTile>;
{ TTileSort }
TTileSort = class(TComparer<TTile>)
public
function Compare(constref ALeft, ARight: TTile): Integer; override;
end;
PTileMapCell = ^TTileMapCell;
TTileMapCell = record
public
Tile: TTile;
FlipX,
FlipY: Boolean;
ForeGnd: TPaletteColour;
end;
TTileMapRow = array of TTileMapCell;
TTileMap = array of TTileMapRow;
TTileDictionary = TDictionary<TMD5, TTileList>;
TPaletteEntry = record
RGB: TRGBPixel;
// Tiles: TTileList;
Count: Integer;
end;
PPaletteMap = ^TPaletteMap;
TPaletteMap = array of TPaletteEntry;
// 254 bytes + 2 bytes sector pointer is one disk sector.
TV4TImgHeader = packed record
Magic: array[0..3] of AnsiChar; //0
Version: Word; //4
Mode: Byte; //5
Reserved0: Byte; //6
ColCount: Byte; //7
RowCount: Byte; //8
LoadBufferAddr: Cardinal; //9
ScreenRAMAddr: Cardinal; //13 0
ColourRAMAddr: Cardinal; //17 4
PaletteAddr: Cardinal; //21 8
PaletteBank: Byte; //25 12
PaletteCount: Byte; //26 13
PaletteOffset: Byte; //27 14
TileCounts: array[0..191] of Byte; //28 15
RelocSource: Cardinal;
RelocDest: Cardinal;
RelocSize: Word;
Reserved1: array[0..22] of Byte;
end;
TMemAddress = $00000..$2FFFF;
TMemModKind = (mmkFree, mmkSystem, mmkSysColourRAM, mmkScreenRAM,
mmkColourRAM, mmkPalette, mmkBuffer, mmkReserved, mmkUnavailable,
mmkRelocSource, mmkRelocDest);
TMemModKinds = set of TMemModKind;
TMemModule = record
Name: string;
Kind: TMemModKind;
Start: TMemAddress;
Segments: Word;
end;
TMemMapTiles = record
Segment: Integer;
Count: Integer;
end;
TMemModuleSegs = array[0..191] of TMemModule;
TMemTileSegs = array[0..191] of TMemMapTiles;
const
VAL_SZE_MEMMOD_SEG = $0400;
REC_MEMMOD_SYSTEMLO: TMemModule = (
Name: 'System Lo'; Kind: mmkSystem;
Start: $00000; Segments: 1);
REC_MEMMOD_SYSTEMHI: TMemModule = (
Name: 'System Hi'; Kind: mmkSystem;
Start: $0FC00; Segments: 1);
REC_MEMMOD_SYSTEMIO: TMemModule = (
Name: 'System IO'; Kind: mmkSystem;
Start: $0D000; Segments: 4);
REC_MEMMOD_SYSCLRRM: TMemModule = (
Name: 'System Colour RAM'; Kind: mmkSysColourRAM;
Start: $1F800; Segments: 2);
REC_MEMMOD_SCREENRM: TMemModule = (
Name: 'Screen RAM'; Kind: mmkScreenRAM;
Start: $02000; Segments: 2);
REC_MEMMOD_LDBUFFER: TMemModule = (
Name: 'Load Buffer'; Kind: mmkBuffer;
Start: $01800; Segments: 2);
LIT_TOK_MEMMOD_CLR = 'Colour RAM';
LIT_TOK_MEMMOD_RSV = 'Reserved';
LIT_TOK_MEMMOD_FRE = 'Free';
LIT_TOK_MEMMOD_PAL = 'Palette Buffer';
LIT_TOK_MEMMOD_UNV = 'Unavailable to Tiles';
LIT_TOK_MEMMOD_RLS = 'Relocation Source';
LIT_TOK_MEMMOD_RLD = 'Relocation Destination';
//dengland
// What on earth was I doing with the Mask? I cannot remember.
function ComputeTileMD5(AData: TTileRGBData; {AMask: TTileMaskData;}
var AMD5: TMD5): Boolean;
procedure SortPaletteMap(var APalette: TPaletteMap);
implementation
type
TMD5Context = record
private
FTotal: array[0..1] of Cardinal;
FState: array[0..3] of Cardinal;
FBuffer: array[0..63] of Byte;
procedure Process(ABuf: PByte);
public
procedure Start;
procedure Update(ABuf: PByte; ACount: Cardinal);
procedure Finish(var AMD5: TMD5);
end;
const
ARR_VAL_TILEMMD5_PADDING: array[0..63] of Byte = (
$80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
function READ_LE_UINT32(ptr: Pointer): Cardinal; inline;
begin
Result:= PCardinal(ptr)^;
end;
procedure WRITE_LE_UINT32(ptr: Pointer; value: Cardinal); inline;
begin
PCardinal(ptr)^:= value;
end;
procedure GET_UINT32(var val: Cardinal; base: PByte; offs: Integer); inline;
begin
val:= READ_LE_UINT32(base + offs);
end;
procedure PUT_UINT32(val: Cardinal; base: PByte; offs: Integer); inline;
begin
WRITE_LE_UINT32(base + offs, val);
end;
{ TTileSort }
function TTileSort.Compare(constref ALeft, ARight: TTile): Integer;
begin
Result:= ALeft.Segment - ARight.Segment;
if Result = 0 then
Result:= ALeft.SegTile - ARight.SegTile;
end;
procedure TMD5Context.Finish(var AMD5: TMD5);
var
last,
padn: Cardinal;
high,
low: Cardinal;
msglen: array[0..7] of Byte;
begin
high:= (FTotal[0] shr 29) or (FTotal[1] shl 3);
low:= FTotal[0] shl 3;
PUT_UINT32(low, @msglen[0], 0);
PUT_UINT32(high, @msglen[0], 4);
last:= FTotal[0] and $3F;
if last < 56 then
padn:= 56 - last
else
padn:= 120 - last;
Update(@ARR_VAL_TILEMMD5_PADDING[0], padn);
Update(@msglen[0], 8);
PUT_UINT32(FState[0], @AMD5[0], 0);
PUT_UINT32(FState[1], @AMD5[0], 4);
PUT_UINT32(FState[2], @AMD5[0], 8);
PUT_UINT32(FState[3], @AMD5[0], 12);
end;
//This is pretty nasty. I hope there are no artefacts from the conversion and
// that I haven't otherwise broken the logic. For some reason the F
// routines don't match my pascal reference. I guess someone has
// determined that these versions are likely to be better??
procedure TMD5Context.Process(ABuf: PByte);
//define S(x, n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
function S(AX: Cardinal; AN: Byte): Cardinal; inline;
begin
Result:= ((AX shl AN) or ((AX and $FFFFFFFF) shr (32 - AN)));
end;
//define P(a, b, c, d, k, s, t)
// {
// a += F(b,c,d) + X[k] + t; a = S(a,s) + b;
// }
//define F(x, y, z) (z ^ (x & (y ^ z)))
procedure P1(var AA: Cardinal; AB, AC, AD: Cardinal; AX: Cardinal; AN: Byte;
AT: Cardinal); inline;
begin
Inc(AA, (AD xor (AB and (AC xor AD))) + AX + AT);
AA:= S(AA, AN) + AB;
end;
//define F(x, y, z) (y ^ (z & (x ^ y)))
procedure P2(var AA: Cardinal; AB, AC, AD: Cardinal; AX: Cardinal; AN: Byte;
AT: Cardinal); inline;
begin
Inc(AA, (AC xor (AD and (AB xor AC))) + AX + AT);
AA:= S(AA, AN) + AB;
end;
//define F(x, y, z) (x ^ y ^ z)
procedure P3(var AA: Cardinal; AB, AC, AD: Cardinal; AX: Cardinal; AN: Byte;
AT: Cardinal); inline;
begin
Inc(AA, (AB xor AC xor AD) + AX + AT);
AA:= S(AA, AN) + AB;
end;
//define F(x, y, z) (y ^ (x | ~z))
procedure P4(var AA: Cardinal; AB, AC, AD: Cardinal; AX: Cardinal; AN: Byte;
AT: Cardinal); inline;
begin
Inc(AA, (AC xor (AB or (not AD))) + AX + AT);
AA:= S(AA, AN) + AB;
end;
var
X: array[0..15] of Cardinal;
A,
B,
C,
D: Cardinal;
begin
GET_UINT32(X[0], ABuf, 0);
GET_UINT32(X[1], ABuf, 4);
GET_UINT32(X[2], ABuf, 8);
GET_UINT32(X[3], ABuf, 12);
GET_UINT32(X[4], ABuf, 16);
GET_UINT32(X[5], ABuf, 20);
GET_UINT32(X[6], ABuf, 24);
GET_UINT32(X[7], ABuf, 28);
GET_UINT32(X[8], ABuf, 32);
GET_UINT32(X[9], ABuf, 36);
GET_UINT32(X[10], ABuf, 40);
GET_UINT32(X[11], ABuf, 44);
GET_UINT32(X[12], ABuf, 48);
GET_UINT32(X[13], ABuf, 52);
GET_UINT32(X[14], ABuf, 56);
GET_UINT32(X[15], ABuf, 60);
A:= FState[0];
B:= FState[1];
C:= FState[2];
D:= FState[3];
P1(A, B, C, D, X[ 0], 7, $D76AA478);
P1(D, A, B, C, X[ 1], 12, $E8C7B756);
P1(C, D, A, B, X[ 2], 17, $242070DB);
P1(B, C, D, A, X[ 3], 22, $C1BDCEEE);
P1(A, B, C, D, X[ 4], 7, $F57C0FAF);
P1(D, A, B, C, X[ 5], 12, $4787C62A);
P1(C, D, A, B, X[ 6], 17, $A8304613);
P1(B, C, D, A, X[ 7], 22, $FD469501);
P1(A, B, C, D, X[ 8], 7, $698098D8);
P1(D, A, B, C, X[ 9], 12, $8B44F7AF);
P1(C, D, A, B, X[ 10], 17, $FFFF5BB1);
P1(B, C, D, A, X[ 11], 22, $895CD7BE);
P1(A, B, C, D, X[ 12], 7, $6B901122);
P1(D, A, B, C, X[ 13], 12, $FD987193);
P1(C, D, A, B, X[ 14], 17, $A679438E);
P1(B, C, D, A, X[ 15], 22, $49B40821);
P2(A, B, C, D, X[ 1], 5, $F61E2562);
P2(D, A, B, C, X[ 6], 9, $C040B340);
P2(C, D, A, B, X[ 11], 14, $265E5A51);
P2(B, C, D, A, X[ 0], 20, $E9B6C7AA);
P2(A, B, C, D, X[ 5], 5, $D62F105D);
P2(D, A, B, C, X[ 10], 9, $02441453);
P2(C, D, A, B, X[ 15], 14, $D8A1E681);
P2(B, C, D, A, X[ 4], 20, $E7D3FBC8);
P2(A, B, C, D, X[ 9], 5, $21E1CDE6);
P2(D, A, B, C, X[ 14], 9, $C33707D6);
P2(C, D, A, B, X[ 3], 14, $F4D50D87);
P2(B, C, D, A, X[ 8], 20, $455A14ED);
P2(A, B, C, D, X[ 13], 5, $A9E3E905);
P2(D, A, B, C, X[ 2], 9, $FCEFA3F8);
P2(C, D, A, B, X[ 7], 14, $676F02D9);
P2(B, C, D, A, X[ 12], 20, $8D2A4C8A);
P3(A, B, C, D, X[ 5], 4, $FFFA3942);
P3(D, A, B, C, X[ 8], 11, $8771F681);
P3(C, D, A, B, X[ 11], 16, $6D9D6122);
P3(B, C, D, A, X[ 14], 23, $FDE5380C);
P3(A, B, C, D, X[ 1], 4, $A4BEEA44);
P3(D, A, B, C, X[ 4], 11, $4BDECFA9);
P3(C, D, A, B, X[ 7], 16, $F6BB4B60);
P3(B, C, D, A, X[ 10], 23, $BEBFBC70);
P3(A, B, C, D, X[ 13], 4, $289B7EC6);
P3(D, A, B, C, X[ 0], 11, $EAA127FA);
P3(C, D, A, B, X[ 3], 16, $D4EF3085);
P3(B, C, D, A, X[ 6], 23, $04881D05);
P3(A, B, C, D, X[ 9], 4, $D9D4D039);
P3(D, A, B, C, X[ 12], 11, $E6DB99E5);
P3(C, D, A, B, X[ 15], 16, $1FA27CF8);
P3(B, C, D, A, X[ 2], 23, $C4AC5665);
P4(A, B, C, D, X[ 0], 6, $F4292244);
P4(D, A, B, C, X[ 7], 10, $432AFF97);
P4(C, D, A, B, X[ 14], 15, $AB9423A7);
P4(B, C, D, A, X[ 5], 21, $FC93A039);
P4(A, B, C, D, X[ 12], 6, $655B59C3);
P4(D, A, B, C, X[ 3], 10, $8F0CCC92);
P4(C, D, A, B, X[ 10], 15, $FFEFF47D);
P4(B, C, D, A, X[ 1], 21, $85845DD1);
P4(A, B, C, D, X[ 8], 6, $6FA87E4F);
P4(D, A, B, C, X[ 15], 10, $FE2CE6E0);
P4(C, D, A, B, X[ 6], 15, $A3014314);
P4(B, C, D, A, X[ 13], 21, $4E0811A1);
P4(A, B, C, D, X[ 4], 6, $F7537E82);
P4(D, A, B, C, X[ 11], 10, $BD3AF235);
P4(C, D, A, B, X[ 2], 15, $2AD7D2BB);
P4(B, C, D, A, X[ 9], 21, $EB86D391);
Inc(FState[0], A);
Inc(FState[1], B);
Inc(FState[2], C);
Inc(FState[3], D);
end;
procedure TMD5Context.Start;
begin
FTotal[0]:= 0;
FTotal[1]:= 0;
FState[0]:= $67452301;
FState[1]:= $EFCDAB89;
FState[2]:= $98BADCFE;
FState[3]:= $10325476;
end;
procedure TMD5Context.Update(ABuf: PByte; ACount: Cardinal);
var
left,
fill: Cardinal;
len: Cardinal;
input: PByte;
begin
len:= ACount;
input:= ABuf;
if len = 0 then
Exit;
left:= FTotal[0] and $3F;
fill:= 64 - left;
Inc(FTotal[0], len);
FTotal[0]:= FTotal[0] and $FFFFFFFF;
if FTotal[0] < len then
Inc(FTotal[1]);
if (left <> 0) and (len >= fill) then
begin
// memcpy((void *)(ctx->buffer + left), (const void *)input, fill);
Move(input^, FBuffer[left], fill);
Process(@FBuffer[0]);
Dec(len, fill);
Inc(input, fill);
left:= 0;
end;
while len >= 64 do
begin
Process(input);
Dec(len, 64);
Inc(input, 64);
end;
if len > 0 then
// memcpy((void *)(ctx->buffer + left), (const void *)input, length);
Move(input^, FBuffer[left], len);
end;
function ComputeTileMD5(AData: TTileRGBData; {AMask: TTileMaskData;}
var AMD5: TMD5): Boolean;
var
ctx: TMD5Context;
i: Integer;
// j,
// k: Integer;
// buf: array[0..191] of Byte;
// restricted: Boolean;
// readlen: Cardinal;
// len: Cardinal;
begin
FillChar(AMD5, SizeOf(TMD5), 0);
// restricted:= (len <> 0);
// if (not restricted) or (SizeOf(buf) <= len) then
// readlen:= SizeOf(buf)
// else
// readlen:= len;
ctx.Start;
// i:= readlen;
i:= SizeOf(TTileRGBData);
// while i > 0 do
// begin
// ctx.Update(@buf[0], i);
ctx.Update(@AData[0], i);
//i:= SizeOf(TTileMaskData);
//ctx.Update(@AMask[0], i);
// if restricted then
// begin
// Dec(len, i);
// if len = 0 then
// Break;
//
// if SizeOf(buf) > len then
// readlen:= len;
// end;
//
// i:= AStream.Read(buf, readlen);
// end;
ctx.Finish(AMD5);
Result:= True;
end;
function ComparePalette(var APalette: TPaletteMap; L, R: Integer): Integer;
begin
// descending
Result:= APalette[R].Count - APalette[L].Count;
end;
procedure ExchangePaletteProc(var APalette: TPaletteMap; L, R: Integer);
var
temp: TPaletteEntry;
begin
temp:= APalette[L];
APalette[L]:= APalette[R];
APalette[R]:= temp;
end;
procedure QuickSortPalette(var APalette: TPaletteMap; L, R: Integer);
var
Pivot,
vL,
vR: Integer;
begin
// a little bit of time saver
if R - L <= 1 then
begin
if L < R then
if ComparePalette(APalette, L, R) > 0 then
ExchangePaletteProc(APalette, L, R);
Exit;
end;
vL:= L;
vR:= R;
// they say random is best
Pivot:= L + Random(R - L);
while vL < vR do
begin
while (vL < Pivot) and (ComparePalette(APalette, vL, Pivot) <= 0) do
Inc(vL);
while (vR > Pivot) and (ComparePalette(APalette, vR, Pivot) > 0) do
Dec(vR);
ExchangePaletteProc(APalette, vL, vR);
// swap pivot if we just hit it from one side
if Pivot = vL then
Pivot := vR
else if Pivot = vR then
Pivot := vL;
end;
if Pivot - 1 >= L then
QuickSortPalette(APalette, L, Pivot - 1);
if Pivot + 1 <= R then
QuickSortPalette(APalette, Pivot + 1, R);
end;
procedure SortPaletteMap(var APalette: TPaletteMap);
begin
QuickSortPalette(APalette, 0, Length(APalette) - 1);
end;
end.
|
unit ClipB;
interface
uses Windows, Clipbrd;
type
TDBRecordOst = packed record
Vp : Char;
Cp : string[3];
Shifr : string[8];
KI : string[4];
Kol : string[11];
Kol2 : string[11];
Kol3 : string[11];
Norma : string[13];
kol_m:string[3];
kol_m2:string[3];
kol_m3:string[3];
Podrazd:Integer;
Znak:Char;
Eim:string[5];
Primech:string[50];
end;
TRowsOst = record
Num:Integer;
DBRecAr: array of TDBRecordOst;
end;
const
FormatNameOst = 'CF_MyFormatOst';
var
CF_MyFormatOst: Word;
procedure CopyToClipboardOst(Rows : TRowsOst);
implementation
procedure CopyToClipboardOst(Rows : TRowsOst);
var
h : THandle;
First : ^Byte;
iSize, RecSize, i : Integer;
begin
Rows.Num := Length(Rows.DBRecAr);
iSize := SizeOf(integer);
RecSize := SizeOf(TDBRecordOst);
h := GlobalAlloc(GMEM_MOVEABLE, iSize + RecSize*Rows.Num);
First := GlobalLock(h);
try
Move(Rows, First^, iSize);
First := pointer(LongWord(First) + iSize);
for i := 1 to Rows.Num do begin
Move(Rows.DBRecAr[i-1], First^, RecSize);
First := pointer(LongWord(First) + RecSize);
end;
Clipboard.SetAsHandle(CF_MyFormatOst, h);
finally
GlobalUnlock(h);
end;
end;
initialization
CF_MyFormatOst := RegisterClipboardFormat(FormatNameOst);
end.
|
unit KInfoRockSampleFrame;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ImgList, StdCtrls, Grids, ExtCtrls, ActnList, ToolWin,
CoreDescription, Slotting;
type
TfrmRockSample = class(TFrame)
GroupBox1: TGroupBox;
pnl: TPanel;
grdRockSamples: TStringGrid;
ckbx: TCheckBox;
tbr: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
actnLst: TActionList;
imgList: TImageList;
actnAdd: TAction;
actnDelete: TAction;
procedure writetext(acanvas: tcanvas; const arect: trect; dx, dy: integer; const text: string; format: word);
procedure AddCheckBoxes;
procedure CleanPreviusBuffer;
procedure SetCheckboxAlignment;
procedure grdRockSamplesSelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
procedure actnAddExecute(Sender: TObject);
procedure actnDeleteExecute(Sender: TObject);
procedure grdRockSamplesTopLeftChanged(Sender: TObject);
procedure grdRockSamplesSetEditText(Sender: TObject; ACol,
ARow: Integer; const Value: String);
procedure ckbxClick(Sender: TObject);
private
FRowIndex: integer;
FActiveRowIndex: integer;
FChangeMade: boolean;
FActiveLayer: TDescriptedLayer;
procedure ClearGrid; overload;
procedure ClearGrid (N: integer); overload;
public
//
property ChangeMade: boolean read FChangeMade write FChangeMade;
// индекс новой строки
property RowIndex: integer read FRowIndex write FRowIndex;
// индекс активной строки
property ActiveRowIndex: integer read FActiveRowIndex write FActiveRowIndex;
property ActiveLayer: TDescriptedLayer read FActiveLayer write FActiveLayer;
procedure MakeRecord(N: integer);
procedure Clear;
procedure Reload;
function Save: boolean;
function CheckInfoRockSamples: boolean;
function GetRockSampleText: string;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
implementation
uses facade, BaseObjects, TypeResearch, RockSample, LayerSlotting;
{$R *.dfm}
{ TfrmRockSample }
constructor TfrmRockSample.Create(AOwner: TComponent);
begin
inherited;
grdRockSamples.Cells[0, 0] := ' № долб. ';
grdRockSamples.Cells[1, 0] := ' от ... (м) ';
grdRockSamples.Cells[2, 0] := ' до ... (м) ';
grdRockSamples.Cells[3, 0] := ' В. к. ';
grdRockSamples.Cells[4, 0] := ' № обр. ';
grdRockSamples.Cells[5, 0] := ' от нач... (м) ';
FRowIndex := 1;
FActiveRowIndex := -1;
(TMainFacade.GetInstance as TMainFacade).TypeResearchs.MakeList(grdRockSamples);
(TMainFacade.GetInstance as TMainFacade).AllLayers.Reload;
end;
destructor TfrmRockSample.Destroy;
begin
inherited;
end;
procedure TfrmRockSample.Reload;
var j, iRow, k, iCol: integer;
begin
if grdRockSamples.RowCount > 2 then ClearGrid;
AddCheckBoxes;
iRow := 1;
for j := 0 to FActiveLayer.RockSamples.Count - 1 do
begin
// долбление
with FActiveLayer.Collection.Owner as TSlotting do
begin
grdRockSamples.Cells[0, iRow] := ' ' + Name;
grdRockSamples.Cells[1, iRow] := ' ' + FloatToStr(Top);
grdRockSamples.Cells[2, iRow] := ' ' + FloatToStr(Bottom);
grdRockSamples.Cells[3, iRow] := ' ' + FloatToStr(CoreYield);
end;
// образец
grdRockSamples.Cells[4, iRow] := FActiveLayer.RockSamples.Items[j].Name;
if FActiveLayer.RockSamples.Items[j].FromBegining > 0 then
grdRockSamples.Cells[5, iRow] := FloatToStr(FActiveLayer.RockSamples.Items[j].FromBegining)
else grdRockSamples.Cells[5, iRow] := 'н. к.';
// ассоциируем с объектом образца
grdRockSamples.Objects[0, iRow] := FActiveLayer.RockSamples.Items[j];
// типы исследований
for iCol := 6 to grdRockSamples.ColCount - 1 do
for k := 0 to FActiveLayer.RockSamples.Items[j].Researchs.Count - 1 do
if Assigned(FActiveLayer.RockSamples.Items[j].Researchs.GetItemByName(trim(grdRockSamples.Cols[iCol].Text))) then
begin
(grdRockSamples.Objects[iCol, iRow] as TCheckBox).Checked := true;
break;
end
else (grdRockSamples.Objects[iCol, iRow] as TCheckBox).Checked := false;
inc(iRow);
if (iRow <= FActiveLayer.RockSamples.Count) and (FActiveLayer.RockSamples.Count > 1) then actnAdd.Execute;
end;
if FActiveLayer.RockSamples.Count = 0 then MakeRecord(2);
grdRockSamples.FixedRows := 1;
end;
procedure TfrmRockSample.writetext(acanvas: tcanvas; const arect: trect;
dx, dy: integer; const text: string; format: word);
var s: array[0..255] of char;
begin
with acanvas, arect do
begin
case format of
dt_left: exttextout(handle, left + dx, top + dy, eto_opaque or eto_clipped,
@arect, strpcopy(s, text), length(text), nil);
dt_right: exttextout(handle, right - textwidth(text) - 3, top + dy,
eto_opaque or eto_clipped, @arect, strpcopy(s, text), length(text), nil);
dt_center: exttextout(handle, left + (right - left - textwidth(text)) div 2,
top + dy, eto_opaque or eto_clipped, @arect,
strpcopy(s, text), length(text), nil);
end;
end;
end;
procedure TfrmRockSample.AddCheckBoxes;
var i: Integer;
NewCheckBox: TCheckBox;
begin
CleanPreviusBuffer; // очищаем неиспользуемые чекбоксы...
for i := 6 to grdRockSamples.ColCount - 1 do
begin
NewCheckBox := TCheckBox.Create(Application);
NewCheckBox.Width := 0;
NewCheckBox.Visible := false;
NewCheckBox.Color := clWindow;
NewCheckBox.Tag := RowIndex;
NewCheckBox.OnClick := ckbx.OnClick; // Связываем предыдущее событие OnClick
// с существующим TCheckBox
NewCheckBox.Parent := pnl;
grdRockSamples.Objects[i, RowIndex] := NewCheckBox;
end;
SetCheckboxAlignment; // расположение чекбоксов в ячейках таблицы...
end;
procedure TfrmRockSample.CleanPreviusBuffer;
var NewCheckBox: TCheckBox;
i: Integer;
begin
for i := 6 to grdRockSamples.ColCount - 1 do
begin
NewCheckBox := grdRockSamples.Objects[i, FRowIndex] as TCheckBox;
if NewCheckBox <> nil then
begin
NewCheckBox.Visible := false;
grdRockSamples.Objects[i, FRowIndex] := nil;
end;
end;
end;
procedure TfrmRockSample.SetCheckboxAlignment;
var NewCheckBox: TCheckBox;
Rect: TRect;
i: Integer;
begin
for i := 6 to grdRockSamples.ColCount - 1 do
begin
NewCheckBox := grdRockSamples.Objects[i, RowIndex] as TCheckBox;
if NewCheckBox <> nil then
begin
Rect := grdRockSamples.CellRect(i, RowIndex); // получаем размер ячейки для чекбокса
NewCheckBox.Left := grdRockSamples.Left + Rect.Left + (grdRockSamples.ColWidths[i] div 2) - 5;
NewCheckBox.Top := grdRockSamples.Top + Rect.Top + 2;
NewCheckBox.Width := 12;
NewCheckBox.Height := Rect.Bottom - Rect.Top;
NewCheckBox.Visible := True;
end;
end;
end;
procedure TfrmRockSample.grdRockSamplesSelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
if ((grdRockSamples.ColCount - (TMainFacade.GetInstance as TMainFacade).TypeResearchs.Count) <= ACol) or (ACol <= 3) then
grdRockSamples.Options := grdRockSamples.Options - [goEditing, goAlwaysShowEditor]
else grdRockSamples.Options := grdRockSamples.Options + [goEditing, goAlwaysShowEditor];
FActiveRowIndex := ARow;
end;
procedure TfrmRockSample.actnAddExecute(Sender: TObject);
begin
FRowIndex := grdRockSamples.RowCount;
FActiveRowIndex := grdRockSamples.RowCount;
grdRockSamples.RowCount := grdRockSamples.RowCount + 1;
AddCheckBoxes;
MakeRecord(grdRockSamples.RowCount);
end;
procedure TfrmRockSample.actnDeleteExecute(Sender: TObject);
var deleting: boolean;
begin
deleting := false;
if Assigned(grdRockSamples.Objects[0, ActiveRowIndex]) then
MessageBox(0, 'Удаление образцов запрещено.', 'Предупреждение', MB_APPLMODAL + MB_OK + MB_ICONWARNING)
else deleting := true;
if deleting then
begin
ClearGrid(ActiveRowIndex);
dec(FActiveRowIndex);
end;
end;
function TfrmRockSample.Save: boolean;
var i, j: integer;
t: Double;
r: TRockSample;
o: TRockSampleResearch;
begin
Result := false;
for j := 1 to grdRockSamples.RowCount - 1 do // все строки
begin
// если окажется, что нет такого образца, то создаем новый экземпляр
if not Assigned(grdRockSamples.Objects[0, j]) then
r := TRockSample.Create(FActiveLayer.RockSamples)
else r := FActiveLayer.RockSamples.ItemsByID[(grdRockSamples.Objects[0, j] as TRockSample).ID] as TRockSample;
// номер образца
r.Name := trim(grdRockSamples.Cells[4, j]);
// ... от начала
if TryStrToFloat(trim(grdRockSamples.Cells[5, j]), t) then
r.FromBegining := StrToFloat(trim(grdRockSamples.Cells[5, j]))
else r.FromBegining := -2;
// типы исследований
r.Researchs.Clear;
for i := 6 to grdRockSamples.ColCount - 1 do // столбцы пока только с исследованиями
if (grdRockSamples.Objects[i, j] as TCheckBox).Checked then
begin
o := TRockSampleResearch.Create(r.Researchs);
o.Assign((TMainFacade.GetInstance as TMainFacade).TypeResearchs.GetItemByName(trim(grdRockSamples.Cells[i, 0])) as TTypeResearch);
o.Research := true;
r.Researchs.Add(o);
end;
if r.ID = 0 then FActiveLayer.RockSamples.Add(r);
Result := true;
end;
end;
procedure TfrmRockSample.ClearGrid;
var i : integer;
NewCheckBox: TCheckBox;
begin
for i := grdRockSamples.RowCount downto 2 do
ClearGrid(i);
// почистить первую строку
for i := 6 to grdRockSamples.ColCount - 1 do
begin
NewCheckBox := grdRockSamples.Objects[i, 1] as TCheckBox;
if Assigned(NewCheckBox) then
(grdRockSamples.Objects[i, 1] as TCheckBox).Checked := false;
end;
end;
procedure TfrmRockSample.ClearGrid(N: integer);
var i: Integer;
NewCheckBox: TCheckBox;
begin
with grdRockSamples do
if (N > 0) and (N < RowCount) then
begin
for i := N to RowCount - 2 do
Rows[i].Assign(Rows[i + 1]);
RowCount := RowCount - 1;
// удалить чекбоксы
for i := 6 to grdRockSamples.ColCount - 1 do
begin
NewCheckBox := grdRockSamples.Objects[i, RowCount] as TCheckBox;
if NewCheckBox <> nil then
begin
NewCheckBox.Visible := false;
grdRockSamples.Objects[i, RowCount] := nil;
end;
end;
end;
end;
function TfrmRockSample.GetRockSampleText: string;
var i, j: integer;
begin
Result := #10 + #9;
for i := 0 to ActiveLayer.RockSamples.Count - 1 do
if ActiveLayer.RockSamples.Items[i].Researchs.Count > 0 then
if ActiveLayer.RockSamples.Items[i].Changing then
begin
if ActiveLayer.RockSamples.Items[i].FromBegining > 0 then
Result := Result + 'Обр. ' + ActiveLayer.Collection.Owner.Name + '/' + ActiveLayer.RockSamples.Items[i].Name + ' (' +
FloatToStr(ActiveLayer.RockSamples.Items[i].FromBegining) + ' м н.к.) ' + #8211 + ' '
else Result := Result + 'Обр. ' + ActiveLayer.Collection.Owner.Name + '/' + ActiveLayer.RockSamples.Items[i].Name + ' (н.к.) ' + #8211 + ' ';
for j := 0 to ActiveLayer.RockSamples.Items[i].Researchs.Count - 1 do
if j < ActiveLayer.RockSamples.Items[i].Researchs.Count - 1 then
Result := Result + AnsiLowerCase(ActiveLayer.RockSamples.Items[i].Researchs.Items[j].Name) + ', '
else Result := Result + AnsiLowerCase(ActiveLayer.RockSamples.Items[i].Researchs.Items[j].Name);
ActiveLayer.RockSamples.Items[i].Changing := false;
Result := Result + #10 + #9;
end;
end;
procedure TfrmRockSample.Clear;
begin
ClearGrid;
FChangeMade := false;
end;
procedure TfrmRockSample.MakeRecord(N: integer);
begin
grdRockSamples.Cells[0, N - 1] := ' ' + FActiveLayer.Collection.Owner.Name;
grdRockSamples.Cells[1, N - 1] := ' ' + FloatToStr((FActiveLayer.Collection.Owner as TSlotting).Top);
grdRockSamples.Cells[2, N - 1] := ' ' + FloatToStr((FActiveLayer.Collection.Owner as TSlotting).Bottom);
grdRockSamples.Cells[3, N - 1] := ' ' + FloatToStr((FActiveLayer.Collection.Owner as TSlotting).CoreYield);
grdRockSamples.Cells[4, N - 1] := '';
grdRockSamples.Cells[5, N - 1] := '';
end;
procedure TfrmRockSample.grdRockSamplesTopLeftChanged(Sender: TObject);
var R: TRect;
i, j: integer;
begin
with grdRockSamples do
for j := 6 to ColCount - 1 do
for i := 0 to RowCount - 1 do
begin
R := grdRockSamples.CellRect(j, i);
if grdRockSamples.Objects[j, i] is TControl then
with TControl(grdRockSamples.Objects[j, i]) do
begin
if R.Right = R.Left then {прямоугольник ячейки невидим}
Visible := False
else
begin
InflateRect(R, 0, 0);
OffsetRect (R, grdRockSamples.Left + (grdRockSamples.ColWidths[j] div 2) - 5, grdRockSamples.Top + 2);
BoundsRect := R;
Visible := True;
end;
end;
end;
end;
function TfrmRockSample.CheckInfoRockSamples: boolean;
begin
Result := false;
end;
procedure TfrmRockSample.grdRockSamplesSetEditText(Sender: TObject; ACol,
ARow: Integer; const Value: String);
var i: integer;
ErrorTrue: boolean;
begin
// проверка ошибок
FChangeMade := true;
if Assigned (grdRockSamples.Objects[0, ARow]) then
begin
(grdRockSamples.Objects[0, ARow] as TRockSample).Changing := true;
if grdRockSamples.RowCount <> 1 then
begin
ErrorTrue := false;
case ACol of
5: begin // выход керна >= значению от начала керна
if (trim(grdRockSamples.Cells[ACol, ARow]) <> '') and
(trim(grdRockSamples.Cells[ACol, ARow]) <> 'н. к.') then
try
if StrToFloat(grdRockSamples.Cells[ACol, ARow]) > StrToFloat(trim(grdRockSamples.Cells[3, ARow]))then
begin
MessageBox(0, 'Значение "от начала керна" не может превышать "выход керна".', 'Ошибка', MB_APPLMODAL + MB_ICONERROR + MB_OK);
ErrorTrue := true;
end;
except
MessageBox(0, 'Введено значение некорректного формата.', 'Ошибка', MB_APPLMODAL + MB_ICONERROR + MB_OK);
ErrorTrue := true;
end;
if ErrorTrue then
if Assigned (grdRockSamples.Objects[0, ARow]) then
if (grdRockSamples.Objects[0, ARow] as TRockSample).FromBegining > 0 then
grdRockSamples.Cells[ACol, ARow] := FloatToStr((grdRockSamples.Objects[0, ARow] as TRockSample).FromBegining)
else grdRockSamples.Cells[ACol, ARow] := 'н. к.';
end;
4: begin // проверить чтобы № образцов не повторялись
for i := 1 to grdRockSamples.RowCount - 1 do
if (grdRockSamples.Cells[ACol, ARow] = grdRockSamples.Cells[ACol, i]) and (i <> ARow) then
begin
MessageBox(0, 'Образец с таким номером уже существует.', 'Ошибка', MB_APPLMODAL + MB_ICONERROR + MB_OK);
if Assigned (grdRockSamples.Objects[0, ARow]) then
grdRockSamples.Cells[ACol, ARow] := (grdRockSamples.Objects[0, ARow] as TRockSample).Name
else grdRockSamples.Cells[ACol, ARow] := '';
end;
end;
end;
end;
end;
end;
procedure TfrmRockSample.ckbxClick(Sender: TObject);
begin
ChangeMade := true;
if (Sender as TCheckBox).Tag > -1 then
if Assigned (grdRockSamples.Objects[0, (Sender as TCheckBox).Tag]) then
(grdRockSamples.Objects[0, (Sender as TCheckBox).Tag] as TRockSample).Changing := true;
end;
end.
|
PROGRAM PrintPattern(INPUT, OUTPUT);
BEGIN {PrintPattern}
WRITE(' *');
WRITELN;
WRITELN(' * *');
WRITELN('* *');
WRITE(' * *');
WRITELN;
WRITELN(' *')
END. {PrintPattern}
|
(**
* $Id: dco.rpc.ErrorObject.pas 840 2014-05-24 06:04:58Z QXu $
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for the specific language governing rights and limitations under the License.
*)
unit dco.rpc.ErrorObject;
interface
uses
System.SysUtils,
superobject { An universal object serialization framework with Json support };
type
/// <summary>This immutable value class represents a RPC error.</summary>
TErrorObject = record
private
FCode: Integer;
FMessage_: string;
FData: ISuperObject;
public
property Code: Integer read FCode;
property Message_: string read FMessage_;
property Data: ISuperObject read FData;
public
function ToString: string;
class function Create(Code: Integer; const Message_: string; const Data: ISuperObject): TErrorObject; static;
class function CreateParseError(const Detail: string): TErrorObject; static;
class function CreateInvalidRequest(const Detail: string): TErrorObject; static;
class function CreateMethodNotFound(const Detail: string): TErrorObject; static;
class function CreateInvalidParams(const Detail: string): TErrorObject; static;
class function CreateInternalError(const Detail: string): TErrorObject; static;
class function CreateInvalidResult(const Detail: string): TErrorObject; static; deprecated 'non-standard error';
class function CreateNoResponseReceived(const Detail: string): TErrorObject; static;
end;
implementation
uses
dutil.text.Util;
class function TErrorObject.Create(Code: Integer; const Message_: string; const Data: ISuperObject): TErrorObject;
begin
Result.FCode := Code;
Result.FMessage_ := Message_;
Result.FData := Data;
end;
function TErrorObject.ToString: string;
var
Detail: string;
begin
Detail := '';
if FData <> nil then
Detail := TUtil.Strip(FData.AsJson, '"');
if Detail = '' then
Result := Format('%s (%d)', [FMessage_, FCode])
else
Result := Format('%s (%d): %s', [FMessage_, FCode, Detail]);
end;
class function TErrorObject.CreateParseError(const Detail: string): TErrorObject;
begin
Result := TErrorObject.Create(-32700, 'Parse error', SO(Detail));
end;
class function TErrorObject.CreateInvalidRequest(const Detail: string): TErrorObject;
begin
Result := TErrorObject.Create(-32600, 'Invalid request', SO(Detail));
end;
class function TErrorObject.CreateMethodNotFound(const Detail: string): TErrorObject;
begin
Result := TErrorObject.Create(-32601, 'Method not found', SO(Detail));
end;
class function TErrorObject.CreateInvalidParams(const Detail: string): TErrorObject;
begin
Result := TErrorObject.Create(-32602, 'Invalid params', SO(Detail));
end;
class function TErrorObject.CreateInternalError(const Detail: string): TErrorObject;
begin
Result := TErrorObject.Create(-32603, 'Internal error', SO(Detail));
end;
class function TErrorObject.CreateInvalidResult(const Detail: string): TErrorObject;
begin
Result := TErrorObject.Create(-2, 'Invalid result', SO(Detail));
end;
class function TErrorObject.CreateNoResponseReceived(const Detail: string): TErrorObject;
begin
Result := TErrorObject.Create(-1, 'No response received', SO(Detail));
end;
end.
|
unit Model.ProdutosVA;
interface
type
TProdutosVA = class
private
var
FID: Integer;
FCodigo: String;
FDescricao: String;
FPadrao: Integer;
FDiario: SmallInt;
FCobranca: Double;
FVenda: Double;
FBarras: String;
FLog: String;
public
property ID: Integer read FID write FID;
property Codigo: String read FCodigo write FCodigo;
property Descricao: String read FDescricao write FDescricao;
property Padrao: Integer read FPadrao write FPadrao;
property Diario: SmallInt read FDiario write FDiario;
property Cobranca: Double read FCobranca write FCobranca;
property Venda: Double read FVenda write FVenda;
property Barras: String read FBarras write FBarras;
property Log: String read FLog write FLog;
constructor Create; overload;
constructor Create(pFID: Integer; pFCodigo: String; pFDescricao: String; pFPadrao: Integer; pFDiario: SmallInt;
pFCobranca: Double; pFVenda: Double; pFBarras: String; pFLog: String); overload;
end;
implementation
constructor TProdutosVA.Create;
begin
inherited Create;
end;
constructor TProdutosVA.Create(pFID: Integer; pFCodigo: String; pFDescricao: String; pFPadrao: Integer; pFDiario: SmallInt;
pFCobranca: Double; pFVenda: Double; pFBarras: String; pFLog: String);
begin
FID := pFID;
FCodigo := pFCodigo;
FDescricao := pFDescricao;
FPadrao := pFPadrao;
FDiario := pFDiario;
FCobranca := pFCobranca;
FVenda:= pFVenda;
FBarras := pFBarras;
FLog := pFLog;
end;
end.
|
{
Create outfits from ARMO records and LVLI lists (containing armors)
in NPCs inventories.
}
unit UserScript;
var
baserecord: IInterface;
slOutfit: TStringList;
//============================================================================
function Initialize: integer;
begin
// template record for new outfits
// DefaultSleepOutfit [OTFT:0001697D]
baserecord := RecordByFormID(FileByIndex(0), $0001697D, True);
if not Assigned(baserecord) then begin
AddMessage('Can not find base record');
Result := 1;
Exit;
end;
slOutfit := TStringList.Create;
end;
//============================================================================
function Process(e: IInterface): integer;
var
items, item, rec, outfit: IInterface;
i: integer;
IsArmor: boolean;
s: string;
begin
// process only NPC_ records
if Signature(e) <> 'NPC_' then
Exit;
// no inventory - nothing to do
items := ElementByName(e, 'Items');
if not Assigned(items) then
Exit;
// gather all armor items from inventory into a list and remove them from inventory
for i := ElementCount(items) - 1 downto 0 do begin
item := ElementByIndex(items, i);
rec := LinksTo(ElementByPath(item, 'CNTO\Item'));
IsArmor := False;
// check if inventory item is ARMO or LVLI with armors (EditorID check)
if Signature(rec) = 'ARMO' then IsArmor := True else
if Signature(rec) = 'LVLI' then begin
s := LowerCase(GetElementEditValues(rec, 'EDID'));
if (Pos('armor', s) > 0) or (Pos('shield', s) > 0) or (Pos('amulet', s) > 0) or
(Pos('ring', s) > 0) or (Pos('cloth', s) > 0) then
IsArmor := True;
end;
// is armor - add to list and remove from inventory
if IsArmor then begin
slOutfit.Add(Name(rec));
RemoveElement(items, i);
end;
end;
// create outfit if list is not empty
if slOutfit.Count > 0 then begin
// first update COCT count of inventory items or remove if none left
if ElementCount(items) > 0 then
SetElementNativeValues(e, 'COCT', ElementCount(items))
else begin
RemoveElement(e, 'Items');
RemoveElement(e, 'COCT');
end;
// grab existing outfit or make a new one using template
outfit := LinksTo(ElementByPath(e, 'DOFT'));
if not Assigned(outfit) then
outfit := wbCopyElementToFile(baserecord, GetFile(e), True, True);
if not Assigned(outfit) then begin
AddMessage('Can''t copy base record as new');
Result := 1;
Exit;
end;
// set new EditorID
SetElementEditValues(outfit, 'EDID', GetElementEditValues(e, 'EDID') + 'Outfit');
// clear items from template
items := ElementByPath(outfit, 'INAM');
while ElementCount(items) > 0 do RemoveElement(items, 0);
// assign new items from list
for i := 0 to slOutfit.Count - 1 do begin
item := ElementAssign(items, HighInteger, nil, False);
SetEditValue(item, slOutfit[i]);
end;
// clear list
slOutfit.Clear;
// give NPC outfit
SetElementNativeValues(e, 'DOFT', FormID(outfit));
end;
end;
//============================================================================
function Finalize: integer;
begin
slOutfit.Free;
end;
end.
|
{
This file is part of the SimpleBOT package.
(c) Luri Darmawan <luri@fastplaz.com>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
}
unit resiibacor_integration;
{$mode objfpc}{$H+}
{
JNE , TIKI , POS , PANDU , JNT , SICEPAT dan WAHANA
[x] USAGE
with TResiIbacorController.Create do
begin
Token := 'YourIbacorToken';
Vendor := 'JNE';
AirwayBill := 'yourairwaybillnumber;
Result := Find();
Free;
end;
}
interface
uses
http_lib, json_lib, fpjson,
Classes, SysUtils;
type
{ TResiIbacorController }
TResiIbacorController = class
private
FCode: string;
FToken: string;
FVendor: string;
procedure setAirwayBill(AValue: string);
public
constructor Create;
destructor Destroy;
property Token: string read FToken write FToken;
property Vendor: string read FVendor write FVendor;
property Code: string read FCode write FCode;
property AirwayBill: string write setAirwayBill;
function Find(): string;
function Find(VendorName, CodeName: string): string;
end;
implementation
const
_RESI_IBACOR_API = 'http://ibacor.com/api/cek-resi?k=%s&pengirim=%s&resi=%s';
var
Response: IHTTPResponse;
{ TResiIbacorController }
procedure TResiIbacorController.setAirwayBill(AValue: string);
begin
FCode := AValue;
end;
constructor TResiIbacorController.Create;
begin
end;
destructor TResiIbacorController.Destroy;
begin
end;
function TResiIbacorController.Find: string;
begin
Result := Find(FVendor, FCode);
end;
function TResiIbacorController.Find(VendorName, CodeName: string): string;
var
s, urlTarget: string;
httpClient: THTTPLib;
json: TJSONUtil;
begin
Result := '';
if FToken = '' then
Exit;
FVendor := UpperCase(FVendor);
urlTarget := Format(_RESI_IBACOR_API, [FToken, FVendor, FCode]);
httpClient := THTTPLib.Create;
httpClient.URL := urlTarget;
Response := httpClient.Get;
httpClient.Free;
json := TJSONUtil.Create;
try
json.LoadFromJsonString(Response.ResultText);
s := json['status'];
if s = 'success' then
begin
Result := 'Pengiriman :';
Result := Result + '\nStatus: ' + json['data/detail/status'];
Result := Result + '\nService: ' + json['data/detail/service'];
Result := Result + '\nTanggal: ' + json['data/detail/tanggal'];
Result := Result + '\nPengirim: ' + json['data/detail/asal/nama'] + ' (' +
json['data/detail/asal/alamat'] + ')';
Result := Result + '\nTujuan: ' + json['data/detail/tujuan/nama'] +
' (' + json['data/detail/tujuan/alamat'] + ')';
end;
except
Result := '';
end;
json.Free;
end;
end.
|
unit andante;
(***< Implements the Andante core system. This include:@unorderedlist(
@item(Configuration.)
@item(Initialization.)
@item(Error handling.)
)
@bold(See also:) @link(getst Getting started) *)
(* See LICENSE.txt for copyright information. *)
interface
uses
anBitmap;
(*
* Identification.
************************************************************************)
const
(*** Andante version string. *)
anVersionString: String = '1.a.0';
(*** Creates an identifier from a string. *)
function anId (const aName: String): LongWord; inline;
(*
* Error handling.
************************************************************************)
const
(* Core error codes. *)
anNoError = 0;
anNoMemoryError = -1;
anCantInitialize = -2;
anDuplicatedDriver = -3;
anGfxModeNotFound = -4;
anNotImplemented = -9999;
var
(*** Last error state. *)
anError: Integer = anNoError;
(*
* Core initialization/finalization.
************************************************************************)
type
andanteExitProc = procedure;
function anAddExitProc (aProc: andanteExitProc): Boolean;
procedure anRemoveExitProc (aProc: andanteExitProc);
function anInstall: Boolean;
procedure anUninstall;
(*
* Graphics mode.
************************************************************************)
const
(* Graphics modes. *)
anGfxText = $54455854; { anId ('TEXT') }
var
(*** Reference to the screen bitmap. *)
anScreen: andanteBitmapPtr = Nil;
(*** Initializes graphics mode. *)
function anSetGraphicsMode (const aName: LongWord): Boolean;
(*
* Timer.
************************************************************************)
const
(*** Default timer frequency, in ticks per second. *)
anTimerFrequency = 50;
var
(*** Timer counter. *)
anTimerCounter: LongWord;
(*
* Keyboard
************************************************************************)
{$INCLUDE ankeys.inc}
var
anKeyState: array [anKeyEscape..anKeyF12] of ByteBool;
function anInstallKeyboard: Boolean;
procedure anUninstallKeyboard;
procedure anClearKeyboard;
(*
* Internal stuff.
************************************************************************)
{ Everything below this is for internal use only. You don't need it for
your games. Do not use it unless you really know what are you doing
OR BAD THINGS MAY HAPPEN!!!
}
type
(*** @exclude *)
_ANDANTE_GFX_INIT_FUNCTION_ = function: andanteBitmapPtr;
(*** @exclude
Registers a new graphics mode.
Parameters:
- aName: An unique identifier. Use one of the anGfx* constants or create
your own.
- aInitializationFn: Pointer to a function that should:
+ Initialize the graphics mode.
+ Create a bitmap that allows to access to the graphics output.
Returns:
A pointer to the bitmap that represents the graphics context or Nil if
something was wrong (use anError to tell what).
*)
function _anRegisterGfxDriver (
const aName: LongWord;
aInitializationFn: _ANDANTE_GFX_INIT_FUNCTION_
): Boolean;
implementation
(* Includes the "platform specific" uses list. *)
{$INCLUDE sysunits.inc}
(*
* Internal stuff.
************************************************************************)
type
TGfxDriverPtr = ^TGfxDriver;
TGfxDriver = record
Name: LongWord;
Initialize: _ANDANTE_GFX_INIT_FUNCTION_;
Next: TGfxDriverPtr
end;
var
GfxDriverList: TGfxDriverPtr = Nil;
(* Finds a graphics driver. *)
function FindGfxDriver (const aName: LongWord): TGfxDriverPtr;
begin
FindGfxDriver := GfxDriverList;
while FindGfxDriver <> Nil do
if FindGfxDriver^.Name = aName then
Exit
else
FindGfxDriver := FindGfxDriver^.Next
end;
(* Registers a new graphics mode. *)
function _anRegisterGfxDriver (
const aName: LongWord;
aInitializationFn: _ANDANTE_GFX_INIT_FUNCTION_
): Boolean;
var
lNewDriver: TGfxDriverPtr;
begin
{ Check if it is in the list. }
if FindGfxDriver (aName) <> Nil then
begin
anError := anDuplicatedDriver;
Exit (False)
end;
{ Add to the list. }
GetMem (lNewDriver, SizeOf (TGfxDriver));
if lNewDriver = Nil then
begin
anError := anNoMemoryError;
Exit (False)
end;
lNewDriver^.Name := aName;
lNewDriver^.Initialize := aInitializationFn;
lNewDriver^.Next := GfxDriverList;
GfxDriverList := lNewDriver;
{ Everything is Ok. }
_anRegisterGfxDriver := True
end;
(* Removes all drivers. *)
procedure _anDestroyGfxDrivers;
var
lDriver: TGfxDriverPtr;
begin
while Assigned (GfxDriverList) do
begin
lDriver := GfxDriverList^.Next;
FreeMem (GfxDriverList);
GfxDriverList := lDriver
end
end;
(*
* Platform dependent stuff.
************************************************************************)
{ This section includes all the "platform dependent" stuff.
Each sub-system first declares the stuff that should be implemented, then
includes the "inc" file that implements it.
}
(* System initialization. *)
function _InitSystem: Boolean; forward;
(* System finalization. *)
procedure _CloseSystem; forward;
(* Closes any text mode and sets a text mode (if available). *)
procedure _CloseGfxMode; forward;
{$INCLUDE system.inc}
(* Installs timer handler. *)
function _InstallTimer: Boolean; forward;
(* Uninstalls timer handler, restoring the default one if needed. *)
procedure _UninstallTimer; forward;
{$INCLUDE timer.inc}
(* Installs the keyboard handler. *)
function _InstallKbd: Boolean; forward;
(* Uninstalls the keyboard handler, restoring the default one if needed. *)
procedure _UninstallKbd; forward;
{$INCLUDE keybrd.inc}
(*
* Identification.
************************************************************************)
(* Builds an id. *)
function anId (const aName: String): LongWord;
begin
anId := (Ord (aName[1]) shl 24) or (Ord (aName[2]) shl 16)
or (Ord (aName[3]) shl 8) or Ord (aName[4])
end;
(*
* Core initialization/finalization.
************************************************************************)
type
TExitProcPtr = ^TExitProc;
TExitProc = record
Proc: andanteExitProc;
Next: TExitProcPtr
end;
var
(* Tells if system was initialized. *)
Initialized: Boolean = False;
(* List of exit procedures. *)
ExitProcList: TExitProcPtr = Nil;
(* Adds new exit procedure. *)
function anAddExitProc (aProc: andanteExitProc): Boolean;
var
lNewExitProc: TExitProcPtr;
begin
{ Check if it is in the list. }
lNewExitProc := ExitProcList;
while Assigned (lNewExitProc) do
begin
if lNewExitProc^.Proc = aProc then Exit (true);
lNewExitProc := lNewExitProc^.Next
end;
{ Add to the list. }
GetMem (lNewExitProc, SizeOf (TExitProc));
if lNewExitProc = Nil then
begin
anError := anNoMemoryError;
Exit (False)
end;
lNewExitProc^.Proc := aProc;
lNewExitProc^.Next := ExitProcList;
ExitProcList := lNewExitProc;
{ Everything is Ok. }
anAddExitProc := True
end;
(* Removes the exit procedure. *)
procedure anRemoveExitProc (aProc: andanteExitProc);
var
lCurrent, lPrevious: TExitProcPtr;
begin
{ This is a copy of Allegro's _al_remove_exit_func. }
lPrevious := Nil;
lCurrent := ExitProcList;
while Assigned (lCurrent) do
begin
if lCurrent^.Proc = aProc then
begin
if Assigned (lPrevious) Then
lPrevious^.Next := lCurrent^.Next
else
ExitProcList := lCurrent^.Next;
FreeMem (lCurrent);
Exit
end;
lPrevious := lCurrent;
lCurrent := lCurrent^.Next
end
end;
function anInstall: Boolean;
begin
if Initialized then Exit (True);
{ Reset globals. }
anError := anNoError;
{ Initialize target specific stuff. }
if not _InitSystem then Exit (False);
if not _InstallTimer then Exit (False);
{ Everything is Ok. }
Initialized := True;
anInstall := True
end;
procedure anUninstall;
procedure CallExitProcedures;
var
lExitProc, lNextProc: TExitProcPtr;
begin
lExitProc := ExitProcList;
repeat
lNextProc := lExitProc^.Next;
lExitProc^.Proc ();
anRemoveExitProc (lExitProc^.Proc);
lExitProc := lNextProc
until lExitProc = Nil;
ExitProcList := Nil
end;
begin
if Initialized then
begin
if Assigned (ExitProcList) then CallExitProcedures;
{ Shut down graphics subsystem. }
if Assigned (anScreen) then
begin
anDestroyBitmap (anScreen);
anScreen := Nil;
_CloseGfxMode
end;
_anDestroyGfxDrivers;
{ Closes target specific stuff. }
_UninstallTimer;
_CloseSystem;
{ Andante finalized. }
anError := anNoError;
Initialized := False
end
end;
(*
* Graphics mode.
************************************************************************)
(* Inits graphics mode. *)
function anSetGraphicsMode (const aName: LongWord): Boolean;
var
lGfxDriver: TGfxDriverPtr;
begin
{ Text mode is a bit special. }
if aName = anGfxText then
begin
if Assigned (anScreen) then
begin
anDestroyBitmap (anScreen);
anScreen := Nil;
_CloseGfxMode
end
end
else begin
{ Find requested graphics mode. }
lGfxDriver := FindGfxDriver (aName);
if not Assigned (lGfxDriver) then
begin
anError := anGfxModeNotFound;
Exit (False)
end;
{ Destroy old screen bitmap (this may close current graphics mode). }
anDestroyBitmap (anScreen); anScreen := Nil;
{ Open new graphics mode and get new screen bitmap. }
anScreen := lGfxDriver^.Initialize ();
if not Assigned (anScreen) then Exit (False)
end;
{ Everything is Ok. }
anSetGraphicsMode := True
end;
(*
* Keyboard
************************************************************************)
(* Install keyboard. *)
function anInstallKeyboard: Boolean;
begin
if not _InstallKbd then Exit (False);
if not anAddExitProc (@anUninstallKeyboard) then
begin
anError := anNoMemoryError;
_UninstallKbd;
Exit (False)
end;
anClearKeyboard;
anInstallKeyboard := True
end;
(* Removes keyboard. *)
procedure anUninstallKeyboard;
begin
_UninstallKbd;
anRemoveExitProc (@anUninstallKeyboard)
end;
(* Clears keyboard state. *)
procedure anClearKeyboard;
var
lKey: Integer;
begin
for lKey := Low (anKeyState) to High (anKeyState) do
anKeyState[lKey] := False
end;
initialization
; { Do none, but some compilers need it. }
finalization
anUninstall
end.
|
// GLSoundFileFormat
{: Revolution<p>
Support classes for loading various fileformats.<p>
These classes work together like vector file formats or Delphi's TGraphic classes.<p>
<b>Historique : </b><font size=-1><ul>
<li>16/07/00 - Egg - Made use of new TDataFile class
<li>09/06/00 - Egg - Added WAVDataSize
<li>04/06/00 - Egg - Creation
</ul></font>
}
unit GLSoundFileObjects;
interface
uses Classes, MMSystem, GLMisc;
type
// TGLSoundSampling
//
{: Defines a sound sampling quality. }
TGLSoundSampling = class (TPersistent)
private
{ Private Declarations }
FOwner : TPersistent;
FFrequency : Integer;
FNbChannels : Integer;
FBitsPerSample : Integer;
protected
{ Protected Declarations }
function GetOwner : TPersistent; override;
public
{ Public Declarations }
constructor Create(AOwner: TPersistent);
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
function BytesPerSec : Integer;
function BytesPerSample : Integer;
function WaveFormat : TWaveFormatEx;
published
{ Published Declarations }
{: Sampling frequency in Hz (= samples per sec) }
property Frequency : Integer read FFrequency write FFrequency default 22050;
{: Nb of sampling channels.<p>
1 = mono, 2 = stereo, etc. }
property NbChannels : Integer read FNbChannels write FNbChannels default 1;
{: Nb of bits per sample.<p>
Common values are 8 and 16 bits. }
property BitsPerSample : Integer read FBitsPerSample write FBitsPerSample default 8;
end;
// TGLSoundFile
//
{: Abstract base class for different Sound file formats.<p>
The actual implementation for these files (WAV, RAW...) must be done
seperately. The concept for TGLSoundFile is very similar to TGraphic
(see Delphi Help).<p>
Default implementation for LoadFromFile/SaveToFile are to directly call the
relevent stream-based methods, ie. you will just have to override the stream
methods in most cases. }
TGLSoundFile = class (TDataFile)
private
{ Private Declarations }
FSampling : TGLSoundSampling;
protected
{ Protected Declarations }
procedure SetSampling(const val : TGLSoundSampling);
public
{ Public Declarations }
constructor Create(AOwner: TPersistent);
destructor Destroy; override;
procedure PlayOnWaveOut; dynamic;
{: Returns a pointer to the sample data viewed as an in-memory WAV File. }
function WAVData : Pointer; virtual; abstract;
{: Returns the size (in bytes) of the WAVData. }
function WAVDataSize : Integer; virtual; abstract;
{: Returns a pointer to the sample data viewed as an in-memory PCM buffer. }
function PCMData : Pointer; virtual; abstract;
{: Length of PCM data, in bytes. }
function LengthInBytes : Integer; virtual; abstract;
{: Nb of intensity samples in the sample. }
function LengthInSamples : Integer;
{: Length of play of the sample at nominal speed in seconds. }
function LengthInSec : Single;
property Sampling : TGLSoundSampling read FSampling write SetSampling;
end;
TGLSoundFileClass = class of TGLSoundFile;
// TGLWAVFile
//
{: Support for Windows WAV format. }
TGLWAVFile = class (TGLSoundFile)
private
{ Public Declarations }
waveFormat : TWaveFormatEx;
pcmOffset : Integer;
data : String; // used to store WAVE bitstream
protected
{ Protected Declarations }
public
{ Private Declarations }
function CreateCopy(AOwner: TPersistent) : TDataFile; override;
procedure LoadFromStream(Stream: TStream); override;
procedure SaveToStream(Stream: TStream); override;
procedure PlayOnWaveOut; override;
function WAVData : Pointer; override;
function WAVDataSize : Integer; override;
function PCMData : Pointer; override;
function LengthInBytes : Integer; override;
end;
// TGLSoundFileFormat
//
TGLSoundFileFormat = record
SoundFileClass : TGLSoundFileClass;
Extension : String;
Description : String;
DescResID : Integer;
end;
PSoundFileFormat = ^TGLSoundFileFormat;
// TGLSoundFileFormatsList
//
TGLSoundFileFormatsList = class(TList)
public
{ Public Declarations }
destructor Destroy; override;
procedure Add(const Ext, Desc: String; DescID: Integer; AClass: TGLSoundFileClass);
function FindExt(Ext: string): TGLSoundFileClass;
procedure Remove(AClass: TGLSoundFileClass);
procedure BuildFilterStrings(SoundFileClass: TGLSoundFileClass; var Descriptions, Filters: string);
end;
procedure PlayOnWaveOut(pcmData : Pointer; lengthInBytes : Integer;
sampling : TGLSoundSampling); overload;
function PlayOnWaveOut(pcmData : Pointer; lengthInBytes : Integer;
waveFormat : TWaveFormatEx) : HWaveOut; overload;
function GetGLSoundFileFormats : TGLSoundFileFormatsList;
procedure RegisterSoundFileFormat(const AExtension, ADescription: String; AClass: TGLSoundFileClass);
procedure UnregisterSoundFileClass(AClass: TGLSoundFileClass);
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// ------------------------------------------------------------------
implementation
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// ------------------------------------------------------------------
uses SysUtils, GLStrings, consts;
type
TRIFFChunkInfo = packed record
ckID : FOURCC;
ckSize : LongInt;
end;
const
WAVE_Format_ADPCM = 2;
var
vSoundFileFormats : TGLSoundFileFormatsList;
// GeTGLSoundFileFormats
//
function GetGLSoundFileFormats : TGLSoundFileFormatsList;
begin
if not Assigned(vSoundFileFormats)then
vSoundFileFormats := TGLSoundFileFormatsList.Create;
Result := vSoundFileFormats;
end;
// RegisterSoundFileFormat
//
procedure RegisterSoundFileFormat(const AExtension, ADescription: String; AClass: TGLSoundFileClass);
begin
RegisterClass(AClass);
GetGLSoundFileFormats.Add(AExtension, ADescription, 0, AClass);
end;
// UnregisterSoundFileClass
//
procedure UnregisterSoundFileClass(AClass: TGLSoundFileClass);
begin
if Assigned(vSoundFileFormats) then
vSoundFileFormats.Remove(AClass);
end;
procedure _waveOutCallBack(hwo : HWAVEOUT; uMsg : Cardinal;
dwInstance, dwParam1, dwParam2 : Integer); stdcall;
begin
if uMsg=WOM_DONE then
waveOutClose(hwo);
end;
// PlayOnWaveOut (sampling)
//
procedure PlayOnWaveOut(pcmData : Pointer; lengthInBytes : Integer;
sampling : TGLSoundSampling);
var
wfx : TWaveFormatEx;
hwo : hwaveout;
wh : wavehdr;
mmres : MMRESULT;
begin
wfx:=sampling.WaveFormat;
mmres:=waveOutOpen(@hwo, WAVE_MAPPER, @wfx, Cardinal(@_waveOutCallBack), 0, CALLBACK_FUNCTION);
Assert(mmres=MMSYSERR_NOERROR, IntToStr(mmres));
wh.dwBufferLength:=lengthInBytes;
wh.lpData:=pcmData;
wh.dwFlags:=0;
wh.dwLoops:=1;
wh.lpNext:=nil;
mmres:=waveOutPrepareHeader(hwo, @wh, SizeOf(wavehdr));
Assert(mmres=MMSYSERR_NOERROR, IntToStr(mmres));
mmres:=waveOutWrite(hwo, @wh, SizeOf(wavehdr));
Assert(mmres=MMSYSERR_NOERROR, IntToStr(mmres));
end;
// PlayOnWaveOut (waveformat)
//
function PlayOnWaveOut(pcmData : Pointer; lengthInBytes : Integer;
waveFormat : TWaveFormatEx) : HWaveOut;
var
hwo : hwaveout;
wh : wavehdr;
mmres : MMRESULT;
begin
mmres:=waveOutOpen(@hwo, WAVE_MAPPER, @waveFormat, Cardinal(@_waveOutCallBack),
0, CALLBACK_FUNCTION);
Assert(mmres=MMSYSERR_NOERROR, IntToStr(mmres));
wh.dwBufferLength:=lengthInBytes;
wh.lpData:=pcmData;
wh.dwFlags:=0;
wh.dwLoops:=1;
wh.lpNext:=nil;
mmres:=waveOutPrepareHeader(hwo, @wh, SizeOf(wavehdr));
Assert(mmres=MMSYSERR_NOERROR, IntToStr(mmres));
mmres:=waveOutWrite(hwo, @wh, SizeOf(wavehdr));
Assert(mmres=MMSYSERR_NOERROR, IntToStr(mmres));
Result:=hwo;
end;
// ------------------
// ------------------ TGLSoundSampling ------------------
// ------------------
// Create
//
constructor TGLSoundSampling.Create(AOwner: TPersistent);
begin
inherited Create;
FOwner:=AOwner;
FFrequency:=22050;
FNbChannels:=1;
FBitsPerSample:=8;
end;
// Destroy
//
destructor TGLSoundSampling.Destroy;
begin
inherited Destroy;
end;
// Assign
//
procedure TGLSoundSampling.Assign(Source: TPersistent);
begin
if Source is TGLSoundSampling then begin
FFrequency:=TGLSoundSampling(Source).Frequency;
FNbChannels:=TGLSoundSampling(Source).NbChannels;
FBitsPerSample:=TGLSoundSampling(Source).BitsPerSample;
end else inherited;
end;
// GetOwner
//
function TGLSoundSampling.GetOwner : TPersistent;
begin
Result:=FOwner;
end;
// BytesPerSec
//
function TGLSoundSampling.BytesPerSec : Integer;
begin
Result:=(FFrequency*FBitsPerSample*FNbChannels) shr 3;
end;
// BytesPerSample
//
function TGLSoundSampling.BytesPerSample : Integer;
begin
Result:=FBitsPerSample shr 3;
end;
// WaveFormat
//
function TGLSoundSampling.WaveFormat : TWaveFormatEx;
begin
Result.nSamplesPerSec:=Frequency;
Result.nChannels:=NbChannels;
Result.wFormatTag:=Wave_Format_PCM;
Result.nAvgBytesPerSec:=BytesPerSec;
Result.wBitsPerSample:=BitsPerSample;
Result.nBlockAlign:=1024;
Result.cbSize:=SizeOf(TWaveFormatEx);
end;
// ------------------
// ------------------ TGLSoundFile ------------------
// ------------------
// Create
//
constructor TGLSoundFile.Create(AOwner: TPersistent);
begin
inherited;
FSampling:=TGLSoundSampling.Create(Self);
end;
// Destroy
//
destructor TGLSoundFile.Destroy;
begin
FSampling.Free;
inherited;
end;
// SetSampling
//
procedure TGLSoundFile.SetSampling(const val : TGLSoundSampling);
begin
FSampling.Assign(val);
end;
// PlayOnWaveOut
//
procedure TGLSoundFile.PlayOnWaveOut;
begin
GLSoundFileObjects.PlayOnWaveOut(PCMData, LengthInSamples, Sampling);
end;
// LengthInSamples
//
function TGLSoundFile.LengthInSamples : Integer;
var
d : Integer;
begin
d:=Sampling.BytesPerSample*Sampling.NbChannels;
if d>0 then
Result:=LengthInBytes div d
else Result:=0;
end;
// LengthInSec
//
function TGLSoundFile.LengthInSec : Single;
begin
Result:=LengthInBytes/Sampling.BytesPerSec;
end;
// ------------------
// ------------------ TGLWAVFile ------------------
// ------------------
// CreateCopy
//
function TGLWAVFile.CreateCopy(AOwner: TPersistent) : TDataFile;
begin
Result:=inherited CreateCopy(AOwner);
if Assigned(Result) then begin
TGLWAVFile(Result).waveFormat:=waveFormat;
TGLWAVFile(Result).data:=data;
end;
end;
// LoadFromStream
//
procedure TGLWAVFile.LoadFromStream(stream : TStream);
var
ck : TRIFFChunkInfo;
dw, bytesToGo, startPosition, totalSize : Integer;
id : Cardinal;
dwDataOffset, dwDataSamples : Integer;
begin
// this WAVE loading code is an adaptation of the 'minimalist' sample from
// the Microsoft DirectX SDK.
Assert(Assigned(stream));
dwDataOffset:=0;
// Check RIFF Header
startPosition:=stream.Position;
stream.Read(ck, SizeOf(TRIFFChunkInfo));
Assert((ck.ckID=mmioStringToFourCC('RIFF',0)), 'RIFF required');
totalSize:=ck.ckSize+SizeOf(TRIFFChunkInfo);
stream.Read(id, SizeOf(Integer));
Assert((id=mmioStringToFourCC('WAVE',0)), 'RIFF-WAVE required');
// lookup for 'fmt '
repeat
stream.Read(ck, SizeOf(TRIFFChunkInfo));
bytesToGo:=ck.ckSize;
if (ck.ckID = mmioStringToFourCC('fmt ',0)) then begin
if waveFormat.wFormatTag=0 then begin
dw:=ck.ckSize;
if dw>SizeOf(TWaveFormatEx) then
dw:=SizeOf(TWaveFormatEx);
stream.Read(waveFormat, dw);
bytesToGo:=ck.ckSize-dw;
end;
// other 'fmt ' chunks are ignored (?)
end else if (ck.ckID = mmioStringToFourCC('fact',0)) then begin
if (dwDataSamples = 0) and (waveFormat.wFormatTag = WAVE_Format_ADPCM) then begin
stream.Read(dwDataSamples, SizeOf(LongInt));
Dec(bytesToGo, SizeOf(LongInt));
end;
// other 'fact' chunks are ignored (?)
end else if (ck.ckID = mmioStringToFourCC('data',0)) then begin
dwDataOffset:=stream.Position-startPosition;
Break;
end;
// all other sub-chunks are ignored, move to the next chunk
stream.Seek(bytesToGo, soFromCurrent);
until Stream.Position = 2048; // this should never be reached
// Only PCM wave format is recognized
// Assert((waveFormat.wFormatTag=Wave_Format_PCM), 'PCM required');
// seek start of data
pcmOffset:=dwDataOffset;
SetLength(data, totalSize);
stream.Position:=startPosition;
stream.Read(data[1], totalSize);
// update Sampling data
with waveFormat do begin
Sampling.Frequency:=nSamplesPerSec;
Sampling.NbChannels:=nChannels;
Sampling.BitsPerSample:=wBitsPerSample;
end;
end;
// SaveToStream
//
procedure TGLWAVFile.SaveToStream(stream: TStream);
begin
stream.Write(data[1], Length(data));
end;
// LengthInBytes
//
function TGLWAVFile.LengthInBytes : Integer;
begin
Result:=Length(data)-pcmOffset;
end;
// PlayOnWaveOut
//
procedure TGLWAVFile.PlayOnWaveOut;
begin
PlaySound(WAVData, 0, SND_ASYNC+SND_MEMORY);
// GLSoundFileObjects.PlayOnWaveOut(PCMData, LengthInBytes, waveFormat);
end;
// WAVData
//
function TGLWAVFile.WAVData : Pointer;
begin
if Length(data)>0 then
Result:=@data[1]
else Result:=nil;
end;
// WAVDataSize
//
function TGLWAVFile.WAVDataSize : Integer;
begin
Result:=Length(data);
end;
// PCMData
//
function TGLWAVFile.PCMData : Pointer;
begin
if Length(data)>0 then
Result:=@data[1+pcmOffset]
else Result:=nil;
end;
// ------------------
// ------------------ TGLSoundFileFormatsList ------------------
// ------------------
// Destroy
//
destructor TGLSoundFileFormatsList.Destroy;
var
i : Integer;
begin
for i:=0 to Count-1 do Dispose(PSoundFileFormat(Items[i]));
inherited;
end;
// Add
//
procedure TGLSoundFileFormatsList.Add(const Ext, Desc: String; DescID: Integer;
AClass: TGLSoundFileClass);
var
newRec: PSoundFileFormat;
begin
New(newRec);
with newRec^ do begin
Extension := AnsiLowerCase(Ext);
SoundFileClass := AClass;
Description := Desc;
DescResID := DescID;
end;
inherited Add(NewRec);
end;
// FindExt
//
function TGLSoundFileFormatsList.FindExt(Ext: string): TGLSoundFileClass;
var
i : Integer;
begin
Ext := AnsiLowerCase(Ext);
for I := Count-1 downto 0 do with PSoundFileFormat(Items[I])^ do
if (Extension = Ext) or ('.'+Extension = Ext) then begin
Result := SoundFileClass;
Exit;
end;
Result := nil;
end;
// Remove
//
procedure TGLSoundFileFormatsList.Remove(AClass: TGLSoundFileClass);
var
i : Integer;
p : PSoundFileFormat;
begin
for I := Count-1 downto 0 do begin
P := PSoundFileFormat(Items[I]);
if P^.SoundFileClass.InheritsFrom(AClass) then begin
Dispose(P);
Delete(I);
end;
end;
end;
// BuildFilterStrings
//
procedure TGLSoundFileFormatsList.BuildFilterStrings(SoundFileClass: TGLSoundFileClass;
var Descriptions, Filters: string);
var
c, i : Integer;
p : PSoundFileFormat;
begin
Descriptions := '';
Filters := '';
C := 0;
for I := Count-1 downto 0 do begin
P := PSoundFileFormat(Items[I]);
if P^.SoundFileClass.InheritsFrom(SoundFileClass) and (P^.Extension <> '') then
with P^ do begin
if C <> 0 then begin
Descriptions := Descriptions+'|';
Filters := Filters+';';
end;
if (Description = '') and (DescResID <> 0) then
Description := LoadStr(DescResID);
FmtStr(Descriptions, '%s%s (*.%s)|*.%2:s',
[Descriptions, Description, Extension]);
FmtStr(Filters, '%s*.%s', [Filters, Extension]);
Inc(C);
end;
end;
if C > 1 then
FmtStr(Descriptions, '%s (%s)|%1:s|%s', [sAllFilter, Filters, Descriptions]);
end;
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// ------------------------------------------------------------------
initialization
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// class registrations
RegisterSoundFileFormat('wav', 'Windows WAV files', TGLWAVFile);
end.
|
{
Gets LOD usage statistics for worldspace in tabulated spreadsheet text file (apply script to worldspace).
Used to find out the LOD meshes with biggest impact for primary optimization targets.
Fields:
Record - base static record
Uses - number of refs
Total Tris - total number of triangles in LOD
LOD0 Mesh - LOD Level 0 mesh name
LOD0 Tris - number of triangles in mesh
LOD0 Total Tris - total number of triangles in LOD Level 0
... repeats for other LOD Levels
Supported games: Fallout 3, Fallout New Vegas, Skyrim, SSE, Fallout4 (partially, no SCOL info)
}
unit LODStatistics;
var
slLOD: TStringList;
// getting _lod.nif file for a record
function FalloutLODMesh(rec: IInterface): string;
begin
Result := GetElementEditValues(rec, 'Model\MODL');
Result := Copy(Result, 1, Length(Result) - 4) + '_lod.nif';
if Result <> '' then begin
Result := wbNormalizeResourceName(Result, resMesh);
if not ResourceExists(Result) then Result := '';
end;
end;
// getting a total number of triangles in a nif mesh
function NifTrisCount(aMesh: string): Integer;
var
nif: TwbNifFile;
block: TwbNifBlock;
i: Integer;
begin
nif := TwbNifFile.Create;
try
try
nif.LoadFromResource(aMesh);
for i := 0 to Pred(nif.BlocksCount) do begin
block := nif.Blocks[i];
if block.IsNiObject('NiTriBasedGeomData', True) then
Result := Result + block.NativeValues['Num Triangles']
else if block.IsNiObject('BSTriShape', True) then
Result := Result + block.NativeValues['Num Triangles'];
end;
except
on E: Exception do
AddMessage('Error reading "' + aMesh + '": ' + E.Message);
end;
finally
nif.Free;
end;
end;
function Initialize: integer;
begin
if wbGameMode = gmTES4 then begin
AddMessage('Oblivion is not supported.');
Result := 1;
Exit;
end;
slLOD := TStringList.Create;
end;
function Process(e: IInterface): integer;
var
base: IInterface;
idx: Integer;
begin
if Signature(e) <> 'REFR' then
Exit;
//if not GetIsVisibleWhenDistant(e) then
// Exit;
base := WinningOverride(BaseRecord(e));
idx := slLOD.IndexOfObject(base);
// check that the base record have LOD if not checked yet
if idx = -1 then begin
if wbGameMode >= gmTES5 then begin
if Signature(base) <> 'STAT' then
Exit;
if not ElementExists(base, 'MNAM') then
Exit;
end
else begin
if Pos(Signature(base), 'STAT SCOL ACTI') = 0 then
Exit;
if FalloutLODMesh(base) = '' then
Exit;
end
slLOD.AddObject('1', base);
end else
slLOD[idx] := Format('%.4d', [StrToInt(slLOD[idx]) + 1])
end;
function Finalize: integer;
var
i, j, cnt, faces, totalfaces: Integer;
stat: IInterface;
mesh, s: string;
dlgSave: TSaveDialog;
begin
for i := 0 to Pred(slLOD.Count) do begin
stat := ObjectToElement(slLOD.Objects[i]);
cnt := StrToInt(slLOD[i]);
totalfaces := 0;
s := Name(stat) + #9 + IntToStr(cnt) + #9 + '{TOTALFACES}';
for j := 0 to 3 do begin
if wbGameMode >= gmTES5 then
mesh := GetElementEditValues(stat, 'MNAM\[' + IntToStr(j) + ']\Mesh')
else if j = 0 then
mesh := FalloutLODMesh(stat)
else
mesh := '';
if mesh = '' then begin
s := s + #9#9#9;
Continue;
end;
mesh := wbNormalizeResourceName(mesh, resMesh);
faces := NifTrisCount(mesh);
totalfaces := totalfaces + faces * cnt;
s := s + #9 + mesh + #9 + IntToStr(faces) + #9 + IntToStr(faces * cnt);
end;
// prepend total faces count prefix for sorting (in reverse order)
slLOD[i] := Format('%.8d', [99999999 - totalfaces]) + StringReplace(s, '{TOTALFACES}', IntToStr(totalfaces), [rfReplaceAll]);
end;
slLOD.Sort;
// remove prefix
for i := 0 to Pred(slLOD.Count) do
slLOD[i] := Copy(slLOD[i], 9, Length(slLOD[i]));
slLOD.Insert(0, 'Record'#9'Uses'#9'Total Tris'#9'LOD0 Mesh'#9'LOD0 Tris'#9'LOD0 Total Tris'#9'LOD1 Mesh'#9'LOD1 Tris'#9'LOD1 Total Tris'#9'LOD2 Mesh'#9'LOD2 Tris'#9'LOD2 Total Tris'#9'LOD3 Mesh'#9'LOD3 Tris'#9'LOD3 Total Tris');
if slLOD.Count > 0 then begin
dlgSave := TSaveDialog.Create(nil);
dlgSave.Options := dlgSave.Options + [ofOverwritePrompt];
dlgSave.Filter := 'Tabulated text (*.txt)|*.txt';
dlgSave.InitialDir := wbScriptsPath;
dlgSave.FileName := 'LOD Statistics.txt';
if dlgSave.Execute then begin
AddMessage('Saving ' + dlgSave.FileName);
slLOD.SaveToFile(dlgSave.FileName);
end;
dlgSave.Free;
end;
slLOD.Free;
end;
end.
|
unit SyncObjs2;
{$MODE Delphi}
interface
uses {$ifdef darwin}
macport, cthreads, unix, unixtype, pthreads, baseunix,
{$else}
windows,
{$endif}SyncObjs, classes, sysutils, LCLIntf;
type TSemaphore=class
private
{$ifdef windows}
h: THandle;
{$endif}
max: integer;
{$ifdef darwin}
h: psem_t;
semaphorecount: cardinal;
semname: string;
{$endif}
public
function TryAcquire(time: integer=0): boolean;
procedure Acquire;
function Release(count:integer=1):integer;
constructor create(maxcount: integer; init0:boolean=false);
destructor destroy; override;
end;
type
TThreadHelper=class helper for TThread
function WaitTillDone(timeout: DWORD; granularity: integer=25): boolean;
end;
{$ifdef THREADNAMESUPPORT}
function GetThreadName(tid: TThreadID={$ifdef windows}0{$else}nil{$endif}): string;
{$endif}
implementation
uses networkInterfaceApi, maps;
var
tm: TThreadManager;
oldSetThreadDebugNameA: procedure(threadHandle: TThreadID; const ThreadName: AnsiString);
threadnames: TMap;
threadnamesCS: TCriticalSection;
{$ifdef THREADNAMESUPPORT}
function GetThreadName(tid: TThreadID={$ifdef windows}0{$else}nil{$endif}): string;
var s: pstring;
begin
result:='';
if {$ifdef windows}tid=0{$else}tid=nil{$endif} then tid:=GetCurrentThreadId;
threadnamesCS.enter;
s:=nil;
if threadnames.GetData(tid, s) then
result:=s^;
threadnamesCS.Leave;
end;
procedure SetThreadDebugNameA(tid: TThreadID; const ThreadName: AnsiString);
var s: pstring;
str: string;
begin
if assigned(oldSetThreadDebugNameA) then
oldSetThreadDebugNameA(tid, threadname);
if tid=TThreadID(-1) then
tid:=GetCurrentThreadId;
threadnamesCS.enter;
if threadnames.GetData(tid, s) then
begin
DisposeStr(s);
threadnames.Delete(tid);
end;
threadnames.Add(tid, NewStr(threadname));
threadnamesCS.Leave;
if (tid=GetCurrentThreadId) and (getConnection<>nil) then
Getconnection.setconnectionname(threadname);
end;
procedure EndThread(exitcode: dword);
var s: pstring;
begin
threadnamesCS.enter;
if threadnames.GetData(GetCurrentThreadId, s) then
begin
DisposeStr(s);
threadnames.Delete(GetCurrentThreadId);
end;
threadnamesCS.Leave;
end;
{$endif}
function TThreadHelper.WaitTillDone(timeout: dword; granularity: integer=25): boolean;
var
needsynchronize: boolean;
endtime: qword;
begin
needsynchronize:=MainThreadID=GetCurrentThreadId;
if Finished then exit(true);
if timeout=0 then exit(Finished);
if timeout=$ffffffff then
begin
WaitFor;
exit(true);
end;
endtime:=gettickcount64+timeout;
repeat
if needsynchronize then
CheckSynchronize(granularity)
else
begin
{$ifdef windows}
exit(waitforsingleobject(self.handle, timeout)=WAIT_OBJECT_0);
{$else}
sleep(granularity);
{$endif}
end;
until (gettickcount64>endtime) or Finished;
result:=finished;
end;
{$ifdef darwin}
function sem_open(name: pchar; oflags: integer; mode: integer; value: integer):Psem_t;cdecl; external;
var
count: integer;
{$endif}
constructor TSemaphore.create(maxcount:integer; init0: boolean=false);
var
init: integer;
i: integer;
begin
max:=maxcount;
if init0 then
init:=0
else
init:=maxcount;
{$ifdef windows}
h:=CreateSemaphore(nil,init,maxcount,nil);
{$endif}
{$ifdef unix}
{$ifndef darwin}
i:=sem_init(@h,0,init);
{$else}
inc(count);
semname:='Semaphore'+inttohex(GetCurrentProcessID,8)+'-'+inttostr(count);
h:=sem_open(pchar(semname), O_CREAT, &644{&777},init);
if IntPtr(h)=-1 then
begin
i:=errno;
raise exception.create('sem_open error '+inttostr(i));
end;
{$endif}
{$endif}
end;
destructor TSemaphore.destroy;
begin
{$ifdef windows}
closehandle(h);
{$endif}
{$ifdef unix}
{$ifndef darwin}
sem_destroy(h);
{$else}
sem_unlink(pchar(semname));
sem_close(@h);
{$endif}
{$endif}
inherited destroy;
end;
procedure TSemaphore.Acquire;
begin
{$ifdef windows}
waitforsingleobject(h,infinite);
{$else}
if sem_wait(h)=0 then //wait inside a critical section
InterlockedDecrement(semaphorecount);
{$endif}
end;
function TSemaphore.TryAcquire(time: integer=0):boolean;
{$ifndef windows}
var
t: TThread;
starttime: qword;
abstime: timespec;
tspec: TTimeSpec;
{$endif}
begin
{$ifdef windows}
result:=waitforsingleobject(h,time)=WAIT_OBJECT_0;
{$else}
starttime:=gettickcount64;
result:=false;
if sem_trywait(h)=0 then
begin
InterlockedDecrement(semaphorecount);
exit(true);
end;
if time>0 then
begin
{$ifndef darwin}
if clock_gettime(CLOCK_REALTIME, tspec)=0 then
begin
//1000000000=1 second
//100000000=100 milliseconds
//1000000=1 millisecond
inc(tspec.tv_nsec, time*1000000);
while (tv_nsec>=1000000000) do
begin
inc(tspec.tv_sec);
dec(tspec.tv_nsec,1000000000);
end
result:=sem_timedwait(h,abstime)=0;
end
else sleep(50);
{$else}
//mac
while (gettickcount64<starttime+time) do
begin
if sem_trywait(h)=0 then
begin
InterlockedDecrement(semaphorecount);
exit(true);
end;
sleep(50);
end;
{$endif}
end;
{$endif}
end;
function TSemaphore.Release(count: integer=1): integer;
var
previouscount: LONG;
e: integer;
begin
{$ifdef windows}
if releasesemaphore(h,count,@previouscount) then
result:=previouscount
else
result:=-1;
{$else}
result:=semaphorecount;
for e:=1 to count do
begin
if semaphorecount<max then
begin
InterlockedIncrement(semaphorecount);
sem_post(h);
end;
end;
{$endif}
end;
{$ifdef THREADNAMESUPPORT}
procedure finalizeThreadNames;
var i: TMapIterator;
s: pstring;
begin
threadnamesCS.enter;
try
i:=TMapIterator.Create(threadnames);
i.First;
while not i.EOM do
begin
s:=nil;
i.GetData(s);
if s<>nil then
DisposeStr(s);
i.Next;
end;
finally
threadnamesCS.leave;
end;
freeandnil(threadnamesCS);
freeandnil(threadnames);
end;
{$endif}
initialization
{$ifdef THREADNAMESUPPORT}
threadnames:=TMap.Create(itu4,sizeof(pointer));
threadnamesCS:=TCriticalSection.Create;
GetThreadManager(tm);
oldSetThreadDebugNameA:=tm.SetThreadDebugNameA;
tm.SetThreadDebugNameA:=@SetThreadDebugNameA;
SetThreadManager(tm);
{$endif}
finalization
{$ifdef THREADNAMESUPPORT}
finalizeThreadNames();
{$endif}
end.
|
program timer;
(* Shows a way to use timers. *)
uses
andante;
var
Cnt: Integer;
begin
WriteLn ('Andante ', anVersionString);
WriteLn;
if not anInstall then
begin
WriteLn ('Can''t initialize Andante!');
Halt
end;
if not anInstallKeyboard then
begin
WriteLn ('Keyboard out: ', anError);
Halt
end;
{ Test timer. }
WriteLn ('Press [Esc] to exit.');
Cnt := 0;
repeat
if anTimerCounter mod anTimerFrequency = 1 then
begin
Inc (Cnt); WriteLn (Cnt);
repeat until anTimerCounter mod anTimerFrequency <> 1;
end
until anKeyState[anKeyEscape];
WriteLn;
WriteLn ('We''re done!')
end.
|
(*
@abstract(Contient les classes pour l'application de filtres sur les couleurs.)
-------------------------------------------------------------------------------------------------------------
@created(2017-08-22)
@author(J.Delauney (BeanzMaster))
Historique : @br
@unorderedList(
@item(22/08/2017 : Creation)
@item(18/06/2019 : Mise à jour)
)
-------------------------------------------------------------------------------------------------------------
@bold(Notes :)@br
-------------------------------------------------------------------------------------------------------------
@bold(Dépendances) : BZClasses, BZControlClasses, BZGraphic, BZBitmap, BZInterpolationFilters
-------------------------------------------------------------------------------------------------------------
@bold(Credits :)
@unorderedList(
@item(FPC/Lazarus)
)
-------------------------------------------------------------------------------------------------------------
@bold(Licence) : MPL / LGPL
------------------------------------------------------------------------------------------------------------- *)
unit BZBitmapThresholdFilters;
//==============================================================================
{$mode objfpc}{$H+}
{$i ..\bzscene_options.inc}
//==============================================================================
interface
uses
Classes, SysUtils,
BZClasses, BZMath, BZColors, BZGraphic, BZBitmapFilterClasses;
Type
{ Enumération des methodes pour le filtre de seuillage adaptatif }
TBZFilterAdaptativeThresOldMode = (atmAverage, atmMinMax, atmGaussian);
{ @abstract(Classe de base pour l'application d'un filtre de seuillage)
@unorderedlist(
@item(https://en.wikipedia.org/wiki/Thresholding_(image_processing))
@item(https://homepages.inf.ed.ac.uk/rbf/HIPR2/adpthrsh.htm)
@item(http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.420.7883&rep=rep1&type=pdf)
@item(https://en.wikipedia.org/wiki/Balanced_histogram_thresholding)
@item(https://en.wikipedia.org/wiki/Otsu%27s_method)
@item(https://theailearner.com/2019/07/19/improving-global-thresholding/)
@item(http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.475.6638&rep=rep1&type=pdf)
@item(https://dsp.stackexchange.com/questions/2411/what-are-the-most-common-algorithms-for-adaptive-thresholding)
@item(https://dsp.stackexchange.com/questions/1932/what-are-the-best-algorithms-for-document-image-thresholding-in-this-example)
@item(https://perso.liris.cnrs.fr/christian.wolf/papers/icpr2002v.pdf)
@item(https://github.com/chriswolfvision/local_adaptive_binarization)
@item(http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=2CB60307341127953FEE6E84A4E5CCFD?doi=10.1.1.130.8869&rep=rep1&type=pdf)
@item(https://www.researchgate.net/publication/220827321_Adaptive_Thresholding_Methods_for_Documents_Image_Binarization)
@item(http://cs.haifa.ac.il/hagit/courses/ip/Lectures/Ip12_Segmentation.pdf)
@item(https://www.researchgate.net/publication/309967669_Image_thresholding_techniques_A_survey_over_categories)
@item(https://aircconline.com/cseij/V6N1/6116cseij01.pdf)
@item(https://www.cse.unr.edu/~bebis/CS791E/Notes/Thresholding.pdf)
@item(https://eprints.ucm.es/16932/1/Tesis_Master_Daniel_Martin_Carabias.pdf)
@item(
) }
TBZBitmapThresholdBaseFilter = class(TBZCustomBitmapFilterPointTransformEx)
private
FMulti : Boolean;
{ TODO 2 -oBZBitmap -cFiltre : Remplacer FMulti par FDual et ajouter le mode multi (tableau de seuil min et max) }
FRedMinThreshold : Byte;
FGreenMinThreshold : Byte;
FBlueMinThreshold : Byte;
FRedMaxThreshold : Byte;
FGreenMaxThreshold : Byte;
FBlueMaxThreshold : Byte;
FMinThreshold : Byte;
FMaxThreshold : Byte;
FMinColor : TBZColor;
FMaxColor : TBZColor;
FInterpolate : Boolean;
FAsGray : Boolean;
procedure SetRedMinThreshold(const AValue : Byte);
procedure SetGreenMinThreshold(const AValue : Byte);
procedure SetBlueMinThreshold(const AValue : Byte);
procedure SetMulti(const AValue : Boolean);
procedure SetMinThreshold(const AValue : byte);
procedure SetMaxThresHold(const AValue : Byte);
procedure SetInterpolate(const AValue : Boolean);
procedure SetMinColor(const AValue : TBZColor);
procedure SetMaxColor(const AValue : TBZColor);
procedure SetRedMaxThreshold(const AValue : Byte);
procedure SetGreenMaxThreshold(const AValue : Byte);
procedure SetBlueMaxThreshold(const AValue : Byte);
procedure SetAsGray(const AValue : Boolean);
protected
FHistogram : Array[0..255] of byte;
procedure ComputeHistogram;
procedure DoInitializeScanner; Override;
Function ProcessPixel(Const inColor : TBZColor) : TBZColor; override;
public
Constructor Create(Const AOwner: TBZBaseBitmap; Const DirectWrite :Boolean = False); Override;
{ Drapeau pour le mode multi/dual }
property Multi : Boolean read FMulti write SetMulti;
{ Seuil minimum pour le canal rouge }
property RedMinThreshold : Byte read FRedMinThreshold write SetRedMinThreshold;
{ Seuil minimum pour le canal vert }
property GreenMinThreshold : Byte read FGreenMinThreshold write SetGreenMinThreshold;
{ Seuil minimum pour le canal bleu }
property BlueMinThreshold : Byte read FBlueMinThreshold write SetBlueMinThreshold;
{ Seuil maximum pour le canal rouge }
property RedMaxThreshold : Byte read FRedMaxThreshold write SetRedMaxThreshold;
{ Seuil maximum pour le canal vert }
property GreenMaxThreshold : Byte read FGreenMaxThreshold write SetGreenMaxThreshold;
{ Seuil maximum pour le canal bleu }
property BlueMaxThreshold : Byte read FBlueMaxThreshold write SetBlueMaxThreshold;
{ Seuil minimum pour tous les canaux }
property MinThreshold : byte read FMinThreshold write SetMinThreshold;
{ Seuil maximum pour tous les canaux }
property MaxThresHold : Byte read FMaxThresHold write SetMaxThresHold;
{ Drapeau d'interpolation pour le mode multi/dual }
property Interpolate : Boolean read FInterpolate write SetInterpolate;
{ Couleur minimum de l'interval à seuiller }
property MinColor : TBZColor read FMinColor write SetMinColor;
{ Couleur maximum de l'interval à seuiller }
property MaxColor : TBZColor read FMaxColor write SetMaxColor;
{ Drapeau pour retourner le resultat en niveau de gris }
property AsGray : Boolean read FAsGray write SetAsGray;
End;
{ Méthode de calcul du seuillage automatique }
TBZAutomaticThresholdMode = (atmTriangle, atmMinimum, atmMean, atmPercentile,
atmOtsu, atmYen, atmHang, atmShanbhag,
atmMoments, atmMinError, atmMinimumCrossEntropy, atmMaxEntropy, atmRenyiEntropy,
atmIsoData, atmIntermodes);
{ Classe pour l'application d'un filtre de seuillage automatique }
TBZBitmapThresholdAutomaticFilter = Class(TBZBitmapThresholdBaseFilter)
private
FAutomaticThresholdMode : TBZAutomaticThresholdMode;
protected
procedure GetOtsuThreshold(var MinThres, MaxThres : Byte);
{ TODO 2 -oBZBitmap -cFiltre : Ajouter d'autres methodes de seuillage automatique
atmTriangle, atmMinimum, atmMean, atmPercentile,
atmYen, atmHang, atmShanbhag,
atmMoments, atmMinError,
atmMinimumCrossEntropy, atmMaxEntropy, atmRenyiEntropy,
atmIsoData, atmIntermodes }
procedure DoInitializeScanner; Override;
public
Constructor Create(Const AOwner: TBZBaseBitmap; Const DirectWrite :Boolean = False); Override;
{ Méthode de calcul du seuillage automatique }
property AutomaticThresholdMode : TBZAutomaticThresholdMode read FAutomaticThresholdMode write FAutomaticThresholdMode;
end;
{ TODO 2 -oBZBitmap -cFiltre : Ajouter d'autres methodes de seuillage
TBZBitmapThresholdLocalFilter = Class(TBZBitmapNonLinearFilter)
TBZBitmapThresholdHysteris
TBZBitmapThresholdNiblack
TBZBitmapThresholdSauvola
TBZBitmapThresholdBernsen
TBZBitmapThresholdSavakis
TBZBitmapThresholdYanowitzBruckstein
TBZBitmapThresholdAdaptativeFilter
}
implementation
{%region ====[ TBZBitmapThresoldBaseFilter ]==========================================}
Constructor TBZBitmapThresholdBaseFilter.Create(Const AOwner: TBZBaseBitmap; Const DirectWrite : Boolean);
begin
inherited Create(AOwner, True);
FMinColor := clrBlack;
FMaxColor := clrWhite;
FMinThreshold := 64;
FMaxThreshold := 192;
FRedMinThreshold := 64;
FGreenMinThreshold := 64;
FBlueMinThreshold := 64;
FRedMaxThreshold := 192;
FGreenMaxThreshold := 192;
FBlueMaxThreshold := 192;
FMulti := False;
FInterpolate := False;
FAsGray := True;
//FAdaptative := False;
//FAdaptativeMode := atmAverage;
FScannerDescription := 'Seuillage';
end;
procedure TBZBitmapThresholdBaseFilter.DoInitializeScanner;
begin
inherited DoInitializeScanner;
//if FAdaptative then
//begin
// FScannerDescription := FScannerDescription + ' adaptatif';
// Case FAdaptativeMode of
// atmAverage : FScannerDescription := FScannerDescription + ' : Moyen';
// atmMinMax : FScannerDescription := FScannerDescription + ' : MinMax';
// atmGaussian : FScannerDescription := FScannerDescription + ' : Gaussien';
// end;
//end
//else
//begin
//
FPreserveLuminosity := False;
if FMulti then FScannerDescription := FScannerDescription + ' Multi';
if FInterpolate then FScannerDescription := FScannerDescription + ' Interpolé';
end;
//procedure TBZBitmapThresholdBaseFilter.SetAdaptative(const AValue : Boolean);
//begin
// if FAdaptative = AValue then Exit;
// FAdaptative := AValue;
//end;
//
//procedure TBZBitmapThresholdBaseFilter.SetAdaptativeMode(const AValue : TBZFilterAdaptativeThresOldMode);
//begin
// if FAdaptativeMode = AValue then Exit;
// FAdaptativeMode := AValue;
//end;
procedure TBZBitmapThresholdBaseFilter.SetInterpolate(const AValue : Boolean);
begin
if FInterpolate = AValue then Exit;
FInterpolate := AValue;
end;
procedure TBZBitmapThresholdBaseFilter.SetMulti(const AValue : Boolean);
begin
if FMulti = AValue then Exit;
FMulti := AValue;
end;
procedure TBZBitmapThresholdBaseFilter.SetMaxThresHold(const AValue : Byte);
begin
if FMaxThresHold = AValue then Exit;
FMaxThresHold := AValue;
end;
procedure TBZBitmapThresholdBaseFilter.SetMinThreshold(const AValue : byte);
begin
if FMinThreshold = AValue then Exit;
FMinThreshold := AValue;
end;
procedure TBZBitmapThresholdBaseFilter.SetMinColor(const AValue : TBZColor);
begin
if FMinColor = AValue then Exit;
FMinColor := AValue;
end;
procedure TBZBitmapThresholdBaseFilter.SetMaxColor(const AValue : TBZColor);
begin
if FMaxColor = AValue then Exit;
FMaxColor := AValue;
end;
procedure TBZBitmapThresholdBaseFilter.SetRedMinThreshold(const AValue : Byte);
begin
if FRedMinThreshold = AValue then Exit;
FRedMinThreshold := AValue;
end;
procedure TBZBitmapThresholdBaseFilter.SetGreenMinThreshold(const AValue : Byte);
begin
if FGreenMinThreshold = AValue then Exit;
FGreenMinThreshold := AValue;
end;
procedure TBZBitmapThresholdBaseFilter.SetBlueMinThreshold(const AValue : Byte);
begin
if FBlueMinThreshold = AValue then Exit;
FBlueMinThreshold := AValue;
end;
procedure TBZBitmapThresholdBaseFilter.SetRedMaxThreshold(const AValue : Byte);
begin
if FRedMaxThreshold = AValue then Exit;
FRedMaxThreshold := AValue;
end;
procedure TBZBitmapThresholdBaseFilter.SetGreenMaxThreshold(const AValue : Byte);
begin
if FGreenMaxThreshold = AValue then Exit;
FGreenMaxThreshold := AValue;
end;
procedure TBZBitmapThresholdBaseFilter.SetBlueMaxThreshold(const AValue : Byte);
begin
if FBlueMaxThreshold = AValue then Exit;
FBlueMaxThreshold := AValue;
end;
procedure TBZBitmapThresholdBaseFilter.SetAsGray(const AValue : Boolean);
begin
if FAsGray = AValue then Exit;
FAsGray := AValue;
end;
procedure TBZBitmapThresholdBaseFilter.ComputeHistogram;
Var
i : Integer;
Lum : Byte;
PixPtr : PBZColor;
begin
for i := 0 to 255 do
begin
FHistogram[i] := 0;
end;
PixPtr := OwnerBitmap.GetScanLine(0);
i := 0;
While i < OwnerBitmap.MaxSize do
begin
Lum := PixPtr^.Luminosity;
inc(FHistogram[Lum]);
inc(i);
inc(PixPtr);
end;
end;
Function TBZBitmapThresholdBaseFilter.ProcessPixel(Const inColor : TBZColor) : TBZColor;
Var
Lum,f,a,b : Single;
outColor : TBZColor;
inColorF, outColorF : TBZColorVector;
l : Byte;
begin
if FInterpolate then
begin
if FMulti then
begin
inColorF := inColor.AsColorVector;
outColorF := inColorF;
// Red
if FRedMinThreshold = FRedMaxThreshold then
if FRedMaxThreshold = 255 then FRedMinThreshold := FRedMinThreshold - 1
else FRedMaxThreshold := FRedMaxThreshold + 1;
a := FRedMinThreshold * _FloatColorRatio;
b := FRedMaxthreshOld * _FloatColorRatio;
f := SmoothStep(a, b, inColorF.Red);
OutColorF.Red := Lerp(FMinColor.AsColorVector.Red, FMaxColor.AsColorVector.Red, f);
// Green
if FGreenMinThreshold = FGreenMaxThreshold then
if FGreenMaxThreshold = 255 then FGreenMinThreshold := FGreenMinThreshold - 1
else FGreenMaxThreshold := FGreenMaxThreshold + 1;
a := FGreenMinThreshold * _FloatColorRatio;
b := FGreenMaxthreshOld * _FloatColorRatio;
f := SmoothStep(a, b, inColorF.Green);
OutColorF.Green := Lerp(FMinColor.AsColorVector.Green, FMaxColor.AsColorVector.Green, f);
// Blue
if FBlueMinThreshold = FBlueMaxThreshold then
if FRedMaxThreshold = 255 then FBlueMinThreshold := FBlueMinThreshold - 1
else FBlueMaxThreshold := FBlueMaxThreshold + 1;
a := FBlueMinThreshold * _FloatColorRatio;
b := FBlueMaxthreshOld * _FloatColorRatio;
f := SmoothStep(a, b, inColorF.Blue);
OutColorF.Blue := Lerp(FMinColor.AsColorVector.Blue, FMaxColor.AsColorVector.Blue, f);
OutColor.Create(outColorF);
Result:= outColor;
end
else
begin
if FMinThreshold = FMaxThreshold then
if FMaxThreshold = 255 then FMinThreshold := FMinThreshold - 1
else FMaxThreshold := FMaxThreshold + 1;
a := FMinThreshold * _FloatColorRatio;
b := FMaxthreshOld * _FloatColorRatio;
if FAsGray then
begin
Lum := FCurrentSrcPixelPtr^.Luminosity * _FloatColorRatio;
f := SmoothStep(a, b, Lum);
Result := FMinColor.Mix(FMaxColor, f);
end
else
begin
inColorF := FCurrentSrcPixelPtr^.AsColorVector;
outColorF := inColorF;
f := SmoothStep(a, b, inColorF.Red);
OutColorF.Red := Lerp(FMinColor.AsColorVector.Red, FMaxColor.AsColorVector.Red, f);
f := SmoothStep(a, b, inColorF.Green);
OutColorF.Green := Lerp(FMinColor.AsColorVector.Green, FMaxColor.AsColorVector.Green, f);
f := SmoothStep(a, b, inColorF.Blue);
OutColorF.Blue := Lerp(FMinColor.AsColorVector.Blue, FMaxColor.AsColorVector.Blue, f);
OutColor.Create(outColorF);
Result := outColor;
end;
end;
end
else
begin
outColor := inColor;
if FMulti then
begin
if FRedMinThresHold = FRedMaxThreshold then
begin
if inColor.Red >= FRedMinThreshold then outColor.Red := FMaxColor.Red
else outColor.Red := FMinColor.Red;
end
else
begin
if (inColor.Red >= FRedMinThreshold) and (inColor.Red <= FRedMaxThreshold) then outColor.Red := FMaxColor.Red
else outColor.Red := FMinColor.Red;
end;
if FGreenMinThreshold = FGreenMaxThreshold then
begin
if inColor.Green <= FGreenMinThreshold then outColor.Green := FMinColor.Green
else if inColor.Green >= FGreenMaxThreshold then outColor.Green := FMaxColor.Green;
end
else
begin
if (inColor.Green >= FGreenMinThreshold) and (inColor.Green <= FGreenMaxThreshold) then outColor.Green := FMaxColor.Green
else outColor.Green := FMinColor.Green;
end;
if FBlueMinThreshold = FBlueMaxThreshold then
begin
if inColor.Blue <= FBlueMinThreshold then outColor.Blue := FMinColor.Blue
else if inColor.Blue >= FBlueMaxThreshold then outColor.Blue := FMaxColor.Blue;
end
else
begin
if (inColor.Blue >= FBlueMinThreshold) and (inColor.Blue <= FBlueMaxThreshold) then outColor.Blue := FMaxColor.Blue
else outColor.Blue := FMinColor.Blue;
end;
end
else
begin
if FMinThreshold = FMaxThreshold then
begin
if FAsGray then
begin
l := inColor.Luminosity;
if l >= FMinThreshold then outColor := FMaxColor
else outColor := FMinColor;
end
else
begin
if inColor.Red >= FMinThreshold then outColor.Red := FMaxColor.Red
else outColor.Red := FMinColor.Red;
if inColor.Green >= FMinThreshold then outColor.Green := FMaxColor.Green
else outColor.Green := FMinColor.Green;
if inColor.Blue >= FMinThreshold then outColor.Blue := FMaxColor.Blue
else outColor.Blue := FMinColor.Blue;
end;
end
else
begin
if FAsGray then
begin
l := inColor.Luminosity;
if (l >= FMinThreshold) and (l <= FMaxThreshold) then outColor := FMaxColor
else outColor := FMinColor;
end
else
begin
if (inColor.Red >= FMinThreshold) and (inColor.Red <= FMaxThreshold) then outColor.Red := FMaxColor.Red
else outColor.Red := FMinColor.Red;
if (inColor.Green >= FMinThreshold) and (inColor.Green <= FMaxThreshold) then outColor.Green := FMaxColor.Green
else outColor.Green := FMinColor.Green;
if (inColor.Blue >= FMinThreshold) and (inColor.Blue <= FMaxThreshold) then outColor.Blue := FMaxColor.Blue
else outColor.Blue := FMinColor.Blue;
end;
end;
end;
Result := outColor;
end;
end;
{%endregion%}
{%region=====[ TBZBitmapThresholdAutomaticFilter ]=====================================}
procedure TBZBitmapThresholdAutomaticFilter.GetOtsuThreshold(var MinThres, MaxThres : Byte);
Var
p1, p2, p3, Diff : Single;
k : Integer;
v : Array[0..255] of Single;
function FuncOtsuA(ii,jj : Byte) : Single;
Var
Sum, i : Integer;
begin
Sum := 0;
for i := ii to jj do
begin
Sum := Sum + FHistogram[i];
end;
Result := Sum;
end;
function FuncOtsuB(ii,jj : Byte) : Single;
Var
Sum, i : Integer;
begin
Sum := 0;
for i := ii to jj do
begin
Sum := Sum + (i*FHistogram[i]);
end;
Result := Sum;
end;
procedure FindMinMax(var MinIdx, MaxIdx : Byte);
Var
f, MaxV, MinV : Single;
i, idxMin, idxMax : Byte;
begin
MaxV := 0;
MinV := 255; //1.0 ???
for i := 0 to 255 do
begin
f := v[i];
if f < MinV then
begin
MinV := f;
idxMin := i;
end;
if f > MaxV then
begin
MaxV := f;
idxMax := i;
end;
end;
MinIdx := idxMin;
MaxIdx := idxMax;
if idxMin > idxMax then
begin
MinIdx := idxMax;
MaxIdx := idxMin;
end;
end;
begin
MinThres := 0;
MaxThres := 255;
For k := 0 to 255 do
begin
p1 := FuncOtsuA(0, k);
p2 := FuncOtsuA(k + 1, 255);
p3 := p1 * p2;
if (p3 = 0) then p3 := 1;
Diff := (FuncOtsuB(0, k) * p2) - (FuncOtsuB(k + 1, 255) * p1);
v[k] := Diff * Diff / p3;
//v[k] := Math.Pow((FuncOtsuB(0, k) * p2) - (FuncOtsuB(k + 1, 255) * p1), 2) / p3;
end;
FindMinMax(MinThres, MaxThres);
end;
procedure TBZBitmapThresholdAutomaticFilter.DoInitializeScanner;
Var
thresMin, ThresMax : Byte;
begin
inherited DoInitializeScanner;
FScannerDescription := FScannerDescription + ' Otsu';
ComputeHistogram;
FMulti := False;
GetOtsuThreshold(thresMin, thresMax);
MinThreshold := thresMin;
MaxThreshold := thresMax;
end;
constructor TBZBitmapThresholdAutomaticFilter.Create(const AOwner : TBZBaseBitmap; const DirectWrite : Boolean);
begin
inherited Create(AOwner, DirectWrite);
FAutomaticThresholdMode := atmOtsu;
FScannerDescription := 'Seuiilage Otsu';
end;
{%endregion%}
end.
|
unit ProjectParserClasses;
interface
uses
System.Generics.Collections, System.Classes, System.SysUtils, System.IOUtils, Dialogs;
type
TUnitFile = class
private
FUnitFileName: string;
FUnitPath: string;
FClassVariable: string;
FUsesList: TStringList;
FTypesList: TStringList;
FUnitLinesCount :integer;
public
constructor Create;
destructor Destroy; override;
property UnitFileName: string read FUnitFileName write FUnitFileName;
property UnitPath: string read FUnitPath write FUnitPath;
property ClassVariable: string read FClassVariable write FClassVariable;
property UsesList: TStringList read FUsesList;
property TypesList: TStringList read FTypesList;
property UnitLinesCount: integer read FUnitLinesCount;
procedure Parse;
procedure ParseTypes;
end;
TUnitList = TList<TUnitFile>;
TProjectFile = class
private
FFullPath: string;
FTitle: string;
FUnits: TUnitList;
function GetFileName: string;
protected
function ParseItem(const AStr: string): TUnitFile;
public
constructor Create;
destructor Destroy; override;
property FullPath: string read FFullPath write FFullPath;
property FileName: string read GetFileName;
property Title: string read FTitle write FTitle;
property Units: TUnitList read FUnits write FUnits;
procedure ParseBlock(const ABlock: string);
procedure ParseTitle(const ABlock: string);
end;
TProjectsList = class(TList<TProjectFile>)
protected
function ParseFile(const APath: string): TProjectFile;
public
procedure ParseDirectory(const ADirectory: string; AIsRecursively: Boolean);
end;
function ProjectsList: TProjectsList;
const
CRLF = #10#13;
implementation
uses
UnitParserClasses;
var
FProjectsList: TProjectsList;
function ProjectsList: TProjectsList;
begin
Result := FProjectsList;
end;
{ TProjectFile }
constructor TProjectFile.Create;
begin
FUnits := TUnitList.Create;
end;
destructor TProjectFile.Destroy;
begin
FUnits.Free;
inherited;
end;
function TProjectFile.GetFileName: string;
begin
Result := TPath.GetFileNameWithoutExtension(FFullPath);
end;
function TProjectFile.ParseItem(const AStr: string): TUnitFile;
var
LData: string;
p: PChar;
s: string;
index: Integer;
pause: Boolean;
function PathCombine(a, b: string): string;
var
sl1, sl2: TStringList;
drive: string;
i: Integer;
begin
drive := '';
sl1 := TStringList.Create;
sl2 := TStringList.Create;
try
if a[2] = ':' then
begin
drive := a[1];
sl1.Delimiter := TPath.DirectorySeparatorChar;
sl1.DelimitedText := a.Substring(2);
end
else
sl1.DelimitedText := a;
sl2.Delimiter := TPath.DirectorySeparatorChar;
sl2.DelimitedText := b;
while (sl2.Count > 0) and (sl2[0] = '..') do
begin
sl1.Delete(sl1.Count - 1);
sl2.Delete(0);
end;
if not drive.IsEmpty then
Result := drive + ':';
for i := 0 to sl1.Count - 1 do
Result := Result + TPath.DirectorySeparatorChar + sl1[i];
for i := 0 to sl2.Count - 1 do
Result := Result + TPath.DirectorySeparatorChar + sl2[i];
finally
sl2.Free;
sl1.Free;
end;
end;
begin
LData := AStr.Trim + ' ';
p := PChar(LData);
Result := TUnitFile.Create;
index := 1;
pause := False;
s := '';
while (p^ <> #0) do
begin
if not pause then
s := s + p^;
if ((p^ = ' ') and (s[s.Trim.Length] <> ':')) or (p^ = #0) then
begin
s := s.Trim;
if s.Equals('in') then
s := ''
else
pause := True;
end;
if pause and not s.IsEmpty then
begin
case index of
1:
Result.UnitFileName := s;
2:
begin
if s.Trim[1] = '''' then
s := s.Substring(1);
if s.Trim[s.Trim.Length] = '''' then
s := s.Substring(0, s.Trim.Length - 1);
// if TPath.GetFileName(s) = s then
if (not s.IsEmpty) and (not((s[1] = '.') and (s[2] = '.'))) then
s := TPath.Combine(TPath.GetDirectoryName(FFullPath), s);
if (not s.IsEmpty) and ((s[1] = '.') and (s[2] = '.')) then
begin
s := PathCombine(TPath.GetDirectoryName(FFullPath), s);
end;
Result.UnitPath := s;
end;
3:
Result.ClassVariable := s;
end;
pause := False;
inc(index);
s := '';
end;
inc(p);
end;
if (Result.UnitPath.IsEmpty and Result.ClassVariable.IsEmpty) then
FreeAndNil(Result);
end;
procedure TProjectFile.ParseTitle(const ABlock: string);
var
s: string;
const
t = 'application.title';
begin
s := ABlock.Substring(Pos(t, ABlock.ToLower) + t.Length).Trim;
if (s[1] = ':') and (s[2] = '=') then
s := s.Substring(2).Trim;
if s[s.Length] = ';' then
s := s.Substring(0, s.Length - 1).Trim;
if (s[1] = '''') then
s := s.Substring(1, MaxInt);
if s[s.Length] = '''' then
s := s.Substring(0, s.Length - 1).Trim;
FTitle := s;
end;
procedure TProjectFile.ParseBlock(const ABlock: string);
var
TempStr: string;
p: PChar;
LUnitInfo: TUnitFile;
LWaitParsing: Boolean;
LStr: string;
begin
TempStr := ABlock.Trim;
if Pos(TempStr, 'uses') = 0 then
TempStr := TempStr.Substring(4).Trim;
p := PChar(TempStr);
LStr := '';
while (p^ <> #0) do
begin
LWaitParsing := (p^ = ',') or (p^ = ';');
if not LWaitParsing then
LStr := LStr + p^;
if LWaitParsing then
begin
LUnitInfo := ParseItem(LStr);
if Assigned(LUnitInfo) then
begin
LUnitInfo.Parse;
LUnitInfo.ParseTypes;
FUnits.Add(LUnitInfo);
end;
LStr := '';
end;
inc(p);
end;
end;
{ TProjectsList }
procedure TProjectsList.ParseDirectory(const ADirectory: string;
AIsRecursively: Boolean);
var
LDirectories: TArray<string>;
LFiles: TArray<string>;
LCurrentPath: string;
LPF: TProjectFile;
begin
if AIsRecursively then
begin
LDirectories := TDirectory.GetDirectories(ADirectory);
for LCurrentPath in LDirectories do
ParseDirectory(LCurrentPath, True);
end;
LFiles := TDirectory.GetFiles(ADirectory, '*.dpr');
for LCurrentPath in LFiles do
begin
LPF := ParseFile(LCurrentPath);
Add(LPF);
end;
end;
function TProjectsList.ParseFile(const APath: string): TProjectFile;
var
LRowUsesList: TStringList;
LFileData: TStringList;
i: Integer;
LParsingStarted: Boolean;
LBlock: string;
LIsTitleFound: Boolean;
begin
Result := TProjectFile.Create;
LParsingStarted := False;
LBlock := '';
LRowUsesList := nil;
LFileData := nil;
try
LFileData := TStringList.Create;
LRowUsesList := TStringList.Create;
if TFile.Exists(APath) then
begin
LFileData.LoadFromFile(APath);
Result.FullPath := APath;
LIsTitleFound := False;
for i := 0 to Pred(LFileData.Count) do
begin
// uses
if (not LParsingStarted) and (Pos(LFileData[i].Trim.ToLower, 'uses') > 0)
then
LParsingStarted := True;
if LParsingStarted then
begin
LBlock := LBlock + LFileData[i] + CRLF;
if LFileData[i].IndexOf(';') > 0 then
LParsingStarted := False;
end;
if (not LParsingStarted) and (not LBlock.IsEmpty) then
begin
Result.ParseBlock(LBlock);
LBlock := '';
end;
// Application.Title
if not LIsTitleFound then
begin
if (Pos('application.title', LFileData[i].Trim.ToLower) > 0) then
begin
Result.ParseTitle(LFileData[i]);
LIsTitleFound := not Result.Title.IsEmpty;
end;
end;
end;
end;
finally
LRowUsesList.Free;
LFileData.Free
end;
end;
{ TUnitFile }
constructor TUnitFile.Create;
begin
FUsesList := TStringList.Create;
FTypesList := TStringList.Create;
end;
destructor TUnitFile.Destroy;
begin
FTypesList.Free;
FUsesList.Free;
inherited;
end;
procedure TUnitFile.Parse;
var
sl: TStringList;
begin
// sl := TStringList.Create;
// try
// sl.LoadFromFile(TPath.Combine(TPath.GetLibraryPath, 'Components/DefaultZ.txt'));
UnitParser.ParseFile(FUnitPath, FUsesList, FUnitLinesCount );
ShowMessage(inttostr(FUnitLinesCount));
// UnitParser.RemoveProjectUnits(FUsesList, sl);
// finally
// sl.Free;
// end;
end;
procedure TUnitFile.ParseTypes;
begin
UnitParser.ParseTypes(FUnitPath, FUsesList);
end;
initialization
FProjectsList := TProjectsList.Create;
finalization
FProjectsList.Free;
end.
|
{
ID: ndchiph1
PROG: kimbits
LANG: PASCAL
}
uses math;
const
maxN = 35;
var
fi,fo: text;
n,l: longint;
s: int64;
res: array[1..maxN] of longint;
c: array[0..maxN,0..maxN] of int64;
procedure input;
begin
readln(fi,n,l,s);
end;
procedure init;
var
i,j: longint;
begin
//
c[0,0]:= 1;
for i:= 1 to 31 do
begin
c[0,i]:= 1; c[i,i]:= 1;
for j:= 1 to i-1 do c[j,i]:= c[j,i-1] + c[j-1,i-1];
end;
//
for i:= 1 to 31 do
for j:= 1 to i do
c[j,i]:= c[j,i] + c[j-1,i];
//
for i:= 0 to 31 do
for j:= i+1 to 31 do
c[j,i]:= c[i,i];
end;
procedure process;
var
i,t: longint;
begin
t:= n;
while (t > 0) do
begin
if (s > c[l,t-1]) then
begin
res[t]:= 1;
dec(s,c[l,t-1]);
dec(l);
end;
dec(t);
end;
for i:= n downto 1 do write(fo,res[i]);
writeln(fo);
end;
begin
assign(fi,'kimbits.in'); reset(fi);
assign(fo,'kimbits.out'); rewrite(fo);
//
input;
init;
process;
//
close(fi);
close(fo);
end.
|
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,strUtils;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
procedure Shuffle(var a:array of integer);
var i,i1,i2:integer;
temp:integer;
begin
for i:=0 to length(a)*10 do
begin
repeat
i1:=random(length(a));
i2:=random(length(a));
until (i1 <> i2);
temp:=a[i1];
a[i1]:=a[i2];
a[i2]:=temp;
end;
end;
procedure BubblesortIntArrAsc(var a:array of integer); //from Low to High values
var
i,j:integer;
temp:integer;
begin
for i:=low(a) to high(a) do
for j:=low(a) to high(a)-1 do
begin
if (a[j] > a[j+1]) then
begin //swap 2 integers in the array
temp:=a[j];
a[j]:=a[j+1];
a[j+1]:=temp;
end;
end;
end;
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var i,j,k,m,n:integer;
a:array of integer;
s:string;
e:array of array of integer;
begin
memo1.text := '';
setlength(a,35);
for i:=0 to 34 do
begin
a[i] := i+1;
end;
shuffle(a);
//assign 1D vector to 2D array here
setlength(e,1);
m:=0; n:=0;
for i:=0 to 6 do // 7 lines in all
begin
setlength(e[i],1);
k:=0;
for j:=0 to 4 do // 5 numbers per line
begin
e[i,j]:=a[n];
inc(n);
inc(k);
setlength(e[i],k+1);
end;
inc(m);
setlength(e,m+1);
end;
//reset lengths here
setlength(e,m);
// &...
for i:=0 to length(e)-1 do
setlength(e[i],k);
for i:=0 to length(e)-1 do
bubblesortintarrasc(e[i]); //sort each number line
//display them unique number combos on screen
s:='';
for i:=0 to length(e)-1 do
begin
s:=s+inttostr(i+1)+'. ';
for j:=0 to length(e[i])-1 do
begin
s:=s+ ifthen(e[i,j]<10, '0'+inttostr(e[i,j]), inttostr(e[i,j])) + ',';
end;
delete(s,length(s),1);
s:=s+'.'+#13#10;
end;
memo1.text:=s; //display the string
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
randomize; //once in the program is enough!
end;
end.
|
unit uEventManager;
interface
uses
Classes;
type
TEvents = class;
// TEventManager = class;
TEvents = class
private
FEvents: array of TNotifyEvent;
public
procedure RegEvent(aEvent: TNotifyEvent);
procedure UnregEvent(aEvent: TNotifyEvent);
procedure ClearEvents;
function EventRegistered(aEvent: TNotifyEvent): Boolean;
procedure DoEvents;
destructor Destroy; override;
end;
// TEventManager = class
// procedure AddToReg(_Event: TEvents; _Method: TMethod);
// procedure RemoveFromReg(_Event: TEvents; _Method: TMethod);
// procedure RegEvents; overload;
// procedure UnregEvents; overload;
// end;
implementation
{ TEventManager }
procedure TEvents.ClearEvents;
var
I: Integer;
begin
for I := 0 to High(FEvents) do
FEvents[I] := nil;
SetLength(FEvents, 0);
end;
destructor TEvents.Destroy;
begin
ClearEvents;
inherited;
end;
procedure TEvents.DoEvents;
var
I: Integer;
begin
for I := 0 to High(FEvents) do
if i < Length(FEvents) then
FEvents[I](Self)
else
break;
end;
function TEvents.EventRegistered(aEvent: TNotifyEvent): Boolean;
var
I: Integer;
begin
// Методы объектов вполне допустимо приводить к TMethod для сравнения
Result := True;
for I := 0 to High(FEvents) do
if (TMethod(aEvent).Code = TMethod(FEvents[I]).Code) and (TMethod(aEvent).Data = TMethod(FEvents[I]).Data) then
Exit;
Result := False;
end;
procedure TEvents.RegEvent(aEvent: TNotifyEvent);
var
I: Integer;
begin
if EventRegistered(aEvent) then
Exit;
I := Length(FEvents);
SetLength(FEvents, I + 1);
FEvents[I] := aEvent;
end;
procedure TEvents.UnregEvent(aEvent: TNotifyEvent);
var
I: Integer;
vDel: Boolean;
begin
// Дублей обработчиков быть не может (эта проверка реализуется в RegisterEvent)
vDel := False;
for I := 0 to High(FEvents) do
if vDel then
FEvents[I - 1] := FEvents[I]
else if (TMethod(aEvent).Code = TMethod(FEvents[I]).Code) and (TMethod(aEvent).Data = TMethod(FEvents[I]).Data) then
vDel := True;
if vDel then
SetLength(FEvents, Length(FEvents) - 1);
end;
end.
|
unit OptionsDBMSOutput;
interface
uses
System.SysUtils, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls,
Vcl.ComCtrls, BCCommon.OptionsContainer, BCFrames.OptionsFrame;
type
TOptionsDBMSOutputFrame = class(TOptionsFrame)
Panel: TPanel;
PollingIntervalLabel: TLabel;
PollingIntervalTrackBar: TTrackBar;
procedure PollingIntervalTrackBarChange(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
destructor Destroy; override;
procedure GetData; override;
procedure PutData; override;
end;
function OptionsDBMSOutputFrame(AOwner: TComponent): TOptionsDBMSOutputFrame;
implementation
{$R *.dfm}
var
FOptionsDBMSOutputFrame: TOptionsDBMSOutputFrame;
function OptionsDBMSOutputFrame(AOwner: TComponent): TOptionsDBMSOutputFrame;
begin
if not Assigned(FOptionsDBMSOutputFrame) then
FOptionsDBMSOutputFrame := TOptionsDBMSOutputFrame.Create(AOwner);
Result := FOptionsDBMSOutputFrame;
end;
destructor TOptionsDBMSOutputFrame.Destroy;
begin
inherited;
FOptionsDBMSOutputFrame := nil;
end;
procedure TOptionsDBMSOutputFrame.PollingIntervalTrackBarChange(Sender: TObject);
begin
PollingIntervalLabel.Caption := Format('Polling interval: %d second ', [
PollingIntervalTrackBar.Position]);
end;
procedure TOptionsDBMSOutputFrame.PutData;
begin
OptionsContainer.PollingInterval := PollingIntervalTrackBar.Position;
end;
procedure TOptionsDBMSOutputFrame.GetData;
begin
PollingIntervalTrackBar.Position := OptionsContainer.PollingInterval;
end;
end.
|
unit dco.rpc.jsonrpc.EncoderTest;
{
Delphi DUnit Test Case
----------------------
This unit contains a skeleton test case class generated by the Test Case Wizard.
Modify the generated code to correctly setup and call the methods from the unit
being tested.
}
interface
uses
TestFramework, superobject,
dco.rpc.ErrorObject,
dco.rpc.Identifier,
dco.rpc.jsonrpc.Encoder;
type
// Test methods for class TEncoder
TEncoderTest = class(TTestCase)
strict private
FEncoder: TEncoder;
public
procedure SetUp; override;
procedure TearDown; override;
published
procedure TestEncodeRequest;
procedure TestEncodeNotification;
procedure TestEncodeResponse;
procedure TestEncodeResponseError;
end;
implementation
procedure TEncoderTest.SetUp;
begin
FEncoder := TEncoder.Create;
end;
procedure TEncoderTest.TearDown;
begin
FEncoder.Free;
FEncoder := nil;
end;
procedure TEncoderTest.TestEncodeRequest;
var
ReturnValue: string;
Id: TIdentifier;
Params: ISuperObject;
Method: string;
begin
Id := TIdentifier.NumberIdentifier(1);
Params := SA([SO(2), SO(3), SO(7)]);
Method := 'multiply';
ReturnValue := FEncoder.EncodeRequest(Method, Params, Id);
CheckEquals('{"method":"multiply","params":[2,3,7],"id":1,"jsonrpc":"2.0"}', ReturnValue);
end;
procedure TEncoderTest.TestEncodeNotification;
var
ReturnValue: string;
Params: ISuperObject;
Method: string;
begin
Params := SO(['progress', 0.0]);
Method := 'progress';
ReturnValue := FEncoder.EncodeNotification(Method, Params);
CheckEquals('{"method":"progress","params":{"progress":0},"jsonrpc":"2.0"}', ReturnValue);
end;
procedure TEncoderTest.TestEncodeResponse;
var
ReturnValue: string;
Id: TIdentifier;
Result_: ISuperObject;
begin
Id := TIdentifier.NumberIdentifier(1);
Result_ := SO(42);
ReturnValue := FEncoder.EncodeResponse(Result_, Id);
CheckEquals('{"result":42,"id":1,"jsonrpc":"2.0"}', ReturnValue);
end;
procedure TEncoderTest.TestEncodeResponseError;
var
ReturnValue: string;
Id: TIdentifier;
Error: TErrorObject;
begin
Id := TIdentifier.NullIdentifier;
Error := TErrorObject.CreateInvalidRequest('don''t panic');
ReturnValue := FEncoder.EncodeResponse(Error, Id);
CheckEquals('{"id":null,"error":{"message":"Invalid request","data":"don''t panic","code":-32600},"jsonrpc":"2.0"}',
ReturnValue);
end;
initialization
// Register any test cases with the test runner
RegisterTest(TEncoderTest.Suite);
end.
|
{ *********************************************************************** }
{ }
{ Win11Forms 单元 }
{ }
{ 设计:Lsuper 2022.01.01 }
{ 备注: }
{ 参考:https://github.com/marcocantu/DelphiSessions Win11Forms.pas }
{ }
{ Copyright (c) 1998-2022 Super Studio }
{ }
{ *********************************************************************** }
unit Win11Forms;
interface
uses
System.SysUtils, Winapi.Windows, VCL.Forms;
type
TRoundedCornerType = (
rcDefault, // Windows default or global app setting
rcOff, // disabled
rcOn, // active
rcSmall // active small size
);
TForm = class(VCL.Forms.TForm)
private
FRoundedCorners: TRoundedCornerType;
FTitleDarkMode: Boolean;
private
class var FDefaultRoundedCorners: TRoundedCornerType;
private
function GetFormCornerPreference: Integer;
procedure SetRoundedCorners(const Value: TRoundedCornerType);
procedure SetTitleDarkMode(const Value: Boolean);
procedure UseImmersiveDarkMode(AHandle: HWND; AEnabled: Boolean);
private
procedure UpdateRoundedCorners;
procedure UpdateTitleDarkMode;
protected
procedure CreateWnd; override;
public
class property DefaultRoundedCorners: TRoundedCornerType
read FDefaultRoundedCorners write FDefaultRoundedCorners;
property RoundedCorners: TRoundedCornerType
read FRoundedCorners write SetRoundedCorners;
property TitleDarkMode: Boolean
read FTitleDarkMode write SetTitleDarkMode;
end;
implementation
uses
Winapi.Dwmapi;
const
DWMWCP_DEFAULT = 0; // Let the system decide whether or not to round window corners (default)
DWMWCP_DONOTROUND = 1; // Never round window corners
DWMWCP_ROUND = 2; // Round the corners if appropriate
DWMWCP_ROUNDSMALL = 3; // Round the corners if appropriate, with a small radius
{ TForm }
procedure TForm.CreateWnd;
begin
inherited;
UpdateRoundedCorners;
UpdateTitleDarkMode;
end;
function TForm.GetFormCornerPreference: Integer;
function RoundedCornerPreference(ACornerType: TRoundedCornerType): Integer;
begin
case ACornerType of
rcOff: Result := DWMWCP_DONOTROUND;
rcOn: Result := DWMWCP_ROUND;
rcSmall: Result := DWMWCP_ROUNDSMALL;
else
Result := DWMWCP_DEFAULT;
end;
end;
begin
if FRoundedCorners = rcDefault then
Result := RoundedCornerPreference(FDefaultRoundedCorners)
else Result := RoundedCornerPreference(FRoundedCorners);
end;
procedure TForm.SetRoundedCorners(const Value: TRoundedCornerType);
begin
FRoundedCorners := Value;
UpdateRoundedCorners;
end;
procedure TForm.SetTitleDarkMode(const Value: Boolean);
begin
FTitleDarkMode := Value;
UpdateTitleDarkMode;
end;
procedure TForm.UpdateRoundedCorners;
const
DWMWA_WINDOW_CORNER_PREFERENCE = 33; // WINDOW_CORNER_PREFERENCE controls the policy that rounds top-level window corners
var
CornerPreference: Integer;
begin
if HandleAllocated then
begin
CornerPreference := GetFormCornerPreference;
Winapi.Dwmapi.DwmSetWindowAttribute(Handle, DWMWA_WINDOW_CORNER_PREFERENCE, @CornerPreference, SizeOf(CornerPreference));
end;
end;
procedure TForm.UpdateTitleDarkMode;
begin
if HandleAllocated then
begin
UseImmersiveDarkMode(Handle, FTitleDarkMode);
end;
end;
////////////////////////////////////////////////////////////////////////////////
//设计:Lsuper 2021.12.10
//功能:
//参数:
//参考:https://stackoverflow.com/questions/57124243/winforms-dark-title-bar-on-windows-10
////////////////////////////////////////////////////////////////////////////////
procedure TForm.UseImmersiveDarkMode(AHandle: HWND; AEnabled: Boolean);
const
DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19;
DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
var
AB: Integer;
DM: Integer;
begin
if CheckWin32Version(10) and (TOSVersion.Build >= 17763) then
begin
AB := DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1;
if TOSVersion.Build >= 18985 then
AB := DWMWA_USE_IMMERSIVE_DARK_MODE;
if AEnabled then
DM := 1
else DM := 0;
Winapi.Dwmapi.DwmSetWindowAttribute(AHandle, AB, @DM, SizeOf(DM));
end;
end;
end.
|
unit CatChromiumLib;
{
Catarinka Browser Component
Copyright (c) 2011-2015 Syhunt Informatica
License: 3-clause BSD
See https://github.com/felipedaragon/catarinka/ for details
}
interface
{$I Catarinka.inc}
uses
{$IFDEF DXE2_OR_UP}
System.Classes, Winapi.Windows, Winapi.Messages, Vcl.Controls, Vcl.Graphics,
Vcl.Forms, System.SysUtils, System.SyncObjs, Vcl.Dialogs, Vcl.Clipbrd,
System.TypInfo, Vcl.StdCtrls, Vcl.ExtCtrls, System.UITypes,
{$ELSE}
Classes, Windows, Messages, Controls, Graphics, Forms, SysUtils, SyncObjs,
Dialogs, Clipbrd, TypInfo, StdCtrls, ExtCtrls,
{$ENDIF}
{$IFDEF USEWACEF}
WACefComponent, WACefInterfaces, WACefTypes, WACefOwns, WACefCExports,
WACefLib, WACefRefs,
{$ELSE}
cefgui, cefvcl, ceflib,
{$ENDIF}
superobject, CatJSON, CatMsg;
{$IFDEF USEWACEF}
type
TChromium = TWAChromium;
TCustomChromiumOSR = TWAChromiumOSR;
{$ENDIF}
type
TCatChromiumOnBrowserMessage = procedure(const msg: integer;
const str: string) of object;
TCatChromiumOnAfterSetSource = procedure(const s: string) of object;
TCatChromiumOnTitleChange = procedure(Sender: TObject; const title: string)
of object;
TCatChromiumOnLoadEnd = procedure(Sender: TObject; httpStatusCode: integer)
of object;
TCatChromiumOnLoadStart = procedure(Sender: TObject) of object;
TCatChromiumOnAddressChange = procedure(Sender: TObject; const url: string)
of object;
TCatChromiumOnStatusMessage = procedure(Sender: TObject; const value: string)
of object;
// TCatChromiumOnRequestComplete = procedure(const s:string) of object;
TCatChromiumOnBeforePopup = procedure(Sender: TObject; var url: string;
out Result: Boolean) of object;
TCatChromiumOnConsoleMessage = procedure(Sender: TObject;
const message, source: string; line: integer) of object;
TCatChromiumOnBeforeResourceLoad = procedure(Sender: TObject;
const request: ICefRequest; out Result: Boolean) of object;
TCatChromiumOnBeforeDownload = procedure(Sender: TObject; const id: integer;
const suggestedName: string) of object;
TCatChromiumOnDownloadUpdated = procedure(Sender: TObject;
var cancel: Boolean; const id, state, percentcomplete: integer;
const fullPath: string) of object;
TCatChromiumOnLoadingStateChange = procedure(Sender: TObject;
const isLoading, canGoBack, canGoForward: Boolean) of object;
TCatChromiumOnLoadError = procedure(Sender: TObject; const errorCode: integer;
const errorText, failedUrl: string) of object;
TCatChromiumOnCertificateError = procedure(Sender: TObject;
aCertError: TCefErrorCode; const aRequestUrl: ustring;
const aSslInfo: ICefSslinfo; const aCallback: ICefRequestCallback;
out Result: Boolean) of object;
type
TCatRequestHeaders = record
StatusCode: string;
SentHead: string;
RcvdHead: string;
end;
type
TCatChromiumRequest = record
Method: string;
url: string;
PostData: string;
Headers: string;
IgnoreCache: Boolean;
UseCachedCredentials: Boolean;
UseCookies: Boolean;
Details: string;
end;
type
TSpecialCEFReq = class(TCefUrlRequestClientOwn)
private
fr: ISuperObject;
fCriticalSection: TCriticalSection;
fLogged: Boolean;
fResponseStream: TMemoryStream;
function CEF_GetPostData(request: ICefRequest): string;
function CEF_GetSentHeader(request: ICefRequest;
IncludePostData: Boolean = true): string;
function CEF_GetRcvdHeader(Response: ICefResponse): string;
protected
procedure OnRequestComplete(const request: ICefUrlRequest); override;
procedure OnDownloadData(const request: ICefUrlRequest;
{$IFDEF USEWACEF}const
{$ENDIF} data: Pointer; dataLength: NativeUInt); override;
public
MsgHandle: HWND;
Details: string;
constructor Create; override;
destructor Destroy; override;
end;
type
TCatDevTools = class(TCustomControl)
private
{$IFNDEF USEWACEF}
fDevTools: TChromiumDevTools;
{$ENDIF}
fTitlePanel: TPanel;
fCloseBtn: TButton;
fSplitter: TSplitter;
procedure CloseBtnClick(Sender: TObject);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure View(browser: ICefBrowser);
property Splitter: TSplitter read fSplitter write fSplitter;
end;
const
cURL_ABOUTBLANK = 'about:blank';
cURL_HOME = 'sandcat:home';
cOptions = 'chrome.options.';
const // Messages from the Chromium renderer to the Sandcat Tab object
CRM_LOG_REQUEST_JSON = 1;
CRM_RENDER_PROCESSTERMINATED = 3;
CRM_NEWTAB = 4;
CRM_JS_ALERT = 10;
CRM_NEWPAGERESOURCE = 11;
CRM_SAVECACHEDRESOURCE = 12;
CRM_SEARCHWITHENGINE = 13;
CRM_SEARCHWITHENGINE_INNEWTAB = 14;
CRM_NEWTAB_INBACKGROUND = 15;
CRM_SAVECLOUDRESOURCE = 16;
CRM_BOOKMARKURL = 17;
const // Messages from the Sandcat tab to the Chromium renderer object
SCTM_SET_V8_MSGHANDLE = 1;
SCTM_V8_REGISTEREXTENSION = 2;
const // Download related
SCD_UNKNOWN = 0;
SCD_INPROGRESS = 1;
SCD_COMPLETE = 2;
SCD_CANCELED = 3;
const // Shutdown modes
SHTD_STANDARD = 10;
SHTD_FORCED = 11;
SHTD_MANUAL = 12;
const // Context menu options
CRMMENU_ID_USER_FIRST = integer(MENU_ID_USER_FIRST);
CRMMENU_ID_OPENIMAGE = CRMMENU_ID_USER_FIRST;
CRMMENU_ID_OPENIMAGE_INNEWTAB = CRMMENU_ID_USER_FIRST + 1;
CRMMENU_ID_COPYIMAGEADDRESS = CRMMENU_ID_USER_FIRST + 2;
CRMMENU_ID_SAVEIMAGEAS = CRMMENU_ID_USER_FIRST + 3;
CRMMENU_ID_OPENLINK = CRMMENU_ID_USER_FIRST + 4;
CRMMENU_ID_OPENLINK_INNEWTAB = CRMMENU_ID_USER_FIRST + 5;
CRMMENU_ID_COPYADDRESS = CRMMENU_ID_USER_FIRST + 6;
CRMMENU_ID_SEARCH = CRMMENU_ID_USER_FIRST + 7;
CRMMENU_ID_SEARCH_INNEWTAB = CRMMENU_ID_USER_FIRST + 8;
CRMMENU_ID_LINK_COPYADDRESS = CRMMENU_ID_USER_FIRST + 9;
CRMMENU_ID_OPENLINK_INBGTAB = CRMMENU_ID_USER_FIRST + 10;
CRMMENU_ID_FRAMEMENU = CRMMENU_ID_USER_FIRST + 11;
CRMMENU_ID_FRAMEMENU_OPEN = CRMMENU_ID_USER_FIRST + 12;
CRMMENU_ID_FRAMEMENU_OPEN_INNEWTAB = CRMMENU_ID_USER_FIRST + 13;
CRMMENU_ID_FRAMEMENU_OPEN_INBGTAB = CRMMENU_ID_USER_FIRST + 14;
CRMMENU_ID_FRAMEMENU_COPYADDRESS = CRMMENU_ID_USER_FIRST + 15;
CRMMENU_ID_PAGE_SAVEAS = CRMMENU_ID_USER_FIRST + 16;
CRMMENU_ID_LINK_SAVEAS = CRMMENU_ID_USER_FIRST + 17;
CRMMENU_ID_PAGE_BOOKMARK = CRMMENU_ID_USER_FIRST + 18;
CRMMENU_ID_LINK_BOOKMARK = CRMMENU_ID_USER_FIRST + 19;
function CertErrorCodeToErrorName(c: TCefErrorCode): string;
function CreateCEFPOSTField(const str: String): ICefPostDataElement;
function GetCEFUserAgent: string;
function GetCEFDefaults(settings: TCatJSON): string;
function CEFStateToBool(s: TCefState): Boolean;
function CEFV8ValueToStr(v: ICefv8Value): string;
function DownloadStateToStr(i: integer): string;
function StrToCefString(s: ustring): TCefString;
function StrToCEFV8Value(const s: string): ICefv8Value;
function BuildRequest(Method, url: string; PostData: string = '')
: TCatChromiumRequest;
function CatCEFLoadLib: Boolean;
procedure CatCEFShutdown(mode: integer);
function SaveResponseToFile(s: string): string;
implementation
uses CatTasks, CatStrings, CatHTTP, CatTime, CatMsgCromis;
var
TempFileCount: integer = 0;
function CatCEFLoadLib: Boolean;
begin
{$IFDEF USEWACEF}
TWACef.Initialize;
{$ENDIF}
Result := {$IFDEF USEWACEF}TWACef.LoadLib{$ELSE}CefLoadLibDefault{$ENDIF};
end;
function BuildRequest(Method, url: string; PostData: string = '')
: TCatChromiumRequest;
begin
Result.Method := Method;
Result.url := url;
Result.PostData := PostData;
Result.Headers := emptystr;
Result.IgnoreCache := true;
Result.UseCookies := true;
Result.UseCachedCredentials := true;
Result.Details := emptystr;
end;
procedure CatCEFShutdown(mode: integer);
begin
case mode of
SHTD_STANDARD:
; // do nothing
SHTD_FORCED:
KillProcessbyPID(GetCurrentProcessId);
SHTD_MANUAL:
begin
{$IFDEF USEWACEF}
cef_shutdown;
{$ELSE}
ceflib.CefShutDown;
{$ENDIF}
ExitProcess(0);
end;
end;
end;
function CertErrorCodeToErrorName(c: TCefErrorCode): string;
begin
case c of
ERR_CERT_COMMON_NAME_INVALID:
Result := 'Certificate common name invalid.';
ERR_CERT_DATE_INVALID:
Result := 'Certificate date invalid.';
ERR_CERT_AUTHORITY_INVALID:
Result := 'Certificate authority invalid.';
ERR_CERT_CONTAINS_ERRORS:
Result := 'Certificate contains errors.';
ERR_CERT_NO_REVOCATION_MECHANISM:
Result := 'No certificate revocation mechanism.';
ERR_CERT_UNABLE_TO_CHECK_REVOCATION:
Result := 'Unable to check certificate revocation.';
ERR_CERT_REVOKED:
Result := 'Certificate revoked.';
ERR_CERT_INVALID:
Result := 'Invalid certificate.';
ERR_CERT_END:
Result := 'Certificate end.';
end;
end;
function CreateCEFPOSTField(const str: String): ICefPostDataElement;
begin
Result := TCefPostDataElementRef.New;
Result.SetToBytes(Length(AnsiString(str)), PAnsiChar(AnsiString(str)));
end;
function StrToCefString(s: ustring): TCefString;
begin
Result := {$IFDEF USEWACEF}TWACef.ToCefString{$ELSE}CefString{$ENDIF}(s);
end;
function StrToCEFV8Value(const s: string): ICefv8Value;
begin
Result := TCefv8ValueRef.{$IFDEF USEWACEF}CreateString{$ELSE}NewString{$ENDIF}(s);
end;
function CEFV8ValueToStr(v: ICefv8Value): string;
begin
Result := emptystr;
if v.IsString then
Result := v.GetStringValue
else
begin
if v.IsUndefined then
Result := 'undefined'
else if v.IsNull then
Result := 'null'
else if v.IsBool then
begin
if v.GetBoolValue = true then
Result := 'true'
else
Result := 'false';
end
else if v.IsInt then
Result := inttostr(v.GetIntValue)
else if v.IsUInt then
Result := inttostr(v.GetUIntValue)
else if v.IsDouble then
Result := floattostr(v.GetDoubleValue)
// else if v.IsDate then
// Result := datetimetostr(v.GetDateValue)
else if v.IsObject then
Result := '[object]'
else if v.IsArray then
Result := '[array]'
else if v.IsFunction then
Result := '[function ' + v.GetFunctionName + ']';
end;
end;
function CEFStateToStr(s: TCefState): string;
begin
Result := emptystr;
case s of
STATE_ENABLED:
Result := 'Enabled';
STATE_DISABLED:
Result := 'Disabled';
STATE_DEFAULT:
Result := 'Default';
end;
end;
function CEFStateToBool(s: TCefState): Boolean;
begin
Result := true;
case s of
STATE_ENABLED:
Result := true;
STATE_DISABLED:
Result := false;
STATE_DEFAULT:
Result := true; // currently all Chromium options are true by default
end;
end;
function DownloadStateToStr(i: integer): string;
begin
case i of
SCD_INPROGRESS:
Result := 'inprogress';
SCD_CANCELED:
Result := 'canceled';
SCD_COMPLETE:
Result := 'complete';
end;
end;
function GetCEFDefaults(settings: TCatJSON): string;
var
sl: TStringList;
Count, Size, i: integer;
List: PPropList;
PropInfo: PPropInfo;
CID: string;
opt: TChromiumOptions;
begin
sl := TStringList.Create;
opt := TChromiumOptions.Create;
Count := GetPropList(opt.ClassInfo, tkAny, nil);
Size := Count * SizeOf(Pointer);
GetMem(List, Size);
try
Count := GetPropList(opt.ClassInfo, tkAny, List);
for i := 0 to Count - 1 do
begin
PropInfo := List^[i];
if PropInfo^.PropType^.Name = 'TCefState' then
begin
CID := cOptions + lowercase(string(PropInfo^.Name));
// currently all Chromium options are true by default
settings[CID] := true;
sl.Add(CID);
end;
end;
finally
FreeMem(List);
end;
opt.Free;
Result := sl.text;
sl.Free;
end;
function GetCEFCacheDir: string;
begin
{$IFDEF USEWACEF}
Result := CefCachePath;
{$ELSE}
Result := CefCache;
{$ENDIF}
end;
function GetCEFUserAgent: string;
begin
Result := CefUserAgent;
end;
function GetTempFile: string;
var
f: string;
begin
TempFileCount := TempFileCount + 1;
f := inttostr(GetCurrentProcessId) + ' - ' + inttostr(DateTimeToUnix(now)) +
'-' + inttostr(TempFileCount) + '.tmp';
Result := GetCEFCacheDir + 'Headers\' + f;
end;
function SaveResponseToFile(s: string): string;
var
sl: TStringList;
begin
Result := GetTempFile;
if GetCEFCacheDir = emptystr then
exit;
sl := TStringList.Create;
sl.text := s;
sl.SaveToFile(Result);
sl.Free;
end;
// ------------------------------------------------------------------------//
// TSpecialCEFReq //
// ------------------------------------------------------------------------//
function TSpecialCEFReq.CEF_GetRcvdHeader(Response: ICefResponse): string;
var
i: integer;
s, kv, lastkv: string;
Map: ICefStringMultimap;
procedure Add(key, value: string);
begin
kv := key + ': ' + value;
if kv <> lastkv then
s := s + crlf + kv; // Workaround: CEF3 sometimes returns repeated headers
lastkv := kv;
end;
begin
Map := TCefStringMultiMapOwn.Create;
Response.GetHeaderMap(Map);
s := 'HTTP/1.1 ' + inttostr(Response.getStatus) + ' ' +
Response.GetStatusText;
with Map do
begin
for i := 0 to GetSize do
begin
if i < GetSize then
Add(GetKey(i), GetValue(i));
end;
end;
Result := s;
end;
function TSpecialCEFReq.CEF_GetSentHeader(request: ICefRequest;
IncludePostData: Boolean = true): string;
var
i: integer;
s, PostData, kv, lastkv: string;
Map: ICefStringMultimap;
procedure Add(key, value: string);
begin
kv := key + ': ' + value;
if kv <> lastkv then
s := s + crlf + kv; // Workaround: CEF3 sometimes returns repeated headers
lastkv := kv;
end;
begin
Map := TCefStringMultiMapOwn.Create;
request.GetHeaderMap(Map);
s := request.getMethod + ' /' + ExtractUrlPath(request.GetURL) + ' HTTP/1.1';
with Map do
begin
if FindCount('Host') = 0 then
Add('Host', ExtractURLHost(request.GetURL));
for i := 0 to GetSize do
begin
if i < GetSize then
Add(GetKey(i), GetValue(i));
end;
end;
if (IncludePostData) and (request.getMethod = 'POST') then
begin
PostData := CEF_GetPostData(request);
if PostData <> emptystr then
begin
s := s + crlf;
s := s + crlf + PostData;
end;
end;
Result := s + crlf;
end;
function TSpecialCEFReq.CEF_GetPostData(request: ICefRequest): string;
var
i: integer;
ansi, datastr: AnsiString;
postElement: ICefPostDataElement;
PostData: ICefPostData;
List: IInterfaceList;
elcount: NativeUInt;
begin
ansi := '';
PostData := request.getPostData;
if PostData <> nil then
begin
elcount := PostData.{$IFDEF USEWACEF}GetElementCount{$ELSE}GetCount{$ENDIF};
{$IFDEF USEWACEF}
// FIXME: WACEF branch 2357 is crashing when trying to get POST elements
try
List := PostData.GetElements(elcount);
except
end;
{$ELSE}
List := PostData.GetElements(elcount);
{$ENDIF}
for i := 0 to List.Count - 1 do
begin
postElement := List[i] as ICefPostDataElement;
case postElement.GetType of
PDE_TYPE_BYTES: // ToDo: handle PDE_TYPE_FILE and PDE_TYPE_EMPTY
begin
SetLength(datastr, postElement.GetBytesCount);
postElement.GetBytes(postElement.GetBytesCount, PAnsiChar(datastr));
ansi := ansi + datastr;
end;
end;
end;
end;
Result := string(ansi);
end;
constructor TSpecialCEFReq.Create;
begin
inherited Create;
fCriticalSection := TCriticalSection.Create;
fCriticalSection.Enter;
fResponseStream := TMemoryStream.Create;
fLogged := false;
end;
destructor TSpecialCEFReq.Destroy;
begin
fResponseStream.Free;
fCriticalSection.Free;
inherited;
end;
procedure TSpecialCEFReq.OnDownloadData(const request: ICefUrlRequest;
{$IFDEF USEWACEF}const {$ENDIF} data: Pointer; dataLength: NativeUInt);
begin
{$IFDEF DXE3_OR_UP}
fResponseStream.WriteData(data, dataLength);
{$ELSE}
fResponseStream.Write(data, dataLength);
{$ENDIF}
inherited;
end;
procedure TSpecialCEFReq.OnRequestComplete(const request: ICefUrlRequest);
var
req: ICefRequest;
resp: ICefResponse;
var
SentHead, RcvdHead, referrer, respfilename: string;
begin
inherited;
fCriticalSection.Enter;
try
fr := TSuperObject.Create(stObject);
req := request.getrequest;
resp := request.getresponse;
SentHead := CEF_GetSentHeader(req);
RcvdHead := CEF_GetRcvdHeader(resp);
fr.s['method'] := req.getMethod;
fr.s['url'] := req.GetURL;
if pos('Referer', SentHead) <> 0 then
referrer := trim(getfield('Referer', SentHead));
if req.getMethod = 'POST' then
fr.s['postdata'] := CEF_GetPostData(req)
else
fr.s['postdata'] := emptystr;
fr.s['status'] := inttostr(resp.getStatus);
fr.s['mimetype'] := resp.GetMimeType;
if Details <> emptystr then // user specified
fr.s['details'] := Details
else
begin
if lowercase(extracturlfileext(referrer)) = '.swf' then
fr.s['details'] := 'Flash Plugin Request'
else
fr.s['details'] := 'Browser Request';
end;
fr.s['reqid'] := emptystr;
fr.s['response'] := emptystr;
respfilename := GetTempFile;
fr.s['responsefilename'] := respfilename;
fResponseStream.SaveToFile(respfilename);
fr.s['length'] := inttostr(fResponseStream.Size);
fr.b['isredir'] := false;
fr.b['islow'] := false;
fr.s['headers'] := SentHead;
fr.s['responseheaders'] := RcvdHead;
if MsgHandle <> 0 then
SendCromisMessage(MsgHandle, CRM_LOG_REQUEST_JSON, fr.AsJson(true));
fr := nil;
finally
fCriticalSection.Leave;
end;
end;
// ------------------------------------------------------------------------//
// TCatDevTools //
// ------------------------------------------------------------------------//
procedure TCatDevTools.View(browser: ICefBrowser);
begin
{$IFNDEF USEWACEF}
if fDevTools = nil then
begin
fDevTools := TChromiumDevTools.Create(self);
fDevTools.Parent := self;
fDevTools.Align := AlClient;
end;
fDevTools.ShowDevTools(browser);
{$ENDIF}
end;
procedure TCatDevTools.CloseBtnClick(Sender: TObject);
begin
height := 0;
if fSplitter <> nil then
fSplitter.Visible := false;
end;
constructor TCatDevTools.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := ControlStyle + [csAcceptsControls];
Color := clWindow;
fTitlePanel := TPanel.Create(self);
fTitlePanel.Parent := self;
fTitlePanel.Align := alTop;
fTitlePanel.height := 24;
fTitlePanel.Caption := 'DevTools';
fTitlePanel.Color := clBtnShadow;
fTitlePanel.ParentBackground := false;
fTitlePanel.Font.Color := clWhite;
fCloseBtn := TButton.Create(self);
fCloseBtn.Parent := fTitlePanel;
fCloseBtn.Align := alright;
fCloseBtn.OnClick := CloseBtnClick;
fCloseBtn.Font.Style := fCloseBtn.Font.Style + [fsBold];
fCloseBtn.Width := 22;
fCloseBtn.Caption := 'x';
end;
destructor TCatDevTools.Destroy;
begin
{$IFNDEF USEWACEF}
if fDevTools <> nil then
fDevTools.Free;
{$ENDIF}
fCloseBtn.Free;
fTitlePanel.Free;
inherited Destroy;
end;
initialization
CefRemoteDebuggingPort := 8000;
end.
|
unit askToRunLuaScript;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, SynEdit, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, LuaSyntax, betterControls;
type
{ TfrmLuaScriptQuestion }
TfrmLuaScriptQuestion = class(TForm)
Button1: TButton;
Button2: TButton;
GroupBox5: TGroupBox;
Label16: TLabel;
Panel1: TPanel;
rbAlways: TRadioButton;
rbSignedOnly: TRadioButton;
rbAlwaysAsk: TRadioButton;
rbNever: TRadioButton;
script: TSynEdit;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ private declarations }
synhighlighter: TSynLuaSyn;
function getLuaScriptAction: integer;
procedure setLuaScriptAction(a: integer);
public
{ public declarations }
property LuaScriptAction: integer read getLuaScriptAction write setLuaScriptAction;
end;
implementation
{$R *.lfm}
{ TfrmLuaScriptQuestion }
function TfrmLuaScriptQuestion.getLuaScriptAction: integer;
begin
result:=0;
if rbAlways.checked then result:=0 else
if rbSignedOnly.checked then result:=1 else
if rbAlwaysAsk.checked then result:=2 else
if rbNever.checked then result:=3;
end;
procedure TfrmLuaScriptQuestion.setLuaScriptAction(a: integer);
begin
case a of
0: rbAlways.checked:=true;
1: rbSignedOnly.checked:=true;
2: rbAlwaysAsk.checked:=true;
3: rbNever.checked:=true;
end;
end;
procedure TfrmLuaScriptQuestion.FormCreate(Sender: TObject);
begin
synhighlighter:=TSynLuaSyn.Create(self);
script.Highlighter:=synhighlighter;
end;
procedure TfrmLuaScriptQuestion.FormDestroy(Sender: TObject);
begin
script.Highlighter:=nil;
if synhighlighter<>nil then
synhighlighter.free;
end;
end.
|
unit uInterface;
interface
uses
Windows, SysUtils, Classes;
type
TFileKindEx = (
fkFundNav_DBF, // 基金净值-DBF
fkFundNav_Web, // 基金净值-官网
fkFundNav_fund123, // 基金净值-fund123
fkFundNav_ifund, // 基金净值-爱基金
fkFundNav_stockstar, // 基金净值-证券之星
fkFundNav_HeXun, // 基金净值-和讯
fkFundNav_JRJ // 基金净值-金融界
);
TFileKindSetEx = set of TFileKindEx;
const
ALL_FILE_KIND: TFileKindSetEx = [fkFundNav_DBF,
fkFundNav_Web,
fkFundNav_fund123,
fkFundNav_ifund,
fkFundNav_stockstar,
fkFundNav_HeXun,
fkFundNav_JRJ];
type
IFundNav = interface
['{5C78597E-F857-4F7B-89C1-D39B10874A43}']
function GetSupportedFileKind(): TFileKindSetEx;
procedure GetFundNav( AFileKind: TFileKindEx; Temporarylist: TStrings);
procedure GetFinaNav(const ADest: TStream; Temporarylist: TStrings);
end;
implementation
end.
|
{
Create patch plugin with "No Respawn" flag on references of ore veins.
}
unit SkyrimOreVeinsDontRespawnPatch;
var
plugin: IInterface;
function Process(e: IInterface): Integer;
var
ore, r: IInterface;
begin
// process only references
if Signature(e) <> 'REFR' then
Exit;
// only master references
if not IsMaster(e) then
Exit;
// but work with the current winning override
e := WinningOverride(e);
// getting base object of a reference (record linked in the 'NAME - Base Object' field)
ore := BaseRecord(e);
// references of activator only
if Signature(ore) <> 'ACTI' then
Exit;
// detect if activator is an ore vein
// check the presense of mining script
if GetElementEditValues(ore, 'VMAD\Scripts\Script\scriptName') <> 'MineOreScript' then
Exit;
// create a new plugin if not created yet or use the last loaded
if not Assigned(plugin) then begin
if MessageDlg('Create a new plugin [YES] or append to the last loaded one [NO]?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
plugin := AddNewFile
else
plugin := FileByIndex(Pred(FileCount));
if not Assigned(plugin) then begin
Result := 1;
Exit;
end;
end;
// add masters before copying as override for parent CELL
AddRequiredElementMasters(LinksTo(ElementByIndex(e, 0)), plugin, False);
// and REFR itself
AddRequiredElementMasters(e, plugin, False);
try
// copy reference as override
r := wbCopyElementToFile(e, plugin, False, True);
// set No Respawn flag (bit 30)
SetElementNativeValues(r, 'Record Header\Record Flags', GetElementNativeValues(r, 'Record Header\Record Flags') or (1 shl 30));
except
on Ex: Exception do begin
AddMessage('Failed to copy: ' + FullPath(e));
AddMessage(' reason: ' + Ex.Message);
end;
end;
end;
function Finalize: integer;
begin
if Assigned(plugin) then
SortMasters(plugin);
end;
end.
|
// creates new COBJ record to make item Temperable
function makeTemperable(itemRecord: IInterface): IInterface;
var
recipeTemper,
recipeCondition, recipeConditions,
recipeItem, recipeItems
: IInterface;
begin
recipeTemper := createRecipe(itemRecord);
// add new condition list
Add(recipeTemper, 'Conditions', true);
// get reference to condition list inside recipe
recipeConditions := ElementByPath(recipeTemper, 'Conditions');
// add IsEnchanted condition
// get new condition from list
recipeCondition := ElementByIndex(recipeConditions, 0);
// set type to 'Not equal to / Or'
SetElementEditValues(recipeCondition, 'CTDA - \Type', '00010000');
// set some needed properties
SetElementEditValues(recipeCondition, 'CTDA - \Comparison Value', '1');
SetElementEditValues(recipeCondition, 'CTDA - \Function', 'EPTemperingItemIsEnchanted');
SetElementEditValues(recipeCondition, 'CTDA - \Run On', 'Subject');
// don't know what is this, but it should be equal to -1, if Function Runs On Subject
SetElementEditValues(recipeCondition, 'CTDA - \Parameter #3', '-1');
// add second condition, for perk ArcaneBlacksmith check
addPerkCondition(recipeConditions, getRecordByFormID('0005218E')); // ArcaneBlacksmith
// add required items list
Add(recipeTemper, 'items', true);
// get reference to required items list inside recipe
recipeItems := ElementByPath(recipeTemper, 'items');
if Signature(itemRecord) = 'WEAP' then begin
// set EditorID for recipe
SetElementEditValues(recipeTemper, 'EDID', 'TemperWeapon' + GetElementEditValues(itemRecord, 'EDID'));
// add reference to the workbench keyword
SetElementEditValues(recipeTemper, 'BNAM', GetEditValue(
getRecordByFormID(WEAPON_TEMPERING_WORKBENCH_FORM_ID)
));
end else if Signature(itemRecord) = 'ARMO' then begin
// set EditorID for recipe
SetElementEditValues(recipeTemper, 'EDID', 'TemperArmor' + GetElementEditValues(itemRecord, 'EDID'));
// add reference to the workbench keyword
SetElementEditValues(recipeTemper, 'BNAM', GetEditValue(
getRecordByFormID(ARMOR_TEMPERING_WORKBENCH_FORM_ID)
));
end;
// figure out required component...
addItem(recipeItems, getMainMaterial(itemRecord), 1);
// remove nil record in items requirements, if any
removeInvalidEntries(recipeTemper);
if GetElementEditValues(recipeTemper, 'COCT') = '' then begin
warn('no item requirements was specified for - ' + Name(recipeTemper));
end;
// return created tempering recipe, just in case
Result := recipeTemper;
end;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.