using BLL; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Web; using System.Linq; namespace FineUIPro.Web.Customization.CNCCG.HSSE.Rewards { public partial class EnvironmentalAwardProjectEdit : PageBase { /// /// 主键 /// public string Id { get { return (string)ViewState["Id"]; } set { ViewState["Id"] = value; } } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.Id = Request.Params["Id"]; if (!string.IsNullOrEmpty(this.Id)) { var model = EnvironmentalAwardService.Detail(this.Id); if (model != null) { txtAwardsName.Text = model.AwardsName; txtAwardsUnit.Text = model.AwardsUnit; txtDocCode.Text = model.DocCode; drpAwardsLevel.SelectedValue = model.AwardsLevel; } } } } /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { this.SaveData(BLL.Const.BtnSave); PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); } private void SaveData(string type) { var model = new Model.HSSE_EnvironmentalAward { UnitId = CurrUser.UnitId, ProjectId=CurrUser.LoginProjectId, AwardsName = txtAwardsName.Text, AwardsUnit = txtAwardsUnit.Text, DocCode = txtDocCode.Text, AwardsLevel = drpAwardsLevel.SelectedValue, CreateTime=DateTime.Now, CreateMan = CurrUser.UserId, Scores=0 }; var thisUnit = BLL.CommonService.GetIsThisUnit(); if (string.IsNullOrEmpty(CurrUser.UnitId)) { model.UnitId = thisUnit.UnitId; } if (!string.IsNullOrEmpty(this.Id)) { var newmodel = EnvironmentalAwardService.Detail(this.Id); model.Id = this.Id; model.Scores = newmodel.Scores; EnvironmentalAwardService.Update(model); } else { this.Id = SQLHelper.GetNewID(typeof(Model.HSSESystem_SafetyInstitution)); model.Id = this.Id; EnvironmentalAwardService.Insert(model); } } #region 附件上传 /// /// 附件上传 /// /// /// protected void btnAttach_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.Id)) //新增记录 { this.SaveData(BLL.Const.BtnSave); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/HSSE/EnvironmentalAward&menuId={1}", this.Id, BLL.Const.EnvironmentalAwardMenuId))); } #endregion } }