学习园地
This commit is contained in:
@@ -0,0 +1,154 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using BLL;
|
||||
|
||||
namespace FineUIPro.Web.HSSE.EduTrain
|
||||
{
|
||||
public partial class StudyZoneSave : PageBase
|
||||
{
|
||||
#region 定义变量
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
public string StudyZoneId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["StudyZoneId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["StudyZoneId"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上级ID
|
||||
/// </summary>
|
||||
public string SupStudyZoneId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["SupStudyZoneId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["SupStudyZoneId"] = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 加载
|
||||
/// <summary>
|
||||
/// 加载页面
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
this.GetButtonPower();
|
||||
btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
||||
|
||||
this.drpIsEndLever.DataTextField = "TypeName";
|
||||
drpIsEndLever.DataValueField = "TypeId";
|
||||
drpIsEndLever.DataSource = BLL.TrainingService.GetIsEndLeverList();
|
||||
drpIsEndLever.DataBind();
|
||||
|
||||
this.StudyZoneId = Request.QueryString["StudyZoneId"];
|
||||
this.SupStudyZoneId = Request.QueryString["SupStudyZoneId"];
|
||||
if (!string.IsNullOrEmpty(StudyZoneId))
|
||||
{
|
||||
var q = BLL.StudyZoneService.GetStudyZoneById(StudyZoneId);
|
||||
if (q != null)
|
||||
{
|
||||
txtStudyZoneCode.Text = q.StudyZoneCode;
|
||||
txtStudyZoneName.Text = q.StudyZoneName;
|
||||
if (q.IsEndLever == true)
|
||||
{
|
||||
this.drpIsEndLever.SelectedValue = "true";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.drpIsEndLever.SelectedValue = "false";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 保存
|
||||
/// <summary>
|
||||
/// 保存按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
Model.Training_StudyZone model = new Model.Training_StudyZone();
|
||||
model.StudyZoneCode = this.txtStudyZoneCode.Text.Trim();
|
||||
model.StudyZoneName = this.txtStudyZoneName.Text.Trim();
|
||||
model.IsEndLever = Convert.ToBoolean(drpIsEndLever.SelectedValue);
|
||||
if (!string.IsNullOrEmpty(this.StudyZoneId))
|
||||
{
|
||||
Model.Training_StudyZone t = BLL.StudyZoneService.GetStudyZoneById(this.StudyZoneId);
|
||||
if (t != null)
|
||||
{
|
||||
model.SupStudyZoneId = t.SupStudyZoneId;
|
||||
}
|
||||
model.StudyZoneId = this.StudyZoneId;
|
||||
BLL.StudyZoneService.UpdateStudyZone(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
model.SupStudyZoneId = this.SupStudyZoneId;
|
||||
this.StudyZoneId = SQLHelper.GetNewID(typeof(Model.Training_StudyZone));
|
||||
model.StudyZoneId = this.StudyZoneId;
|
||||
BLL.StudyZoneService.AddStudyZone(model);
|
||||
}
|
||||
// 2. 关闭本窗体,然后刷新父窗体
|
||||
// PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
||||
// 2. 关闭本窗体,然后回发父窗体
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||||
//PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(trainingId) + ActiveWindow.GetHideReference());
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 验证学习园地资料名称是否存在
|
||||
/// <summary>
|
||||
/// 验证学习园地资料名称是否存在
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
var model = Funs.DB.Training_StudyZone.FirstOrDefault(x => x.SupStudyZoneId == this.SupStudyZoneId && x.StudyZoneName == this.txtStudyZoneName.Text.Trim() && (x.StudyZoneId != this.StudyZoneId || (this.StudyZoneId == null && x.StudyZoneId != null)));
|
||||
if (model != null)
|
||||
{
|
||||
ShowNotify("输入的名称已存在!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 按钮权限
|
||||
/// <summary>
|
||||
/// 获取按钮权限
|
||||
/// </summary>
|
||||
/// <param name="button"></param>
|
||||
/// <returns></returns>
|
||||
private void GetButtonPower()
|
||||
{
|
||||
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.StudyZoneMenuId);
|
||||
if (buttonList.Count() > 0)
|
||||
{
|
||||
if (buttonList.Contains(BLL.Const.BtnSave))
|
||||
{
|
||||
this.btnSave.Hidden = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user