Exemplo n.º 1
0
        public int Delete(tblRegisterAdult tblRegisterAdult)
        {
            int __rowsAffected = 0;

            // Create command
            using (SqlCommand sqlCommand = new SqlCommand("tblRegisterAdultDelete"))
            {
                // Set command type
                sqlCommand.CommandType = CommandType.StoredProcedure;

                try
                {
                    // Attach command
                    AttachCommand(sqlCommand);

                    // Add command parameters
                    SqlParameter vid = new SqlParameter("@id", SqlDbType.BigInt);
                    vid.Direction = ParameterDirection.Input;
                    sqlCommand.Parameters.Add(vid);

                    // Set input parameter values
                    SqlServerHelper.SetParameterValue(vid, tblRegisterAdult.id);

                    // Execute command
                    __rowsAffected = sqlCommand.ExecuteNonQuery();
                }
                finally
                {
                    // Detach command
                    DetachCommand(sqlCommand);
                }
            }

            return(__rowsAffected);
        }
Exemplo n.º 2
0
        public virtual void Clone(tblRegisterAdult sourceObject)
        {
            if (sourceObject == null)
            {
                throw new ArgumentNullException("sourceObject");
            }

            // Clone attributes from source object
            this._id                   = sourceObject.id;
            this._dateOfBirth          = sourceObject.dateOfBirth;
            this._employmentStatusId   = sourceObject.employmentStatusId;
            this._employmentDurationId = sourceObject.employmentDurationId;
            this._educationalLevelId   = sourceObject.educationalLevelId;
            this._populationId         = sourceObject.populationId;
            this._cityId               = sourceObject.cityId;
            this._municipality         = sourceObject.municipality;
            this._userId               = sourceObject.userId;
        }
Exemplo n.º 3
0
        public int Insert(tblRegisterAdult tblRegisterAdult)
        {
            int __rowsAffected = 0;

            // Create command
            using (SqlCommand sqlCommand = new SqlCommand("tblRegisterAdultInsert"))
            {
                // Set command type
                sqlCommand.CommandType = CommandType.StoredProcedure;

                // Add command parameters
                SqlParameter vid = new SqlParameter("@id", SqlDbType.BigInt);
                vid.Direction = ParameterDirection.InputOutput;
                sqlCommand.Parameters.Add(vid);
                SqlParameter vdateOfBirth = new SqlParameter("@dateOfBirth", SqlDbType.DateTime);
                vdateOfBirth.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vdateOfBirth);
                SqlParameter vemploymentStatusId = new SqlParameter("@employmentStatusId", SqlDbType.BigInt);
                vemploymentStatusId.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vemploymentStatusId);
                SqlParameter vemploymentDurationId = new SqlParameter("@employmentDurationId", SqlDbType.BigInt);
                vemploymentDurationId.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vemploymentDurationId);
                SqlParameter veducationalLevelId = new SqlParameter("@educationalLevelId", SqlDbType.BigInt);
                veducationalLevelId.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(veducationalLevelId);
                SqlParameter vpopulationId = new SqlParameter("@populationId", SqlDbType.BigInt);
                vpopulationId.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vpopulationId);
                SqlParameter vcityId = new SqlParameter("@cityId", SqlDbType.BigInt);
                vcityId.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vcityId);
                SqlParameter vmunicipality = new SqlParameter("@municipality", SqlDbType.NVarChar, 255);
                vmunicipality.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vmunicipality);
                SqlParameter vuserId = new SqlParameter("@userId", SqlDbType.BigInt);
                vuserId.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vuserId);

                // Set input parameter values
                SqlServerHelper.SetParameterValue(
                    vid,
                    tblRegisterAdult.id,
                    0);
                SqlServerHelper.SetParameterValue(vdateOfBirth, tblRegisterAdult.dateOfBirth);
                SqlServerHelper.SetParameterValue(vemploymentStatusId, tblRegisterAdult.employmentStatusId);
                SqlServerHelper.SetParameterValue(vemploymentDurationId, tblRegisterAdult.employmentDurationId);
                SqlServerHelper.SetParameterValue(veducationalLevelId, tblRegisterAdult.educationalLevelId);
                SqlServerHelper.SetParameterValue(vpopulationId, tblRegisterAdult.populationId);
                SqlServerHelper.SetParameterValue(vcityId, tblRegisterAdult.cityId);
                SqlServerHelper.SetParameterValue(vmunicipality, tblRegisterAdult.municipality);
                SqlServerHelper.SetParameterValue(vuserId, tblRegisterAdult.userId);

                try
                {
                    // Attach command
                    AttachCommand(sqlCommand);

                    // Execute command
                    __rowsAffected = sqlCommand.ExecuteNonQuery();
                    if (__rowsAffected == 0)
                    {
                        return(__rowsAffected);
                    }


                    // Get output parameter values
                    tblRegisterAdult.id = SqlServerHelper.ToInt64(vid);
                }
                finally
                {
                    // Detach command
                    DetachCommand(sqlCommand);
                }
            }

            return(__rowsAffected);
        }
