コード例 #1
0
        public static List<Donator> GetDonator(string BloodGroup, string RhFactor)
        {
            List<Donator> DonatorList = new List<Donator>();

            using (var context = new DonatorContext())
            {
                foreach (var Donator in context.Donators)
                {
                    if (Donator.BloodGroup == BloodGroup && Donator.RhFactor == RhFactor)
                        DonatorList.Add(Donator);
                }
            }

            return DonatorList;
        }
コード例 #2
0
        public static List<Donator> GetDonator(string Name, string Town, string PhoneNumber)
        {
            List<Donator> DonatorList = new List<Donator>();

            using (var context = new DonatorContext())
            {
                foreach (var Donator in context.Donators)
                {
                    if (Name != "" && Town != "" && PhoneNumber != "___-___-___")
                    {
                        if (Donator.Name == Name && Donator.Town == Town && Donator.PhoneNumber == PhoneNumber)
                            DonatorList.Add(Donator);
                    }
                    else if (Name != "" && Town != "" && PhoneNumber == "___-___-___")
                    {
                        if (Donator.Name == Name && Donator.Town == Town)
                            DonatorList.Add(Donator);
                    }
                    else if (Name != "" && Town == "" && PhoneNumber != "___-___-___")
                    {
                        if (Donator.Name == Name && Donator.PhoneNumber == PhoneNumber)
                            DonatorList.Add(Donator);
                    }
                    else if (Name == "" && Town != "" && PhoneNumber != "___-___-___")
                    {
                        if (Donator.PhoneNumber == PhoneNumber && Donator.Town == Town)
                            DonatorList.Add(Donator);
                    }
                    else if (Name == "" && Town == "" && PhoneNumber != "___-___-___")
                    {
                        if (Donator.PhoneNumber == PhoneNumber)
                            DonatorList.Add(Donator);
                    }
                    else if (Name != "" && Town == "" && PhoneNumber == "___-___-___")
                    {
                        if (Donator.Name == Name)
                            DonatorList.Add(Donator);
                    }
                    else if (Name == "" && Town != "" && PhoneNumber == "___-___-___")
                    {
                        if (Donator.Town == Town)
                            DonatorList.Add(Donator);
                    }

                }
            }
            return DonatorList;
        }
コード例 #3
0
        private void Submit_btn_Click(object sender, RoutedEventArgs e)
        {
            if (Name_txb != null && Town_txb != null && PhoneNumber_txb.IsMaskFull)
            {
                Donator Donator = new Donator() { Name = Name_txb.Text,
                    BloodGroup = BloodGroup_cbb.Text,
                    RhFactor = RhFactor_cbb.Text,
                    Town = Town_txb.Text,
                    PhoneNumber = PhoneNumber_txb.Text };

                using (var ctx = new DonatorContext())
                {
                    ctx.Donators.Add(Donator);
                    ctx.SaveChanges();
                }

                Close();
                System.Windows.MessageBox.Show("Donator saved!");
            }
        }