//=================================================== public void LoadBoardUIs() { BoardBLL boardBLL = new BoardBLL(); boards.Clear(); this.pnWorkSpace.Controls.Clear(); this.pnWorkSpace.Controls.Add(listActivityUI); this.pnWorkSpace.BackgroundImage = null; // boards = boardBLL.GetAllBoard(); boards = boardBLL.GetAllBoard(user.UserId); //foreach (Board bo in boards) for (int i = 0; i < boards.Count; i++) { Board bo = boards[i]; //BoardUI b = new BoardUI(bo.BoardId,bo.Index,bo.GroupId,bo.Title,bo.Mode,bo.Star,bo.Background); BoardUI b = new BoardUI(bo.BoardId, i, bo.GroupId, bo.Title, bo.Mode, bo.Star, bo.Background); boardUIs.Add(b); this.pnWorkSpace.Controls.Add(b); } BoardNoInfor boardNoInfor = new BoardNoInfor(this, boards.Count); this.pnWorkSpace.Controls.Add(boardNoInfor); }
public ActionResult BoardUpdate(Board iBoard) { if (ModelState.IsValid) { // Instantiate BoardMapper object BoardMapper lBoardMapper = new BoardMapper(); BoardDBO lBoardDBO = lBoardMapper.MapBoardTOBoardDBO(iBoard); // Instantiate BoardBLL object BoardBLL lBoardBLL = new BoardBLL(); // Update the board in database bool lResult = lBoardBLL.UpdateBoardByBoardID(lBoardDBO); if (lResult) { // success iBoard.type = 1; iBoard.message = "Successfully Updated!"; } else { // fail iBoard.type = -1; iBoard.message = "Failed to Update!"; } } else { iBoard.type = -1; iBoard.message = "Please Fill all required fields."; } return(RedirectToAction("BoardView", "Board", new { @id = iBoard.BoardIDPK })); }
public ActionResult UserProfile(int id, Common notice) { // Instantiate objects UserBLL lUserBLL = new UserBLL(); UserMapper lUserMapper = new UserMapper(); BoardBLL lBoardBLL = new BoardBLL(); RestaurantBLL lRestaurantBLL = new RestaurantBLL(); BoardCommentBLL lBoardCommentBLL = new BoardCommentBLL(); // Instantiate object to hold all info about user UserRestaurantBoardUtil lUserAllData = new UserRestaurantBoardUtil(); // Get info about user with id lUserAllData.UserData = lUserBLL.FindUserByID(id); // Get info about board with user id lUserAllData.BoardList = lBoardBLL.GetAllBoardsByUserID(id); lUserAllData.BoardCommentList = lBoardCommentBLL.GetAllCommentsByUserID(id); // Get info about order with user id lUserAllData.OrderList = lRestaurantBLL.GetAllOrdersByUserID(id); // number of rows per page lUserAllData.PageSize = 10; return(View(lUserAllData)); }
public ActionResult BoardUpdate(int id) { // Instantiate BoardBLL object BoardBLL lBoardBLL = new BoardBLL(); // check if the user requesting to edit the view is same user by boardID and UserID bool lIsSameUser = lBoardBLL.FindBoolSameUserByUserIDAndBoardID(id, Convert.ToInt32(Session["AUTHUserIDPK"])); // if it is different user who is requesting to edit the post, redirect to the view with error message if (!lIsSameUser) { int lBoardID = id; TempData["msg"] = "<script>alert('You are not authorized to edit.');</script>"; return(RedirectToAction("BoardView", "Board", new { id = lBoardID })); } // Find the board with id as primary key BoardDBO lBoardDBO = lBoardBLL.FindBoardByBoardID(id); // Instantiate Model.Board object BoardMapper lBoardMapper = new BoardMapper(); // Map to Model.Board Board lBoard = lBoardMapper.MapBoardDBOToBoard(lBoardDBO); return(View(lBoard)); }
public void TestInsertFunction() { BoardBLL boardBLL = new BoardBLL(); if (boardBLL.InsertBoard(2, "Project Test from client", 1, false, "NULL") == true) { MessageBox.Show("Success insert"); } else { MessageBox.Show("Can't insert"); } }
private void btnSave_Click(object sender, EventArgs e) { BoardBLL boardBLL = new BoardBLL(); ActivityBLL activityBLL = new ActivityBLL(); String title = tbTitle.Text; int mode = cbMode.SelectedIndex; bool star = false; if (string.IsNullOrEmpty(tbTitle.Text)) { MessageBox.Show("Tiêu đề không được để trống!", "Lỗi!!!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (this.background == "NULL") { DialogResult r = MessageBox.Show("Bạn có muốn lưu ảnh nền mặc định?", "Cảnh báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (r == DialogResult.OK) { if (cbTeam.SelectedIndex == 0) { //----no team--------- boardBLL.InsertBoard(this.index, title, mode, star, this.background); //add board for this user in user_board int boardID = boardBLL.GetMaxID(); boardBLL.AddUser(Global.user.UserId, boardID); activityBLL.InsertActivity(Global.user.UserId, boardID, Global.user.Name + " Has create new board: " + title, DateTime.Now); } this.DialogResult = DialogResult.OK; this.Close(); } } else { if (cbTeam.SelectedIndex == 0) { //----no team--------- boardBLL.InsertBoard(this.index, title, mode, star, this.background); //add board for this user in user_board int boardID = boardBLL.GetMaxID(); boardBLL.AddUser(Global.user.UserId, boardID); activityBLL.InsertActivity(Global.user.UserId, boardID, Global.user.Name + " Has create new board: " + title, DateTime.Now); } this.DialogResult = DialogResult.OK; this.Close(); } }
public ActionResult BoardCreate(Board iBoard) { // check if every input is valid if (ModelState.IsValid) { //get value from executing query int lResult = 0; // Instantiate Mapper object BoardMapper lBoardMapper = new BoardMapper(); // Map Model.Board to BoardDBO BoardDBO lBoardDBO = lBoardMapper.MapBoardTOBoardDBO(iBoard); // Instantiate DAL object BoardBLL lBoardBLL = new BoardBLL(); // Change the UserIDFK to Session["AUTHUserIDPK"] lBoardDBO.UserIDFK = Convert.ToInt32(Session["AUTHUserIDPK"]); // insert into the database lResult = lBoardBLL.CreateBoard(lBoardDBO); // Success if (lResult > 0) { // message on success TempData["msg"] = "<script>alert('Successfully Written!');</script>"; return(RedirectToAction("BoardList", "Board")); } // Failed to insert else { // message on failure iBoard.type = -1; iBoard.message = "Failed. Please try again."; } } // ModelState is not valid else { iBoard.type = -1; iBoard.message = "Please Fill all Required Information."; } return(View(iBoard)); }
public ActionResult BoardList(string category, string searchString) { // Instantiate Objects BoardBLL lBoardBLL = new BoardBLL(); BoardListUtil BoardListUtil = new BoardListUtil(); // Retreive list of posts that are in the same category and contain search string from database BoardListUtil.BoardList = lBoardBLL.GetAllBoards(category, searchString); // highlighting search string ViewBag.searchString = searchString; // categories for search bar BoardListUtil.CategoryList = new SelectList(lBoardBLL.GetAllBoardCategories(), "CategoryID", "CategoryName"); return(View(BoardListUtil)); }
private void cbListUser_SelectedIndexChanged(object sender, EventArgs e) { if (cbListUser.SelectedIndex != 0) { BoardBLL boardBLL = new BoardBLL(); ActivityBLL activityBLL = new ActivityBLL(); try { boardBLL.AddUser(userDTOs[cbListUser.SelectedIndex - 1].UserId, this.idBoard); activityBLL.InsertActivity(Global.user.UserId, this.idBoard, Global.user.Name + " Add " + userDTOs[cbListUser.SelectedIndex - 1].Name + " to " + this.title, DateTime.Now); MessageBox.Show("Add succedd" + userDTOs[cbListUser.SelectedIndex - 1].Name + " to " + this.title, "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { MessageBox.Show(cbListUser.SelectedText + "already exist in this board!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { this.cbListUser.Visible = false; } }
public ActionResult BoardRemove(int id) { // Instantiate BoardBLL object BoardBLL lBoardBLL = new BoardBLL(); // Remove data from database and get bool as return value bool lResult = lBoardBLL.RemoveBoardByBoardID(id); if (lResult) { // success TempData["msg"] = "<script>alert('Successfully Removed!');</script>"; } else { // fail TempData["msg"] = "<script>alert('Your request failed. Please try later.');</script>"; } return(RedirectToAction("BoardList", "Board")); }
public ActionResult BoardView(int id) { // Instantiate BCViewModel to pass three models BoardAndCommentsViewModel lBCViewModel = new BoardAndCommentsViewModel(); // Instantiate Mapper Objects BoardCommentMapper lBCMapper = new BoardCommentMapper(); BoardMapper lBoardMapper = new BoardMapper(); // Instantiate BLL Objects BoardBLL lBoardBLL = new BoardBLL(); BoardCommentBLL lBoardCommentBLL = new BoardCommentBLL(); // Retreive data for post from database based on BoardIDPK BoardDBO lBoardDBO = lBoardBLL.FindBoardByBoardID(id); // if there is no post with the id, redirect to board list with error message if (lBoardDBO == null) { TempData["msg"] = "<script>alert('Error occured while processing your request.')</script>"; return(RedirectToAction("BoardList", "Board")); } // Retreive data for comments from database based on BoardIDPK List <BoardCommentDBO> lBoardCommentDBOList = lBoardCommentBLL.GetAllCommentsByBoardID(id); // Map DB objects to Model.BoardComment lBCViewModel.BoardCommentList = lBCMapper.MapBoardCommentDBOToBoardComment(lBoardCommentDBOList); lBCViewModel.Board = lBoardMapper.MapBoardDBOToBoard(lBoardDBO); // set values for board comment lBCViewModel.BoardComment = new BoardComment(); lBCViewModel.BoardComment.BoardIDFK = lBCViewModel.Board.BoardIDPK; lBCViewModel.BoardComment.UserIDFK = Convert.ToInt32(Session["AUTHUserIDPK"]); return(View(lBCViewModel)); }