CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/Party/WorkPlanEdit.aspx.cs

101 lines
3.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
namespace FineUIPro.Web.Party
{
public partial class WorkPlanEdit : PageBase
{
#region
/// <summary>
/// 页面加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string id = Request.Params["workPlanId"];
string year = DateTime.Now.Year.ToString();
if (!string.IsNullOrEmpty(Request.Params["Year"]))
{
year = Request.Params["Year"];
}
if (!string.IsNullOrEmpty(id))
{
Model.Party_WorkPlan workPlan = BLL.WorkPlanService.GetWorkPlanById(id);
if (workPlan != null)
{
this.hdId.Text = id;
if (workPlan.Year != null)
{
this.txtYear.Text = workPlan.Year.ToString();
}
}
}
else
{
this.txtYear.Text = year;
}
}
}
#endregion
#region
/// <summary>
/// 附件上传
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttach_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.hdId.Text)) //新增记录
{
this.hdId.Text = SQLHelper.GetNewID(typeof(Model.Party_WorkPlan));
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/Party/WorkPlan&menuId={1}", this.hdId.Text, BLL.Const.WorkPlanMenuId)));
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
string id = Request.Params["workPlanId"];
Model.Party_WorkPlan newWorkPlan = new Model.Party_WorkPlan();
newWorkPlan.Year = Funs.GetNewIntOrZero(this.txtYear.Text.Trim());
if (!string.IsNullOrEmpty(id))
{
newWorkPlan.WorkPlanId = id;
BLL.WorkPlanService.UpdateWorkPlan(newWorkPlan);
}
else
{
if (!string.IsNullOrEmpty(this.hdId.Text))
{
newWorkPlan.WorkPlanId = this.hdId.Text.Trim();
}
else
{
newWorkPlan.WorkPlanId = SQLHelper.GetNewID(typeof(Model.Party_WorkPlan));
this.hdId.Text = newWorkPlan.WorkPlanId;
}
newWorkPlan.CompileMan = this.CurrUser.UserId;
newWorkPlan.CompileDate = DateTime.Now;
BLL.WorkPlanService.AddWorkPlan(newWorkPlan);
}
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
}
}