//------------------------------------------ #endregion #region --------------PopulateEntity-------------- private SiteOtherValuesEntity PopulateEntity(IDataReader reader) { //Create a new SiteOtherValues object SiteOtherValuesEntity siteOtherValues = new SiteOtherValuesEntity(); //Fill the object with data //SeetingID if (reader["SeetingID"] != DBNull.Value) { siteOtherValues.SeetingID = (SiteOtherValuesItems)reader["SeetingID"]; } //Value if (reader["Value"] != DBNull.Value) { siteOtherValues.Value = (string)reader["Value"]; } //Comment if (reader["Comment"] != DBNull.Value) { siteOtherValues.Comment = (string)reader["Comment"]; } //Return the populated object return(siteOtherValues); }
//------------------------------------------ #endregion #region --------------GetObject-------------- public static SiteOtherValuesEntity GetObject(SiteOtherValuesItems seetingID) { SiteOtherValuesEntity siteOtherValues = SiteOtherValuesSqlDataPrvider.Instance.GetObject(seetingID); //return the object return(siteOtherValues); }
/// <summary> /// Updates SiteOtherValues object by calling SiteOtherValues data provider update method. /// <example>[Example]bool status=SiteOtherValuesFactory.Update(siteOtherValues);.</example> /// </summary> /// <param name="siteOtherValues">The SiteOtherValues object.</param> /// <returns>Status of update operation.</returns> public static bool Save(SiteOtherValuesEntity siteOtherValues) { bool status = SiteOtherValuesSqlDataPrvider.Instance.Save(siteOtherValues); //Reload Site Settings if (status) { LoadAllSettings(); } //return result return(status); }
//------------------------------------------ #endregion #region --------------Save-------------- public bool Save(SiteOtherValuesEntity siteOtherValues) { using (SqlConnection myConnection = GetSqlConnection()) { SqlCommand myCommand = new SqlCommand("SiteOtherValues_Save", myConnection); myCommand.CommandType = CommandType.StoredProcedure; // Set the parameters myCommand.Parameters.Add("@SeetingID", SqlDbType.Int, 4).Value = (int)siteOtherValues.SeetingID; myCommand.Parameters.Add("@Value", SqlDbType.NVarChar).Value = siteOtherValues.Value; myCommand.Parameters.Add("@Comment", SqlDbType.NVarChar).Value = siteOtherValues.Comment; // Execute the command bool status = false; myConnection.Open(); if (myCommand.ExecuteNonQuery() > 0) { status = true; } myConnection.Close(); return(status); } }
public SiteOtherValuesEntity GetObject(SiteOtherValuesItems seetingID) { SiteOtherValuesEntity siteOtherValues = null; using (SqlConnection myConnection = GetSqlConnection()) { SqlCommand myCommand = new SqlCommand("SiteOtherValues_GetOneByID", myConnection); myCommand.CommandType = CommandType.StoredProcedure; // Set the parameters myCommand.Parameters.Add("@SeetingID", SqlDbType.Int, 4).Value = (int)seetingID; // Execute the command myConnection.Open(); using (SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection)) { if (dr.Read()) { siteOtherValues = PopulateEntity(dr); } dr.Close(); } myConnection.Close(); return(siteOtherValues); } }