Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 2nd, 2008, 10:19 AM
Authorized User
 
Join Date: Apr 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the checked list contains strings which can be equaly to the "flaske" propertyId.

Therefore the syste can run throw the list "Flakseliste" and add a "rerservaring" to all "flaske" which have the same ID as the checked items from the checkedListBox.

//makes a reservation
    Reservering ny = new Reservering((label12.Text), (dt));

//The reservations are added to the "Flaske"
en_flaske.Add(ny) ;

 
Old May 2nd, 2008, 10:28 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Look, this really isn't that hard - if the user can select more than one Flaske then you need to check the List of Fleske's to see if it contains the current Fleske and then add the reservation:

Code:
private void button2_Click(object sender, EventArgs e)
{
  //makes temporary list
  List<string> temp_flasker = new List<string>();
  foreach (object i in checkedListBox12.CheckedItems) temp_flasker.Add(i.ToString());

  Reservering ny = new Reservering(label12.Text, dt);

  foreach (Flaske en_flaske in Flaskeliste)
  {
    if (en_flaske._flaskeledig(dt) && temp_flasker.Contains(en_flaske.PropertyFlaskeID));
    {
      en_flaske.Add(ny) ;
    }
  }
}
/- Sam Judson : Wrox Technical Editor -/
 
Old May 2nd, 2008, 10:30 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Also, if the flaskeledig() function is a time consuming one then I'd swap the two parts of the 'if' around:

Code:
if (temp_flasker.Contains(en_flaske.PropertyFlaskeID) && en_flaske._flaskeledig(dt))
{
   ...
Actually, come to think of its I've just spotted your problem. You've got a ';' at the end of the line including the if. Get rid of that.

/- Sam Judson : Wrox Technical Editor -/
 
Old May 2nd, 2008, 12:27 PM
Authorized User
 
Join Date: Apr 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

okay, thanks a lot for your help..






Similar Threads
Thread Thread Starter Forum Replies Last Post
foreach confusion stokerfed C# 2 June 13th, 2007 02:30 PM
hlpe with foreach(); haryohnesa PHP Databases 1 August 3rd, 2006 12:46 PM
"foreach" error BradBrening Pro PHP 2 January 13th, 2005 05:33 PM
Need help with foreach loop Arsi C# 3 September 7th, 2004 09:41 PM
for loops from within foreach richard.york Pro PHP 5 October 2nd, 2003 01:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.