Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
        public RequestList()
        {
            InitializeComponent();

            DC     = new BloodBankDBDataContext();
            IdList = new List <int>();

            LoadData();
        }
Exemplo n.º 3
0
        public ViewDonors()
        {
            InitializeComponent();

            DC     = new BloodBankDBDataContext();
            IdList = new List <int>();

            LoadData();
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
0
        private BloodGroup[] bloodgroupList; // array of blood groups

        public AddNewDonor()
        {
            InitializeComponent();
            DC = new BloodBankDBDataContext();

            // get all provinces, add into array and show in combobox
            var provinces = from P in DC.Provinces select P;

            provinceList = new Province[provinces.ToList().Count];
            int i = 0;

            foreach (var p in provinces.ToList())
            {
                provinceList[i] = p;
                i++;
            }
            ProvinceComboBox.ItemsSource       = provinces.Distinct();
            ProvinceComboBox.DisplayMemberPath = "ProvinceName";


            // get all blood groups, add into array and show in combobox
            var bloodGroups = from BG in DC.BloodGroups select BG;

            bloodgroupList = new BloodGroup[bloodGroups.ToList().Count];
            i = 0;
            foreach (var bg in bloodGroups.ToList())
            {
                bloodgroupList[i] = bg;
                i++;
            }
            BloodGroupComboBox.ItemsSource       = bloodGroups.Distinct();
            BloodGroupComboBox.DisplayMemberPath = "Name";

            var cities = from P in DC.Cities select P;

            cityList = new City[cities.ToList().Count];
            i        = 0;
            foreach (var p in cities.ToList())
            {
                cityList[i] = p;
                i++;
            }
            CityComboBox.ItemsSource       = cities.Distinct();
            CityComboBox.DisplayMemberPath = "CityName";


            // show current date-time in form
            DateTime dateTime = DateTime.Now;

            DateTextBox.Text = dateTime.Date.ToShortDateString();
        }
Exemplo n.º 6
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var DC         = new BloodBankDBDataContext();
            var donordb    = DC.Donors.First(x => x.Id == donor.Id);
            int provinceId = provinceList[ddlProvince.SelectedIndex].Id;
            int cityId     = cityList[ddlCity.SelectedIndex].Id;

            donordb.City           = cityId;
            donordb.Province       = provinceId;
            donordb.Phone          = txtPhone.Text;
            donordb.BloodAvailable = Yes.IsChecked.GetValueOrDefault() ? 1 : 0;
            MessageBox.Show("Donor is added successfully!");
            Close();
        }
Exemplo n.º 7
0
        private bool isValidAdmin(string username, string password)
        {
            //querying db for validating admin credentials
            BloodBankDBDataContext dc = new BloodBankDBDataContext();
            var q = from p in dc.Credentials where p.Username == username && p.Password == password && p.Type == "admin" select p;

            if (q.Any())
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 8
0
        private void EditDonor_Click(object sender, RoutedEventArgs e)
        {
            if (DonorsDataGridPending.CurrentItem == null)
            {
                return;
            }
            DC = new BloodBankDBDataContext();
            int selectedRowIndex = DonorsDataGridPending.Items.IndexOf(DonorsDataGridPending.CurrentItem);
            int Id            = IdList[selectedRowIndex];
            var bloodrequests = (from D in DC.BloodRequests where D.Id == Id select D).Single();

            RequestApproval form = new RequestApproval(bloodrequests);

            form.ShowDialog();
            Close();

            DonorsDataGridPending.UnselectAll();
        }
Exemplo n.º 9
0
        private void EditDonor_Click(object sender, RoutedEventArgs e)
        {
            if (DonorsDataGrid.CurrentItem == null)
            {
                return;
            }
            DC = new BloodBankDBDataContext();
            int selectedRowIndex = DonorsDataGrid.Items.IndexOf(DonorsDataGrid.CurrentItem);
            int Id    = IdList[selectedRowIndex];
            var Donor = (from D in DC.Donors where D.Id == Id select D).Single();

            EditDonor form = new EditDonor(Donor);

            form.ShowDialog();
            ApplyFilter();

            DonorsDataGrid.UnselectAll();
        }
 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();
     }
 }
        public SearchByBloodGroup(bool isAdmin, string username)
        {
            InitializeComponent();
            BloodAvailibility = new Dictionary <string, bool>();
            this.isAdmin      = isAdmin;
            user = username;

            BloodBankDBDataContext DC = new BloodBankDBDataContext();
            //Querying db for stored blood groups
            var result = from b in DC.BloodGroups select b;

            foreach (var b in result)
            {
                //for each blood group search in db for for availability
                var result2 = from d in DC.Donors where d.BloodGroup == b.Id && d.BloodAvailable == 1 select d;
                //store available blood groups in dictionary
                BloodAvailibility.Add(b.Name, result2.Any());
            }

            if (isAdmin)
            {
                LogoutButton.Visibility = Visibility.Hidden;
            }

            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;
        }
        // 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;
        }
Exemplo n.º 13
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();
     }
 }
        public AppointmentApproval(Donor donor)
        {
            InitializeComponent();
            this.donor = donor;
            DC         = new BloodBankDBDataContext();

            if (donor != null)
            {
                txt_Name.Text       = donor.Name;
                txt_bloodGroup.Text = DC.BloodGroups.First(d => d.Id == donor.BloodGroup).Name;
                txt_Donor_No.Text   = donor.Id.ToString();
                if (donor.Date > DateTime.UtcNow)
                {
                    MessageBox.Show("Donor already have an appointment");
                    btn_Submit.Visibility = Visibility.Hidden;
                }
                else
                {
                    btn_Submit.Visibility = Visibility.Visible;
                }
            }
        }
Exemplo n.º 15
0
        private City[] cityList;           // array of city
        public EditDonor(Donor donor)
        {
            InitializeComponent();
            this.donor = donor;
            DC         = new BloodBankDBDataContext();

            // get all provinces, add into array and show in combobox
            var provinces = from P in DC.Provinces select P;

            provinceList = new Province[provinces.ToList().Count];
            int i = 0;

            foreach (var p in provinces.ToList())
            {
                provinceList[i] = p;
                i++;
            }
            ddlProvince.ItemsSource   = provinces.Distinct();
            ddlCity.DisplayMemberPath = "ProvinceName";
            var cities = from P in DC.Cities select P;

            cityList = new City[cities.ToList().Count];
            i        = 0;
            foreach (var p in cities.ToList())
            {
                cityList[i] = p;
                i++;
            }
            ddlCity.ItemsSource       = cities.Distinct();
            ddlCity.DisplayMemberPath = "CityName";
            if (donor != null)
            {
                NameTextBox.Text = donor.Name;
                txtPhone.Text    = donor.Phone;
            }
        }
Exemplo n.º 16
0
 public SearchHelper()
 {
     DC = new BloodBankDBDataContext();
 }