unit p_touchcash;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  cxGridCardView, cxGridDBCardView, Buttons, cxGridLevel,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
  cxControls, cxGridCustomView, cxGrid, ExtCtrls, RzPanel, StdCtrls, Mask,
  DBCtrls, Db, DBTables, RzButton, OoMisc, AdPort, cxStyles, Grids, DBGrids,
  SUIDlg,frxBDEComponents,cxContainer, cxEdit, cxLabel, cxDBLabel, RzLabel, RzDBLbl, Menus,
  DBSearch, IvDictio, IvMulti, BULabel, BUBlinkingLabel, cxPropertiesStore,
  dxGDIPlusClasses, DBCGrids, frxpngimage;

type
  Tf_touchcash = class(TForm)
    RzPanel1: TRzPanel;
    RzPanel2: TRzPanel;
    tttt: TcxGrid;
    ttttDBTableView1: TcxGridDBTableView;
    ttttDBTableView1DESCR: TcxGridDBColumn;
    ttttDBTableView1FRAC: TcxGridDBColumn;
    ttttDBTableView1TOTAL: TcxGridDBColumn;
    ttttLevel1: TcxGridLevel;
    RzPanel3: TRzPanel;
    RzPanel4: TRzPanel;
    s: TcxGrid;
    sDBCardView1: TcxGridDBCardView;
    sDBCardView1Row1: TcxGridDBCardViewRow;
    sDBCardView1Row2: TcxGridDBCardViewRow;
    sLevel1: TcxGridLevel;
    RzPanel5: TRzPanel;
    categ: TQuery;
    dcateg: TDataSource;
    stock: TQuery;
    dstock: TDataSource;
    stockITEM: TStringField;
    stockDESCR1: TStringField;
    stockDESCR2: TStringField;
    stockCATEGORY: TStringField;
    stockSUBCAT1: TStringField;
    stockSUBCAT2: TStringField;
    stockWHEREIS: TStringField;
    stockSUPPLIER: TStringField;
    stockMASDAR: TStringField;
    stockPACK: TFloatField;
    stockBCOSTUS: TFloatField;
    stockBCOSTLC: TFloatField;
    stockPOSPRICE1: TFloatField;
    stockSALESCURRID: TIntegerField;
    stockPRICEA: TFloatField;
    stockPRICEB: TFloatField;
    stockPRICEC: TFloatField;
    stockPRICED: TFloatField;
    stockPRICEE: TFloatField;
    stockPRICEF: TFloatField;
    stockBARCODE1: TStringField;
    stockBARCODE2: TStringField;
    stockBARCODE3: TStringField;
    stockBARCODE4: TStringField;
    stockPACK1: TFloatField;
    stockPACK2: TFloatField;
    stockPACK3: TFloatField;
    stockPACK4: TFloatField;
    stockPRICE1: TFloatField;
    stockPRICE2: TFloatField;
    stockPRICE3: TFloatField;
    stockPRICE4: TFloatField;
    stockMINSTOCK: TFloatField;
    stockMAXSTOCK: TFloatField;
    stockGWEIGHT: TFloatField;
    stockNWEIGHT: TFloatField;
    stockVOLUME: TFloatField;
    stockSALESDISC: TFloatField;
    stockPURCHDISC: TFloatField;
    stockSUNIT: TStringField;
    stockVAT: TFloatField;
    stockBQTY: TFloatField;
    stockQTY: TFloatField;
    stockCDATE: TDateTimeField;
    stockYESNO: TStringField;
    stockCOSTUS: TFloatField;
    stockCOSTLC: TFloatField;
    stockLCOST: TFloatField;
    stockSTYPE: TIntegerField;
    stockBUY: TFloatField;
    stockPAY: TFloatField;
    stockRBUY: TFloatField;
    stockRPAY: TFloatField;
    stockADJUSTIN: TFloatField;
    stockADJUSTOUT: TFloatField;
    stockPRODIN: TFloatField;
    stockPRODOUT: TFloatField;
    stockPROFORMAQTY: TFloatField;
    stockORDERQTY: TFloatField;
    stockOQTY: TFloatField;
    stockJQTY: TFloatField;
    stockUSER_: TStringField;
    stockMIZANE: TIntegerField;
    stockMIZANE1: TIntegerField;
    stockMIZANE2: TIntegerField;
    stockMIZANE3: TIntegerField;
    stockMIZANE4: TIntegerField;
    stockOFRE: TIntegerField;
    stockCARTOON: TFloatField;
    btnclose1: TRzBitBtn;
    RzBitBtn3: TRzBitBtn;
    RzBitBtn4: TRzBitBtn;
    RzBitBtnback: TRzBitBtn;
    locstock: TTable;
    dlocstock: TDataSource;
    RzBitBtn5: TRzBitBtn;
    RzBitBtn7: TRzBitBtn;
    RzBitBtn9: TRzBitBtn;
    RzBitBtn10: TRzBitBtn;
    RzBitBtn11: TRzBitBtn;
    RzBitBtn12: TRzBitBtn;
    RzBitBtn13: TRzBitBtn;
    RzBitBtn14: TRzBitBtn;
    RzBitBtn15: TRzBitBtn;
    RzBitBtn16: TRzBitBtn;
    RzBitBtn2: TRzBitBtn;
    RzPanel6: TRzPanel;
    RzPanel7: TRzPanel;
    DBEdit12: TDBEdit;
    Label4: TLabel;
    DBEdit16: TDBEdit;
    Label5: TLabel;
    mypass: TsuiInputDialog;
    RzPanel8: TRzPanel;
    RzLabel1: TRzLabel;
    RzLabel2: TRzLabel;
    RzDBLabel1: TRzDBLabel;
    sDBCardView1Row3: TcxGridDBCardViewRow;
    sDBCardView1Row4: TcxGridDBCardViewRow;
    loccateg: TQuery;
    dloccateg: TDataSource;
    ttttDBTableView1Column1: TcxGridDBColumn;
    PopupMenu1: TPopupMenu;
    OpenInvoiceAfterPrint1: TMenuItem;
    btnexit: TRzBitBtn;
    fff: TRaDBSearch;
    N1: TMenuItem;
    stockMYPRN: TStringField;
    rzcedit: TRzBitBtn;
    IvTranslator1: TIvTranslator;
    e_bar: TEdit;
    touser: TTable;
    plabel: TBUBlinkingLabel;
    toushviewm: TcxPropertiesStore;
    Image1: TImage;
    PopupMenu2: TPopupMenu;
    Design1: TMenuItem;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    cxStyle2: TcxStyle;
    cxStyle3: TcxStyle;
    cxStyle4: TcxStyle;
    cxStyle5: TcxStyle;
    cxStyle6: TcxStyle;
    cxStyle7: TcxStyle;
    OpenDrawer1: TMenuItem;
    ShowBarcode1: TMenuItem;
    lqty: TBUBlinkingLabel;
    RzPanel9: TRzPanel;
    DBCtrlGrid1: TDBCtrlGrid;
    DBText2: TDBText;
    DBText3: TDBText;
    DBText4: TDBText;
    RzBitBtn1: TRzBitBtn;
    ttttDBTableView1Column2: TcxGridDBColumn;
    btnprint: TRzBitBtn;
    STOCK2: TQuery;
    STOCK2ITEM: TStringField;
    STOCK2DESCR1: TStringField;
    STOCK2DESCR2: TStringField;
    STOCK2CATEGORY: TStringField;
    STOCK2SUBCAT1: TStringField;
    STOCK2SUBCAT2: TStringField;
    STOCK2WHEREIS: TStringField;
    STOCK2SUPPLIER: TStringField;
    STOCK2MASDAR: TStringField;
    STOCK2PACK: TFloatField;
    STOCK2BCOSTUS: TFloatField;
    STOCK2BCOSTLC: TFloatField;
    STOCK2POSPRICE1: TFloatField;
    STOCK2SALESCURRID: TIntegerField;
    STOCK2PRICEA: TFloatField;
    STOCK2PRICEB: TFloatField;
    STOCK2PRICEC: TFloatField;
    STOCK2PRICED: TFloatField;
    STOCK2PRICEE: TFloatField;
    STOCK2PRICEF: TFloatField;
    STOCK2BARCODE1: TStringField;
    STOCK2BARCODE2: TStringField;
    STOCK2BARCODE3: TStringField;
    STOCK2BARCODE4: TStringField;
    STOCK2PACK1: TFloatField;
    STOCK2PACK2: TFloatField;
    STOCK2PACK3: TFloatField;
    STOCK2PACK4: TFloatField;
    STOCK2PRICE1: TFloatField;
    STOCK2PRICE2: TFloatField;
    STOCK2PRICE3: TFloatField;
    STOCK2PRICE4: TFloatField;
    STOCK2MINSTOCK: TFloatField;
    STOCK2MAXSTOCK: TFloatField;
    STOCK2GWEIGHT: TFloatField;
    STOCK2NWEIGHT: TFloatField;
    STOCK2VOLUME: TFloatField;
    STOCK2SALESDISC: TFloatField;
    STOCK2PURCHDISC: TFloatField;
    STOCK2SUNIT: TStringField;
    STOCK2VAT: TFloatField;
    STOCK2BQTY: TFloatField;
    STOCK2QTY: TFloatField;
    STOCK2CDATE: TDateTimeField;
    STOCK2YESNO: TStringField;
    STOCK2COSTUS: TFloatField;
    STOCK2COSTLC: TFloatField;
    STOCK2LCOST: TFloatField;
    STOCK2STYPE: TIntegerField;
    STOCK2BUY: TFloatField;
    STOCK2PAY: TFloatField;
    STOCK2RBUY: TFloatField;
    STOCK2RPAY: TFloatField;
    STOCK2ADJUSTIN: TFloatField;
    STOCK2ADJUSTOUT: TFloatField;
    STOCK2PRODIN: TFloatField;
    STOCK2PRODOUT: TFloatField;
    STOCK2PROFORMAQTY: TFloatField;
    STOCK2ORDERQTY: TFloatField;
    STOCK2OQTY: TFloatField;
    STOCK2JQTY: TFloatField;
    STOCK2USER_: TStringField;
    STOCK2MIZANE: TIntegerField;
    STOCK2MIZANE1: TIntegerField;
    STOCK2MIZANE2: TIntegerField;
    STOCK2MIZANE3: TIntegerField;
    STOCK2MIZANE4: TIntegerField;
    STOCK2OFRE: TIntegerField;
    STOCK2CARTOON: TFloatField;
    STOCK2LCOST1: TFloatField;
    STOCK2LCOST2: TFloatField;
    STOCK2LCOST3: TFloatField;
    STOCK2LCOST4: TFloatField;
    STOCK2MYPRN: TStringField;
    STOCK2MYCOSTUS: TFloatField;
    STOCK2MYCOSTLC: TFloatField;
    STOCK2POSORDER: TIntegerField;
    STOCK2OLDPRICE: TFloatField;
    STOCK2DISC2: TFloatField;
    SpeedButton1: TSpeedButton;
    N01: TMenuItem;
    ExcludeVat1: TMenuItem;
    DBNavigator1: TDBNavigator;
    categID: TIntegerField;
    categMID: TIntegerField;
    categDESCR: TStringField;
    categMYRATE: TFloatField;
    categMYRATE2: TFloatField;
    categABREV: TStringField;
    categSITE: TStringField;
    categSID: TStringField;
    cbsp: TCheckBox;
    cxStyle8: TcxStyle;
    RzPanel10: TRzPanel;
    RzBitBtn19: TRzBitBtn;
    RzBitBtn17: TRzBitBtn;
    RzBitBtn20: TRzBitBtn;
    RzBitBtn18: TRzBitBtn;
    RzBitBtn21: TRzBitBtn;
    RzBitBtn22: TRzBitBtn;
    RzBitBtn23: TRzBitBtn;
    RzBitBtn26: TRzBitBtn;
    Image4: TImage;
    RzBitBtn8: TRzBitBtn;
    RzDBGrid1: TDBGrid;
    Barcodeslist1: TMenuItem;
    RzBitBtn24: TRzBitBtn;
    DBCtrlGrid2: TDBCtrlGrid;
    RzDBLabel2: TRzDBLabel;
    procedure FormShow(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure sDBCardView1CellClick(Sender: TcxCustomGridTableView;
      ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
      AShift: TShiftState; var AHandled: Boolean);
    procedure RzDBGrid1Exit(Sender: TObject);
    procedure RzBitBtn8Click(Sender: TObject);
    procedure btnclose1Click(Sender: TObject);
    procedure RzBitBtn15Click(Sender: TObject);
    procedure RzBitBtn16Click(Sender: TObject);
    procedure RzBitBtn4Click(Sender: TObject);
    procedure RzBitBtn3Click(Sender: TObject);
    procedure RzBitBtn23Click(Sender: TObject);
    procedure RzBitBtnbackClick(Sender: TObject);
    procedure RzBitBtn2Click(Sender: TObject);
    procedure RzLabel1Click(Sender: TObject);
    procedure cxGrid1DBCardView1StylesGetContentStyle(
      Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
      AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
    procedure cxGridDBCardView1StylesGetContentStyle(
      Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
      AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
    procedure RzLabel2Click(Sender: TObject);
    procedure ttttDBTableView1StylesGetContentStyle(
      Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
      AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
    procedure RzBitBtn19Click(Sender: TObject);
    procedure RzBitBtn22Click(Sender: TObject);
    procedure OpenInvoiceAfterPrint1Click(Sender: TObject);
    procedure btnexitClick(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure rzceditClick(Sender: TObject);
    procedure categBeforeOpen(DataSet: TDataSet);
    procedure stockBeforeOpen(DataSet: TDataSet);
    procedure e_barKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Design1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ttttDBTableView1DblClick(Sender: TObject);
    procedure OpenDrawer1Click(Sender: TObject);
    procedure ShowBarcode1Click(Sender: TObject);
    procedure RzBitBtn1Click(Sender: TObject);
    procedure btnprintClick(Sender: TObject);
    procedure DBCtrlGrid1Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure N01Click(Sender: TObject);
    procedure ExcludeVat1Click(Sender: TObject);
    procedure DBCtrlGrid2Click(Sender: TObject);
    procedure RzBitBtn26Click(Sender: TObject);
    procedure Barcodeslist1Click(Sender: TObject);
    procedure RzBitBtn24Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  f_touchcash: Tf_touchcash;qty:currency;bb:boolean;c:currency;LAST:STRING;
     myexit:integer;  myff:integer;
implementation

uses p_posmodule, p_selbar, p_closeing, p_repmodule, p_telep, p_helpdesk,
  p_tableno, p_mynotes, p_stocklist, p_barcode, p_companye, p_item,
  p_stocklist2;



{$R *.DFM}

procedure Tf_touchcash.FormShow(Sender: TObject);
begin
//plabel.Caption:=posmodule.CURRFACTABLENO.AsString;

categ.open;
stock.open;
locstock.open;
loccateg.open;

//cxGridDBCardView1.OptionsView.CardIndent:=posmodule.CONFIGSCATCOL.AsInteger;
toushviewm.active:=posmodule.touser.FieldByName('UDESIGN').AsBoolean;

try
if posmodule.CONFIGSCATCOL.AsInteger<>0 then
DBCtrlGrid2.RowCount:=posmodule.CONFIGSCATCOL.AsInteger;
except
end;



end;

procedure Tf_touchcash.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
stock.close;
categ.close;
loccateg.close;
locstock.close;
// f_touchcash2.ModalResult:=mrok;
end;

procedure Tf_touchcash.sDBCardView1CellClick(
  Sender: TcxCustomGridTableView;
  ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
  AShift: TShiftState; var AHandled: Boolean);
begin
inherited;
//AHandled:=true ;
if posmodule.CURRFACPRN.AsString='True' then
exit;
if abutton=mbRight then exit;

if stoCK.IsEmpty=false then
begin
posmodule.items.append;
posmodule.itemsmid.AsString:=posmodule.invoiceid.AsString;
posmodule.itemssite.AsString:=posmodule.invoicesite.AsString;
posmodule.itemsfdate.AsString:=posmodule.invoicefdate.AsString;

posmodule.itemssid.AsString:=posmodule.invoicesid.AsString;
posmodule.itemscontact.AsString:=posmodule.invoicecontact.AsString;
posmodule.itemssalesman.AsString:=posmodule.invoicesalesman.AsString;

posmodule.itemsdiscount.AsCurrency :=stockSALESDISC.AsCurrency;
posmodule.itemsvat.AsCurrency:=stockvat.AsCurrency;
posmodule.itemsdescr.AsString:=stockdescr1.AsString;
posmodule.itemsstqty.AsCurrency:=stockQTY.AsCurrency;
 posmodule.itemsMYPRN.AsString:=stockMYPRN.AsString;
posmodule.itemsitem.AsString:=stockitem.AsString;
posmodule.itemsPACK.AsCurrency:=1;

 if posmodule.CONFIGSPRICE.AsInteger=2 then
posmodule.itemsprice.AsCurrency:=stockPRICEc.AsCurrency
 else
IF POSMODULE.CONFIGSPRICE.AsInteger=5 THEN
begin
if stockPRICEE.AsCurrency<>0 then
posmodule.itemsprice.AsCurrency:=stockPRICEE.AsCurrency
else
posmodule.itemsprice.AsCurrency:=stockPOSPRICE1.AsCurrency;
end
ELSE
posmodule.itemsprice.AsCurrency:=stockPOSPRICE1.AsCurrency;

if cbsp.Checked then
begin
if stockPRICEE.AsCurrency<>0 then
posmodule.itemsprice.AsCurrency:=stockPRICEE.AsCurrency;
end;

posmodule.itemsqty.AsCurrency:=1;
if stockBARCODE1.AsString<>'' then
begin
  //Application.CreateForm(Tf_selbar,f_selbar);
    if not assigned(f_selbar) then
f_selbar:=tf_selbar.create(self);
f_selbar.DataSource1.DataSet:=stock;
f_selbar.ShowModal  ;
try
if p_selbar.mysel=0 then
begin
posmodule.itemsqty.AsCurrency:=1;
posmodule.itemspack.AsCurrency:=1;
posmodule.itemsPRICE.AsCurrency:=stockPOSPRICE1.AsCurrency;


end
else
if p_selbar.mysel=1 then
begin
posmodule.itemsqty.AsCurrency:=1;
posmodule.itemspack.AsCurrency:=stockPACK1.AsCurrency;
posmodule.itemsPRICE.AsCurrency:=stockPRICE1.AsCurrency;


end
else
if p_selbar.mysel=2 then
begin
posmodule.itemsqty.AsCurrency:=1;
posmodule.itemspack.AsCurrency:=stockPACK2.AsCurrency;
posmodule.itemsPRICE.AsCurrency:=stockPRICE2.AsCurrency;


end
else
if p_selbar.mysel=3 then
begin
posmodule.itemsqty.AsCurrency:=1;
posmodule.itemspack.AsCurrency:=stockPACK3.AsCurrency;
posmodule.itemsPRICE.AsCurrency:=stockPRICE3.AsCurrency;


end
else
if p_selbar.mysel=4 then
begin
posmodule.itemsqty.AsCurrency:=1;
posmodule.itemspack.AsCurrency:=stockPACK4.AsCurrency;
posmodule.itemsPRICE.AsCurrency:=stockPRICE4.AsCurrency;
end;



if cbsp.Checked then
begin
if (posmodule.itemspack.AsCurrency=1) then
BEGIN
if (stoCKpricee.AsCurrency<>0 ) then
posmodule.itemsprice.AsCurrency:=stockPRICEE.AsCurrency
END
else
begin
if (stoCKpricef.AsCurrency<>0 ) then
posmodule.itemsprice.AsCurrency:=stockPRICEf.AsCurrency;
end;

end;








except
end;
 if  assigned(f_selbar) then
freeandnil(f_selbar);

end;


posmodule.itemsfrac.AsCurrency:=0;

posmodule.itemscostus.AsCurrency:=stockcostus.AsCurrency;
posmodule.itemscostlc.AsCurrency:=stockcostlc.AsCurrency;
//posmodule.itemssttype.AsString:=posmodule.detstocksttype.AsString;
posmodule.itemsyesno.AsString:=stockyesno.AsString;
posmodule.itemsbarcode.AsString:=stockitem.AsString;
posmodule.itemsqty.AsCurrency:=1;


posmodule.itemsCATREGORYID.AsInteger:=stockCATEGORY.AsInteger;
posmodule.items.post;

try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;
END;
e_bar.SetFocus;
 AHandled:=true ;
end;


procedure Tf_touchcash.RzDBGrid1Exit(Sender: TObject);

var cc,i:integer;c1,cvat,CDISC,cpro,ptotal:currency; II:INTEGER;
   s:string;mycomp:string[20];
begin

cvat:=0;
cc:=0;
c1:=0;
cpro:=0;
CDISC:=0;
posmodulE.items.DisableControls;
try
posmodulE.items.First;

FOR II:=1 TO  posmodulE.items.RecordCount do
begin
//posmodulE.items.edit;
//posmodulE.itemsQTY.AsCurrency:=posmodulE.itemsQTY.AsCurrency+1-1;

//posmodulE.items.post;



c1:=c1+posmodulE.itemstotal.AsCurrency;

cc:=cc+1;

cvat:=cvat+posmodulE.itemsvatamount.ascurrency;


posmodulE.items.Next;
end;
posmodulE.CURRFAC.edit;
posmodulE.CURRFACvat.AsCurrency:=cvat;

if (POSmodule.CONFIGSVATTYPE.AsString = 'TTC' )  then
posmodulE.CURRFACSUBTOTAL.AsCurrency:=c1-cvat
else
posmodulE.CURRFACSUBTOTAL.AsCurrency:=c1;

 posmodule.CURRFACtotal.AsCurrency:=posmodulE.CURRFACSUBTOTAL.AsCurrency+
posmodulE.CURRFACvat.AsCurrency-posmodulE.CURRFACdiscount.AsCurrency ;






posmodulE.CURRFAC.post;

  except
  end;
posmodulE.items.EnableControls;






   try
         mycomp:=posmodule.tocomp.fieldbyname('NAME1').AsString;
         mycomp:=mycomp+'....................';
       if posmodule.CONFIGSMYCOM.AsInteger<>0 then
       begin
     //    ccc.PutString(#$1b#$40);

 // ccc.PutString(mycomp+'Your amount = '+DBEdit12.Text);
      end;
        except
        end;
        try
        e_bar.SetFocus;
         except
         end;
end;

procedure Tf_touchcash.RzBitBtn8Click(Sender: TObject);
var k:word;S:STRING;
begin

k:=13;
e_bar.Text:='-'+posmodule.itemsQTY.AsString;
e_barKeyDown(e_bar,k,[ssLeft]);
S:=lqty.Caption;
IF (LENGTH(S)>1) THEN
IF S[1]='-' THEN
BEGIN


e_bar.Text:=posmodule.itemsitem.AsString;
e_barKeyDown(e_bar,k,[ssLeft]);

e_bar.SetFocus;

END;

end;

{try
repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'touchorder.fr3') ;

repmodule.frxReport1.PrepareReport;
repmodule.frxReport1.PrintOptions.ShowDialog:=false;
repmodule.frxReport1.print;

except
end;
modalresult:=mrok }



//end;

procedure Tf_touchcash.btnclose1Click(Sender: TObject);
var s:string;i:integer;
begin
if posmodule.items.IsEmpty then
begin
 e_bar.setfocus;
exit;
end;

    f_touchcash.Enabled:=false;
//cxGrid1.Enabled:=false;


 TRY
   //Application.CreateForm(Tf_closetable,f_closetable);
    if not assigned(f_closetable) then
f_closetable:=tf_closetable.create(self);

f_closetable.query1.open;
f_closetable.Query1.Locate('sid',posmodule.CURRFACSID.AsString,[]);
try
if f_closetable.ShowModal=mrok then
begin
posmodule.CURRFAC.edit;
posmodule.CURRFACSID.AsString:=f_closetable.Query1SID.AsString;
posmodule.CURRFAC.post;


end
else
begin
f_closetable.query1.close;
 if  assigned(f_closetable) then
freeandnil(f_closetable);
f_touchcash.Enabled:=true;
// cxGrid1.Enabled:=true;
e_bar.SetFocus;
exit;
end;

except
f_touchcash.Enabled:=true;
// cxGrid1.Enabled:=true;
e_bar.SetFocus;
exit;
end;
EXCEPT

END;

// cxGrid1.Enabled:=true;
f_closetable.query1.close;
 if  assigned(f_closetable) then
freeandnil(f_closetable);

try
if (posmodule.CURRFACCONTACT.AsInteger<>0)
    AND (posmodule.CURRFACTOTAL.AsCurrency<>0) then
begin

posmodule.contdet.ParamByName('mymid').AsInteger:=posmodule.CURRFACCONTACT.AsInteger;
posmodule.contdet.ParamByName('mycurrfac').AsInteger:=posmodule.CURRFACID.AsInteger;
if posmodule.CONFIGSPOINTAMOUNT.AsCurrency<>0 then
posmodule.contdet.ParamByName('mypointin').AsCurrency:=trunc(posmodule.CURRFACTOTAL.AsCurrency/posmodule.CONFIGSPOINTAMOUNT.AsCurrency)
else
posmodule.contdet.ParamByName('mypointin').AsCurrency:=0;
posmodule.contdet.ParamByName('mypointout').AsCurrency:=0;
posmodule.contdet.ParamByName('mytotal').AsCurrency:=posmodule.CURRFACTOTAL.AsCurrency;
posmodule.contdet.ParamByName('mydate').AsDate:=date;
posmodule.contdet.ParamByName('mytime').AsDateTime:=time;
posmodule.contdet.ExecSQL;
end;

except
end;


try
repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'touchinv.fr3') ;

if trim(posmodule.CONFIGSPINVOICE.AsString)<>'' then
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSPINVOICE.AsString;
repmodule.frxReport1.PrintOptions.ShowDialog:=false;

//repmodule.frxReport1.PrintOptions.Printer:='Default';
s:=posmodule.CURRFACsid.AsString;
if s[1]='4' then
repmodule.frxReport1.PrintOptions.Copies:=2
else
repmodule.frxReport1.PrintOptions.Copies:=1;
repmodule.frxReport1.PrepareReport;
repmodule.frxReport1.PrintOptions.ShowDialog:=false;
if posmodule.CONFIGSMYPRN.AsString<>'OFF' then
repmodule.frxReport1.print;

except
end;



try
posmodule.items.close;
posmodule.items.open;

try
repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'touchinv.fr3') ;

s:=repmodule.frxReport1.PrintOptions.Printer;
  try

 if FileExists(extractfilepath(application.exename)+'orderchef.fr3') then
begin
if posmodule.CONFIGSORDERCHEF.AsString<>'' then
begin
repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'orderchef.fr3') ;
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSORDERCHEF.AsString;

repmodule.frxReport1.PrintOptions.ShowDialog:=false;
repmodule.frxReport1.PrepareReport;
//repmodule.frxReport1.PrintOptions.Printer:='Default';

(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN

repmodule.frxReport1.print;
end;

end;
except
end;
try
//repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'touchinv.fr3') ;




repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'touchorder.fr3') ;
repmodule.frxReport1.PrintOptions.ShowDialog:=false;

repmodule.frxReport1.ShowProgress:=false;
if posmodule.CONFIGSKITCHEN.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''KITCHEN''';


repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSKITCHEN.AsString;


repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN

repmodule.frxReport1.print;
end;
if posmodule.CONFIGSBAR.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''BAR''';

repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSBAR.AsString;

repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;
if posmodule.CONFIGSCOCKTAIL.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''COCKTAIL''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSCOCKTAIL.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;
if posmodule.CONFIGSFASTFOOD.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''FAST FOOD''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSFASTFOOD.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;
if posmodule.CONFIGSOVEN.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''OVEN''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSOVEN.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;
if posmodule.CONFIGSBOUCHERY.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''BOUCHERY''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSBOUCHERY.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;
if posmodule.CONFIGSSNACK.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''SNACK''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSSNACK.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;
if posmodule.CONFIGSCAFETERIA.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''CAFETERIA''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSCAFETERIA.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;
if posmodule.CONFIGSPATESSERIE.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''PATESSERIE''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSPATESSERIE.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;
if posmodule.CONFIGSPIZZA.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''PIZZA''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSPIZZA.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;
if posmodule.CONFIGSSHISHAZ.AsString<>'' then
begin
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''SHISHAZ''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSSHISHAZ.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;
end;





except
end;
try
  repmodule.frxReport1.PrintOptions.Printer:=s;
 except
 end;
except
end;

posmodule.items.DisableControls;
try
posmodule.items.first;
while not posmodule.items.Eof do
begin
if  posmodule.itemsprn.AsString<>'BOOK' then
begin
posmodule.items.edit;

posmodule.itemsprn.AsString:='True';
posmodule.items.post;
end;
posmodule.items.next;
end;

except
end;
posmodule.items.enableControls;








if posmodule.ITEMS.IsEmpty then
begin
 posmodule.CURrFAC.delete;
posmodule.CURRFAC.close;

posmodule.CURRFAC.Filtered:=true;
posmodule.CURRFAC.open;

if posmodule.CURRFAC.IsEmpty   then
begin

posmodule.CURRFAC.Insert;

posmodule.CURRFACTABLENO.AsString:='Take Away';
posmodule.CURRFACIACTIVE.AsString:='C';



posmodule.CURrFAC.POST;
end;
 e_bar.setfocus;
exit;

end;

except

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


end;
posmodule.items.close;
i:=posmodule.CURRFACid.AsInteger;
//posmodule.CURRFAC.Filtered:=false;
//posmodule.CURRFAC.close;
//posmodule.CURRFAC.open;
//posmodule.CURRFAC.locate('id',i,[]);

try
posmodule.CURRFAC.edit;
posmodule.CURRFACprn.AsString:='True';
posmodule.CURRFACIACTIVE.AsString:='False';
posmodule.CURRFAC.post;
posmodule.CURRFAC.Refresh;

except
end;
posmodule.CURRFAC.close;

posmodule.CURRFAC.Filtered:=true;
posmodule.CURRFAC.open;

if posmodule.CURRFAC.IsEmpty   then
begin

posmodule.CURRFAC.Insert;

posmodule.CURRFACTABLENO.AsString:='Delivery';
posmodule.CURRFACIACTIVE.AsString:='C';


posmodule.CURrFAC.POST;
end;
f_touchcash.Enabled:=true;
//cxGrid1.Enabled:=true;
//1: b:=false;
posmodule.items.open;

 e_bar.setfocus;
end;

procedure Tf_touchcash.RzBitBtn15Click(Sender: TObject);
begin
if posmodule.items.IsEmpty then exit;
if posmodule.CURRFACPRN.AsString='True' then
exit;
posmodule.items.edit;
posmodule.itemsqty.AsCurrency:=strtoint((Sender as tRzBitBtn ).caption);

 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;


end;


procedure Tf_touchcash.RzBitBtn16Click(Sender: TObject);
begin
if posmodule.items.IsEmpty then exit;
if (posmodule.CURRFACPRN.AsString='True') or
   (posmodule.CURRFACPAID.AsString='True') then
exit;

if (posmodule.itemsPRN.AsString<>'True') then
posmodule.items.delete
else
begin
if posmodule.CONFIGSMYDEL.AsInteger=1 then
begin
posmodule.passdlg.ValueText:='';
if posmodule.passdlg.ShowModal=mrok then
begin
posmodule.touser.Locate('pass',posmodule.passdlg.ValueText,[]);
if posmodule.touser.FieldByName('posdelete').asstring='True' then
begin


posmodule.items.delete;
end;
end;
try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;


exit;
end;
stock2.close;



stock2.sql.Strings[1]:='where item='''+posmodule.itemsITEM.AsString+'''';


stock2.open;


qty:=posmodule.itemsqty.AsCurrency;

posmodule.items.append;
posmodule.itemsmid.AsString:=posmodule.invoiceid.AsString;
posmodule.itemssite.AsString:=posmodule.invoicesite.AsString;
posmodule.itemsfdate.AsString:=posmodule.invoicefdate.AsString;

posmodule.itemssid.AsString:=posmodule.invoicesid.AsString;
posmodule.itemscontact.AsString:=posmodule.invoicecontact.AsString;
posmodule.itemssalesman.AsString:=posmodule.invoicesalesman.AsString;
 posmodule.itemsPRN.AsString:='False';
posmodule.itemsdiscount.AsCurrency :=STOCK2SALESDISC.AsCurrency;
posmodule.itemsvat.AsCurrency:=STOCK2vat.AsCurrency;
posmodule.itemsdescr.AsString:=STOCK2descr1.AsString;
posmodule.itemsstqty.AsCurrency:=STOCK2QTY.AsCurrency;

posmodule.itemsMYPRN.AsString:=STOCK2MYPRN.AsString;
posmodule.itemsitem.AsString:=STOCK2item.AsString;
posmodule.itemsPACK.AsCurrency:=1;
posmodule.itemsqty.AsCurrency:=-QTY;
posmodule.itemsfrac.AsCurrency:=0;

posmodule.itemscostus.AsCurrency:=STOCK2costus.AsCurrency;
posmodule.itemscostlc.AsCurrency:=STOCK2costlc.AsCurrency;
//posmodule.itemssttype.AsString:=posmodule.detSTOCK2sttype.AsString;
posmodule.itemsyesno.AsString:=STOCK2yesno.AsString;
posmodule.itemsbarcode.AsString:=STOCK2item.AsString;
posmodule.itemsqty.AsCurrency:=-qty;

posmodule.itemsprice.AsCurrency:=STOCK2POSPRICE1.AsCurrency;
posmodule.items.post;

try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;


stock2.close;



end;


 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;



end;

procedure Tf_touchcash.RzBitBtn4Click(Sender: TObject);
begin

//Application.CreateForm(Tf_telep,f_telep);
    if not assigned(f_telep) then
f_telep:=tf_telep.create(self);
try
if f_telep.ShowModal=mrok then
begin




posmodule.CURRFAC.edit;

posmodule.CURRFACNAME.AsString:=f_telep.Query1name.AsString;
posmodule.CURRFACCONTACT.AsString:=f_telep.Query1id.AsString;
//posmodule.CURRFACTABLENO.AsString:='Delivery';
//posmodule.CURRFACIACTIVE.AsString:='D';
posmodule.CURRFACNAME.AsString:=f_telep.Query1NAME.AsString;
posmodule.CURrFAC.POST;
end;
except
end;
 if  assigned(f_telep) then
freeandnil(f_telep);
 e_bar.setfocus;
end;

procedure Tf_touchcash.RzBitBtn3Click(Sender: TObject);
begin
if posmodule.items.IsEmpty=true then
exit;

if posmodule.touser.fieldbyname('posdiscount').AsBoolean=false then

exit;
mypass.PasswordChar:=#0 ;
mypass.PromptText:='Enter Discount % Or Amount:';
mypass.ValueText:='';
try
if mypass.ShowModal=mrok then
begin
posmodule.items.First;
while not posmodule.items.Eof do
begin
posMODULe.stock.close;
posMODULe.stock.ParamByName('MYITEM').ASSTRING:=posmodule.itemsITEM.AsString;

posMODULe.stock.OPEN;
posmodule.items.edit;
if strtofloat(mypass.ValueText)<101 then
posmodule.itemsDISCOUNT.AsCurrency:=posMODULe.stockSALESDISC.AsCurrency+
strtofloat(mypass.ValueText)
else
posmodule.itemsDISCOUNT.AsCurrency:=posMODULe.stockSALESDISC.AsCurrency+strtofloat(mypass.ValueText)/posmodule.CURRFACTOTAL.AsCurrency*100;
posmodule.items.post;
posmodule.items.Next;
end;


end;


except
end;


 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;
 e_bar.setfocus;
end;

procedure Tf_touchcash.RzBitBtn23Click(Sender: TObject);
begin
if posmodule.CURRFACPRN.AsString='True' then
exit;
mypass.PromptText:='Enter Chef Name:';
mypass.ValueText:=posmodule.CURRFACCHEF.AsString ;
if mypass.ShowModal=mrok then
begin
posmodule.CURRFAC.edit;
posmodule.CURRFACCHEF.AsString:=mypass.ValueText;

end;

end;

procedure Tf_touchcash.RzBitBtnbackClick(Sender: TObject);
begin
Close;
exit;
if posmodule.items.IsEmpty then
begin
modalresult:=mrok;
exit;
end;
//Application.CreateForm(Tf_helpdesk,f_helpdesk);
    if not assigned(f_helpdesk) then
f_helpdesk:=tf_helpdesk.create(self);
plabel.Caption:='';
plabel.Color:=$00FFE6CC;



plabel.Blinking:=False;
try
 f_touchcash.Enabled:=false;
f_helpdesk.fcImageBtn1.Visible:=false;
if f_helpdesk.ShowModal=mrok then
begin
btnclose1Click(btnclose1);
e_bar.setfocus;
end;
except
end;
 if  assigned(f_helpdesk) then
freeandnil(f_helpdesk);
 f_touchcash.Enabled:=true;
 cbsp.Checked:=false;
// cxGrid1.Enabled:=true;
e_bar.setfocus;
end;

procedure Tf_touchcash.RzBitBtn2Click(Sender: TObject);
begin
if posmodule.items.IsEmpty then exit;
if posmodule.CURRFACPRN.AsString='True' then
exit;
//Application.CreateForm(Tf_tableno,f_tableno);
    if not assigned(f_tableno) then
f_tableno:=tf_tableno.create(self);
try
if f_tableno.ShowModal=mrok then
begin

if (posmodule.touser.FieldByName('NADJUST').AsString<>'True')

   and (strtofloat(f_tableno.Edit1.text)<0) then

begin
showmessage('No Priviligies!!!');

end
else
begin


posmodule.items.edit;
posmodule.itemsqty.AsCurrency:=strtofloat(f_tableno.Edit1.text);
end;
 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;


end



except
end;
 if  assigned(f_tableno) then
 freeandnil(f_tableno);
end;

procedure Tf_touchcash.RzLabel1Click(Sender: TObject);
begin
if posmodule.items.IsEmpty then exit;
if posmodule.CURRFACPRN.AsString='True' then
exit;
//Application.CreateForm(Tf_mynotes,f_mynotes);
    if not assigned(f_mynotes) then
f_mynotes:=tf_mynotes.create(self);
try
f_mynotes.ShowModal;
except

end;
 if  assigned(f_mynotes) then
 freeandnil(f_mynotes);
end;

procedure Tf_touchcash.cxGrid1DBCardView1StylesGetContentStyle(
  Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
  AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
begin
inherited;
try
astyle:=cxStyle1;

if ((arecord.Values[0]<>null) and (arecord.Values[0]<>0)) then
astyle.Color:=arecord.Values[0]
else
astyle.Color:=cxStyle1.Color;
except
astyle:=cxStyle1;
astyle.Color:=cxStyle1.Color;
end;
end;

procedure Tf_touchcash.cxGridDBCardView1StylesGetContentStyle(
  Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
  AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
begin
inherited;
{try
astyle:=cxStyle1;
astyle.Color:=arecord.Values[0];

except
astyle:=cxStyle1;
end;}
end;

procedure Tf_touchcash.RzLabel2Click(Sender: TObject);
begin
if posmodule.items.IsEmpty then exit;
if posmodule.CURRFACPRN.AsString='True' then
exit;
posmodule.items.edit;
if posmodule.itemsprn.AsString='BOOK' then
posmodule.itemsprn.AsString:='False'
else
posmodule.itemsprn.AsString:='BOOK';

 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;

end;

procedure Tf_touchcash.ttttDBTableView1StylesGetContentStyle(
  Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
  AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
begin
inherited;
try

if arecord.Values[0]='BOOK' then

astyle:=cxStyle7

else
astyle:=cxStyle6;




except
astyle:=cxStyle6;
end;
end;

procedure Tf_touchcash.RzBitBtn19Click(Sender: TObject);
var s:string;
begin
if posmodule.items.IsEmpty then exit;
if posmodule.CURRFACPRN.AsString='True' then
exit;

s:=(Sender as tRzBitBtn ).caption;
s:=s[1]+s[2]+s[3];
posmodule.items.edit;
posmodule.itemsqty.AsCurrency:=strtoint(s)/1000;

 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;

end;

procedure Tf_touchcash.RzBitBtn22Click(Sender: TObject);
begin
if posmodule.CURRFACPRN.AsString='True' then
exit;
end;

procedure Tf_touchcash.OpenInvoiceAfterPrint1Click(Sender: TObject);
begin
posmodule.passdlg.ShowModal;
posmodule.touser.Locate('pass',posmodule.passdlg.ValueText,[]);
if posmodule.touser.FieldByName('esinv').asstring='True' then
begin
posmodule.CURRFAC.edit;
posmodule.CURRFACprn.AsString:='False';
posmodule.CURRFAC.post;


end;

end;

procedure Tf_touchcash.btnexitClick(Sender: TObject);
begin
{if myexit=1 then
begin
modalresult:=mrok;
exit;
end;
if (posmodule.items.IsEmpty=false) and (posmodule.CURRFACTABLENO.AsString<>'Delivery')
then
begin

exit;
end;

modalresult:=mrok  }
posmodule.CURRFAC.edit;
if posmodule.CURRFACTABLENO.AsString='Dine In' then
begin
posmodule.CURRFACTABLENO.AsString:='Take Away';
plabel.Caption:='Take Away';
end
 else
 begin
posmodule.CURRFACTABLENO.AsString:='Dine In';
plabel.Caption:='Dine In';
end;
posmodule.CURRFAC.post;
 plabel.color:=clred;
 plabel.Blinking:=true;


end;

procedure Tf_touchcash.N1Click(Sender: TObject);
var key:word;s:string;
begin

if posMODULe.stock.Active then
posMODULe.stock.close;
s:=posMODULe.stock.sql.Strings[1];
posMODULe.stock.sql.Strings[1]:='';
//MODULe.stock.ParamByName('MYITEM').ASSTRING:='''''';
posMODULe.stock.open;
//Application.CreateForm(Tf_stocklist,f_stocklist);
    if not assigned(f_stocklist) then
f_stocklist:=tf_stocklist.create(self);
 try
 p_stocklist.myenter:=1;
if f_stocklist.showmodal=mrok then
BEGIN
e_bar.Text:=posMODULe.stockitem.AsString ;


posMODULe.stock.close;
posMODULe.stock.sql.Strings[1]:='where item='''+e_bar.Text+'''';
posMODULe.stock.open;
if posmodule.stockBARCODE1.AsString<>'' then
begin

//Application.CreateForm(Tf_selbar,f_selbar);
    if not assigned(f_selbar) then
f_selbar:=tf_selbar.create(self);
f_selbar.DataSource1.DataSet:=posmodule.stock;
f_selbar.ShowModal  ;

if p_selbar.mysel=0 then
begin

e_bar.text:=posmodule.stockitem.AsString;


end
else
if p_selbar.mysel=1 then
begin
e_bar.text:=posmodule.stockBARCODE1.AsString;

end
else
if p_selbar.mysel=2 then
begin
e_bar.text:=posmodule.stockBARCODE2.AsString;

end
else
if p_selbar.mysel=3 then
begin
e_bar.text:=posmodule.stockBARCODE3.AsString;

end
else
if p_selbar.mysel=4 then
begin
e_bar.text:=posmodule.stockBARCODE4.AsString;
end;
end;
 if  assigned(f_selbar) then
freeandnil(f_selbar);


END;
EXCEPT
END;

 posMODULe.stock.close;
posMODULe.stock.sql.Strings[1]:=s;
key:=13;
 if  assigned(f_stocklist) then
freeandnil(f_stocklist);

 if e_bar.text<>'' then
e_barKeyDown(e_bar,key,[ssShift]);






end;



procedure Tf_touchcash.rzceditClick(Sender: TObject);
var s:string;
begin
if posmodule.items.IsEmpty then
begin
 e_bar.setfocus;
exit;
end;
    f_touchcash.Enabled:=false;


//Application.CreateForm(Tf_barcode,f_barcode);
    if not assigned(f_barcode) then
f_barcode:=tf_barcode.create(self);

try
if f_barcode.ShowModal=mrok then
begin
posmodule.CURRFAC.edit;
posmodule.CURRFACsid.AsString:=f_barcode.RzButtonEdit1.text;
posmodule.CURRFACSDISC.AsCurrency:=F_BARCODE.Query1.FIELDBYNAME('DISCOUNT').ASCURRENCY;
posmodule.CURRFACname.AsString:=F_BARCODE.Query1.FIELDBYNAME('sname').AsString;

posmodule.CURRFAC.post;
posmodule.items.first;
while not posmodule.items.Eof do
begin
posmodule.items.edit;
posmodule.itemssid.AsString:=f_barcode.RzButtonEdit1.text;
TRY
POSMODULE.itemsDISCOUNT.AsCurrency:=F_BARCODE.Query1.FIELDBYNAME('DISCOUNT').ASCURRENCY;
EXCEPT
END;

posmodule.items.post;
posmodule.items.next;
end;

end
else
begin
 e_bar.setfocus;
     f_touchcash.Enabled:=true;
exit;
end;
except
end;
f_barcode.query1.close;
 if  assigned(f_barcode) then
freeandnil(f_barcode);


try
repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'touchinv.fr3') ;
repmodule.frxReport1.PrintOptions.Printer:='Default';
s:=posmodule.CURRFACsid.AsString;
if s[1]='4' then
repmodule.frxReport1.PrintOptions.Copies:=2
else
repmodule.frxReport1.PrintOptions.Copies:=1;
repmodule.frxReport1.PrepareReport;
repmodule.frxReport1.PrintOptions.ShowDialog:=false;
if posmodule.CONFIGSMYPRN.AsString<>'OFF' then
repmodule.frxReport1.print;

except
end;





try
posmodule.items.close;
posmodule.items.open;

try
repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'touchorder.fr3') ;
repmodule.frxReport1.PrintOptions.ShowDialog:=false;

repmodule.frxReport1.ShowProgress:=false;

(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''KITCHEN''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSKITCHEN.AsString;


repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN

repmodule.frxReport1.print;

(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''BAR''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSBAR.AsString;

repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;


(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''COCKTAIL''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSCOCKTAIL.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;

(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''FAST FOOD''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSFASTFOOD.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;

(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''OVEN''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSOVEN.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;

(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''BOUCHERY''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSBOUCHERY.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;

(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).filter:='myprn=''SNACK''';
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSSNACK.AsString;
repmodule.frxReport1.PrepareReport;
(repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.OPEN;
IF (repmodule.frxReport1.GetDataset('BDEtable1') as tfrxbdeQUERY ).Query.IsEmpty=FALSE THEN
repmodule.frxReport1.print;

repmodule.frxReport1.PrintOptions.Printer:='Default';

except
end;

posmodule.items.DisableControls;
try
posmodule.items.first;
while not posmodule.items.Eof do
begin
if  posmodule.itemsprn.AsString<>'BOOK' then
begin
posmodule.items.edit;

posmodule.itemsprn.AsString:='True';
posmodule.items.post;
end;
posmodule.items.next;
end;

except
end;
posmodule.items.enableControls;







if posmodule.ITEMS.IsEmpty then
begin
 posmodule.CURrFAC.delete;
posmodule.CURRFAC.close;

posmodule.CURRFAC.Filtered:=true;
posmodule.CURRFAC.open;

if posmodule.CURRFAC.IsEmpty   then
begin

posmodule.CURRFAC.Insert;


posmodule.CURRFACTABLENO.AsString:='Take Away';
posmodule.CURRFACIACTIVE.AsString:='C';


posmodule.CURrFAC.POST;
end;
     f_touchcash.Enabled:=true;
 e_bar.setfocus;
exit;

end;

except

posmodule.ITEMS.cancel;
posmodule.CURrFAC.cancel;
     f_touchcash.Enabled:=true;

end;
posmodule.items.close;
//i:=posmodule.CURRFACid.AsInteger;
//posmodule.CURRFAC.Filtered:=false;
//posmodule.CURRFAC.close;
//posmodule.CURRFAC.open;
//posmodule.CURRFAC.locate('id',i,[]);

try
posmodule.CURRFAC.edit;
posmodule.CURRFACprn.AsString:='True';
posmodule.CURRFACIACTIVE.AsString:='False';
posmodule.CURRFAC.post;
posmodule.CURRFAC.Refresh;

except
end;
posmodule.CURRFAC.close;

posmodule.CURRFAC.Filtered:=true;
posmodule.CURRFAC.open;

if posmodule.CURRFAC.IsEmpty   then
begin

posmodule.CURRFAC.Insert;


posmodule.CURRFACTABLENO.AsString:='Take Away';
posmodule.CURRFACIACTIVE.AsString:='C';


posmodule.CURrFAC.POST;
end;

//1: b:=false;
posmodule.items.open;

     f_touchcash.Enabled:=true;
 e_bar.setfocus;
end;

procedure Tf_touchcash.categBeforeOpen(DataSet: TDataSet);
begin
if posmodule.CONFIGSWHEREIS.AsInteger=0 then
categ.SQL.Strings[1]:='where  STYPE in (19,26)  '
else
categ.SQL.Strings[1]:='where  STYPE in (19,26)  and cast(whereis as integer)='+posmodule.CONFIGSWHEREIS.AsString+'';

end;

procedure Tf_touchcash.stockBeforeOpen(DataSet: TDataSet);
begin
if posmodule.CONFIGSWHEREIS.AsInteger=0 then
stock.SQL.Strings[1]:='where cast(category as integer)=:id and STYPE in (19,26)'
else
stock.SQL.Strings[1]:='where cast(category as integer)=:id and STYPE in (19,26) and whereis='''+posmodule.CONFIGSWHEREIS.AsString+'''';

end;

procedure Tf_touchcash.e_barKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var s,S2,prices:string;b,b_enter,b_tab:boolean;r,price:currency;
    i,j:integer;bep:integer;mycomp:string[20];notint:integer;myb:boolean;
    cp,cpr:real;

    begin
s:=e_bar.text;
if posmodule.CONFIGSMINUSQTY.AsString='YES' then
begin
if length(s)>1 then
begin
if s[1]='-' then
begin
mypass.PasswordChar:='*';
mypass.ValueText:='';
mypass.PromptText:='Enter Password:';
mypass.ShowModal;
touser.open;

if touser.Locate('pass',mypass.ValueText,[]) then
begin
if touser.FieldByName('NADJUST').AsString<>'True' then
begin
E_BAR.Text:='';
 e_bar.SetFocus;
exit;
end;

end
else
begin
E_BAR.Text:='';
 e_bar.SetFocus;
exit;
end;
end;
end;

end;
    myb:=false;

if  (key=13)  then
begin
 if e_bar.text='' then
 begin
 RzBitBtnbackClick(RzBitBtnback);
 exit;
 end;

  myff:=0;

posMODULe.stock.cLOSE;
b:=false;




try

if ((s[1]='2') and (s[2]='7') and (s[3]='0')) or
    ((s[1]='2') and (s[2]='6')  ) then
begin
prices:='';
try
for i:=posmodule.CONFIGSMIZANENO.AsInteger+1 to length(s) do
prices:=prices+s[i];

IF posmodule.CONFIGSMIZANEDIGIT.AsString='YES' THEN
begin
prices:='';
for i:=posmodule.CONFIGSMIZANENO.AsInteger+1 to length(s)-1 do
prices:=prices+s[i];
end;

if (posmodule.CONFIGSFRACTIONPRICE.AsString='YES') THEN
price:=strtofloat(prices)/100
ELSE
price:=strtofloat(prices);




s2:='';
for j:=1 to posmodule.CONFIGSMIZANENO.AsInteger do
S2:=s2+s[j];
b:=true;
except
exit;
end;
S:=S2;

end;





posmodule.qextcomp.close;
posmodule.qextcomp.ParamByName('mycode').AsString:=s;
posmodule.qextcomp.open;
if posmodule.qextcomp.IsEmpty=false then
begin
if posmodule.QEXTCOMPMYTYPE.AsString='ITEM' then
begin
// mypass.PasswordChar:=#0 ;
//mypass.PromptText:='Enter The Amount:';
//mypass.ValueText:='';
//mypass.ShowModal;
f_mycompany.ShowModal   ;

 PRICE:=f_mycompany.RzNumericEdit1.Value;
 //price:=strtofloat(prices);
end;

 posmodule.items.append;
posmodule.itemsmid.AsString:=posmodule.invoiceid.AsString;
posmodule.itemssite.AsString:=posmodule.invoicesite.AsString;
posmodule.itemsfdate.AsString:=posmodule.invoicefdate.AsString;

posmodule.itemssid.AsString:=posmodule.invoicesid.AsString;
posmodule.itemscontact.AsString:=posmodule.invoicecontact.AsString;
posmodule.itemssalesman.AsString:=posmodule.invoicesalesman.AsString;

posmodule.itemsvat.AsCurrency:=0;
posmodule.itemsCONTACT.AsCurrency:=posmodule.CURRFACCONTACT.AsCurrency ;
posmodule.itemssid.AsString:=posmodule.CURRFACsid.AsString;

posmodule.itemsdescr.AsString:=posmodule.qextcompCOMPANY.AsString;
posmodule.itemsstqty.AsCurrency:=0;

posmodule.itemsitem.AsString:=S;
posmodule.itemsPACK.AsCurrency:=1;
posmodule.itemsEXTYESNO.AsInteger:=1;

//posmodule.itemssttype.AsString:=posmodule.detstocksttype.AsString;

posmodule.itemsbarcode.AsString:=s;
posmodule.itemsqty.AsCurrency:=1;
posmodule.itemsPRICE.AsCurrency:=price;
posmodule.items.Post;

E_BAR.Text:='';
//e_barExit(e_bar);
E_BAR.SetFocus;
//e_barEnter(e_bar);

exit;
end;


except
EXIT;
end;









{try
r:=strtofloat(s);
try
notint:=0;
j:=strtoint(s);

except
  notint:=1;
end;
except
notint:=0;
end;
}
{
notint:=0;
if ((s[1]='-') or (notint=1) ) then
begin
mypass.PasswordChar:='*';
mypass.ValueText:='';
mypass.PromptText:='Enter Password:';
mypass.ShowModal;
touser.open;

if touser.Locate('pass',mypass.ValueText,[]) then
begin
if touser.FieldByName('udelete').AsString<>'True' then
begin

exit;
end;

end
else
begin

exit;
end;
end;

}
posmodule.barcodes.close;
posmodule.barcodes.ParamByName('myitem').AsString:=s;
posmodule.barcodes.open;
if  posmodule.barcodes.IsEmpty=false then
begin
 s:=posmodule.barcodes.fieldbyname('item').AsString;

   try
  cp:=posmodule.barcodes.fieldbyname('pack').AsCurrency;
  if cbsp.Checked then
  cpr:=posmodule.barcodes.fieldbyname('price2').AsCurrency
  else
  cpr:=posmodule.barcodes.fieldbyname('price'+posmodule.CONFIGSPRICE.AsString).AsCurrency;
 except
   cpr:=posmodule.barcodes.fieldbyname('price').AsCurrency ;
 end;
 myb:=true;

end;


posMODULe.stock.ParamByName('MYITEM').ASSTRING:=s;

posMODULe.stock.OPEN;
if posmodulE.stoCK.IsEmpty=FALSE then
begin
 plabel.Caption:='Item Exist  :';
 plabel.color:=clgreen;
 plabel.Blinking:=False;




posmodule.items.append;
posmodule.itemsmid.AsString:=posmodule.invoiceid.AsString;
posmodule.itemssite.AsString:=posmodule.invoicesite.AsString;
posmodule.itemsfdate.AsString:=posmodule.invoicefdate.AsString;

posmodule.itemssid.AsString:=posmodule.invoicesid.AsString;
posmodule.itemscontact.AsString:=posmodule.invoicecontact.AsString;
posmodule.itemssalesman.AsString:=posmodule.invoicesalesman.AsString;
if posmodule.CURRFACSDISC.AsCurrency<>0 then
posmodule.itemsDISCOUNT.AsCurrency:=posmodule.CURRFACSDISC.AsCurrency
else
begin
if posmodule.CONFIGSDISCOUNTTYPE.AsInteger=2 then
posmodule.itemsdiscount.AsCurrency :=posmodule.stockdisc2.AsCurrency
else
posmodule.itemsdiscount.AsCurrency :=posmodule.stockSALESDISC.AsCurrency;
end;

posmodule.itemsvat.AsCurrency:=posmodule.stockvat.AsCurrency;
posmodule.itemsCONTACT.AsCurrency:=posmodule.CURRFACCONTACT.AsCurrency ;
posmodule.itemssid.AsString:=posmodule.CURRFACsid.AsString;
 posmodule.itemsMYPRN.AsString:=posmodule.stockMYPRN.AsString;
posmodule.itemsdescr.AsString:=posmodule.stockdescr1.AsString;
posmodule.itemsstqty.AsCurrency:=posmodule.stockQTY.AsCurrency;

posmodule.itemsitem.AsString:=posmodule.stockitem.AsString;
posmodule.itemsPACK.AsCurrency:=1;

posmodule.itemscostus.AsCurrency:=posmodule.stockcostus.AsCurrency;
posmodule.itemscostlc.AsCurrency:=posmodule.stockcostlc.AsCurrency;
//posmodule.itemssttype.AsString:=posmodule.detstocksttype.AsString;
posmodule.itemsyesno.AsString:=posmodule.stockyesno.AsString;
posmodule.itemsbarcode.AsString:=s;
posmodule.itemsqty.AsCurrency:=1;
 if posmodule.CONFIGSPRICE.AsInteger=2 then
posmodule.itemsprice.AsCurrency:=posmodule.stockPRICEc.AsCurrency
else
 if posmodule.CONFIGSPRICE.AsInteger=3 then
posmodule.itemsprice.AsCurrency:=posmodule.stockPRICEe.AsCurrency
else

posmodule.itemsprice.AsCurrency:=posmodule.stockPOSPRICE1.AsCurrency;



 if s=posmodule.stockbarcode1.AsString then
begin
posmodule.itemsqty.AsCurrency:=1;
posmodule.itemspack.AsCurrency:=posmodule.stockpack1.AsCurrency;
posmodule.itemsprice.AsCurrency:=posmodule.stockprice1.AsCurrency;
end
else
if s=posmodule.stockbarcode2.AsString then
begin
posmodule.itemsqty.AsCurrency:=1;
posmodule.itemspack.AsCurrency:=posmodule.stockpack2.AsCurrency;
posmodule.itemsprice.AsCurrency:=posmodule.stockprice2.AsCurrency;
end
else
if s=posmodule.stockbarcode3.AsString then
begin
posmodule.itemsqty.AsCurrency:=1;
posmodule.itemspack.AsCurrency:=posmodule.stockpack3.AsCurrency;
posmodule.itemsprice.AsCurrency:=posmodule.stockprice3.AsCurrency;
end
else
if s=posmodule.stockbarcode4.AsString then
begin
posmodule.itemsqty.AsCurrency:=1;
posmodule.itemspack.AsCurrency:=posmodule.stockpack4.AsCurrency;
posmodule.itemsprice.AsCurrency:=posmodule.stockprice4.AsCurrency;
end;



if myb then
begin
posmodule.itemsqty.AsCurrency:=1;
posmodule.itemspack.AsCurrency:=cp;
posmodule.itemsprice.AsCurrency:=cpr;
if posmodule.itemsprice.AsCurrency=0 then
posmodule.itemsprice.AsCurrency:=posmodule.stockposprice1.AsCurrency;


if cbsp.Checked then
begin
if (posmodule.itemspack.AsCurrency=1) then
BEGIN
if (posmodulE.stoCKpricee.AsCurrency<>0 ) then
posmodule.itemsprice.AsCurrency:=posmodule.stockPRICEE.AsCurrency
END
else
begin
if (posmodulE.stoCKpricef.AsCurrency<>0 ) then
posmodule.itemsprice.AsCurrency:=posmodule.stockPRICEf.AsCurrency;
end;

end;




end;

  posmodule.itemsMYPRN.AsString:=posmodule.stockMYPRN.AsString;


        if b then
        begin
        posmodule.itemsqty.AsCurrency:=price/
        posmodule.itemsprice.AsCurrency
        end;




        if qty<>0 then
        begin

                posmodule.itemsqty.AsCurrency:=qty*posmodule.itemsqty.AsCurrency;

                qty:=0;
        end;


       // label2.Caption:=floattostr(strtofloat(label2.Caption)+posmodule.ITEMStotal.AsInteger);
       // if  creditacc.active then
       // if  strtofloat(label2.caption)>creditaccCREDITLIMIT.AsCurrency then
       // begin
   

       // posmodule.items.delete;
       //  E_BAR.Text:='';


        if posmodule.itemsprice.AsFloat=0 then
        begin
               // imz.Visible:=true;
              // try
              //  MessageBeep($0FFFFFFFF);

              //  for bep:=1 to 20 do
              //  Beep();
               //  except
               //  end;

               plabel.Caption:='Price Is Zero  :';
               plabel.color:=clred;
               plabel.Blinking:=true;
              // www.PlayItem(1);


        end;


end
else
begin

if (length(s)<=5) then
BEGIN
TRY
qty:=strtofloat(s)
EXCEPT
END;
END
else
begin

qty:=0;
 plabel.Caption:='Item Not Exist !!!!!  :';
 plabel.color:=clred;
 plabel.Blinking:=true;
// www.PlayItem(0);


end;
end  ;

if (qty<>0) then
begin
lqty.Visible:=true;
lqty.color:=clred;
LQTY.Caption:=FLOATTOSTR(QTY);
 lqty.Blinking:=true;
 end
 else
 BEGIN
lqty.Visible:=false;
LQTY.Caption:=' ';
 lqty.Blinking:=FALSE;
 lqty.color:=clSILVER;

 END;
if (trim(e_bar.text)<>'') then
begin
E_BAR.Text:='';
 e_bar.SetFocus;
end;
E_BAR.Text:='';

POSMODULE.qitinfo.CLOSE;
POSMODULE.qitinfo.OPEN;

end;



try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;

 try
         mycomp:=posmodule.tocomp.fieldbyname('NAME1').AsString;
         mycomp:=mycomp+'....................';
         if posmodule.CONFIGSMYCOM.AsInteger<>0 then
       begin
        // ccc.PutString(#$1b#$40);

  //ccc.PutString(mycomp+'Your amount = '+dbedit12.Text);
       end;
        except
        end;



END;


procedure Tf_touchcash.Design1Click(Sender: TObject);
begin
if posmodule.CONFIGSEXTYESNO.AsString='YES' then
exit;
if posmodule.touser.FieldByName('UDESIGN').AsBoolean=true then
begin
///Application.CreateForm(Tf_item,f_item);
    if not assigned(f_item) then
f_item:=tf_item.Create(self);

f_item.query1.ParamByName('myitem').AsString:=stockitem.AsString;
f_item.query1.open;
try
f_item.ShowModal;
except
end;
f_item.Query1.close;
 if  assigned(f_item) then
freeandnil(f_item);

end;
end;

procedure Tf_touchcash.FormCreate(Sender: TObject);
begin
try
//ccc.ComNumber:=posmodule.CONFIGSMYCOM.AsInteger;
except
end;

myexit:=0;
end;

procedure Tf_touchcash.ttttDBTableView1DblClick(Sender: TObject);
begin
if posmodule.items.IsEmpty=true then
exit;

if posmodule.touser.fieldbyname('CHANGEPRICE').AsBoolean=false then

exit;
mypass.PasswordChar:=#0 ;
mypass.PromptText:='Enter The New Price:';
mypass.ValueText:=posmodule.itemsprice.AsString;
try
if mypass.ShowModal=mrok then
begin
posmodule.items.edit;

posmodule.itemsprice.AsCurrency:=strtofloat(mypass.ValueText);
posmodule.items.post;
 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;
end;


except
end;
 e_bar.setfocus;


end;

procedure Tf_touchcash.OpenDrawer1Click(Sender: TObject);
begin
 repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'drawer.fr3') ;
 repmodule.frxReport1.PrepareReport;
repmodule.frxReport1.PrintOptions.ShowDialog:=false;
repmodule.frxReport1.ShowProgress:=false;
repmodule.frxReport1.print;

end;

procedure Tf_touchcash.ShowBarcode1Click(Sender: TObject);
begin
//Application.CreateForm(Tf_selbar,f_selbar);
    if not assigned(f_selbar) then
f_selbar:=tf_selbar.create(self);
try
f_selbar.ShowModal;
except
end;
 if  assigned(f_selbar) then
 freeandnil(f_selbar);

end;

procedure Tf_touchcash.RzBitBtn1Click(Sender: TObject);
begin

if posmodule.items.IsEmpty then
begin
 e_bar.setfocus;
exit;
end;

posmodule.CURRFAC.Insert;

posmodule.CURRFACTABLENO.AsString:='Take Away';
posmodule.CURRFACIACTIVE.AsString:='C';


posmodule.CURrFAC.POST;
e_bar.setfocus;
end;

procedure Tf_touchcash.btnprintClick(Sender: TObject);
var s:string;
begin

try
repmodule.frxReport1.LoadFromFile(extractfilepath(application.exename)+'touchinv.fr3') ;
//repmodule.frxReport1.PrintOptions.Printer:='Default';
s:=posmodule.CURRFACsid.AsString;
if trim(s)<>'' then
begin

if s[1]='4' then
repmodule.frxReport1.PrintOptions.Copies:=2
else
repmodule.frxReport1.PrintOptions.Copies:=1;
end;
repmodule.frxReport1.PrepareReport;
repmodule.frxReport1.PrintOptions.ShowDialog:=false;
if trim(posmodule.CONFIGSPINVOICE.AsString)<>'' then
repmodule.frxReport1.PrintOptions.Printer:=posmodule.CONFIGSPINVOICE.AsString;

repmodule.frxReport1.print;

except
end;

  e_bar.setfocus;
end;

procedure Tf_touchcash.DBCtrlGrid1Click(Sender: TObject);
begin
e_bar.SetFocus;
end;

procedure Tf_touchcash.SpeedButton1Click(Sender: TObject);
begin
if posmodule.items.IsEmpty=true then
exit;

if posmodule.touser.fieldbyname('posdiscount').AsBoolean=false then

exit;
mypass.PasswordChar:=#0 ;
mypass.PromptText:='Enter Discount Amount:';
mypass.ValueText:='';
try
if mypass.ShowModal=mrok then
begin
posmodule.items.edit;
if strtofloat(mypass.ValueText)<101 then
posmodule.itemsDISCOUNT.AsCurrency:=strtofloat(mypass.ValueText);
posmodule.items.post;
 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;
end;


except
end;
 e_bar.setfocus;


end;

procedure Tf_touchcash.N01Click(Sender: TObject);
var k:word;
begin

k:=13;
e_bar.Text:='-'+posmodule.itemsQTY.AsString;
e_barKeyDown(e_bar,k,[ssLeft]);
e_bar.Text:=posmodule.itemsitem.AsString;
e_barKeyDown(e_bar,k,[ssLeft]);
e_bar.SetFocus;



end;

procedure Tf_touchcash.ExcludeVat1Click(Sender: TObject);
begin
posmodule.items.First;
while not posmodule.items.Eof do
begin


posmodule.items.edit;

posmodule.itemsVAT.AsCurrency:=0;
posmodule.itemsVATAMOUNT.AsCurrency:=0;

posmodule.items.post;
posmodule.items.Next;
end;
   try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;
 e_bar.setfocus;

end;

procedure Tf_touchcash.DBCtrlGrid2Click(Sender: TObject);
begin
 try
        e_bar.SetFocus;
         except
         end;
end;

procedure Tf_touchcash.RzBitBtn26Click(Sender: TObject);
var s:string;
begin
if posmodule.items.IsEmpty then exit;
if posmodule.CURRFACPRN.AsString='True' then
exit;

s:=(Sender as tRzBitBtn ).caption;
s:=s[1]+s[2];
posmodule.items.edit;
posmodule.itemsqty.AsCurrency:=strtoint(s)/1000;

 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;


end;

procedure Tf_touchcash.Barcodeslist1Click(Sender: TObject);
var key:word;s:string;
begin
f_stocklist2:=tf_stocklist2.Create(self);
f_stocklist2.Query1.open;
try
if f_stocklist2.ShowModal=mrok then
begin
 key:=13;
e_bar.text:=f_stocklist2.Query1BARCODE.AsString;
e_barKeyDown(e_bar,key,[ssShift]);
end;
except
end;
f_stocklist2.Query1.close;
f_stocklist2.Release;

e_bar.SetFocus;
end;


procedure Tf_touchcash.RzBitBtn24Click(Sender: TObject);
begin
if posmodule.items.IsEmpty=true then
exit;


if posmodule.touser.fieldbyname('posdiscount').AsBoolean=false then

exit;
mypass.PasswordChar:=#0 ;
mypass.PromptText:='Enter Discount %:';
mypass.ValueText:='';
try
if mypass.ShowModal=mrok then
begin

posmodule.items.edit;
if strtofloat(mypass.ValueText)<101 then
posmodule.itemsDISCOUNT.AsCurrency:=strtofloat(mypass.ValueText);
posmodule.items.post;
 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;
end;


except
end;
 e_bar.setfocus;




end;

end.
