SGGL_JT/SUBQHSE/FineUIPro.Web/HSSE/HiddenInspection/CheckTwolevelEdit.aspx.cs

193 lines
7.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
namespace FineUIPro.Web.HSSE.HiddenInspection
{
public partial class CheckTwolevelEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string CheckTwolevelId
{
get
{
return (string)ViewState["CheckTwolevelId"];
}
set
{
ViewState["CheckTwolevelId"] = value;
}
}
/// <summary>
/// 单位 ID
/// </summary>
public string UnitId
{
get
{
return (string)ViewState["UnitId"];
}
set
{
ViewState["UnitId"] = value;
}
}
/// <summary>
/// 菜单 ID
/// </summary>
public string MenuId
{
get
{
return (string)ViewState["MenuId"];
}
set
{
ViewState["MenuId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
UserService.InitFlowOperateControlUserDropDownList(this.drpLeaderIds, null, null, true);
this.CheckTwolevelId = Request.Params["CheckTwolevelId"];
this.UnitId = Request.Params["UnitId"] ?? CommonService.GetThisUnitId();
this.MenuId = Const.ProjectCheckTwolevelMenuId;
ProjectService.InitProjectDropDownList(this.drpProject, false);
if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
{
this.drpProject.SelectedValue = this.CurrUser.LoginProjectId;
this.drpProject.Readonly = true;
}
else
{
this.MenuId = Const.ServerCheckTwolevelMenuId;
ProjectService.InitUnitProjectDropDownList(this.drpProject, this.UnitId, false);
}
if (!string.IsNullOrEmpty(this.CheckTwolevelId))
{
var getCheckTwolevel = BLL.Check_CheckTwolevelService.GetCheckTwolevelById(this.CheckTwolevelId);
if (getCheckTwolevel != null)
{
ProjectService.InitAllProjectDropDownList(this.drpProject, false);
this.drpProject.SelectedValue = getCheckTwolevel.ProjectId;
this.UnitId = getCheckTwolevel.UnitId;
if (!string.IsNullOrEmpty(getCheckTwolevel.LeaderIds))
{
this.drpLeaderIds.SelectedValueArray = getCheckTwolevel.LeaderIds.Split(',');
}
this.txtCheckCode.Text = getCheckTwolevel.CheckCode;
this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", getCheckTwolevel.CheckDate);
this.ckIsHoldMeet.Checked = getCheckTwolevel.IsHoldMeet.Value;
this.txtRequirement.Text = getCheckTwolevel.Requirement;
this.txtLeaderName.Text = getCheckTwolevel.LeaderNames;
}
}
else
{
////自动生成编码
this.txtCheckCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(this.MenuId, this.drpProject.SelectedValue, this.UnitId);
this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
}
}
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
this.SaveData(Const.BtnSubmit);
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
/// <summary>
/// 保存数据
/// </summary>
/// <param name="type"></param>
private void SaveData(string type)
{
string LeaderIds = Funs.GetStringByArray(this.drpLeaderIds.SelectedValueArray);
if (string.IsNullOrEmpty(LeaderIds) && type == Const.BtnSubmit)
{
ShowNotify("请选择带班领导!", MessageBoxIcon.Warning);
return;
}
Model.Check_CheckTwolevel newCheckTwolevel = new Model.Check_CheckTwolevel
{
ProjectId = this.CurrUser.LoginProjectId,
CheckCode = this.txtCheckCode.Text.Trim(),
CheckDate = Funs.GetNewDateTime(this.txtCheckDate.Text.Trim()),
LeaderIds = LeaderIds,
IsHoldMeet = this.ckIsHoldMeet.Checked,
Requirement = this.txtRequirement.Text.Trim(),
UnitId = this.UnitId,
LeaderNames=this.txtLeaderName.Text.Trim(),
};
if (!string.IsNullOrEmpty(this.drpProject.SelectedValue) && this.drpProject.SelectedValue != Const._Null)
{
newCheckTwolevel.ProjectId = this.drpProject.SelectedValue;
}
if (!string.IsNullOrEmpty(this.CheckTwolevelId))
{
newCheckTwolevel.CheckTwolevelId = this.CheckTwolevelId;
BLL.Check_CheckTwolevelService.UpdateCheckTwolevel(newCheckTwolevel);
BLL.LogService.AddSys_Log(this.CurrUser, newCheckTwolevel.CheckCode, newCheckTwolevel.CheckTwolevelId, this.MenuId, BLL.Const.BtnModify);
}
else
{
this.CheckTwolevelId = SQLHelper.GetNewID();
newCheckTwolevel.CheckTwolevelId = this.CheckTwolevelId;
BLL.Check_CheckTwolevelService.AddCheckTwolevel(newCheckTwolevel, this.MenuId);
BLL.LogService.AddSys_Log(this.CurrUser, newCheckTwolevel.CheckCode, newCheckTwolevel.CheckTwolevelId, this.MenuId, BLL.Const.BtnAdd);
}
}
#endregion
#region
/// <summary>
/// 上传附件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.CheckTwolevelId))
{
SaveData(BLL.Const.BtnSave);
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/CheckTwolevelAttachUrl&menuId={1}", CheckTwolevelId, this.MenuId)));
}
#endregion
protected void drpLeaderIds_SelectedIndexChanged(object sender, EventArgs e)
{
this.drpLeaderIds.SelectedValueArray = Funs.RemoveDropDownListNull(this.drpLeaderIds.SelectedValueArray);
}
}
}