private void tsbNuevo_Click(object sender, EventArgs e) { frmFormaFarmaceuticaAE frm = new frmFormaFarmaceuticaAE(); frm.Text = "Agregar Forma Farmaceutica"; DialogResult dr = frm.ShowDialog(this); if (dr == DialogResult.OK) { try { FormaFarmaceutica forma = frm.GetFormaFarmaceutica(); if (!servicio.Existe(forma)) { servicio.Agregar(forma); var r = ConstruirFila(); SetearFila(r, forma); AgregarFila(r); MessageBox.Show("Forma farmaceutica agregada", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Forma farmaceutica repetida... Alta denegada", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception exception) { MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
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 bool ValidarObjeto() { var valido = true; errorProvider1.Clear(); if (_servicio.Existe(formaFarmaceutica)) { valido = false; errorProvider1.SetError(txtFormaFarmaceutica, "FormaFarmaceutica repetida"); } return(valido); }