private void tslAgregar_Click(object sender, EventArgs e) { frmFormasFarmaceuticasAE frm = new frmFormasFarmaceuticasAE(this); frm.Text = "Nueva Forma farmaceutica"; DialogResult dr = frm.ShowDialog(this); if (dr == DialogResult.OK) { try { FormaFarmaceutica formaFarmaceutica = frm.GetFormaFarmaceutica(); if (!_servicio.Existe(formaFarmaceutica)) { _servicio.Guardar(formaFarmaceutica); DataGridViewRow r = ConstruirFila(); SetearFila(r, formaFarmaceutica); AñadirFila(r); MessageBox.Show("Registro Agregado"); } else { MessageBox.Show("Forma farmaceutica repetida"); } } catch (Exception exception) { MessageBox.Show(exception.Message); } } }
private void btnAceptar_Click(object sender, System.EventArgs e) { if (ValidarDatos()) { if (formaFarmaceutica == null) { formaFarmaceutica = new FormaFarmaceutica(); } formaFarmaceutica.Descripcion = txtFormaFarmaceutica.Text; if (ValidarObjeto()) { if (!_esEdicion) { try { _servicio.Guardar(formaFarmaceutica); if (frm != null) { frm.AgregarFila(formaFarmaceutica); } MessageBox.Show("Registro Guardado", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult dr = MessageBox.Show("¿Desea dar de alta otro registro?", "Confirmar", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.No) { DialogResult = DialogResult.Cancel; } else { InicializarControles(); } } catch (Exception exception) { MessageBox.Show(exception.Message); } } else { DialogResult = DialogResult.OK; } } } }
private void tsbEditar_Click(object sender, EventArgs e) { if (dgvDatos.SelectedRows.Count > 0) { DataGridViewRow r = dgvDatos.SelectedRows[0]; FormaFarmaceutica forma = (FormaFarmaceutica)r.Tag; frmFormaFarmaceuticaAE frm = new frmFormaFarmaceuticaAE(); frm.Text = "Editar Tipo De Documento"; frm.SetFormaFarmaceutica(forma); DialogResult dr = frm.ShowDialog(this); if (dr == DialogResult.OK) { try { forma = frm.GetFormaFarmaceutica(); if (!servicio.Existe(forma)) { servicio.Guardar(forma); SetearFila(r, forma); MessageBox.Show("Forma Farmaceutica Editada", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Forma Farmaceutica Duplicada... Alta denegada", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception exception) { MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }