CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/Transfer/CivilStructureEdit.aspx.cs

169 lines
6.5 KiB
C#
Raw Normal View History

2024-08-01 10:56:31 +08:00
using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
namespace FineUIPro.Web.Transfer
{
public partial class CivilStructureEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
private string Id
{
get
{
return (string)ViewState["Id"];
}
set
{
ViewState["Id"] = value;
}
}
/// <summary>
/// 项目主键
/// </summary>
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Id = Request.Params["Id"];
ProjectId = this.CurrUser.LoginProjectId;
if (!string.IsNullOrEmpty(Id))
{
var model = Funs.DB.Transfer_Civil_Structure.FirstOrDefault(x => x.Id == Id);
if (model != null)
{
2024-12-14 10:27:27 +08:00
txtSN.Text = model.SN.ToString();
2024-08-01 10:56:31 +08:00
txtCivil_Structure.Text = model.Civil_Structure;
txtSystemName.Text = model.SystemName;
txtSubsystem.Text = model.Subsystem;
txtTest_Package.Text = model.Test_Package;
ddlFoundation.SelectedValue = model.Foundation;
ddlMainstructure.SelectedValue = model.Mainstructure;
//ddlBuildingdecoration.SelectedValue = model.Buildingdecoration;
//ddlEquipment.SelectedValue = model.Equipment;
2024-08-01 10:56:31 +08:00
2024-08-09 10:48:15 +08:00
//ddlInstrument.SelectedValue = model.Instrument;
//ddlElectrical.SelectedValue = model.Electrical;
//ddlFireFighting.SelectedValue = model.FireFighting;
//ddlHVAC.SelectedValue = model.HVAC;
2024-08-09 10:48:15 +08:00
txtDescriptions.Text = model.Descriptions;
2024-08-01 10:56:31 +08:00
}
}
2024-12-14 10:27:27 +08:00
else
{
var model = Funs.DB.Transfer_Civil_Structure.OrderByDescending(x => x.SN).FirstOrDefault(x => x.ProjectId == CurrUser.LoginProjectId);
if (model == null)
txtSN.Text = "1001";
else
txtSN.Text = (model.SN + 1).ToString();
}
2024-08-01 10:56:31 +08:00
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
var model = new Model.Transfer_Civil_Structure
{
2024-12-14 10:27:27 +08:00
SN = Convert.ToInt32(txtSN.Text),
2024-08-01 10:56:31 +08:00
ProjectId = ProjectId,
Civil_Structure = txtCivil_Structure.Text,
SystemName = txtSystemName.Text,
Subsystem = txtSubsystem.Text,
Test_Package = txtTest_Package.Text,
Foundation = ddlFoundation.SelectedValue,
Mainstructure = ddlMainstructure.SelectedValue,
//Buildingdecoration = ddlBuildingdecoration.SelectedValue,
//Equipment = ddlEquipment.SelectedValue,
2024-08-01 10:56:31 +08:00
2024-08-09 10:48:15 +08:00
//Instrument = ddlInstrument.SelectedValue,
//Electrical = ddlElectrical.SelectedValue,
//FireFighting = ddlFireFighting.SelectedValue,
//HVAC = ddlHVAC.SelectedValue,
2024-08-09 10:48:15 +08:00
Descriptions= txtDescriptions.Text
2024-08-01 10:56:31 +08:00
};
#region
var listObj = new List<string>();
listObj.Add(model.Foundation);
listObj.Add(model.Mainstructure);
//listObj.Add(model.Buildingdecoration);
//listObj.Add(model.Equipment);
2024-08-01 10:56:31 +08:00
2024-08-09 10:48:15 +08:00
//listObj.Add(model.Instrument);
//listObj.Add(model.Electrical);
//listObj.Add(model.FireFighting);
//listObj.Add(model.HVAC);
2024-12-24 19:25:18 +08:00
model.FINAL_Status = "Not Start";
2024-08-01 10:56:31 +08:00
//全是NA或Completed 状态是Completed
if (listObj.Where(x => x == "NA" || x == "Completed").ToList().Count == 2)
2024-08-01 10:56:31 +08:00
{
model.FINAL_Status = "Completed";
2025-02-17 12:15:10 +08:00
}
//如果全是NA或Not Start、空 就是 Not Start
else if (listObj.Where(x => string.IsNullOrWhiteSpace(x) || x == "NA" || x == "Not Start").ToList().Count == 2)
2024-08-01 10:56:31 +08:00
{
model.FINAL_Status = "Not Start";
}
2025-02-17 12:15:10 +08:00
//如果其中有一项是In progress 或Not Start、空 是 In progress
else if (listObj.Where(x => string.IsNullOrWhiteSpace(x) || x == "In progress" || x == "Not Start").ToList().Count >= 1)
2024-08-01 10:56:31 +08:00
{
model.FINAL_Status = "In progress";
}
#endregion
2024-12-14 10:27:27 +08:00
2024-08-01 10:56:31 +08:00
if (!string.IsNullOrEmpty(Id))
{
var newModel = Funs.DB.Transfer_Civil_Structure.FirstOrDefault(x => x.Id == Id);
if (newModel != null)
{
2024-12-14 10:27:27 +08:00
newModel.SN = model.SN;
2024-08-01 10:56:31 +08:00
newModel.Civil_Structure = txtCivil_Structure.Text;
newModel.SystemName = txtSystemName.Text;
newModel.Subsystem = txtSubsystem.Text;
newModel.Test_Package = txtTest_Package.Text;
newModel.Foundation = ddlFoundation.SelectedValue;
newModel.Mainstructure = ddlMainstructure.SelectedValue;
//newModel.Buildingdecoration = ddlBuildingdecoration.SelectedValue;
//newModel.Equipment = ddlEquipment.SelectedValue;
2024-08-01 10:56:31 +08:00
2024-08-09 10:48:15 +08:00
//newModel.Instrument = ddlInstrument.SelectedValue;
//newModel.Electrical = ddlElectrical.SelectedValue;
//newModel.FireFighting = ddlFireFighting.SelectedValue;
//newModel.HVAC = ddlHVAC.SelectedValue;
2024-08-01 10:56:31 +08:00
newModel.FINAL_Status = model.FINAL_Status;
2024-08-09 10:48:15 +08:00
newModel.Descriptions = txtDescriptions.Text;
2024-08-01 10:56:31 +08:00
}
}
else
{
model.Id = Id = Guid.NewGuid().ToString();
Funs.DB.Transfer_Civil_Structure.InsertOnSubmit(model);
}
Funs.DB.SubmitChanges();
ShowNotify("保存成功", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
}
}