Ejemplo n.º 1
0
        public CreateNewItemWindow(IControllerBase databaseController, bool isChange = false, int UID = -1)
        {
            this.databaseController = databaseController;
            this.isChange           = isChange;
            this.UID = UID;

            InitializeComponent();
            AddCategoriesToSelector();

            if (isChange)
            {
                MainLabel.Content = "Изменение товара";
                prevItemData      = databaseController.GetFullItemData(UID);
                CategoryComboBox.SelectedIndex = FindComboBoxIndexWithCategory(prevItemData.Category).Value;
                NameTextBox.Text        = prevItemData.Name;
                PriceTextBox.Text       = prevItemData.Price.ToString();
                DescriptionTextBox.Text = prevItemData.Description;
                for (var i = 0; i < CategoryParamsListBox.Items.Count; i++)
                {
                    ((TextBox)((Grid)CategoryParamsListBox.Items[i]).Children[1]).Text = prevItemData.Params[i];
                }
            }
        }