943,946 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 736
  • C# RSS
Nov 9th, 2009
0

C# Random names

Expand Post »
Hello all! Looking for some help with this, I've been using a book to make an sql database to store names, and was hoping to use a button to randomly select any of the names in the database to be allocated to one of two machines. Also there is a checkbox, which if checked would mean that particular person will not be selected. Here is a picture of the GUI:

http://farm3.static.flickr.com/2689/...b76fa9c7_o.jpg

As for the code so far:

C# Syntax (Toggle Plain Text)
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10.  
  11. namespace IttellaII
  12. {
  13.  
  14. public partial class Form1 : Form
  15. {
  16. private readonly string[] NAMES = new string[]
  17. {
  18.  
  19.  
  20.  
  21. };
  22.  
  23. public Form1()
  24. {
  25. InitializeComponent();
  26. }
  27.  
  28. private void pictureBox1_Click(object sender, EventArgs e)
  29. {
  30. MessageBox.Show("Machine List 1.0.0.\nWritten by: Nathan Sharpe","About");
  31. }
  32.  
  33. private void machineWorkersBindingNavigatorSaveItem_Click(object sender, EventArgs e)
  34. {
  35. this.Validate();
  36. this.machineWorkersBindingSource.EndEdit();
  37. this.tableAdapterManager.UpdateAll(this.machineListDBDataSet);
  38.  
  39. }
  40.  
  41. private void machineWorkersBindingNavigatorSaveItem_Click_1(object sender, EventArgs e)
  42. {
  43. this.Validate();
  44. this.machineWorkersBindingSource.EndEdit();
  45. this.tableAdapterManager.UpdateAll(this.machineListDBDataSet);
  46.  
  47. }
  48.  
  49. private void Form1_Load(object sender, EventArgs e)
  50. {
  51. // TODO: This line of code loads data into the 'machineListDBDataSet.MachineWorkers' table. You can move, or remove it, as needed.
  52. this.machineWorkersTableAdapter.Fill(this.machineListDBDataSet.MachineWorkers);
  53.  
  54. }
  55.  
  56.  
  57. private void btGenerateWorkers_Click_1(object sender, EventArgs e)
  58. {
  59. //MachineListDBDataSet.ToString;
  60. //Random.ReferenceEquals.OnClick Generate
  61.  
  62. }
  63.  
  64.  
  65.  
  66.  
  67. }
  68. }

As you can see not much has happened since the GUI and database have been created... I am very lost at how to start the rest...

Thanks in advance to anyone who can help!

Cheers nathan
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Natsu29 is offline Offline
2 posts
since Nov 2009
Nov 9th, 2009
0
Re: C# Random names
Not sure what you are looking for. Are you wanting to load a table from your database containing the names and their availability (all of info already in table) and then randomly select two names from the table data having records marked/flagged as available?
Reputation Points: 341
Solved Threads: 233
Posting Shark
DdoubleD is offline Offline
984 posts
since Jul 2009
Nov 9th, 2009
0
Re: C# Random names
If you want to select a random row from MS-SQL database then use,
text Syntax (Toggle Plain Text)
  1. SELECT TOP 1 column FROM table ORDER BY NEWID()
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
Nov 10th, 2009
0
Re: C# Random names
Click to Expand / Collapse  Quote originally posted by DdoubleD ...
Not sure what you are looking for. Are you wanting to load a table from your database containing the names and their availability (all of info already in table) and then randomly select two names from the table data having records marked/flagged as available?
Thanks, yeah I have two combo boxes and providing the people are checked, click the button and into the combo boxes 'randomly' will appear some names of those who are working...

Guess the check box is a simple 'if' statement, but I dont know the code for the button/combo boxes and how to generate random names for them...

Aaarrgggh! =)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Natsu29 is offline Offline
2 posts
since Nov 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Help with KeyPress?!
Next Thread in C# Forum Timeline: PdfSharp class library





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC