473,394 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Cor..

Hi Cor

U earlier help me with coding for removing items from a combobox based on what is contained in my array

What i wanted to ask was advise on a similar situation i have encountered. Im not sure on the best method to code this....

I have 3 comboboxes.... ComboBoxHireDate, ComboboxCarMake, ComboBoxCarRe

What i want to ensure is that if the same date and CarMake is selected as a previous Hir
then that particular CarReg is not displayed, as it has already been booked for that day
The Car Reg will therefore have to be removed from the combobox if the HireDate and CarMake is matched to an existing booking

The problem i have is that i dont know how to do this. At the moment the value selected from each combobox is added to a separate Arraylist when the user clicks ok. Would it be better to store it all in a multidimentional array

If so do u have example of how to use multidimentional array? I will need to store 3 columns in it when user clicks ok..... HireDate, CarMake, CarRegistration.
I will then need to make that when the user tries to make a new hire that if the date and Carmake is the same in the combobxes, then the previously booked registartion is removed from the combobox

Does this make sense?? Im confusing myself now :o

Can you give me any advise
thank yo

Jul 21 '05 #1
5 1406
Cor
Hi Varun,

Let 's start at the beginning, where is the data about those cars?

- a textfile?
- a XML file?
- a database (access or SQL or whatever)?

Cor
Hi Cor,

U earlier help me with coding for removing items from a combobox based on what is contained in my array.
What i wanted to ask was advise on a similar situation i have encountered. Im not sure on the best method to code this.....
I have 3 comboboxes.... ComboBoxHireDate, ComboboxCarMake, ComboBoxCarReg
What i want to ensure is that if the same date and CarMake is selected as a previous Hire then that particular CarReg is not displayed, as it has already been booked for that day. The Car Reg will therefore have to be removed from the combobox if the HireDate and CarMake is matched to an existing booking.
The problem i have is that i dont know how to do this. At the moment the value selected from each combobox is added to a separate Arraylist when the
user clicks ok. Would it be better to store it all in a multidimentional
array?
If so do u have example of how to use multidimentional array? I will need to store 3 columns in it when user clicks ok..... HireDate, CarMake,
CarRegistration. I will then need to make that when the user tries to make a new hire that if the date and Carmake is the same in the combobxes, then the previously
booked registartion is removed from the combobox.
Does this make sense?? Im confusing myself now :o)

Can you give me any advise?
thank you

Jul 21 '05 #2
Cor
Hi Varun,

To give some answers hoping that I understand you.

What i want to ensure is that if the same date and CarMake is selected as a previous Hire then that particular CarReg is not displayed, as it has already been booked for that day. The Car Reg will therefore have to be removed from the combobox if the HireDate and CarMake is matched to an existing booking.

Why are you showing the date if you know that you cannot use it?

The problem i have is that i dont know how to do this. At the moment the value selected from each combobox is added to a separate Arraylist when the
user clicks ok. Would it be better to store it all in a multidimentional
array?

I think there is another approach, but for that I need your information.

If so do u have example of how to use multidimentional array? I will need to store 3 columns in it when user clicks ok..... HireDate, CarMake,
CarRegistration. I will then need to make that when the user tries to make a new hire that

if the date and Carmake is the same in the combobxes, then the previously
booked registartion is removed from the combobox.

What is the dataformat.

You have cars sorted on make with a registration
You have car appointments (hire dates I asume only full days)
You have hire dates, but that can be a datepicker I asume.

Give some more information about this.

Cor


Jul 21 '05 #3
Cor
Hi Varun,

When I look at your process than I think that I would do it like this.
I do not know if it is a multiuser environment but lets do if it is.

I would take a date (or a date from/to)
Then do a "select distinct" on all cars where the date matches as free
in the database.
Set that in a dataset and a dataview
That should give you all free carmakes on that date which you display in
combobox1.

The user select a carmake in the datacombo1
Then you do a normal select on your database again with a selection of
the date and the choosen carmake.

You check if you get an empty set, because it can be choosen in the meantime
by another operator.

You shows the Carregs in combobox2 using a dataset and a dataview and let
choose.

You update and check if the Car is not taken in the meantime by using the
errorchecking on concurrency errors.

