private void DataListado_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == dataListado.Columns["Eliminar"].Index) { DialogResult Opcion; Opcion = MessageBox.Show("Realmente desea Eliminar El Registro", "Sistema de Ventas", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (Opcion == DialogResult.OK) { string Codigo; string Rpta = ""; Codigo = Convert.ToString(this.dataListado.CurrentRow.Cells["tratamientoID"].Value); ETratamiento Obj = new ETratamiento(); Obj.tratamientoID = Convert.ToInt32(Codigo); Rpta = Convert.ToString(NTratamiento.delete(Obj)); if (Rpta.Equals("OK")) { this.MensajeOk("Se ELimino Correctamente el Registro"); } else { this.MensajeError(Rpta); } this.MostrarDB(); } } else { if (e.ColumnIndex == dataListado.Columns["Editar"].Index) { this.LimpiarImgError(); this.txtId.Text = Convert.ToString(this.dataListado.CurrentRow.Cells["tratamientoID"].Value); this.txtNombre.Text = Convert.ToString(this.dataListado.CurrentRow.Cells["nombre"].Value); this.txtColor.Text = Convert.ToString(this.dataListado.CurrentRow.Cells["color"].Value); string tipo = Convert.ToString(this.dataListado.CurrentRow.Cells["tipo"].Value); if (tipo == "Diagnostico") { this.rbDiagnostico.Checked = true; } else { this.rbProcedimiento.Checked = true; } this.txtPrecio.Text = Convert.ToString(this.dataListado.CurrentRow.Cells["precio"].Value); this.OcultarPRegistro(false, false); this.lbModificar.Visible = true; this.lbAgregar.Visible = false; } } }
private void MostrarDB() { this.dataListado.DataSource = NTratamiento.mostrar(this.txtBuscar.Text, siguientePag); /// this.dataListado.AutoResizeRows(); this.ordenarColumnas(); this.dataListado.AutoResizeColumns(); int dataTotal = NTratamiento.mostrarTotal(this.txtBuscar.Text) / 10; if (dataTotal == 0) { this.btnIncio.Enabled = false; this.btnAtras.Enabled = false; this.btnFin.Enabled = false; this.btnSiguiente.Enabled = false; } else { if (dataTotal == siguientePag) { this.btnIncio.Enabled = true; this.btnAtras.Enabled = true; this.btnFin.Enabled = false; this.btnSiguiente.Enabled = false; } else { if (Convert.ToInt32(this.siguientePag) > 0) { this.btnAtras.Enabled = true; this.btnIncio.Enabled = true; this.btnFin.Enabled = true; this.btnSiguiente.Enabled = true; } else { this.btnIncio.Enabled = false; this.btnAtras.Enabled = false; this.btnFin.Enabled = true; this.btnSiguiente.Enabled = true; } } } lblTotal.Text = "Total de Registros: " + Convert.ToString(dataListado.Rows.Count); }
private void BtnActualizar_Click(object sender, EventArgs e) { try { if (this.validacionImgError()) { this.convertir(); ETratamiento Obj = new ETratamiento(); Obj.tratamientoID = Convert.ToInt32(this.txtId.Text); Obj.nombre = this.txtNombre.Text.Trim(); Obj.color = this.txtColor.Text.Trim(); if (rbDiagnostico.Checked == true) { Obj.tipo = "DIAGNOSTICO"; } else { Obj.tipo = "PROCEDIMIENTO"; } Obj.precio = Convert.ToDecimal(this.txtPrecio.Text); NTratamiento.update(Obj); this.MostrarDB(); this.LimpiarPRegistro(); } else { throw new Exception("Datos Obligatorios"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Sistema Odontograma"); } }
private void BtnFin_Click(object sender, EventArgs e) { this.siguientePag = NTratamiento.mostrarTotal(this.txtBuscar.Text) / 10; this.MostrarDB(); }