Exemplo n.º 1
0
        protected void CurrentJobGridView_RowCommand(Object sender, GridViewCommandEventArgs e)
        {
            JobController            control       = new JobController();
            GridViewRow              row           = ((LinkButton)e.CommandSource).NamingContainer as GridViewRow;
            List <ServiceDetailPoco> serviceDetail = control.ListServiceDetails(int.Parse(JobNumberLabel.Text));
            int serviceDetailID = int.Parse(CurrentJobGridView.DataKeys[row.RowIndex].Value.ToString());

            if (serviceDetail.Count > 1)
            {
                MessageUserControl.TryRun(() =>
                {
                    control.DeleteServiceDetail(serviceDetailID);
                }, "Service Deleted", "Service was successfully removed");

                serviceDetail = control.ListServiceDetails(int.Parse(JobNumberLabel.Text));
                CurrentJobGridView.DataSource = serviceDetail;
                CurrentJobGridView.DataBind();
            }
            else
            {
                MessageUserControl.TryRun(() =>
                {
                    int jobId = int.Parse(JobNumberLabel.Text);
                    control.DeleteJob(jobId, serviceDetailID);

                    currentJobListForm.Visible = true;
                    currentJobForm.Visible     = false;
                    NewJobButton.Visible       = true;
                    jobInfo.Visible            = false;

                    JobGridView.DataSource = control.ListCurrentJobs();
                    JobGridView.DataBind();
                }, "Job Deleted", "All services removed job has been deleted");
            }
        }
Exemplo n.º 2
0
        protected void JobGridView_RowCommand(Object sender, GridViewCommandEventArgs e)
        {
            JobController control = new JobController();
            GridViewRow   row     = ((LinkButton)e.CommandSource).NamingContainer as GridViewRow;

            currentJobListForm.Visible = false;
            NewJobButton.Visible       = false;
            jobInfo.Visible            = true;
            JobNumberLabel.Text        = row.Cells[0].Text;
            CustomerLabel.Text         = row.Cells[4].Text;
            ContactLabel.Text          = row.Cells[5].Text;

            List <ServiceDetailPoco> serviceDetail = control.ListServiceDetails(int.Parse(JobNumberLabel.Text));

            if (e.CommandName == "CurrentJob")
            {
                pageTitle.InnerHtml           = "Current Job";
                currentJobForm.Visible        = true;
                CurrentJobGridView.DataSource = serviceDetail;
                CurrentJobGridView.DataBind();
            }
            else if (e.CommandName == "CurrentJobService")
            {
                pageTitle.InnerHtml         = "Current Job Service Details";
                currentJobService.Visible   = true;
                ServicesGridView.DataSource = serviceDetail;
                ServicesGridView.DataBind();
            }
        }
Exemplo n.º 3
0
        protected void AddServiceButton_Click(Object sender, EventArgs e)
        {
            MessageUserControl.TryRun(() =>
            {
                JobController control = new JobController();


                ServiceDetailPoco newItem = new ServiceDetailPoco();

                newItem.Description = DescriptionTB.Text;
                newItem.JobID       = int.Parse(JobNumberLabel.Text);

                bool success = decimal.TryParse(HoursTB.Text, out decimal hours);
                if (success)
                {
                    newItem.JobHours = hours;
                }
                else
                {
                    throw new Exception("Must enter a valid decimal for hours.");
                }

                newItem.CouponID = int.Parse(CouponDDL.SelectedValue);

                newItem.Comments = CommentsTB.Text;

                control.AddServiceDetail(newItem);

                List <ServiceDetailPoco> serviceDetail = control.ListServiceDetails(int.Parse(JobNumberLabel.Text));
                CurrentJobGridView.DataSource          = serviceDetail;
                CurrentJobGridView.DataBind();

                DescriptionTB.Text      = "";
                HoursTB.Text            = "";
                CouponDDL.SelectedIndex = 0;
                CommentsTB.Text         = "";
            }, "Service Added", "Service was successfully added to job");
        }