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(); } }
private void btnInsertar_Click(object sender, EventArgs e) { string tipoPago = ""; string tipoServicio = ""; string tipoDocumento = ""; string[] vendedor = new string[2]; vendedor = txtVendedor.Text.Split(" ".ToCharArray()); string[] cliente = new string[2]; cliente = txtCliente.Text.Split(" ".ToCharArray()); for (int i = 0; i <= listaTipoPagoVal.Count - 1; i++) { if (listaTipoPagoVal[i] == cmbTipoPago.Text) { tipoPago = listaTipoPagoKey[i].ToString(); break; } } if (rbtnDocumento.Checked == true) { for (int i = 0; i <= listaServicioDocumentoVal.Count - 1; i++) { if (listaServicioDocumentoVal[i] == cmbTipoDocumento.Text) { tipoDocumento = listaServicioDocumentoKey[i].ToString(); break; } } regMovCaja = new CRegMovCaja(vendedor[0], cliente[0], tipoPago, mtxtFecha.Text, decimal.Parse(mtxtMonto.Text.Replace(",", "").Replace("RD$", "")), cmbEstado.Text, tipoDocumento); } else { for (int i = 0; i <= listaServicioDocumentoVal.Count - 1; i++) { if (listaServicioDocumentoVal[i] == cmbTipoServicio.Text) { tipoServicio = listaServicioDocumentoKey[i].ToString(); break; } } regMovCaja = new CRegMovCaja(vendedor[0], cliente[0], tipoServicio, tipoPago, mtxtFecha.Text, decimal.Parse(mtxtMonto.Text.Replace(",", "").Replace("RD$", "")), cmbEstado.Text); } regMovCaja.Insertar(); dataGridView1.DataSource = CRegMovCaja.Visualizar(); limpiar(); }
private void dataGridView1_Click(object sender, EventArgs e) { dataGridView1.DataSource = dataGridView1.Rows.Count < 1 ? CRegMovCaja.Visualizar() : dataGridView1.DataSource; }
private void btnBuscar_Click(object sender, EventArgs e) { dataGridView1.DataSource = CRegMovCaja.Visualizar($"SELECT * FROM VISTA_REG_MOV_CAJA WHERE {cmbCampo.Text} {cmbCriterio.Text} '{txtValor.Text.SQLInyectionClearString()}'"); }