Exemplo n.º 1
0
    protected void initJob(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Job job          = e.Item.DataItem as Job;
            var jobstarttime = e.Item.FindControl("JobStartTime") as Literal;
            var jobendtime   = e.Item.FindControl("JobEndTime") as Literal;
            var jobcar       = e.Item.FindControl("JobCar") as Literal;
            var jobphone     = e.Item.FindControl("JobPhone") as Literal;
            if (job != null)
            {
                if (jobstarttime != null)
                {
                    jobstarttime.Text = job.JobStartTime.TimeOfDay.ToString();
                }
                if (jobendtime != null)
                {
                    jobendtime.Text = job.JobEndTime.TimeOfDay.ToString();
                }

                if (jobphone != null)
                {
                    jobphone.Text = job.Phone;
                }

                if (jobcar != null)
                {
                    var existingcars = SiteUtilities.GetCarFromJobID(job.JobId);

                    for (int i = 0; i < existingcars.Count; i++)
                    {
                        jobcar.Text += existingcars[i].Name;
                    }
                }
            }
        }
    }
Exemplo n.º 2
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
        {
        }
    }