FrmBoard: Delete button.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using VAR.Focus.Web.Code.Entities;
|
using VAR.Focus.Web.Code.Entities;
|
||||||
|
|
||||||
namespace VAR.Focus.Web.Code.BusinessLogic
|
namespace VAR.Focus.Web.Code.BusinessLogic
|
||||||
@@ -46,7 +47,7 @@ namespace VAR.Focus.Web.Code.BusinessLogic
|
|||||||
public List<Board> Boards_GetListForUser(string userName)
|
public List<Board> Boards_GetListForUser(string userName)
|
||||||
{
|
{
|
||||||
// FIXME: filter by permissions
|
// FIXME: filter by permissions
|
||||||
return _boards;
|
return _boards.Where(board => board.Active).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Board Board_GetByIDBoard(int idBoard)
|
public Board Board_GetByIDBoard(int idBoard)
|
||||||
@@ -72,7 +73,6 @@ namespace VAR.Focus.Web.Code.BusinessLogic
|
|||||||
_lastIDBoard++;
|
_lastIDBoard++;
|
||||||
board = new Board();
|
board = new Board();
|
||||||
board.IDBoard = _lastIDBoard;
|
board.IDBoard = _lastIDBoard;
|
||||||
board.Active = true;
|
|
||||||
board.CreatedBy = userName;
|
board.CreatedBy = userName;
|
||||||
board.CreatedDate = currentDate;
|
board.CreatedDate = currentDate;
|
||||||
_boards.Add(board);
|
_boards.Add(board);
|
||||||
@@ -85,6 +85,8 @@ namespace VAR.Focus.Web.Code.BusinessLogic
|
|||||||
|
|
||||||
board.Title = title;
|
board.Title = title;
|
||||||
board.Description = description;
|
board.Description = description;
|
||||||
|
|
||||||
|
board.Active = true;
|
||||||
board.ModifiedBy = userName;
|
board.ModifiedBy = userName;
|
||||||
board.ModifiedDate = currentDate;
|
board.ModifiedDate = currentDate;
|
||||||
|
|
||||||
@@ -93,6 +95,29 @@ namespace VAR.Focus.Web.Code.BusinessLogic
|
|||||||
return board;
|
return board;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Boards_DelBoard(int idBoard, string userName)
|
||||||
|
{
|
||||||
|
DateTime currentDate = DateTime.UtcNow;
|
||||||
|
Board board;
|
||||||
|
if (idBoard == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
board = Board_GetByIDBoard(idBoard);
|
||||||
|
}
|
||||||
|
if (board == null) { return false; }
|
||||||
|
|
||||||
|
board.Active = false;
|
||||||
|
board.ModifiedBy = userName;
|
||||||
|
board.ModifiedDate = currentDate;
|
||||||
|
|
||||||
|
SaveData();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Private methods
|
#region Private methods
|
||||||
|
|||||||
@@ -67,6 +67,18 @@ namespace VAR.Focus.Web.Pages
|
|||||||
typeof(FrmBoard).Name));
|
typeof(FrmBoard).Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void BtnDelete_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
CButton btnEdit = (CButton)sender;
|
||||||
|
int idBoard = Convert.ToInt32(btnEdit.CommandArgument);
|
||||||
|
|
||||||
|
if (Boards.Current.Boards_DelBoard(idBoard, CurrentUser.Name))
|
||||||
|
{
|
||||||
|
Controls.Clear();
|
||||||
|
FrmBoard_InitIndex();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Private methods
|
#region Private methods
|
||||||
@@ -103,6 +115,15 @@ namespace VAR.Focus.Web.Pages
|
|||||||
btnEdit.CommandArgument = Convert.ToString(board.IDBoard);
|
btnEdit.CommandArgument = Convert.ToString(board.IDBoard);
|
||||||
btnEdit.Click += BtnEdit_Click;
|
btnEdit.Click += BtnEdit_Click;
|
||||||
pnlButtons.Controls.Add(btnEdit);
|
pnlButtons.Controls.Add(btnEdit);
|
||||||
|
var btnDelete = new CButton
|
||||||
|
{
|
||||||
|
ID = string.Format("btnDelete{0}", board.IDBoard),
|
||||||
|
Text = "Delete",
|
||||||
|
};
|
||||||
|
btnDelete.CommandArgument = Convert.ToString(board.IDBoard);
|
||||||
|
btnDelete.Click += BtnDelete_Click;
|
||||||
|
btnDelete.Attributes.Add("onclick", String.Format("return confirm('{0}');", "¿Are you sure to delete?"));
|
||||||
|
pnlButtons.Controls.Add(btnDelete);
|
||||||
pnlBoardSelector.Controls.Add(pnlButtons);
|
pnlBoardSelector.Controls.Add(pnlButtons);
|
||||||
|
|
||||||
return pnlBoardSelector;
|
return pnlBoardSelector;
|
||||||
|
|||||||
Reference in New Issue
Block a user