protected void GetAllJobs(object sender, EventArgs e) { Panel panel = sender as Panel; DateTime now = System.DateTime.Now; String daylabel = ""; DateTime daytime = new DateTime(); if (Session["Week"] == null) { Session.Add("Week", week); } sessionweekObject = Session["Week"]; if (sessionweekObject.ToString() == "0") { sessionweekObject = SiteUtilities.GetWeekNumber(DateTime.Now, 0); } List <JobList> jobLists = new List <JobList>(); GetDate(now, jobLists); for (int i = 0; i < jobLists.Count; i++) { List <JobPersonList> personInJob = new List <JobPersonList>(); var tmplist = SiteUtilities.GetJobsByDate(jobLists[i].Date); for (int j = 0; j < tmplist.Count; j++) { personInJob = SiteUtilities.GetJobPersonal(tmplist[j].JobId); for (int k = 0; k < personInJob.Count; k++) { if (personInJob[k] != null) { string names = personInJob[k].Firstname + " " + personInJob[k].Lastname + " "; tmplist[j].PersonsInThisJob += names; } } } jobLists[i].Jobs = tmplist; } jobRepeater.DataSource = jobLists; jobRepeater.DataBind(); }
protected void GetAllJobs(object sender, EventArgs e) { if (Session["Week"] == null) { Session.Add("Week", week); } sessionweekObject = Session["Week"]; if (sessionweekObject.ToString() == "0") { sessionweekObject = SiteUtilities.GetWeekNumber(DateTime.Now, 0); } List <JobList> jobLists = new List <JobList>(); GetDate(FirstDayofWeek, jobLists); for (int i = 0; i < jobLists.Count; i++) { //List<Job> tmplist = new List<Job>(); var personInJob = new List <JobPersonList>(); var tmplist = SiteUtilities.GetJobsByDate(jobLists[i].Date); for (int j = 0; j < tmplist.Count; j++) { personInJob = SiteUtilities.GetJobPersonal(tmplist[j].JobId); for (int k = 0; k < personInJob.Count; k++) { if (personInJob[k] != null) { if (personInJob[k].Active) { string names = personInJob[k].Firstname + " " + personInJob[k].Lastname.Substring(0, 1) + " "; tmplist[j].PersonsInThisJob += names; } } } } jobLists[i].Jobs = tmplist; } jobRepeater.DataSource = jobLists; jobRepeater.DataBind(); }
protected void GetAllNewJobs(object sender, EventArgs e) { Panel panel = sender as Panel; String daylabel = ""; if (Session["Week"] == null) { Session.Add("Week", week); } sessionweekObject = Session["Week"]; if (sessionweekObject.ToString() == "0") { sessionweekObject = SiteUtilities.GetWeekNumber(DateTime.Now, 0); } if (panel != null && panel.ID == "NoDate") { List <JobPersonList> personInJob = new List <JobPersonList>(); var jobslist = SiteUtilities.GetJobsByDate(DateTime.MaxValue); for (int i = 0; i < jobslist.Count; i++) { personInJob = SiteUtilities.GetJobPersonal(jobslist[i].JobId); for (int j = 0; j < personInJob.Count; j++) { if (personInJob[j] != null) { if (personInJob[j].Active) { string names = personInJob[j].Firstname + " " + personInJob[j].Lastname + " "; jobslist[i].PersonsInThisJob += names; } } } } NoDayRepeater.DataSource = jobslist; NoDayRepeater.DataBind(); NoDateLabel.Text = daylabel; } }
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()); } }