FrmBoardEdit: Edit title and description of boards.
This commit is contained in:
@@ -54,7 +54,17 @@ namespace VAR.Focus.Web.Pages
|
||||
Board board = Boards.Current.Boards_SetBoard(0, _txtTitle.Text, _txtDescription.Text, CurrentUser.Name);
|
||||
_idBoard = board.IDBoard;
|
||||
|
||||
Response.Redirect(string.Format("{0}?idBoard={1}", "FrmBoard", _idBoard));
|
||||
Response.Redirect(string.Format("{0}?idBoard={1}", typeof(FrmBoard).Name, _idBoard));
|
||||
}
|
||||
|
||||
private void BtnEdit_Click(object sender, EventArgs e)
|
||||
{
|
||||
CButton btnEdit = (CButton)sender;
|
||||
int idBoard = Convert.ToInt32(btnEdit.CommandArgument);
|
||||
Response.Redirect(string.Format("{0}?idBoard={1}&returnUrl={2}",
|
||||
typeof(FrmBoardEdit).Name,
|
||||
idBoard,
|
||||
typeof(FrmBoard).Name));
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -64,9 +74,10 @@ namespace VAR.Focus.Web.Pages
|
||||
private Panel BoardSelector_Create(Board board)
|
||||
{
|
||||
var pnlBoardSelector = new Panel { CssClass = "boardBanner" };
|
||||
|
||||
var lnkTitle = new HyperLink
|
||||
{
|
||||
NavigateUrl = string.Format("{0}?idBoard={1}", "FrmBoard", board.IDBoard),
|
||||
NavigateUrl = string.Format("{0}?idBoard={1}", typeof(FrmBoard).Name, board.IDBoard),
|
||||
};
|
||||
var lblTitle = new CLabel
|
||||
{
|
||||
@@ -74,15 +85,23 @@ namespace VAR.Focus.Web.Pages
|
||||
CssClass = "title",
|
||||
};
|
||||
lnkTitle.Controls.Add(lblTitle);
|
||||
var pnlDescription = new Panel();
|
||||
pnlBoardSelector.Controls.Add(lnkTitle);
|
||||
|
||||
var lblDescription = new CLabel
|
||||
{
|
||||
Text = board.Description,
|
||||
Text = board.Description.Replace(" ", " ").Replace("\n", "<br>"),
|
||||
CssClass = "description",
|
||||
};
|
||||
pnlDescription.Controls.Add(lblDescription);
|
||||
pnlBoardSelector.Controls.Add(lnkTitle);
|
||||
pnlBoardSelector.Controls.Add(pnlDescription);
|
||||
pnlBoardSelector.Controls.Add(FormUtils.CreatePanel(lblDescription, ""));
|
||||
|
||||
var btnEdit = new CButton
|
||||
{
|
||||
ID = string.Format("btnEdit{0}", board.IDBoard),
|
||||
Text = "Edit",
|
||||
};
|
||||
btnEdit.CommandArgument = Convert.ToString(board.IDBoard);
|
||||
btnEdit.Click += BtnEdit_Click;
|
||||
pnlBoardSelector.Controls.Add(FormUtils.CreatePanel(btnEdit, "formRow"));
|
||||
|
||||
return pnlBoardSelector;
|
||||
}
|
||||
|
||||
122
VAR.Focus.Web/Pages/FrmBoardEdit.cs
Normal file
122
VAR.Focus.Web/Pages/FrmBoardEdit.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI.WebControls;
|
||||
using VAR.Focus.Web.Code;
|
||||
using VAR.Focus.Web.Code.BusinessLogic;
|
||||
using VAR.Focus.Web.Code.Entities;
|
||||
using VAR.Focus.Web.Controls;
|
||||
|
||||
namespace VAR.Focus.Web.Pages
|
||||
{
|
||||
public class FrmBoardEdit : PageCommon
|
||||
{
|
||||
#region Declarations
|
||||
|
||||
private int _idBoard = 0;
|
||||
|
||||
private CTextBox _txtTitle = new CTextBox { ID = "txtTitle", CssClassExtra = "width100pc", AllowEmpty = false };
|
||||
private CTextBox _txtDescription = new CTextBox { ID = "txtDescription", CssClassExtra = "width100pc", TextMode = TextBoxMode.MultiLine };
|
||||
private CButton _btnSave = new CButton { ID = "btnSave" };
|
||||
private CButton _btnExit = new CButton { ID = "btnExit" };
|
||||
|
||||
#endregion
|
||||
|
||||
#region Page life cycle
|
||||
|
||||
public FrmBoardEdit()
|
||||
{
|
||||
Init += FrmBoardEdit_Init;
|
||||
Load += FrmBoardEdit_Load;
|
||||
}
|
||||
|
||||
private void FrmBoardEdit_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (IsPostBack == false)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
void FrmBoardEdit_Init(object sender, EventArgs e)
|
||||
{
|
||||
string strIDBoard = Context.GetRequestParm("idBoard");
|
||||
if (String.IsNullOrEmpty(strIDBoard) == false)
|
||||
{
|
||||
_idBoard = Convert.ToInt32(strIDBoard);
|
||||
}
|
||||
if (_idBoard == 0)
|
||||
{
|
||||
Response.Redirect(typeof(FrmBoard).Name);
|
||||
}
|
||||
InitializeComponents();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UI Events
|
||||
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (FormUtils.Controls_AreValid(Controls) == false) { return; }
|
||||
|
||||
Board board = Boards.Current.Boards_SetBoard(_idBoard, _txtTitle.Text, _txtDescription.Text, CurrentUser.Name);
|
||||
|
||||
// FIXME: Notify User of "Save Succesfully"
|
||||
}
|
||||
|
||||
private void btnExit_Click(object sender, EventArgs e)
|
||||
{
|
||||
string returnUrl = Context.GetRequestParm("returnUrl");
|
||||
if (string.IsNullOrEmpty(returnUrl))
|
||||
{
|
||||
Response.Redirect(string.Format("{0}?idBoard={1}", typeof(FrmBoard).Name, _idBoard));
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Redirect(returnUrl);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private methods
|
||||
|
||||
private void InitializeComponents()
|
||||
{
|
||||
Title = "Register";
|
||||
var lblTitle = new CLabel { Text = "Register", Tag = "h2" };
|
||||
Controls.Add(lblTitle);
|
||||
|
||||
Controls.Add(FormUtils.CreateField("Title", _txtTitle));
|
||||
_txtTitle.NextFocusOnEnter = _txtTitle;
|
||||
_txtTitle.PlaceHolder = "Title";
|
||||
|
||||
Controls.Add(FormUtils.CreateField("Description", _txtDescription));
|
||||
_txtDescription.PlaceHolder = "Description";
|
||||
|
||||
_btnSave.Text = "Save";
|
||||
_btnSave.Click += btnSave_Click;
|
||||
|
||||
_btnExit.Text = "Exit";
|
||||
_btnExit.Click += btnExit_Click;
|
||||
|
||||
Panel pnlButtons = new Panel();
|
||||
pnlButtons.Controls.Add(_btnSave);
|
||||
pnlButtons.Controls.Add(_btnExit);
|
||||
Controls.Add(FormUtils.CreateField(String.Empty, pnlButtons));
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
Board board = Boards.Current.Board_GetByIDBoard(_idBoard);
|
||||
|
||||
_txtTitle.Text = board.Title;
|
||||
_txtDescription.Text = board.Description;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -101,6 +101,9 @@
|
||||
<Compile Include="Pages\FrmBoard.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Pages\FrmBoardEdit.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Pages\FrmEcho.cs" />
|
||||
<Compile Include="Pages\FrmLogin.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
|
||||
Reference in New Issue
Block a user