357 lines
18 KiB
C#
357 lines
18 KiB
C#
using BLL;
|
||
using Model;
|
||
using System;
|
||
using System.Linq;
|
||
|
||
namespace FineUIPro.Web.ZHGL.Information
|
||
{
|
||
public partial class SafetyBriefingEdit : PageBase
|
||
{
|
||
#region 定义变量
|
||
/// <summary>
|
||
/// 报表主键Id
|
||
/// </summary>
|
||
public string SafetyBriefingId
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["SafetyBriefingId"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["SafetyBriefingId"] = value;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 加载页面
|
||
/// <summary>
|
||
/// 加载页面
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
this.GetButtonPower();
|
||
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;
|
||
BLL.UserService.InitUserUnitIdDropDownList(this.drpCompileMan, this.drpUnit.SelectedValue, true);
|
||
string unitId = Request.QueryString["UnitId"];
|
||
string year = Request.QueryString["Year"];
|
||
string months = Request.QueryString["Months"];
|
||
SafetyBriefingId = Request.QueryString["safetyBriefingId"];
|
||
if (!String.IsNullOrEmpty(SafetyBriefingId))
|
||
{
|
||
var report = BLL.SafetyBriefingService.GetSafetyBriefingById(SafetyBriefingId);
|
||
if (report != null)
|
||
{
|
||
this.btnSave.Hidden = true;
|
||
this.btnCopy.Hidden = true;
|
||
if (this.CurrUser.UserId == BLL.Const.sysglyId || this.CurrUser.UserId == BLL.Const.hfnbdId)
|
||
{
|
||
this.btnSave.Hidden = false;
|
||
}
|
||
if (report.UpState == BLL.Const.UpState_3)
|
||
{
|
||
this.btnSave.Hidden = true;
|
||
this.btnUpdata.Hidden = true;
|
||
}
|
||
drpMonth.SelectedValue = report.Month.ToString();
|
||
drpYear.SelectedValue = report.YearId.ToString();
|
||
drpUnit.SelectedValue = report.UnitId;
|
||
if (!string.IsNullOrEmpty(report.CompileMan))
|
||
{
|
||
this.drpCompileMan.SelectedValue = report.CompileMan;
|
||
}
|
||
this.txtAuditor.Text = report.Auditor;
|
||
this.txtApprover.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
|
||
{
|
||
this.btnCopy.Hidden = false;
|
||
drpMonth.SelectedValue = months;
|
||
drpYear.SelectedValue = year;
|
||
|
||
#region 获取项目上报数据
|
||
string mainWork = string.Empty;
|
||
string hazardRecording = string.Empty;
|
||
string safetyAccident = string.Empty;
|
||
string ePAccident = string.Empty;
|
||
string oHAccident = string.Empty;
|
||
string workPermitNum = string.Empty;
|
||
string hiddenDangerDetection = string.Empty;
|
||
string rectificationSituation = string.Empty;
|
||
string checkProblemsRectification = string.Empty;
|
||
string pendingProject = string.Empty;
|
||
string contractorManagement = string.Empty;
|
||
string environmentalEmissions = string.Empty;
|
||
string nextMonthWorkPlan = 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)
|
||
{
|
||
mainWork += item.ProjectName + ":\r\n" + report.MainWork + "\r\n";
|
||
hazardRecording += item.ProjectName + ":\r\n" + report.HazardRecording + "\r\n";
|
||
safetyAccident += item.ProjectName + ":\r\n" + report.SafetyAccident + "\r\n";
|
||
ePAccident += item.ProjectName + ":\r\n" + report.EPAccident + "\r\n";
|
||
oHAccident += item.ProjectName + ":\r\n" + report.OHAccident + "\r\n";
|
||
workPermitNum += item.ProjectName + ":\r\n" + report.WorkPermitNum + "\r\n";
|
||
hiddenDangerDetection += item.ProjectName + ":\r\n" + report.HiddenDangerDetection + "\r\n";
|
||
rectificationSituation += item.ProjectName + ":\r\n" + report.RectificationSituation + "\r\n";
|
||
checkProblemsRectification += item.ProjectName + ":\r\n" + report.CheckProblemsRectification + "\r\n";
|
||
pendingProject += item.ProjectName + ":\r\n" + report.PendingProject + "\r\n";
|
||
contractorManagement += item.ProjectName + ":\r\n" + report.ContractorManagement + "\r\n";
|
||
environmentalEmissions += item.ProjectName + ":\r\n" + report.EnvironmentalEmissions + "\r\n";
|
||
nextMonthWorkPlan += item.ProjectName + ":\r\n" + report.NextMonthWorkPlan + "\r\n";
|
||
}
|
||
}
|
||
this.txtMainWork.Text = mainWork;
|
||
this.txtHazardRecording.Text = hazardRecording;
|
||
this.txtSafetyAccident.Text = safetyAccident;
|
||
this.txtEPAccident.Text = ePAccident;
|
||
this.txtOHAccident.Text = oHAccident;
|
||
this.txtWorkPermitNum.Text = workPermitNum;
|
||
this.txtHiddenDangerDetection.Text = hiddenDangerDetection;
|
||
this.txtRectificationSituation.Text = rectificationSituation;
|
||
this.txtCheckProblemsRectification.Text = checkProblemsRectification;
|
||
this.txtPendingProject.Text = pendingProject;
|
||
this.txtContractorManagement.Text = contractorManagement;
|
||
this.txtEnvironmentalEmissions.Text = environmentalEmissions;
|
||
this.txtNextMonthWorkPlan.Text = nextMonthWorkPlan;
|
||
#endregion
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 保存、上报
|
||
/// <summary>
|
||
/// 保存数据
|
||
/// </summary>
|
||
/// <param name="type"></param>
|
||
private void Save(string type)
|
||
{
|
||
Model.Information_SafetyBriefing report = new Information_SafetyBriefing
|
||
{
|
||
UnitId = drpUnit.SelectedValue,
|
||
YearId = Funs.GetNewIntOrZero(drpYear.SelectedValue),
|
||
Month = Funs.GetNewIntOrZero(drpMonth.SelectedValue),
|
||
CompileDate = DateTime.Now,
|
||
Auditor = this.txtAuditor.Text.Trim(),
|
||
Approver = this.txtApprover.Text.Trim(),
|
||
MainWork = this.txtMainWork.Text,
|
||
HazardRecording=this.txtHazardRecording.Text,
|
||
SafetyAccident=this.txtSafetyAccident.Text,
|
||
EPAccident=this.txtEPAccident.Text,
|
||
OHAccident=this.txtOHAccident.Text,
|
||
WorkPermitNum=this.txtWorkPermitNum.Text,
|
||
HiddenDangerDetection =this.txtHiddenDangerDetection.Text,
|
||
RectificationSituation=this.txtRectificationSituation.Text,
|
||
CheckProblemsRectification=this.txtCheckProblemsRectification.Text,
|
||
PendingProject=this.txtPendingProject.Text,
|
||
ContractorManagement=this.txtContractorManagement.Text,
|
||
EnvironmentalEmissions=this.txtEnvironmentalEmissions.Text,
|
||
NextMonthWorkPlan=this.txtNextMonthWorkPlan.Text
|
||
};
|
||
if (this.drpCompileMan.SelectedValue!=BLL.Const._Null)
|
||
{
|
||
report.CompileMan = this.drpCompileMan.SelectedValue;
|
||
}
|
||
|
||
if (String.IsNullOrEmpty(SafetyBriefingId))
|
||
{
|
||
Information_SafetyBriefing old = SafetyBriefingService.GetSafetyBriefingByUnitIdAndYearAndMonth(drpUnit.SelectedValue, Funs.GetNewIntOrZero(drpYear.SelectedValue), Funs.GetNewIntOrZero(drpMonth.SelectedValue));
|
||
if (old == null)
|
||
{
|
||
SafetyBriefingId = SQLHelper.GetNewID(typeof(Model.Information_SafetyBriefing));
|
||
report.SafetyBriefingId = SafetyBriefingId;
|
||
report.UpState = BLL.Const.UpState_2;
|
||
BLL.SafetyBriefingService.AddSafetyBriefing(report);
|
||
BLL.LogService.AddSys_Log(this.CurrUser, report.YearId.ToString() + "-" + report.Month.ToString(), report.SafetyBriefingId, BLL.Const.SafetyBriefingMenuId, BLL.Const.BtnAdd);
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("该月份记录已存在!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
report.SafetyBriefingId = SafetyBriefingId;
|
||
report.UpState = BLL.Const.UpState_2;
|
||
BLL.SafetyBriefingService.UpdateSafetyBriefing(report);
|
||
BLL.LogService.AddSys_Log(this.CurrUser, report.YearId.ToString() + "-" + report.Month.ToString(), report.SafetyBriefingId, BLL.Const.SafetyBriefingMenuId, BLL.Const.BtnModify);
|
||
}
|
||
|
||
if (type == "updata") //数据同步
|
||
{
|
||
if (report.UpState == BLL.Const.UpState_2)
|
||
{
|
||
string code = CNCECHSSEWebService.UpSafetyBriefing(report.SafetyBriefingId, this.CurrUser);
|
||
if (code == "1")
|
||
{
|
||
ShowNotify("同步成功!", MessageBoxIcon.Success);
|
||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInParent("同步异常,请退出后重试!", MessageBoxIcon.Error);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("当前单据状态不能同步!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||
}
|
||
|
||
protected void btnSave_Click(object sender, EventArgs e)
|
||
{
|
||
Save("add");
|
||
}
|
||
|
||
protected void btnUpdata_Click(object sender, EventArgs e)
|
||
{
|
||
Save("updata");
|
||
}
|
||
#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.BtnSave))
|
||
{
|
||
this.btnSave.Hidden = false;
|
||
this.btnCopy.Hidden = false;
|
||
}
|
||
//if (buttonList.Contains(BLL.Const.BtnSaveUp))
|
||
//{
|
||
// this.btnUpdata.Hidden = false;
|
||
//}
|
||
//if (buttonList.Contains(BLL.Const.BtnSubmit))
|
||
//{
|
||
// this.btnSubmit.Hidden = false;
|
||
// //this.btnCopy.Hidden = false;
|
||
//}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 复制上个月数据
|
||
/// <summary>
|
||
/// 复制上个月的数据
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnCopy_Click(object sender, EventArgs e)
|
||
{
|
||
DateTime? nowDate = Funs.GetNewDateTime(this.drpYear.SelectedValue + "-" + this.drpMonth.SelectedValue);
|
||
if (nowDate.HasValue)
|
||
{
|
||
DateTime showDate = new DateTime();
|
||
showDate = nowDate.Value.AddMonths(-1);
|
||
Model.Information_SafetyBriefing report = BLL.SafetyBriefingService.GetSafetyBriefingByUnitIdAndYearAndMonth(this.drpUnit.SelectedValue, showDate.Year, showDate.Month);
|
||
if (report != null)
|
||
{
|
||
Model.Information_SafetyBriefing newReport = new Information_SafetyBriefing();
|
||
this.SafetyBriefingId = SQLHelper.GetNewID(typeof(Model.Information_SafetyBriefing));
|
||
newReport.SafetyBriefingId = this.SafetyBriefingId;
|
||
newReport.UnitId = this.drpUnit.SelectedValue;
|
||
newReport.YearId = Convert.ToInt32(this.drpYear.SelectedValue);
|
||
newReport.Month = Convert.ToInt32(this.drpMonth.SelectedValue);
|
||
newReport.CompileMan = report.CompileMan;
|
||
newReport.CompileDate = report.CompileDate;
|
||
newReport.Auditor = report.Auditor;
|
||
newReport.Approver = report.Approver;
|
||
newReport.MainWork = report.MainWork;
|
||
newReport.HazardRecording = report.HazardRecording;
|
||
newReport.SafetyAccident = report.SafetyAccident;
|
||
newReport.EPAccident = report.EPAccident;
|
||
newReport.OHAccident = report.OHAccident;
|
||
newReport.WorkPermitNum = report.WorkPermitNum;
|
||
newReport.HiddenDangerDetection = report.HiddenDangerDetection;
|
||
newReport.RectificationSituation = report.RectificationSituation;
|
||
newReport.CheckProblemsRectification = report.CheckProblemsRectification;
|
||
newReport.PendingProject = report.PendingProject;
|
||
newReport.ContractorManagement = report.ContractorManagement;
|
||
newReport.EnvironmentalEmissions = report.EnvironmentalEmissions;
|
||
newReport.NextMonthWorkPlan = report.NextMonthWorkPlan;
|
||
newReport.UpState = BLL.Const.UpState_2;
|
||
BLL.SafetyBriefingService.AddSafetyBriefing(newReport);
|
||
|
||
GetValues(newReport.SafetyBriefingId);
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取复制的值绑定到文本中
|
||
/// </summary>
|
||
private void GetValues(string safetyBriefingId)
|
||
{
|
||
var report = BLL.SafetyBriefingService.GetSafetyBriefingById(safetyBriefingId);
|
||
if (report != null)
|
||
{
|
||
drpUnit.SelectedValue = report.UnitId;
|
||
drpYear.SelectedValue = report.YearId.ToString();
|
||
drpMonth.SelectedValue = report.Month.ToString();
|
||
drpCompileMan.SelectedValue = report.CompileMan;
|
||
txtAuditor.Text = report.Auditor;
|
||
txtApprover.Text = report.Approver;
|
||
txtMainWork.Text = report.MainWork;
|
||
txtHazardRecording.Text = report.HazardRecording;
|
||
txtSafetyAccident.Text = report.SafetyAccident;
|
||
txtEPAccident.Text = report.EPAccident;
|
||
txtOHAccident.Text = report.OHAccident;
|
||
txtWorkPermitNum.Text = report.WorkPermitNum;
|
||
txtHiddenDangerDetection.Text = report.HiddenDangerDetection;
|
||
txtRectificationSituation.Text = report.RectificationSituation;
|
||
txtCheckProblemsRectification.Text = report.CheckProblemsRectification;
|
||
txtPendingProject.Text = report.PendingProject;
|
||
txtContractorManagement.Text = report.ContractorManagement;
|
||
txtEnvironmentalEmissions.Text = report.EnvironmentalEmissions;
|
||
txtNextMonthWorkPlan.Text = report.NextMonthWorkPlan;
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
} |