Exemple #1
0
    private bool SubmitData()
    {
        _user.CreationDate   = DateTime.Now;
        _user.LastUpdateDate = DateTime.Now;
        _user.Description    = txtDescription.Text.Trim();
        _user.Password       = _methods.EncryptPassword(txtPassword.Text.Trim());
        _user.Role           = rbtnPatient.Checked ? Roles.Patient : rbtnDoctor.Checked ? Roles.Doctor : rbtnPharmacist.Checked ? Roles.Pharmacist : Roles.Patient;
        _user.UserName       = txtEmail.Text.Trim();



        if (rbtnPatient.Checked == true)
        {
            _patient                 = new Patient();
            _patient.Address         = "";
            _patient.AlternativeNo   = "";
            _patient.Country         = "";
            _patient.CreationDate    = DateTime.Now;
            _patient.DateOfBirth     = DateTime.Now;
            _patient.Email           = txtEmail.Text;
            _patient.Ethnicity       = "1";
            _patient.FirstName       = txtFirstName.Text.Trim();
            _patient.LandLineNo      = "";
            _patient.LastName        = txtLastName.Text.Trim();
            _patient.LastUpdatedDate = DateTime.Now;
            _patient.MiddleName      = "";
            _patient.MobileNo        = "";
            _patient.Gender          = chkMale.Checked == true ? Gender.Male : chkFemale.Checked == true ? Gender.Female : Gender.Male;
        }
        else if (rbtnDoctor.Checked == true)
        {
            _doctor.Address         = "";
            _doctor.AlternativeNo   = "";
            _doctor.Country         = "";
            _doctor.Email           = txtEmail.Text.Trim();
            _doctor.FirstName       = txtFirstName.Text.Trim();
            _doctor.LandLineNo      = "";
            _doctor.LastName        = txtLastName.Text.Trim();
            _doctor.LastUpdatedDate = DateTime.Now;
            _doctor.MiddleName      = "";
            _doctor.MobileNo        = "";
            _doctor.Qualifications  = "";
            _doctor.Speciality      = "";
            _doctor.Gender          = chkMale.Checked == true ? Gender.Male : chkFemale.Checked == true ? Gender.Female : Gender.Male;
        }
        else if (rbtnPharmacist.Checked == true)
        {
            _pharmacist.Address      = "";
            _pharmacist.Country      = "";
            _pharmacist.Email        = txtEmail.Text.Trim();
            _pharmacist.FirstName    = txtFirstName.Text.Trim();
            _pharmacist.LandLineNo   = "";
            _pharmacist.LastName     = txtLastName.Text.Trim();
            _pharmacist.MobileNo     = "";
            _pharmacist.PharmacyName = txtFirstName.Text.Trim() + "'s Pharmacy";
            _pharmacist.Gender       = chkMale.Checked == true ? Gender.Male : chkFemale.Checked == true ? Gender.Female : Gender.Male;
        }

        try
        {
            work.GenericUserRepo.Insert(_user);
            work.Save();
            if (rbtnPatient.Checked == true)
            {
                _patient.UserId = _user.Id;
                work.GenericPatientRepo.Insert(_patient);
                work.Save();
            }
            else if (rbtnDoctor.Checked == true)
            {
                _doctor.UserId = _user.Id;
                work.GenericDoctorRepo.Insert(_doctor);
                work.Save();
            }
            else if (rbtnPharmacist.Checked == true)
            {
                _pharmacist.UserId = _user.Id;
                work.GenericPharmacistRepo.Insert(_pharmacist);
                work.Save();
            }
            return(true);
        }
        catch (Exception ex)
        {
            return(false);
        }
    }