(If it is taken in the meantime, you tell that on your screen, and start at
the procedure again in my opinon with combobox1)

When it is free and registrated you can make the bill.

I think this is the way I would go.

I hope this helps?

Cor
Hello Cor,

thank you for responding to my help call.

My data is coming from an sql server database
Why are you showing the date if you know that you cannot use it? The date is selected using a datetimepicker. It is need as the user can book another carmake for the same day. i.e even if they already book a ford
car they can still book a Skoda for the same day.What is the dataformat.
The date is in a dateTime format (short date)
CarMake is a varchar(30)
CarReg is VarChar(7)

Date is first selected using the dateTimePicker
Carmake is then selected using a datareader from database (Combobox)
CarRegistration is then displayed based on the carMake selected.

(Combobox)
i.e if Porsche 911 is selected registration xxx xxxx and yyy yyyy is shown in the CarRegistration combobox if Ford escort is selected registartion aaa aaaa and bbb bbbb and ccc cccc is shown
the user then go through each combobox and select the approapraite car.
Lets say Porsche 911 xxx xxxx was hired for 1/1/2004
They then click add button and the values are moved to my datatable. and all comboboxes are reset
The problem i get is that when user goes back to make another hire and selects the same date and carmake again, (i.e. they select Porsche 911 and
date 1/1/2004, the reg xxx xxxx is stil shown again which allows them to
book same car again and cause duplicate row in my datatable. The application
then crashes. The reason it does this is beacause the database has no knowledge that Porsche 911 xxx xxxx was hired for 1/1/2004 as this is all done in my
dataset. The values retrieved for my combox are from the database. This is
why i wish to remove this registration from the combobox based on the date
and carmake.
Does this make any more sense?
My wording is not too good. :)

Jul 21 '05 #4
Hi Cor

I am creating a single user application. By the sounds of it i am doing what u suggest already. I think anyway!!! This is what im doing.

there are 5 controls on form:
1) DateTimePicker (dtp
2) Combobox1 - to select a carmake (filled using a datareader
3) Combobox2 - to select the car registrations that are availble for the carmake and date specifed. I created a stored procedure with the carmake and date as parameters to only show the registrations that are available. This combobox is filled using a datareader once the stored procedure has been run
4) 'Ok' button to push the single booking to a datatable that is created a runtime (Only fill schema - is empty and does not contain any data)
5) 'Submit' button to push all rows in the datatable to my database

There can be many car registrations for a single car make. e.g the company may have 10 ford escorts with registrations aaa aaaa, bbb bbbb, ccc cccc etc

eg lets say user1 wants to book a ford escort for the 1/1/2004
user1 first selects a date from dtp. Then they select ford from combobox1. They then choose 1 of the 10 registrations that are available. The user the clicks the 'Ok' button to push the booking to my datatable. they can then make another booking or they can click the 'Submit' button to push the rows in my datatable to the database. Lets say user1 choose registration aaa aaaa for the 1/1/2004.

The registrations that are available for a particular car make are shown in combobox2
i.e when another user (User2) selects the date 1/1/2004 again and carmake Ford escort
combobox2 will show all registartions available for that date and make (Not aaa aaaa as this has been booked by user1)
Lets say they book
1/1/2004, Ford escort, bbb bbb
they click ok button which pushes this row to my datatable
When they go back to make another booking....
they select 1/1/2004 again and ford escort. The carregistration will still show bbb bbbb as this registration is not shown as booked in my database. It still is in my datatable. The query to pull available registrations for that date and carMake is running against the database and not the datatable. This means that they can rebook this item causing problems. How would i remove it

I want it to be removed if the date and make selected matches a row that is in my datatable
in this example user2 has already chose
1/1/2004, Ford escort, bbb bbbb (in my datatable
i want to now ensure that if the user again selects 1/1/2004 and ford escort that the registration bbb bbbb is removed from combobox2 so it cannot be rebooked

i appologise for my lengthy post. I just wanted to make sure that i didnt make any mistakes when explaining what i doing. :

If u can help me then i willin to pay for your time

Thanks in advance.
Jul 21 '05 #5
Cor
Hi Varun,

Nothing wrong but I did type a lot, just to make it better and also in a way
you can next time make a webapplication from it (that is not the reason),
then they can hire your cars at home.
I am creating a single user application. By the sounds of it i am doing what u suggest already. I think anyway!!! This is what im doing..
there are 5 controls on form:
1) DateTimePicker (dtp)
2) Combobox1 - to select a carmake (filled using a datareader)
Use a dataset, it is so easy to use

