Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help With VFP DryCleaning POS Pickup Form

Status
Not open for further replies.

foxprox558

Programmer
Oct 19, 2013
53
US
Ok, So if you will take a look at the picture attached to the thread, you will see the basic layout of the pickup form

the order database is arranged to store the customer number of the customer, when you choose the customer from the top of the form, search through the orders database and find all the orders so you can select the ones you need to pick up.
I need help with putting them in this grid and having it to where you can select multiple orders and have it auto-total in the bottom text box, then save them all as paid when you push pay. This Should Be The Final Problem I'm having. Sorry for the numerous posts, but as said before, I'm kind of new to FoxPro!
 
No, I was getting errors with init from the beginning.
Errors include:
customer alias not found
details alias not found
cyclic relation
unknown member COLUMN3 (~x6)
 
if you quit foxpro and restart, you still get these errors ?
do you have only this form with 2 grids and Find button and pay button. you should not have any combobox. i think there is a code omewhere you are executing and throuing out everything.

i suggest you try to understand the code presented first before debugging. if you have any question on any of the statements then you can ask again.

in the meantime i will test the code and give you the results. you may be doing somewhere in the code 'use accounts' or 'use orders'. again, try to understand 'use accounts' 'use accounts alias customer in 0' and 'select customer'. do not debug until you know the difference.


nasib
 
Hi Foxprox558:

* i just check the code it. it requires many enhancements. the 2 bugs that i found are :
* in Find.click() you need to initialise the TotCoxtx to 0 as the following. insert this after the local statemnt
* Bug 1 fix
store 0 to TotCost1, TotCost2, TotCost3, TotCost4, TotCost5, TotCost6, TotCost7, TotCost8


* bug 2 and fix
go t_CurRec
* replace the above 1 line with the following 3 lines in both methods ( find.click() and pay.click())

if not ( eof() or bof() )
go t_CurRec
endif


* you need to enhance all the code as you learn. for example, you do not need to 'index on' in the init(). but you have * to know where to put these statements according to your program flow.



 
Hi Foxpro558

Below the code for a fully working demo for what your trying to do. Just copy it into a PRG file and run it.
Please have a look at the AfterRowColChange() method and the different Click() methods. I think they might lead you into the right direction.
Enjoy
MarK

***code starts here***********************************************
PUBLIC oForm

oForm = NEWOBJECT("form1")
ADDPROPERTY(oForm, "la_Sales[1]")
oForm.Show
Read Events
Close all
Clear All
RETURN


**************************************************
DEFINE CLASS chkBox1 AS CheckBox
Visible = .T.
Caption = " "

PROCEDURE Click()
LOCAL lc_Alias, li_RecNo
lc_Alias = ALIAS()
li_RecNo = RECNO(lc_Alias)

GOTO li_RecNo IN (lc_Alias)

Select SUM(N_Price) FROM curSalesSelection ;
WHERE curSalesSelection.L_Paid = .T. ;
INTO ARRAY Thisform.la_Sales

ThisForm.txtTotalSales.Value = ThisForm.la_Sales[1]

IF VARTYPE(ThisForm.la_Sales[1]) != "N"
ThisForm.txtTotalSales.Value = 0

Endif

ThisForm.Refresh()
ENDPROC
ENDDEFINE

DEFINE CLASS form1 AS Form
AutoCenter = .T.
Caption = "Sales"
Height = 480
Width = 660
MinHeight = This.Height
MinWidth = This.Width


ADD OBJECT lblLastName AS Label WITH ;
Caption = "Customer Lastname", ;
Left = 12, ;
Top = 6, ;
Anchor = 3

ADD OBJECT lblCustomers AS Label WITH ;
Caption = "Customer Names", ;
Left = 10, ;
Top = 30, ;
Anchor = 3

ADD OBJECT lblSelection AS Label WITH ;
Caption = "Sales", ;
Left = 300, ;
Top = 30, ;
Anchor = 1 + 2

ADD OBJECT grdCustomer AS Grid WITH ;
Left = 10, ;
Top = 48, ;
Width = 270, ;
Height = 408, ;
Anchor = 1 + 2 + 4, ;
Visible = .F.

PROCEDURE grdCustomer.AfterRowColChange()
LPARAMETERS nColIndex

SELECT * FROM curSales ;
WHERE curSelection.C_CID = curSales.C_CID ;
INTO CURSOR curSalesSelection READWRITE


IF _Tally > 0
WITH Thisform.grdSales
.Visible = .T.
.ColumnCount = -1
.RecordSource = "curSalesSelection"
.Column1.ReadOnly = .T.
.Column2.ReadOnly = .T.
.Column3.ReadOnly = .T.
.Column3.Sparse = .F.
.Column3.Text1.InputMask = "9999.99"
.Column4.Sparse = .F.
.Column4.AddObject("chkBoxSelection", "chkBox1")
.Column4.RemoveObject("Text1")
.Column4.CurrentControl = "chkBoxSelection"

ENDWITH

WITH Thisform
.cmdSave.Visible = .T.
.txtTotalSales.Visible = .T.
.txtTotalSales.Value = 0
ENDWITH
ELSE
WITH Thisform
.grdSales.Visible =.F.
.cmdSave.Visible = .F.
.txtTotalSales.Visible = .F.
ENDWITH
ENDIF

ThisForm.Refresh()

