protected void ServicesGridView_RowCommand(object sender, GridViewCommandEventArgs e) { GridViewRow row = ((LinkButton)e.CommandSource).NamingContainer as GridViewRow; JobController control = new JobController(); List <ServiceDetailPoco> serviceDetail = control.ListServiceDetails(int.Parse(JobNumberLabel.Text)); int serviceDetailiD = int.Parse(ServicesGridView.DataKeys[row.RowIndex].Value.ToString()); int jobId = int.Parse(JobNumberLabel.Text); if (e.CommandName == "start") { MessageUserControl.TryRun(() => { control.ChangeStatus(serviceDetailiD, jobId, "S"); serviceDetail = control.ListServiceDetails(int.Parse(JobNumberLabel.Text)); ServicesGridView.DataSource = serviceDetail; ServicesGridView.DataBind(); }, "Status Update", row.Cells[0].Text + " status set to start"); } else if (e.CommandName == "done") { MessageUserControl.TryRun(() => { control.ChangeStatus(serviceDetailiD, jobId, "C"); serviceDetail = control.ListServiceDetails(int.Parse(JobNumberLabel.Text)); ServicesGridView.DataSource = serviceDetail; ServicesGridView.DataBind(); }, "Status Update", row.Cells[0].Text + " status set to done"); } else if (e.CommandName == "view") { foreach (var item in serviceDetail) { if (item.ServiceDetailID == serviceDetailiD) { DescriptionLabel.Text = item.Description; HoursLabel.Text = item.JobHours.ToString(); CommentsLabel.Text = item.Comments; ServiceDetailIdLabel.Text = item.ServiceDetailID.ToString(); } } ViewServiceDetails.Visible = true; PartsObjectDataSource.SelectParameters["serviceDetailId"].DefaultValue = serviceDetailiD.ToString(); } else if (e.CommandName == "remove") { if (serviceDetail.Count > 1) { MessageUserControl.TryRun(() => { control.DeleteServiceDetail(serviceDetailiD); }, "Service Deleted", "Service was successfully removed"); serviceDetail = control.ListServiceDetails(int.Parse(JobNumberLabel.Text)); ServicesGridView.DataSource = serviceDetail; ServicesGridView.DataBind(); } else { MessageUserControl.TryRun(() => { control.DeleteJob(jobId, serviceDetailiD); currentJobListForm.Visible = true; currentJobForm.Visible = false; NewJobButton.Visible = true; currentJobService.Visible = false; ViewServiceDetails.Visible = false; JobGridView.DataSource = control.ListCurrentJobs(); JobGridView.DataBind(); }, "Job Deleted", "All services removed job has been deleted"); } } }