using BLL; using System; namespace FineUIPro.Web.License { public partial class HSETechnicalEdit : PageBase { #region 定义项 /// /// 主键 /// public string HSETechnicalId { get { return (string)ViewState["HSETechnicalId"]; } set { ViewState["HSETechnicalId"] = value; } } /// /// 项目主键 /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } #endregion /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ProjectId = this.CurrUser.LoginProjectId; this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.InitDropDownList(); Funs.FineUIPleaseSelect(this.drpTeamGroupId); this.HSETechnicalId = Request.Params["HSETechnicalId"]; if (!string.IsNullOrEmpty(this.HSETechnicalId)) { Model.License_HSETechnical hseTechnical = BLL.HSETechnicalService.GetHSETechnicalById(this.HSETechnicalId); if (hseTechnical != null) { this.ProjectId = hseTechnical.ProjectId; if (this.ProjectId != this.CurrUser.LoginProjectId) { this.InitDropDownList(); } this.txtHSETechnicalCode.Text = BLL.CodeRecordsService.ReturnCodeByDataId(this.HSETechnicalId); this.txtHSETechnicalDate.Text = string.Format("{0:yyyy-MM-dd}", hseTechnical.HSETechnicalDate); if (!string.IsNullOrEmpty(hseTechnical.UnitId)) { this.drpUnitId.SelectedValue = hseTechnical.UnitId; this.drpTeamGroupId.DataValueField = "TeamGroupId"; this.drpTeamGroupId.DataTextField = "TeamGroupName"; this.drpTeamGroupId.DataSource = BLL.TeamGroupService.GetTeamGroupListByUnitId(this.ProjectId, hseTechnical.UnitId); this.drpTeamGroupId.DataBind(); Funs.FineUIPleaseSelect(this.drpTeamGroupId); } if (!string.IsNullOrEmpty(hseTechnical.TeamGroupId)) { this.drpTeamGroupId.SelectedValue = hseTechnical.TeamGroupId; } this.txtWorkContents.Text = hseTechnical.WorkContents; this.txtAddress.Text = hseTechnical.Address; } } else { this.txtHSETechnicalDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); ////自动生成编码 this.txtHSETechnicalCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectHSETechnicalMenuId, this.ProjectId, this.CurrUser.UnitId); this.drpUnitId.SelectedValue = this.CurrUser.UnitId; } } } /// /// 初始化下拉框 /// private void InitDropDownList() { BLL.UnitService.InitUnitDropDownList(this.drpUnitId, this.ProjectId, true); } #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { SaveData(BLL.Const.BtnSave); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } /// /// 保存数据 /// /// private void SaveData(string type) { Model.License_HSETechnical hSETechnical = new Model.License_HSETechnical { ProjectId = this.ProjectId, HSETechnicalCode = this.txtHSETechnicalCode.Text.Trim(), HSETechnicalDate = Funs.GetNewDateTime(this.txtHSETechnicalDate.Text.Trim()) }; if (this.drpUnitId.SelectedValue != BLL.Const._Null) { hSETechnical.UnitId = this.drpUnitId.SelectedValue; } if (this.drpTeamGroupId.SelectedValue != BLL.Const._Null) { hSETechnical.TeamGroupId = this.drpTeamGroupId.SelectedValue; } hSETechnical.WorkContents = this.txtWorkContents.Text.Trim(); hSETechnical.Address = this.txtAddress.Text.Trim(); hSETechnical.CompileMan = this.CurrUser.UserId; hSETechnical.CompileDate = DateTime.Now; hSETechnical.States = BLL.Const.State_0; if (!string.IsNullOrEmpty(this.HSETechnicalId)) { hSETechnical.HSETechnicalId = this.HSETechnicalId; BLL.HSETechnicalService.UpdateHSETechnical(hSETechnical); BLL.LogService.AddSys_Log(this.CurrUser, hSETechnical.HSETechnicalCode, hSETechnical.HSETechnicalId, BLL.Const.ProjectHSETechnicalMenuId, BLL.Const.BtnModify); } else { this.HSETechnicalId = SQLHelper.GetNewID(typeof(Model.License_HSETechnical)); hSETechnical.HSETechnicalId = this.HSETechnicalId; hSETechnical.QRCodeAttachUrl = CreateQRCodeService.CreateCode_Simple("HSETechnical$" + this.HSETechnicalId); BLL.HSETechnicalService.AddHSETechnical(hSETechnical); BLL.LogService.AddSys_Log(this.CurrUser, hSETechnical.HSETechnicalCode, hSETechnical.HSETechnicalId, BLL.Const.ProjectHSETechnicalMenuId, BLL.Const.BtnAdd); } } #endregion #region 附件上传 /// /// 上传附件 /// /// /// protected void btnAttachUrl_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.HSETechnicalId)) { SaveData(BLL.Const.BtnSave); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/HSETechnicalAttachUrl&menuId={1}", this.HSETechnicalId, BLL.Const.ProjectHSETechnicalMenuId))); } #endregion /// /// 单位下拉选择事件 /// /// /// protected void drpUnitId_SelectedIndexChanged(object sender, EventArgs e) { if (this.drpUnitId.SelectedValue != BLL.Const._Null) { this.drpTeamGroupId.Items.Clear(); this.drpTeamGroupId.DataValueField = "TeamGroupId"; this.drpTeamGroupId.DataTextField = "TeamGroupName"; this.drpTeamGroupId.DataSource = BLL.TeamGroupService.GetTeamGroupListByUnitId(this.ProjectId, this.drpUnitId.SelectedValue); this.drpTeamGroupId.DataBind(); Funs.FineUIPleaseSelect(this.drpTeamGroupId); this.drpTeamGroupId.SelectedIndex = 0; } else { this.drpTeamGroupId.Items.Clear(); Funs.FineUIPleaseSelect(this.drpTeamGroupId); this.drpTeamGroupId.SelectedIndex = 0; } } } }