190 lines
6.3 KiB
C#
190 lines
6.3 KiB
C#
|
using BLL;
|
|||
|
using System;
|
|||
|
using System.Linq;
|
|||
|
using System.Web;
|
|||
|
|
|||
|
namespace FineUIPro.Web.Customization.CNCCG.HSSE.Rewards
|
|||
|
{
|
|||
|
public partial class GreenSiteEdit : 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();
|
|||
|
//加载项目
|
|||
|
ProjectService.InitAllUnEndProjectShortNameByAttributeDropDownList(this.drpProjectId,
|
|||
|
this.CurrUser.UserId, string.Empty, "GONGCHENG", false, BLL.Const.ProjectState_1);
|
|||
|
|
|||
|
BLL.UnitService.InitBranchUnitDropDownList(this.drpUnitId, false);//加载公司
|
|||
|
|
|||
|
this.Id = Request.Params["Id"];
|
|||
|
if (!string.IsNullOrEmpty(this.Id))
|
|||
|
{
|
|||
|
var model = GreenSiteService.Detail(this.Id);
|
|||
|
if (model != null)
|
|||
|
{
|
|||
|
drpProjectId.SelectedValue = model.ProjectId;
|
|||
|
drpUnitId.SelectedValue = model.UnitId;
|
|||
|
txtCreateMonth.Text = Convert.ToDateTime(model.CreateMonth).ToString("yyyy-MM");
|
|||
|
txtScore1.Text = model.Score1.ToString();
|
|||
|
txtScore2.Text = model.Score2.ToString();
|
|||
|
//加载安全生产、生态环保、质量获奖处罚加减分(然后加载总分)
|
|||
|
getBonuspoints();
|
|||
|
txtRecommendation.Text = model.Recommendation;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
txtCreateMonth.Text = string.Format("{0:yyyy-MM}", DateTime.Now);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected void drpProject_TextChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(drpProjectId.SelectedValue))
|
|||
|
{
|
|||
|
drpUnitId.SelectedValue = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == drpProjectId.SelectedValue).UnitId;
|
|||
|
|
|||
|
getBonuspoints();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//修改总得分
|
|||
|
protected void txt_TextChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
getBonuspointsNew();
|
|||
|
}
|
|||
|
|
|||
|
//根据单位加载奖励得分
|
|||
|
void getBonuspoints()
|
|||
|
{
|
|||
|
txtRemark.Text = "";
|
|||
|
var sTime = Convert.ToDateTime(txtCreateMonth.Text + "-01");
|
|||
|
var eTime = sTime.AddMonths(1);
|
|||
|
decimal score = 0;
|
|||
|
|
|||
|
var pid = drpProjectId.SelectedValue;
|
|||
|
var uid = drpUnitId.SelectedValue;
|
|||
|
var list = Funs.DB.HSSE_EnvironmentalAward.Where(x => x.ProjectId == pid && x.CreateTime >= sTime && x.CreateTime <= eTime).ToList();
|
|||
|
if (list.Count > 0)
|
|||
|
{
|
|||
|
score = list.Sum(x => x.Scores) ?? 0;
|
|||
|
foreach (var item in list)
|
|||
|
{
|
|||
|
txtRemark.Text += "奖项名称:" + item.AwardsName + ",加分值:" + item.Scores.ToString() + ";";
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(txtRemark.Text))
|
|||
|
{
|
|||
|
txtRemark.Text = txtRemark.Text.Substring(0, txtRemark.Text.Length - 1) + "。";
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
txtRemark.Text = "无奖项";
|
|||
|
}
|
|||
|
|
|||
|
decimal score1 = 0;
|
|||
|
if (!string.IsNullOrEmpty(txtScore1.Text))
|
|||
|
{
|
|||
|
score1 = Convert.ToDecimal(txtScore1.Text);
|
|||
|
}
|
|||
|
decimal score2 = 0;
|
|||
|
if (!string.IsNullOrEmpty(txtScore2.Text))
|
|||
|
{
|
|||
|
score2 = Convert.ToDecimal(txtScore2.Text);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
txtAllScore.Text = (score1 + score2 + score).ToString();
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
void getBonuspointsNew()
|
|||
|
{
|
|||
|
var sTime = Convert.ToDateTime(txtCreateMonth.Text + "-01");
|
|||
|
var eTime = sTime.AddMonths(1);
|
|||
|
decimal score = 0;
|
|||
|
|
|||
|
var pid = drpProjectId.SelectedValue;
|
|||
|
var uid = drpUnitId.SelectedValue;
|
|||
|
var list = Funs.DB.HSSE_EnvironmentalAward.Where(x => x.ProjectId==pid
|
|||
|
&& x.CreateTime >= sTime && x.CreateTime <= eTime).ToList();
|
|||
|
if (list.Count > 0)
|
|||
|
{
|
|||
|
score = list.Sum(x => x.Scores) ?? 0;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
txtRemark.Text = "无奖项";
|
|||
|
}
|
|||
|
|
|||
|
decimal score1 = 0;
|
|||
|
if (!string.IsNullOrEmpty(txtScore1.Text))
|
|||
|
{
|
|||
|
score1 = Convert.ToDecimal(txtScore1.Text);
|
|||
|
}
|
|||
|
decimal score2 = 0;
|
|||
|
if (!string.IsNullOrEmpty(txtScore2.Text))
|
|||
|
{
|
|||
|
score2 = Convert.ToDecimal(txtScore2.Text);
|
|||
|
}
|
|||
|
txtAllScore.Text = (score1 + score2 + score).ToString();
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
/// <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_GreenSite
|
|||
|
{
|
|||
|
ProjectId=drpProjectId.SelectedValue,
|
|||
|
UnitId = drpUnitId.SelectedValue,
|
|||
|
Score1 = Convert.ToDecimal(txtScore1.Text),
|
|||
|
Score2 = Convert.ToDecimal(txtScore2.Text),
|
|||
|
AllScore = Convert.ToDecimal(txtAllScore.Text),
|
|||
|
Recommendation = txtRecommendation.Text,
|
|||
|
CreateMonth = Convert.ToDateTime(txtCreateMonth.Text)
|
|||
|
};
|
|||
|
if (!string.IsNullOrEmpty(this.Id))
|
|||
|
{
|
|||
|
model.Id = this.Id;
|
|||
|
GreenSiteService.Update(model);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
this.Id = SQLHelper.GetNewID(typeof(Model.HSSESystem_SafetyInstitution));
|
|||
|
model.Id = this.Id;
|
|||
|
GreenSiteService.Insert(model);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|