Example #1
0
    protected void Job(object sender, EventArgs e)
    {
        if (Request.QueryString["JobID"] == null)
        {
            EditArea.Visible = false;
            return;
        }

        JobNewDate.Text = DateTime.Now.ToShortDateString();
        InitButtons();
        if (!Page.IsPostBack)
        {
            try
            {
                InitMembershipInfo(c_listBoxSelectedItems, c_listBoxExistingItems);
                if (Request.QueryString["JobID"] != null)
                {
                    string jobdatetime = "";

                    TextBox textBox  = sender as TextBox;
                    var     jobslist = SiteUtilities.GetJobsByJobId(new Guid(Request.QueryString["JobID"]));

                    if (jobslist.Count > 0)
                    {
                        JobContactPhone.Text = jobslist[0].Phone;

                        if (jobslist[0].JobStartTime.Hour.ToString() != "23")
                        {
                            ListItem starttime =
                                StartTime.Items.FindByText(jobslist[0].JobStartTime.ToShortTimeString().Substring(0, 5)) as ListItem;
                            starttime.Selected = true;
                        }
                        else
                        {
                            StartTime.Items[0].Selected = true;
                        }


                        if (jobslist[0].JobEndTime.Hour.ToString() != "23")
                        {
                            ListItem endtime =
                                EndTime.Items.FindByText(jobslist[0].JobEndTime.ToShortTimeString().Substring(0, 5)) as ListItem;
                            endtime.Selected = true;
                        }
                        else
                        {
                            EndTime.Items[18].Selected = true;
                        }
                    }
                }
            }
            catch
            {
            }
        }
    }
Example #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["JobID"] != null)
        {
            JobID = new Guid(Request.QueryString["JobID"]);

            var job = SiteUtilities.GetJobsByJobId(JobID);

            if (job.Count > 0)
            {
                sessionweekObject = SiteUtilities.GetWeekNumber(job[0].JobStartDate, 0);
                displayweek       = Convert.ToInt16(sessionweekObject);
                if (Session["Week"] == null)
                {
                    Session.Add("Week", week);
                }
                CurrentYear     = job[0].JobStartDate.Year;
                CurrentWeek     = Convert.ToInt16(sessionweekObject);
                now             = job[0].JobStartDate;
                Session["Week"] = sessionweekObject;

                if (job[0].JobStartDate.ToString() == "9999-12-31 00:00:00")
                {
                    FirstDayofWeek = SiteUtilities.GetFirstDayOfWeek(DateTime.Now.Year, SiteUtilities.GetWeekNumber(DateTime.Now, 0));
                }
                else
                {
                    FirstDayofWeek = SiteUtilities.GetFirstDayOfWeek(CurrentYear, CurrentWeek);
                }
            }
        }
        else
        {
            if (Session["CurrentWeekFirstDay"] != null)
            {
                FirstDayofWeek = Convert.ToDateTime(Session["CurrentWeekFirstDay"]);
            }
            else
            {
                FirstDayofWeek = SiteUtilities.GetFirstDayOfWeek(DateTime.Now.Year, SiteUtilities.GetWeekNumber(DateTime.Now, 0));
            }
        }


        displayweek     = SiteUtilities.GetWeekNumber(FirstDayofWeek, 0);
        weeknumber.Text = "Vecka " + displayweek.ToString() + " År: " + FirstDayofWeek.Year;
        Job(sender, e);
    }
Example #3
0
    protected void FreeWeekOfRental()
    {
        if (Request.QueryString["JobID"] != null)
        {
            string jobdatetime = "";

            var jobslist = SiteUtilities.GetJobsByJobId(new Guid(Request.QueryString["JobID"]));

            if (jobslist[0].ParentJobID != Guid.Empty)
            {
                Guid tmp = jobslist[0].ParentJobID;
                jobslist.Clear();
                jobslist = SiteUtilities.GetJobsByJobId(tmp);
            }


            if (jobslist[0].RentStartDate.ToShortDateString() != "9999-12-31" && jobslist[0].RentEndDate.ToShortDateString() != "9999-12-31")
            {
                TimeSpan dateTime = jobslist[0].RentEndDate - jobslist[0].RentStartDate;

                int weeks = Convert.ToInt32(dateTime.TotalDays) / 7;


                ListItem freeweek = FreeWeeksOfRental.Items.FindByValue(weeks.ToString()) as ListItem;
                freeweek.Selected = true;
            }
            else
            {
                for (int i = 0; i < FreeWeeksOfRental.Items.Count; i++)
                {
                    FreeWeeksOfRental.Items[i].Selected = false;
                }
                ListItem freeweek = FreeWeeksOfRental.Items.FindByText("4 veckor") as ListItem;
                freeweek.Selected = true;
            }

            if (FreeWeeksOfRental != null)
            {
                RentalEndDate.Text = jobslist[0].RentEndDate.ToShortDateString();
            }
        }
    }
