258 lines
11 KiB
C#
258 lines
11 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.CQMS.Check
|
|
{
|
|
public partial class RewardAndPunishEdit : PageBase
|
|
{
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string RewardAndPunishID
|
|
{
|
|
get { return (string)ViewState["RewardAndPunishID"]; }
|
|
set { ViewState["RewardAndPunishID"] = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 图片是否可以编辑 -1查看 0编辑
|
|
/// </summary>
|
|
public int QuestionImg
|
|
{
|
|
get { return Convert.ToInt32(ViewState["QuestionImg"]); }
|
|
set { ViewState["QuestionImg"] = value; }
|
|
}
|
|
|
|
public string SysTemType
|
|
{
|
|
get { return (string)ViewState["SysTemType"]; }
|
|
set { ViewState["SysTemType"] = value; }
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
drpTeamGroup.DataValueField = "TeamGroupId";
|
|
drpTeamGroup.DataTextField = "TeamGroupName";
|
|
drpTeamGroup.DataSource = TeamGroupService.GetTeamGroupList(this.CurrUser.LoginProjectId);
|
|
drpTeamGroup.DataBind();
|
|
Funs.FineUIPleaseSelect(drpTeamGroup, null);
|
|
|
|
UnitService.InitUnitByProjectIdUnitTypeDropDownList(drpResponseUnit, this.CurrUser.LoginProjectId, "", true);
|
|
this.SysTemType = Request.Params["sysTemType"];
|
|
|
|
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|
RewardAndPunishID = Request.Params["RewardAndPunishID"];
|
|
if (!string.IsNullOrEmpty(RewardAndPunishID))
|
|
{
|
|
this.hdId.Text = RewardAndPunishID;
|
|
Model.Check_RewardAndPunish RewardAndPunish = BLL.RewardAndPunishService.GetRewardAndPunishById(RewardAndPunishID);
|
|
if (RewardAndPunish != null)
|
|
{
|
|
//this.CurrUser.LoginProjectId = RewardAndPunish.ProjectId;
|
|
|
|
this.drpRewardAndPunishType.SelectedValue = RewardAndPunish.RewardAndPunishType;
|
|
|
|
if (RewardAndPunish.Type.HasValue)
|
|
{
|
|
this.drpType.SelectedValue = RewardAndPunish.Type.Value.ToString();
|
|
drpRewardAndPunishType_Click(sender, e);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(RewardAndPunish.ResponseUnit))
|
|
{
|
|
this.drpResponseUnit.SelectedValue = RewardAndPunish.ResponseUnit;
|
|
}
|
|
|
|
if (RewardAndPunish.Money.HasValue)
|
|
{
|
|
this.txtMoney.Text = RewardAndPunish.Money.Value.ToString();
|
|
}
|
|
|
|
if (RewardAndPunish.Date.HasValue)
|
|
{
|
|
this.dpDate.Text = string.Format("{0:yyyy-MM-dd}", RewardAndPunish.Date.Value);
|
|
}
|
|
this.txtDescription.Text = RewardAndPunish.Description;
|
|
|
|
this.txtRewardAndPunishCode.Text = RewardAndPunish.RewardAndPunishCode;
|
|
|
|
if (!string.IsNullOrEmpty(RewardAndPunish.RewardAndPunishType))
|
|
{
|
|
this.drpRewardAndPunishType.SelectedValue = RewardAndPunish.RewardAndPunishType;
|
|
}
|
|
if (!string.IsNullOrEmpty(RewardAndPunish.RewardAndPunishMan))
|
|
{
|
|
this.drpRewardAndPunishMan.SelectedValue = RewardAndPunish.RewardAndPunishMan;
|
|
}
|
|
if (!string.IsNullOrEmpty(RewardAndPunish.TeamGroupId))
|
|
{
|
|
this.drpTeamGroup.SelectedValue = RewardAndPunish.TeamGroupId;
|
|
}
|
|
this.txtRemark.Text = RewardAndPunish.Remark;
|
|
if (this.CurrUser.UserId == RewardAndPunish.CreateMan)
|
|
{
|
|
QuestionImg = 1;
|
|
}
|
|
else
|
|
{
|
|
QuestionImg = 0;
|
|
this.btnSave.Hidden = true;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
drpType_OnSelectedIndexChanged(sender, e);
|
|
}
|
|
drpResponseUnit_OnSelectedIndexChanged(sender, e);
|
|
}
|
|
}
|
|
|
|
protected void WindowAtt_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
}
|
|
|
|
protected void imgBtnFile_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(this.hdId.Text)) //新增记录
|
|
{
|
|
this.hdId.Text = SQLHelper.GetNewID(typeof(Model.Check_CheckControl));
|
|
}
|
|
|
|
var model = BLL.RewardAndPunishService.GetRewardAndPunishById(this.hdId.Text);
|
|
if (model != null && model.HazardRegisterId != null)
|
|
{
|
|
Model.HSSE_Hazard_HazardRegister register =
|
|
BLL.HSSE_Hazard_HazardRegisterService.GetHazardRegisterByHazardRegisterId(model.HazardRegisterId);
|
|
DateTime date = Convert.ToDateTime(register.CheckTime);
|
|
string dateStr = date.Year.ToString() + date.Month.ToString();
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format(
|
|
"~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/Registration/" + dateStr +
|
|
"&menuId={1}&edit={2}", register.HazardRegisterId, Const.HSSE_HiddenRectificationListMenuId, "1")));
|
|
}
|
|
else
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format(
|
|
"../../AttachFile/webuploader.aspx?type={0}&toKeyId={1}&path=FileUpload/CheckControl&menuId={2}",
|
|
QuestionImg, this.hdId.Text, BLL.Const.RewardAndPunishMenuId)));
|
|
}
|
|
}
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (BLL.CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, this.CurrUser.UserId,
|
|
BLL.Const.RewardAndPunishMenuId, BLL.Const.BtnSave))
|
|
{
|
|
SaveData();
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
|
|
private void SaveData()
|
|
{
|
|
Model.Check_RewardAndPunish RewardAndPunish = new Model.Check_RewardAndPunish();
|
|
if (!string.IsNullOrEmpty(this.hdId.Text))
|
|
{
|
|
RewardAndPunish.RewardAndPunishID = this.hdId.Text;
|
|
}
|
|
RewardAndPunish.ProjectId = this.CurrUser.LoginProjectId;
|
|
RewardAndPunish.Type = int.Parse(this.drpType.SelectedValue);
|
|
RewardAndPunish.ResponseUnit = this.drpResponseUnit.SelectedValue;
|
|
// RewardAndPunish.NoticeUnit = this.drpNoticeUnit.SelectedValue;
|
|
RewardAndPunish.Money = Decimal.Parse(this.txtMoney.Text);
|
|
RewardAndPunish.Date = Convert.ToDateTime(this.dpDate.Text.Trim());
|
|
RewardAndPunish.Description = this.txtDescription.Text;
|
|
RewardAndPunish.CreateMan = this.CurrUser.UserId;
|
|
RewardAndPunish.RewardAndPunishType = this.drpRewardAndPunishType.SelectedValue;
|
|
RewardAndPunish.RewardAndPunishCode = this.txtRewardAndPunishCode.Text;
|
|
RewardAndPunish.RewardAndPunishMan = this.drpRewardAndPunishMan.SelectedValue;
|
|
RewardAndPunish.TeamGroupId = this.drpTeamGroup.SelectedValue;
|
|
RewardAndPunish.Remark = this.txtRemark.Text.Trim();
|
|
RewardAndPunish.DataSource = "0";
|
|
RewardAndPunish.SysTemType = this.SysTemType;
|
|
|
|
if (string.IsNullOrEmpty(this.hdId.Text.Trim()))
|
|
{
|
|
RewardAndPunish.RewardAndPunishID = Guid.NewGuid().ToString();
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(RewardAndPunishID))
|
|
{
|
|
BLL.RewardAndPunishService.AddRewardAndPunish(RewardAndPunish);
|
|
}
|
|
else
|
|
{
|
|
BLL.RewardAndPunishService.UpdateRewardAndPunish(RewardAndPunish);
|
|
}
|
|
|
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
|
|
#region 单位下拉框事件
|
|
|
|
/// <summary>
|
|
/// 单位下拉框事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void drpResponseUnit_OnSelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.drpResponseUnit.SelectedValue))
|
|
{
|
|
//根据单位和项目获取人员
|
|
BLL.PersonService.InitPersonByProjectUnitDropDownList(this.drpRewardAndPunishMan,
|
|
this.CurrUser.LoginProjectId, this.drpResponseUnit.SelectedValue, false);
|
|
}
|
|
}
|
|
|
|
protected void drpUser_OnSelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.drpRewardAndPunishMan.SelectedValue))
|
|
{
|
|
this.drpTeamGroup.SelectedValue = BLL.PersonService.GetPersonById(this.drpRewardAndPunishMan.SelectedValue).TeamGroupId;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
protected void drpType_OnSelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (this.drpType.SelectedValue == "1")
|
|
{
|
|
this.txtRewardAndPunishCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5",
|
|
"Check_RewardAndPunish", "RewardAndPunishCode", $"JL");
|
|
}
|
|
else
|
|
{
|
|
this.txtRewardAndPunishCode.Text = BLL.SQLHelper.RunProcNewId("SpGetNewCode5",
|
|
"Check_RewardAndPunish", "RewardAndPunishCode", $"CF");
|
|
}
|
|
drpRewardAndPunishType_Click(sender, e);
|
|
}
|
|
|
|
|
|
protected void drpRewardAndPunishType_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.drpType.SelectedValue == "1")
|
|
{
|
|
ConstValue.InitConstValueDropDownList(this.drpRewardAndPunishType, "RewardType", false);
|
|
}
|
|
else
|
|
{
|
|
ConstValue.InitConstValueDropDownList(this.drpRewardAndPunishType, "PunishType", false);
|
|
}
|
|
}
|
|
}
|
|
} |