SGGL_HBAZ/SGGL/FineUIPro.Web/SYHSE/Data_EnvironmentProtectionE...

144 lines
5.6 KiB
C#

using BLL;
using Microsoft.Office.Interop.Excel;
using Model.APIItem.SYHSE;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.SYHSE
{
public partial class Data_EnvironmentProtectionEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string Id
{
get
{
return (string)ViewState["Id"];
}
set
{
ViewState["Id"] = value;
}
}
#endregion
/// <summary>
/// 把状态转换代号为文字形式
/// </summary>
/// <param name="state"></param>
/// <returns></returns>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Id = Request.Params["Id"];
if (!string.IsNullOrEmpty(Id))
{
var environmentProtection = Funs.DB.SYHSEData_EnvironmentProtection.FirstOrDefault(x => x.Id == Id);
if (environmentProtection != null)
{
if (environmentProtection.DetectionTimeA.HasValue)
{
this.txtReportDateA.Text = environmentProtection.DetectionTimeA.Value.ToString("yyyy-MM-dd");
}
if (environmentProtection.DetectionTimeZ.HasValue)
{
this.txtReportDateZ.Text = environmentProtection.DetectionTimeZ.Value.ToString("yyyy-MM-dd");
}
this.txtDetectionAddress.Text = environmentProtection.DetectionAddress;
this.txtDetectionProject.Text = environmentProtection.DetectionProject;
this.txtDetectionValue.Text = environmentProtection.DetectionValue;
this.txtStandValue.Text = environmentProtection.StandValue;
this.txtAvgFlow.Text = environmentProtection.AvgFlow;
this.txtSumFlow.Text = environmentProtection.SumFlow;
this.txtIsOk.Text = environmentProtection.IsOk;
this.txtIsStop.Text = environmentProtection.IsStop;
this.txtReMark.Text = environmentProtection.ReMark;
}
}
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
//string projectId, string userId, string menuId, string buttonName)
if (BLL.CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.SYHSE_EnvironmentProtectionMenuId, BLL.Const.BtnSave))
{
Model.SYHSEData_EnvironmentProtection Promise = Funs.DB.SYHSEData_EnvironmentProtection.FirstOrDefault(x => x.Id == Id);
if (Promise == null)
{
Promise = new Model.SYHSEData_EnvironmentProtection();
Promise.Id = Guid.NewGuid().ToString();
Funs.DB.SYHSEData_EnvironmentProtection.InsertOnSubmit(Promise);
}
Promise.ProjectId = this.CurrUser.LoginProjectId;
Promise.DetectionAddress = this.txtDetectionAddress.Text;
Promise.DetectionProject = this.txtDetectionProject.Text;
Promise.DetectionValue = this.txtDetectionValue.Text;
Promise.StandValue = this.txtStandValue.Text;
Promise.AvgFlow = this.txtAvgFlow.Text;
Promise.SumFlow = this.txtSumFlow.Text;
Promise.IsOk = this.txtIsOk.Text;
Promise.IsStop = this.txtIsStop.Text;
Promise.ReMark = this.txtReMark.Text;
Promise.CreateMan = this.CurrUser.UserId;
Promise.CreateDate = DateTime.Now;
Promise.DetectionTimeA = this.txtReportDateA.SelectedDate;
Promise.DetectionTimeZ = this.txtReportDateZ.SelectedDate;
Funs.DB.SubmitChanges();
DataEnvironmentProtectionItem newItem = new DataEnvironmentProtectionItem();
newItem.Id = Promise.Id;
newItem.ProjectId = Promise.ProjectId;
newItem.UnitId = Promise.UnitId;
newItem.CreateMan = Promise.CreateMan;
newItem.CreateDate = Promise.CreateDate;
newItem.DetectionTimeA = Promise.DetectionTimeA;
newItem.DetectionTimeZ = Promise.DetectionTimeZ;
newItem.DetectionAddress = Promise.DetectionAddress;
newItem.DetectionProject = Promise.DetectionProject;
newItem.DetectionValue = Promise.DetectionValue;
newItem.StandValue = Promise.StandValue;
newItem.AvgFlow = Promise.AvgFlow;
newItem.SumFlow = Promise.SumFlow;
newItem.IsOk = Promise.IsOk;
newItem.IsStop = Promise.IsStop;
newItem.ReMark = Promise.ReMark;
newItem.Type = Promise.Type;
string contenttype = "application/json;charset=utf-8";
string url = ConfigurationManager.AppSettings["QHSE_URL"] + "api/SYHSEData/SaveEnvironmentProtection";
string messages = APIGetHttpService.Http(url, "POST", contenttype, null, JsonConvert.SerializeObject(newItem));
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
}
}