Example #1
0
 //МЕТОДЫ КЛАССА
 //+-------------------------------------------------------------------+
 /// <summary>
 /// Создание формы для редактирования информации о товаре
 /// </summary>
 /// <returns>объект класса DialogResult</returns>
 private DialogResult FormCreateAndEditInitialization()
 {
     if(this.formCreateAndEdit != null)
     {
         this.formCreateAndEdit.Close();
         this.formCreateAndEdit.Dispose();
         this.formCreateAndEdit = null;
     }
     else
     {
         this.formCreateAndEdit = new FormCreateAndEdit(this.categories,
             this.assortment, this.selectedProduct);
         this.formCreateAndEdit.Owner = this;
     }
     return this.formCreateAndEdit.ShowDialog(this);
 }
Example #2
0
        /// <summary>
        /// Обработка нажатия кнопки "Создать". Добавляет информацию о 
        /// новом товаре в ассортимент товаров.
        /// </summary>
        private void ButtonCreate(Object sender, EventArgs e)
        {
            this.formCreateAndEdit = new FormCreateAndEdit(this.categories, this.assortment);
            this.formCreateAndEdit.Owner = this;
            this.formCreateAndEdit.StartPosition = FormStartPosition.CenterParent;
            this.formCreateAndEdit.ShowDialog(this);

            if (this.formCreateAndEdit.DialogResult == DialogResult.OK)
            {
                this.selectedProduct = this.formCreateAndEdit.SelectedProduct;
                this.assortment = this.formCreateAndEdit.Assortment;
                this.categories = this.formCreateAndEdit.Categoties;

                this.comboBoxProducts.Items.Clear();
                this.ComboBoxProductsInitialization();
                this.comboBoxProducts.SelectedItem = this.selectedProduct.Name;
                this.textBoxPrice.Text = this.selectedProduct.Price.ToString();
            }
            if (this.formCreateAndEdit != null)
            {
                this.formCreateAndEdit.Close();
                this.formCreateAndEdit.Dispose();
                this.formCreateAndEdit = null;
            }
        }
Example #3
0
        /// <summary>
        /// Обработка нажатия кнопки "Редактировать". Создает окно
        /// предоставляющее возможность редактировать информацию о выбранном
        /// товаре.
        /// </summary>
        private void ButtonEditClick(Object sender, EventArgs e)
        {
            if(this.selectedProduct == null )
            {
                MessageBox.Show(
                    text: "Операция редактирования " +
                    "не может быть выполнена. Не выбрано имя товара, " +
                    "информацию о котором необходимо отредактировать. " +
                    "Выберите имя товара и повторите попытку.",
                    caption: "Уведомление",
                    buttons: MessageBoxButtons.OK,
                    icon: MessageBoxIcon.Exclamation);
            }
            else
            {
                this.FormCreateAndEditInitialization();
                if (this.formCreateAndEdit.DialogResult == DialogResult.OK)
                {
                    this.selectedProduct = this.formCreateAndEdit.SelectedProduct;
                    this.assortment = this.formCreateAndEdit.Assortment;
                    this.categories = this.formCreateAndEdit.Categoties;

                    this.comboBoxProducts.Items.Clear();
                    this.ComboBoxProductsInitialization();
                    this.comboBoxProducts.SelectedItem = this.selectedProduct.Name;
                    this.textBoxPrice.Text = this.selectedProduct.Price.ToString();
                    this.textBoxTotalPrice.Text = "0.00";
                    totalOrderPrice = 0.00;
                    this.listBoxOrderInfo.Items.Clear();
                }
                if (this.formCreateAndEdit != null)
                {
                    this.formCreateAndEdit.Close();
                    this.formCreateAndEdit.Dispose();
                    this.formCreateAndEdit = null;
                }
            }
        }