Пример #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (this.button2.Text == "Создать продукт")
            {
                AddProductForm apf = new AddProductForm();
                apf.ShowDialog();
                if (apf.DialogResult == DialogResult.OK)
                {
                    try {
                    this.productsTableAdapter1.Insert(apf.prod.name, apf.prod.type.ToString(), apf.prod.volume, apf.prod.ID);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                }
            }
            else {
                try {
                Product p = new Product();
                p.ID = 1;
                //p.name = this.productsTableAdapter1.getProductName((int)dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[3].Value);
                //p.volume = float.Parse((string)this.productsTableAdapter1.getVolume(p.ID,p.name));
                AddProductForm apf = new AddProductForm(p);
                apf.ShowDialog();
                    if (apf.DialogResult == DialogResult.OK)
                    {
                        this.productsTableAdapter1.Update(WPDS);

                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

            }
        }
Пример #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (this.button2.Text == "Создать продукт")
     {
         AddProductForm apf = new AddProductForm();
         apf.ShowDialog();
         if (apf.DialogResult == DialogResult.OK)
         {
             try {
                 this.productsTableAdapter1.Insert(apf.prod.name, apf.prod.type.ToString(), apf.prod.volume, apf.prod.ID);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
     }
     else
     {
         try {
             Product p = new Product();
             p.ID = 1;
             //p.name = this.productsTableAdapter1.getProductName((int)dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[3].Value);
             //p.volume = float.Parse((string)this.productsTableAdapter1.getVolume(p.ID,p.name));
             AddProductForm apf = new AddProductForm(p);
             apf.ShowDialog();
             if (apf.DialogResult == DialogResult.OK)
             {
                 this.productsTableAdapter1.Update(WPDS);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }