示例#1
0
        private void SaveMotherboard_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                MotherboardProperties motherboardProperties = new MotherboardProperties()
                {
                    MotherboardType    = (MotherboardTypes)Enum.Parse(typeof(MotherboardTypes), MotherboardType.SelectedItem.ToString()),
                    Socket             = (Sockets)Enum.Parse(typeof(Sockets), MotherboardCPUSocket.SelectedItem.ToString()),
                    MultiCoreProcessor = MotherboardMultiCoreProcessor.IsChecked.Value,
                    Chipset            = MotherboardChipset.Text,
                    BIOS             = (MotherboardBIOS)Enum.Parse(typeof(MotherboardBIOS), MotherboardBIOS.SelectedItem.ToString()),
                    EFI              = MotherboardEFI.IsChecked.Value,
                    RamType          = (RAMTypes)Enum.Parse(typeof(RAMTypes), MotherboardRamType.SelectedItem.ToString()),
                    RAMSlots         = Convert.ToInt32(MotherboardRAMSlots.Text),
                    MinFrequency     = Convert.ToInt32(MotherboardRamMinFrequency.Text),
                    MaxFrequency     = Convert.ToInt32(MotherboardRamMaxFrequency.Text),
                    RAMVolume        = Convert.ToInt32(MotherboardRAMVolume.Text),
                    IDE              = Convert.ToInt32(MotherboardIDE.Text),
                    PCI              = Convert.ToInt32(MotherboardPCI.Text),
                    PCI_Ex1          = Convert.ToInt32(MotherboardPCI_Ex1.Text),
                    PCI_Ex4          = Convert.ToInt32(MotherboardPCI_Ex4.Text),
                    PCI_Ex8          = Convert.ToInt32(MotherboardPCI_Ex8.Text),
                    PCI_Ex16         = Convert.ToInt32(MotherboardPCI_Ex16.Text),
                    PCIE2_0          = MotherboardPCIE2_0.IsChecked.Value,
                    PCIE3_0          = MotherboardPCIE3_0.IsChecked.Value,
                    EmbeddedGraphics = MotherboardEmbeddedGraphics.IsChecked.Value,
                    Sound            = MotherboardSound.IsChecked.Value,
                    EthernetSpeed    = Convert.ToInt32(MotherboardEthernetSpeed.Text),
                    PS2Keyboard      = MotherboardPS2Keyboard.IsChecked.Value,
                    PS2Mouse         = MotherboardPS2Mouse.IsChecked.Value,
                    USB2_0           = Convert.ToInt32(MotherboardUSB2_0.Text),
                    USB3_0           = Convert.ToInt32(MotherboardUSB3_0.Text),
                };

                for (int i = 0; CaseFormFactorMotherboard.SelectedItems.Count > i; i++)
                {
                    motherboardProperties.VideoInterfaces.Add((VideoInterface)Enum.Parse(typeof(VideoInterface), MotherboardVideoInterfaces.SelectedItems[i].ToString()));
                }

                Motherboard motherboard = new Motherboard(0, MotherboardName.Text, "motherboard", Convert.ToInt32(MotherboardPrice.Text), MotherboardManufacturingDate.SelectedDate.Value, motherboardProperties);
                int         id          = InsertToDB(motherboard);
                motherboard.Uid = id;
                items.AllMotherboards.Add(motherboard);
                Motherboards.Items.Refresh();
                MessageBox.Show("Запись добавлена!");
            } catch {
                MessageBox.Show("Запись не была добавлена в базу, вероятно не заполнено одно или несколько полей, либо заполнены неверно.");
            }
        }
        private bool IsСompatibleInterface(Collection <ListBoxObject> collection, VideoCard videoСard, string problem_report)
        {
            bool isValid = false;

            MotherboardProperties motherboard = (GetSingleItem(collection, "motherboard") as Motherboard).Properties;

            switch (GetCount(collection, "video_card"))
            {
            case 0:
                if (videoСard.IsCompatibility(motherboard))
                {
                    isValid = true;
                }
                break;

            default:
            {
                for (int i = 0; i > collection.Where(m => m.Item.GetTypeValue() == "video_card").Count(); i++)
                {
                    VideoCard cVideoСard          = collection[i].IObject as VideoCard;
                    int       mon_videoInterfaces = cVideoСard.Compatibility(((GetSingleItem(collection, "motherboard") as Motherboard).Properties));
                    if (mon_videoInterfaces > 1)
                    {
                        if (cVideoСard.IsCompatibility(motherboard))
                        {
                            isValid = true; break;
                        }
                    }
                }
                break;
            }
            }

            if (!isValid)
            {
                ProblemReport(problem_report);
            }
            return(isValid);
        }