202 lines
7.5 KiB
C#
202 lines
7.5 KiB
C#
using BLL;
|
|
using System;
|
|
|
|
namespace FineUIPro.Web.HSSE.PostTraining
|
|
{
|
|
public partial class CourseEdit : PageBase
|
|
{
|
|
#region 定义项
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string Id
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["Id"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["Id"] = value;
|
|
}
|
|
}
|
|
///// <summary>
|
|
///// 项目主键
|
|
///// </summary>
|
|
//public string ProjectId
|
|
//{
|
|
// get
|
|
// {
|
|
// return (string)ViewState["ProjectId"];
|
|
// }
|
|
// set
|
|
// {
|
|
// ViewState["ProjectId"] = value;
|
|
// }
|
|
//}
|
|
#endregion
|
|
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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_Course model = BLL.PostTrainingCourseService.GetCourseById(this.Id);
|
|
if (model != null)
|
|
{
|
|
this.txtCode.Text = model.Code;
|
|
this.txtName.Text = model.Name;
|
|
this.txtRemark.Text = model.Remark;
|
|
if (!string.IsNullOrWhiteSpace(model.CategoryId))
|
|
{
|
|
this.drpCategory.SelectedValue = model.CategoryId;
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(model.Method1))
|
|
{
|
|
this.drpMethod1.SelectedValue = model.Method1;
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(model.Method2))
|
|
{
|
|
this.drpMethod2.SelectedValue = model.Method2;
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(model.Teachers1))
|
|
{
|
|
this.drpTeachers1.SelectedValue = model.Teachers1;
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(model.Teachers2))
|
|
{
|
|
this.drpTeachers2.SelectedValue = model.Teachers2;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
////自动生成编码
|
|
//this.txtCode.Text = SQLHelper.RunProcNewId2("SpGetNewCode3ByProjectId", "dbo.PostTraining_Course", "Code", CurrUser.LoginProjectId);
|
|
this.txtCode.Text = SQLHelper.RunProcNewId("SpGetNewCode5", "dbo.PostTraining_Course", "Code", "");
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 下拉框加载
|
|
/// </summary>
|
|
private void InitDropDownList()
|
|
{
|
|
//获取培训类别下拉框
|
|
PostTrainingCategoryService.InitPostTrainingCategoryDropDownList(this.drpCategory, false);
|
|
//获取培训方式一下拉框
|
|
PostTrainingMethodService.InitPostTrainingMethodDropDownList(this.drpMethod1, null, false);
|
|
//培训方式二
|
|
PostTrainingMethodService.InitPostTrainingMethodDropDownList(this.drpMethod2, this.drpMethod1.SelectedText, true);
|
|
//获取培训师资一下拉框
|
|
PostTrainingTeachersService.InitPostTrainingTeachersDropDownList(this.drpTeachers1, null, false);
|
|
//培训师资二
|
|
PostTrainingTeachersService.InitPostTrainingTeachersDropDownList(this.drpTeachers2, this.drpTeachers1.SelectedText, true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 培训方式一下拉加载
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void drpMethod1_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
//培训方式二
|
|
PostTrainingMethodService.InitPostTrainingMethodDropDownList(this.drpMethod2, this.drpMethod1.SelectedText, true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 培训师资一下拉加载
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void drpTeachers1_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
//培训师资二
|
|
PostTrainingTeachersService.InitPostTrainingTeachersDropDownList(this.drpTeachers2, this.drpTeachers1.SelectedText, true);
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
this.SaveData(BLL.Const.BtnSave);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存数据
|
|
/// </summary>
|
|
/// <param name="type"></param>
|
|
private void SaveData(string type)
|
|
{
|
|
Model.PostTraining_Course newModel = new Model.PostTraining_Course
|
|
{
|
|
//ProjectId = this.ProjectId,
|
|
Code = this.txtCode.Text.Trim(),
|
|
CompileDate = DateTime.Now,
|
|
CompileMan = this.CurrUser.UserId
|
|
};
|
|
newModel.Name = this.txtName.Text.Trim();
|
|
newModel.CategoryId = this.drpCategory.SelectedValue;
|
|
newModel.CategoryName = this.drpCategory.SelectedText;
|
|
newModel.Method1 = this.drpMethod1.SelectedValue;
|
|
newModel.Method2 = this.drpMethod2.SelectedValue;
|
|
newModel.Teachers1 = this.drpTeachers1.SelectedValue;
|
|
newModel.Teachers2 = this.drpTeachers2.SelectedValue;
|
|
newModel.Remark = this.txtRemark.Text.Trim();
|
|
|
|
if (!string.IsNullOrEmpty(this.Id))
|
|
{
|
|
newModel.Id = this.Id;
|
|
BLL.PostTrainingCourseService.UpdateCourse(newModel);
|
|
BLL.LogService.AddSys_Log(this.CurrUser, newModel.Code, newModel.Id, BLL.Const.PostTrainingCourseMenuId, BLL.Const.BtnModify);
|
|
}
|
|
else
|
|
{
|
|
this.Id = SQLHelper.GetNewID(typeof(Model.PostTraining_Course));
|
|
newModel.Id = this.Id;
|
|
BLL.PostTrainingCourseService.AddCourse(newModel);
|
|
BLL.LogService.AddSys_Log(this.CurrUser, newModel.Code, newModel.Id, BLL.Const.PostTrainingCourseMenuId, BLL.Const.BtnAdd);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 附件上传
|
|
///// <summary>
|
|
///// 上传附件
|
|
///// </summary>
|
|
///// <param name="sender"></param>
|
|
///// <param name="e"></param>
|
|
//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/Course&menuId={1}", Id, BLL.Const.PostTrainingCourseMenuId)));
|
|
//}
|
|
#endregion
|
|
}
|
|
} |