public void UpdateScreenUI(bool working) { List <Job> jobs = new JobCRUD().GetJobs(); if (working) { WorkPeriod wp = new WorkPeriodCRUD().GetWorkPeriodByUserIdAndWorkPeriodId(CurrentUser.UserId, CurrentUser.WorkPeriodId); this.GbJobComboBox.Visibility = Visibility.Hidden; this.GbJobLabel.Visibility = Visibility.Visible; this.LblJobName.Content = jobs.Where(x => x.JobId == wp.JobId).First().Name; this.BtnClock.Content = "Clock Out"; } else { this.GbJobComboBox.Visibility = Visibility.Visible; this.GbJobLabel.Visibility = Visibility.Hidden; this.CbJobId.ItemsSource = jobs; this.CbJobId.DisplayMemberPath = "Name"; this.CbJobId.SelectedValuePath = "JobId"; this.BtnClock.Content = "Clock In"; } }
public void BindDataGrid(List <Job> jobs) { if (jobs == null) { jobs = new JobCRUD().GetJobs(); } List <JobStatusType> statusTypes = new JobTypeCRUD().GetJobStatusTypes(); List <JobType> jobTypes = new JobTypeCRUD().GetJobTypes(); foreach (var job in jobs) { if (job.JobStatusTypeId > 0) { job.JobStatusTypeName = statusTypes.Where(x => x.JobStatusTypeId == job.JobStatusTypeId).First().JobStatusTypeName; } else { job.JobStatusTypeName = "None"; } if (job.JobTypeId > 0) { job.JobTypeName = jobTypes.Where(x => x.JobTypeId == job.JobTypeId).First().JobTypeName; } else { job.JobTypeName = "None"; } } this.dgData.ItemsSource = jobs; }
public void JobSearch(SearchWindow window) { string name = window.TxtSearchJobName.Text; string balanceDue = window.TxtSearchJobBalanceDue.Text; string city = window.TxtSearchJobCity.Text; bool? mobile = window.ChkSearchJobMobile.IsChecked; string statusId = window.CbSearchJobJobStatusId.Text; string scheduledDate = window.DpSearchJobScheduledDate.Text; List <Job> jobs = new JobCRUD().GetJobs(); if (!String.IsNullOrEmpty(name)) { jobs.RemoveAll(x => x.Name != name); } if (!String.IsNullOrEmpty(balanceDue)) { jobs.RemoveAll(x => x.BalanceDue != Convert.ToDecimal(balanceDue)); } if (!String.IsNullOrEmpty(city)) { jobs.RemoveAll(x => x.City != city); } if (mobile != null) { jobs.RemoveAll(x => x.Mobile != mobile); } if (!String.IsNullOrEmpty(statusId)) { jobs.RemoveAll(x => x.JobStatusId != Convert.ToInt32(statusId)); } if (scheduledDate.Length > 0) { jobs.RemoveAll(x => x.ScheduledDate != Convert.ToDateTime(scheduledDate)); } if (jobs.Count > 0) { BindDataGrid(jobs); window.Close(); } else { MessageBox.Show("There are no results", "Information"); } }
private void BtnSubmit_Click(object sender, RoutedEventArgs e) { int result = new JobCRUD().Update((Job)this.DataContext); if (result > 0) { this.Close(); MessageBox.Show("Job was updated", "Success"); } else { MessageBox.Show("Job failed to update", "Failure"); } }
public void BindDataGrid(List <Order> orders) { if (orders == null) { orders = new OrderCRUD().GetOrders(); } if (orders.Count > 0) { List <OrderStatus> orderStatuses = new OrderCRUD().GetOrderStatuses(); List <Job> jobs = new JobCRUD().GetJobs(); foreach (Order ord in orders) { if (ord.OrderStatusId > 0) { if (orderStatuses.Count > 0) { ord.OrderStatusName = orderStatuses.Where(x => x.OrderStatusId == ord.OrderStatusId).First().OrderStatusName; } else { ord.OrderStatusName = "None"; } } else { ord.OrderStatusName = "None"; } if (ord.JobId > 0) { if (jobs.Count > 0) { ord.JobName = jobs.Where(x => x.JobId == ord.JobId).First().Name; } else { ord.JobName = "None"; } } else { ord.JobName = "None"; } } } dgData.ItemsSource = orders; }
private void BtnSubmit_Click(object sender, RoutedEventArgs e) { Job currentJob = (Job)this.DataContext; int result = new JobCRUD().Create(currentJob); if (result > 0) { this.Close(); MessageBox.Show("Job was created", "Success"); } else { MessageBox.Show("Failed to create job", "Failure"); } }
public void BindDataGrid(List <Objects.Invoice> invoices) { if (invoices == null) { invoices = new InvoiceCRUD().GetInvoices(); } List <Objects.InvoiceType> invoiceTypes = new InvoiceCRUD().GetInvoiceTypes(); List <Job> allJobs = new JobCRUD().GetJobs(); if (invoices.Count > 0) { foreach (var inv in invoices) { if (inv.InvoiceTypeId > 0) { inv.InvoiceTypeName = invoiceTypes.Where(x => x.InvoiceTypeId == inv.InvoiceTypeId).First().InvoiceTypeName; } else { inv.InvoiceTypeName = "None"; } try { if (inv.JobId > 0) { inv.JobName = allJobs.Where(x => x.JobId == inv.JobId).First().Name; } else { inv.JobName = "None"; } } catch (Exception ex) { inv.JobName = ""; continue; } } } this.dgData.ItemsSource = invoices; }
private void BtnDestroy_Click(object sender, RoutedEventArgs e) { int result = 0; if (GetSelectedJob().JobId > 0) { MessageBoxResult mbResult = MessageBox.Show("Deleting a job will also delete any charges for this job. Are you sure you want to delete this job and it's charges?", "Warning", MessageBoxButton.YesNo); if (mbResult == MessageBoxResult.Yes) { result = new JobCRUD().Destroy(GetSelectedJob().JobId); if (result > 0) { BindDataGrid(); MessageBox.Show("The job and it's charges were deleted", "Success"); } else { MessageBox.Show("Unable to delete job and it's charges", "Failure"); } } } }
private void BtnDestroy_Click(object sender, RoutedEventArgs e) { int result = 0; if (GetSelectedJob().JobId > 0) { MessageBoxResult mbResult = MessageBox.Show("Deleting this Job will remove all job relations to invoices, orders, time entries and job charges. Are you sure?", "Warning", MessageBoxButton.YesNo); if (mbResult == MessageBoxResult.Yes) { result = new JobCRUD().Destroy(GetSelectedJob().JobId); if (result > 0) { BindDataGrid(null); MessageBox.Show("The job and it's charges were deleted. All invoices, orders and time periods are no longer assigned to this job", "Success"); } else { MessageBox.Show("Unable to delete job and it's charges; something went wrong.", "Failure"); } } } }