예제 #1
0
        private void btn_Reject_Click(object sender, RoutedEventArgs e)
        {
            var DC       = new BloodBankDBDataContext();
            var requests = DC.BloodRequests.First(x => x.Id == request.Id);

            requests.Status = "REJECTED";
            DC.SubmitChanges();
            RequestList requestList = new RequestList();

            requestList.ShowDialog();
        }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (dtpDonorDate.SelectedDate > DateTime.UtcNow.AddMonths(+3))
     {
         MessageBox.Show("Donor not able to donate blood on this Date");
     }
     else if (dtpDonorDate.SelectedDate < DateTime.UtcNow)
     {
         MessageBox.Show("Please Select Future Date");
     }
     else
     {
         var DC      = new BloodBankDBDataContext();
         var donordb = DC.Donors.First(x => x.Id == donor.Id);
         donordb.Date = dtpDonorDate.SelectedDate;
         DC.SubmitChanges();
         this.Close();
     }
 }
        // 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;
        }
예제 #4
0
 private void btn_Approve_Click(object sender, RoutedEventArgs e)
 {
     if (dtp_date.SelectedDate == null || dtp_date.SelectedDate < DateTime.Now)
     {
         MessageBox.Show("Please Enter Valid Date");
     }
     else
     {
         int donorId = availabledonors[ddl_donors.SelectedIndex].Id;
         var DC      = new BloodBankDBDataContext();
         var donor   = DC.Donors.First(x => x.Id == donorId);
         donor.Date = dtp_date.SelectedDate;
         var requests = DC.BloodRequests.First(x => x.Id == request.Id);
         requests.Status    = "APPROVED";
         requests.DonorId   = donor.Id;
         requests.DonarDate = dtp_date.SelectedDate;
         DC.SubmitChanges();
         RequestList requestList = new RequestList();
         requestList.ShowDialog();
     }
 }
예제 #5
0
        // On click add button, validate all data and save into database
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            AddButton.Focusable = false;

            if (NameTextBox.Text == null || NameTextBox.Text.Length == 0 ||
                PhoneTextBox.Text == null || PhoneTextBox.Text.Length == 0 ||
                AgeTextBox.Text == null || AgeTextBox.Text.Length == 0 ||
                BloodGroupComboBox.SelectedIndex < 0 ||
                CityComboBox.SelectedIndex < 0 ||
                ProvinceComboBox.SelectedIndex < 0)
            {
                MessageBox.Show("Please fill all fields");
                return;
            }

            int provinceId   = provinceList[ProvinceComboBox.SelectedIndex].Id;
            int bloodGroupId = bloodgroupList[BloodGroupComboBox.SelectedIndex].Id;
            int cityId       = cityList[CityComboBox.SelectedIndex].Id;

            Donor Dnrobj = new Donor();

            Dnrobj.Name           = NameTextBox.Text;
            Dnrobj.Age            = int.Parse(AgeTextBox.Text);
            Dnrobj.Gender         = Male.IsChecked.GetValueOrDefault() ? "Male" : "Female";
            Dnrobj.City           = cityId;
            Dnrobj.Province       = provinceId;
            Dnrobj.Phone          = PhoneTextBox.Text;
            Dnrobj.BloodGroup     = bloodGroupId;
            Dnrobj.BloodAvailable = Yes.IsChecked.GetValueOrDefault() ? 1 : 0;
            Dnrobj.Date           = DateTime.Now;

            DC.Donors.InsertOnSubmit(Dnrobj);
            DC.SubmitChanges();
            MessageBox.Show("Donor is added successfully!");
            Close();
        }