using BLL; using System; using System.Linq; namespace FineUIPro.Web.OfficeCheck.Check { public partial class CheckNoticeEdit : PageBase { #region 定义项 /// /// 检查通知主键 /// public string CheckNoticeId { get { return (string)ViewState["CheckNoticeId"]; } set { ViewState["CheckNoticeId"] = value; } } #endregion #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.GetButtonPower(); BLL.UnitService.InitSeDinAndCNCECUnitDropDownList(this.drpUnit, false); BLL.DepartService.InitDepartDropDownList(this.drpDepart, true); this.drpDepart.SelectedValue = Const.Depart_constructionId; BLL.Person_PersonsService.InitUserUnitIdDepartIdDropDownList(this.drpCheckTeamLeader, this.drpUnit.SelectedValue, string.Empty, true); BLL.ProjectService.InitProjectDropDownList(this.drpSubjectProject, true); this.CheckNoticeId = Request.Params["CheckNoticeId"]; if (!string.IsNullOrEmpty(this.CheckNoticeId)) { var checkNotice = BLL.CheckNoticeService.GetCheckNoticeById(this.CheckNoticeId); if (checkNotice != null) { this.txtCheckStartTime.Text = string.Format("{0:yyyy-MM-dd}", checkNotice.CheckStartTime); this.txtCheckEndTime.Text = string.Format("{0:yyyy-MM-dd}", checkNotice.CheckEndTime); if (!string.IsNullOrEmpty(checkNotice.SubjectProjectId)) { this.drpSubjectProject.SelectedValue = checkNotice.SubjectProjectId; SitePerson_PersonService.InitSitePersonDropDownList(this.drpSubjectUnitMan, checkNotice.SubjectProjectId, Const.UnitId_SEDIN, null, null, true); this.drpSubjectUnitMan.SelectedValue = checkNotice.SubjectUnitMan; } this.drpUnit.SelectedValue = checkNotice.UnitId; this.drpDepart.SelectedValue = checkNotice.DepartId; this.drpCheckTeamLeader.SelectedValue = checkNotice.SubjectUnitMan; this.txtSubjectUnitAdd.Text = checkNotice.SubjectUnitAdd; this.txtSubjectUnitTel.Text = checkNotice.SubjectUnitTel; this.drpSex.SelectedValue = checkNotice.SexName; this.hdUserId.Text = checkNotice.CheckTeamLeader; } } else { this.txtCheckStartTime.Text = string.Format("{0:yyyy-MM-dd}", System.DateTime.Now); this.txtCheckEndTime.Text = string.Format("{0:yyyy-MM-dd}", System.DateTime.Now.AddDays(3)); } } } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (this.drpCheckTeamLeader.SelectedValue == Const._Null) { ShowNotify("请先填写检查组长!", MessageBoxIcon.Warning); return; } Model.ProjectSupervision_CheckNotice newCheckNotice = new Model.ProjectSupervision_CheckNotice(); newCheckNotice.SubjectUnitAdd = this.txtSubjectUnitAdd.Text.Trim(); if (this.drpSubjectUnitMan.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpSubjectUnitMan.SelectedValue)) { newCheckNotice.SubjectUnitMan = this.drpSubjectUnitMan.SelectedValue; } newCheckNotice.SubjectUnitTel = this.txtSubjectUnitTel.Text.Trim(); newCheckNotice.CheckStartTime = Funs.GetNewDateTime(this.txtCheckStartTime.Text).Value; newCheckNotice.CheckEndTime = Funs.GetNewDateTime(this.txtCheckEndTime.Text).Value; newCheckNotice.CompileMan = this.CurrUser.PersonId; newCheckNotice.CompileDate = DateTime.Now; if (this.drpCheckTeamLeader.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpCheckTeamLeader.SelectedValue)) { newCheckNotice.CheckTeamLeader = this.drpCheckTeamLeader.SelectedValue; } newCheckNotice.CheckTeamLeaderName = this.drpCheckTeamLeader.SelectedText; if (this.drpSubjectProject.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpSubjectProject.SelectedValue)) { newCheckNotice.SubjectProjectId = this.drpSubjectProject.SelectedValue; } if (this.drpSex.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpSex.SelectedValue)) { newCheckNotice.SexName = this.drpSex.SelectedValue; } if (this.drpUnit.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpUnit.SelectedValue)) { newCheckNotice.UnitId = this.drpUnit.SelectedValue; } if (this.drpDepart.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpDepart.SelectedValue)) { newCheckNotice.DepartId = this.drpDepart.SelectedValue; } if (string.IsNullOrEmpty(this.CheckNoticeId)) { newCheckNotice.CheckNoticeId = SQLHelper.GetNewID(); BLL.CheckNoticeService.AddCheckNotice(newCheckNotice); BLL.LogService.AddSys_Log(this.CurrUser, newCheckNotice.CheckTeamLeaderName, newCheckNotice.CheckNoticeId, BLL.Const.CheckNoticeMenuId, BLL.Const.BtnAdd); } else { newCheckNotice.CheckNoticeId = this.CheckNoticeId; BLL.CheckNoticeService.UpdateCheckNotice(newCheckNotice); BLL.LogService.AddSys_Log(this.CurrUser, newCheckNotice.CheckTeamLeaderName, newCheckNotice.CheckNoticeId, BLL.Const.CheckNoticeMenuId, BLL.Const.BtnAdd); } ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion #region 受检单位下拉框事件 /// /// 受检单位下拉框事件 /// /// /// protected void drpSubjectProject_OnSelectedIndexChanged(object sender, EventArgs e) { var units = BLL.ProjectService.GetProjectByProjectId(this.drpSubjectProject.SelectedValue); if (units != null) { this.txtSubjectUnitAdd.Text = units.ProjectAddress; } SitePerson_PersonService.InitSitePersonDropDownList(this.drpSubjectUnitMan, this.drpSubjectProject.SelectedValue, Const.UnitId_SEDIN, null, null, true); } #endregion #region 按钮权限 /// /// 获取按钮权限 /// /// /// private void GetButtonPower() { var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.CheckNoticeMenuId); if (buttonList.Count() > 0) { if (buttonList.Contains(BLL.Const.BtnSave)) { this.btnSave.Hidden = false; } } } #endregion protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e) { BLL.Person_PersonsService.InitUserUnitIdDepartIdDropDownList(this.drpCheckTeamLeader, this.drpUnit.SelectedValue, string.Empty, true); } /// /// 组长 /// /// /// protected void drpCheckTeamLeader_SelectedIndexChanged(object sender, EventArgs e) { if (this.drpCheckTeamLeader.SelectedValue != Const._Null) { var getperson = Person_PersonsService.GetPerson_PersonsById(this.drpCheckTeamLeader.SelectedValue); if (getperson != null) { this.drpSex.SelectedValue = (getperson.Sex == "2" ? "女" : "男"); } } } /// /// /// /// /// protected void drpSubjectUnitMan_SelectedIndexChanged(object sender, EventArgs e) { if (this.drpSubjectUnitMan.SelectedValue != Const._Null) { var getperson = Person_PersonsService.GetPerson_PersonsById(this.drpSubjectUnitMan.SelectedValue); if (getperson != null) { this.txtSubjectUnitTel.Text = getperson.Telephone; } } } } }