private void Add_Contact(object sender, RoutedEventArgs e)
        {
            if(ContactFirstName != null && ContactFirstName != ""  && ContactLastName != null && ContactLastName != "")
            {

                FCS_DBModel db = new FCS_DBModel();
                DonorContact d = new DonorContact();

                d.ContactFirstName = ContactFirstName;
                d.ContactLastName = ContactLastName;
                d.ContactPhone = ContactPhone;
                d.ContactEmail = ContactEmail;
                d.DonorID = DonorID;

                db.DonorContacts.Add(d);
                if (ContactPhone.Length < 11)
                {
                    db.SaveChanges();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("The phone number entered is invalid.");
                }
            }
            //add both patient and household
            else
            {
                MessageBox.Show("Please check the data entered.");
            }

        }
        private void Add_Contact(object sender, RoutedEventArgs e)
        {
            try
            {
                if (DonorFirstName != null && DonorFirstName != "" && DonorLastName != null && DonorLastName != "" && ContactPhone != null && ContactPhone != ""
                    && ContactEmail != null && ContactEmail != "")
                {
                    FCS_DBModel db = new FCS_DBModel();
                    //MessageBox.Show(DonorFirstName + "\n" + DonorLastName + "\n" + ContactPhone + "\n" + ContactEmail + "\n" + DonorAddress1 + "\n" + DonorAddress2
                    //    + "\n" + DonorCity + "\n" + DonorState + "\n" + DonorZip + "\n" + DonorType + "\n" + OrganizationName);
                    Donor d = new Donor();
                    DonorContact dc = new DonorContact();

                    d.DonorType = DonorType;
                    d.OrganizationName = OrganizationName;
                    d.DonorAddress1 = DonorAddress1;
                    d.DonorAddress2 = DonorAddress2;
                    d.DonorState = DonorState;
                    d.DonorCity = DonorCity;
                    d.DonorZip = DonorZip;
                    db.Donors.Add(d);
                    db.SaveChanges();

                    dc.ContactFirstName = DonorFirstName;
                    dc.ContactLastName = DonorLastName;
                    dc.ContactPhone = ContactPhone;
                    dc.ContactEmail = ContactEmail;
                    dc.DonorID = d.DonorID;
                    db.DonorContacts.Add(dc);
                    db.SaveChanges();
                    
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Add the correct fields.");
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show("Make sure your phone number is 10 digits or less.");
            }
        }
        private void CreateDonor(object sender, RoutedEventArgs e)
        {
            Determine_DonorType(this.dType.SelectedIndex);
            //DonorFirstName != null && DonorFirstName != "" && DonorLastName != null && DonorLastName != ""
            if (DonorType != null && DonorType != "")
            {
                FCS_DBModel db = new FCS_DBModel();
                if (DonorType == "Organization" || DonorType == "Government" || DonorType == "Insurance")
                {
                    var OrgName = from d in db.Donors
                                  where d.OrganizationName == OrganizationName
                                  select d;
                    if (OrganizationName != null && OrganizationName != "")
                    {
                        //MessageBox.Show(DonorAddress1 + "\n" + DonorAddress2 + "\n" + DonorCity + "\n" + DonorState + "\n" + DonorZip
                        //    + "\n" + DonorType + "\n" + OrganizationName);
                        Donor d = new Donor();


                        try { d.DonorState = DonorState; } catch { }
                        try { d.DonorCity = DonorCity; } catch { }
                        try { d.DonorZip = DonorZip; } catch { }
                        try { d.DonorAddress2 = DonorAddress2; } catch { }
                        try { d.DonorAddress1 = DonorAddress1; } catch { }
                        d.DonorType = DonorType;
                        d.OrganizationName = OrganizationName;
                        db.Donors.Add(d);

                        db.SaveChanges();
                        
                        this.Close();
                    }
                    else if (OrganizationName == null || OrganizationName == "")
                    {
                        MessageBox.Show("Make sure to add an Organization Name.");
                    }
                    else
                    {
                        MessageBox.Show("There is already an organization with the name selected. \nNote: Number the organizations if any organizations have the same name.");
                    }
                }
                else if(DonorType == "Individual")
                {
                    //MessageBox.Show(DonorAddress1 + "\n" + DonorAddress2 + "\n" + DonorCity + "\n" + DonorState + "\n" + DonorZip
                    //    + "\n" + DonorType + "\n" + OrganizationName);
                    if(DonorZip == null)
                    {
                        DonorZip = "";
                    }
                    if(DonorState == null)
                    {
                        DonorState = "";
                    }
                    if(DonorZip.Length <= 5 && DonorState.Length <= 2)
                    { 
                        Donor d = new Donor();

                        d.DonorType = DonorType;
                        d.OrganizationName = OrganizationName;
                        d.DonorAddress1 = DonorAddress1;
                        d.DonorAddress2 = DonorAddress2;
                        d.DonorState = DonorState;
                        d.DonorCity = DonorCity;
                        d.DonorZip = DonorZip;

                        CreateIndividualContact cic = new CreateIndividualContact(d);
                        this.Close();
                        cic.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Make sure your state is two digits and your zip is 5 digits.");
                    }
                }
                //its anonymous
                else if(DonorType == "Anonymous")
                {
                    //"Anonymous"
                    int anony = db.Donors.Where(x => x.DonorType == "Anonymous").Select(x => x.DonorType).Count(); //Distinct().First();
                    string Anon = "Anonymous";
                    if (anony < 1)
                    {
                        Donor d = new Donor();
                        d.DonorType = Anon;
                        d.OrganizationName = Anon;
                        d.DonorAddress1 = Anon;
                        d.DonorAddress2 = Anon;
                        d.DonorState = "";
                        d.DonorCity = Anon;
                        d.DonorZip = "";
                        DonorContact dc = new DonorContact();
                        dc.ContactFirstName = Anon;
                        dc.ContactLastName = Anon;
                        dc.ContactPhone = Anon;
                        dc.ContactEmail = Anon;
                        dc.DonorID = d.DonorID;

                        db.Donors.Add(d);
                        db.DonorContacts.Add(dc);
                        db.SaveChanges();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Anonymous donor already exists");
                    }
                }
            }
            //add both patient and household
            else
            {
                MessageBox.Show("Make sure to select Donor Type.");
            }

        }