unit ufrmSelGuest;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ufrmBsGridSelect, cxStyles, cxCustomData, cxGraphics, cxFilter,
cxData, cxDataStorage, cxEdit, DB, cxDBData, DBClient, mfDBClient,
ActnList, cxGridLevel, cxClasses, cxControls, cxGridCustomView,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid,
ComCtrls, ToolWin, mfFieldCentre, mfGridColCreator, mfDevGridColCreator,
mfDBSearchMgr, mfBsFormCmptMgr, mfFormCmptMgr, StdCtrls, ExtCtrls,
mfQueryCtrlsCreator, mfDevQueryCtrlsCreator, mfMovePanel, cxCheckBox,
cxContainer;
type
TfrmSelGuest = class(TfrmBsGridSelect)
procedure FormCreate(Sender: TObject);
procedure FormMgrPrepare(Sender: TObject);
procedure QueryCreatorGetQueryCondition(AQueryItem: TmfQueryCtrlsItem;
var vCondi: string; var vProcessed: Boolean);
private
function GetProviderChecker: Integer;
function GetCustChecker: Integer;
function GetBrotherChecker: Integer;
procedure SetProviderChecker(const AValue: Integer);
procedure SetCustChecker(const AValue: Integer);
procedure SetBrotherChecker(const AValue: Integer);
{ Private declarations }
public
property ProviderChecker: Integer read GetProviderChecker write
SetProviderChecker;
property CustChecker: Integer read GetCustChecker write SetCustChecker;
property BrotherChecker: Integer read GetBrotherChecker write SetBrotherChecker;
{ Public declarations }
end;
var
frmSelGuest: TfrmSelGuest;
implementation
{$R *.dfm}
procedure TfrmSelGuest.FormCreate(Sender: TObject);
begin
inherited;
fdcMain.Open;
gccMain.Open;
end;
procedure TfrmSelGuest.FormMgrPrepare(Sender: TObject);
var
AIsRefresh: Boolean;
begin
AIsRefresh := false;
//if FOleParams.FieldExists('Provi') then
if FOleParams.IntegerValue['Provi'] <> ProviderChecker then
begin
ProviderChecker := FOleParams.IntegerValue['Provi'];
AIsRefresh := true;
end;
// if FOleParams.FieldExists('Cust') then
if FOleParams.IntegerValue['Cust'] <> CustChecker then
begin
CustChecker := FOleParams.IntegerValue['Cust'];
AIsRefresh := true;
end;
//if FOleParams.FieldExists('Brother') then
if FOleParams.IntegerValue['Brother'] <> BrotherChecker then
begin
BrotherChecker := FOleParams.IntegerValue['Brother'];
AIsRefresh := true;
end;
if not cdsMain.Active or AIsRefresh then actRefresh.Execute;
end;
function TfrmSelGuest.GetProviderChecker: Integer;
var
ACheckBox: TcxCheckBox;
begin
Result := -1;
if Assigned(QueryCreator.FindItemByFieldName('FGongYingShang')) then
begin
QueryCreator.FindItemByFieldName('FGongYingShang').Reset;
ACheckBox := TcxCheckBox(QueryCreator.FindItemByFieldName('FGongYingShang').NextValueCtrl);
if Assigned(ACheckBox) then
case ACheckBox.State of
cbsUnchecked: Result := 0;
cbsChecked: Result := 1;
cbsGrayed: Result := -1;
end;
end;
end;
function TfrmSelGuest.GetCustChecker: Integer;
var
ACheckBox: TcxCheckBox;
begin
Result := -1;
if Assigned(QueryCreator.FindItemByFieldName('FKeHu')) then
begin
QueryCreator.FindItemByFieldName('FKeHu').Reset;
ACheckBox := TcxCheckBox(QueryCreator.FindItemByFieldName('FKeHu').NextValueCtrl);
if Assigned(ACheckBox) then
case ACheckBox.State of
cbsUnchecked: Result := 0;
cbsChecked: Result := 1;
cbsGrayed: Result := -1;
end;
end;
end;
function TfrmSelGuest.GetBrotherChecker: Integer;
var
ACheckBox: TcxCheckBox;
begin
Result := -1;
if Assigned(QueryCreator.FindItemByFieldName('FTongHang')) then
begin
QueryCreator.FindItemByFieldName('FTongHang').Reset;
ACheckBox := TcxCheckBox(QueryCreator.FindItemByFieldName('FTongHang').NextValueCtrl);
if Assigned(ACheckBox) then
case ACheckBox.State of
cbsUnchecked: Result := 0;
cbsChecked: Result := 1;
cbsGrayed: Result := -1;
end;
end;
end;
procedure TfrmSelGuest.SetProviderChecker(const AValue: Integer);
var
ACheckBox: TcxCheckBox;
begin
if Assigned(QueryCreator.FindItemByFieldName('FGongYingShang')) then
begin
QueryCreator.FindItemByFieldName('FGongYingShang').Reset;
ACheckBox := TcxCheckBox(QueryCreator.FindItemByFieldName('FGongYingShang').NextValueCtrl);
if Assigned(ACheckBox) then
case AValue of
0: ACheckBox.State := cbsUnchecked;
1: ACheckBox.State := cbsChecked;
-1: ACheckBox.State := cbsGrayed;
end;
end;
end;
procedure TfrmSelGuest.SetCustChecker(const AValue: Integer);
var
ACheckBox: TcxCheckBox;
begin
if Assigned(QueryCreator.FindItemByFieldName('FKeHu')) then
begin
QueryCreator.FindItemByFieldName('FKeHu').Reset;
ACheckBox := TcxCheckBox(QueryCreator.FindItemByFieldName('FKeHu').NextValueCtrl);
if Assigned(ACheckBox) then
case AValue of
0: ACheckBox.State := cbsUnchecked;
1: ACheckBox.State := cbsChecked;
-1: ACheckBox.State := cbsGrayed;
end;
end;
end;
procedure TfrmSelGuest.SetBrotherChecker(const AValue: Integer);
var
ACheckBox: TcxCheckBox;
begin
if Assigned(QueryCreator.FindItemByFieldName('FTongHang')) then
begin
QueryCreator.FindItemByFieldName('FTongHang').Reset;
ACheckBox := TcxCheckBox(QueryCreator.FindItemByFieldName('FTongHang').NextValueCtrl);
if Assigned(ACheckBox) then
case AValue of
0: ACheckBox.State := cbsUnchecked;
1: ACheckBox.State := cbsChecked;
-1: ACheckBox.State := cbsGrayed;
end;
end;
end;
procedure TfrmSelGuest.QueryCreatorGetQueryCondition(
AQueryItem: TmfQueryCtrlsItem; var vCondi: string;
var vProcessed: Boolean);
var
ACheckBox: TcxCheckBox;
begin
vProcessed := True;
if AQueryItem.FieldDataObject.FieldName = 'FKeHu' then
begin
ACheckBox := TcxCheckBox(AQueryItem.FirstValueCtrl);
if Assigned(ACheckBox) then
if ACheckBox.Checked then vCondi := 'FKeHu = 1';
end else if AQueryItem.FieldDataObject.FieldName = 'FGongYingShang' then
begin
ACheckBox := TcxCheckBox(AQueryItem.FirstValueCtrl);
if Assigned(ACheckBox) then
if ACheckBox.Checked then vCondi := 'FGongYingShang = 1';
end else if AQueryItem.FieldDataObject.FieldName = 'FTongHang' then
begin
ACheckBox := TcxCheckBox(AQueryItem.FirstValueCtrl);
if Assigned(ACheckBox) then
if ACheckBox.Checked then vCondi := 'FTongHang = 1';
end else
vProcessed := false;
end;
end.