xinjiang/SGGL/FineUIPro.Web/Person/PersonPlanEdit.aspx.cs

169 lines
7.5 KiB
C#

using BLL;
using System;
namespace FineUIPro.Web.Person
{
public partial class PersonPlanEdit : PageBase
{
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
//加载下拉列表
BLL.DepartService.InitDepartDropDownList(this.drpDepartId, true);
BLL.ProjectService.InitAllProjectDropDownList(this.drpProjectId, true);
this.drpUserId.DataTextField = "UserName";
this.drpUserId.DataValueField = "UserId";
this.drpUserId.DataSource = BLL.UserService.GetUserList();
this.drpUserId.DataBind();
Funs.FineUIPleaseSelect(this.drpUserId);
this.drpPersonType.DataTextField = "Text";
this.drpPersonType.DataValueField = "Value";
this.drpPersonType.DataSource = BLL.DropListService.drpPersonTypeList();
this.drpPersonType.DataBind();
string personPlanId = Request.Params["PersonPlanId"];
if (!string.IsNullOrEmpty(personPlanId))
{
var personPlan = BLL.Person_PersonPlanService.GetPersonPlanById(personPlanId);
if (personPlan != null)
{
if (!string.IsNullOrEmpty(personPlan.DepartId))
{
this.drpDepartId.SelectedValue = personPlan.DepartId;
}
if (!string.IsNullOrEmpty(personPlan.UserId))
{
this.drpUserId.SelectedValue = personPlan.UserId;
}
this.txtMajor.Text = personPlan.Major;
if (!string.IsNullOrEmpty(personPlan.ProjectId))
{
this.drpProjectId.SelectedValue = personPlan.ProjectId;
}
if (!string.IsNullOrEmpty(personPlan.PersonType))
{
this.drpPersonType.SelectedValue = personPlan.PersonType.Trim();
}
this.txtYear.Text = personPlan.Years.HasValue ? personPlan.Years.ToString() : "";
if (personPlan.Month1 == true)
{
this.checkbox1.Checked = true;
}
if (personPlan.Month2 == true)
{
this.checkbox2.Checked = true;
}
if (personPlan.Month3 == true)
{
this.checkbox3.Checked = true;
}
if (personPlan.Month4 == true)
{
this.checkbox4.Checked = true;
}
if (personPlan.Month5 == true)
{
this.checkbox5.Checked = true;
}
if (personPlan.Month6 == true)
{
this.checkbox6.Checked = true;
}
if (personPlan.Month7 == true)
{
this.checkbox7.Checked = true;
}
if (personPlan.Month8 == true)
{
this.checkbox8.Checked = true;
}
if (personPlan.Month9 == true)
{
this.checkbox9.Checked = true;
}
if (personPlan.Month10 == true)
{
this.checkbox10.Checked = true;
}
if (personPlan.Month11 == true)
{
this.checkbox11.Checked = true;
}
if (personPlan.Month12 == true)
{
this.checkbox12.Checked = true;
}
this.txtRemark.Text = personPlan.Remark;
}
}
else
{
this.txtYear.Text = DateTime.Now.Year.ToString();
}
}
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
string personPlanId = Request.Params["PersonPlanId"];
Model.Person_PersonPlan newPersonPlan = new Model.Person_PersonPlan();
if (this.drpDepartId.SelectedValue != BLL.Const._Null)
{
newPersonPlan.DepartId = this.drpDepartId.SelectedValue;
}
if (this.drpUserId.SelectedValue != BLL.Const._Null)
{
newPersonPlan.UserId = this.drpUserId.SelectedValue;
}
newPersonPlan.Major = this.txtMajor.Text.Trim();
if (this.drpProjectId.SelectedValue != BLL.Const._Null)
{
newPersonPlan.ProjectId = this.drpProjectId.SelectedValue;
}
newPersonPlan.PersonType = this.drpPersonType.SelectedValue.Trim();
newPersonPlan.Years = Funs.GetNewInt(this.txtYear.Text.Trim());
newPersonPlan.Month1 = this.checkbox1.Checked == true ? true : false;
newPersonPlan.Month2 = this.checkbox2.Checked == true ? true : false;
newPersonPlan.Month3 = this.checkbox3.Checked == true ? true : false;
newPersonPlan.Month4 = this.checkbox4.Checked == true ? true : false;
newPersonPlan.Month5 = this.checkbox5.Checked == true ? true : false;
newPersonPlan.Month6 = this.checkbox6.Checked == true ? true : false;
newPersonPlan.Month7 = this.checkbox7.Checked == true ? true : false;
newPersonPlan.Month8 = this.checkbox8.Checked == true ? true : false;
newPersonPlan.Month9 = this.checkbox9.Checked == true ? true : false;
newPersonPlan.Month10 = this.checkbox10.Checked == true ? true : false;
newPersonPlan.Month11 = this.checkbox11.Checked == true ? true : false;
newPersonPlan.Month12 = this.checkbox12.Checked == true ? true : false;
newPersonPlan.Remark = this.txtRemark.Text.Trim();
if (!string.IsNullOrEmpty(personPlanId))
{
newPersonPlan.PersonPlanId = personPlanId;
BLL.Person_PersonPlanService.UpdatePersonPlan(newPersonPlan);
}
else
{
newPersonPlan.PersonPlanId = SQLHelper.GetNewID(typeof(Model.Person_PersonPlan));
BLL.Person_PersonPlanService.AddPersonPlan(newPersonPlan);
}
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
}
}