ENDPROC


ADD OBJECT grdSales AS Grid WITH ;
Left = 300, ;
Top = 48, ;
Width = 330, ;
Height = 342, ;
Anchor = 1 + 2 + 4 + 8, ;
Visible = .F.


ADD OBJECT txtTotalSales AS Textbox WITH ;
Left = 366, Top = 396, Height = 42, Width = 264, Value = 0, InputMask = "99999.99", Anchor = 2 + 4 + 8, Visible = .F. , ;
FontBold = .T., FontSize = 24

ADD OBJECT cmdSave AS CommandButton WITH ;
Left = 300, Top = 396, Height = 42, Width = 60, Caption = "Save", Anchor = 2 + 4, Visible = .F.

PROCEDURE cmdSave.Click()
= MESSAGEBOX("You saved your change", 0, "Sales out")

ENDPROC

ADD OBJECT txtCustomer AS Textbox WITH ;
Left = 120, Top = 6, Height = 21, Width = 120, Format = "!"

ADD OBJECT cmdSearch AS CommandButton WITH ;
Left = 252, Top = 6, Height = 21, Width = 90, Caption = "Search"

PROCEDURE cmdSearch.Click()

SELECT * FROM curCustomer ;
WHERE UPPER(curCustomer.C_LName) = ALLTRIM(UPPER(Thisform.txtCustomer.Value)) ;
INTO CURSOR curSelection

WITH Thisform.grdCustomer
.Visible = .T.
.ColumnCount = -1
.RecordSource = "curSelection"
ENDWITH

WITH ThisForm
.grdSales.Visible = .F.
.txtTotalSales.Visible =.F.
.cmdSave.Visible = .F.
.Refresh()
ENDWITH
ENDPROC

PROCEDURE Destroy
CLOSE ALL
Clear Events

ENDPROC

PROCEDURE Load
CREATE CURSOR curCustomer (C_CID C(3), C_LName C(20))
INSERT INTO curCustomer (C_CID, C_LName) VALUES ("CI1", "Smith Frank")
INSERT INTO curCustomer (C_CID, C_LName) VALUES ("CI2", "Smith Joe")
INSERT INTO curCustomer (C_CID, C_LName) VALUES ("CI3", "Klein Frank")
INSERT INTO curCustomer (C_CID, C_LName) VALUES ("CI4", "Klein Suzy")
INSERT INTO curCustomer (C_CID, C_LName) VALUES ("CI5", "Bogart Humphrey")
INSERT INTO curCustomer (C_CID, C_LName) VALUES ("CI6", "Peter Dummy")
LOCATE

CREATE CURSOR curSales (C_CID C(3), C_Descri C(20), N_Price N(4,2), L_Paid L)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI1", "Description", 4.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI1", "Description", 14.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI1", "Description", 24.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI1", "Description", 34.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI2", "Description", 54.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI2", "Description", 64.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI2", "Description", 47.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI2", "Description", 48.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI3", "Description", 44.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI3", "Description", 42.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI3", "Description", 64.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI4", "Description", 94.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI4", "Description", 84.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI4", "Description", 74.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI5", "Description", 64.25, .F.)
INSERT INTO curSales (C_CID, C_Descri, N_Price, L_Paid) VALUES ("CI5", "Description", 104.25, .F.)

ENDPROC

ENDDEFINE
***code ends here*********************************************
 
That code is not returning any results. I did modify it, because the format was upper case, my databases are upper and lower case, just depends on how it's initially typed in. And I'm not seeing 'use accounts.dbf' in there, so It can't be searching for anything.
 
Hi foxprox558

Well, this is a DEMO to show how you could do things - it is NOT based on your tables, because I don't know their structure.

hth

MarK
 
Hi FoxPro558

The form which MjcMrsr published here works without any errors.
There is no need for you to change to upper or lower at all, MjcKrsr made a generic code:
WHERE UPPER(curCustomer.C_LName) = ALLTRIM(UPPER(Thisform.txtCustomer.Value)) he changed for searching problems the content of thisform.txtCustomer.Value into UPPER and also changed curCustomer.C_Lname into upper, so nevermind how you/one put his name, it will always be found if available.

And of course you don't see any accounts.dbf in his form, he is given an example how you should make the form using his basic architecture. Now you change the variables to your situation and you are done.

Regards,

Jockey(2)

 
Thanks, all. But I've decided to use a different method, using checkboxes with checking out a maximum of 14 orders, please see the new thread. I have a feeling that this way will be MUCH less of a headache
 
Hi foxprox558:

you have a good working demo from mark. try copy and paste in to a new .prg file run and view the results. you might start feeling ease with it.

otherwise try modify database names to match what you have in my posted code, as follows:

all references: where it says customer, change it to accounts. where it says details, change it to orders. if you see any problem with any line of code in the solutions presented, ask back.

it is important that you read in the help file. try the following in the command window, one line at a time.

use accounts in 0 alias ac
use orders in 0 alias or
sele ac
brow
sele or
brow
use
sele ac
use
use accounts in 0 alias accounts
use orders in 0 alias orders
sele accounts
index on custno to tmp
go top
browse
go bott
browse

sele orders
browse

select accounts
browse

close databases

i hope this may help.


nasib
 
I have decided that using checkboxes is more graphically pretty and want the program to look nice instead of 2 big grids in the middle of a form
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top