Exemple #1
0
        //------------------------------------------
        /// <summary>
        /// Converts the SMSGroups object properties to SQL paramters and executes the update SMSGroups procedure.
        /// <example>[Example]bool result=SMSGroupsSqlDataPrvider.Instance.Update(smsGroups);.</example>
        /// </summary>
        /// <param name="smsGroups">The SMSGroups object.</param>
        /// <returns>The result of update query.</returns>
        public bool Update(SMSGroupsEntity smsGroups)
        {
            bool result = false;

            using (SqlConnection myConnection = GetSqlConnection())
            {
                SqlCommand myCommand = new SqlCommand("SMSGroups_Update", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                // Set the parameters
                myCommand.Parameters.Add("@GroupID", SqlDbType.Int, 4).Value     = smsGroups.GroupID;
                myCommand.Parameters.Add("@Name", SqlDbType.NVarChar, 100).Value = smsGroups.Name;
                //----------------------------------------------------------------------------------------------
                //OwnerID
                myCommand.Parameters.Add("@OwnerID", SqlDbType.UniqueIdentifier).Value = SitesHandler.GetOwnerIDAsGuid();
                //----------------------------------------------------------------------------------------------
                // Execute the command
                myConnection.Open();
                if (myCommand.ExecuteNonQuery() > 0)
                {
                    result = true;
                }
                myConnection.Close();
                return(result);
            }
        }
Exemple #2
0
        //------------------------------------------
        /// <summary>
        /// Gets single SMSGroups object .
        /// <example>[Example]SMSGroupsEntity smsGroups=SMSGroupsSqlDataPrvider.Instance.GetSMSGroupsObject(GroupID);.</example>
        /// </summary>
        /// <param name="GroupID">The smsGroups id.</param>
        /// <returns>SMSGroups object.</returns>
        public SMSGroupsEntity GetSMSGroupsObject(int GroupID)
        {
            SMSGroupsEntity smsGroups = null;

            using (SqlConnection myConnection = GetSqlConnection())
            {
                SqlCommand myCommand = new SqlCommand("SMSGroups_GetOneByID", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                // Set the parameters
                myCommand.Parameters.Add("@GroupID", SqlDbType.Int, 4).Value = GroupID;
                //----------------------------------------------------------------------------------------------
                //OwnerID
                myCommand.Parameters.Add("@OwnerID", SqlDbType.UniqueIdentifier).Value = SitesHandler.GetOwnerIDAsGuid();
                //----------------------------------------------------------------------------------------------
                // Execute the command
                myConnection.Open();
                using (SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    if (dr.Read())
                    {
                        smsGroups = PopulateEntity(dr);
                    }
                    dr.Close();
                }
                myConnection.Close();
                return(smsGroups);
            }
        }
Exemple #3
0
        //------------------------------------------
        /// <summary>
        /// Populates SMSGroups Entity From DataRowView .
        /// <example>[Example]SMSGroupsEntitysmsGroups=PopulateSMSGroupsEntityFromDataRowView(obj);.</example>
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>SMSGroups object.</returns>
        private SMSGroupsEntity PopulateSMSGroupsEntityFromDataRowView(DataRowView obj)
        {
            //Create a new SMSGroups object
            SMSGroupsEntity smsGroups = new SMSGroupsEntity();

            //Fill the object with data
            if (obj["GroupID"] != DBNull.Value)
            {
                smsGroups.GroupID = (int)obj["GroupID"];
            }
            if (obj["Name"] != DBNull.Value)
            {
                smsGroups.Name = (string)obj["Name"];
            }
            //Return the populated object
            return(smsGroups);
        }
Exemple #4
0
        //------------------------------------------
        /// <summary>
        /// Populates SMSGroups Entity From IDataReader .
        /// <example>[Example]SMSGroupsEntitysmsGroups=PopulateEntity(reader);.</example>
        /// </summary>
        /// <param name="reader"></param>
        /// <returns>SMSGroups object.</returns>
        private SMSGroupsEntity PopulateEntity(IDataReader reader)
        {
            //Create a new SMSGroups object
            SMSGroupsEntity smsGroups = new SMSGroupsEntity();

            //Fill the object with data
            if (reader["GroupID"] != DBNull.Value)
            {
                smsGroups.GroupID = (int)reader["GroupID"];
            }
            if (reader["Name"] != DBNull.Value)
            {
                smsGroups.Name = (string)reader["Name"];
            }
            //Return the populated object
            return(smsGroups);
        }
Exemple #5
0
 //------------------------------------------
 /// <summary>
 /// Updates SMSGroups object by calling SMSGroups data provider update method.
 /// <example>[Example]bool result=SMSGroupsFactory.Update(smsGroups);.</example>
 /// </summary>
 /// <param name="smsGroups">The SMSGroups object.</param>
 /// <returns>The result of update operation.</returns>
 public static bool Update(SMSGroupsEntity smsGroups)
 {
     return(SMSGroupsSqlDataPrvider.Instance.Update(smsGroups));
 }