private void btnSave_Click(object sender, RoutedEventArgs e) { String ServerUrl = "http://localhost:8080"; var service = new LibraryAdminService(ServerUrl); // Create Gadget String value = this.tbPrice.Text; Double result = 0; try { result = Convert.ToDouble(value); } catch (FormatException) { Console.WriteLine("Unable to convert '{0}' to a Double.", value); } catch (OverflowException) { Console.WriteLine("'{0}' is outside the range of a Double.", value); } ch.hsr.wpf.gadgeothek.domain.Condition condition = new ch.hsr.wpf.gadgeothek.domain.Condition(); switch (cbCondition.Text.ToUpper()) { case "NEW": condition = ch.hsr.wpf.gadgeothek.domain.Condition.New; break; case "GOOD": condition = ch.hsr.wpf.gadgeothek.domain.Condition.Good; break; case "DAMAGED": condition = ch.hsr.wpf.gadgeothek.domain.Condition.Damaged; break; case "WASTE": condition = ch.hsr.wpf.gadgeothek.domain.Condition.Waste; break; case "LOST": condition = ch.hsr.wpf.gadgeothek.domain.Condition.Lost; break; default: condition = ch.hsr.wpf.gadgeothek.domain.Condition.New; break; } Gadget newGadget = new Gadget(); string invetoryNr = "0"; if (!this.tbID.Text.Equals("")) { invetoryNr = this.tbID.Text; } newGadget.InventoryNumber = invetoryNr; newGadget.Name = this.tbName.Text; newGadget.Manufacturer = this.tbManufacturer.Text; newGadget.Price = result; newGadget.Condition = condition; service.UpdateGadget(newGadget); this.DialogResult = true; }
private void btnSave_Click(object sender, RoutedEventArgs e) { String value = this.tbPrice.Text; Double result = 0.0; try { result = Convert.ToDouble(value); } catch (FormatException) { Console.WriteLine("Unable to convert '{0}' to a Double.", value); } catch (OverflowException) { Console.WriteLine("'{0}' is outside the range of a Double.", value); } ch.hsr.wpf.gadgeothek.domain.Condition condition = new ch.hsr.wpf.gadgeothek.domain.Condition(); switch (cbCondition.Text.ToUpper()) { case "NEW": condition = ch.hsr.wpf.gadgeothek.domain.Condition.New; break; case "GOOD": condition = ch.hsr.wpf.gadgeothek.domain.Condition.Good; break; case "DAMAGED": condition = ch.hsr.wpf.gadgeothek.domain.Condition.Damaged; break; case "WASTE": condition = ch.hsr.wpf.gadgeothek.domain.Condition.Waste; break; case "LOST": condition = ch.hsr.wpf.gadgeothek.domain.Condition.Lost; break; default: condition = ch.hsr.wpf.gadgeothek.domain.Condition.New; break; } Gadget newGadget = new Gadget(); newGadget.InventoryNumber = findInventoryNumber(); newGadget.Name = this.tbName.Text; newGadget.Manufacturer = this.tbManufacturer.Text; newGadget.Price = result; newGadget.Condition = condition; service.AddGadget(newGadget); this.DialogResult = true; this.Close(); }
private void Button_Gadget_Create(object sender, RoutedEventArgs e) { string name = Text_Name.Text; string manufacturer = Text_Manufacturer.Text; double price = System.Convert.ToDouble(Text_Price.Text); ch.hsr.wpf.gadgeothek.domain.Condition condition = (ch.hsr.wpf.gadgeothek.domain.Condition)System.Enum.Parse(typeof(ch.hsr.wpf.gadgeothek.domain.Condition), ((ComboBoxItem)Combo_Condition.SelectedItem).Content.ToString()); var url = ConfigurationManager.AppSettings["server"]; var service = new LibraryAdminService(url); myGadget = new Gadget(name); myGadget.Condition = condition; myGadget.Manufacturer = manufacturer; myGadget.Price = price; if (service.AddGadget(myGadget)) { System.Console.WriteLine("Add Gadget " + myGadget.ToString() + " done"); this.Close(); } }