void Comment_Approved(object sender, EventArgs e) { BSComment bsComment = (BSComment)sender; if (bsComment.Approve) { using (DataProcess dp = new DataProcess()) { dp.AddParameter("PostID", bsComment.PostID); dp.AddParameter("NotifyMe", true); dp.AddParameter("Approve", true); dp.ExecuteReader("SELECT DISTINCT Email FROM Comments WHERE PostID=@PostID AND NotifyMe=@NotifyMe AND Approve=@Approve"); if (dp.Return.Status == DataProcessState.Success) { BSPost bsPost = BSPost.GetPost(bsComment.PostID); using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr.Read()) { string strEmail = (string)dr["Email"]; System.Threading.ThreadPool.QueueUserWorkItem(delegate { BSHelper.SendMail(Language.Get["NewCommentNotice"], Blogsa.Settings["smtp_email"].ToString(), Blogsa.Settings["smtp_name"].ToString() , strEmail, "", Language.Get["NewCommentNoticeDescription"] + "<br><br><a href=\"" + bsPost.Link + "\">" + bsPost.Title + "</a>", true); }); } } } } } }
public static List <BSComment> GetCommentsByUserID(int iUserID, CommentStates state) { List <BSComment> comments = new List <BSComment>(); using (DataProcess dp = new DataProcess()) { if (state == CommentStates.All) { dp.AddParameter("UserID", iUserID); dp.ExecuteReader("SELECT * FROM Comments WHERE [UserID]=@UserID ORDER By CreateDate DESC"); } else { dp.AddParameter("UserID", iUserID); dp.AddParameter("Approve", state == CommentStates.Approved); dp.ExecuteReader("SELECT * FROM Comments WHERE [UserID]=@UserID AND [Approve]=@Approve ORDER By CreateDate DESC"); } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSComment bsComment = new BSComment(); FillComment(dr, bsComment); comments.Add(bsComment); } } } } return(comments); }
public static List <BSPost> GetPostsByTitle(string title, int iUserId) { List <BSPost> posts = new List <BSPost>(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("Title", title); if (iUserId == 0) { dp.ExecuteReader("SELECT * FROM [Posts] WHERE [Title] LIKE '%' + @Title + '%' ORDER By [CreateDate] DESC,[Title]"); } else { dp.AddParameter("UserID", iUserId); dp.ExecuteReader("SELECT * FROM [Posts] WHERE [Title] LIKE '%' + @Title + '%' AND [UserID]=@UserID ORDER By [CreateDate] DESC,[Title]"); } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSPost bsPost = new BSPost(); FillPost(dr, bsPost); posts.Add(bsPost); } } } } return(posts); }
public static List <BSTerm> GetTermsByObjectID(int objectId, TermTypes termType) { List <BSTerm> terms = new List <BSTerm>(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("ObjectID", objectId); if (termType != TermTypes.All) { dp.AddParameter("Type", termType.ToString().ToLowerInvariant()); dp.ExecuteReader("SELECT * FROM Terms WHERE [TermID] IN (SELECT TermID FROM TermsTo WHERE [ObjectID]=@ObjectID AND [Type]=@Type) ORDER BY Name"); } else { dp.ExecuteReader("SELECT * FROM Terms WHERE [TermID] IN (SELECT TermID FROM TermsTo WHERE [ObjectID]=@ObjectID) ORDER BY Name"); } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSTerm bsTerm = new BSTerm(); FillTerm(dr, bsTerm); terms.Add(bsTerm); } } } } return(terms); }
public static List <BSTerm> GetTermsBySubID(TermTypes termType, int iSubID) { List <BSTerm> terms = new List <BSTerm>(); using (DataProcess dp = new DataProcess()) { if (termType != TermTypes.All) { dp.AddParameter("Type", termType.ToString().ToLowerInvariant()); dp.AddParameter("SubID", iSubID); dp.ExecuteReader("SELECT * FROM Terms WHERE [Type]=@Type AND [SubID]=@SubID ORDER BY [Name] ASC"); } else { dp.AddParameter("SubID", iSubID); dp.ExecuteReader("SELECT * FROM Terms WHERE [SubID]=@SubID ORDER BY [Name] ASC"); } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSTerm bsTerm = new BSTerm(); FillTerm(dr, bsTerm); terms.Add(bsTerm); } } } } return(terms); }
public static List <BSWidget> GetWidgetsByPlaceHolder(string placeHolder, bool visible) { List <BSWidget> widgets = new List <BSWidget>(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("PlaceHolder", placeHolder); dp.AddParameter("Visible", visible); dp.ExecuteReader("SELECT * FROM [Widgets] WHERE [PlaceHolder]=@PlaceHolder AND [Visible]=@Visible ORDER BY [Sort]"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr.Read()) { BSWidget bsWidget = new BSWidget(); FillWidget(dr, bsWidget); widgets.Add(bsWidget); } } } } return(widgets); }
public static List <BSPost> GetPosts(PostTypes postType, PostVisibleTypes postVisibleType, FileTypes fileType, int postCount) { List <BSPost> posts = new List <BSPost>(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("Type", (short)postType); if (postVisibleType != PostVisibleTypes.All) { if (fileType != FileTypes.All) { dp.AddParameter("State", (short)postVisibleType); dp.AddParameter("Show", (short)fileType); dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type AND [State]=@State AND [Show]=@Show ORDER By [CreateDate] DESC,[Title]" , postCount == 0 ? String.Empty : "TOP " + postCount)); } else { dp.AddParameter("State", (short)postVisibleType); dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type AND [State]=@State ORDER By [CreateDate] DESC,[Title]" , postCount == 0 ? String.Empty : "TOP " + postCount)); } } else { if (fileType != FileTypes.All) { dp.AddParameter("Show", (short)fileType); dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type AND [Show]=@Show ORDER By [CreateDate] DESC,[Title]" , postCount == 0 ? String.Empty : "TOP " + postCount)); } else { dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type ORDER By [CreateDate] DESC,[Title]" , postCount == 0 ? String.Empty : "TOP " + postCount)); } } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSPost bsPost = new BSPost(); FillPost(dr, bsPost); posts.Add(bsPost); } } } } return(posts); }
public bool Save() { DataProcess dp = new DataProcess(); string sql = String.Empty; if (SettingID == 0) { sql = "INSERT INTO Settings([SiteID],[Name],[Value],[Title],[Description],[Main],[Sort],[Visible]) " + "VALUES(@SiteID,@Name,@Value,@Title,@Description,@Main,@Sort,@Visible);"; } else { sql = "UPDATE Settings SET [SiteID]=@SiteID,[Name]=@Name,[Value]=@Value,[Title]=@Title,[Description]=@Description,[Main]=@Main,[Sort]=@Sort,[Visible]=@Visible WHERE [SettingID] = @SettingID;"; } dp.AddParameter("SiteID", this.SiteID); dp.AddParameter("Name", this.Name); dp.AddParameter("Value", this.Value); dp.AddParameter("Title", this.Title); dp.AddParameter("Description", this.Description); dp.AddParameter("Main", this.Main); dp.AddParameter("Sort", this.Sort); dp.AddParameter("Visible", this.Visible); if (SettingID != 0) { dp.AddParameter("SettingID", this.SettingID); } dp.ExecuteNonQuery(sql); return(dp.Return.Status == DataProcessState.Success); }
private void AddObjects() { using (DataProcess dp = new DataProcess()) { string type = Type.ToString().ToLowerInvariant(); foreach (int objectID in Objects) { dp.AddParameter("ObjectID", objectID); dp.AddParameter("TermID", TermID); dp.AddParameter("Type", type); dp.ExecuteNonQuery("INSERT INTO TermsTo([ObjectID],[TermID],[Type]) VALUES(@ObjectID,@TermID,@Type)"); } } }
public static List <BSPost> GetPostsByColumnValue(string column, object value, int postCount, string orderBy, PostTypes postType, PostStates postState) { List <BSPost> posts = new List <BSPost>(); using (DataProcess dp = new DataProcess()) { string top = postCount > 0 ? "TOP " + postCount : String.Empty; if (!String.IsNullOrEmpty(column) && value != null) { dp.AddParameter("Type", (short)postType); dp.AddParameter(column, value); if (postState == PostStates.All) { dp.ExecuteReader(String.Format("SELECT {1} * FROM Posts WHERE [Type]=@Type AND [{0}]=@{0} {2}", column, top, orderBy)); } else { dp.AddParameter("State", (short)postState); dp.ExecuteReader(String.Format("SELECT {1} * FROM Posts WHERE [Type]=@Type AND [{0}]=@{0} AND [State]=@State {2}", column, top, orderBy)); } } else { dp.AddParameter("Type", (short)postType); if (postState == PostStates.All) { dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type {1}", top, orderBy)); } else { dp.AddParameter("State", (short)postState); dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type AND [State]=@State {1}", top, orderBy)); } } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSPost bsPost = new BSPost(); FillPost(dr, bsPost); posts.Add(bsPost); } } } } return(posts); }
public static List <BSComment> GetComments(CommentStates state, int iCommentCount) { List <BSComment> comments = new List <BSComment>(); using (DataProcess dp = new DataProcess()) { string top = iCommentCount == 0 ? String.Empty : "TOP " + iCommentCount; if (state == CommentStates.All) { dp.ExecuteReader(String.Format("SELECT {0} * FROM Comments ORDER By CreateDate DESC", top)); } else { dp.AddParameter("Approve", state == CommentStates.Approved); dp.ExecuteReader(String.Format("SELECT {0} * FROM Comments WHERE [Approve]=@Approve ORDER By CreateDate DESC", top)); } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSComment bsComment = new BSComment(); FillComment(dr, bsComment); comments.Add(bsComment); } } } } return(comments); }
private static void FillTerm(IDataReader dr, BSTerm bsTerm) { bsTerm.SubID = (int)dr["SubID"]; bsTerm.Name = (string)dr["Name"]; bsTerm.Code = (string)dr["Code"]; bsTerm.Description = dr["Description"].ToString(); string termType = (string)dr["Type"]; bsTerm.Type = GetTermType(termType); bsTerm.TermID = (int)dr["TermID"]; bsTerm.Objects = new List <int>(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("TermID", bsTerm.TermID); dp.ExecuteReader("SELECT * FROM TermsTo WHERE [TermID]=@TermID"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader drObjects = (IDataReader)dp.Return.Value) while (drObjects.Read()) { bsTerm.Objects.Add((int)drObjects["ObjectID"]); } } } }
public static List <BSTerm> GetTerms(TermTypes termType, int iTermCount) { List <BSTerm> terms = new List <BSTerm>(); using (DataProcess dp = new DataProcess()) { string top = iTermCount == 0 ? String.Empty : "TOP " + iTermCount; if (termType != TermTypes.All) { dp.AddParameter("Type", termType.ToString().ToLowerInvariant()); dp.ExecuteReader(String.Format("SELECT {0} * FROM Terms WHERE [Type]=@Type ORDER BY [Name] ASC", top)); } else { dp.ExecuteReader(String.Format("SELECT {0} * FROM Terms ORDER BY [Name] ASC", top)); } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSTerm bsTerm = new BSTerm(); FillTerm(dr, bsTerm); terms.Add(bsTerm); } } } } return(terms); }
public static List <BSWidget> GetWidgetsByColumnValue(string column, object value, int widgetCount, string orderBy) { List <BSWidget> widgets = new List <BSWidget>(); using (DataProcess dp = new DataProcess()) { string top = widgetCount > 0 ? "TOP " + widgetCount : String.Empty; if (!String.IsNullOrEmpty(column) && value != null) { dp.AddParameter(column, value); dp.ExecuteReader(String.Format("SELECT {0} * FROM [Widgets] WHERE [{1}]=@{1} {2}", top, column, orderBy)); } else { dp.ExecuteReader(String.Format("SELECT {0} * FROM [Widgets] {1}", top, orderBy)); } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSWidget bsWidget = new BSWidget(); FillWidget(dr, bsWidget); widgets.Add(bsWidget); } } } } return(widgets); }
public static List <BSWidget> GetWidgetsBySorted() { List <BSWidget> widgets = new List <BSWidget>(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("Visible", true); dp.ExecuteReader("SELECT * FROM Widgets WHERE [Visible] = @Visible ORDER BY [Sort]"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr.Read()) { BSWidget bsWidget = new BSWidget(); FillWidget(dr, bsWidget); widgets.Add(bsWidget); } } } } return(widgets); }
public static int GetReadCounts(int iPostID) { using (DataProcess dp = new DataProcess()) { if (iPostID > 0) { dp.AddParameter("PostID", iPostID); dp.ExecuteScalar("SELECT SUM([ReadCount]) FROM Posts WHERE [PostID] = @PostID"); } else { dp.ExecuteScalar("SELECT SUM([ReadCount]) FROM Posts"); } if (dp.Return.Status == DataProcessState.Success) { if (dp.Return.Value != DBNull.Value) { return(Convert.ToInt32(dp.Return.Value)); } else { return(0); } } } return(0); }
public static BSSetting GetSetting(int iSettingID) { BSSetting bsSetting = new BSSetting(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("SettingID", iSettingID); dp.ExecuteReader("SELECT * FROM Settings WHERE SettingID = @SettingID"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { if (dr.Read()) { FillValue(dr, bsSetting); return(bsSetting); } } } } return(null); }
public static List <BSSetting> GetThemeSettings(string themeName) { List <BSSetting> _Settings = new List <BSSetting>(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("Name", themeName); dp.ExecuteReader("SELECT * FROM Settings WHERE Name LIKE @Name + '_%'"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr.Read()) { BSSetting bsSetting = new BSSetting(); FillValue(dr, bsSetting); _Settings.Add(bsSetting); } } } } return(_Settings); }
public bool Save() { bool bReturnValue = false; using (DataProcess dp = new DataProcess()) { if (this.Default) { dp.AddParameter("Default", false); dp.ExecuteNonQuery("UPDATE [MenuGroups] SET [Default]=@Default"); } dp.AddParameter("SiteID", this.SiteID); dp.AddParameter("Code", this.Code); dp.AddParameter("Description", this.Description); dp.AddParameter("Title", this.Title); dp.AddParameter("Default", this.Default); dp.AddParameter("LanguageCode", this.LanguageCode); if (MenuGroupID != 0) { dp.AddParameter("MenuGroupID", this.MenuGroupID); dp.ExecuteNonQuery("UPDATE [MenuGroups] SET [SiteID]=@SiteID,[Code]=@Code,[Description]=@Description,[Title]=@Title,[Default]=@Default,[LanguageCode]=@LanguageCode WHERE [MenuGroupID] = @MenuGroupID"); bReturnValue = dp.Return.Status == DataProcessState.Success; if (bReturnValue) { foreach (BSMenu bsMenu in Menu) { bsMenu.Save(); } } } else { dp.ExecuteNonQuery("INSERT INTO [MenuGroups]([SiteID],[Code],[Description],[Title],[Default],[LanguageCode]) VALUES(@SiteID,@Code,@Description,@Title,@Default,@LanguageCode)"); bReturnValue = dp.Return.Status == DataProcessState.Success; if (bReturnValue) { foreach (BSMenu bsMenu in Menu) { bsMenu.Save(); } dp.ExecuteScalar("SELECT @@IDENTITY"); if (dp.Return.Status == DataProcessState.Success) { MenuGroupID = Convert.ToInt32(dp.Return.Value); } } } } return(bReturnValue); }
public bool Save() { using (DataProcess dp = new DataProcess()) { dp.AddParameter("SiteID", SiteID); dp.AddParameter("Name", Name); dp.AddParameter("Description", Description); dp.AddParameter("Target", Target); dp.AddParameter("Url", Url); dp.AddParameter("LanguageCode", LanguageCode); if (LinkID != 0) { dp.AddParameter("LinkID", LinkID); dp.ExecuteNonQuery( "UPDATE Links SET [SiteID]=@SiteID,[Name]=@Name,[Description]=@Description,[Target]=@Target,[Url]=@Url,[LanguageCode]=@LanguageCode WHERE [LinkID]=@LinkID"); return(dp.Return.Status == DataProcessState.Success); } else { dp.ExecuteNonQuery("INSERT INTO Links([SiteID],[Name],[Description],[Target],[Url],[LanguageCode]) VALUES(@SiteID,@Name,@Description,@Target,@Url,@LanguageCode)"); if (dp.Return.Status == DataProcessState.Success) { dp.ExecuteScalar("SELECT @@IDENTITY"); if (dp.Return.Status == DataProcessState.Success) { LinkID = Convert.ToInt32(dp.Return.Value); } return(true); } } } return(false); }
public static bool ValidateUser(string userName, string password) { using (DataProcess dp = new DataProcess()) { dp.AddParameter("UserName", userName); dp.AddParameter("Password", password); dp.ExecuteReader("SELECT * FROM Users WHERE [UserName]=@UserName AND [Password]=@Password"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { return(dr != null && dr.Read()); } } } return(false); }
public static List <BSPost> GetPostsByTerm(int termId, string code, TermTypes termType, PostTypes postType, PostStates postState) { List <BSPost> posts = new List <BSPost>(); using (DataProcess dp = new DataProcess()) { BSTerm bsTerm = null; bsTerm = termId != 0 ? BSTerm.GetTerm(termId) : BSTerm.GetTerm(code, termType); if (bsTerm != null) { dp.AddParameter("TermID", bsTerm.TermID); if (postState != PostStates.All) { dp.AddParameter("State", (short)postState); dp.ExecuteReader("SELECT * FROM Posts WHERE [PostID] IN (SELECT [ObjectID] FROM TermsTo WHERE [TermID]=@TermID) AND [State]=@State ORDER By [CreateDate] DESC"); } else { dp.ExecuteReader("SELECT * FROM Posts WHERE [PostID] IN (SELECT [ObjectID] FROM TermsTo WHERE [TermID]=@TermID) AND [Type]=@Type ORDER By [CreateDate] DESC"); } } else { return(posts); } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSPost bsPost = new BSPost(); FillPost(dr, bsPost); posts.Add(bsPost); } } } } return(posts); }
public bool Save() { bool bReturnValue = false; using (DataProcess dp = new DataProcess()) { dp.AddParameter("SiteID", this.SiteID); dp.AddParameter("Description", this.Description); dp.AddParameter("FolderName", this.FolderName); dp.AddParameter("PlaceHolder", this.PlaceHolder); dp.AddParameter("Sort", this.Sort); dp.AddParameter("Title", this.Title); dp.AddParameter("Visible", this.Visible); dp.AddParameter("Type", this.Type); dp.AddParameter("LanguageCode", this.LanguageCode); if (WidgetID != 0) { dp.AddParameter("WidgetID", WidgetID); dp.ExecuteNonQuery("UPDATE Widgets SET [SiteID]=@SiteID,[Description]=@Description,[FolderName]=@FolderName,[PlaceHolder]=@PlaceHolder,[Sort]=@Sort," + "[Title]=@Title,[Visible]=@Visible,[Type]=@Type,[LanguageCode]=@LanguageCode WHERE [WidgetID] = @WidgetID"); bReturnValue = dp.Return.Status == DataProcessState.Success; } else { dp.ExecuteNonQuery("INSERT INTO Widgets([SiteID],[Description],[FolderName],[PlaceHolder],[Sort],[Title],[Visible],[Type],[LanguageCode]) " + "VALUES(@SiteID,@Description,@FolderName,@PlaceHolder,@Sort,@Title,@Visible,@Type,@LanguageCode)"); bReturnValue = dp.Return.Status == DataProcessState.Success; if (bReturnValue) { dp.ExecuteScalar("SELECT @@IDENTITY"); if (dp.Return.Status == DataProcessState.Success) { WidgetID = Convert.ToInt32(dp.Return.Value); } } } } return(bReturnValue); }
protected void Page_Load(object sender, EventArgs e) { try { List <BSPost> posts = new List <BSPost>(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("PostID", BSPost.CurrentPost.PostID); dp.AddParameter("Title", BSPost.CurrentPost.Title); dp.ExecuteReader("SELECT TOP 5 * FROM Posts WHERE [PostID]<>@PostID AND [Type]=0 AND [State]=1 AND ([Title] Like '%'+@Title+'%' OR Content Like '%'+@Title+'%') ORDER BY [CreateDate] DESC"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr.Read()) { BSPost bsPost = new BSPost(); BSPost.FillPost(dr, bsPost); posts.Add(bsPost); } } } } if (posts.Count > 0) { rpRelatedPosts.DataSource = posts; rpRelatedPosts.DataBind(); } else { this.Visible = false; } } catch (System.Exception ex) { } }
public bool Remove() { using (DataProcess dp = new DataProcess()) { CancelEventArgs cancelEvent = new CancelEventArgs(); OnDeleting(this, cancelEvent); if (!cancelEvent.Cancel) { dp.AddParameter("TermID", TermID); dp.ExecuteNonQuery("DELETE FROM Terms WHERE [TermID] = @TermID"); dp.AddParameter("TermID", TermID); dp.ExecuteNonQuery("DELETE FROM TermsTo WHERE [TermID] = @TermID"); if (dp.Return.Status == DataProcessState.Success) { OnDeleted(this, null); return(true); } } } return(false); }
public static BSUser GetUser(string userName, string password) { using (DataProcess dp = new DataProcess()) { dp.AddParameter("UserName", userName); dp.AddParameter("Password", password); dp.ExecuteReader("SELECT * FROM Users WHERE [UserName]=@UserName AND [Password]=@Password"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { if (dr != null && dr.Read()) { BSUser user = new BSUser(); FillUser(dr, user); return(user); } } } } return(null); }
public static string GetWidgetState(string FolderName) { using (DataProcess dp = new DataProcess()) { dp.AddParameter("FolderName", FolderName); dp.ExecuteScalar("SELECT WidgetID FROM Widgets WHERE FolderName = @FolderName"); if (dp.Return.Status == DataProcessState.Success) return (string)dp.Return.Value; else return string.Empty; } }
public static List <BSTerm> GetTermsByContainsName(string name, TermTypes termType, int iTermCount) { List <BSTerm> terms = new List <BSTerm>(); using (DataProcess dp = new DataProcess()) { string top = iTermCount == 0 ? String.Empty : "TOP " + iTermCount; if (termType != TermTypes.All) { string type = termType == TermTypes.Category ? "category" : "tag"; dp.AddParameter("Type", type); dp.AddParameter("Name", name); dp.ExecuteReader(String.Format("SELECT {0} * FROM Terms WHERE [Type]=@Type AND [Name] LIKE '%' + @Name + '%' ORDER BY [Name] ASC", top)); } else { dp.AddParameter("Name", name); dp.ExecuteReader(String.Format("SELECT {0} * FROM Terms WHERE [Name] LIKE '%' + @Name + '%' ORDER BY [Name] ASC", top)); } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSTerm bsTerm = new BSTerm(); FillTerm(dr, bsTerm); terms.Add(bsTerm); } } } } return(terms); }
protected void Page_Load(object sender, EventArgs e) { try { List<BSPost> posts = new List<BSPost>(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("PostID", BSPost.CurrentPost.PostID); dp.AddParameter("Title", BSPost.CurrentPost.Title); dp.ExecuteReader("SELECT TOP 5 * FROM Posts WHERE [PostID]<>@PostID AND [Type]=0 AND [State]=1 AND ([Title] Like '%'+@Title+'%' OR Content Like '%'+@Title+'%') ORDER BY [CreateDate] DESC"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr.Read()) { BSPost bsPost = new BSPost(); BSPost.FillPost(dr, bsPost); posts.Add(bsPost); } } } } if (posts.Count > 0) { rpRelatedPosts.DataSource = posts; rpRelatedPosts.DataBind(); } else this.Visible = false; } catch (System.Exception ex) { } }
public static bool RemoveTo(TermTypes termType, int iObjectID) { using (DataProcess dp = new DataProcess()) { if (termType == TermTypes.All) { dp.AddParameter("ObjectID", iObjectID); dp.ExecuteNonQuery("DELETE FROM TermsTo WHERE [ObjectID]=@ObjectID"); } else { dp.AddParameter("Type", termType == TermTypes.Category ? "category" : "tag"); dp.AddParameter("ObjectID", iObjectID); dp.ExecuteNonQuery("DELETE FROM TermsTo WHERE [Type]=@Type AND [ObjectID]=@ObjectID"); } if (dp.Return.Status == DataProcessState.Success) { return(true); } } return(false); }
public bool DoApprove(bool bApprove) { CancelEventArgs eventArgs = new CancelEventArgs(); BSComment bsComment = GetComment(CommentID); OnApproving(bsComment, eventArgs); if (!eventArgs.Cancel) { using (DataProcess dp = new DataProcess()) { dp.AddParameter("Approve", bApprove); dp.AddParameter("CommentID", CommentID); dp.ExecuteNonQuery("UPDATE Comments SET [Approve]=@Approve WHERE [CommentID]=@CommentID"); if (dp.Return.Status == DataProcessState.Success) { bsComment.Approve = bApprove; OnApproved(bsComment, null); return(true); } } } return(false); }
protected void Page_Load(object sender, EventArgs e) { if (String.IsNullOrEmpty(SearchText)) { Response.Redirect("~/"); } using (DataProcess dp = new DataProcess()) { try { dp.AddParameter("Content", SearchText); dp.ExecuteReader("SELECT * FROM Posts WHERE Type = 0 AND State = 1 AND (Content LIKE @Content + ' %' OR Content LIKE '% ' + @Content OR Content LIKE '% ' + @Content + ' %')"); int p = 0; int.TryParse(Request["p"], out p); p = p == 0 ? 1 : p; IDataReader dr = dp.Return.Value as IDataReader; List <BSPost> posts = new List <BSPost>(); while (dr.Read()) { BSPost post = new BSPost(); BSPost.FillPost(dr, post); posts.Add(post); } if (posts.Count > 0) { ltResult.Text = String.Format(Language.Get["SearchFoundedItemCount"], String.Format("<b>{0}</b>", posts.Count)); } else { ltResult.Text = Language.Get["SearchNotFound"]; } ltPaging.Visible = posts.Count > 0; rpSearch.DataSource = Data.Paging(posts, p, ltPaging); rpSearch.DataBind(); } catch (Exception) { } } }
protected void Page_Load(object sender, EventArgs e) { if (String.IsNullOrEmpty(SearchText)) Response.Redirect("~/"); using (DataProcess dp = new DataProcess()) { try { dp.AddParameter("Content", SearchText); dp.ExecuteReader("SELECT * FROM Posts WHERE Type = 0 AND State = 1 AND (Content LIKE @Content + ' %' OR Content LIKE '% ' + @Content OR Content LIKE '% ' + @Content + ' %')"); int p = 0; int.TryParse(Request["p"], out p); p = p == 0 ? 1 : p; IDataReader dr = dp.Return.Value as IDataReader; List<BSPost> posts = new List<BSPost>(); while (dr.Read()) { BSPost post = new BSPost(); BSPost.FillPost(dr, post); posts.Add(post); } if (posts.Count > 0) { ltResult.Text = String.Format(Language.Get["SearchFoundedItemCount"], String.Format("<b>{0}</b>", posts.Count)); } else ltResult.Text = Language.Get["SearchNotFound"]; ltPaging.Visible = posts.Count > 0; rpSearch.DataSource = Data.Paging(posts, p, ltPaging); rpSearch.DataBind(); } catch (Exception) { } } }
public static List<BSWidget> GetWidgetsByColumnValue(string column, object value, int widgetCount, string orderBy) { List<BSWidget> widgets = new List<BSWidget>(); using (DataProcess dp = new DataProcess()) { string top = widgetCount > 0 ? "TOP " + widgetCount : String.Empty; if (!String.IsNullOrEmpty(column) && value != null) { dp.AddParameter(column, value); dp.ExecuteReader(String.Format("SELECT {0} * FROM [Widgets] WHERE [{1}]=@{1} {2}", top, column, orderBy)); } else { dp.ExecuteReader(String.Format("SELECT {0} * FROM [Widgets] {1}", top, orderBy)); } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSWidget bsWidget = new BSWidget(); FillWidget(dr, bsWidget); widgets.Add(bsWidget); } } } } return widgets; }
public static List<BSWidget> GetWidgetsBySorted() { List<BSWidget> widgets = new List<BSWidget>(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("Visible", true); dp.ExecuteReader("SELECT * FROM Widgets WHERE [Visible] = @Visible ORDER BY [Sort]"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr.Read()) { BSWidget bsWidget = new BSWidget(); FillWidget(dr, bsWidget); widgets.Add(bsWidget); } } } } return widgets; }
public static List<BSWidget> GetWidgetsByPlaceHolder(string placeHolder, bool visible) { List<BSWidget> widgets = new List<BSWidget>(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("PlaceHolder", placeHolder); dp.AddParameter("Visible", visible); dp.ExecuteReader("SELECT * FROM [Widgets] WHERE [PlaceHolder]=@PlaceHolder AND [Visible]=@Visible ORDER BY [Sort]"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr.Read()) { BSWidget bsWidget = new BSWidget(); FillWidget(dr, bsWidget); widgets.Add(bsWidget); } } } } return widgets; }
public static BSMenuGroup GetMenuGroup(string menuCode) { using (DataProcess dp = new DataProcess()) { dp.AddParameter("Code", menuCode); dp.ExecuteReader("SELECT * FROM [MenuGroups] WHERE [Code]=@Code"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { if (dr != null && dr.Read()) { BSMenuGroup menuGroup = new BSMenuGroup(); FillMenuGroup(dr, menuGroup); return menuGroup; } } } } return null; }
public bool Remove() { using (DataProcess dp = new DataProcess()) { CancelEventArgs cancelEvent = new CancelEventArgs(); OnDeleting(this, cancelEvent); if (!cancelEvent.Cancel) { dp.AddParameter("CommentID", CommentID); dp.ExecuteNonQuery("DELETE FROM Comments WHERE [CommentID] = @CommentID"); if (dp.Return.Status == DataProcessState.Success) { OnDeleted(this, null); return true; } } } return false; }
public bool Save() { using (DataProcess dp = new DataProcess()) { dp.AddParameter("SiteID", SiteID); dp.AddParameter("Name", Name); dp.AddParameter("Description", Description); dp.AddParameter("Target", Target); dp.AddParameter("Url", Url); dp.AddParameter("LanguageCode", LanguageCode); if (LinkID != 0) { dp.AddParameter("LinkID", LinkID); dp.ExecuteNonQuery( "UPDATE Links SET [SiteID]=@SiteID,[Name]=@Name,[Description]=@Description,[Target]=@Target,[Url]=@Url,[LanguageCode]=@LanguageCode WHERE [LinkID]=@LinkID"); return dp.Return.Status == DataProcessState.Success; } else { dp.ExecuteNonQuery("INSERT INTO Links([SiteID],[Name],[Description],[Target],[Url],[LanguageCode]) VALUES(@SiteID,@Name,@Description,@Target,@Url,@LanguageCode)"); if (dp.Return.Status == DataProcessState.Success) { dp.ExecuteScalar("SELECT @@IDENTITY"); if (dp.Return.Status == DataProcessState.Success) { LinkID = Convert.ToInt32(dp.Return.Value); } return true; } } } return false; }
public static List<BSLink> GetLinks(int iTermID) { List<BSLink> links = new List<BSLink>(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("TermID", iTermID); dp.ExecuteReader("SELECT * FROM [Links] WHERE [LinkID] IN (SELECT [ObjectID] FROM [TermsTo] WHERE [TermID]=@TermID)"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSLink link = new BSLink(); FillLink(dr, link); links.Add(link); } } } } return links; }
public static List<BSComment> GetComments(CommentStates state, int iCommentCount) { List<BSComment> comments = new List<BSComment>(); using (DataProcess dp = new DataProcess()) { string top = iCommentCount == 0 ? String.Empty : "TOP " + iCommentCount; if (state == CommentStates.All) { dp.ExecuteReader(String.Format("SELECT {0} * FROM Comments ORDER By CreateDate DESC", top)); } else { dp.AddParameter("Approve", state == CommentStates.Approved); dp.ExecuteReader(String.Format("SELECT {0} * FROM Comments WHERE [Approve]=@Approve ORDER By CreateDate DESC", top)); } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSComment bsComment = new BSComment(); FillComment(dr, bsComment); comments.Add(bsComment); } } } } return comments; }
public static BSComment GetComment(int iCommentID) { using (DataProcess dp = new DataProcess()) { dp.AddParameter("CommentID", iCommentID); dp.ExecuteReader("SELECT * FROM Comments WHERE [CommentID]=@CommentID"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { if (dr != null && dr.Read()) { BSComment bsComment = new BSComment(); FillComment(dr, bsComment); return bsComment; } } } } return null; }
public bool Save() { bool bReturnValue = false; using (DataProcess dp = new DataProcess()) { dp.AddParameter("Description", this.Description); dp.AddParameter("MenuGroupID", this.MenuGroupID); dp.AddParameter("MenuType", (short)this.MenuType); dp.AddParameter("ObjectID", this.ObjectID); dp.AddParameter("ObjectType", (short)this.ObjectType); dp.AddParameter("ParentID", this.ParentID); dp.AddParameter("Sort", this.Sort); dp.AddParameter("Target", this.Target); dp.AddParameter("Title", this.Title); dp.AddParameter("Url", this.Url); if (MenuID != 0) { dp.AddParameter("MenuID", MenuID); dp.ExecuteNonQuery("UPDATE [Menus] SET [Description]=@Description,[MenuGroupID]=@MenuGroupID,[MenuType]=@MenuType," + "[ObjectID]=@ObjectID,[ObjectType]=@ObjectType,[ParentID]=@ParentID,[Sort]=@Sort,[Target]=@Target,[Title]=@Title,[Url]=@Url WHERE [MenuID] = @MenuID"); bReturnValue = dp.Return.Status == DataProcessState.Success; } else { dp.ExecuteNonQuery("INSERT INTO [Menus]([Description],[MenuGroupID],[MenuType],[ObjectID],[ObjectType],[ParentID],[Sort],[Target],[Title],[Url]) " + "VALUES(@Description,@MenuGroupID,@MenuType,@ObjectID,@ObjectType,@ParentID,@Sort,@Target,@Title,@Url)"); bReturnValue = dp.Return.Status == DataProcessState.Success; if (bReturnValue) { dp.ExecuteScalar("SELECT @@IDENTITY"); if (dp.Return.Status == DataProcessState.Success) { MenuID = Convert.ToInt32(dp.Return.Value); } } } } return bReturnValue; }
public static List<BSComment> GetCommentsByUserID(int iUserID, CommentStates state) { List<BSComment> comments = new List<BSComment>(); using (DataProcess dp = new DataProcess()) { if (state == CommentStates.All) { dp.AddParameter("UserID", iUserID); dp.ExecuteReader("SELECT * FROM Comments WHERE [UserID]=@UserID ORDER By CreateDate DESC"); } else { dp.AddParameter("UserID", iUserID); dp.AddParameter("Approve", state == CommentStates.Approved); dp.ExecuteReader("SELECT * FROM Comments WHERE [UserID]=@UserID AND [Approve]=@Approve ORDER By CreateDate DESC"); } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSComment bsComment = new BSComment(); FillComment(dr, bsComment); comments.Add(bsComment); } } } } return comments; }
public static List<BSMenu> GetMenus(int menuGroupID) { List<BSMenu> menus = new List<BSMenu>(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("MenuGroupID", menuGroupID); dp.ExecuteReader("SELECT * FROM [Menus] WHERE [MenuGroupID]=@MenuGroupID ORDER BY [Sort]"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSMenu menu = new BSMenu(); FillMenu(dr, menu); menus.Add(menu); } } } } return menus; }
public static BSMenu GetMenu(int menuID) { using (DataProcess dp = new DataProcess()) { dp.AddParameter("MenuID", menuID); dp.ExecuteReader("SELECT * FROM [Menus] WHERE [MenuID]=@MenuID"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { if (dr != null && dr.Read()) { BSMenu menu = new BSMenu(); FillMenu(dr, menu); return menu; } } } } return null; }
public bool Save() { bool bReturnValue = false; using (DataProcess dp = new DataProcess()) { dp.AddParameter("UserID", UserID); dp.AddParameter("PostID", PostID); dp.AddParameter("Name", UserName); dp.AddParameter("Comment", Content); dp.AddParameter("Email", Email); dp.AddParameter("WebPage", WebPage); dp.AddParameter("Ip", IP); dp.AddParameter("CreateDate", Date); dp.AddParameter("Approve", Approve); dp.AddParameter("NotifyMe", NotifyMe); if (CommentID != 0) { dp.AddParameter("CommentID", CommentID); dp.ExecuteNonQuery("UPDATE Comments SET [UserID]=@UserID,[PostID]=@PostID,[Name]=@Name,[Comment]=@Comment," + "[Email]=@Email,[WebPage]=@WebPage,[Ip]=@Ip,[CreateDate]=@CreateDate,[Approve]=@Approve,[NotifyMe]=@NotifyMe WHERE [CommentID] = @CommentID"); bReturnValue = dp.Return.Status == DataProcessState.Success; } else { dp.ExecuteNonQuery("INSERT INTO Comments([UserID],[PostID],[Name],[Comment],[Email],[WebPage],[Ip],[CreateDate],[Approve],[NotifyMe]) " + "VALUES(@UserID,@PostID,@Name,@Comment,@Email,@WebPage,@Ip,@CreateDate,@Approve,@NotifyMe)"); bReturnValue = dp.Return.Status == DataProcessState.Success; if (bReturnValue) { dp.ExecuteScalar("SELECT @@IDENTITY"); if (dp.Return.Status == DataProcessState.Success) { CommentID = Convert.ToInt32(dp.Return.Value); } } } } return bReturnValue; }
public static BSWidget GetWidget(string folderName) { using (DataProcess dp = new DataProcess()) { dp.AddParameter("FolderName", folderName); dp.ExecuteReader("SELECT * FROM Widgets WHERE [FolderName]=@FolderName"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { if (dr != null && dr.Read()) { BSWidget bsWidget = new BSWidget(); FillWidget(dr, bsWidget); return bsWidget; } } } } return null; }
public bool Save() { bool bReturnValue = false; using (DataProcess dp = new DataProcess()) { if (this.Default) { dp.AddParameter("Default", false); dp.ExecuteNonQuery("UPDATE [MenuGroups] SET [Default]=@Default"); } dp.AddParameter("SiteID", this.SiteID); dp.AddParameter("Code", this.Code); dp.AddParameter("Description", this.Description); dp.AddParameter("Title", this.Title); dp.AddParameter("Default", this.Default); dp.AddParameter("LanguageCode", this.LanguageCode); if (MenuGroupID != 0) { dp.AddParameter("MenuGroupID", this.MenuGroupID); dp.ExecuteNonQuery("UPDATE [MenuGroups] SET [SiteID]=@SiteID,[Code]=@Code,[Description]=@Description,[Title]=@Title,[Default]=@Default,[LanguageCode]=@LanguageCode WHERE [MenuGroupID] = @MenuGroupID"); bReturnValue = dp.Return.Status == DataProcessState.Success; if (bReturnValue) { foreach (BSMenu bsMenu in Menu) { bsMenu.Save(); } } } else { dp.ExecuteNonQuery("INSERT INTO [MenuGroups]([SiteID],[Code],[Description],[Title],[Default],[LanguageCode]) VALUES(@SiteID,@Code,@Description,@Title,@Default,@LanguageCode)"); bReturnValue = dp.Return.Status == DataProcessState.Success; if (bReturnValue) { foreach (BSMenu bsMenu in Menu) { bsMenu.Save(); } dp.ExecuteScalar("SELECT @@IDENTITY"); if (dp.Return.Status == DataProcessState.Success) { MenuGroupID = Convert.ToInt32(dp.Return.Value); } } } } return bReturnValue; }
public bool Save() { using (DataProcess dp = new DataProcess()) { dp.AddParameter("ParentID", this.ParentID); dp.AddParameter("UserID", this.UserID); dp.AddParameter("Code", this.Code); dp.AddParameter("State", this.State); string sql = "INSERT INTO Sites([ParentID],[UserID],[Code],[State]) " + "VALUES(@ParentID,@UserID,@Code,@State);"; if (SiteID != 0) { sql = "UPDATE Settings SET [ParentID]=@ParentID,[UserID]=@UserID,[Code]=@Code,[State]=@State WHERE [SiteID] = @SiteID;"; dp.AddParameter("SiteID", this.SiteID); } dp.ExecuteNonQuery(sql); return dp.Return.Status == DataProcessState.Success; } }
public bool Save() { bool bReturnValue = false; using (DataProcess dp = new DataProcess()) { dp.AddParameter("SiteID", this.SiteID); dp.AddParameter("Description", this.Description); dp.AddParameter("FolderName", this.FolderName); dp.AddParameter("PlaceHolder", this.PlaceHolder); dp.AddParameter("Sort", this.Sort); dp.AddParameter("Title", this.Title); dp.AddParameter("Visible", this.Visible); dp.AddParameter("Type", this.Type); dp.AddParameter("LanguageCode", this.LanguageCode); if (WidgetID != 0) { dp.AddParameter("WidgetID", WidgetID); dp.ExecuteNonQuery("UPDATE Widgets SET [SiteID]=@SiteID,[Description]=@Description,[FolderName]=@FolderName,[PlaceHolder]=@PlaceHolder,[Sort]=@Sort," + "[Title]=@Title,[Visible]=@Visible,[Type]=@Type,[LanguageCode]=@LanguageCode WHERE [WidgetID] = @WidgetID"); bReturnValue = dp.Return.Status == DataProcessState.Success; } else { dp.ExecuteNonQuery("INSERT INTO Widgets([SiteID],[Description],[FolderName],[PlaceHolder],[Sort],[Title],[Visible],[Type],[LanguageCode]) " + "VALUES(@SiteID,@Description,@FolderName,@PlaceHolder,@Sort,@Title,@Visible,@Type,@LanguageCode)"); bReturnValue = dp.Return.Status == DataProcessState.Success; if (bReturnValue) { dp.ExecuteScalar("SELECT @@IDENTITY"); if (dp.Return.Status == DataProcessState.Success) { WidgetID = Convert.ToInt32(dp.Return.Value); } } } } return bReturnValue; }
public bool Remove() { using (DataProcess dp = new DataProcess()) { CancelEventArgs cancelEvent = new CancelEventArgs(); OnDeleting(this, cancelEvent); if (!cancelEvent.Cancel) { dp.AddParameter("LinkID", LinkID); dp.ExecuteNonQuery("DELETE FROM [Links] WHERE [LinkID] = @LinkID"); dp.AddParameter("ObjectID", LinkID); dp.ExecuteNonQuery("DELETE FROM [TermsTo] WHERE [ObjectID] = @ObjectID"); if (dp.Return.Status == DataProcessState.Success) { OnDeleted(this, null); return true; } } } return false; }
public bool Save() { DataProcess dp = new DataProcess(); string sql = String.Empty; if (SettingID == 0) sql = "INSERT INTO Settings([SiteID],[Name],[Value],[Title],[Description],[Main],[Sort],[Visible]) " + "VALUES(@SiteID,@Name,@Value,@Title,@Description,@Main,@Sort,@Visible);"; else sql = "UPDATE Settings SET [SiteID]=@SiteID,[Name]=@Name,[Value]=@Value,[Title]=@Title,[Description]=@Description,[Main]=@Main,[Sort]=@Sort,[Visible]=@Visible WHERE [SettingID] = @SettingID;"; dp.AddParameter("SiteID", this.SiteID); dp.AddParameter("Name", this.Name); dp.AddParameter("Value", this.Value); dp.AddParameter("Title", this.Title); dp.AddParameter("Description", this.Description); dp.AddParameter("Main", this.Main); dp.AddParameter("Sort", this.Sort); dp.AddParameter("Visible", this.Visible); if (SettingID != 0) dp.AddParameter("SettingID", this.SettingID); dp.ExecuteNonQuery(sql); return dp.Return.Status == DataProcessState.Success; }
public static BSLink GetLink(int iLinkID) { using (DataProcess dp = new DataProcess()) { dp.AddParameter("LinkID", iLinkID); dp.ExecuteReader("SELECT * FROM Links WHERE [LinkID]=@LinkID"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { if (dr != null && dr.Read()) { BSLink link = new BSLink(); FillLink(dr, link); return link; } } } } return null; }
public static BSSetting GetSetting(int iSettingID) { BSSetting bsSetting = new BSSetting(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("SettingID", iSettingID); dp.ExecuteReader("SELECT * FROM Settings WHERE SettingID = @SettingID"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { if (dr.Read()) { FillValue(dr, bsSetting); return bsSetting; } } } } return null; }
public bool Remove() { using (DataProcess dp = new DataProcess()) { //CancelEventArgs cancelEvent = new CancelEventArgs(); //OnDeleting(this, cancelEvent); //if (!cancelEvent.Cancel) //{ dp.AddParameter("MenuGroupID", MenuGroupID); dp.ExecuteNonQuery("DELETE FROM [MenuGroups] WHERE [MenuGroupID] = @MenuGroupID"); if (dp.Return.Status == DataProcessState.Success) { //OnDeleted(this, null); return true; } //} } return false; }
public bool DoApprove(bool bApprove) { CancelEventArgs eventArgs = new CancelEventArgs(); BSComment bsComment = GetComment(CommentID); OnApproving(bsComment, eventArgs); if (!eventArgs.Cancel) { using (DataProcess dp = new DataProcess()) { dp.AddParameter("Approve", bApprove); dp.AddParameter("CommentID", CommentID); dp.ExecuteNonQuery("UPDATE Comments SET [Approve]=@Approve WHERE [CommentID]=@CommentID"); if (dp.Return.Status == DataProcessState.Success) { bsComment.Approve = bApprove; OnApproved(bsComment, null); return true; } } } return false; }
public static BSMenuGroup GetDefault() { using (DataProcess dp = new DataProcess()) { dp.AddParameter("Default", true); dp.ExecuteReader("SELECT * FROM [MenuGroups] WHERE [Default]=@Default"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { if (dr != null && dr.Read()) { BSMenuGroup menuGroup = new BSMenuGroup(); FillMenuGroup(dr, menuGroup); return menuGroup; } } } } BSMenuGroup defaultMenuGroup = new BSMenuGroup(); return defaultMenuGroup; }
public static void Delete(int iCommentID) { CancelEventArgs eventArgs = new CancelEventArgs(); BSComment bsComment = GetComment(iCommentID); BSComment.OnDeleting(bsComment, eventArgs); if (!eventArgs.Cancel) { using (DataProcess dp = new DataProcess()) { dp.AddParameter("CommentID", iCommentID); dp.ExecuteReader("DELETE FROM Comments WHERE [CommentID]=@CommentID"); if (dp.Return.Status == DataProcessState.Success) { BSComment.OnDeleted(bsComment, EventArgs.Empty); } } } }