I got something which is confused me now, and i would ask for some ideas here.
How should i get the total hours, by comparing the TIME_IN and TIME_OUT
I would like to display the records according to ID, which means, if the user select ID= 1 from the Data Grid View, and MONTH= JANUARY, the List View only display all the records of ID=1 and MONTH= JANUARY.
Ya thanks, i had got what i wanted to display in the List View now. But allow me to ask another questions regarding to the List View items.
In the List view items, i have four colums of 'TIME_IN', 'TIME_OUT', 'DATE', 'TOTAL_HOURS'. How should the records display according to the order in each columns
Now all the data display in only one column. What should i do to seperate every items according to the column
Definitely, follow these steps: (Note: place this after you have populated your listview)
1. Traverse all the Data in ListView via ListView.Items 2. Inside the loop, get the 2 Time data that you are going to subtract. 3. Use the code that I post earlier to subtract the Times...
If you want to display records according to ID, then you would have to modify your SELECT statement in SqlCommand(). Just add the additional filter (hope your familiar with SQL lang)...
Well to subtract just the Hours of a time, you may use this approach:
Basically i am doing an Employee Payroll, using c# and Ms Access. There are 2 parts which is employee information and time card.I had completed the employee information part, and i am facing some problems on the time card part.
In the time card, there is a Date Time Picker which display the MONTH, and a list View that should display the 'TIME_IN',TIME_OUT', 'DATE' and 'TOTAL_HOURS' from database of the selected month.
I had added the codes that you provided to me just now into the data time picker events, and i found out that it cannot work properly where it display all the records in the databases.
The problem is, I want to display ONLY the records of the selected Month. For example, if the user select JANUARY from the date time picker, the list view will fill by the 'TIME_IN',TIME_OUT', 'DATE' and 'TOTAL_HOURS' of JANUARY only. How should i do this
Hope you can understand the details provided above, Thanks.
Date Time Picker
JavaKid
Sorry to ask an easy questions here.
How should i get those data that contain the selected months from database to List View
Thanks.
Dr_dre
You must first know how to use ADO.Net to be able to access data from the database. It also depends on what DBMS your database is using.
Generally it looks like this:
SqlConnection _conn = new SqlConnection("<Your connection string>");
_conn.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM Table1", _conn);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read()) {
listView1.Items.Add(reader[0].ToString());
}
_conn.Close();
If this doesn't help, give me more details on what your doing, maybe I can help...
cheers,
Paul June A. Domag
mx666_!
I got something which is confused me now, and i would ask for some ideas here.
How should i get the total hours, by comparing the TIME_IN and TIME_OUT
I would like to display the records according to ID, which means, if the user select ID= 1 from the Data Grid View, and MONTH= JANUARY, the List View only display all the records of ID=1 and MONTH= JANUARY.
Thanks.
Stijn&
Change the format property to Custom and set the Custom format property to MMMM... You may also want to set the ShowUpDown to true...
cheers,
Paul June A. Domag
prowl
Can i do the substraction of the hours in the List View column
J&#252;rgen Hefele
Just create columns in your listview (In your constructor):
listView1.Columns.Add("Col1");
listView1.Columns.Add("Col2");
...
Modify your loop
while (reader.read()) {
ListViewItem item = listView1.Items.Add(reader["Col1"].ToString());
item.SubItems.Add(reader["Col2"].ToString());
item.SubItems.Add(reader["Col3"].ToString());
}
Try that...
Cheers,
Paul June A. Domag
KirHil
In the List view items, i have four colums of 'TIME_IN', 'TIME_OUT', 'DATE', 'TOTAL_HOURS'. How should the records display according to the order in each columns
Now all the data display in only one column. What should i do to seperate every items according to the column
Thanks.
MikeOtown
Hi,
Sorry, please allow me to ask more, can you guide me more details on how to traverse the list view items and create the loop
Thanks.
BrianW
Hi,
Definitely, follow these steps:
(Note: place this after you have populated your listview)
1. Traverse all the Data in ListView via ListView.Items
2. Inside the loop, get the 2 Time data that you are going to subtract.
3. Use the code that I post earlier to subtract the Times...
cheers,
Paul June A. Domag
Sol Bad Guy
Place the logic on retrieving your data in the ValueChanged event of the datepicker. you can get the current month by using the dateTimePicker.Text.
cheers,
Paul June A. Domag
TylerH
To be able to filter out specific dates, you must do it in the sql statement in the SqlCommand object:
SqlCommand cmd = new SqlCommand("SELECT * FROM Table1 WHERE MONTH(dateField) = " + dateTimePicker1.Value.Month.ToString(), _conn);
cheers,
Paul June A. Domag
William McIlroy
Example: When the user choose JANUARY, and all the 'TIME' and 'DATE' of JANUARY will be display on the List View.
How can i do that
Derek Theriot
If you want to display records according to ID, then you would have to modify your SELECT statement in SqlCommand(). Just add the additional filter (hope your familiar with SQL lang)...
Well to subtract just the Hours of a time, you may use this approach:
DateTime d = DateTime.Parse("12:30 am");
DateTime d1 = DateTime.Parse("1:30 am");
MessageBox.Show((d1.Hour - d.Hour).ToString());
cheers,
Paul June A. Domag
sledge
Basically i am doing an Employee Payroll, using c# and Ms Access. There are 2 parts which is employee information and time card.I had completed the employee information part, and i am facing some problems on the time card part.
In the time card, there is a Date Time Picker which display the MONTH, and a list View that should display the 'TIME_IN',TIME_OUT', 'DATE' and 'TOTAL_HOURS' from database of the selected month.
I had added the codes that you provided to me just now into the data time picker events, and i found out that it cannot work properly where it display all the records in the databases.
The problem is, I want to display ONLY the records of the selected Month. For example, if the user select JANUARY from the date time picker, the list view will fill by the 'TIME_IN',TIME_OUT', 'DATE' and 'TOTAL_HOURS' of JANUARY only. How should i do this
Hope you can understand the details provided above, Thanks.