xinjiang/SGGL/FineUIPro.Web/HSSE/Check/ProjectLeaderCheckEdit.aspx.cs

285 lines
12 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Microsoft.Office.Interop.Excel;
using static BLL.TrainingPlanService;
namespace FineUIPro.Web.HSSE.Check
{
public partial class ProjectLeaderCheckEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string ProjectLeaderCheckId
{
get
{
return (string)ViewState["ProjectLeaderCheckId"];
}
set
{
ViewState["ProjectLeaderCheckId"] = 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();
this.InitDropDownList();
this.ProjectLeaderCheckId = Request.Params["ProjectLeaderCheckId"];
this.UnitId = Request.Params["UnitId"];
this.MenuId = Const.ProjectLeaderCheckMenuId;
if (!string.IsNullOrEmpty(this.ProjectLeaderCheckId))
{
var model = BLL.Check_ProjectLeaderCheckService.GetProjectLeaderCheckById(this.ProjectLeaderCheckId);
if (model != null)
{
if (!string.IsNullOrEmpty(model.UnitIds))
{
this.drpUnits.SelectedValueArray = model.UnitIds.Split(',');
PersonService.InitPersonByMultiProjectUnitDropDownList(this.drpResponsibleMan, this.CurrUser.LoginProjectId, model.UnitIds, false);
}
if (!string.IsNullOrEmpty(model.LeaderIds))
{
this.drpLeaderIds.SelectedValueArray = model.LeaderIds.Split(',');
}
if (!string.IsNullOrEmpty(model.ResponsibleMan))
{
this.drpResponsibleMan.SelectedValue = model.ResponsibleMan;
//根据人员Id获取职务Id
var user = PersonService.GetPersonById(model.ResponsibleMan);
CompanyTrainingItemService.InitCompanyTrainingItemDownList(this.drpTrainingItem, user.WorkPostId, false);
}
if (!string.IsNullOrEmpty(model.CompanyTrainingItemId))
{
this.drpTrainingItem.SelectedValue = model.CompanyTrainingItemId;
}
this.txtCheckCode.Text = model.CheckCode;
this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", model.CheckDate);
this.ckIsHoldMeet.Checked = model.IsHoldMeet.Value;
this.txtQuestionDef.Text = model.QuestionDef;
this.txtRequirement.Text = model.Requirement;
//this.txtLeaderName.Text = model.LeaderNames;
}
}
else
{
////自动生成编码
this.txtCheckCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(this.MenuId, this.CurrUser.LoginProjectId, this.CurrUser.UnitId);
this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
}
}
}
/// <summary>
/// 下拉框加载
/// </summary>
private void InitDropDownList()
{
List<Model.SpSysUserItem> list = new List<Model.SpSysUserItem>();
List<Model.SpSysUserItem> newList = new List<Model.SpSysUserItem>();
list.AddRange(BLL.UserService.GetProjectRoleUserListByProjectId(this.CurrUser.LoginProjectId, null));
list.AddRange(BLL.UserService.GetProjectRoleUserListByProjectId(null, null));
foreach (var item in list)
{
var user = newList.FirstOrDefault(x => x.UserId == item.UserId);
if (user == null)
{
newList.Add(item);
}
}
drpLeaderIds.DataValueField = "UserId";
drpLeaderIds.DataTextField = "UserName";
drpLeaderIds.DataSource = newList;
drpLeaderIds.DataBind();
Funs.FineUIPleaseSelect(drpLeaderIds);
//UserService.InitFlowOperateControlUserDropDownList(this.drpLeaderIds, this.CurrUser.LoginProjectId, null, true);
UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpUnits, this.CurrUser.LoginProjectId, null, true);
PersonService.InitPersonByProjectUnitDropDownList(this.drpResponsibleMan, this.CurrUser.LoginProjectId, string.Empty, false);
}
/// <summary>
/// 责任人下拉加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpResponsibleMan_SelectedIndexChanged(object sender, EventArgs e)
{
//责任人Id
var responsibleManId = this.drpResponsibleMan.SelectedValue;
if (!string.IsNullOrWhiteSpace(responsibleManId))
{
//根据人员Id获取职务Id
var user = PersonService.GetPersonById(responsibleManId);
if (user != null && !string.IsNullOrWhiteSpace(user.WorkPostId))
{
CompanyTrainingItemService.InitCompanyTrainingItemDownList(this.drpTrainingItem, user.WorkPostId, false);
}
}
}
#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 unitIds = Funs.GetStringByArray(this.drpUnits.SelectedValueArray);
string LeaderIds = Funs.GetStringByArray(this.drpLeaderIds.SelectedValueArray);
if (string.IsNullOrEmpty(LeaderIds) && type == Const.BtnSubmit)
{
ShowNotify("请选择带班领导!", MessageBoxIcon.Warning);
return;
}
Model.Check_ProjectLeaderCheck model = new Model.Check_ProjectLeaderCheck
{
ProjectId = this.CurrUser.LoginProjectId,
CheckCode = this.txtCheckCode.Text.Trim(),
CheckDate = Funs.GetNewDateTime(this.txtCheckDate.Text.Trim()),
UnitIds = unitIds,
LeaderIds = LeaderIds,
IsHoldMeet = this.ckIsHoldMeet.Checked,
QuestionDef = this.txtQuestionDef.Text.Trim(),
Requirement = this.txtRequirement.Text.Trim(),
//LeaderNames = this.txtLeaderName.Text.Trim(),
CompileDate = DateTime.Now,
CompileMan = this.CurrUser.UserId
};
if (this.drpResponsibleMan.SelectedValue != BLL.Const._Null)
{
model.ResponsibleMan = this.drpResponsibleMan.SelectedValue;
}
model.CompanyTrainingItemId = drpTrainingItem.SelectedValue;
if (!string.IsNullOrEmpty(this.ProjectLeaderCheckId))
{
model.ProjectLeaderCheckId = this.ProjectLeaderCheckId;
BLL.Check_ProjectLeaderCheckService.UpdateProjectLeaderCheck(model);
BLL.LogService.AddSys_Log(this.CurrUser, model.CheckCode, model.ProjectLeaderCheckId, this.MenuId, BLL.Const.BtnModify);
}
else
{
this.ProjectLeaderCheckId = SQLHelper.GetNewID();
model.ProjectLeaderCheckId = this.ProjectLeaderCheckId;
BLL.Check_ProjectLeaderCheckService.AddProjectLeaderCheck(model);
BLL.LogService.AddSys_Log(this.CurrUser, model.CheckCode, model.ProjectLeaderCheckId, this.MenuId, BLL.Const.BtnAdd);
}
Project_HSSEData_HSSEService.StatisticalData(this.CurrUser.LoginProjectId, Project_HSSEData_HSSEService.HSSEDateType.SupervisionAndInspection);
#region
if (!string.IsNullOrWhiteSpace(model.ResponsibleMan) && !string.IsNullOrWhiteSpace(model.CompanyTrainingItemId))
{//责任人和重修教材非空,生成培训计划
var CheckTypeName = Enums.RetakeCourseType..ToString();
Model.ProducePlanInfo info = new Model.ProducePlanInfo
{
CurrProjectId = this.CurrUser.LoginProjectId,
CurrUserId = this.CurrUser.UserId,
CheckId = this.ProjectLeaderCheckId,
CheckType = (int)Enums.RetakeCourseType.,
CheckTypeName = "领导带班检查",
PersonId = model.ResponsibleMan,
CompanyTrainingItemId = model.CompanyTrainingItemId,
//TrainEndDate = model.RectificationPeriod
};
TrainingPlanService.RetakeCourseProducePlan(info);
}
#endregion
}
#endregion
#region
/// <summary>
/// 上传附件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.ProjectLeaderCheckId))
{
SaveData(BLL.Const.BtnSave);
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/ProjectLeaderCheckAttachUrl&menuId={1}", ProjectLeaderCheckId, this.MenuId)));
}
#endregion
protected void drpUnits_SelectedIndexChanged(object sender, EventArgs e)
{
string unitIds = Funs.GetStringByArray(this.drpUnits.SelectedValueArray);
if (!string.IsNullOrWhiteSpace(unitIds))
{
PersonService.InitPersonByMultiProjectUnitDropDownList(this.drpResponsibleMan, this.CurrUser.LoginProjectId, unitIds, false);
}
this.drpUnits.SelectedValueArray = Funs.RemoveDropDownListNull(this.drpUnits.SelectedValueArray);
}
protected void drpLeaderIds_SelectedIndexChanged(object sender, EventArgs e)
{
this.drpLeaderIds.SelectedValueArray = Funs.RemoveDropDownListNull(this.drpLeaderIds.SelectedValueArray);
}
}
}