SGGL_JT/SUBQHSE/FineUIPro.Web/Customization/CNCCG/HSSE/Rewards/EnvironmentalAwardProjectEd...

114 lines
3.6 KiB
C#

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
{
/// <summary>
/// 主键
/// </summary>
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;
}
}
}
}
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
/// <summary>
/// 附件上传
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
}
}