As I m using MKB timer Control. In my project I want insert intime and outime and calculate the difference. Intime is inserting but there is problem in inserting outime. Can u find this error and correct it?
protected void Button1_Click(object sender, EventArgs e)
{
DateTime time = DateTime.Parse(string.Format("{0}:{1}:{2} {3}", TimeSelector1.Hour, TimeSelector1.Minute, TimeSelector1.Second, TimeSelector1.AmPm));
var shortDate = time.Date;
ClientScript.RegisterStartupScript(this.GetType(), "time", "alert('Selected Time: " + time.ToString("hh:mm:ss tt") + "');", true);
SqlConnection conn = new SqlConnection(@"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=SUJAY;Data Source=SUPREME6-PC");
conn.Open();
String s = "Insert into timesheet(username,intime) values('" + Label1.Text + "','" + time + "')";
//String s = "Insert into timecal(starttime) values('" + time + "')";
SqlCommand cmd = new SqlCommand(s, conn);
cmd.ExecuteNonQuery();
conn.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{
DateTime time = DateTime.Parse(string.Format("{0}:{1}:{2} {3}", TimeSelector1.Hour, TimeSelector1.Minute, TimeSelector1.Second, TimeSelector1.AmPm));
var shortDate = time.Date;
ClientScript.RegisterStartupScript(this.GetType(), "time", "alert('Selected Time: " + time.ToString("hh:mm:ss tt") + "');", true);
SqlConnection conn = new SqlConnection(@"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=SUJAY;Data Source=SUPREME6-PC");
conn.Open();
String s = "Update timesheet(outime) values('" + time + "') where outime= ISNULL";
//String s = "Insert into timesheet(outime) values('" + time + "')";
SqlCommand cmd = new SqlCommand(s, conn);
cmd.ExecuteNonQuery();
conn.Close();
endTime = DateTime.Now;
}