151 lines
5.6 KiB
C#
151 lines
5.6 KiB
C#
|
using BLL;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Web;
|
|||
|
using System.Web.UI;
|
|||
|
using System.Web.UI.WebControls;
|
|||
|
|
|||
|
namespace FineUIPro.Web.ZHGL.Information
|
|||
|
{
|
|||
|
public partial class EnvironmentalDataEdit: PageBase
|
|||
|
{
|
|||
|
#region
|
|||
|
/// <summary>
|
|||
|
/// 主键
|
|||
|
/// </summary>
|
|||
|
public string Id
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["Id"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["Id"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|||
|
////权限按钮方法
|
|||
|
this.GetButtonPower();
|
|||
|
this.Id = Request.Params["Id"];
|
|||
|
if (!string.IsNullOrEmpty(this.Id))
|
|||
|
{
|
|||
|
Model.Information_EnvironmentalData model = BLL.Information_EnvironmentalDataService.GetInformation_EnvironmentalDataById(this.Id);
|
|||
|
if (model != null)
|
|||
|
{
|
|||
|
this.txtUnitName.Text = UnitService.GetUnitNameByUnitId(model.UnitId) ;
|
|||
|
if (model.TotalEnergyConsumption.HasValue)
|
|||
|
{
|
|||
|
this.txtTotalEnergyConsumption.Text = model.TotalEnergyConsumption.Value.ToString();
|
|||
|
}
|
|||
|
if (model.IncomeComprehensiveEnergyConsumption.HasValue)
|
|||
|
{
|
|||
|
this.txtIncomeComprehensiveEnergyConsumption.Text = model.IncomeComprehensiveEnergyConsumption.Value.ToString();
|
|||
|
}
|
|||
|
if (model.NewWaterConsumption.HasValue)
|
|||
|
{
|
|||
|
this.txtNewWaterConsumption.Text = model.NewWaterConsumption.Value.ToString();
|
|||
|
}
|
|||
|
if (model.ReportDate != null)
|
|||
|
{
|
|||
|
this.txtReportDate.Text = string.Format("{0:yyyy-MM-dd}", model.ReportDate);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
this.txtUnitName.Text = CommonService.GetIsThisUnit().UnitName;
|
|||
|
txtReportDate.Text = DateTime.Now.ToString(txtReportDate.DateFormatString);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 保存按钮
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnSave_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (txtReportDate.SelectedDate == null)
|
|||
|
{
|
|||
|
|
|||
|
ShowNotify("请选择上报日期!",MessageBoxIcon.Question);
|
|||
|
return;
|
|||
|
|
|||
|
}
|
|||
|
if (txtReportDate.SelectedDate != null&& string .IsNullOrEmpty(Id))
|
|||
|
{
|
|||
|
DateTime dt = (DateTime)txtReportDate.SelectedDate;
|
|||
|
if (BLL.Information_EnvironmentalDataService.IsExitDataByReportDate(dt))
|
|||
|
{
|
|||
|
txtReportDate.SelectedDate = null;
|
|||
|
ShowNotify("该日期已上报!", MessageBoxIcon.Question);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
Model.Information_EnvironmentalData table = new Model.Information_EnvironmentalData();
|
|||
|
table.UnitId = CommonService.GetIsThisUnit().UnitId;
|
|||
|
table.TotalEnergyConsumption = Funs.GetNewInt(this.txtTotalEnergyConsumption.Text);
|
|||
|
table.IncomeComprehensiveEnergyConsumption = Funs.GetNewInt(this.txtIncomeComprehensiveEnergyConsumption.Text);
|
|||
|
table.NewWaterConsumption = Funs.GetNewInt(this.txtNewWaterConsumption.Text);
|
|||
|
table.ReportDate = this.txtReportDate.SelectedDate;
|
|||
|
table.CreateMan =this.CurrUser.UserId;
|
|||
|
table.CreateDate = DateTime.Now;
|
|||
|
if (string.IsNullOrEmpty(this.Id))
|
|||
|
{
|
|||
|
table.Id = SQLHelper.GetNewID(typeof(Model.Information_EnvironmentalData));
|
|||
|
BLL.Information_EnvironmentalDataService.AddInformation_EnvironmentalData(table);
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
table.Id = this.Id;
|
|||
|
BLL.Information_EnvironmentalDataService.UpdateInformation_EnvironmentalData(table);
|
|||
|
}
|
|||
|
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
|||
|
}
|
|||
|
|
|||
|
#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.Information_EnvironmentalDataMenuId);
|
|||
|
if (buttonList.Count() > 0)
|
|||
|
{
|
|||
|
if (buttonList.Contains(BLL.Const.BtnSave))
|
|||
|
{
|
|||
|
this.btnSave.Hidden = false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
protected void txtReportDate_TextChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (txtReportDate.SelectedDate != null)
|
|||
|
{
|
|||
|
DateTime dt = (DateTime)txtReportDate.SelectedDate;
|
|||
|
if (BLL.Information_EnvironmentalDataService.IsExitDataByReportDate(dt))
|
|||
|
{
|
|||
|
txtReportDate.SelectedDate = null;
|
|||
|
ShowNotify("该日期已上报!");
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|