string D1 = Convert.ToDateTime(TextBox5.Text).ToString("0:MM/dd/yyyy");
Emp_Course EC = new Emp_Course();
EC.Course_ID = M.Courses.Single(c => c.Course_Name == DropDownList2.Text).Course_ID;
EC.Emp_ID = M.Employees.Single(c => c.Emp_Name == DropDownList1.Text).Emp_ID;
EC.Course_Start_Date = Convert.ToDateTime(D1);
EC.Course_End_Date =Convert.ToDateTime( TextBox6.Text.Trim().ToString());
if (EC.Course_End_Date > EC.Course_Start_Date)
{
Response.Write("<script>alert('the end date cannot be bigger than start date')</script>");
return;
}
M.Emp_Courses.InsertOnSubmit(EC);
M.SubmitChanges();
Response.Write("<script>alert('Data Saved')</script>");