集成人员同步,专项检查同步
This commit is contained in:
@@ -0,0 +1,778 @@
|
||||
using BLL;
|
||||
using FineUIPro.Web.HSSE.License;
|
||||
using Model;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
|
||||
namespace FineUIPro.Web.HSSE.Check
|
||||
{
|
||||
public partial class CheckSpecialProEdit : PageBase
|
||||
{
|
||||
#region 定义变量
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
public string CheckSpecialId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["CheckSpecialId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["CheckSpecialId"] = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 项目主键
|
||||
/// </summary>
|
||||
public string ProjectId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["ProjectId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["ProjectId"] = value;
|
||||
}
|
||||
}
|
||||
//public List<View_CheckSpecialProDetail> details
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return (List<View_CheckSpecialProDetail>)ViewState["details"];
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// ViewState["details"] = value;
|
||||
// }
|
||||
//}
|
||||
/// <summary>
|
||||
/// 定义集合
|
||||
/// </summary>
|
||||
private static List<Model.View_CheckSpecialProDetail> details = new List<Model.View_CheckSpecialProDetail>();
|
||||
// public List<View_CheckSpecialProDetail> details = new List<View_CheckSpecialProDetail>();
|
||||
#endregion
|
||||
|
||||
|
||||
#region 加载页面
|
||||
/// <summary>
|
||||
/// 加载页面
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
string checkItem = Request.Params["checkItem"];
|
||||
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
||||
this.ProjectId = this.CurrUser.LoginProjectId;
|
||||
this.InitDropDownList();
|
||||
this.InitCheckItemSetDropDownList();
|
||||
this.CheckSpecialId = Request.Params["CheckSpecialId"];
|
||||
var checkSpecial = Check_CheckSpecialProService.GetCheckSpecialByCheckSpecialId(this.CheckSpecialId);
|
||||
Technique_CheckItemSetService.InitCheckItemSetNameDropDownList(this.drpSupCheckItemSet, "2", "0", false);
|
||||
|
||||
|
||||
var sysUser = BLL.ProjectUserService.GetProjectUserByUnitidAndProjectId(CurrUser.LoginProjectId, Const.HSSEManager);
|
||||
List<ListItem> lists = new List<ListItem>();
|
||||
foreach (var item in sysUser)
|
||||
{
|
||||
lists.Add(new ListItem(item.UserName, item.UserId));
|
||||
}
|
||||
drpHSE.Items.Clear();
|
||||
drpHSE.DataValueField = "Value";
|
||||
drpHSE.DataTextField = "Text";
|
||||
drpHSE.DataSource = lists;
|
||||
drpHSE.DataBind();
|
||||
if (checkSpecial != null)
|
||||
{
|
||||
details.Clear();
|
||||
this.ProjectId = checkSpecial.ProjectId;
|
||||
if (this.ProjectId != this.CurrUser.LoginProjectId)
|
||||
{
|
||||
this.InitDropDownList();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(checkSpecial.CheckType))
|
||||
{
|
||||
this.drpType.SelectedValue = checkSpecial.CheckType;
|
||||
}
|
||||
this.InitCheckItemSetDropDownList();
|
||||
this.txtCheckSpecialCode.Text = CodeRecordsService.ReturnCodeByDataId(this.CheckSpecialId);
|
||||
if (checkSpecial.CheckTime != null)
|
||||
{
|
||||
this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", checkSpecial.CheckTime);
|
||||
}
|
||||
this.txtPartInPersonNames.Text = checkSpecial.PartInPersonNames;
|
||||
if (!string.IsNullOrEmpty(checkSpecial.CheckItemSetId))
|
||||
{
|
||||
var getCheckItem = Funs.DB.Technique_CheckItemSet.FirstOrDefault(x => x.CheckItemSetId == checkSpecial.CheckItemSetId);
|
||||
this.drpSupCheckItemSet.SelectedValue = getCheckItem.CheckItemName;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(checkSpecial.PartInPersonIds))
|
||||
{
|
||||
this.drpPartInPersons.SelectedValueArray = checkSpecial.PartInPersonIds.Split(',');
|
||||
}
|
||||
BindDetailGrid();
|
||||
//var checkSpecialDetails = (from x in Funs.DB.View_CheckSpecialProDetail
|
||||
// where x.CheckSpecialId == this.CheckSpecialId
|
||||
// orderby x.UnitName, x.SortIndex
|
||||
// select x).ToList();
|
||||
//if (checkSpecialDetails.Count() > 0)
|
||||
//{
|
||||
// this.drpSupCheckItemSet.Readonly = true;
|
||||
// this.drpType.Readonly = true;
|
||||
//}
|
||||
|
||||
//details = checkSpecialDetails;
|
||||
//Grid1.DataSource = details;
|
||||
//Grid1.DataBind();
|
||||
}
|
||||
else
|
||||
{
|
||||
////自动生成编码
|
||||
this.txtCheckSpecialCode.Text = CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectCheckSpecialMenuId, this.ProjectId, this.CurrUser.UnitId);
|
||||
this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(checkItem))
|
||||
{
|
||||
this.drpSupCheckItemSet.Items.FindByText(checkItem).Selected = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.drpSupCheckItemSet.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// 删除选中单元格的客户端脚本
|
||||
string deleteScript = GetDeleteScript();
|
||||
// 新增数据初始值
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定数据
|
||||
/// </summary>
|
||||
private void BindDetailGrid()
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.CheckSpecialId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var checkSpecialDetails = (from x in Funs.DB.View_CheckSpecialProDetail
|
||||
where x.CheckSpecialId == this.CheckSpecialId
|
||||
orderby x.UnitName, x.SortIndex
|
||||
select x).ToList();
|
||||
if (checkSpecialDetails.Count() > 0)
|
||||
{
|
||||
this.drpSupCheckItemSet.Readonly = true;
|
||||
this.drpType.Readonly = true;
|
||||
}
|
||||
|
||||
details = checkSpecialDetails;
|
||||
Grid1.DataSource = details;
|
||||
Grid1.DataBind();
|
||||
}
|
||||
|
||||
#endregion
|
||||
protected void btnAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
//JObject defaultObj = new JObject
|
||||
// { { "CheckSpecialDetailId",Guid.NewGuid() },
|
||||
// { "CheckAreaName", "" },
|
||||
// { "UnitName", "" },
|
||||
// { "HSEManage",""},
|
||||
// { "Unqualified", "" },
|
||||
// { "attchUrl","上传" },
|
||||
// {"RiskLevel","" },
|
||||
// { "CompleteStatusName", "" },
|
||||
// {"LimitedDate","" },
|
||||
// { "Suggestions",""},
|
||||
// { "HandleStepStr", "" },
|
||||
// { "Delete", String.Format("<a href=\"javascript:;\" onclick=\"{0}\"><img src=\"{1}\"/></a>", deleteScript, IconHelper.GetResolvedIconUrl(Icon.Delete)) }
|
||||
// };
|
||||
//details = (from x in Funs.DB.View_CheckSpecialProDetail
|
||||
// where x.CheckSpecialId == this.CheckSpecialId
|
||||
// orderby x.UnitName, x.SortIndex
|
||||
// select x).ToList();
|
||||
//if (details == null)
|
||||
// details = new List<View_CheckSpecialProDetail>();
|
||||
//View_CheckSpecialProDetail d = new View_CheckSpecialProDetail();
|
||||
//d.CheckSpecialDetailId = Guid.NewGuid().ToString();
|
||||
//details.Add(d);
|
||||
//Grid1.DataSource= details;
|
||||
|
||||
//Grid1.DataBind();
|
||||
|
||||
|
||||
JArray teamGroupData = Grid1.GetMergedData();
|
||||
List<JObject> list = new List<JObject>();
|
||||
foreach (JObject teamGroupRow in teamGroupData)
|
||||
{
|
||||
JObject values = teamGroupRow.Value<JObject>("values");
|
||||
values.Add("CheckSpecialDetailId", teamGroupRow.Value<string>("id"));
|
||||
list.Add(values);
|
||||
}
|
||||
JObject defaultObj = new JObject
|
||||
{ { "CheckSpecialDetailId",Guid.NewGuid() },
|
||||
{ "CheckAreaName", "" },
|
||||
{ "UnitName", "" },
|
||||
{ "HSEManage",""},
|
||||
{ "Unqualified", "" },
|
||||
{"RiskLevel","" },
|
||||
{ "CompleteStatusName", "" },
|
||||
{"LimitedDate","" },
|
||||
{ "Suggestions",""},
|
||||
{ "HandleStepStr", "" },
|
||||
{ "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();
|
||||
// Grid1.GetAddNewRecordReference(defaultObj, true);
|
||||
|
||||
// 在第一行新增一条数据
|
||||
//btnNew.OnClientClick = Grid1.GetAddNewRecordReference(defaultObj, true);
|
||||
}
|
||||
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
||||
{
|
||||
string itemId = Grid1.DataKeys[e.RowIndex][0].ToString();
|
||||
|
||||
if (e.CommandName == "attchUrl")
|
||||
{
|
||||
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/CheckSpecial&menuId={1}&edit=1", itemId, BLL.Const.ProjectCheckSpecialMenuId)));
|
||||
}
|
||||
|
||||
}
|
||||
protected string ConvertImageUrlByImage(object CheckSpecialDetailId)
|
||||
{
|
||||
string url = string.Empty;
|
||||
string httpUrl = string.Empty;
|
||||
var sysSet6 = (from x in Funs.DB.Sys_Set where x.SetName == "程序访问地址" select x).ToList().FirstOrDefault();
|
||||
if (sysSet6 != null)
|
||||
{
|
||||
httpUrl = sysSet6.SetValue;
|
||||
}
|
||||
if (CheckSpecialDetailId != null)
|
||||
{
|
||||
var imhurl = BLL.AttachFileService.getFileUrl(CheckSpecialDetailId.ToString());
|
||||
if (imhurl != null)
|
||||
{
|
||||
url = BLL.UploadAttachmentService.ShowImage(httpUrl, imhurl);
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
/// <summary>
|
||||
/// 初始化下拉框
|
||||
/// </summary>
|
||||
private void InitDropDownList()
|
||||
{
|
||||
ListItem[] item = new ListItem[4];
|
||||
|
||||
item[0] = new ListItem("专项检查", "0");
|
||||
item[1] = new ListItem("安全周检", "1");
|
||||
item[2] = new ListItem("安全月检", "2");
|
||||
item[3] = new ListItem("节假日安全检查", "3");
|
||||
this.drpType.DataValueField = "Value";
|
||||
this.drpType.DataTextField = "Text";
|
||||
this.drpType.DataSource = item;
|
||||
this.drpType.DataBind();
|
||||
//检查组成员
|
||||
UserService.InitUserDropDownList(this.drpPartInPersons, this.ProjectId, true);
|
||||
// ConstValue.InitConstNameDropDownList(this.drpHandleStep, ConstValue.Group_HandleStep, true);
|
||||
///责任单位
|
||||
UnitService.InitUnitNameByProjectIdUnitTypeDropDownList(this.drpWorkUnit, this.ProjectId, null, true);
|
||||
///单位工程
|
||||
UnitWorkService.InitUnitWorkNameDropDownList(this.drpCheckArea, this.ProjectId, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private void SaveNew()
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.CheckSpecialId))
|
||||
{
|
||||
Model.Check_CheckSpecialPro checkSpecial = new Model.Check_CheckSpecialPro
|
||||
{
|
||||
CheckSpecialId = SQLHelper.GetNewID(typeof(Model.Check_CheckSpecialPro)),
|
||||
CheckSpecialCode = this.txtCheckSpecialCode.Text.Trim(),
|
||||
ProjectId = this.ProjectId,
|
||||
CompileMan = this.CurrUser.UserId,
|
||||
};
|
||||
|
||||
///组成员
|
||||
string partInPersonIds = string.Empty;
|
||||
string partInPersons = string.Empty;
|
||||
foreach (var item in this.drpPartInPersons.SelectedValueArray)
|
||||
{
|
||||
var user = BLL.UserService.GetUserByUserId(item);
|
||||
if (user != null)
|
||||
{
|
||||
partInPersonIds += user.UserId + ",";
|
||||
partInPersons += user.UserName + ",";
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(partInPersonIds))
|
||||
{
|
||||
checkSpecial.PartInPersonIds = partInPersonIds.Substring(0, partInPersonIds.LastIndexOf(","));
|
||||
checkSpecial.PartInPersons = partInPersons.Substring(0, partInPersons.LastIndexOf(","));
|
||||
}
|
||||
checkSpecial.PartInPersonNames = this.txtPartInPersonNames.Text.Trim();
|
||||
checkSpecial.CheckTime = Funs.GetNewDateTime(this.txtCheckDate.Text.Trim());
|
||||
|
||||
////单据状态
|
||||
checkSpecial.States = Const.State_0;
|
||||
this.CheckSpecialId = checkSpecial.CheckSpecialId;
|
||||
checkSpecial.CompileMan = this.CurrUser.UserId;
|
||||
BLL.Check_CheckSpecialProService.AddCheckSpecial(checkSpecial);
|
||||
BLL.LogService.AddSys_Log(this.CurrUser, checkSpecial.CheckSpecialCode, checkSpecial.CheckSpecialId, BLL.Const.ProjectCheckSpecialMenuId, BLL.Const.BtnAdd);
|
||||
}
|
||||
}
|
||||
|
||||
#region 提交按钮
|
||||
/// <summary>
|
||||
/// 提交按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.drpType.SelectedValue == "0" && (string.IsNullOrEmpty(this.drpSupCheckItemSet.SelectedValue) || this.drpSupCheckItemSet.SelectedValue == Const._Null))
|
||||
{
|
||||
ShowNotify("请选择检查类别!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
this.SaveData(Const.BtnSubmit);
|
||||
}
|
||||
#endregion
|
||||
public string ConvertDate(object date)
|
||||
{
|
||||
if (date != null)
|
||||
{
|
||||
return string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(date));
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
#region 保存按钮
|
||||
/// <summary>
|
||||
/// 保存按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.drpType.SelectedValue == "0" && (string.IsNullOrEmpty(this.drpSupCheckItemSet.SelectedValue) || this.drpSupCheckItemSet.SelectedValue == Const._Null))
|
||||
{
|
||||
ShowNotify("请选择检查类别!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
this.SaveData(Const.BtnSave);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 保存方法
|
||||
/// <summary>
|
||||
/// 保存数据
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
private void SaveData(string type)
|
||||
{
|
||||
Model.Check_CheckSpecialPro checkSpecial = new Model.Check_CheckSpecialPro
|
||||
{
|
||||
CheckSpecialCode = this.txtCheckSpecialCode.Text.Trim(),
|
||||
ProjectId = this.ProjectId,
|
||||
PartInPersonNames = this.txtPartInPersonNames.Text.Trim(),
|
||||
CheckTime = Funs.GetNewDateTime(this.txtCheckDate.Text.Trim()),
|
||||
CompileMan = this.CurrUser.UserId,
|
||||
CheckType = this.drpType.SelectedValue,
|
||||
////单据状态
|
||||
States = Const.State_0,
|
||||
};
|
||||
///组成员
|
||||
string partInPersonIds = string.Empty;
|
||||
string partInPersons = string.Empty;
|
||||
foreach (var item in this.drpPartInPersons.SelectedValueArray)
|
||||
{
|
||||
var user = BLL.UserService.GetUserByUserId(item);
|
||||
if (user != null)
|
||||
{
|
||||
partInPersonIds += user.UserId + ",";
|
||||
partInPersons += user.UserName + ",";
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(partInPersonIds))
|
||||
{
|
||||
checkSpecial.PartInPersonIds = partInPersonIds.Substring(0, partInPersonIds.LastIndexOf(","));
|
||||
checkSpecial.PartInPersons = partInPersons.Substring(0, partInPersons.LastIndexOf(","));
|
||||
}
|
||||
var getCheckItem = Funs.DB.Technique_CheckItemSet.FirstOrDefault(x => x.CheckItemName == this.drpSupCheckItemSet.SelectedValue);
|
||||
if (getCheckItem != null)
|
||||
{
|
||||
checkSpecial.CheckItemSetId = getCheckItem.CheckItemSetId;
|
||||
}
|
||||
//if (!string.IsNullOrEmpty(this.drpSupCheckItemSet.SelectedValue) && this.drpSupCheckItemSet.SelectedValue != Const._Null)
|
||||
//{
|
||||
// checkSpecial.CheckItemSetId = this.drpSupCheckItemSet.SelectedValue;
|
||||
//}
|
||||
if (!string.IsNullOrEmpty(this.CheckSpecialId))
|
||||
{
|
||||
checkSpecial.CheckSpecialId = this.CheckSpecialId;
|
||||
Check_CheckSpecialProService.UpdateCheckSpecial(checkSpecial);
|
||||
LogService.AddSys_Log(this.CurrUser, checkSpecial.CheckSpecialCode, checkSpecial.CheckSpecialId, BLL.Const.ProjectCheckSpecialMenuId, BLL.Const.BtnModify);
|
||||
// Check_CheckSpecialProDetailService.DeleteCheckSpecialDetails(this.CheckSpecialId);
|
||||
}
|
||||
else
|
||||
{
|
||||
checkSpecial.CheckSpecialId = SQLHelper.GetNewID(typeof(Model.Check_CheckSpecialPro));
|
||||
this.CheckSpecialId = checkSpecial.CheckSpecialId;
|
||||
checkSpecial.CompileMan = this.CurrUser.UserId;
|
||||
|
||||
Check_CheckSpecialProService.AddCheckSpecial(checkSpecial);
|
||||
LogService.AddSys_Log(this.CurrUser, checkSpecial.CheckSpecialCode, checkSpecial.CheckSpecialId, BLL.Const.ProjectCheckSpecialMenuId, BLL.Const.BtnAdd);
|
||||
}
|
||||
// Project_HSSEData_HSSEService.StatisticalData(this.CurrUser.LoginProjectId, Project_HSSEData_HSSEService.HSSEDateType.SupervisionAndInspection);
|
||||
ShowNotify(this.SaveDetail(type, checkSpecial), MessageBoxIcon.Success);
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存明细项
|
||||
/// </summary>
|
||||
private string SaveDetail(string type, Model.Check_CheckSpecialPro checkSpecial)
|
||||
{
|
||||
string info = string.Empty;
|
||||
var unitWorks = from x in Funs.DB.WBS_UnitWork
|
||||
where x.ProjectId == this.ProjectId && x.SuperUnitWork == null
|
||||
orderby x.UnitWorkCode
|
||||
select new
|
||||
{
|
||||
x.UnitWorkId,
|
||||
UnitWorkName = BLL.UnitWorkService.GetUnitWorkALLName(x.UnitWorkId)
|
||||
};
|
||||
var olddetailLists = Check_CheckSpecialProDetailService.GetCheckSpecialDetailByCheckSpecialId(this.CheckSpecialId);
|
||||
List<string> needRemove = new List<string>();
|
||||
foreach (var oldDetail in olddetailLists)
|
||||
{
|
||||
bool hasFind = false;
|
||||
for (int i = 0; i < Grid1.Rows.Count; i++)
|
||||
{
|
||||
if (oldDetail.CheckSpecialDetailId == Grid1.Rows[i].DataKeys[0].ToString())
|
||||
{
|
||||
hasFind = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasFind)
|
||||
{
|
||||
Check_CheckSpecialProDetailService.DeleteCheckSpecialDetailById(oldDetail.CheckSpecialDetailId);
|
||||
}
|
||||
}
|
||||
List<Model.Check_CheckSpecialProDetail> detailLists = new List<Model.Check_CheckSpecialProDetail>();
|
||||
JArray teamGroupData = Grid1.GetMergedData();
|
||||
foreach (JObject teamGroupRow in teamGroupData)
|
||||
{
|
||||
JObject values = teamGroupRow.Value<JObject>("values");
|
||||
int rowIndex = teamGroupRow.Value<int>("index");
|
||||
Model.Check_CheckSpecialProDetail newDetail = new Model.Check_CheckSpecialProDetail
|
||||
{
|
||||
CheckSpecialDetailId = values.Value<string>("CheckSpecialDetailId"),
|
||||
CheckSpecialId = this.CheckSpecialId,
|
||||
CheckContent = values.Value<string>("CheckItemName"),
|
||||
Unqualified = values.Value<string>("Unqualified"),
|
||||
Suggestions = values.Value<string>("Suggestions"),
|
||||
RectifyOpinion = values.Value<string>("RectifyOpinion"),
|
||||
ProposeUnitId = this.CurrUser.UnitId
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(values.Value<string>("RectifyOpinion")))
|
||||
{
|
||||
if (values.Value<string>("RectifyOpinion") == "")
|
||||
newDetail.HandleStep = "";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(values.Value<string>("LimitedDate")))
|
||||
{
|
||||
newDetail.LimitedDate = values.Value<DateTime>("LimitedDate");
|
||||
}
|
||||
var HSE = Funs.DB.Sys_User.FirstOrDefault(x => x.UserName == values.Value<string>("HSE"));
|
||||
var getUnit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitName == values.Value<string>("UnitName"));
|
||||
if (getUnit != null)
|
||||
{
|
||||
newDetail.UnitId = getUnit.UnitId;
|
||||
}
|
||||
var getF = from x in unitWorks.ToList()
|
||||
where x.UnitWorkName == values.Value<string>("CheckAreaName")
|
||||
select x;
|
||||
if (getF.FirstOrDefault() != null)
|
||||
{
|
||||
newDetail.CheckArea = getF.FirstOrDefault().UnitWorkId;
|
||||
}
|
||||
//var getUnitWork = Funs.DB.WBS_UnitWork.FirstOrDefault(x => x.UnitWorkName == values.Value<string>("CheckAreaName")
|
||||
//&& x.ProjectId == this.ProjectId);
|
||||
//if (getUnitWork != null)
|
||||
//{
|
||||
// newDetail.CheckArea = getUnitWork.UnitWorkId;
|
||||
//}
|
||||
if (!string.IsNullOrEmpty(values.Value<string>("HSEManage")))
|
||||
{
|
||||
string hsemange = values.Value<string>("HSEManage");
|
||||
if (hsemange.Split('-').Length == 5)
|
||||
{
|
||||
newDetail.HSEManage = values.Value<string>("HSEManage");
|
||||
}
|
||||
else
|
||||
{
|
||||
var sysUser = BLL.ProjectUserService.GetProjectUserByUnitidAndProjectId(CurrUser.LoginProjectId, Const.HSSEManager);
|
||||
Sys_User user = sysUser.FirstOrDefault(x => x.UserName == hsemange);
|
||||
if (user != null)
|
||||
{
|
||||
newDetail.HSEManage = user.UserId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (values.Value<string>("CompleteStatusName") == "已整改")
|
||||
{
|
||||
newDetail.CompleteStatus = true;
|
||||
newDetail.CompletedDate = DateTime.Now;
|
||||
}
|
||||
else
|
||||
{
|
||||
newDetail.CompleteStatus = false;
|
||||
}
|
||||
var getCheckItem = Funs.DB.HSSE_Hazard_HazardRegisterTypes.FirstOrDefault(x => x.RegisterTypesName == values.Value<string>("CheckItemName"));
|
||||
if (getCheckItem != null)
|
||||
{
|
||||
newDetail.CheckItem = getCheckItem.RegisterTypesId;
|
||||
}
|
||||
newDetail.SortIndex = rowIndex;
|
||||
if (Grid1.Rows[rowIndex].DataKeys.Length > 0)
|
||||
{
|
||||
newDetail.CheckSpecialDetailId = Grid1.Rows[rowIndex].DataKeys[0].ToString();
|
||||
}
|
||||
switch (values.Value<string>("RiskLevel"))
|
||||
{
|
||||
case "低": newDetail.RiskLevel = "0"; break;
|
||||
case "一般": newDetail.RiskLevel = "1"; break;
|
||||
case "较高": newDetail.RiskLevel = "2"; break;
|
||||
case "高": newDetail.RiskLevel = "3"; break;
|
||||
}
|
||||
if (string.IsNullOrEmpty(newDetail.CheckSpecialDetailId))
|
||||
{
|
||||
Check_CheckSpecialProDetailService.AddCheckSpecialDetail(newDetail);
|
||||
}
|
||||
else
|
||||
{
|
||||
Check_CheckSpecialProDetailService.UpdateCheckSpecialDetail(newDetail);
|
||||
}
|
||||
detailLists.Add(newDetail);
|
||||
}
|
||||
if (type == Const.BtnSubmit)
|
||||
{
|
||||
var getDails = detailLists.Where(x => x.CompleteStatus == false);
|
||||
if (getDails.Count() > 0)
|
||||
{
|
||||
checkSpecial.States = Const.State_1;
|
||||
info = Check_CheckSpecialProService.IssueRectification(getDails.ToList(), checkSpecial);
|
||||
}
|
||||
else
|
||||
{
|
||||
checkSpecial.States = Const.State_2;
|
||||
Check_CheckSpecialProService.UpdateCheckSpecial(checkSpecial);
|
||||
info = "提交成功!";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
info = "保存成功!";
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 附件上传
|
||||
/// <summary>
|
||||
/// 上传附件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnAttachUrl_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.CheckSpecialId))
|
||||
{
|
||||
SaveNew();
|
||||
}
|
||||
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/CheckSpecial&menuId={1}", this.CheckSpecialId, BLL.Const.ProjectCheckSpecialMenuId)));
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <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();
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除提示
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string GetDeleteScript()
|
||||
{
|
||||
return Confirm.GetShowReference("删除选中行?", String.Empty, MessageBoxIcon.Question, Grid1.GetDeleteSelectedRowsReference(), String.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void drpSupCheckItemSet_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
//this.drpCheckItem.Items.Clear();
|
||||
//Technique_CheckItemSetService.InitCheckItemSetNameDropDownList(this.drpCheckItem, "2", this.drpSupCheckItemSet.SelectedValue, false);
|
||||
}
|
||||
protected void drpWorkUnit_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
//for (int i = 0; i < this.Grid1.Rows.Count; i++)
|
||||
//{
|
||||
// DropDownList drpUnitWork = (DropDownList)Grid1.Rows[i].FindControl("drpUnitWork");
|
||||
// if(((DropDownList)sender).ID == drpUnitWork.ID)
|
||||
// {
|
||||
//DropDownList drpHSE = (DropDownList)Grid1.Rows[i].FindControl("drpHSE");
|
||||
|
||||
string unitName = ((DropDownList)sender).SelectedValue;
|
||||
string id = "";
|
||||
if (unitName != BLL.Const._Null)
|
||||
{
|
||||
var unit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitName == unitName);
|
||||
if (unit != null)
|
||||
{
|
||||
id = unit.UnitId;
|
||||
}
|
||||
}
|
||||
|
||||
var sysUser = BLL.ProjectUserService.GetProjectUserByUnitidAndProjectId(CurrUser.LoginProjectId, Const.HSSEManager);
|
||||
List<ListItem> lists = new List<ListItem>();
|
||||
foreach (var item in sysUser)
|
||||
{
|
||||
lists.Add(new ListItem(item.UserName, item.UserName));
|
||||
}
|
||||
drpHSE.Items.Clear();
|
||||
drpHSE.DataValueField = "Value";
|
||||
drpHSE.DataTextField = "Value";
|
||||
drpHSE.DataSource = lists;
|
||||
drpHSE.DataBind();
|
||||
|
||||
// }
|
||||
//}
|
||||
|
||||
//this.drpHSE.Items.Clear();
|
||||
//this.drpHSE.DataValueField = "UserId";
|
||||
//this.drpHSE.DataTextField = "UserId";
|
||||
//this.drpHSE.DataSource=BLL.ProjectUserService.GetProjectUserByProjectId(CurrUser.LoginProjectId, Const.HSSEManager);
|
||||
}
|
||||
|
||||
protected void drpPartInPersons_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.drpPartInPersons.SelectedValueArray = Funs.RemoveDropDownListNull(this.drpPartInPersons.SelectedValueArray);
|
||||
|
||||
}
|
||||
|
||||
protected void rbType_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
InitCheckItemSetDropDownList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private void InitCheckItemSetDropDownList()
|
||||
{
|
||||
this.drpCheckItem.DataTextField = "RegisterTypesName";
|
||||
this.drpCheckItem.DataValueField = "RegisterTypesName";
|
||||
this.drpCheckItem.DataSource = BLL.HSSE_Hazard_HazardRegisterTypesService.GetHazardRegisterTypesList("1"); //安全巡检类型
|
||||
this.drpCheckItem.DataBind();
|
||||
//this.drpCheckItem.SelectedValue = null;
|
||||
ListItem[] item = new ListItem[4];
|
||||
|
||||
item[0] = new ListItem("低风险", "低");
|
||||
item[1] = new ListItem("一般风险", "一般");
|
||||
item[2] = new ListItem("较大风险", "较高");
|
||||
item[3] = new ListItem("重大风险", "高");
|
||||
this.drpRiskLevel.DataValueField = "Value";
|
||||
this.drpRiskLevel.DataTextField = "Text";
|
||||
this.drpRiskLevel.DataSource = item;
|
||||
this.drpRiskLevel.DataBind();
|
||||
}
|
||||
|
||||
protected void drpCheckItem_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
// this.drpCheckItem.SelectedValueArray = Funs.RemoveDropDownListNull(this.drpCheckItem.SelectedValueArray);
|
||||
}
|
||||
|
||||
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
||||
{
|
||||
var checkSpecialDetails = (from x in Funs.DB.View_CheckSpecialProDetail
|
||||
where x.CheckSpecialId == this.CheckSpecialId
|
||||
orderby x.SortIndex
|
||||
select x).ToList();
|
||||
if (checkSpecialDetails.Count() > 0)
|
||||
{
|
||||
this.drpSupCheckItemSet.Readonly = true;
|
||||
this.drpType.Readonly = true;
|
||||
}
|
||||
details = checkSpecialDetails;
|
||||
Grid1.DataSource = details;
|
||||
Grid1.DataBind();
|
||||
}
|
||||
|
||||
|
||||
#region 导入
|
||||
/// <summary>
|
||||
/// 导入按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnImport_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.CheckSpecialId))
|
||||
{
|
||||
SaveNew();
|
||||
}
|
||||
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("CheckSpecialDetailIn.aspx?ProjectId={0}&CheckSpecialId={1}", this.ProjectId, this.CheckSpecialId, "导入 - ")));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭导入弹出窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Window2_Close(object sender, WindowCloseEventArgs e)
|
||||
{
|
||||
BindDetailGrid();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user