SGGL_SHJ/SGGL/FineUIPro.Web/Person/PersonItemEdit.aspx.cs

247 lines
9.4 KiB
C#

using BLL;
using System;
namespace FineUIPro.Web.Person
{
public partial class PersonItemEdit : PageBase
{
#region
/// <summary>
/// 人员主键
/// </summary>
private string PersonId
{
get
{
return (string)ViewState["PersonId"];
}
set
{
ViewState["PersonId"] = value;
}
}
/// <summary>
/// 主键
/// </summary>
private string PersonItemId
{
get
{
return (string)ViewState["PersonItemId"];
}
set
{
ViewState["PersonItemId"] = value;
}
}
#endregion
#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();
this.PersonId = Request.Params["PersonId"];
this.PersonItemId = Request.Params["PersonItemId"];
UnitService.InitUnitDropDownList(this.drpUnit, null, true);
ProjectService.InitAllProjectDropDownList(this.drpProject, true);
Funs.FineUIPleaseSelect(this.drpTeamGroup);
WorkPostService.InitWorkPostDropDownList(this.drpWorkPost, true);
if (!string.IsNullOrEmpty(this.PersonItemId))
{
var getData = BLL.SitePerson_PersonItemService.getDataById(this.PersonItemId);
if (getData != null)
{
this.PersonId = getData.PersonId;
this.drpUnit.SelectedValue = getData.UnitId;
this.txtUnitName.Text = getData.UnitName;
this.drpProject.SelectedValue = getData.ProjectId;
this.txtProjectName.Text = getData.ProjectName;
this.txtTeamGroupName.Text = getData.TeamGroupName;
this.drpWorkPost.SelectedValue = getData.WorkPostId;
this.txtWorkPostName.Text = getData.WorkPostName;
this.txtInTime.Text = string.Format("{0:yyyy-MM-dd}", getData.InTime);
this.txtOutTime.Text = string.Format("{0:yyyy-MM-dd}", getData.OutTime);
this.txtOutResult.Text = getData.OutResult;
TeamGroupService.InitTeamGroupProjectUnitDropDownList(this.drpTeamGroup, getData.ProjectId,getData.UnitId, true);
this.drpTeamGroup.SelectedValue = getData.TeamGroupId;
}
}
var person = BLL.Person_PersonsService.GetPerson_PersonsById(this.PersonId);
if (person != null)
{
this.txtPersonName.Text = person.PersonName;
this.txtIdentityCard.Text = person.IdentityCard;
}
if (Request.Params["value"] == "0")
{
this.btnSave.Hidden = true;
}
}
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
SaveData();
}
/// <summary>
/// 保存数据
/// </summary>
private void SaveData()
{
if (!String.IsNullOrEmpty(this.PersonId))
{
Model.SitePerson_PersonItem newData = new Model.SitePerson_PersonItem
{
PersonId = this.PersonId,
PersonItemId = this.PersonItemId,
InTime = Funs.GetNewDateTime(this.txtInTime.Text.Trim()),
OutTime = Funs.GetNewDateTime(this.txtOutTime.Text.Trim()),
OutResult = this.txtOutResult.Text.Trim(),
};
if (!string.IsNullOrEmpty(this.drpProject.SelectedValue) && this.drpProject.SelectedValue != Const._Null)
{
newData.ProjectId = this.drpProject.SelectedValue;
newData.ProjectName = ProjectService.GetProjectNameByProjectId(newData.ProjectId);
}
else
{
newData.ProjectName = this.txtProjectName.Text.Trim();
}
if (!string.IsNullOrEmpty(this.drpUnit.SelectedValue) && this.drpUnit.SelectedValue != Const._Null)
{
newData.UnitId = this.drpUnit.SelectedValue;
newData.UnitName = UnitService.GetUnitNameByUnitId(newData.UnitId);
}
else
{
newData.UnitName = this.txtUnitName.Text.Trim();
}
if (!string.IsNullOrEmpty(this.drpWorkPost.SelectedValue) && this.drpWorkPost.SelectedValue != Const._Null)
{
newData.WorkPostId = this.drpWorkPost.SelectedValue;
newData.WorkPostName = WorkPostService.getWorkPostNameById(newData.WorkPostId);
}
else
{
newData.WorkPostName = this.txtWorkPostName.Text.Trim();
}
if (!string.IsNullOrEmpty(this.drpTeamGroup.SelectedValue) && this.drpTeamGroup.SelectedValue != Const._Null)
{
newData.TeamGroupId = this.drpTeamGroup.SelectedValue;
newData.TeamGroupName = TeamGroupService.GetTeamGroupNameByTeamGroupId(newData.TeamGroupId);
}
else
{
newData.TeamGroupName = this.txtTeamGroupName.Text.Trim();
}
if (!string.IsNullOrEmpty(this.PersonItemId))
{
BLL.SitePerson_PersonItemService.UpdatePersonItem(newData);
BLL.LogService.AddSys_Log(this.CurrUser, newData.PersonName, newData.PersonItemId, BLL.Const.ProjectPersonMenuId, BLL.Const.BtnModify);
}
else
{
this.PersonItemId = SQLHelper.GetNewID();
newData.PersonItemId = this.PersonItemId;
BLL.SitePerson_PersonItemService.AddPersonItem(newData,null);
BLL.LogService.AddSys_Log(this.CurrUser, newData.PersonName, newData.PersonItemId, BLL.Const.ProjectPersonMenuId, BLL.Const.BtnAdd);
}
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
}
#endregion
#region
/// <summary>
/// 项目下拉框事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpProject_SelectedIndexChanged(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.drpProject.SelectedValue) && this.drpProject.SelectedValue != Const._Null)
{
this.txtProjectName.Text = this.drpProject.SelectedText;
}
SetTeam();
}
/// <summary>
/// 单位下拉框事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e)
{
if(!string.IsNullOrEmpty(this.drpUnit.SelectedValue) && this.drpUnit.SelectedValue != Const._Null)
{
this.txtUnitName.Text = this.drpUnit.SelectedText;
}
SetTeam();
}
/// <summary>
/// 班组事件事件
/// </summary>
private void SetTeam()
{
string unitId = null;
if (!string.IsNullOrEmpty(this.drpUnit.SelectedValue) && this.drpUnit.SelectedValue != Const._Null)
{
unitId = this.drpUnit.SelectedValue;
}
TeamGroupService.InitTeamGroupProjectUnitDropDownList(this.drpTeamGroup, this.drpProject.SelectedValue, unitId, true);
}
/// <summary>
/// 班组下拉框事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpTeamGroup_SelectedIndexChanged(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.drpTeamGroup.SelectedValue) && this.drpTeamGroup.SelectedValue != Const._Null)
{
this.txtTeamGroupName.Text = this.drpTeamGroup.SelectedText;
}
}
/// <summary>
/// 岗位下拉框事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpWorkPost_SelectedIndexChanged(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.drpWorkPost.SelectedValue) && this.drpWorkPost.SelectedValue != Const._Null)
{
this.txtWorkPostName.Text = this.drpWorkPost.SelectedText;
}
}
#endregion
}
}