unit p_mob;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, BUThreadTimer, cxGridLevel, cxGridCustomTableView,
  cxGridCardView, cxGridDBCardView, cxClasses, cxControls,
  cxGridCustomView, cxGrid, ExtCtrls, RzPanel, Db, DBTables, RzButton,
  cxStyles;

type
  Tf_mob = class(TForm)
    DMOB: TDataSource;
    Query2: TQuery;
    Query2ID: TIntegerField;
    Query2AUTONO: TIntegerField;
    Query2FNO: TStringField;
    Query2VAT: TFloatField;
    Query2SUBTOTAL: TFloatField;
    Query2TOTAL: TFloatField;
    Query2CASHIN: TFloatField;
    Query2CASHOUT: TFloatField;
    Query2TABLENO: TStringField;
    Query2IACTIVE: TStringField;
    Query2NAME: TStringField;
    Query2COVER: TIntegerField;
    Query2ISTATE: TIntegerField;
    Query2LASTTIME: TDateTimeField;
    Query2CREATETIME: TDateTimeField;
    Query2DISCOUNT: TFloatField;
    Query2PRN: TStringField;
    Query2CHEF: TStringField;
    Query2SID: TStringField;
    Query2CONTACT: TIntegerField;
    Query2ZALEID: TIntegerField;
    Query2SDISC: TFloatField;
    Query2PAID: TStringField;
    RzPanel1: TRzPanel;
    RzPanel2: TRzPanel;
    cxGrid3: TcxGrid;
    cxGridDBCardView2: TcxGridDBCardView;
    cxGridDBCardViewRow1: TcxGridDBCardViewRow;
    cxGridDBCardViewRow2: TcxGridDBCardViewRow;
    cxGridDBCardViewRow3: TcxGridDBCardViewRow;
    cxGridDBCardViewRow4: TcxGridDBCardViewRow;
    cxGridDBCardViewRow5: TcxGridDBCardViewRow;
    cxGridDBCardViewRow6: TcxGridDBCardViewRow;
    cxGridDBCardViewRow8: TcxGridDBCardViewRow;
    cxGridLevel2: TcxGridLevel;
    BUThreadTimer1: TBUThreadTimer;
    Label1: TLabel;
    Query1: TQuery;
    Query1ID: TIntegerField;
    Query1AUTONO: TIntegerField;
    Query1FNO: TStringField;
    Query1VAT: TFloatField;
    Query1SUBTOTAL: TFloatField;
    Query1TOTAL: TFloatField;
    Query1CASHIN: TFloatField;
    Query1CASHOUT: TFloatField;
    Query1TABLENO: TStringField;
    Query1IACTIVE: TStringField;
    Query1NAME: TStringField;
    Query1COVER: TIntegerField;
    Query1ISTATE: TIntegerField;
    Query1LASTTIME: TDateTimeField;
    Query1CREATETIME: TDateTimeField;
    Query1DISCOUNT: TFloatField;
    Query1PRN: TStringField;
    Query1CHEF: TStringField;
    Query1ZALEID: TIntegerField;
    RzBitBtn3: TRzBitBtn;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    cxStyle2: TcxStyle;
    cxStyle3: TcxStyle;
    cxStyle4: TcxStyle;
    cxStyle5: TcxStyle;
    cxStyle6: TcxStyle;
    cxStyle7: TcxStyle;
    Query1DOPRN: TStringField;
    Query2DOPRN: TStringField;
    procedure Label1Click(Sender: TObject);
    procedure BUThreadTimer1Timer(Sender: TObject);
    procedure RzBitBtn3Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure cxGridDBCardView2StylesGetContentStyle(
      Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
      AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  f_mob: Tf_mob;

implementation

uses p_posmodule, p_touchinv;

{$R *.DFM}

procedure Tf_mob.Label1Click(Sender: TObject);
var s:string;
begin


//query1.close;
//Query2.close;
//myorder.close;
try
posmodule.CURRFAC.open;

posmodule.CURRFAC.Refresh;
posmodule.CURRFAC.close;

Query2.close;
Query2.open;

IF QUERY2.IsEmpty THEN EXIT;



S:=QUERY2TABLENO.AsString;




query1.close;
query1.ParamByName('mytable').asstring:=S;
//query1.ParamByName('myID').ASINTEGER:=1;
query1.open;
posmodule.CURrFAC.open;


posmodule.CURRFAC.Locate('id',query1id.AsInteger,[]);
posmodule.CURRFAC.EDIT;
posmodule.CURRFACIACTIVE.AsString:='True';





posmodule.CURrFAC.POST;

posmodule.items.open;
//1: b:=false;
//Application.CreateForm(Tf_touchinv,f_touchinv);
if not assigned(f_touchinv) then
f_touchinv:=tf_touchinv.create(self);
TRY
if posmodule.CURRFACDOPRN.AsString='True' then
f_touchinv.RzBitBtn1Click(f_touchinv.RzBitBtn1);

f_touchinv.RzBitBtn8Click(f_touchinv.RzBitBtn8);



if (posmodule.CURrFAC.State in [dsedit]) or (posmodule.CURrFAC.State in [dsinsert]) then


 posmodule.CURrFAC.post;

//if posmodule.ITEMS.IsEmpty then
// posmodule.CURrFAC.delete;


except

posmodule.ITEMS.cancel;
posmodule.CURrFAC.cancel;


end;
//if b then goto 1;

    if  assigned(f_touchinv) then
 freeandnil(f_touchinv);
TRY
posmodule.ITEMS.close;
posmodule.CURrFAC.close;



QUERY1.CLOSE;
QUERY2.close;
QUERY2.open;
EXCEPT
END;








//myorder.open;


except

end;
end;

procedure Tf_mob.BUThreadTimer1Timer(Sender: TObject);
begin
try
BUThreadTimer1.Active:=false;

if Active=true then
begin
Label1Click(Label1);
end;
except
end;
BUThreadTimer1.Active:=true;
end;

procedure Tf_mob.RzBitBtn3Click(Sender: TObject);
begin
close;
end;

procedure Tf_mob.FormShow(Sender: TObject);
begin
query2.open;
BUThreadTimer1.Active:=true;
end;

procedure Tf_mob.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
BUThreadTimer1.Active:=false;
query2.close;
end;

procedure Tf_mob.cxGridDBCardView2StylesGetContentStyle(
  Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
  AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
begin
inherited;

TRY
try
astyle:=cxStyle7;

if (arecord.Values[0]='True') then
astyle.Color:=cxStyle5.Color    ;



except
astyle:=cxStyle7;
astyle.Color:=cxStyle1.Color;
end;

EXCEPT
END;

end;

end.
