Beispiel #1
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                MessageBox.Show("Seleccione un elemento para Eliminar", "Error al Eliminar");
            }

            else if (dataGridView1.SelectedRows.Count > 1)
            {
                MessageBox.Show("Seleccione solo un elemento por favor", "Error al Eliminar");
            }
            else
            {
                DataGridViewRow row = new DataGridViewRow();
                row = dataGridView1.SelectedRows[0];

                if (row.Cells[4].Value.ToString() == "")
                {
                    regMovCaja = new CRegMovCaja(int.Parse(row.Cells[0].Value.ToString()), row.Cells[1].Value.ToString(), row.Cells[2].Value.ToString(), row.Cells[6].Value.ToString(), row.Cells[7].Value.ToString(), decimal.Parse(row.Cells[8].Value.ToString()), row.Cells[9].Value.ToString(), row.Cells[5].Value.ToString());
                }

                else
                {
                    regMovCaja = new CRegMovCaja(int.Parse(row.Cells[0].Value.ToString()), row.Cells[1].Value.ToString(), row.Cells[2].Value.ToString(), row.Cells[4].Value.ToString(), row.Cells[6].Value.ToString(), row.Cells[7].Value.ToString(), decimal.Parse(row.Cells[8].Value.ToString()), row.Cells[9].Value.ToString());
                }

                regMovCaja.Eliminar();
                dataGridView1.DataSource = CRegMovCaja.Visualizar();
            }
        }