unit p_touchcash3;

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;

type
  Tf_touchcash3 = class(TForm)
    RzPanel1: TRzPanel;
    RzPanel2: TRzPanel;
    tttt: TcxGrid;
    ttttDBTableView1: TcxGridDBTableView;
    ttttDBTableView1DESCR: TcxGridDBColumn;
    ttttDBTableView1FRAC: TcxGridDBColumn;
    ttttDBTableView1TOTAL: TcxGridDBColumn;
    ttttLevel1: TcxGridLevel;
    RzPanel3: TRzPanel;
    RzPanel4: TRzPanel;
    cxGrid1: TcxGrid;
    cxGrid1DBCardView1: TcxGridDBCardView;
    cxGrid1DBCardView1Row1: TcxGridDBCardViewRow;
    cxGrid1DBCardView1Row2: TcxGridDBCardViewRow;
    cxGrid1Level1: TcxGridLevel;
    RzPanel5: TRzPanel;
    categ: TQuery;
    dcateg: TDataSource;
    stock: TQuery;
    dstock: TDataSource;
    categcategory: TStringField;
    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;
    RzBitBtn6: TRzBitBtn;
    locstock: TTable;
    dlocstock: TDataSource;
    ccc: TApdComPort;
    cxGrid2: TcxGrid;
    cxGridDBCardView1: TcxGridDBCardView;
    cxGridDBCardViewRow1: TcxGridDBCardViewRow;
    cxGridLevel1: TcxGridLevel;
    cxGridDBCardView1Row1: TcxGridDBCardViewRow;
    RzBitBtn5: TRzBitBtn;
    RzBitBtn7: TRzBitBtn;
    RzBitBtn9: TRzBitBtn;
    RzBitBtn10: TRzBitBtn;
    RzBitBtn11: TRzBitBtn;
    RzBitBtn12: TRzBitBtn;
    RzBitBtn13: TRzBitBtn;
    RzBitBtn14: TRzBitBtn;
    RzBitBtn15: TRzBitBtn;
    RzBitBtn16: TRzBitBtn;
    RzBitBtn17: TRzBitBtn;
    RzBitBtn18: TRzBitBtn;
    RzBitBtn20: TRzBitBtn;
    RzBitBtn19: TRzBitBtn;
    RzBitBtn21: 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;
    cxGrid1DBCardView1Row3: TcxGridDBCardViewRow;
    cxGrid1DBCardView1Row4: TcxGridDBCardViewRow;
    loccateg: TQuery;
    dloccateg: TDataSource;
    categmycolor: TIntegerField;
    cxGridDBCardView1Row2: TcxGridDBCardViewRow;
    ttttDBTableView1Column1: TcxGridDBColumn;
    PopupMenu1: TPopupMenu;
    OpenInvoiceAfterPrint1: TMenuItem;
    RzDBGrid1: TDBGrid;
    btnexit: TRzBitBtn;
    fff: TRaDBSearch;
    N1: TMenuItem;
    stockMYPRN: TStringField;
    rzcedit: TRzBitBtn;
    IvTranslator1: TIvTranslator;
    e_bar: TEdit;
    touser: TTable;
    plabel: TBUBlinkingLabel;
    toushview: 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;
    cbsp: TCheckBox;
    btnprint: TRzBitBtn;
    Cbprice: TComboBox;
    procedure FormShow(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure cxGrid1DBCardView1CellClick(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 RzBitBtn6Click(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 CbpriceChange(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  f_touchcash3: Tf_touchcash3;qty:currency;bb:boolean;c:currency;LAST:STRING;
     myexit:integer;  myff:integer;
implementation

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

{$R *.DFM}

procedure Tf_touchcash3.FormShow(Sender: TObject);
begin
categ.open;
stock.open;
locstock.open;
loccateg.open;

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

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

procedure Tf_touchcash3.cxGrid1DBCardView1CellClick(
  Sender: TcxCustomGridTableView;
  ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
  AShift: TShiftState; var AHandled: Boolean);
begin
inherited;
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 cbprice.Text='1' then
posmodule.itemsprice.AsCurrency:=posmodule.stockPOSPRICE1.AsCurrency
else
if cbprice.Text='2' then
posmodule.itemsprice.AsCurrency:=posmodule.stockPRICEc.AsCurrency
else
if cbprice.Text='3' then
posmodule.itemsprice.AsCurrency:=posmodule.stockPRICEe.AsCurrency;
if posmodule.itemsprice.AsCurrency=0 then
posmodule.itemsprice.AsCurrency:=posmodule.stockPOSPRICE1.AsCurrency;





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;
if cbprice.Text='1' then
posmodule.itemsprice.AsCurrency:=posmodule.stockPOSPRICE1.AsCurrency
else
if cbprice.Text='2' then
posmodule.itemsprice.AsCurrency:=posmodule.stockPRICEc.AsCurrency
else
if cbprice.Text='3' then
posmodule.itemsprice.AsCurrency:=posmodule.stockPRICEe.AsCurrency;
if posmodule.itemsprice.AsCurrency=0 then
posmodule.itemsprice.AsCurrency:=posmodule.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;
end;


procedure Tf_touchcash3.RzDBGrid1Exit(Sender: TObject);

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

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

while not posmodulE.items.eof do
begin

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;

end;

procedure Tf_touchcash3.RzBitBtn8Click(Sender: TObject);
begin
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_touchcash3.btnclose1Click(Sender: TObject);
var s:string;i:integer;
begin

//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);
exit;
end;

except
exit;
end;
f_closetable.query1.close;
 if  assigned(f_closetable) then
freeandnil(f_closetable);

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)+'touchinv.fr3') ;
s:=repmodule.frxReport1.PrintOptions.Printer;
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.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;

(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;

(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;

(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;



repmodule.frxReport1.PrintOptions.Printer:=s;

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:='Delivery';
posmodule.CURRFACIACTIVE.AsString:='D';


posmodule.CURrFAC.POST;
end;
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:='D';


posmodule.CURrFAC.POST;
end;

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

 e_bar.setfocus;
end;

procedure Tf_touchcash3.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_touchcash3.RzBitBtn16Click(Sender: TObject);
begin
if myexit=1  then exit;

if posmodule.items.IsEmpty then exit;
if posmodule.CURRFACPRN.AsString='True' then
exit;
posmodule.items.delete;

 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;


end;

procedure Tf_touchcash3.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.CURrFAC.POST;
end;
except
end;
 if  assigned(f_telep) then
freeandnil(f_telep);
 e_bar.setfocus;
end;

procedure Tf_touchcash3.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.items.edit;
if strtofloat(mypass.ValueText)<101 then
posmodule.itemsDISCOUNT.AsCurrency:=strtofloat(mypass.ValueText)
else
posmodule.itemsDISCOUNT.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_touchcash3.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_touchcash3.RzBitBtn6Click(Sender: TObject);
begin
//Application.CreateForm(Tf_helpdesk,f_helpdesk);
 if not assigned(f_helpdesk) then
f_helpdesk:=tf_helpdesk.create(self);
try
f_helpdesk.ShowModal;
except
end;
 if  assigned(f_helpdesk) then
freeandnil(f_helpdesk);
e_bar.setfocus;
end;

procedure Tf_touchcash3.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
posmodule.items.edit;
posmodule.itemsqty.AsCurrency:=strtofloat(f_tableno.Edit1.text);

 try
RzDBGrid1.OnExit(RzDBGrid1);
except
end;


end



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

procedure Tf_touchcash3.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_touchcash3.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_touchcash3.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_touchcash3.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_touchcash3.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_touchcash3.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_touchcash3.RzBitBtn22Click(Sender: TObject);
begin
if posmodule.CURRFACPRN.AsString='True' then
exit;
end;

procedure Tf_touchcash3.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_touchcash3.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
f_msgdlg:=tf_msgdlg.create(self);
try
f_msgdlg.mymsg.Caption:='The Invoice Not Empty!!!';
f_msgdlg.ShowModal;
except
end;
f_msgdlg.Release;


exit;
end;

modalresult:=mrok;
end;

procedure Tf_touchcash3.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
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;
END;
EXCEPT
END;
 if  assigned(f_selbar) then
freeandnil(f_selbar);
 if  assigned(f_stocklist) then
freeandnil(f_stocklist);

 posMODULe.stock.close;
posMODULe.stock.sql.Strings[1]:=s;
key:=13;

e_barKeyDown(e_bar,key,[ssShift]);






end;



procedure Tf_touchcash3.rzceditClick(Sender: TObject);
var s:string;
begin
//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
exit;

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:='Delivery';
posmodule.CURRFACIACTIVE.AsString:='D';


posmodule.CURrFAC.POST;
end;
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:='D';


posmodule.CURrFAC.POST;
end;

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

 e_bar.setfocus;
end;

procedure Tf_touchcash3.categBeforeOpen(DataSet: TDataSet);
begin
if posmodule.CONFIGSWHEREIS.AsInteger=0 then
categ.SQL.Strings[1]:='where category is not null  and STYPE in (19,26)'
else
categ.SQL.Strings[1]:='where category is not null  and STYPE in (19,26) and whereis='''+posmodule.CONFIGSWHEREIS.AsString+'''';

end;

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

end;

procedure Tf_touchcash3.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('posdelete').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


  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;

  cp:=posmodule.barcodes.fieldbyname('pack').AsCurrency;
  cpr:=posmodule.barcodes.fieldbyname('price1'+cbprice.Text).AsCurrency;

 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 cbprice.Text='1' then
posmodule.itemsprice.AsCurrency:=posmodule.stockPOSPRICE1.AsCurrency
else
if cbprice.Text='2' then
posmodule.itemsprice.AsCurrency:=posmodule.stockPRICEc.AsCurrency
else
if cbprice.Text='3' then
posmodule.itemsprice.AsCurrency:=posmodule.stockPRICEe.AsCurrency;
if posmodule.itemsprice.AsCurrency=0 then
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:=posmodule.stockposprice1.AsCurrency*cp;
//if posmodule.itemsprice.AsCurrency=0 then
posmodule.itemsprice.AsCurrency:=cpr;
if posmodule.itemsprice.AsCurrency=0 then
begin
if cbprice.Text='1' then
posmodule.itemsprice.AsCurrency:=posmodule.stockPOSPRICE1.AsCurrency
else
if cbprice.Text='2' then
posmodule.itemsprice.AsCurrency:=posmodule.stockPRICEc.AsCurrency
else
if cbprice.Text='3' then
posmodule.itemsprice.AsCurrency:=posmodule.stockPRICEe.AsCurrency;
if posmodule.itemsprice.AsCurrency=0 then
posmodule.itemsprice.AsCurrency:=posmodule.stockPOSPRICE1.AsCurrency;
end;

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_touchcash3.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_touchcash3.FormCreate(Sender: TObject);
begin
myexit:=0;
end;

procedure Tf_touchcash3.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_touchcash3.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_touchcash3.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_touchcash3.RzBitBtn1Click(Sender: TObject);
begin

posmodule.CURRFAC.Insert;

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


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

procedure Tf_touchcash3.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 posmodule.CONFIGSMYPRN.AsString<>'OFF' then
repmodule.frxReport1.print;

except
end;


end;

procedure Tf_touchcash3.CbpriceChange(Sender: TObject);
begin
e_bar.SetFocus;
end;

end.
