In the code below I am using an insert statement and before I execute the insert statement I would like to cater for weekends by the NextDueDate field which should be exactly a year in advance. If the NextDueDate is on a Saturday then I want to add 367 days and If it is on a Sunday then I want to add 366 days.
Using command As New SqlCommand("INSERT INTO tblMedicalResults (MedicalCertificateID , ID, Code, EmployeeID , CostCentre , ExaminationTypeID , PhysicalExamType , AudiogramID , AudiogramRecID , AudiogramDate , LungFunctionID , LungFunctionDate , ChestResults , ECGResult , ECGDate , DrugScreeningResult , BloodGlucoseResult , GGTResult , LeftEyeDayNight , RightEyeDayNight , LeftEyeCorrDayNight , RightEyeCorrDayNight , VisualFieldLeftDayNight , VisualFieldRightDayNight , ColourVisionDayNight, DeptPerceptionDayNight , OptometristYesNo , EyeTestDate , OutcomeID , OutcomeRecommendationsID, OtherProblems, Notes ,ExpiryDate , DateTested , NextDueDate,Photo) VALUES ( @MedicalCertificateID , @ID , @Code , @EmployeeID , @CostCentre , @ExaminationTypeID , @PhysicalExamType , @AudioGramID , @AudiogramRecID , @AudioGramDate , @LungFunctionID , @LungFunctionDate , @ChestResults , @ECGResult , @ECGDate , @DrugScreeningResult , @BloodGlucoseResult , @GGTResult , @LeftEyeDayNight , @RightEyeDayNight , @LeftEyeCorrDayNight , @RightEyeCorrDayNight , @VisualFieldLeftDayNight , @VisualFieldRightDayNight ,@ColourVisionDayNight, @DeptPerceptionDayNight , @OptometristYesNo , @EyeTestDate , @OutcomeID , @OutcomeRecommendationsID , @OtherProblems, @Notes ,@ExpiryDate , @DateTested , @NextDueDate,@Photo)", con)
command.Parameters.AddWithValue("@ExpiryDate", DateTime.Now.AddDays(365))
command.Parameters.AddWithValue("@DateTested", DateTime.Now())
command.Parameters.AddWithValue("@Photo", image1.Src)
command.Parameters.AddWithValue("@NextDueDate", DateTime.Now.AddDays(365)) 'DateTime.Now.AddDays(366) DateTime.Now.AddDays(+10)
con.Open()
command.ExecuteNonQuery()
con.Close()
End Using