private void Edit_InKindService(object sender, MouseButtonEventArgs e) { DataGrid dg = sender as DataGrid; InKindService p = (InKindService)dg.SelectedItems[0]; // OR: Patient p = (Patient)dg.SelectedItem; UpdateInKindService up = new UpdateInKindService(p); up.DateRecieved.SelectedDate = p.StartDateTime; if (p.StartDateTime.Hour >= 12) { up.AMPM_Start.SelectedIndex = 1; } else { up.AMPM_Start.SelectedIndex = 0; } if (p.EndDateTime.Hour >= 12) { up.AMPM_End.SelectedIndex = 1; } else { up.AMPM_End.SelectedIndex = 0; } up.ShowDialog(); }
public UpdateInKindService(InKindService p) { DonorID = p.DonorID; DonationID = p.DonationID; ServiceID = p.ServiceID; ServiceDescription = p.ServiceDescription; RatePerHour = Math.Round(p.RatePerHour, 2); BeginMinute = p.StartDateTime.Minute.ToString(); EndMinute = p.EndDateTime.Minute.ToString(); if (BeginMinute.Length == 1) { BeginMinute = "0" + BeginMinute; } if (EndMinute.Length == 1) { EndMinute = "0" + EndMinute; } if (p.StartDateTime.Hour > 12) { BeginHour = (p.StartDateTime.Hour - 12).ToString(); } else if (p.StartDateTime.Hour == 0) { BeginHour = "12"; } else { BeginHour = p.StartDateTime.Hour.ToString(); } if (p.EndDateTime.Hour > 12) { EndHour = (p.EndDateTime.Hour - 12).ToString(); } else if (p.EndDateTime.Hour == 0) { EndHour = "12"; } else { EndHour = p.EndDateTime.Hour.ToString(); } InitializeComponent(); text_ServiceDescription.Focus(); }