private void SaveCase_Click(object sender, RoutedEventArgs e) { try { CaseProperties caseProperties = new CaseProperties { CaseType = (CaseTypes)Enum.Parse(typeof(CaseTypes), CaseType.SelectedItem.ToString()), CoolerHeight = Convert.ToInt32(CaseCoolerHeight.Text), VideocardLength = Convert.ToInt32(CaseVideocardLength.Text), Sections3_5 = Convert.ToInt32(CaseSections3_5.Text), Sections2_5 = Convert.ToInt32(CaseSections2_5.Text), ExpansionSlots = Convert.ToInt32(CaseExpansionSlots.Text), BuiltinFans = Convert.ToInt32(CaseBuiltinFans.Text), PlacesFans = Convert.ToInt32(CasePlacesFans.Text), LiquidCooling = CaseLiquidCooling.IsChecked.Value, USB2_0 = Convert.ToInt32(CaseUSB2_0.Text), USB3_0 = Convert.ToInt32(CaseUSB3_0.Text), HeadphoneJack = CaseHeadphoneJack.IsChecked.Value, MicrophoneJack = CaseMicrophoneJack.IsChecked.Value, }; for (int i = 0; CaseFormFactorMotherboard.SelectedItems.Count > i; i++) { caseProperties.FormFactor.Add((MotherboardTypes)Enum.Parse(typeof(MotherboardTypes), CaseFormFactorMotherboard.SelectedItems[i].ToString())); } for (int i = 0; CaseFormFactorPSU.SelectedItems.Count > i; i++) { caseProperties.FormFactorPSU.Add((PSUTypes)Enum.Parse(typeof(PSUTypes), CaseFormFactorPSU.SelectedItems[i].ToString())); } Case @case = new Case(0, CaseName.Text, "case", Convert.ToInt32(CasePrice.Text), CaseManufacturingDate.SelectedDate.Value, caseProperties); int id = InsertToDB(@case); @case.Uid = Convert.ToInt32(id); items.AllCases.Add(@case); Cases.Items.Refresh(); MessageBox.Show("Запись добавлена!"); } catch { MessageBox.Show("Запись не была добавлена в базу, вероятно не заполнено одно или несколько полей, либо заполнены неверно."); } }
/// <summary> /// Run a test for the current category methods. /// </summary> /// <param name="hVolume">The current volume pointer.</param> /// <param name="nOpType">The current operation type.</param> /// <returns></returns> public static void RunTest(IntPtr hVolume, XTensionActionSource nOpType) { HelperMethods.OutputMessage("CASE DETAILS TESTING MODULE", OutputMessageOptions.Level1 | OutputMessageOptions.Header); // XWF_GetCaseProp() test. HelperMethods.OutputMessage("GetCaseProp() Test", OutputMessageOptions.Level2 | OutputMessageOptions.Header); CaseProperties caseProps = HelperMethods.GetCaseProperties(); HelperMethods.OutputMessage("Case Title: " + caseProps.CaseTitle , OutputMessageOptions.Level3); HelperMethods.OutputMessage("Case Examiner: " + caseProps.CaseExaminer , OutputMessageOptions.Level3); HelperMethods.OutputMessage("Case File Path: " + caseProps.CaseFilePath, OutputMessageOptions.Level3); HelperMethods.OutputMessage("Case Directory: " + caseProps.CaseDirectory, OutputMessageOptions.Level3); HelperMethods.OutputMessage(""); }