public RequestApproval(BloodRequest bloodRequest) { InitializeComponent(); DC = new BloodBankDBDataContext(); this.request = bloodRequest; txt_requestNumber.Text = bloodRequest.Id.ToString(); txt_HospitalName.Text = request.HospitalId.ToString(); availabledonors = DC.Donors.Where(x => x.Date > DateTime.Now.AddMonths(+3) && x.BloodGroup == request.BloodGroupId).ToList(); if (availabledonors != null && availabledonors.Count > 0) { btn_Approve.Visibility = Visibility.Visible; btn_Reject.Visibility = Visibility.Hidden; ddl_donors.ItemsSource = availabledonors; ddl_donors.DisplayMemberPath = "Name"; lbl_Donor.Visibility = Visibility.Visible; lbl_Donor_Date.Visibility = Visibility.Visible; ddl_donors.Visibility = Visibility.Visible; dtp_date.Visibility = Visibility.Visible; } else { MessageBox.Show("No Donors available"); btn_Approve.Visibility = Visibility.Hidden; btn_Reject.Visibility = Visibility.Visible; lbl_Donor.Visibility = Visibility.Hidden; lbl_Donor_Date.Visibility = Visibility.Hidden; ddl_donors.Visibility = Visibility.Hidden; dtp_date.Visibility = Visibility.Hidden; } }
// validate input and show availibility private void Button_Click(object sender, RoutedEventArgs e) { Request.Focusable = false; if (BloodGroup.SelectedIndex <= 0) { resultBox.Text = "Choose a Blood Group to Search"; return; } bool available = BloodAvailibility[BloodGroup.Text]; BloodBankDBDataContext DC = new BloodBankDBDataContext(); BloodRequest bloodRequest = new BloodRequest(); bloodRequest.Id = Convert.ToInt16(DC.BloodRequests.Max(x => x.Id)) + 1; bloodRequest.BloodGroupId = DC.BloodGroups.FirstOrDefault(x => x.Name == BloodGroup.Text).Id; bloodRequest.HospitalId = DC.Credentials.FirstOrDefault(x => x.Username == user).Id; bloodRequest.Status = "REQUESTED"; bloodRequest.RequestDate = DateTime.UtcNow; DC.BloodRequests.InsertOnSubmit(bloodRequest); DC.SubmitChanges(); resultBox.Text = "Blood requested."; var table = from D in DC.BloodRequests join C in DC.Credentials on D.HospitalId equals C.Id join us in DC.Donors on D.DonorId equals us.Id into ps from us in ps.DefaultIfEmpty() join BG in DC.BloodGroups on D.BloodGroupId equals BG.Id select new { No = D.Id, HospitalName = C.Username, BloodGroup = BG.Name, D.Status, D.DonarDate, DonorName = us.Name, D.RequestDate }; DonorsDataGridPending.ItemsSource = table; }
partial void DeleteBloodRequest(BloodRequest instance);
partial void UpdateBloodRequest(BloodRequest instance);
partial void InsertBloodRequest(BloodRequest instance);