firas shaar

firas shaar

  • NA
  • 15
  • 17.9k

question about datetimepicker

Sep 29 2014 6:57 AM
hi
I have created form from insert daily job (date + time )for employees
start time for job is 8:00 AM
and end time for job is 18:00 PM
I have two datetimepicker
datetimepicker1 is called StartTimePicker for start time
datetimepicker2 is called EndTimePicker for end time
in properties for StartTimePicker I set Format= custom and
custom format = 08:00 MM/dd/yyyy
in properties for EndTimePicker I set Format = custom and
custom foramt = 18:00 MM/dd/yyyy
I created the following class for insert rows
 public static bool Addtimerow(DateTime starttime, DateTime endtime )
        {
            bool b;
            string strconn = AlShehabi.Properties.Settings.Default.NewSalariesDBConnectionString;
            SqlConnection conn = new SqlConnection(strconn);

            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }

            SqlCommand cmd = new SqlCommand("INSERT INTO JobHours(Worker_ID)           
Select Worker_ID FROM Workers;", conn);
      
            int i = cmd.ExecuteNonQuery();

            if (i <= 0)
                b = false;
            else
                b = true;
            conn.Close();
            return b;
        }
whent btnadd_click event I want to add in JobHours table all workers names and starttime for job (date +time ) and endtime for job
for example
Mark 3/15/2014 08:00 3/15/2014 18:00
Jack 3/15/2014 08:00 3/15/2014 18:00
and so on
when btnadd_click event I wrote
 private void btnadd_Click(object sender, EventArgs e)
        {
           DateTime Start_Work = StartTimePicker.Value;
            DateTime End_Work = EndTimePicker.Value;
            if (dailyworkerhours.Addtimerow(Start_Work,End_Work))
            gridviewjobhours.EndEdit();
}
 the code works but my problems is when btnadd_click
workers names is inserted in the gridview without starttime for job and endtime for job
for example
Mark
Jack
how to solve this problem?

Answers (1)