示例#1
0
        public int Delete(tblRegisterStudent tblRegisterStudent)
        {
            int __rowsAffected = 0;

            // Create command
            using (SqlCommand sqlCommand = new SqlCommand("tblRegisterStudentDelete"))
            {
                // 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, tblRegisterStudent.id);

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

            return(__rowsAffected);
        }
示例#2
0
        public virtual void Clone(tblRegisterStudent sourceObject)
        {
            if (sourceObject == null)
            {
                throw new ArgumentNullException("sourceObject");
            }

            // Clone attributes from source object
            this._id                 = sourceObject.id;
            this._dateOfBirth        = sourceObject.dateOfBirth;
            this._populationId       = sourceObject.populationId;
            this._cityId             = sourceObject.cityId;
            this._municipality       = sourceObject.municipality;
            this._email              = sourceObject.email;
            this._educationalGradeId = sourceObject.educationalGradeId;
            this._orientationGroupId = sourceObject.orientationGroupId;
            this._coachingSchool     = sourceObject.coachingSchool;
            this._privateLessons     = sourceObject.privateLessons;
            this._userId             = sourceObject.userId;
        }
示例#3
0
        public int Insert(tblRegisterStudent tblRegisterStudent)
        {
            int __rowsAffected = 0;

            // Create command
            using (SqlCommand sqlCommand = new SqlCommand("tblRegisterStudentInsert"))
            {
                // 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 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 vemail = new SqlParameter("@email", SqlDbType.NVarChar, 255);
                vemail.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vemail);
                SqlParameter veducationalGradeId = new SqlParameter("@educationalGradeId", SqlDbType.BigInt);
                veducationalGradeId.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(veducationalGradeId);
                SqlParameter vorientationGroupId = new SqlParameter("@orientationGroupId", SqlDbType.BigInt);
                vorientationGroupId.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vorientationGroupId);
                SqlParameter vcoachingSchool = new SqlParameter("@coachingSchool", SqlDbType.NVarChar, 255);
                vcoachingSchool.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vcoachingSchool);
                SqlParameter vprivateLessons = new SqlParameter("@privateLessons", SqlDbType.Bit);
                vprivateLessons.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vprivateLessons);
                SqlParameter vuserId = new SqlParameter("@userId", SqlDbType.BigInt);
                vuserId.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vuserId);

                // Set input parameter values
                SqlServerHelper.SetParameterValue(
                    vid,
                    tblRegisterStudent.id,
                    0);
                SqlServerHelper.SetParameterValue(vdateOfBirth, tblRegisterStudent.dateOfBirth);
                SqlServerHelper.SetParameterValue(vpopulationId, tblRegisterStudent.populationId);
                SqlServerHelper.SetParameterValue(vcityId, tblRegisterStudent.cityId);
                SqlServerHelper.SetParameterValue(vmunicipality, tblRegisterStudent.municipality);
                SqlServerHelper.SetParameterValue(vemail, tblRegisterStudent.email);
                SqlServerHelper.SetParameterValue(veducationalGradeId, tblRegisterStudent.educationalGradeId);
                SqlServerHelper.SetParameterValue(vorientationGroupId, tblRegisterStudent.orientationGroupId);
                SqlServerHelper.SetParameterValue(vcoachingSchool, tblRegisterStudent.coachingSchool);
                SqlServerHelper.SetParameterValue(vprivateLessons, tblRegisterStudent.privateLessons);
                SqlServerHelper.SetParameterValue(vuserId, tblRegisterStudent.userId);

                try
                {
                    // Attach command
                    AttachCommand(sqlCommand);

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


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

            return(__rowsAffected);
        }
示例#4
0
        public int Retrieve(tblRegisterStudent tblRegisterStudent)
        {
            int __rowsAffected = 1;

            // Create command
            using (SqlCommand sqlCommand = new SqlCommand("tblRegisterStudentGet"))
            {
                // 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 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 vemail = new SqlParameter("@email", SqlDbType.NVarChar, 255);
                    vemail.Direction = ParameterDirection.Output;
                    sqlCommand.Parameters.Add(vemail);
                    SqlParameter veducationalGradeId = new SqlParameter("@educationalGradeId", SqlDbType.BigInt);
                    veducationalGradeId.Direction = ParameterDirection.Output;
                    sqlCommand.Parameters.Add(veducationalGradeId);
                    SqlParameter vorientationGroupId = new SqlParameter("@orientationGroupId", SqlDbType.BigInt);
                    vorientationGroupId.Direction = ParameterDirection.Output;
                    sqlCommand.Parameters.Add(vorientationGroupId);
                    SqlParameter vcoachingSchool = new SqlParameter("@coachingSchool", SqlDbType.NVarChar, 255);
                    vcoachingSchool.Direction = ParameterDirection.Output;
                    sqlCommand.Parameters.Add(vcoachingSchool);
                    SqlParameter vprivateLessons = new SqlParameter("@privateLessons", SqlDbType.Bit);
                    vprivateLessons.Direction = ParameterDirection.Output;
                    sqlCommand.Parameters.Add(vprivateLessons);
                    SqlParameter vuserId = new SqlParameter("@userId", SqlDbType.BigInt);
                    vuserId.Direction = ParameterDirection.Output;
                    sqlCommand.Parameters.Add(vuserId);

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

                    // Execute command
                    sqlCommand.ExecuteNonQuery();

                    try
                    {
                        // Get output parameter values
                        tblRegisterStudent.id                 = SqlServerHelper.ToInt64(vid);
                        tblRegisterStudent.dateOfBirth        = SqlServerHelper.ToDateTime(vdateOfBirth);
                        tblRegisterStudent.populationId       = SqlServerHelper.ToInt64(vpopulationId);
                        tblRegisterStudent.cityId             = SqlServerHelper.ToInt64(vcityId);
                        tblRegisterStudent.municipality       = SqlServerHelper.ToString(vmunicipality);
                        tblRegisterStudent.email              = SqlServerHelper.ToString(vemail);
                        tblRegisterStudent.educationalGradeId = SqlServerHelper.ToInt64(veducationalGradeId);
                        tblRegisterStudent.orientationGroupId = SqlServerHelper.ToNullableInt64(vorientationGroupId);
                        tblRegisterStudent.coachingSchool     = SqlServerHelper.ToString(vcoachingSchool);
                        tblRegisterStudent.privateLessons     = SqlServerHelper.ToNullableBoolean(vprivateLessons);
                        tblRegisterStudent.userId             = SqlServerHelper.ToInt64(vuserId);
                    }
                    catch (Exception ex)
                    {
                        if (ex is System.NullReferenceException)
                        {
                            __rowsAffected = 0;
                        }
                        else
                        {
                            throw ex;
                        }
                    }
                }
                finally
                {
                    // Detach command
                    DetachCommand(sqlCommand);
                }
            }

            return(__rowsAffected);
        }