Пример #1
0
        /// <summary>
        /// Creates a new Company record
        /// </summary>
        public static int Create(CompanyDO DO)
        {
            SqlParameter _CompanyName = new SqlParameter("CompanyName", SqlDbType.VarChar);

            _CompanyName.Value = DO.CompanyName;

            SqlParameter[] _params = new SqlParameter[] {
                _CompanyName
            };

            return DataCommon.ExecuteScalar("[dbo].[Company_Insert]", _params, "dbo");
        }
Пример #2
0
        /// <summary>
        /// Deletes a Company record
        /// </summary>
        public static int Delete(CompanyDO DO)
        {
            SqlParameter _CompanyID = new SqlParameter("CompanyID", SqlDbType.Int);

            _CompanyID.Value = DO.CompanyID;

            SqlParameter[] _params = new SqlParameter[] {
                _CompanyID
            };

            return DataCommon.ExecuteScalar("[dbo].[Company_Delete]", _params, "dbo");
        }
Пример #3
0
        /// <summary>
        /// Gets all Company records
        /// </summary>
        public static CompanyDO[] GetAll()
        {
            SafeReader sr = DataCommon.ExecuteSafeReader("[dbo].[Company_GetAll]", new SqlParameter[] { }, "dbo");

            List<CompanyDO> objs = new List<CompanyDO>();

            while(sr.Read()){

                CompanyDO obj = new CompanyDO();

                obj.CompanyID = sr.GetInt32(sr.GetOrdinal("CompanyID"));
                obj.CompanyName = sr.GetString(sr.GetOrdinal("CompanyName"));

                objs.Add(obj);
            }

            return objs.ToArray();
        }
Пример #4
0
        /// <summary>
        /// Selects Company records by PK
        /// </summary>
        public static CompanyDO[] GetByPK(Int32 CompanyID)
        {
            SqlParameter _CompanyID = new SqlParameter("CompanyID", SqlDbType.Int);

            _CompanyID.Value = CompanyID;

            SqlParameter[] _params = new SqlParameter[] {
                _CompanyID
            };

            SafeReader sr = DataCommon.ExecuteSafeReader("[dbo].[Company_GetByPK]", _params, "dbo");

            List<CompanyDO> objs = new List<CompanyDO>();

            while(sr.Read())
            {
                CompanyDO obj = new CompanyDO();

                obj.CompanyID = sr.GetInt32(sr.GetOrdinal("CompanyID"));
                obj.CompanyName = sr.GetString(sr.GetOrdinal("CompanyName"));

                objs.Add(obj);
            }

            return objs.ToArray();
        }
Пример #5
0
        /// <summary>
        /// Updates a Company record and returns the number of records affected
        /// </summary>
        public static int Update(CompanyDO DO)
        {
            SqlParameter _CompanyID = new SqlParameter("CompanyID", SqlDbType.Int);
            SqlParameter _CompanyName = new SqlParameter("CompanyName", SqlDbType.VarChar);

            _CompanyID.Value = DO.CompanyID;
            _CompanyName.Value = DO.CompanyName;

            SqlParameter[] _params = new SqlParameter[] {
                _CompanyID,
                _CompanyName
            };

            return DataCommon.ExecuteScalar("[dbo].[Company_Update]", _params, "dbo");
        }