xinjiang/SGGL/FineUIPro.Web/ZHGL/Information/SafetyBriefing.aspx.cs

327 lines
13 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BLL;
using AspNet = System.Web.UI.WebControls;
namespace FineUIPro.Web.ZHGL.Information
{
public partial class SafetyBriefing : PageBase
{
#region
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BLL.ConstValue.InitConstValueDropDownList(this.drpMonth, ConstValue.Group_0009, false);
BLL.ConstValue.InitConstValueDropDownList(this.drpYear, ConstValue.Group_0008, false);
this.drpUnit.DataTextField = "UnitName";
drpUnit.DataValueField = "UnitId";
drpUnit.DataSource = BLL.UnitService.GetThisUnitDropDownList();
drpUnit.DataBind();
this.drpUnit.Readonly = true;
////取上个报表时间
DateTime showDate = System.DateTime.Now.AddMonths(-1);
drpMonth.SelectedValue = showDate.Month.ToString();
drpYear.SelectedValue = showDate.Year.ToString();
GetValue();
}
}
private void SetEmpty()
{
this.SimpleForm1.Title = string.Empty;
lbUnitName.Text = "填报企业:";
lbCompileMan.Text = "编制人:";
lbAuditor.Text = "审核人:";
lbApprover.Text = "审批人:";
this.txtMainWork.Text = string.Empty;
txtHazardRecording.Text = string.Empty;
txtSafetyAccident.Text = string.Empty;
txtEPAccident.Text = string.Empty;
txtOHAccident.Text = string.Empty;
txtWorkPermitNum.Text = string.Empty;
txtHiddenDangerDetection.Text = string.Empty;
txtRectificationSituation.Text = string.Empty;
txtCheckProblemsRectification.Text = string.Empty;
txtPendingProject.Text = string.Empty;
txtContractorManagement.Text = string.Empty;
txtEnvironmentalEmissions.Text = string.Empty;
txtNextMonthWorkPlan.Text = string.Empty;
}
#endregion
#region
private void GetValue()
{
int year = Funs.GetNewIntOrZero(drpYear.SelectedValue);
int month = Funs.GetNewIntOrZero(drpMonth.SelectedValue);
Model.Information_SafetyBriefing report = Funs.DB.Information_SafetyBriefing.FirstOrDefault(e => e.UnitId == drpUnit.SelectedValue && e.Month == month && e.YearId == year);
if (report != null)
{
string upState = string.Empty;
if (report.UpState == BLL.Const.UpState_3)
{
upState = "(已上报)";
}
else
{
upState = "(未上报)";
}
this.SimpleForm1.Title = "实业安全简报" + report.YearId + "年 " + report.Month + "月" + upState;
lbUnitName.Text = "填报企业:" + BLL.UnitService.GetUnitNameByUnitId(report.UnitId);
lbCompileMan.Text = "编制人:" + BLL.UserService.GetUserNameByUserId(report.CompileMan);
lbAuditor.Text = "审核人:" + report.Auditor;
lbApprover.Text = "审批人:" + report.Approver;
this.txtMainWork.Text = report.MainWork;
this.txtHazardRecording.Text = report.HazardRecording;
this.txtSafetyAccident.Text = report.SafetyAccident;
this.txtEPAccident.Text = report.EPAccident;
this.txtOHAccident.Text = report.OHAccident;
this.txtWorkPermitNum.Text = report.WorkPermitNum;
this.txtHiddenDangerDetection.Text = report.HiddenDangerDetection;
this.txtRectificationSituation.Text = report.RectificationSituation;
this.txtCheckProblemsRectification.Text = report.CheckProblemsRectification;
this.txtPendingProject.Text = report.PendingProject;
this.txtContractorManagement.Text = report.ContractorManagement;
this.txtEnvironmentalEmissions.Text = report.EnvironmentalEmissions;
this.txtNextMonthWorkPlan.Text = report.NextMonthWorkPlan;
}
else
{
SetEmpty();
}
this.GetButtonPower();
}
#endregion
#region
/// <summary>
/// 关闭窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
GetValue();
}
#endregion
#region
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.SafetyBriefingMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnAdd))
{
this.btnNew.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnModify))
{
this.btnEdit.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnDelete))
{
this.btnDelete.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnSaveUp))
{
this.btnUpdata.Hidden = false;
}
}
var getReport = BLL.SafetyBriefingService.GetSafetyBriefingByUnitIdAndYearAndMonth(drpUnit.SelectedValue, Funs.GetNewIntOrZero(drpYear.SelectedValue), Funs.GetNewIntOrZero(drpMonth.SelectedValue));
if (getReport != null)
{
this.btnNew.Hidden = true;
}
}
#endregion
#region
/// <summary>
/// 增加
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNew_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SafetyBriefingEdit.aspx?UnitId={0}&&Year={1}&&Months={2}", this.CurrUser.UnitId, this.drpYear.SelectedValue, this.drpMonth.SelectedValue, "编辑 - ")));
}
/// <summary>
/// 修改
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnEdit_Click(object sender, EventArgs e)
{
Model.Information_SafetyBriefing report = BLL.SafetyBriefingService.GetSafetyBriefingByUnitIdAndYearAndMonth(drpUnit.SelectedValue, Funs.GetNewIntOrZero(drpYear.SelectedValue), Funs.GetNewIntOrZero(drpMonth.SelectedValue));
if (report != null)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SafetyBriefingEdit.aspx?safetyBriefingId={0}", report.SafetyBriefingId, "编辑 - ")));
}
else
{
ShowNotify("所选时间无报表记录!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 上报
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnUpdata_Click(object sender, EventArgs e)
{
Model.Information_SafetyBriefing report = BLL.SafetyBriefingService.GetSafetyBriefingByUnitIdAndYearAndMonth(drpUnit.SelectedValue, Funs.GetNewIntOrZero(drpYear.SelectedValue), Funs.GetNewIntOrZero(drpMonth.SelectedValue));
if (report != null)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SafetyBriefingEdit.aspx?safetyBriefingId={0}", report.SafetyBriefingId, "编辑 - ")));
}
else
{
ShowNotify("所选时间无报表记录!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 删除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDelete_Click(object sender, EventArgs e)
{
Model.Information_SafetyBriefing report = BLL.SafetyBriefingService.GetSafetyBriefingByUnitIdAndYearAndMonth(drpUnit.SelectedValue, Funs.GetNewIntOrZero(drpYear.SelectedValue), Funs.GetNewIntOrZero(drpMonth.SelectedValue));
if (report != null)
{
BLL.LogService.AddSys_Log(this.CurrUser, report.YearId.ToString() + "-" + report.Month.ToString(), report.SafetyBriefingId, BLL.Const.SafetyBriefingMenuId, BLL.Const.BtnDelete);
BLL.SafetyBriefingService.DeleteSafetyBriefingById(report.SafetyBriefingId);
SetEmpty();
this.btnNew.Hidden = false;
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
}
else
{
ShowNotify("所选时间无报表记录!");
}
}
#endregion
#region
/// <summary>
/// 单位下拉框联动事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e)
{
var units = BLL.UnitService.GetUnitDropDownList();
if (units != null && !string.IsNullOrEmpty(this.drpUnit.SelectedText))
{
var unit = units.FirstOrDefault(x => x.UnitName == this.drpUnit.SelectedText);
if (unit != null)
{
drpUnit.SelectedValue = unit.UnitId;
}
}
GetValue();
}
#endregion
#region /
/// <summary>
/// 前一个月
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void BtnBulletLeft_Click(object sender, EventArgs e)
{
SetMonthChange("-");
}
/// <summary>
/// 后一个月
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void BulletRight_Click(object sender, EventArgs e)
{
SetMonthChange("+");
}
/// <summary>
/// 月份加减变化
/// </summary>
/// <param name="type"></param>
private void SetMonthChange(string type)
{
DateTime? nowDate = Funs.GetNewDateTime(this.drpYear.SelectedValue + "-" + this.drpMonth.SelectedValue);
if (nowDate.HasValue)
{
DateTime showDate = new DateTime();
if (type == "+")
{
showDate = nowDate.Value.AddMonths(1);
}
else
{
showDate = nowDate.Value.AddMonths(-1);
}
this.drpYear.SelectedValue = showDate.Year.ToString();
drpMonth.SelectedValue = showDate.Month.ToString();
///值变化
GetValue();
}
}
#endregion
#region
/// <summary>
/// 查看未上报的项目
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnView_Click(object sender, EventArgs e)
{
string info = string.Empty;
DateTime date = Convert.ToDateTime(this.drpYear.SelectedValue + "-" + this.drpMonth.SelectedValue + "-01").AddDays(-1).AddMonths(1);
var projects = (from x in Funs.DB.Base_Project
where (x.ProjectState == BLL.Const.ProjectState_1 || x.ProjectState == null)
&& x.ProjectAttribute == "SHIYE"
&& x.StartDate <= date
select x).ToList();
foreach (var item in projects)
{
var report = Funs.DB.InformationProject_SafetyBriefing.FirstOrDefault(x => x.ProjectId == item.ProjectId && x.YearId == date.Year && x.Month == date.Month);
if (report == null)
{
info += item.ProjectCode + ":" + item.ProjectName + ",未填写报表;</br>";
}
}
if (!string.IsNullOrEmpty(info))
{
Alert.ShowInTop(info + "项目报表未上报。", MessageBoxIcon.Warning);
}
else
{
ShowNotify("项目报表已上报", MessageBoxIcon.Success);
}
}
#endregion
}
}