合并最新

This commit is contained in:
2022-12-20 09:32:32 +08:00
parent 844e9f1488
commit 1abdaa9476
654 changed files with 73563 additions and 9746 deletions
@@ -6,25 +6,12 @@ using System.Linq;
using System.Text;
using BLL;
using AspNet = System.Web.UI.WebControls;
using Newtonsoft.Json.Linq;
namespace FineUIPro.Web.HSSE.Manager
{
public partial class ManagerMonthC : PageBase
{
/// <summary>
/// 项目主键
/// </summary>
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
#region
/// <summary>
@@ -34,54 +21,388 @@ namespace FineUIPro.Web.HSSE.Manager
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
// 表头过滤
//FilterDataRowItem = FilterDataRowItemImplement;
if (!IsPostBack)
{
this.ProjectId = this.CurrUser.LoginProjectId;
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.ProjectId)
{
this.ProjectId = Request.Params["projectId"];
}
////权限按钮方法
this.GetButtonPower();
this.txtReportDate.Text = string.Format("{0:yyyy-MM}",DateTime.Now);
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
this.txtReportYear.Text = string.Format("{0:yyyy}", DateTime.Now);
// 绑定表格
BindGrid();
//BindGrid();
InitTreeMenu();
}
}
private void InitTreeMenu()
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode = new TreeNode();
rootNode.Text = "年份";
rootNode.NodeID = "0";
rootNode.Expanded = true;
this.tvControlItem.Nodes.Add(rootNode);
var report = from x in Funs.DB.HSSE_MonthReport
where x.ProjectId == CurrUser.LoginProjectId orderby x.Years
select x;
if (report.Count() > 0)
{
foreach (var y in report)
{
TreeNode tnYear = new TreeNode();//年节点
tnYear.Text = y.Years.HasValue ? y.Years.Value.ToString() : "";
tnYear.NodeID = y.MonthReportId;
tnYear.EnableClickEvent = true;
rootNode.Nodes.Add(tnYear);
}
}
}
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
BindGrid();
}
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
string strSql = @"SELECT MonthReport.MonthReportId,MonthReport.ProjectId,MonthReport.Months,CodeRecords.Code AS MonthReportCode,Users.UserName as ReportManName"
+ @" FROM Manager_MonthReportC AS MonthReport "
+ @" LEFT JOIN Sys_User AS Users ON MonthReport.ReportMan=Users.UserId "
+ @" LEFT JOIN Sys_CodeRecords AS CodeRecords ON MonthReport.MonthReportId=CodeRecords.DataId WHERE 1=1 ";
string strSql = @"SELECT item.* ,ISNULL(0,t.SumProjectTotal) AS SumProjectTotal
FROM dbo.HSSE_MonthReportItem item
LEFT JOIN dbo.HSSE_MonthReport r ON r.MonthReportId = item.MonthReportId
LEFT JOIN (SELECT a.MonthReportItemId,ISNULL(0,SUM(ISNULL(0,a.ProjectTotal))) AS SumProjectTotal
FROM dbo.HSSE_MonthReportItem a
LEFT JOIN dbo.HSSE_MonthReport b ON b.MonthReportId = a.MonthReportId
WHERE b.ProjectId=@ProjectId AND b.Years<>DATENAME(YEAR,GETDATE())
GROUP BY a.MonthReportItemId )t ON t.MonthReportItemId = item.MonthReportItemId
WHERE r.ProjectId=@ProjectId AND r.MonthReportId=@MonthReportId
ORDER BY item.Sort";
List<SqlParameter> listStr = new List<SqlParameter>();
strSql += " AND MonthReport.ProjectId = @ProjectId";
listStr.Add(new SqlParameter("@ProjectId", this.ProjectId));
listStr.Add(new SqlParameter("@ProjectId",CurrUser.LoginProjectId));
listStr.Add(new SqlParameter("@MonthReportId", tvControlItem.SelectedNodeID));
if (!string.IsNullOrEmpty(this.txtMonthReportCode.Text.Trim()))
{
strSql += " AND CodeRecords.Code LIKE @MonthReportCode";
listStr.Add(new SqlParameter("@MonthReportCode", "%" + this.txtMonthReportCode.Text.Trim() + "%"));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter);
// 2.获取当前分页数据
//var table = this.GetPagedDataTable(Grid1, tb1);
Grid1.RecordCount = tb.Rows.Count;
tb = GetFilteredTable(Grid1.FilteredData, tb);
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataSource = dt;
Grid1.DataBind();
}
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
{
int cm = GetCurMonth();
for (int i = 1; i <= 12; i++)
{
if (i != cm)
{
string monthC = "Month" + i.ToString();
RenderField month = Grid1.FindColumn(monthC) as RenderField;
e.CellCssClasses[month.ColumnIndex] = "f-grid-cell-uneditable";
}
else
{
string monthC = "Month" + i.ToString();
RenderField month = Grid1.FindColumn(monthC) as RenderField;
RenderField yearTotal = Grid1.FindColumn("YearTotal") as RenderField;
RenderField projectTotal = Grid1.FindColumn("ProjectTotal") as RenderField;
RenderField sumProjectTotal = Grid1.FindColumn("SumProjectTotal") as RenderField;
if (e.RowIndex == 0) // 成达公司现场人数
{
var person = from x in Funs.DB.SitePerson_Person
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
where x.ProjectId == this.CurrUser.LoginProjectId && y.UnitCode == "CHENGDA"
select x;
if (e.Values[month.ColumnIndex].ToString() == "")
{
e.Values[month.ColumnIndex] = person.Count();
}
}
if (e.RowIndex == 1) // 成达公司HSE管理人数
{
var person = from x in Funs.DB.SitePerson_Person
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
join z in Funs.DB.Base_WorkPost on x.WorkPostId equals z.WorkPostId
where x.ProjectId == this.CurrUser.LoginProjectId && y.UnitCode == "CHENGDA"
&& z.WorkPostName.Contains("安全")
select x;
if (e.Values[month.ColumnIndex].ToString() == "")
{
e.Values[month.ColumnIndex] = person.Count();
}
}
if (e.RowIndex == 2) // 分包商现场人数
{
var person = from x in Funs.DB.SitePerson_Person
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
where x.ProjectId == this.CurrUser.LoginProjectId && y.UnitCode != "CHENGDA"
select x;
if (e.Values[month.ColumnIndex].ToString() == "")
{
e.Values[month.ColumnIndex] = person.Count();
}
}
if (e.RowIndex == 3) // 分包商HSE管理人数
{
var person = from x in Funs.DB.SitePerson_Person
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
join z in Funs.DB.Base_WorkPost on x.WorkPostId equals z.WorkPostId
where x.ProjectId == this.CurrUser.LoginProjectId && y.UnitCode != "CHENGDA"
&& z.WorkPostName.Contains("安全")
select x;
if (e.Values[month.ColumnIndex].ToString() == "")
{
e.Values[month.ColumnIndex] = person.Count();
}
}
if (e.RowIndex == 4 || e.RowIndex == 5) // 人工时数,安全生产人工时数
{
DateTime? sDate = Convert.ToDateTime(tvControlItem.SelectedNode.Text + "-" + i.ToString());
var dayReports = BLL.SitePerson_MonthReportService.getMonthReports(this.CurrUser.LoginProjectId, sDate);
if (e.Values[month.ColumnIndex].ToString() == "" && dayReports.Count() > 0)
{
e.Values[month.ColumnIndex] = dayReports.First().DayWorkTime;
}
else
{
e.Values[month.ColumnIndex] = 0;
}
}
DateTime startDate = Convert.ToDateTime(tvControlItem.SelectedNode.Text + "-" + i.ToString() + "-01");
if (e.RowIndex == 6) // HSE记录事故数量
{
var accident = from x in Funs.DB.Accident_AccidentPersonRecord
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1)
select x;
if (e.Values[month.ColumnIndex].ToString() == "")
{
e.Values[month.ColumnIndex] = accident.Count();
}
}
if (e.RowIndex == 7) // 死亡
{
var accident = from x in Funs.DB.Accident_AccidentPersonRecord
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1)
&& x.Injury=="1"
select x;
if (e.Values[month.ColumnIndex].ToString() == "")
{
e.Values[month.ColumnIndex] = accident.Count();
}
}
if (e.RowIndex == 8) // 重伤
{
var accident = from x in Funs.DB.Accident_AccidentPersonRecord
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1)
&& x.Injury == "2"
select x;
if (e.Values[month.ColumnIndex].ToString() == "")
{
e.Values[month.ColumnIndex] = accident.Count();
}
}
if (e.RowIndex == 9) // 轻伤
{
var accident = from x in Funs.DB.Accident_AccidentPersonRecord
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1)
&& x.Injury == "3"
select x;
if (e.Values[month.ColumnIndex].ToString() == "")
{
e.Values[month.ColumnIndex] = accident.Count();
}
}
if (e.RowIndex == 10) // 未遂事故
{
var accident = from x in Funs.DB.Accident_AccidentHandle
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1)
select x;
if (e.Values[month.ColumnIndex].ToString() == "")
{
e.Values[month.ColumnIndex] = accident.Count();
}
}
if (e.RowIndex == 11) // 现场环境事故
{
if (e.Values[month.ColumnIndex].ToString() == "")
{
e.Values[month.ColumnIndex] = "0";
}
}
if (e.RowIndex == 12) // 现场发生设备材料盗窃案件
{
if (e.Values[month.ColumnIndex].ToString() == "")
{
e.Values[month.ColumnIndex] = "0";
}
}
if (e.RowIndex == 13) // HSE周会
{
var weekMeeting = from x in Funs.DB.Meeting_WeekMeeting
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.WeekMeetingDate >= startDate && x.WeekMeetingDate < startDate.AddMonths(1)
select x;
if (e.Values[month.ColumnIndex].ToString() == "")
{
e.Values[month.ColumnIndex] = weekMeeting.Count();
}
}
if (e.RowIndex == 14) // HSE委员会会议
{
var weekMeeting = from x in Funs.DB.Meeting_AttendMeeting
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.AttendMeetingDate >= startDate && x.AttendMeetingDate < startDate.AddMonths(1)
select x;
if (e.Values[month.ColumnIndex].ToString() == "")
{
e.Values[month.ColumnIndex] = weekMeeting.Count();
}
}
if (e.RowIndex == 15) // 施工现场HSE联检
{
if (e.Values[month.ColumnIndex].ToString() == "")
{
e.Values[month.ColumnIndex] = "0";
}
}
if (e.RowIndex == 16) // 发布HSE整改通知书
{
var check = from x in Funs.DB.Check_RectifyNotices
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.CheckedDate >= startDate && x.CheckedDate < startDate.AddMonths(1)
select x;
if (e.Values[month.ColumnIndex].ToString() == "")
{
e.Values[month.ColumnIndex] = check.Count();
}
}
if (e.RowIndex == 17) // 关闭HSE整改通知书
{
var check = from x in Funs.DB.Check_RectifyNotices
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.CompleteDate >= startDate && x.CompleteDate < startDate.AddMonths(1)
select x;
if (e.Values[month.ColumnIndex].ToString() == "")
{
e.Values[month.ColumnIndex] = check.Count();
}
}
if (e.RowIndex == 18) // 发布HSE处罚书
{
var check = from x in Funs.DB.Check_PunishNotice
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.PunishNoticeDate >= startDate && x.PunishNoticeDate < startDate.AddMonths(1)
select x;
if (e.Values[month.ColumnIndex].ToString() == "")
{
e.Values[month.ColumnIndex] = check.Count();
}
}
if (e.RowIndex == 19) // 发布应急预案
{
var em = from x in Funs.DB.Emergency_EmergencyList
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.CompileDate >= startDate && x.CompileDate < startDate.AddMonths(1)
select x;
if (e.Values[month.ColumnIndex].ToString() == "")
{
e.Values[month.ColumnIndex] = em.Count();
}
}
if (e.RowIndex == 20) // 人员培训
{
var edu = from x in Funs.DB.EduTrain_TrainRecord
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.TrainStartDate >= startDate && x.TrainStartDate < startDate.AddMonths(1)
select x;
if (e.Values[month.ColumnIndex].ToString() == "")
{
if (edu.Count() > 0)
{
e.Values[month.ColumnIndex] = edu.Sum(x => x.TrainPersonNum);
}
else
{
e.Values[month.ColumnIndex] = 0;
}
}
}
if (e.RowIndex == 21) // 设备HSE检验
{
var equ = from x in Funs.DB.License_EquipmentSafetyList
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.CompileDate >= startDate && x.CompileDate < startDate.AddMonths(1)
select x;
if (e.Values[month.ColumnIndex].ToString() == "")
{
if (equ.Count()>0)
{
e.Values[month.ColumnIndex] = equ.Sum(x => x.EquipmentSafetyListCount);
}
else
{
e.Values[month.ColumnIndex] = 0;
}
}
}
RenderField month1 = Grid1.FindColumn("Month1") as RenderField;
RenderField month2 = Grid1.FindColumn("Month2") as RenderField;
RenderField month3 = Grid1.FindColumn("Month3") as RenderField;
RenderField month4 = Grid1.FindColumn("Month4") as RenderField;
RenderField month5 = Grid1.FindColumn("Month5") as RenderField;
RenderField month6 = Grid1.FindColumn("Month6") as RenderField;
RenderField month7 = Grid1.FindColumn("Month7") as RenderField;
RenderField month8 = Grid1.FindColumn("Month8") as RenderField;
RenderField month9 = Grid1.FindColumn("Month9") as RenderField;
RenderField month10 = Grid1.FindColumn("Month10") as RenderField;
RenderField month11 = Grid1.FindColumn("Month11") as RenderField;
RenderField month12 = Grid1.FindColumn("Month12") as RenderField;
// 年度总计
e.Values[yearTotal.ColumnIndex] = Convert.ToInt32(e.Values[month1.ColumnIndex].ToString() != "" ? e.Values[month1.ColumnIndex] : 0)
+ Convert.ToInt32(e.Values[month2.ColumnIndex].ToString() != "" ? e.Values[month2.ColumnIndex] : 0)
+ Convert.ToInt32(e.Values[month3.ColumnIndex].ToString() != "" ? e.Values[month3.ColumnIndex] : 0)
+ Convert.ToInt32(e.Values[month4.ColumnIndex].ToString() != "" ? e.Values[month4.ColumnIndex] : 0)
+ Convert.ToInt32(e.Values[month5.ColumnIndex].ToString() != "" ? e.Values[month5.ColumnIndex] : 0)
+ Convert.ToInt32(e.Values[month6.ColumnIndex].ToString() != "" ? e.Values[month6.ColumnIndex] : 0)
+ Convert.ToInt32(e.Values[month7.ColumnIndex].ToString() != "" ? e.Values[month7.ColumnIndex] : 0)
+ Convert.ToInt32(e.Values[month8.ColumnIndex].ToString() != "" ? e.Values[month8.ColumnIndex] : 0)
+ Convert.ToInt32(e.Values[month9.ColumnIndex].ToString() != "" ? e.Values[month9.ColumnIndex] : 0)
+ Convert.ToInt32(e.Values[month10.ColumnIndex].ToString() != "" ? e.Values[month10.ColumnIndex] : 0)
+ Convert.ToInt32(e.Values[month11.ColumnIndex].ToString() != "" ? e.Values[month11.ColumnIndex] : 0)
+ Convert.ToInt32(e.Values[month12.ColumnIndex].ToString() != "" ? e.Values[month12.ColumnIndex] : 0);
// 项目总计
e.Values[projectTotal.ColumnIndex] = Convert.ToInt32(e.Values[yearTotal.ColumnIndex]) + Convert.ToInt32(e.Values[sumProjectTotal.ColumnIndex]);
}
}
}
#endregion
@@ -97,191 +418,7 @@ namespace FineUIPro.Web.HSSE.Manager
}
#endregion
#region
/// <summary>
/// 过滤表头
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_FilterChange(object sender, EventArgs e)
{
BindGrid();
}
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
Grid1.PageIndex = e.NewPageIndex;
BindGrid();
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
Grid1.SortDirection = e.SortDirection;
Grid1.SortField = e.SortField;
BindGrid();
}
/// <summary>
/// 分页显示条数下拉框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
/// <summary>
/// 关闭弹出窗
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
#endregion
#region Grid双击事件
/// <summary>
/// Grid行双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
btnMenuModify_Click(null, null);
}
#endregion
#region
/// <summary>
/// 编辑按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuModify_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string MonthReportId = Grid1.SelectedRowID;
var monthReport = BLL.MonthReportCService.GetMonthReportByMonthReportId(MonthReportId);
int n = 6; //月报冻结时间
var sysSet = BLL.ConstValue.drpConstItemList(BLL.ConstValue.Group_MonthReportFreezeDay).FirstOrDefault();
if (sysSet != null)
{
n = Convert.ToInt32(sysSet.ConstValue);
}
if (monthReport != null)
{
int d = Convert.ToInt32(DateTime.Now.Day);
if ((monthReport.Months.Value.Year == DateTime.Now.Year && monthReport.Months.Value.Month == DateTime.Now.Month) ||
((monthReport.Months.Value.AddMonths(1).Month == DateTime.Now.Month) && d < n + 1))
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("MonthReportCEdit.aspx?MonthReportId={0}", MonthReportId, "编辑 - ")));
}
else
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("MonthReportCView.aspx?MonthReportId={0}", MonthReportId, "查看 - ")));
}
}
}
#endregion
#region
/// <summary>
/// 导出按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuOut_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string MonthReportId = Grid1.SelectedRowID;
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("MonthReportCOut.aspx?MonthReportId={0}", MonthReportId, "编辑 - ")));
}
#endregion
#region
/// <summary>
/// 批量删除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDel_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length > 0)
{
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
var mont = BLL.MonthReportCService.GetMonthReportByMonthReportId(rowID);
if (mont != null)
{
BLL.LogService.AddSys_Log(this.CurrUser, mont.MonthReportCode, mont.MonthReportId, BLL.Const.ProjectManagerMonthCMenuId, BLL.Const.BtnDelete);
BLL.PersonSortCService.DeletePersonSortsByMonthReportId(rowID);
BLL.HazardSortCService.DeleteHazardSortsByMonthReportId(rowID);
BLL.AccidentSortCService.DeleteAccidentSortsByMonthReportId(rowID);
BLL.HseCostCService.DeleteHseCostsByMonthReportId(rowID);
BLL.TrainSortCService.DeleteTrainSortsByMonthReportId(rowID);
BLL.TrainActivitySortCService.DeleteTrainActivitySortsByMonthReportId(rowID);
BLL.MeetingSortCService.DeleteMeetingSortsByMonthReportId(rowID);
BLL.CheckSortCService.DeleteCheckSortsByMonthReportId(rowID);
BLL.CheckDetailSortCService.DeleteCheckDetailSortsByMonthReportId(rowID);
BLL.PromotionalActiviteSortCService.DeletePromotionalActiviteSortsByMonthReportId(rowID);
BLL.EmergencySortCService.DeleteEmergencySortsByMonthReportId(rowID);
BLL.DrillSortCService.DeleteDrillSortsByMonthReportId(rowID);
BLL.IncentiveSortCService.DeleteIncentiveSortsByMonthReportId(rowID);
BLL.OtherActiveSortCService.DeleteOtherActiveSortsByMonthReportId(rowID);
BLL.ActivityDesCService.DeleteActivityDesByMonthReportId(rowID);
BLL.OtherManagementCService.DeleteOtherManagementByMonthReportId(rowID);
BLL.PlanCService.DeletePlanByMonthReportId(rowID);
BLL.ReviewRecordCService.DeleteReviewRecordByMonthReportId(rowID);
BLL.FileManageCService.DeleteFileManageByMonthReportId(rowID);
BLL.FiveExpenseCService.DeleteFiveExpenseByMonthReportId(rowID);
BLL.SubExpenseCService.DeleteSubExpenseByMonthReportId(rowID);
BLL.AccidentDesciptionItemCService.DeleteAccidentDesciptionItemByMonthReportId(rowID);
BLL.AccidentDesciptionCService.DeleteAccidentDesciptionByMonthReportId(rowID);
BLL.OtherWorkCService.DeleteOtherWorkByMonthReportId(rowID);
BLL.HazardCService.DeleteHazardByMonthReportId(rowID);
BLL.TrainCService.DeleteTrainByMonthReportId(rowID);
BLL.CheckCService.DeleteCheckByMonthReportId(rowID);
BLL.MeetingCService.DeleteMeetingByMonthReportId(rowID);
BLL.ActivitiesCService.DeleteActivitiesByMonthReportId(rowID);
BLL.EmergencyPlanCService.DeleteEmergencyPlanByMonthReportId(rowID);
BLL.EmergencyExercisesCService.DeleteEmergencyExercisesByMonthReportId(rowID);
BLL.CostInvestmentPlanCService.DeleteCostInvestmentPlanByMonthReportId(rowID);
BLL.ManageDocPlanCService.DeleteManageDocPlanByMonthReportId(rowID);
BLL.OtherWorkPlanCService.DeleteOtherWorkPlanByMonthReportId(rowID);
BLL.MonthReportCService.DeleteMonthReportByMonthReportId(rowID);
}
}
BindGrid();
ShowNotify("删除数据成功!(表格数据已重新绑定)");
}
}
#endregion
#region
#region
/// <summary>
/// 新增
/// </summary>
@@ -292,23 +429,163 @@ namespace FineUIPro.Web.HSSE.Manager
Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
if (project.StartDate != null)
{
if (!string.IsNullOrEmpty(this.txtReportDate.Text.Trim()))
if (!string.IsNullOrEmpty(this.txtReportYear.Text.Trim()))
{
DateTime months = Convert.ToDateTime(this.txtReportDate.Text.Trim() + "-01");
Model.Manager_MonthReportC monthReport = BLL.MonthReportCService.GetMonthReportByMonths(months, this.CurrUser.LoginProjectId);
if (monthReport != null)
if (this.txtReportYear.Text.Trim() == DateTime.Now.Year.ToString())
{
Alert.ShowInTop("当前月份的月报已存在!", MessageBoxIcon.Warning);
return;
int? years = Convert.ToInt32(this.txtReportYear.Text.Trim());
var report = Funs.DB.HSSE_MonthReport.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.Years == years);
if (report == null)
{
Model.HSSE_MonthReport newReport = new Model.HSSE_MonthReport();
newReport.MonthReportId = SQLHelper.GetNewID(typeof(Model.HSSE_MonthReport));
newReport.ProjectId = this.CurrUser.LoginProjectId;
newReport.Years = years;
Funs.DB.HSSE_MonthReport.InsertOnSubmit(newReport);
Funs.DB.SubmitChanges();
List<Model.HSSE_MonthReportItem> ItemList = new List<Model.HSSE_MonthReportItem>();
for (int i = 0; i < 22; i++)
{
Model.HSSE_MonthReportItem item = new Model.HSSE_MonthReportItem();
item.MonthReportItemId = SQLHelper.GetNewID(typeof(Model.HSSE_MonthReportItem));
item.MonthReportId = newReport.MonthReportId;
if (i == 0)
{
item.ReportItem = "成达公司现场人数";
item.Unit = "人月";
}
if (i == 1)
{
item.ReportItem = "成达公司HSE管理人数";
item.Unit = "人月";
}
if (i == 2)
{
item.ReportItem = "分包商现场人数";
item.Unit = "人月";
}
if (i == 3)
{
item.ReportItem = "分包商HSE管理人数";
item.Unit = "人月";
}
if (i == 4)
{
item.ReportItem = "人工时数";
item.Unit = "人工时";
}
if (i == 5)
{
item.ReportItem = "安全生产人工时数";
item.Unit = "人工时";
}
if (i == 6)
{
item.ReportItem = "HSE记录事故数量";
item.Unit = "次";
}
if (i == 7)
{
item.ReportItem = "死亡";
item.Unit = "人";
}
if (i == 8)
{
item.ReportItem = "重伤";
item.Unit = "人次";
}
if (i == 9)
{
item.ReportItem = "轻伤";
item.Unit = "人次";
}
if (i == 10)
{
item.ReportItem = "未遂事故";
item.Unit = "次";
}
if (i == 11)
{
item.ReportItem = "现场环境事故";
item.Unit = "次";
}
if (i == 12)
{
item.ReportItem = "现场发生设备材料盗窃案件";
item.Unit = "次";
}
if (i == 13)
{
item.ReportItem = "HSE周会";
item.Unit = "次";
}
if (i == 14)
{
item.ReportItem = "HSE委员会会议";
item.Unit = "次";
}
if (i == 15)
{
item.ReportItem = "施工现场HSE联检";
item.Unit = "次";
}
if (i == 16)
{
item.ReportItem = "发布HSE整改通知书";
item.Unit = "份";
}
if (i == 17)
{
item.ReportItem = "关闭HSE整改通知书";
item.Unit = "份";
}
if (i == 18)
{
item.ReportItem = "发布HSE处罚书";
item.Unit = "份";
}
if (i == 19)
{
item.ReportItem = "发布应急预案";
item.Unit = "份";
}
if (i == 20)
{
item.ReportItem = "人员培训";
item.Unit = "人次";
}
if (i == 21)
{
item.ReportItem = "设备HSE检验";
item.Unit = "台/辆次";
}
item.Sort = i + 1;
ItemList.Add(item);
}
Funs.DB.HSSE_MonthReportItem.InsertAllOnSubmit(ItemList);
Funs.DB.SubmitChanges();
this.InitTreeMenu();
Alert.ShowInTop("月报创建成功!", MessageBoxIcon.Success);
}
else
{
Alert.ShowInTop("月报已创建,请选择左边树的年进行编辑!", MessageBoxIcon.Warning);
return;
}
BindGrid();
}
else
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("MonthReportCEdit.aspx?months={0}", string.Format("{0:yyyy-MM-dd}", months), "编辑 - ")));
Alert.ShowInTop("只能新建当年的月报!", MessageBoxIcon.Warning);
return;
}
}
else
{
Alert.ShowInTop("请选择月份", MessageBoxIcon.Warning);
Alert.ShowInTop("请选择年度", MessageBoxIcon.Warning);
return;
}
}
@@ -320,6 +597,109 @@ namespace FineUIPro.Web.HSSE.Manager
}
#endregion
protected void btnSave_Click(object sender, EventArgs e)
{
int cm = GetCurMonth();
JArray editReport = Grid1.GetMergedData();
if (editReport.Count > 0)
{
if (cm != 0)
{
for (int i = 0; i < editReport.Count; i++)
{
JObject objects = (JObject)editReport[i];
string monthReportItemId = objects["values"]["MonthReportItemId"].ToString();
Model.HSSE_MonthReportItem item = Funs.DB.HSSE_MonthReportItem.FirstOrDefault(x => x.MonthReportItemId == monthReportItemId);
if (cm == 1)
{
item.Month1 = Funs.GetNewInt(objects["values"]["Month1"].ToString());
}
if (cm == 2)
{
item.Month2 = Funs.GetNewInt(objects["values"]["Month2"].ToString());
}
if (cm == 3)
{
item.Month3 = Funs.GetNewInt(objects["values"]["Month3"].ToString());
}
if (cm == 4)
{
item.Month4 = Funs.GetNewInt(objects["values"]["Month4"].ToString());
}
if (cm == 5)
{
item.Month5 = Funs.GetNewInt(objects["values"]["Month5"].ToString());
}
if (cm == 6)
{
item.Month6 = Funs.GetNewInt(objects["values"]["Month6"].ToString());
}
if (cm == 7)
{
item.Month7 = Funs.GetNewInt(objects["values"]["Month7"].ToString());
}
if (cm == 8)
{
item.Month8 = Funs.GetNewInt(objects["values"]["Month8"].ToString());
}
if (cm == 9)
{
item.Month9 = Funs.GetNewInt(objects["values"]["Month9"].ToString());
}
if (cm == 10)
{
item.Month10 = Funs.GetNewInt(objects["values"]["Month10"].ToString());
}
if (cm == 11)
{
item.Month11 = Funs.GetNewInt(objects["values"]["Month11"].ToString());
}
if (cm == 12)
{
item.Month12 = Funs.GetNewInt(objects["values"]["Month12"].ToString());
}
item.YearTotal = Funs.GetNewInt(objects["values"]["YearTotal"].ToString());
item.ProjectTotal = Funs.GetNewInt(objects["values"]["ProjectTotal"].ToString());
Funs.DB.SubmitChanges();
this.ShowNotify("保存成功");
}
}
else
{
Alert.ShowInTop("月报的填报日期为每月的26号开始到下月的4号截止!", MessageBoxIcon.Warning);
return;
}
}
}
/// <summary>
/// 获取可编辑的月份
/// </summary>
/// <returns></returns>
private int GetCurMonth()
{
DateTime nowDate = DateTime.Now;
// 本月
int m = nowDate.Month;
// 上月
int lm = nowDate.AddMonths(-1).Month;
// 当月第几天
int cd = nowDate.Day;
// 下月的第几天
int nd = nowDate.AddMonths(1).Day;
int cm = 0;
if (cd >= 26)
{
cm = m;
}
if (nd <= 4)
{
cm = lm;
}
return cm;
}
#region
/// <summary>
/// 获取按钮权限
@@ -332,21 +712,13 @@ namespace FineUIPro.Web.HSSE.Manager
{
return;
}
var buttonList = BLL.CommonService.GetAllButtonList(this.ProjectId, this.CurrUser.UserId, BLL.Const.ProjectManagerMonthCMenuId);
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectManagerMonthCMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnAdd))
{
this.btnNew.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnModify))
{
this.btnMenuModify.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnDelete))
{
this.btnMenuDel.Hidden = false;
}
}
}
#endregion