/// <summary> /// Add common parameters before calling a procedure /// </summary> /// <param name="cmd">command object, where parameters will be added</param> /// <param name="globalSettingObject"></param> private void AddCommonParams(SqlCommand cmd, GlobalSettingBase globalSettingObject) { AddParameter(cmd, pGuid(GlobalSettingBase.Property_CompanyId, globalSettingObject.CompanyId)); AddParameter(cmd, pNVarChar(GlobalSettingBase.Property_SearchKey, 250, globalSettingObject.SearchKey)); AddParameter(cmd, pNVarChar(GlobalSettingBase.Property_Value, 1000, globalSettingObject.Value)); AddParameter(cmd, pBool(GlobalSettingBase.Property_IsActive, globalSettingObject.IsActive)); }
/// <summary> /// Updates GlobalSetting /// </summary> /// <param name="globalSettingObject">Object to be updated</param> /// <returns>Number of rows affected</returns> public long Update(GlobalSettingBase globalSettingObject) { try { SqlCommand cmd = GetSPCommand(UPDATEGLOBALSETTING); AddParameter(cmd, pInt32(GlobalSettingBase.Property_Id, globalSettingObject.Id)); AddCommonParams(cmd, globalSettingObject); long result = UpdateRecord(cmd); if (result > 0) { globalSettingObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow; } return(result); } catch (SqlException x) { throw new ObjectUpdateException(globalSettingObject, x); } }
/// <summary> /// Fills GlobalSetting object /// </summary> /// <param name="globalSettingObject">The object to be filled</param> /// <param name="reader">The reader to use to fill a single object</param> /// <param name="start">The ordinal position from which to start reading the reader</param> protected void FillObject(GlobalSettingBase globalSettingObject, SqlDataReader reader, int start) { globalSettingObject.Id = reader.GetInt32(start + 0); globalSettingObject.CompanyId = reader.GetGuid(start + 1); if (!reader.IsDBNull(2)) { globalSettingObject.SearchKey = reader.GetString(start + 2); } if (!reader.IsDBNull(3)) { globalSettingObject.Value = reader.GetString(start + 3); } if (!reader.IsDBNull(4)) { globalSettingObject.IsActive = reader.GetBoolean(start + 4); } FillBaseObject(globalSettingObject, reader, (start + 5)); globalSettingObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow; }
/// <summary> /// Inserts GlobalSetting /// </summary> /// <param name="globalSettingObject">Object to be inserted</param> /// <returns>Number of rows affected</returns> public long Insert(GlobalSettingBase globalSettingObject) { try { SqlCommand cmd = GetSPCommand(INSERTGLOBALSETTING); AddParameter(cmd, pInt32Out(GlobalSettingBase.Property_Id)); AddCommonParams(cmd, globalSettingObject); long result = InsertRecord(cmd); if (result > 0) { globalSettingObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow; globalSettingObject.Id = (Int32)GetOutParameter(cmd, GlobalSettingBase.Property_Id); } return(result); } catch (SqlException x) { throw new ObjectInsertException(globalSettingObject, x); } }
/// <summary> /// Fills GlobalSetting object /// </summary> /// <param name="globalSettingObject">The object to be filled</param> /// <param name="reader">The reader to use to fill a single object</param> protected void FillObject(GlobalSettingBase globalSettingObject, SqlDataReader reader) { FillObject(globalSettingObject, reader, 0); }