ChengDa_English/SGGL/FineUIPro.Web/ZHGL/Information/QualityWorkSummaryReportEdi...

377 lines
18 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using BLL;
using System;
using System.Linq;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.ZHGL.Information
{
public partial class QualityWorkSummaryReportEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string QualityWorkSummaryReportId
{
get
{
return (string)ViewState["QualityWorkSummaryReportId"];
}
set
{
ViewState["QualityWorkSummaryReportId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.ddlUnitId.DataTextField = "UnitName";
this.ddlUnitId.DataValueField = "UnitId";
this.ddlUnitId.DataSource = BLL.UnitService.GetThisUnitDropDownList();
this.ddlUnitId.DataBind();
this.ddlYearId.DataTextField = "ConstText";
ddlYearId.DataValueField = "ConstValue";
ddlYearId.DataSource = BLL.ConstValue.drpConstItemList(ConstValue.Group_0008);
ddlYearId.DataBind();
this.ddlUnitId.Readonly = true;
string unitId = Request.Params["UnitId"];
string year = Request.QueryString["Year"];
this.QualityWorkSummaryReportId = Request.Params["qualityWorkSummaryReportId"];
if (!string.IsNullOrEmpty(this.QualityWorkSummaryReportId))
{
var report = BLL.QualityWorkSummaryReportService.GetQualityWorkSummaryReportById(this.QualityWorkSummaryReportId);
if (report != null)
{
this.btnCopy.Hidden = true;
//this.btnSave.Hidden = true;
//this.btnSubmit.Hidden = true;
//if (report.HandleState == BLL.Const.HandleState_4)
//{
// this.btnUpdata.Hidden = false;
//}
//else
//{
// if (report.HandleMan == this.CurrUser.UserId)
// {
// this.btnSave.Hidden = false;
// this.btnSubmit.Hidden = false;
// }
//}
if (report.UpState == BLL.Const.UpState_3) //已上报
{
this.btnSave.Hidden = true;
this.btnUpdata.Hidden = true;
}
#region
if (!string.IsNullOrEmpty(report.UnitId))
{
this.ddlUnitId.SelectedValue = report.UnitId;
}
this.ddlYearId.SelectedValue = report.YearId.ToString();
this.txtReportDate.Text = report.ReportDate.HasValue ? string.Format("{0:yyyy-MM-dd}", report.ReportDate) : "";
this.txtResponsiblePerson.Text = report.ResponsiblePerson;
this.txtResponsiblePersonTel.Text = report.ResponsiblePersonTel;
this.txtContactPerson.Text = report.ContactPerson;
this.txtContactPersonTel.Text = report.ContactPersonTel;
this.txtPerformance.Text = report.Performance;
this.txtAccidentSituation.Text = report.AccidentSituation;
this.txtAwards.Text = report.Awards;
this.txtWorkDevelopment.Text = report.WorkDevelopment;
this.txtPersonnelTraining.Text = report.PersonnelTraining;
this.txtCheckSituation.Text = report.CheckSituation;
this.txtManagementActivity.Text = report.ManagementActivity;
this.txtWorkExperience.Text = report.WorkExperience;
this.txtCountermeasures.Text = report.Countermeasures;
this.txtNextYearWorkPlan.Text = report.NextYearWorkPlan;
this.txtJobSuggestion.Text = report.JobSuggestion;
#endregion
}
}
else
{
this.btnCopy.Hidden = false;
this.ddlUnitId.SelectedValue = unitId;
this.ddlYearId.SelectedValue = year;
this.txtReportDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
#region
string performance = string.Empty;
string accidentSituation = string.Empty;
string awards = string.Empty;
string workDevelopment = string.Empty;
string personnelTraining = string.Empty;
string checkSituation = string.Empty;
string managementActivity = string.Empty;
string workExperience = string.Empty;
string countermeasures = string.Empty;
string nextYearWorkPlan = string.Empty;
string jobSuggestion = string.Empty;
int date = Convert.ToInt32(this.ddlYearId.SelectedValue);
var projects = (from x in Funs.DB.Base_Project
where (x.ProjectState == BLL.Const.ProjectState_1 || x.ProjectState == null)
&& x.StartDate.Value.Year <= date
select x).ToList();
foreach (var item in projects)
{
var report = Funs.DB.InformationProject_QualityWorkSummaryReport.FirstOrDefault(x => x.ProjectId == item.ProjectId && x.YearId == date);
if (report != null)
{
performance += item.ProjectName + "\r\n" + report.Performance + "\r\n";
accidentSituation += item.ProjectName + "\r\n" + report.AccidentSituation + "\r\n";
awards += item.ProjectName + "\r\n" + report.Awards + "\r\n";
workDevelopment += item.ProjectName + "\r\n" + report.WorkDevelopment + "\r\n";
personnelTraining += item.ProjectName + "\r\n" + report.PersonnelTraining + "\r\n";
checkSituation += item.ProjectName + "\r\n" + report.CheckSituation + "\r\n";
managementActivity += item.ProjectName + "\r\n" + report.ManagementActivity + "\r\n";
workExperience += item.ProjectName + "\r\n" + report.WorkExperience + "\r\n";
countermeasures += item.ProjectName + "\r\n" + report.Countermeasures + "\r\n";
nextYearWorkPlan += item.ProjectName + "\r\n" + report.NextYearWorkPlan + "\r\n";
jobSuggestion += item.ProjectName + "\r\n" + report.JobSuggestion + "\r\n";
}
}
this.txtPerformance.Text = performance;
this.txtAccidentSituation.Text = accidentSituation;
this.txtAwards.Text = awards;
this.txtWorkDevelopment.Text = workDevelopment;
this.txtPersonnelTraining.Text = personnelTraining;
this.txtCheckSituation.Text = checkSituation;
this.txtManagementActivity.Text = managementActivity;
this.txtWorkExperience.Text = workExperience;
this.txtCountermeasures.Text = countermeasures;
this.txtNextYearWorkPlan.Text = nextYearWorkPlan;
this.txtJobSuggestion.Text = jobSuggestion;
#endregion
}
}
}
#endregion
#region
private void Save(string type)
{
Model.Information_QualityWorkSummaryReport newReport = new Model.Information_QualityWorkSummaryReport();
if (this.ddlUnitId.SelectedValue != BLL.Const._Null)
{
newReport.UnitId = this.ddlUnitId.SelectedValue;
}
else
{
ShowNotify("请选择单位!", MessageBoxIcon.Warning);
return;
}
if (this.ddlYearId.SelectedValue != BLL.Const._Null)
{
newReport.YearId = Funs.GetNewIntOrZero(this.ddlYearId.SelectedValue);
}
else
{
ShowNotify("请选择年度!", MessageBoxIcon.Warning);
return;
}
newReport.ResponsiblePerson = this.txtResponsiblePerson.Text.Trim();
newReport.ResponsiblePersonTel = this.txtResponsiblePersonTel.Text.Trim();
newReport.ContactPerson = this.txtContactPerson.Text.Trim();
newReport.ContactPersonTel = this.txtContactPersonTel.Text.Trim();
newReport.ReportDate = Funs.GetNewDateTime(this.txtReportDate.Text.Trim());
newReport.Performance = this.txtPerformance.Text.Trim();
newReport.AccidentSituation = this.txtAccidentSituation.Text.Trim();
newReport.Awards = this.txtAwards.Text.Trim();
newReport.WorkDevelopment = this.txtWorkDevelopment.Text.Trim();
newReport.PersonnelTraining = this.txtPersonnelTraining.Text.Trim();
newReport.CheckSituation = this.txtCheckSituation.Text.Trim();
newReport.ManagementActivity = this.txtManagementActivity.Text.Trim();
newReport.WorkExperience = this.txtWorkExperience.Text.Trim();
newReport.Countermeasures = this.txtCountermeasures.Text.Trim();
newReport.NextYearWorkPlan = this.txtNextYearWorkPlan.Text.Trim();
newReport.JobSuggestion = this.txtJobSuggestion.Text.Trim();
if (string.IsNullOrEmpty(this.QualityWorkSummaryReportId))
{
var s = BLL.QualityWorkSummaryReportService.GetQualityWorkSummaryReportByUnitIdAndYear(this.ddlUnitId.SelectedValue, Funs.GetNewIntOrZero(this.ddlYearId.SelectedValue));
if (s != null)
{
ShowNotify("该单位的该年度的该质量管理工作总结报告已经存在,不能重复编制!", MessageBoxIcon.Warning);
return;
}
else
{
this.QualityWorkSummaryReportId = SQLHelper.GetNewID(typeof(Model.Information_QualityWorkSummaryReport));
newReport.QualityWorkSummaryReportId = this.QualityWorkSummaryReportId;
//workSummaryReport.CompileMan = this.CurrUser.UserName;
newReport.UpState = BLL.Const.UpState_2;
//newReport.HandleMan = this.CurrUser.UserId;
//newReport.HandleState = BLL.Const.HandleState_1;
BLL.QualityWorkSummaryReportService.AddQualityWorkSummaryReport(newReport);
BLL.LogService.AddSys_Log(this.CurrUser, this.ddlYearId.SelectedText, newReport.QualityWorkSummaryReportId, BLL.Const.QualityWorkSummaryReportMenuId, BLL.Const.BtnAdd);
}
}
else
{
//var oldReport = BLL.QualityWorkSummaryReportService.GetQualityWorkSummaryReportById(this.QualityWorkSummaryReportId);
//if (oldReport != null)
//{
// newReport.HandleMan = oldReport.HandleMan;
// newReport.HandleState = oldReport.HandleState;
//}
newReport.QualityWorkSummaryReportId = this.QualityWorkSummaryReportId;
newReport.UpState = BLL.Const.UpState_2;
BLL.QualityWorkSummaryReportService.UpdateQualityWorkSummaryReport(newReport);
BLL.LogService.AddSys_Log(this.CurrUser, this.ddlYearId.SelectedText, newReport.QualityWorkSummaryReportId, BLL.Const.QualityWorkSummaryReportMenuId, BLL.Const.BtnModify);
}
if (type == "updata") //保存并上报
{
if (newReport.UpState == BLL.Const.UpState_2)
{
string code = CNCECHSSEWebService.UpQualityWorkSummaryReport(newReport.QualityWorkSummaryReportId, this.CurrUser);
if (code == "1")
{
ShowNotify("同步成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
return;
}
else
{
Alert.ShowInParent("同步异常,请退出后重试!", MessageBoxIcon.Error);
}
}
else
{
ShowNotify("当前单据状态不能同步!", MessageBoxIcon.Warning);
return;
}
}
//if (type == "submit")
//{
// PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ReportSubmit.aspx?Type=QualityWorkSummaryReport&Id={0}", newReport.QualityWorkSummaryReportId, "编辑 - ")));
//}
//if (type != "submit")
//{
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
//}
}
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
Save("add");
}
protected void btnUpdata_Click(object sender, EventArgs e)
{
Save("updata");
}
/// <summary>
/// 提交按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
//protected void btnSubmit_Click(object sender, EventArgs e)
//{
// Save("submit");
//}
#endregion
#region
/// <summary>
/// 关闭办理流程窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
//protected void Window1_Close(object sender, WindowCloseEventArgs e)
//{
// Model.Information_QualityWorkSummaryReport report = BLL.QualityWorkSummaryReportService.GetQualityWorkSummaryReportById(this.QualityWorkSummaryReportId);
// if (report.HandleMan == this.CurrUser.UserId)
// {
// this.btnSave.Hidden = false;
// this.btnSubmit.Hidden = false;
// }
// else
// {
// this.btnSave.Hidden = true;
// this.btnSubmit.Hidden = true;
// }
//}
#endregion
#region
/// <summary>
/// 复制上个年度数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnCopy_Click(object sender, EventArgs e)
{
int lastYear = 0;
int year = Convert.ToInt32(this.ddlYearId.SelectedValue);
lastYear = year - 1;
Model.Information_QualityWorkSummaryReport report = BLL.QualityWorkSummaryReportService.GetQualityWorkSummaryReportByUnitIdAndYear(this.ddlUnitId.SelectedValue, lastYear);
if (report != null)
{
Model.Information_QualityWorkSummaryReport newReport = new Model.Information_QualityWorkSummaryReport();
this.QualityWorkSummaryReportId = SQLHelper.GetNewID(typeof(Model.Information_QualityWorkSummaryReport));
newReport.QualityWorkSummaryReportId = this.QualityWorkSummaryReportId;
newReport.UnitId = this.ddlUnitId.SelectedValue;
newReport.YearId = Funs.GetNewIntOrZero(this.ddlYearId.SelectedValue);
newReport.Performance = report.Performance;
newReport.AccidentSituation = report.AccidentSituation;
newReport.Awards = report.Awards;
newReport.WorkDevelopment = report.WorkDevelopment;
newReport.PersonnelTraining = report.PersonnelTraining;
newReport.CheckSituation = report.CheckSituation;
newReport.ManagementActivity = report.ManagementActivity;
newReport.WorkExperience = report.WorkExperience;
newReport.Countermeasures = report.Countermeasures;
newReport.NextYearWorkPlan = report.NextYearWorkPlan;
newReport.JobSuggestion = report.JobSuggestion;
newReport.UpState = BLL.Const.UpState_2;
BLL.QualityWorkSummaryReportService.AddQualityWorkSummaryReport(newReport);
GetValues(newReport.QualityWorkSummaryReportId);
}
}
/// <summary>
/// 赋值
/// </summary>
private void GetValues(string reportId)
{
var report = BLL.QualityWorkSummaryReportService.GetQualityWorkSummaryReportById(reportId);
if (report != null)
{
this.txtPerformance.Text = report.Performance;
this.txtAccidentSituation.Text = report.AccidentSituation;
this.txtAwards.Text = report.Awards;
this.txtWorkDevelopment.Text = report.WorkDevelopment;
this.txtPersonnelTraining.Text = report.PersonnelTraining;
this.txtCheckSituation.Text = report.CheckSituation;
this.txtManagementActivity.Text = report.ManagementActivity;
this.txtWorkExperience.Text = report.WorkExperience;
this.txtCountermeasures.Text = report.Countermeasures;
this.txtNextYearWorkPlan.Text = report.NextYearWorkPlan;
this.txtJobSuggestion.Text = report.JobSuggestion;
}
}
#endregion
}
}