private void funcAddGadget(Window window)
 {
     if (!string.IsNullOrWhiteSpace(newGadget.Name) && !string.IsNullOrWhiteSpace(newGadget.Manufacturer) && newGadget.Price > 0)
     {
         var gadget = new Gadget(newGadget.Name)
         {
             Manufacturer = newGadget.Manufacturer, Price = newGadget.Price, Condition = newGadget.Condition
         };
         if (!service.AddGadget(gadget))
         {
             // Error Output
             MessageBox.Show($"{gadget} konnte nicht hinzugefügt werden...");
             Console.WriteLine($"{gadget} konnte nicht hinzugefügt werden...");
         }
         else
         {
             window.Close();
         }
     }
     else
     {
         // Do nothing
         MessageBox.Show("Bitte alle Felder ausfüllen.");
         Console.WriteLine("Bitte alle Felder ausfüllen.");
     }
 }
示例#2
0
        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();
        }
示例#3
0
        private void addNewGadget_Click(object sender, RoutedEventArgs e)
        {
            var newGadget = new Gadget("");
            var dialog    = new GadgetDialog(newGadget);

            dialog.Title           = "Neues Gadget";
            dialog.ActionText.Text = "Gadget erstellen";
            if (dialog.ShowDialog() == false)
            {
                return;
            }
            _service.AddGadget(newGadget);
            LoadData();
            DgGadgets.SelectedItem = newGadget;
        }
示例#4
0
        public void AddGadget()
        {
            Gadget gadget = new Gadget();
            NewEditGadgetWindow singleGadgetWindow = new NewEditGadgetWindow(gadget);

            if (singleGadgetWindow.ShowDialog() == true)
            {
                if (_service.AddGadget(gadget))
                {
                    LoadServerData();
                }
                else
                {
                    throw new Exception("Add Gadget Failed!");
                }
            }
        }
示例#5
0
        private void addNewGadget_onClick(object sender, RoutedEventArgs e)
        {
            Gadgets.Add(new Gadget
            {
                InventoryNumber = "100",
                Name            = "TestName",
                Manufacturer    = "TestManufacturer",
                Price           = 12.00,
                Condition       = Condition.New
            });

            DgGadgets.SelectedIndex = Gadgets.Count - 1;
            DgGadgets.CurrentColumn = DgGadgets.Columns[0];
            DgGadgets.BeginEdit();
            // DgGadgets.Focus();
            _service.AddGadget(SelectedGadget);
        }
示例#6
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Gadget gadget = new Gadget(name.Text.ToString());
            double isDouble;

            double.TryParse(price.Text.ToString(), out isDouble);
            gadget.Price        = isDouble;
            gadget.Manufacturer = manufacturer.Text.ToString();
            LibraryAdminService service = new LibraryAdminService(ConfigurationSettings.AppSettings.Get("server"));

            if (service.AddGadget(gadget))
            {
                MessageBox.Show("Gadget successfully added!");
                this.Close();
            }
            else
            {
                MessageBox.Show("Operation failed!");
            }
        }
        private void OkButton_Click(object sender, RoutedEventArgs e)
        {
            if (EditedGadget.Name.Equals(""))
            {
                MessageBox.Show("Bitte Namen eingeben");
            }
            else if (EditedGadget.Manufacturer.Equals(""))
            {
                MessageBox.Show("Bitte Hersteller eingeben");
            }
            else
            {
                // Gadget zusammenstellen
                EditedGadget.Condition = (ch.hsr.wpf.gadgeothek.domain.Condition)Enum.Parse(typeof(ch.hsr.wpf.gadgeothek.domain.Condition), GadgetCondition.Text);

                // Hier wird Gadget eingefügt
                lib.AddGadget(EditedGadget);
                DialogResult = true;
            }
        }
示例#8
0
        /// <summary>
        /// demonstrates the use of the admin functions to add/remove
        /// new objects to/from the gadgeothek
        /// </summary>
        public void ShowAdminInteraction()
        {
            var service = new LibraryAdminService(ServerUrl);

            var gadget = new Gadget("XBOX360")
            {
                Manufacturer = "Microsoft"
            };

            if (!service.AddGadget(gadget))
            {
                Console.WriteLine($"{gadget} konnte nicht hinzugefügt werden...");
                return;
            }

            var gadgets = service.GetAllGadgets();

            PrintAll(gadgets, "Gadgets (NEW)");

            gadget.Condition = Condition.Damaged;
            if (!service.UpdateGadget(gadget))
            {
                Console.WriteLine($"{gadget} konnte nicht aktualisiert werden...");
                return;
            }


            gadgets = service.GetAllGadgets();
            PrintAll(gadgets, "Gadgets (NEW 2)");

            if (!service.DeleteGadget(gadget))
            {
                Console.WriteLine($"{gadget} konnte nicht gelöscht werden...");
                return;
            }

            gadgets = service.GetAllGadgets();
            PrintAll(gadgets, "Gadgets (NEW 3)");
        }
        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();
            }
        }
示例#10
0
 public bool AddGadget(Gadget gadget)
 {
     return(Service.AddGadget(gadget));
 }
示例#11
0
 public void addGadget(Gadget gadget)
 {
     gadget = SelectedGadget;
     AllGadgets.Add(gadget);
     service.AddGadget(gadget);
 }
示例#12
0
 private void Save()
 {
     libraryAdminService.AddGadget(SelectedGadget);
     GadgetNotSaved = false;
 }