1
This commit is contained in:
@@ -0,0 +1,425 @@
|
||||
using BLL;
|
||||
using FineUIPro.Web.BaseInfo;
|
||||
using FineUIPro.Web.SysManage;
|
||||
using Microsoft.Win32;
|
||||
using Model;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace FineUIPro.Web.ZHGL.Supervise
|
||||
{
|
||||
public partial class UnitHazardRegisterEdit : PageBase
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private List<View_UnitHazardRegisterItem> items = new List<View_UnitHazardRegisterItem>();
|
||||
|
||||
#endregion Fields
|
||||
|
||||
#region Properties
|
||||
|
||||
public string UnitHazardRegisterId
|
||||
{
|
||||
get { return (string)ViewState["UnitHazardRegisterId"]; }
|
||||
set { ViewState["UnitHazardRegisterId"] = value; }
|
||||
}
|
||||
public string type
|
||||
{
|
||||
get { return (string)ViewState["type"]; }
|
||||
set { ViewState["type"] = value; }
|
||||
}
|
||||
#endregion Properties
|
||||
|
||||
#region Methods
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
// 获取 Type 参数
|
||||
type = Request["type"] ?? "0";
|
||||
btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
||||
|
||||
InitDropList();
|
||||
|
||||
this.UnitHazardRegisterId = Request.Params["UnitHazardRegisterId"];
|
||||
var register = BLL.UnitHazardRegisterService.GetUnitHazardRegisterById(this.UnitHazardRegisterId);
|
||||
|
||||
if (register != null)
|
||||
{
|
||||
// 编辑模式 - 加载数据
|
||||
this.txtUnitHazardRegisterCode.Text = register.UnitHazardRegisterCode;
|
||||
if (register.CheckDate != null)
|
||||
{
|
||||
this.dpkCheckDate.Text = string.Format("{0:yyyy-MM-dd}", register.CheckDate);
|
||||
}
|
||||
this.drpCheckMainType.SelectedValue = register.CheckMainType;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(register.CheckType))
|
||||
{
|
||||
BLL.SuperviseCheckTypeService.InitCheckTypeDropDownListByMainType(
|
||||
this.drpCheckType, register.CheckMainType, false);
|
||||
this.drpCheckType.SelectedValue = register.CheckType;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(register.ProjectId))
|
||||
{
|
||||
this.ddlProjectId.SelectedValue = register.ProjectId;
|
||||
this.ddlInsResponsibleUserId.Items.Clear();
|
||||
BLL.Person_PersonsService.InitUserDropDownList(this.ddlInsResponsibleUserId, this.ddlProjectId.SelectedValue, true, null);
|
||||
if (!string.IsNullOrWhiteSpace(register.InsResponsibleUserId))
|
||||
{
|
||||
this.ddlInsResponsibleUserId.SelectedValue = register.InsResponsibleUserId;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(register.CheckUnitId))
|
||||
{
|
||||
this.ddlCheckUnitId.SelectedValue = register.CheckUnitId;
|
||||
}
|
||||
|
||||
this.txtCheckTeam.Text = register.CheckTeam;
|
||||
|
||||
// 加载明细
|
||||
items = BLL.UnitHazardRegisterItemService.GetItemsByRegisterId(this.UnitHazardRegisterId)
|
||||
.Select(x => new View_UnitHazardRegisterItem
|
||||
{
|
||||
UnitHazardRegisterItemId = x.UnitHazardRegisterItemId,
|
||||
ProblemDescription = x.ProblemDescription,
|
||||
ProblemType = x.ProblemType,
|
||||
RiskLevel = x.RiskLevel,
|
||||
RectifyRequirement = x.RectifyRequirement,
|
||||
CompleteStatus = x.CompleteStatus,
|
||||
CompletedDate = x.CompletedDate
|
||||
}).ToList();
|
||||
|
||||
if (register.States> (int)UnitHazardRegisterService.StateInt.待提交)
|
||||
{
|
||||
btnAdd.Hidden = true;
|
||||
btnSave.Hidden = true;
|
||||
btnSubmit.Hidden = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 新增模式
|
||||
var unitModel = UnitService.GetUnitByUnitId(this.CurrUser.UnitId);
|
||||
if (unitModel?.IsBranch == true)
|
||||
{
|
||||
this.ddlCheckUnitId.SelectedValue = this.CurrUser.UnitId;
|
||||
}
|
||||
else
|
||||
{
|
||||
var thisUnit = BLL.CommonService.GetIsThisUnit();
|
||||
this.ddlCheckUnitId.SelectedValue = thisUnit.UnitId;
|
||||
}
|
||||
this.txtCheckTeam.Text = BLL.UnitService.GetUnitNameByUnitId(this.CurrUser.UnitId) + " " + this.CurrUser.PersonName;
|
||||
this.dpkCheckDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
||||
|
||||
// 自动生成编号
|
||||
int newCount= UnitHazardRegisterService.GetCount(type)+1;
|
||||
this.txtUnitHazardRegisterCode.Text = newCount.ToString().PadLeft(5,'0');
|
||||
}
|
||||
|
||||
Grid1.DataSource = items;
|
||||
Grid1.DataBind();
|
||||
}
|
||||
}
|
||||
|
||||
protected void InitDropList()
|
||||
{
|
||||
drpCheckMainType.SelectedValue = type;
|
||||
// 初始化下拉框
|
||||
BLL.UnitService.InitBranchUnitDropDownList(this.ddlCheckUnitId, false);
|
||||
BLL.ProjectService.InitProjectDropDownList(this.ddlProjectId, ddlCheckUnitId.SelectedValue, true);
|
||||
BLL.Person_PersonsService.InitUserDropDownList(this.ddlInsResponsibleUserId, this.ddlProjectId.SelectedValue, true, null);
|
||||
BLL.SuperviseCheckTypeService.InitCheckTypeDropDownListByMainType(
|
||||
this.drpCheckType, type, false);
|
||||
|
||||
if (type=="0")
|
||||
{
|
||||
this.drpProblemType.DataTextField = "RegisterTypesName";
|
||||
this.drpProblemType.DataValueField = "RegisterTypesName";
|
||||
this.drpProblemType.DataSource = BLL.HSSE_Hazard_HazardRegisterTypesService.GetHazardRegisterTypesList("1"); //安全巡检类型
|
||||
this.drpProblemType.DataBind();
|
||||
}
|
||||
else
|
||||
{
|
||||
QualityQuestionTypeService.InitQualityQuestionType(drpProblemType, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
protected void btnAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
JArray teamGroupData = Grid1.GetMergedData();
|
||||
List<JObject> list = new List<JObject>();
|
||||
foreach (JObject teamGroupRow in teamGroupData)
|
||||
{
|
||||
JObject values = teamGroupRow.Value<JObject>("values");
|
||||
values.Add("UnitHazardRegisterItemId", teamGroupRow.Value<string>("id"));
|
||||
list.Add(values);
|
||||
}
|
||||
JObject defaultObj = new JObject
|
||||
{ { "UnitHazardRegisterItemId",Guid.NewGuid() },
|
||||
{ "ProblemDescription", "" },
|
||||
{ "ProblemType", "" },
|
||||
{ "RiskLevel","一般"},
|
||||
{ "RectifyRequirement", "" },
|
||||
{ "Delete", String.Format("<a href=\"javascript:;\" onclick=\"{0}\"><img src=\"{1}\"/></a>", GetDeleteScript(), IconHelper.GetResolvedIconUrl(Icon.Delete)) }
|
||||
};
|
||||
list.Add(defaultObj);
|
||||
Grid1.DataSource = list;
|
||||
Grid1.DataBind();
|
||||
}
|
||||
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.drpCheckMainType.SelectedValue == BLL.Const._Null)
|
||||
{
|
||||
Alert.ShowInTop("请选择检查大类!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
if (this.drpCheckType.SelectedValue == BLL.Const._Null)
|
||||
{
|
||||
Alert.ShowInTop("请选择检查类别!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
if (this.ddlProjectId.SelectedValue == BLL.Const._Null)
|
||||
{
|
||||
Alert.ShowInTop("请选择检查对象!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
if (this.ddlCheckUnitId.SelectedValue == BLL.Const._Null)
|
||||
{
|
||||
Alert.ShowInTop("请选择检查单位!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
SaveNew();
|
||||
SaveItem();
|
||||
|
||||
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||||
}
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.drpCheckMainType.SelectedValue == BLL.Const._Null)
|
||||
{
|
||||
Alert.ShowInTop("请选择检查大类!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
if (this.drpCheckType.SelectedValue == BLL.Const._Null)
|
||||
{
|
||||
Alert.ShowInTop("请选择检查类别!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
if (this.ddlProjectId.SelectedValue == BLL.Const._Null)
|
||||
{
|
||||
Alert.ShowInTop("请选择检查对象!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
if (this.ddlCheckUnitId.SelectedValue == BLL.Const._Null)
|
||||
{
|
||||
Alert.ShowInTop("请选择检查单位!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
SaveNew(Const.BtnSubmit);
|
||||
SaveItem();
|
||||
|
||||
ShowNotify("提交成功!", MessageBoxIcon.Success);
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||||
}
|
||||
protected void ddlCheckUnitId_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.ddlProjectId.Items.Clear();
|
||||
this.ddlInsResponsibleUserId.Items.Clear();
|
||||
BLL.ProjectService.InitProjectDropDownList(this.ddlProjectId,ddlCheckUnitId.SelectedValue, true);
|
||||
|
||||
}
|
||||
protected void ddlProjectId_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.ddlInsResponsibleUserId.Items.Clear();
|
||||
//BLL.UnitService.InitUnitNameByProjectIdUnitTypeDropDownList(this.ddlUnitId, this.ddlProjectId.SelectedValue, Const.ProjectUnitType_1, true);
|
||||
BLL.Person_PersonsService.InitUserDropDownList(this.ddlInsResponsibleUserId, this.ddlProjectId.SelectedValue, true, null);
|
||||
|
||||
}
|
||||
|
||||
protected void drpCheckMainType_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
BLL.SuperviseCheckTypeService.InitCheckTypeDropDownListByMainType(
|
||||
this.drpCheckType, this.drpCheckMainType.SelectedValue, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_PreDataBound(object sender, EventArgs e)
|
||||
{
|
||||
// 设置LinkButtonField的点击客户端事件
|
||||
LinkButtonField deleteField = Grid1.FindColumn("Delete") as LinkButtonField;
|
||||
deleteField.OnClientClick = GetDeleteScript();
|
||||
var register = BLL.UnitHazardRegisterService.GetUnitHazardRegisterById(this.UnitHazardRegisterId);
|
||||
|
||||
if (register!=null&& register.States > (int)UnitHazardRegisterService.StateInt.待提交)
|
||||
{
|
||||
LinkButtonField lbUpload = Grid1.FindColumn(6) as LinkButtonField;
|
||||
LinkButtonField lbDelete = Grid1.FindColumn(7) as LinkButtonField;
|
||||
|
||||
lbUpload.Enabled = false;
|
||||
lbDelete.Enabled = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
||||
{
|
||||
string itemId = Grid1.DataKeys[e.RowIndex][0].ToString();
|
||||
string menuId = Request["type"] == "0" ?
|
||||
BLL.Const.UnitHazardRegisterMenu_Safety :
|
||||
BLL.Const.UnitHazardRegisterMenu_Quality;
|
||||
if (e.CommandName == "attchUrl")
|
||||
{
|
||||
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/UnitHazardRegister&menuId={1}&edit=1", itemId, menuId)));
|
||||
}
|
||||
}
|
||||
|
||||
protected void SaveItem()
|
||||
{
|
||||
JArray teamGroupData = Grid1.GetMergedData();
|
||||
foreach (JObject teamGroupRow in teamGroupData)
|
||||
{
|
||||
JObject values = teamGroupRow.Value<JObject>("values");
|
||||
|
||||
Model.Supervise_UnitHazardRegisterItem registerItem = new Model.Supervise_UnitHazardRegisterItem
|
||||
{
|
||||
UnitHazardRegisterItemId = teamGroupRow.Value<string>("id"),
|
||||
UnitHazardRegisterId = this.UnitHazardRegisterId,
|
||||
ProblemDescription = values.Value<string>("ProblemDescription"),
|
||||
ProblemType = values.Value<string>("ProblemType"),
|
||||
RiskLevel = values.Value<string>("RiskLevel"),
|
||||
RectifyRequirement = values.Value<string>("RectifyRequirement"),
|
||||
CompleteStatus = 0
|
||||
};
|
||||
if (UnitHazardRegisterItemService.GetUnitHazardRegisterItemById(registerItem.UnitHazardRegisterItemId) != null)
|
||||
{
|
||||
UnitHazardRegisterItemService.UpdateUnitHazardRegisterItem(registerItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
BLL.UnitHazardRegisterItemService.AddUnitHazardRegisterItem(registerItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void SaveNew(string type="")
|
||||
{
|
||||
Supervise_UnitHazardRegister register = new Supervise_UnitHazardRegister
|
||||
{
|
||||
UnitHazardRegisterCode = this.txtUnitHazardRegisterCode.Text.Trim(),
|
||||
CheckDate = Funs.GetNewDateTime(this.dpkCheckDate.Text.Trim()),
|
||||
CheckMainType = this.drpCheckMainType.SelectedValue,
|
||||
CheckType = this.drpCheckType.SelectedValue,
|
||||
ProjectId = this.ddlProjectId.SelectedValue,
|
||||
CheckUnitId = this.ddlCheckUnitId.SelectedValue,
|
||||
InsResponsibleUserId = this.ddlInsResponsibleUserId.SelectedValue,
|
||||
CheckTeam = this.txtCheckTeam.Text.Trim(),
|
||||
CompileMan = this.CurrUser.PersonId,
|
||||
States = (int)UnitHazardRegisterService.StateInt.待提交
|
||||
};
|
||||
if (!string.IsNullOrEmpty(type))
|
||||
{
|
||||
|
||||
register.States = (int)UnitHazardRegisterService.StateInt.待整改;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(this.UnitHazardRegisterId))
|
||||
{
|
||||
// 新增
|
||||
register.UnitHazardRegisterId = SQLHelper.GetNewID(typeof(Supervise_UnitHazardRegister));
|
||||
this.UnitHazardRegisterId = register.UnitHazardRegisterId;
|
||||
BLL.UnitHazardRegisterService.AddUnitHazardRegister(register);
|
||||
|
||||
// 增加一条编码记录
|
||||
BLL.CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(
|
||||
BLL.Const.UnitHazardRegisterMenu_Safety, register.ProjectId, null,
|
||||
register.UnitHazardRegisterId, register.CheckDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 更新
|
||||
register.UnitHazardRegisterId = this.UnitHazardRegisterId;
|
||||
BLL.UnitHazardRegisterService.UpdateUnitHazardRegister(register);
|
||||
}
|
||||
}
|
||||
|
||||
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
||||
{
|
||||
// 刷新Grid数据
|
||||
items = BLL.UnitHazardRegisterItemService.GetItemsByRegisterId(this.UnitHazardRegisterId)
|
||||
.Select(x => new View_UnitHazardRegisterItem
|
||||
{
|
||||
UnitHazardRegisterItemId = x.UnitHazardRegisterItemId,
|
||||
ProblemDescription = x.ProblemDescription,
|
||||
ProblemType = x.ProblemType,
|
||||
RiskLevel = x.RiskLevel,
|
||||
RectifyRequirement = x.RectifyRequirement,
|
||||
CompleteStatus = x.CompleteStatus,
|
||||
CompletedDate = x.CompletedDate
|
||||
}).ToList();
|
||||
|
||||
Grid1.DataSource = items;
|
||||
Grid1.DataBind();
|
||||
}
|
||||
|
||||
protected void WindowAtt_Close(object sender, WindowCloseEventArgs e)
|
||||
{
|
||||
// 刷新Grid数据
|
||||
JArray teamGroupData = Grid1.GetMergedData();
|
||||
List<JObject> list = new List<JObject>();
|
||||
foreach (JObject teamGroupRow in teamGroupData)
|
||||
{
|
||||
JObject values = teamGroupRow.Value<JObject>("values");
|
||||
values.Add("UnitHazardRegisterItemId", teamGroupRow.Value<string>("id"));
|
||||
list.Add(values);
|
||||
}
|
||||
Grid1.DataSource = list;
|
||||
Grid1.DataBind();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除提示
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string GetDeleteScript()
|
||||
{
|
||||
return Confirm.GetShowReference("删除选中行?", String.Empty, MessageBoxIcon.Question, Grid1.GetDeleteSelectedRowsReference(), String.Empty);
|
||||
}
|
||||
|
||||
#endregion Methods
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 企业级检查明细视图类
|
||||
/// </summary>
|
||||
public class View_UnitHazardRegisterItem
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public DateTime? CompletedDate { get; set; }
|
||||
public int? CompleteStatus { get; set; }
|
||||
public string ProblemDescription { get; set; }
|
||||
public string ProblemImageUrl { get; set; }
|
||||
public string ProblemType { get; set; }
|
||||
public string RectifyRequirement { get; set; }
|
||||
public string RiskLevel { get; set; }
|
||||
public string UnitHazardRegisterItemId { get; set; }
|
||||
|
||||
#endregion Properties
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user