Beispiel #1
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (listViewKrovat.SelectedItems.Count == 1)
            {
                ProductSet product = listViewKrovat.SelectedItems[0].Tag as ProductSet;
                product.Type     = textBoxType.Text;
                product.Material = textBoxMaterial.Text;

                if (textBoxLength.Text != "")
                {
                    product.Length = Convert.ToDouble(textBoxLength.Text);
                }
                if (textBoxWidth.Text != "")
                {
                    product.Width = Convert.ToDouble(textBoxWidth.Text);
                }
                if (textBoxHeight.Text != "")
                {
                    product.Height = Convert.ToDouble(textBoxHeight.Text);
                }
                if (textBoxPrice.Text != "")
                {
                    product.Price = Convert.ToInt64(textBoxPrice.Text);
                }

                Program.furn.SaveChanges();
                ShowProduct();
            }
        }
Beispiel #2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            ProductSet product = new ProductSet();

            product.Type     = textBoxType.Text;
            product.Material = textBoxMaterial.Text;
            if (textBoxLength.Text != "")
            {
                product.Length = Convert.ToDouble(textBoxLength.Text);
            }
            if (textBoxWidth.Text != "")
            {
                product.Width = Convert.ToDouble(textBoxWidth.Text);
            }
            if (textBoxHeight.Text != "")
            {
                product.Height = Convert.ToDouble(textBoxHeight.Text);
            }
            if (textBoxPrice.Text != "")
            {
                product.Price = Convert.ToInt64(textBoxPrice.Text);
            }
            Program.furn.ProductSet.Add(product);
            Program.furn.SaveChanges();
            ShowProduct();
        }
Beispiel #3
0
        private void listViewKrovat_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewKrovat.SelectedItems.Count == 1)
            {
                ProductSet product = listViewKrovat.SelectedItems[0].Tag as ProductSet;

                textBoxType.Text     = product.Type;
                textBoxMaterial.Text = product.Material;
                textBoxHeight.Text   = product.Height.ToString();
                textBoxWidth.Text    = product.Width.ToString();
                textBoxLength.Text   = product.Length.ToString();
                textBoxPrice.Text    = product.Price.ToString();
            }
            else
            {
                textBoxType.Text     = "";
                textBoxMaterial.Text = "";
                textBoxLength.Text   = "";
                textBoxWidth.Text    = "";
                textBoxHeight.Text   = "";
                textBoxPrice.Text    = "";
            }
        }
Beispiel #4
0
        private void buttonDel_Click(object sender, EventArgs e)
        {
            try
            {
                if (listViewKrovat.SelectedItems.Count == 1)
                {
                    ProductSet product = listViewKrovat.SelectedItems[0].Tag as ProductSet;
                    Program.furn.ProductSet.Remove(product);
                    Program.furn.SaveChanges();
                    ShowProduct();
                }

                textBoxType.Text     = "";
                textBoxMaterial.Text = "";
                textBoxLength.Text   = "";
                textBoxWidth.Text    = "";
                textBoxHeight.Text   = "";
                textBoxPrice.Text    = "";
            }
            catch
            {
                MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }