/// <summary> /// Creates a new Company record using async /// </summary> public static async Task<int> CreateAsync(CompanyDO DO) { SqlParameter _CompanyName = new SqlParameter("CompanyName", SqlDbType.VarChar); _CompanyName.Value = DO.CompanyName; SqlParameter[] _params = new SqlParameter[] { _CompanyName }; string pid = ConfigurationManager.AppSettings["ePermitDAL"]; return await DataCommon.ExecuteScalarAsync("[dbo].[Company_Insert]", _params, pid); }
/// <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 }; string pid = ConfigurationManager.AppSettings["ePermitDAL"]; return DataCommon.ExecuteScalar("[dbo].[Company_Update]", _params, pid); }
/// <summary> /// Gets all Company records /// </summary> public static async Task<CompanyDO[]> GetAllAsync() { string pid = ConfigurationManager.AppSettings["ePermitDAL"]; SafeReader sr = await DataCommon.ExecuteSafeReaderAsync("[dbo].[Company_GetAll]", new SqlParameter[] { }, pid); 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(); }
/// <summary> /// Selects Company records by PK /// </summary> public static async Task<CompanyDO[]> GetByPKAsync(Int32 CompanyID) { SqlParameter _CompanyID = new SqlParameter("CompanyID", SqlDbType.Int); _CompanyID.Value = CompanyID; SqlParameter[] _params = new SqlParameter[] { _CompanyID }; string pid = ConfigurationManager.AppSettings["ePermitDAL"]; SafeReader sr = await DataCommon.ExecuteSafeReaderAsync("[dbo].[Company_GetByPK]", _params, pid); 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(); }
/// <summary> /// Deletes a Company record /// </summary> public static async Task<int> DeleteAsync(CompanyDO DO) { SqlParameter _CompanyID = new SqlParameter("CompanyID", SqlDbType.Int); _CompanyID.Value = DO.CompanyID; SqlParameter[] _params = new SqlParameter[] { _CompanyID }; string pid = ConfigurationManager.AppSettings["ePermitDAL"]; return await DataCommon.ExecuteScalarAsync("[dbo].[Company_Delete]", _params, pid); }