Exemple #1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            Producto producto = new Producto(textBox1.Text, Int32.Parse(textBox2.Text), float.Parse(textBox3.Text));

            Console.WriteLine(producto.ToString());
            DBConnection.ExectNonQuery("INSERT INTO productos (nombre,cantidad,precio,subtotal) VALUES ('" + textBox1.Text + "','" + Int32.Parse(textBox2.Text) + "','" + float.Parse(textBox3.Text) + "','" + Int32.Parse(textBox2.Text) * float.Parse(textBox3.Text) + "')");

            Form2 grid = new Form2();

            grid.Show();

            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
        }
Exemple #2
0
        private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            if (e.RowIndex == dataGridView1.NewRowIndex || e.RowIndex < 0)
            {
                return;
            }
            else if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                     e.RowIndex >= 0)
            {
                Console.WriteLine(senderGrid.CurrentRow.Cells["Id"].Value);
                DialogResult res = MessageBox.Show("Desea eliminar la fila?", "Advertencia", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

                if ((res == DialogResult.OK) || (res == DialogResult.Yes))
                {
                    DBConnection.ExectNonQuery("DELETE FROM productos WHERE id='" + senderGrid.CurrentRow.Cells["Id"].Value + "';");
                    senderGrid.Rows.RemoveAt(e.RowIndex);
                }
            }
        }