I am doing a movie application an I need your advice. At the moment am doing the GUI for lending out the movies. I have a combobox (lookup table) for holding the customer details from the customer table and another combobox (lookup table) for holding movie titles from the movies table. The idea is when I select a customer from the combo, and then select the movie they want to borrow, when i click on a command button (cmdSelect), the selected movie in the movies combo should be transfered into this control where it is listed as selected. (Like it is done in the supermarket applications where each item you buy is scanned and its details appear in a grid like control that indicates item description, price, discount etc) A user is allowed to borrow a maximum of three movies per day. All the selected movies should be held in a listed format in this control. After the selection, there is another command button (cmdCheckOutAllSelected) which when clicked, all the selected movies should be inserted into an orders table indicating the customer id, and the three or less movies that are appearing in this control. Note I should also be able to remove a selected movie from the control
1- Can this be implemented? If yes, which is the best control that can hold these selected movies and which can be manipulated using code to INSERT the selected movies into the DB?
2- how can I code to ensure that the selected movies are inserted into the DB
I am able to code and have the selected items appear in a listview but I don't know how to code so that all the listed items (1-3) in a ListView can get inserted into the orders table and still bear the same customer ID. How can I do that? Any sample code?
- For the customer combobox the table is Customer (customerId, Firstname, lastName, address, telephone)
- For the movies combobox, the table is movies (movieId, title, genre, category)
- I also have 2 datepickers on the form. datePicker (dtOrderDate) and a datePicker (dtDueDate)
- 2 command button (cmdAddItemToList) and (cmdCheckOutAllListedItems)
- The orders table (orderId, customerId, OrderDate, DueDate, returnDate)
- The orderDetails table (orderId, movieId, ItemcostPerDay, ItemDiscount, ItemSubTotal)
- Intend to display the following as columnheaders in the ListView control, (#, movietitle, DueDate, ItemcostPerDay, ItemDiscount, ItemSubTotal, Total)
To load the ListView am using:-
VB Code:
Private Sub PopulateList(pList As ListView, _
pRst As ADODB.Recordset)
On Error Resume Next
Dim i As Long
Dim iColCount As Long
Dim sColName As String
Dim sColValue As String
Dim oCH As ColumnHeader
Dim oLI As ListItem
Dim oSI As ListSubItem
Dim oFld As ADODB.Field
With pList
.View = lvwReport
.GridLines = True
.FullRowSelect = True
.ListItems.Clear
.Sorted = False
pRst.MoveFirst
' set up column headers
For Each oFld In pRst.Fields
sColName = cn(oFld.Name)
Set oCH = .ColumnHeaders.Add()
oCH.Text = sColName
iColCount = iColCount + 1
Next oFld
Do Until pRst.EOF
i = 0
' setup fiprst column as a listitem
sColValue = cn(pRst.Fields(i).Value)
Set oLI = .ListItems.Add()
oLI.Text = sColValue
' add the remaining columns
'as subitems
For i = 1 To iColCount
Set oSI = oLI.ListSubItems.Add()
oSI.Text = cn(pRst(i))
Next ' next column
pRst.MoveNext
Loop ' Next record
' refresh it all
.Refresh
' make sure 1st row can be seen
.ListItems(1).EnsureVisible
End With
End Sub
I hope this is sufficient info.
Thanks
Last edited by osemollie; Jun 28th, 2006 at 11:33 AM.
to take a SCREENSHOOT you can use the "PrintScreen" key on your keyborad
then paste it either to your windows paint or excel to modify the image height and length..
I am able to code and have the selected items appear in a listview but I don't know how to code so that all the listed items (1-3) in a ListView can get inserted into the orders table and still bear the same customer ID. How can I do that? Any sample code?
Thanks
I'm looking at your form but do not see any indication of a customer ID. Where is that coming from?
You will loop through the listitems and insert each listitem/record one by one to the orders table...jusr refer to the values held in the other controls for values that are similar for the listitem/record group
Just wrap everything in a transaction. cnADO.BeginTrans, CommitTrans, etc
Honestly speaking I don't know how to use the transaction thing. How do I do code that? Where can I get a tutorial on the same so that I can learn something on how to us it?
Looking at my GUI above, how can I code so that am able to print out the Patron name, date/time of transaction, resouceType, movies borrowed (as they appear in the ListView) on the click of the command button (cmdPrint)?
Looking at my GUI above, when u click on Add selected command button, the selected item should be displayed in the ListView. How can I code in such away that the text of the selected item in the combo is displayed in the ListView but I still get the selected item's itemdata for use in my INSERT code into the checkout table.?
Last edited by osemollie; Jul 4th, 2006 at 08:02 AM.
Honestly speaking I don't know how to use the transaction thing. How do I do code that? Where can I get a tutorial on the same so that I can learn something on how to us it?
It's pretty much:
VB Code:
'set an error trap
Connection.BeginTrans
'do all your inserts and/or updates here
...
'you got here because there were no errors
Connection.CommitTrans 'let everything you did be done for real
Exit Sub
ErrorTrap:
Connection.RollbackTrans 'throw away everything you did
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana
Looking at my GUI above, how can I code so that am able to print out the Patron name, date/time of transaction, resouceType, movies borrowed (as they appear in the ListView) on the click of the command button (cmdPrint)?
Any idea how I can print?
Last edited by osemollie; Jul 7th, 2006 at 07:32 AM.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana
I was able to print the items in the ListView, however, it only printed column one and the first subitem in the listView. How do I get it to print all subitems in the listview and also the columnheaders?
Thanks.
Last edited by osemollie; Jul 10th, 2006 at 08:03 AM.
Looking at my GUI above, when u click on Add selected command button, the selected item should be displayed in the ListView. How can I code in such away that the text of the selected item in the combo is displayed in the ListView but I still get the selected item's itemdata for use in my INSERT code into the checkout table.?
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana
Thanks Al42 for your help. I seem to be getting somewhere. I have seen receipts printed having columnheaders and even align the selected items in the ListView to their respective columnheaders, might you have an idea about that?
The 13 is the length of the item in the header - you want to make sure that the data takes as much space as the header (adjust each column for your needs) or the columns won't line up.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana
Looking at my GUI above, when u click on Add selected command button, the selected item from the movie title combobox (cboTitle) should be displayed in the ListView after the following code is run and all the fields in the code displayed in the ListView.
VB Code:
'strSQL = "SELECT movieInfo.movieId, movieInfo.title, MediaType.StrKey, MediaType.DefRentPricePerDay, MediaType.DefRentPeriodInDays FROM movieInfo INNER JOIN MediaType ON movieInfo.media_catId = MediaType.media_catId WHERE movieId = " & cboTitle.ItemData(cboTitle.ListIndex)
Remember, I should be able to add atleast 3 movies into the ListView control.
Is this possible?
Thanks HACK!! I knew you will help me out!! It works just like I wanted it. Now, after selecting the movies am interested in I only want to display all the fields in the recordset EXCEPT the movieId HOWEVER I need the movieId of each movie in the listview inorder to use it in my INSERT code when checking out the selected movies from the ListView control. Can this be done? I have also heard of carrying a non-displaying/hidden column in a ListView how is that implemented?
You would have to have the movie id in your listview in order to do what you need to do (providing I'm understanding your needs correctly.)
You can insert the movie id in a column that does not display simply by having that column further over on the right than the control itself has been drawn. Caution: when you do this, the horizontal scrollbar will autosize itself so that column, although not displayed by default, can be scrolled to. I don't know if this would be an issue.
Sorry, I had used a wrong thread to post my question. The question is:
----------
Looking at the GUI above, you will realise there is a button for the resource type and movie title. The title combo is populated depending on the resource type selected in the resource type combo. Movies are lend out depending on the type, eg
- VHS = 4 days
- VCD = 3 days
- DVD = 2 days
I wish to automatically update the dueDate automatically depending on the resource type and the checkout date.
I also have an a admin table where the users should be able to set the number of days they want to allow their customers to borrow movies instead of depending on the default dates set by the application. How can I do that.