Exemplo n.º 4
0
        public int Retrieve(tblRegisterAdult tblRegisterAdult)
        {
            int __rowsAffected = 1;

            // Create command
            using (SqlCommand sqlCommand = new SqlCommand("tblRegisterAdultGet"))
            {
                // Set command type
                sqlCommand.CommandType = CommandType.StoredProcedure;

                try
                {
                    // Attach command
                    AttachCommand(sqlCommand);

                    // Add command parameters
                    SqlParameter vid = new SqlParameter("@id", SqlDbType.BigInt);
                    vid.Direction = ParameterDirection.InputOutput;
                    sqlCommand.Parameters.Add(vid);
                    SqlParameter vdateOfBirth = new SqlParameter("@dateOfBirth", SqlDbType.DateTime);
                    vdateOfBirth.Direction = ParameterDirection.Output;
                    sqlCommand.Parameters.Add(vdateOfBirth);
                    SqlParameter vemploymentStatusId = new SqlParameter("@employmentStatusId", SqlDbType.BigInt);
                    vemploymentStatusId.Direction = ParameterDirection.Output;
                    sqlCommand.Parameters.Add(vemploymentStatusId);
                    SqlParameter vemploymentDurationId = new SqlParameter("@employmentDurationId", SqlDbType.BigInt);
                    vemploymentDurationId.Direction = ParameterDirection.Output;
                    sqlCommand.Parameters.Add(vemploymentDurationId);
                    SqlParameter veducationalLevelId = new SqlParameter("@educationalLevelId", SqlDbType.BigInt);
                    veducationalLevelId.Direction = ParameterDirection.Output;
                    sqlCommand.Parameters.Add(veducationalLevelId);
                    SqlParameter vpopulationId = new SqlParameter("@populationId", SqlDbType.BigInt);
                    vpopulationId.Direction = ParameterDirection.Output;
                    sqlCommand.Parameters.Add(vpopulationId);
                    SqlParameter vcityId = new SqlParameter("@cityId", SqlDbType.BigInt);
                    vcityId.Direction = ParameterDirection.Output;
                    sqlCommand.Parameters.Add(vcityId);
                    SqlParameter vmunicipality = new SqlParameter("@municipality", SqlDbType.NVarChar, 255);
                    vmunicipality.Direction = ParameterDirection.Output;
                    sqlCommand.Parameters.Add(vmunicipality);
                    SqlParameter vuserId = new SqlParameter("@userId", SqlDbType.BigInt);
                    vuserId.Direction = ParameterDirection.Output;
                    sqlCommand.Parameters.Add(vuserId);

                    // Set input parameter values
                    SqlServerHelper.SetParameterValue(vid, tblRegisterAdult.id);

                    // Execute command
                    sqlCommand.ExecuteNonQuery();

                    try
                    {
                        // Get output parameter values
                        tblRegisterAdult.id                   = SqlServerHelper.ToInt64(vid);
                        tblRegisterAdult.dateOfBirth          = SqlServerHelper.ToDateTime(vdateOfBirth);
                        tblRegisterAdult.employmentStatusId   = SqlServerHelper.ToInt64(vemploymentStatusId);
                        tblRegisterAdult.employmentDurationId = SqlServerHelper.ToNullableInt64(vemploymentDurationId);
                        tblRegisterAdult.educationalLevelId   = SqlServerHelper.ToInt64(veducationalLevelId);
                        tblRegisterAdult.populationId         = SqlServerHelper.ToInt64(vpopulationId);
                        tblRegisterAdult.cityId               = SqlServerHelper.ToInt64(vcityId);
                        tblRegisterAdult.municipality         = SqlServerHelper.ToString(vmunicipality);
                        tblRegisterAdult.userId               = SqlServerHelper.ToInt64(vuserId);
                    }
                    catch (Exception ex)
                    {
                        if (ex is System.NullReferenceException)
                        {
                            __rowsAffected = 0;
                        }
                        else
                        {
                            throw ex;
                        }
                    }
                }
                finally
                {
                    // Detach command
                    DetachCommand(sqlCommand);
                }
            }

            return(__rowsAffected);
        }