322 lines
14 KiB
C#
322 lines
14 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.ZHGL.Environmental
|
|
{
|
|
public partial class OperationReportEdit : PageBase
|
|
{
|
|
#region 定义项
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
private string BusinessReportId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["BusinessReportId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["BusinessReportId"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
BLL.ConstValue.InitConstValueDropDownList(this.drpYear, BLL.ConstValue.Group_0008, true);
|
|
BLL.ConstValue.InitConstValueDropDownList(this.ddlQuarter, BLL.ConstValue.Group_0011, true);
|
|
|
|
this.ddlUnitId.DataTextField = "UnitName";
|
|
this.ddlUnitId.DataValueField = "UnitId";
|
|
this.ddlUnitId.DataSource = BLL.UnitService.GetThisUnitDropDownList();
|
|
this.ddlUnitId.DataBind();
|
|
|
|
this.ddlUnitId.Readonly = true;
|
|
|
|
var year = Request.Params["Year"];
|
|
var quarter = Request.Params["Quarter"];
|
|
string unitId = Request.Params["UnitId"];
|
|
|
|
this.drpYear.SelectedValue = year;
|
|
this.ddlQuarter.SelectedValue = quarter;
|
|
|
|
if (!string.IsNullOrEmpty(Request.QueryString["type"]))
|
|
{
|
|
this.btnSave.Hidden = true;
|
|
this.btnUpdata.Hidden = false;
|
|
}
|
|
else
|
|
{
|
|
this.btnSave.Hidden = false;
|
|
this.btnUpdata.Hidden = true;
|
|
}
|
|
|
|
BindGrid(year, quarter, unitId);
|
|
}
|
|
}
|
|
|
|
private void BindGrid(string year, string quarter, string unitId)
|
|
{
|
|
this.BusinessReportId = Request.Params["BusinessReportId"];
|
|
if (!string.IsNullOrEmpty(this.BusinessReportId))
|
|
{
|
|
var operationReport = Funs.DB.Environmental_OperationReport.FirstOrDefault(s => s.BusinessReportId == this.BusinessReportId);
|
|
|
|
if (operationReport != null)
|
|
{
|
|
#region 赋值
|
|
if (operationReport.Year != null)
|
|
{
|
|
this.drpYear.SelectedValue = operationReport.Year.ToString();
|
|
}
|
|
if (operationReport.Quarters != null)
|
|
{
|
|
this.ddlQuarter.SelectedValue = operationReport.Quarters.ToString();
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(operationReport.FillingMan))
|
|
{
|
|
this.txtCompileMan.Text = operationReport.FillingMan.ToString();
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(operationReport.UnitLevel))
|
|
{
|
|
this.txtUnitLevel.Text = operationReport.UnitLevel;
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(operationReport.Place))
|
|
{
|
|
this.txtPlace.Text = operationReport.Place;
|
|
}
|
|
if (operationReport.FillingDate != null)
|
|
{
|
|
this.txtFillingDate.Text = operationReport.FillingDate.Value.ToString("yyyy-MM-dd");
|
|
}
|
|
if (operationReport.CreateDate != null)
|
|
{
|
|
this.txtCreateDate.Text = operationReport.CreateDate.Value.ToString("yyyy-MM-dd");
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(operationReport.Code))
|
|
{
|
|
this.txtCode.Text = operationReport.Code;
|
|
}
|
|
if (operationReport.PersonNum != null)
|
|
{
|
|
this.txtPersonNum.Text = operationReport.PersonNum.ToString();
|
|
}
|
|
if (operationReport.TotalAssets != null)
|
|
{
|
|
this.txtTotalAssets.Text = operationReport.TotalAssets.ToString();
|
|
}
|
|
if (operationReport.TotalValue != null)
|
|
{
|
|
this.txtTotalValue.Text = operationReport.TotalValue.ToString();
|
|
}
|
|
if (operationReport.NewInvestment != null)
|
|
{
|
|
this.txtNewInvestment.Text = operationReport.NewInvestment.ToString();
|
|
}
|
|
this.txtStatisticsDutyPerson.Text = operationReport.StatisticsDutyPerson;
|
|
this.txtUnitDutyPerson.Text = operationReport.UnitDutyPerson;
|
|
this.txtRemark.Text = operationReport.Remark;
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
else
|
|
{
|
|
#region 不存在则根据项目统计生成
|
|
this.ddlUnitId.SelectedValue = unitId;
|
|
this.drpYear.SelectedValue = year;
|
|
this.ddlQuarter.SelectedValue = quarter;
|
|
this.txtFillingDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
|
|
|
var projects = Funs.DB.Base_Project.Where(s => s.UnitId == unitId).Select(s => s.ProjectId).ToList();
|
|
|
|
var items = Funs.DB.Environmental_ProjectOperationReport
|
|
.Where(s => s.Year.ToString() == year && s.Quarters.ToString() == quarter && projects.Contains(s.ProjectId))
|
|
.ToList();
|
|
|
|
if (items.Any())
|
|
{
|
|
this.txtPersonNum.Text = items.Sum(s => s.PersonNum ?? 0).ToString();
|
|
this.txtTotalAssets.Text = items.Sum(s => s.TotalAssets ?? 0).ToString();
|
|
this.txtTotalValue.Text = items.Sum(s => s.TotalValue ?? 0).ToString();
|
|
this.txtNewInvestment.Text = items.Sum(s => s.NewInvestment ?? 0).ToString();
|
|
}
|
|
this.txtCompileMan.Text = this.CurrUser.UserName;
|
|
this.txtStatisticsDutyPerson.Text = this.CurrUser.UserName;
|
|
this.txtUnitDutyPerson.Text = this.CurrUser.UserName;
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 保存、提交、关闭
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.drpYear.SelectedValue == BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择年度", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
if (this.ddlQuarter.SelectedValue == BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择季度", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
this.SaveData(BLL.Const.BtnSave);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 上报
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnUpdata_Click(object sender, EventArgs e)
|
|
{
|
|
SaveData("updata");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存数据
|
|
/// </summary>
|
|
/// <param name="p"></param>
|
|
private void SaveData(string type)
|
|
{
|
|
Model.Environmental_OperationReport operationReport = new Model.Environmental_OperationReport
|
|
{
|
|
UnitId = this.ddlUnitId.SelectedValue
|
|
};
|
|
|
|
if (this.drpYear.SelectedValue != BLL.Const._Null)
|
|
{
|
|
operationReport.Year = Funs.GetNewInt(this.drpYear.SelectedValue);
|
|
}
|
|
if (this.ddlQuarter.SelectedValue != BLL.Const._Null)
|
|
{
|
|
operationReport.Quarters = Funs.GetNewInt(this.ddlQuarter.SelectedValue);
|
|
}
|
|
operationReport.FillingMan = this.txtCompileMan.Text.Trim();
|
|
operationReport.StatisticsDutyPerson = this.txtStatisticsDutyPerson.Text.Trim();
|
|
operationReport.UnitDutyPerson = this.txtUnitDutyPerson.Text.Trim();
|
|
operationReport.FillingDate = Funs.GetNewDateTime(this.txtFillingDate.Text);
|
|
operationReport.Code = this.txtCode.Text.Trim();
|
|
operationReport.PersonNum = Funs.GetNewInt(this.txtPersonNum.Text.Trim());
|
|
operationReport.TotalAssets = Funs.GetNewDecimalOrZero(this.txtTotalAssets.Text.Trim());
|
|
operationReport.TotalValue = Funs.GetNewDecimalOrZero(this.txtTotalValue.Text.Trim());
|
|
operationReport.NewInvestment = Funs.GetNewDecimalOrZero(this.txtNewInvestment.Text.Trim());
|
|
operationReport.UnitLevel = this.txtUnitLevel.Text.Trim();
|
|
operationReport.CreateDate = Funs.GetNewDateTime(this.txtCreateDate.Text);
|
|
operationReport.Place = this.txtPlace.Text.Trim();
|
|
operationReport.Remark = this.txtRemark.Text.Trim();
|
|
|
|
if (!string.IsNullOrEmpty(this.BusinessReportId))
|
|
{
|
|
var model = Funs.DB.Environmental_OperationReport.FirstOrDefault(s => s.BusinessReportId == this.BusinessReportId);
|
|
if (model != null)
|
|
{
|
|
model.Code = operationReport.Code;
|
|
model.PersonNum = operationReport.PersonNum;
|
|
model.TotalAssets = operationReport.TotalAssets;
|
|
model.TotalValue = operationReport.TotalValue;
|
|
model.NewInvestment = operationReport.NewInvestment;
|
|
model.Quarters = operationReport.Quarters;
|
|
model.Year = operationReport.Year;
|
|
model.FillingMan = operationReport.FillingMan;
|
|
model.FillingDate = operationReport.FillingDate;
|
|
model.CreateDate = operationReport.CreateDate;
|
|
model.Place = operationReport.Place;
|
|
model.Remark = operationReport.Remark;
|
|
model.StatisticsDutyPerson = operationReport.StatisticsDutyPerson;
|
|
model.UnitDutyPerson = operationReport.UnitDutyPerson;
|
|
|
|
operationReport.UpState = model.UpState;
|
|
operationReport.BusinessReportId = model.BusinessReportId;
|
|
|
|
BLL.LogService.AddSys_Log(this.CurrUser, operationReport.Year.ToString() + "-" + operationReport.Quarters.ToString(), operationReport.BusinessReportId, BLL.Const.OperationReportMenuId, BLL.Const.BtnModify);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var model = (from x in Funs.DB.Environmental_OperationReport
|
|
where x.UnitId == operationReport.UnitId && x.Year == operationReport.Year && x.Quarters == operationReport.Quarters
|
|
select x).FirstOrDefault();
|
|
|
|
if (model == null)
|
|
{
|
|
this.BusinessReportId = SQLHelper.GetNewID(typeof(Model.Environmental_ProjectOperationReport));
|
|
operationReport.BusinessReportId = this.BusinessReportId;
|
|
operationReport.UpState = Const.UpState_2;
|
|
|
|
Funs.DB.Environmental_OperationReport.InsertOnSubmit(operationReport);
|
|
BLL.LogService.AddSys_Log(this.CurrUser, operationReport.Year.ToString() + "-" + operationReport.Quarters.ToString(), operationReport.BusinessReportId,
|
|
BLL.Const.OperationReportMenuId, BLL.Const.BtnAdd);
|
|
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("该季度记录已存在", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (type == "updata") //数据同步
|
|
{
|
|
if (operationReport.UpState == BLL.Const.UpState_2)
|
|
{
|
|
string code = CNCECHSSEWebService.UpOperationReport(operationReport.BusinessReportId, this.CurrUser);
|
|
if (code == "1")
|
|
{
|
|
ShowNotify("同步成功!", MessageBoxIcon.Success);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInParent("同步异常,请退出后重试!", MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("当前单据状态不能同步!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 年季度变化事件
|
|
/// <summary>
|
|
/// 年季度变化事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void drpYear_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (this.drpYear.SelectedValue != BLL.Const._Null && this.ddlQuarter.SelectedValue != BLL.Const._Null)
|
|
{
|
|
BindGrid(this.drpYear.SelectedValue, this.ddlQuarter.SelectedValue, Request.Params["unitId"]);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |