示例#1
0
        private void tbInserir_Click(object sender, System.EventArgs e)
        {
            try
            {
                var paciente = new Paciente();
                validationInsertUpdate(paciente);

                if (PacienteDao.Select(new List <Tuple <string, object, string> >()
                {
                    new Tuple <string, object, string>("CPF", paciente.CPF, "=")
                }).Count > 0)
                {
                    throw new Exception("Já existe paciente com o CPF informado");
                }

                PacienteDao.Insert(paciente);
                dgResultado.DataSource = null;
                Util.lstPacientes      = PacienteDao.Select(null);

                MessageBox.Show(this, "Paciente alterado com sucesso", "Paciente");

                dgResultado.DataSource = Util.lstPacientes;
                formOnEndTask();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
        private void agregarButton_Click(object sender, EventArgs e)
        {
            PacienteDao insertar  = new PacienteDao();
            bool        seInserto = insertar.Insert(nombreTB.Text, apellidoTB.Text, curpTB.Text, Convert.ToInt32(nssTB.Text), Convert.ToInt32(cpTB.Text), sexoCB.Text[0]);
            string      resultado;

            if (seInserto)
            {
                resultado = "Insertado correctamente";
            }
            else
            {
                resultado = "NSS o CURP ya existen";
            }
            nombreTB.Clear();
            apellidoTB.Clear(); curpTB.Clear();
            nssTB.Clear();
            cpTB.Clear();
            MessageBox.Show(resultado);
        }