public static BE.CommonPageContent[] SelectAll(string CommonPage)
        {
            ArrayList commonPageContents = new ArrayList();

            BE.CommonPageContent commonPageContent;
            string     SQLQuery = "SELECT * FROM [CommonPageContent] where CommonPage=@CommonPage  ";
            SqlCommand command  = new SqlCommand();

            command.CommandText = SQLQuery;
            command.Parameters.AddWithValue("@CommonPage", CommonPage);
            SqlDataReader reader = SQLHelper.ExecuteReader(command);

            while (reader.Read())
            {
                commonPageContent = new BE.CommonPageContent();

                commonPageContent.Id         = Convert.ToInt32(reader["Id"]);
                commonPageContent.CommonPage = Convert.ToInt32(reader["CommonPage"]);
                commonPageContent.Title      = Convert.ToString(reader["Title"]);
                commonPageContent.Content    = Convert.ToString(reader["Content"]);
                commonPageContent.Created    = Convert.ToDateTime(reader["Created"]);
                commonPageContent.CreatedBy  = Convert.ToString(reader["CreatedBy"]);
                commonPageContent.Edited     = Convert.ToDateTime(reader["Edited"]);
                commonPageContent.EditedBy   = Convert.ToString(reader["EditedBy"]);
                commonPageContent.Publish    = Convert.ToString(reader["Publish"]);
                commonPageContents.Add(commonPageContent);
            }


            reader.Close();
            reader.Dispose();
            return((BE.CommonPageContent[])commonPageContents.ToArray(typeof(BE.CommonPageContent)));
        }
        public static BE.CommonPageContent SelectApproved(Int32 Id)
        {
            BE.CommonPageContent commonPageContent = new BE.CommonPageContent();
            string SQLQuery = "SELECT * FROM [CommonPageContent] WHERE [CommonPage]=@Id  And Publish=@Publish";

            SqlCommand command = new SqlCommand();

            command.CommandText = SQLQuery;
            command.Parameters.AddWithValue("@Id", Id);
            command.Parameters.AddWithValue("@Publish", "P");

            SqlDataReader reader = SQLHelper.ExecuteReader(command);

            reader.Read();

            commonPageContent.Id         = Convert.ToInt32(reader["Id"]);
            commonPageContent.CommonPage = Convert.ToInt32(reader["CommonPage"]);
            commonPageContent.Title      = Convert.ToString(reader["Title"]);
            commonPageContent.Content    = Convert.ToString(reader["Content"]);
            commonPageContent.Created    = Convert.ToDateTime(reader["Created"]);
            commonPageContent.CreatedBy  = Convert.ToString(reader["CreatedBy"]);
            commonPageContent.Edited     = Convert.ToDateTime(reader["Edited"]);
            commonPageContent.EditedBy   = Convert.ToString(reader["EditedBy"]);
            commonPageContent.Publish    = Convert.ToString(reader["Publish"]);

            reader.Close();
            reader.Dispose();
            return(commonPageContent);
        }
 private static void AddParameters(SqlCommand command, BE.CommonPageContent commonPageContent)
 {
     command.Parameters.AddWithValue("@Id", commonPageContent.Id);
     command.Parameters.AddWithValue("@CommonPage", commonPageContent.CommonPage);
     command.Parameters.AddWithValue("@Title", commonPageContent.Title);
     command.Parameters.AddWithValue("@Content", commonPageContent.Content);
     command.Parameters.AddWithValue("@Created", commonPageContent.Created);
     command.Parameters.AddWithValue("@CreatedBy", commonPageContent.CreatedBy);
     command.Parameters.AddWithValue("@Edited", commonPageContent.Edited);
     command.Parameters.AddWithValue("@EditedBy", commonPageContent.EditedBy);
     command.Parameters.AddWithValue("@Publish", commonPageContent.Publish);
 }
        public static bool Update(BE.CommonPageContent commonPageContent)
        {
            string SQLQuery = "UPDATE [CommonPageContent] SET Id = @Id, CommonPage= @CommonPage, Title= @Title, Content= @Content, Created= @Created, CreatedBy= @CreatedBy, Edited= @Edited, EditedBy= @EditedBy, Publish= @Publish WHERE [Id]=@Id ";

            SqlCommand command = new SqlCommand();

            command.CommandText = SQLQuery;

            AddParameters(command, commonPageContent);

            return(Convert.ToBoolean(SQLHelper.ExecuteNonQuery(command)));
        }
        public static bool Insert(BE.CommonPageContent commonPageContent)
        {
            string SQLQuery = "INSERT INTO [CommonPageContent] ( id,commonPage,title,content,created,createdBy,edited,editedBy,publish ) VALUES	(@id, @commonPage, @title, @content, @created, @createdBy, @edited, @editedBy, @publish)";

            commonPageContent.Id = Utility.GetId("CommonPageContent", "Id");
            SqlCommand command = new SqlCommand();

            command.CommandText = SQLQuery;

            AddParameters(command, commonPageContent);

            return(Convert.ToBoolean(SQLHelper.ExecuteNonQuery(command)));
        }
        public static bool Save(BE.CommonPageContent commonPageContent)
        {
            bool IsAffected = false;

            if (commonPageContent.State == BE.RowState.Added)
            {
                IsAffected = Insert(commonPageContent);
            }
            else if (commonPageContent.State == BE.RowState.Modified)
            {
                IsAffected = Update(commonPageContent);
            }
            else if (commonPageContent.State == BE.RowState.Deleted)
            {
                IsAffected = Delete(commonPageContent.Id);
            }
            return(IsAffected);
        }