示例#1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtApellido.Text == "" || txtedad.Text == "" || txtCedula.Text == "" ||
                txtNombre.Text == "" || txtTel.Text == "")
            {
                Notification.Show("Los campos cedula, nombres, apellidos, telefono y edad son requeridos", AlertType.warm);
                return;
            }
            if (!UtilController.VerificarCedula(txtCedula.Text))
            {
                Notification.Show("La cedula especificada es invalida", AlertType.warm);
                return;
            }
            if (pc.exist(txtCedula.Text))
            {
                Notification.Show("Ya existe un registro con esta cedula", AlertType.info);
                return;
            }
            Persona per = new Persona();

            per.nombre    = txtNombre.Text;
            per.apellido  = txtApellido.Text;
            per.edad      = int.Parse(txtedad.Text);
            per.email     = txtEmail.Text;
            per.telefono  = txtTel.Text;
            per.dni       = txtCedula.Text;
            per.direccion = txtDireccion.Text;
            per.status    = 1;
            per.tipo      = 3; // paciente
            string validate = pc.validate(per);

            if (validate == "")
            {
                pc.store(per);
                _clearRegisterInputs();
                Notification.Show("Los datos fueron registrados con exito", AlertType.ok);
            }
            else
            {
                Notification.Show(validate, AlertType.warm);
            }
        }
示例#2
0
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            if (txtNombreDoc.Text == "" && id_medic <= 0)
            {
                Notification.Show("Necesitas especificar un médico, usa el botón buscar", AlertType.warm);
                return;
            }
            if (txtNombrePac.Text == "" || txtCedulaPac.Text == "" ||
                txtApellidosPac.Text == "" || txtTelPac.Text == "" ||
                txtEdadPac.Text == "")
            {
                Notification.Show("Todos los datos del paciente son requeridos, porfavor complete el formulario.", AlertType.warm);
                return;
            }
            if (txtCosto.Text == "")
            {
                Notification.Show("El valor a cobrar por la consulta es requerido", AlertType.ok);
                return;
            }
            if (txtFecha.Text == "")
            {
                Notification.Show("Necesitas especificar una fecha", AlertType.warm);
                return;
            }
            if (!UtilController.VerificarCedula(txtCedulaPac.Text))
            {
                Notification.Show("Cedula del paciente no valida.", AlertType.warm);
                return;
            }


            //Registro del Paciente en caso de no existir
            Persona p = new Persona();

            p.dni      = txtCedulaPac.Text;
            p.nombre   = txtNombrePac.Text;
            p.apellido = txtApellidosPac.Text;
            p.telefono = txtTelPac.Text;
            try
            {
                p.edad = int.Parse(txtEdadPac.Text);
                if (p.edad < 0)
                {
                    Notification.Show("La edad no puede ser menor a 0", AlertType.warm);
                    return;
                }
            }
            catch {
                Notification.Show("Asegurese de que la edad sea un valor valido", AlertType.warm);
                return;
            }
            p.tipo = 3;

            string valid = pc.validate(p);

            if (valid == "")
            {
                if (id_pacient == 0)
                {
                    pc.store(p);
                    id_pacient = Convert.ToInt32(p.id_person);
                }
                else
                {
                    pc.update(id_pacient, p);
                }
            }
            else
            {
                Notification.Show(valid, AlertType.warm);
                return;
            }

            // creando la cita
            Cita c = new Cita();

            c.id_medico = id_medic;
            c.id_person = id_pacient;
            c.fecha     = DateTime.Parse(txtFecha.Text);
            try
            {
                c.precio    = decimal.Parse(txtCosto.Text);
                c.retencion = decimal.Parse(txtRetencion.Text);

                if (c.precio < 0)
                {
                    Notification.Show("El precio de la consulta no puede ser menor a 0", AlertType.warm);
                    return;
                }
                if (c.retencion < 0 || c.retencion > 100)
                {
                    Notification.Show("La retención en un valor porcentual entre 0 y 100", AlertType.warm);
                    return;
                }
            }
            catch {
                Notification.Show("Asegurese de ingresar valores validos para precio y retención", AlertType.warm);
                return;
            }
            // 0 No pagada, 1 pagada, 2 atendida
            c.status = (txtPendientePAgo.Checked) ? 0 : 1;

            String validate = cc.validate(c);

            if (validate == "")
            {
                cc.store(c);
                _clearRegisterInputs();
                Notification.Show("La cita se guardo con exito como : " + ((c.status == 1) ? "PAGADA" : "PENDIENTE DE PAGO"), AlertType.ok);
            }
            else
            {
                Notification.Show(validate, AlertType.warm);
            }
            // save
        }