I am using this code to save hours but with the use ShowFooter
property, can I enter the spaces under the columns in total how to have a use code and summaryitem
format what should it be?
connection.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO LogBook (Se,Me)VALUES(,@Se,@Me)", connection);
cmd.Parameters.AddWithValue("@Se", Convert.ToDateTime(textEdit7.Text).ToString("HH:mm"));
cmd.Parameters.AddWithValue("@Me", Convert.ToDateTime(textEdit8.Text).ToString("HH:mm"));
cmd.ExecuteNonQuery();
cmd.Dispose();
connection.Close();
After you are done inserting the data in the database , you can simply use a datareader and achieve your goal :
int totalhours;
SqlCommand cmd = new SqlCommand("Select Se,Me from LogBook",con)
SqlDataReader dr = cmd.ExecuteREader();
While (dr.Read)
{
totalhours = totalhours + Convert.ToInt32(dr[0].ToString().Split(':')(0)) + Convert.ToInt32(dr[1].ToString().Split(':')(0));
}
MessageBox.Show(totalhours);