John
p.s. when i choose the perons ID on the input form after that no matter who i choose the same pay details come up
This post has been edited by smallzz: 04 June 2009 - 01:22 PM




Posted 04 June 2009 - 01:21 PM
This post has been edited by smallzz: 04 June 2009 - 01:22 PM
Posted 04 June 2009 - 01:56 PM
Posted 04 June 2009 - 02:18 PM
Posted 04 June 2009 - 02:46 PM
private void cbxID_SelectedIndexChanged(object sender, EventArgs e)
{//shows name in txtName afte you pick a user ID from combo box
if (cbxID.SelectedIndex == 001)
txtName.Text = "John Smith";
else if
(cbxID.SelectedIndex == 002)
txtName.Text = "Michael Alderwood";
else if
(cbxID.SelectedIndex == 003)
txtName.Text = "Thomas Hooper";
else if
(cbxID.SelectedIndex == 004)
txtName.Text = "Nathan Church";
else if
(cbxID.SelectedIndex == 005)
txtName.Text = "Jonas Gutierrez";
else if
(cbxID.SelectedIndex == 006)
txtName.Text = "James Jackson";
else if
(cbxID.SelectedIndex == 007)
txtName.Text = "Jake McNally";
else if
(cbxID.SelectedIndex == 008)
txtName.Text = "Stacey Jameson";
else if
(cbxID.SelectedIndex == 009)
txtName.Text = "Jet Li";
else if
(cbxID.SelectedIndex == 010)
txtName.Text = "Alan Sheffield";
}
Posted 04 June 2009 - 10:12 PM
public class Employee
{
public string Name {get; set;}
public double HoursWorked {get; set;}
public double PayRate {get; set;}
public Employee(string name)
{
Name = name;
}
public override string ToString()
{
return Name;
}
}
....in your main code, load the employees prior to your form loads
cbxID.Items.Add(new Employee("John Smith"));
cbxID.Items.Add(new Employee("Michael Alderwood"));
....
....load the same objects into your second comboBox
foreach (Employee e in cbxID.Items)
comboBox2.Items.Add(e);
... when you select a name from your first combo box:
Employee e = (Employee)cbxID.SelectedItem;
... when you want to apply changes to the hours and pay rate
e.HoursWorked = Convert.ToDouble(hoursTextBox.Text);
e.PayRate = Convert.ToDouble(payTextBox.Text);
...do something similar when you need to access the data in the second combo box
Employee e = (Employee)comboBox2.SelectedItem;
displayHoursTextBox.Text = e.HoursWorked.ToString();
displayPayRateTextBox.Text = e.PayRate.ToString();
displayTotalTextBox.Text = (e.PayRate*e.HoursWorked).ToString();
|
|
Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).
|
