using BLL; using System; namespace FineUIPro.Web.Person { public partial class PersonContractEdit : PageBase { #region 定义项 /// /// 人员主键 /// private string PersonId { get { return (string)ViewState["PersonId"]; } set { ViewState["PersonId"] = value; } } /// /// 主键 /// private string PersonContractId { get { return (string)ViewState["PersonContractId"]; } set { ViewState["PersonContractId"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.PersonId = Request.Params["PersonId"]; this.PersonContractId = Request.Params["PersonContractId"]; ProjectService.InitAllProjectDropDownList(this.drpProject, true); if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId)) { this.drpProject.SelectedValue = this.CurrUser.LoginProjectId; } UnitService.InitUnitDropDownList(this.drpUnit, null, true); if (!string.IsNullOrEmpty(this.CurrUser.UnitId)) { this.drpUnit.SelectedValue = this.CurrUser.UnitId; } Funs.FineUIPleaseSelect(this.drpLeadMan); DropListService.InitConstDropDownList(this.drpContractType, DropListService.Group_ContractType, false); if (!string.IsNullOrEmpty(this.PersonContractId)) { var getData = BLL.Person_PersonContractService.getDataById(this.PersonContractId); if (getData != null) { this.PersonId = getData.PersonId; this.drpUnit.SelectedValue = getData.UnitId; this.drpProject.SelectedValue = getData.ProjectId; this.txtTelephone.Text = getData.Telephone; this.drpContractType.SelectedValue = getData.ContractType; this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", getData.StartDate); this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", getData.EndDate); Person_PersonsService.InitFlowOperateControlUserDropDownList(this.drpLeadMan, null, this.drpUnit.SelectedValue, true); this.drpLeadMan.SelectedValue = getData.LeadManId; } } 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 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { SaveData(); } /// /// 保存数据 /// private void SaveData() { if (!String.IsNullOrEmpty(this.PersonId)) { Model.Person_PersonContract newData = new Model.Person_PersonContract { PersonId = this.PersonId, PersonContractId = this.PersonContractId, StartDate = Funs.GetNewDateTime(this.txtStartDate.Text.Trim()), EndDate = Funs.GetNewDateTime(this.txtEndDate.Text.Trim()), Telephone = this.txtTelephone.Text.Trim(), }; if (!string.IsNullOrEmpty(this.drpProject.SelectedValue) && this.drpProject.SelectedValue != Const._Null) { newData.ProjectId = this.drpProject.SelectedValue; } if (!string.IsNullOrEmpty(this.drpUnit.SelectedValue) && this.drpUnit.SelectedValue != Const._Null) { newData.UnitId = this.drpUnit.SelectedValue; } if (!string.IsNullOrEmpty(this.drpLeadMan.SelectedValue) && this.drpLeadMan.SelectedValue != Const._Null) { newData.LeadManId = this.drpLeadMan.SelectedValue; } if (!string.IsNullOrEmpty(this.drpContractType.SelectedValue) && this.drpContractType.SelectedValue != Const._Null) { newData.ContractType = this.drpContractType.SelectedValue; } if (!string.IsNullOrEmpty(this.PersonContractId)) { BLL.Person_PersonContractService.UpdateData(newData); BLL.LogService.AddSys_Log(this.CurrUser, this.txtIdentityCard.Text, newData.PersonContractId, BLL.Const.ProjectPersonMenuId, BLL.Const.BtnModify); } else { this.PersonContractId = SQLHelper.GetNewID(); newData.PersonContractId = this.PersonContractId; BLL.Person_PersonContractService.AddData(newData); BLL.LogService.AddSys_Log(this.CurrUser, this.txtIdentityCard.Text, newData.PersonContractId, BLL.Const.ProjectPersonMenuId, BLL.Const.BtnAdd); } PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); } } #endregion #region 下拉框事件 /// /// 单位下拉框事件 /// /// /// protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e) { Person_PersonsService.InitFlowOperateControlUserDropDownList(this.drpLeadMan, null, this.drpUnit.SelectedValue, true); } /// /// 合同下拉框事件 /// /// /// protected void drpContractType_SelectedIndexChanged(object sender, EventArgs e) { if (this.drpContractType.SelectedValue == "1") { this.txtStartDate.Hidden = false; this.txtEndDate.Hidden = false; } else { this.txtStartDate.Hidden = true; this.txtEndDate.Hidden = true; } } /// /// /// /// /// protected void drpLeadMan_SelectedIndexChanged(object sender, EventArgs e) { var getPerson = Person_PersonsService.GetPerson_PersonsById(this.drpLeadMan.SelectedValue); if (getPerson != null) { this.txtTelephone.Text = getPerson.Telephone; } } #endregion } }