using BLL;
using System;
namespace FineUIPro.Web.HSSE.PostTraining
{
public partial class RoleEdit : PageBase
{
#region 定义项
///
/// 主键
///
public string Id
{
get
{
return (string)ViewState["Id"];
}
set
{
ViewState["Id"] = value;
}
}
/////
///// 项目主键
/////
//public string ProjectId
//{
// get
// {
// return (string)ViewState["ProjectId"];
// }
// set
// {
// ViewState["ProjectId"] = value;
// }
//}
#endregion
#region 加载
///
/// 加载页面
///
///
///
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//this.ProjectId = this.CurrUser.LoginProjectId;
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
//this.InitDropDownList();
this.Id = Request.Params["Id"];
if (!string.IsNullOrEmpty(this.Id))
{
Model.PostTraining_Role model = BLL.PostTrainingRoleService.GetRoleById(this.Id);
if (model != null)
{
this.txtCode.Text = model.Code;
this.txtName.Text = model.Name;
this.txtRemark.Text = model.Remark;
}
}
else
{
////自动生成编码
//this.txtCode.Text = SQLHelper.RunProcNewId2("SpGetNewCode3ByProjectId", "dbo.PostTraining_Role", "Code", CurrUser.LoginProjectId);
this.txtCode.Text = SQLHelper.RunProcNewId("SpGetNewCode3", "dbo.PostTraining_Role", "Code", "");
}
}
}
#endregion
#region 保存
///
/// 保存按钮
///
///
///
protected void btnSave_Click(object sender, EventArgs e)
{
this.SaveData(BLL.Const.BtnSave);
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
///
/// 保存数据
///
///
private void SaveData(string type)
{
Model.PostTraining_Role newModel = new Model.PostTraining_Role
{
//ProjectId = this.ProjectId,
Code = this.txtCode.Text.Trim(),
CompileDate = DateTime.Now,
CompileMan = this.CurrUser.UserId
};
newModel.Name = this.txtName.Text.Trim();
newModel.Remark = this.txtRemark.Text.Trim();
if (!string.IsNullOrEmpty(this.Id))
{
newModel.Id = this.Id;
BLL.PostTrainingRoleService.UpdateRole(newModel);
BLL.LogService.AddSys_Log(this.CurrUser, newModel.Code, newModel.Id, BLL.Const.PostTrainingRoleMenuId, BLL.Const.BtnModify);
}
else
{
this.Id = SQLHelper.GetNewID(typeof(Model.PostTraining_Role));
newModel.Id = this.Id;
BLL.PostTrainingRoleService.AddRole(newModel);
BLL.LogService.AddSys_Log(this.CurrUser, newModel.Code, newModel.Id, BLL.Const.PostTrainingRoleMenuId, BLL.Const.BtnAdd);
}
}
#endregion
#region 附件上传
/////
///// 上传附件
/////
/////
/////
//protected void btnAttachUrl_Click(object sender, EventArgs e)
//{
// if (string.IsNullOrEmpty(this.Id))
// {
// SaveData(BLL.Const.BtnSave);
// }
// PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/PostTraining/Role&menuId={1}", Id, BLL.Const.PostTrainingRoleMenuId)));
//}
#endregion
}
}