Example #4
0
    protected void InitCarsList(object sender, EventArgs e)
    {
        try
        {
            CheckBoxList    checkBoxList = sender as CheckBoxList;
            List <ListItem> carsLists    = new List <ListItem>();
            if (checkBoxList != null && Request.QueryString["JobID"] != null)
            {
                var jobslist     = SiteUtilities.GetJobsByJobId(new Guid(Request.QueryString["JobID"]));
                var allcars      = SiteUtilities.GetAllCars();
                var existingcars = SiteUtilities.GetCarFromJobID(jobslist[0].JobId);


                foreach (Car existingcar in existingcars)
                {
                    for (int i = 0; i < allcars.Count; i++)
                    {
                        if (existingcar.CarId == allcars[i].CarId)
                        {
                            string   name = allcars[i].Name;
                            ListItem item = new ListItem(name, allcars[i].CarId.ToString());
                            item.Selected = true;
                            carsLists.Add(item);
                            allcars.Remove(allcars[i]);
                        }
                    }
                }

                for (int i = 0; i < allcars.Count; i++)
                {
                    string   name = allcars[i].Name;
                    ListItem item = new ListItem(name, allcars[i].CarId.ToString());
                    carsLists.Add(item);
                }
            }
            else
            {
                var allcars = SiteUtilities.GetAllCars();
                for (int i = 0; i < allcars.Count; i++)
                {
                    string   name = allcars[i].Name;
                    ListItem item = new ListItem(name, allcars[i].CarId.ToString());
                    carsLists.Add(item);
                }
            }



            checkBoxList.DataSource = carsLists;
            checkBoxList.DataBind();

            for (int i = 0; i < checkBoxList.Items.Count; i++)
            {
                if (checkBoxList.Items[i].Text == carsLists[i].Text)
                {
                    if (carsLists[i].Selected)
                    {
                        checkBoxList.Items[i].Selected = true;
                        checkBoxList.Items[i].Value    = carsLists[i].Value;
                    }
                    else
                    {
                        checkBoxList.Items[i].Value = carsLists[i].Value;
                    }
                }
            }
        }
        catch
        {
        }
    }
Example #5
0
    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());
        }
    }
Example #6
0
    protected void JobDateInit(object sender, EventArgs e)
    {
        if (Request.QueryString["JobID"] != null)
        {
            try
            {
                Guid jobid = new Guid(Request.QueryString["JobID"]);

                var jobslist = SiteUtilities.GetJobsByJobId(jobid);
                var tmplist  = SiteUtilities.GetCloneJobsByJobId(jobslist[0].JobId);


                if (tmplist.Count == 0 && jobslist[0].ParentJobID == Guid.Empty)
                {
                    if (jobslist[0].Type == SiteUtilities.CONSTRUCTION)
                    {
                        Button1.Visible = false;
                    }
                }

                if (jobslist[0].ParentJobID == Guid.Empty)
                {
                }
                else if (jobslist[0].ParentJobID != Guid.Empty)
                {
                    if (jobslist[0].Type == SiteUtilities.CONSTRUCTION || jobslist[0].Type == SiteUtilities.DESTRUCTION)
                    {
                        JobDate.Visible           = false;
                        JobDateEnd.Visible        = false;
                        JobDateSet.Visible        = false;
                        FreeWeeksOfRental.Visible = false;
                        JobName.Enabled           = false;
                        JobAddress.Enabled        = false;
                    }
                }
                else if (jobslist[0].Type == SiteUtilities.CONSTRUCTIONFINNISHED || jobslist[0].Type == SiteUtilities.DESTRUCTIONFINNISHED)
                {
                    JobDate.Visible           = false;
                    JobDateEnd.Visible        = false;
                    JobDateSet.Visible        = false;
                    FreeWeeksOfRental.Visible = false;
                    JobName.Enabled           = false;
                    JobAddress.Enabled        = false;
                }

                if (jobslist[0].JobStartDate.ToShortDateString() == "9999-12-31")
                {
                    JobDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
                    if (jobslist[0].JobEndDate.ToShortDateString() == "9999-12-31")
                    {
                        JobDateEnd.Text = DateTime.Now.ToString("yyyy-MM-dd");
                    }
                }
                else
                {
                    JobDate.Text = jobslist[0].JobStartDate.ToShortDateString();
                    if (jobslist[0].JobEndDate.ToShortDateString() != "9999-12-31")
                    {
                        JobDateEnd.Text = jobslist[0].JobEndDate.ToShortDateString();
                    }
                }


                JobContact.Text  = jobslist[0].ContactName;
                JobName.Text     = jobslist[0].JobName;
                JobAddress.Text  = jobslist[0].Address;
                JobComments.Text = jobslist[0].Comments;

                FreeWeekOfRental();
            }
            catch
            {
            }
        }
    }