protected void ButtonSend_Save(object sender, EventArgs e) { List <Job> job = new List <Job>(); List <Car> jobcars = new List <Car>(); List <Person> personInJob = new List <Person>(); var jobslist = SiteUtilities.GetJobsByJobId(new Guid(Request.QueryString["JobID"])); foreach (string personIDString in c_hiddenSelectedItems.Value.Split(new Char[] { DELIMITER_LIST_BOX_SELECTION })) { if (personIDString.Length > 15) { personInJob.Add(SiteUtilities.GetPersonByID(new Guid(personIDString))); } } double starttime = 0; double endtime = 0; bool fullday = false; starttime = Convert.ToDouble(StartTime.SelectedItem.Text.Substring(0, 2)); endtime = Convert.ToDouble(EndTime.SelectedItem.Text.Substring(0, 2)); DateTime startJobTime = Convert.ToDateTime(StartTime.SelectedItem.Text); DateTime endJobTime = Convert.ToDateTime(EndTime.SelectedItem.Text); if (StartTime.SelectedItem.Text.Substring(3) == "30") { starttime = starttime + 0.5; } if (EndTime.SelectedItem.Text.Substring(3) == "30") { endtime = endtime + 0.5; } if (endtime - starttime >= 9) { fullday = true; } int RentalDays = Convert.ToInt16(FreeWeeksOfRental.SelectedItem.Value) * 7; DateTime tmp = Convert.ToDateTime(JobDateEnd.Text); TimeSpan timeSpan = new TimeSpan(RentalDays, 0, 0, 0); DateTime RentalDateEnd = tmp.Add((timeSpan)); try { DateTime JobStart = Convert.ToDateTime(JobDate.Text); DateTime JobEnd = Convert.ToDateTime(JobDateEnd.Text); if (JobStart != JobEnd) { if (jobslist[0].Type == SiteUtilities.IMPORT) { jobslist[0].Type = SiteUtilities.CONSTRUCTION; } int days = JobEnd.DayOfYear - JobStart.DayOfYear; for (int i = 0; i < days; i++) { DateTime JobDateStart = Convert.ToDateTime(JobDate.Text); DateTime newdadate = JobDateStart.AddDays(i + 1); var tmpjobs = SiteUtilities.GetJobsByDate(newdadate); if (tmpjobs.Count == 0) { Job extra = new Job(Guid.NewGuid(), JobName.Text, true, jobslist[0].OrderID, JobDateStart.AddDays(i + 1), JobDateStart.AddDays(i + 1), JobContact.Text, JobAddress.Text, JobComments.Text, Convert.ToDateTime(JobDateEnd.Text), RentalDateEnd, startJobTime, endJobTime, string.Empty, fullday, false, jobslist[0].JobId, string.Empty, JobContactPhone.Text, jobslist[0].Type, string.Empty); job.Add(extra); } else if (tmpjobs.Count > 0 && !JobNewDatePanel.Visible) { Job extra = new Job(Guid.NewGuid(), JobName.Text, true, jobslist[0].OrderID, JobDateStart.AddDays(i + 1), JobDateStart.AddDays(i + 1), JobContact.Text, JobAddress.Text, JobComments.Text, Convert.ToDateTime(JobDateEnd.Text), RentalDateEnd, startJobTime, endJobTime, string.Empty, fullday, false, jobslist[0].JobId, string.Empty, JobContactPhone.Text, jobslist[0].Type, string.Empty); job.Add(extra); } } } if (job.Count > 0) { DateTime JobDateStart = Convert.ToDateTime(JobDate.Text); Job currentjob = new Job(new Guid(Request.QueryString["JobID"]), JobName.Text, true, jobslist[0].OrderID, JobDateStart, Convert.ToDateTime(JobDateEnd.Text), JobContact.Text, JobAddress.Text, JobComments.Text, Convert.ToDateTime(JobDateEnd.Text), RentalDateEnd, startJobTime, endJobTime, string.Empty, fullday, false, Guid.Empty, string.Empty, JobContactPhone.Text, jobslist[0].Type, JobDateStart.Month.ToString()); job.Add(currentjob); } else { if (JobDateEnd.Visible && JobDate.Visible) { DateTime JobDateStart = Convert.ToDateTime(JobDate.Text); Job currentjob = new Job(new Guid(Request.QueryString["JobID"]), JobName.Text, true, jobslist[0].OrderID, JobDateStart, Convert.ToDateTime(JobDateEnd.Text), JobContact.Text, JobAddress.Text, JobComments.Text, Convert.ToDateTime(JobDateEnd.Text), RentalDateEnd, startJobTime, endJobTime, string.Empty, fullday, false, Guid.Empty, string.Empty, JobContactPhone.Text, jobslist[0].Type, JobDateStart.Month.ToString()); job.Add(currentjob); } else { Job currentjob = new Job(new Guid(Request.QueryString["JobID"]), JobName.Text, true, jobslist[0].OrderID, jobslist[0].JobStartDate, jobslist[0].JobEndDate, JobContact.Text, JobAddress.Text, JobComments.Text, jobslist[0].RentStartDate, jobslist[0].RentEndDate, startJobTime, endJobTime, string.Empty, fullday, false, jobslist[0].ParentJobID, string.Empty, JobContactPhone.Text, jobslist[0].Type, string.Empty); job.Add(currentjob); } } } catch { } for (int i = 0; i < CarsCheckBoxList.Items.Count; i++) { if (CarsCheckBoxList.Items[i].Selected) { Guid carid = new Guid(CarsCheckBoxList.Items[i].Value); Car car = new Car(carid, new Guid(Request.QueryString["JobID"]), CarsCheckBoxList.Items[i].Text, string.Empty); jobcars.Add(car); } } if (JobNewDatePanel.Visible) { DateTime JobStart = Convert.ToDateTime(JobNewDate.Text); SiteUtilities.JobComplete(new Guid(Request.QueryString["JobID"]), JobStart); SiteUtilities.DeleteOldSession(job, Session); Response.Redirect(Request.Url.ToString()); } else { SiteUtilities.DeleteOldSession(job, Session); SiteUtilities.UpdateOrCreateJob(new Guid(Request.QueryString["JobID"]), job, personInJob, jobcars); Response.Redirect(Request.Url.ToString()); } }