コード例 #1
0
        public int Retrieve(tblEducationalGrade tblEducationalGrade)
        {
            int __rowsAffected = 1;

            // Create command
            using (SqlCommand sqlCommand = new SqlCommand("tblEducationalGradeGet"))
            {
                // 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 vname = new SqlParameter("@name", SqlDbType.NVarChar, 255);
                    vname.Direction = ParameterDirection.Output;
                    sqlCommand.Parameters.Add(vname);
                    SqlParameter vstageId = new SqlParameter("@stageId", SqlDbType.BigInt);
                    vstageId.Direction = ParameterDirection.Output;
                    sqlCommand.Parameters.Add(vstageId);

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

                    // Execute command
                    sqlCommand.ExecuteNonQuery();

                    try
                    {
                        // Get output parameter values
                        tblEducationalGrade.id      = SqlServerHelper.ToInt64(vid);
                        tblEducationalGrade.name    = SqlServerHelper.ToString(vname);
                        tblEducationalGrade.stageId = SqlServerHelper.ToInt64(vstageId);
                    }
                    catch (Exception ex)
                    {
                        if (ex is System.NullReferenceException)
                        {
                            __rowsAffected = 0;
                        }
                        else
                        {
                            throw ex;
                        }
                    }
                }
                finally
                {
                    // Detach command
                    DetachCommand(sqlCommand);
                }
            }

            return(__rowsAffected);
        }
コード例 #2
0
        public int Delete(tblEducationalGrade tblEducationalGrade)
        {
            int __rowsAffected = 0;

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

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

            return(__rowsAffected);
        }
コード例 #3
0
        public int Insert(tblEducationalGrade tblEducationalGrade)
        {
            int __rowsAffected = 0;

            // Create command
            using (SqlCommand sqlCommand = new SqlCommand("tblEducationalGradeInsert"))
            {
                // 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 vname = new SqlParameter("@name", SqlDbType.NVarChar, 255);
                vname.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vname);
                SqlParameter vstageId = new SqlParameter("@stageId", SqlDbType.BigInt);
                vstageId.Direction = ParameterDirection.Input;
                sqlCommand.Parameters.Add(vstageId);

                // Set input parameter values
                SqlServerHelper.SetParameterValue(
                    vid,
                    tblEducationalGrade.id,
                    0);
                SqlServerHelper.SetParameterValue(vname, tblEducationalGrade.name);
                SqlServerHelper.SetParameterValue(vstageId, tblEducationalGrade.stageId);

                try
                {
                    // Attach command
                    AttachCommand(sqlCommand);

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


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

            return(__rowsAffected);
        }
コード例 #4
0
        public virtual void Clone(tblEducationalGrade sourceObject)
        {
            if (sourceObject == null)
            {
                throw new ArgumentNullException("sourceObject");
            }

            // Clone attributes from source object
            this._id      = sourceObject.id;
            this._name    = sourceObject.name;
            this._stageId = sourceObject.stageId;
        }