Your connection stays the same
Your select becomes something as (or stored procedure)
dim sqlString = "SELECT DISTINCT markes FROM cars WHERE date = @date ORDER
BY markes" (I am really someone who hates SQL, so that part you have to
check extra).

you fill the commandparameters just the same as you did before with the
dates from the datareader

then
dim ds1 as new dataset
dim da as new Sqlclient.SqlDataAdapter(theCommand)
da.fill(ds1)
me.combobox1.datasource = nothing 'that is for the secondtime you set it.
me.combobox1.datasource =ds1.tables(0)
me.combobox1.displaymember = "markes"
3) Combobox2 - to select the car registrations that are availble for the carmake and date specifed. I created a stored procedure with the carmake and
date as parameters to only show the registrations that are available. This
combobox is filled using a datareader once the stored procedure has been
run.

When the mark is choosen,

you fill the commandparameters
dim sqlString = "SELECT * FROM cars WHERE date = @date AND mark = @mark
ORDER BY regs"

you fill the commandparameters and the mark from combobox1

dim ds2 as new dataset
dim da2 as new Sqlclient.SqlDataAdapter(mycommand2)
'I use the same dataadapter but take another that is for me easier to
explain to you
dim cmb as new commandbuilder(da2)
da.fill(ds2)
me.combobox2.datasource = nothing
me.combobox2.datasource =ds2.tables(0)
me.combobox1.displaymember = "regist"
5) 'Submit' button to push all rows in the datatable to my database


There is a by me known bug in the combobox, otherwise I did know another
method so I have to do it something strange.

dim position as integer = CType(BindingContext(ds.Tables(0)),
CurrencyManager).position
ds2.tables(0).rows(position)("date")=registrationd ate

try
da2.update(ds2)
catch ex as exception
messagebox.show(ex)
start procedure again with combobox1
end try

Otherwise print bill.

I think this is much easier to make. Try it by first copying your project to
a new one. Do not do it in your project you now have made, you will see that
it is ready very fast. (use first normal select statements before you use
stored procedures, that you can change when all is working nice)

When you put the concurrency checkings on the right place you have it in my
opinion multi user. This is very easy to convert to a webapplication,
because you use the datasets in a single messagetraject with a webpage.
(Although you have to save the last one for a webpage to be able to do the
update)

Do not forget that you also need a routine for correction (canceled hires).
I would use for that as start a dataset from the whole car database and a
datagrid.
Do not forget the databinding.......endcurrentupdate with that last before
you do the update.

I hope you are a little bit further, sorry that it seems that I ruin a
little bit your approach but that is not true, I only try to make it more
easy, your approach stays the same.

I have all typed in in this message, so you have to check it very carefully,
my expirience with the combobox is that it can give a lot of strange
results. (Although until now I could always pass that).

I hope this helps you somehow?

Cor

Jul 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL)...
2
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues...
3
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which...
0
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. ...
1
by: Richard Galli | last post by:
I want viewers to compare state laws on a single subject. Imagine a three-column table with a drop-down box on the top. A viewer selects a state from the list, and that state's text fills the...
4
by: Albert Ahtenberg | last post by:
Hello, I have two questions. 1. When the user presses the back button and returns to a form he filled the form is reseted. How do I leave there the values he inserted? 2. When the...
1
by: inderjit S Gabrie | last post by:
Hi all Here is the scenerio ...is it possibly to do this... i am getting valid course dates output on to a web which i have designed ....all is okay so far , look at the following web url ...
2
by: Jack | last post by:
Hi All, What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g. select x from y where z=:parameter Which in asp/jsp would be followed by some statements to bind a value...
3
by: Sandwick | last post by:
I am trying to change the size of a drawing so they are all 3x3. the script below is what i was trying to use to cut it in half ... I get errors. I can display the normal picture but not the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.