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

134 lines
5.0 KiB
C#
Raw Normal View History

2024-07-31 17:38:02 +08:00
using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
namespace FineUIPro.Web.Transfer
{
public partial class RotatingEquipmentEdit : 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_RotatingEquipment.FirstOrDefault(x => x.Id == Id);
if (model != null)
{
txtRotatingEquipment.Text = model.RotatingEquipment;
txtSYSTEM.Text = model.SYSTEM;
txtSubsystem.Text = model.Subsystem;
txtTestPackage.Text = model.TestPackage;
ddlAlignment.SelectedValue = model.Alignment;
ddlMotorsoloruntest.SelectedValue = model.Motorsoloruntest;
ddlStandalonetest.SelectedValue = model.Standalonetest;
ddlLubricatefilling.SelectedValue = model.Lubricatefilling;
2024-08-09 10:48:15 +08:00
txtDescriptions.Text = model.Descriptions;
2024-07-31 17:38:02 +08:00
}
}
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
var model = new Model.Transfer_RotatingEquipment
{
ProjectId = ProjectId,
RotatingEquipment = txtRotatingEquipment.Text,
SYSTEM = txtSYSTEM.Text,
Subsystem = txtSubsystem.Text,
TestPackage = txtTestPackage.Text,
Alignment = ddlAlignment.SelectedValue,
Motorsoloruntest = ddlMotorsoloruntest.SelectedValue,
2024-08-09 10:48:15 +08:00
Standalonetest = ddlStandalonetest.SelectedValue,
Descriptions= txtDescriptions.Text,
Lubricatefilling=ddlLubricatefilling.SelectedValue
2024-07-31 17:38:02 +08:00
};
#region
var listObj = new List<string>();
listObj.Add(model.Alignment);
listObj.Add(model.Motorsoloruntest);
listObj.Add(model.Standalonetest);
listObj.Add(model.Lubricatefilling);
2024-07-31 17:38:02 +08:00
//全是NA或Completed 状态是Completed
if (listObj.Where(x => x == "NA" || x == "Completed").ToList().Count == 4)
2024-07-31 17:38:02 +08:00
{
model.MechanicalFINALStatus = "Completed";
}
//如果全是NA或Not Start 就是 Not Start
else if (listObj.Where(x => x == "NA" || x == "Not Start").ToList().Count == 4)
2024-07-31 17:38:02 +08:00
{
model.MechanicalFINALStatus = "Not Start";
}
//如果其中有一项是In progress 或Not Start 是 In progress
else if (listObj.Where(x => x == "In progress" || x == "Not Start").ToList().Count >= 1)
{
model.MechanicalFINALStatus = "In progress";
}
#endregion
if (!string.IsNullOrEmpty(Id))
{
var newModel = Funs.DB.Transfer_RotatingEquipment.FirstOrDefault(x => x.Id == Id);
if (newModel != null)
{
newModel.RotatingEquipment = txtRotatingEquipment.Text;
newModel.SYSTEM = txtSYSTEM.Text;
newModel.Subsystem = txtSubsystem.Text;
newModel.TestPackage = txtTestPackage.Text;
newModel.Alignment = ddlAlignment.SelectedValue;
newModel.Motorsoloruntest = ddlMotorsoloruntest.SelectedValue;
newModel.Standalonetest = ddlStandalonetest.SelectedValue;
newModel.MechanicalFINALStatus = model.MechanicalFINALStatus;
2024-08-09 10:48:15 +08:00
newModel.Descriptions = txtDescriptions.Text;
newModel.Lubricatefilling = ddlLubricatefilling.SelectedValue;
2024-07-31 17:38:02 +08:00
}
}
else
{
model.Id = Id = Guid.NewGuid().ToString();
Funs.DB.Transfer_RotatingEquipment.InsertOnSubmit(model);
}
Funs.DB.SubmitChanges();
ShowNotify("保存成功", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
}
}