using BLL; using System; using System.Collections.Generic; using System.Data; using System.Linq; namespace FineUIPro.Web.Transfer { public partial class TelecomEdit : PageBase { #region 定义项 /// /// 主键 /// private string Id { get { return (string)ViewState["Id"]; } set { ViewState["Id"] = value; } } /// /// 项目主键 /// 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_Telecom.FirstOrDefault(x => x.Id == Id); if (model != null) { txtTelecom.Text = model.Telecom; txtSystemName.Text = model.SystemName; txtSubsystem.Text = model.Subsystem; txtTest_Package.Text = model.Test_Package; ddlInstallation.SelectedValue = model.Installation; ddlCommunication.SelectedValue = model.Communication; ddlCableLaying.SelectedValue = model.CableLaying; ddlFunctionTest.SelectedValue = model.FunctionTest; txtDescriptions.Text = model.Descriptions; } } } } protected void btnSave_Click(object sender, EventArgs e) { var model = new Model.Transfer_Telecom { ProjectId = ProjectId, Telecom = txtTelecom.Text, SystemName = txtSystemName.Text, Subsystem = txtSubsystem.Text, Test_Package = txtTest_Package.Text, Installation = ddlInstallation.SelectedValue, Communication = ddlCommunication.SelectedValue, CableLaying = ddlCableLaying.SelectedValue, FunctionTest = ddlFunctionTest.SelectedValue, Descriptions= txtDescriptions.Text, }; #region 判断状态 var listObj = new List(); listObj.Add(model.Installation); listObj.Add(model.Communication); listObj.Add(model.CableLaying); listObj.Add(model.FunctionTest); //全是NA或Completed 状态是Completed if (listObj.Where(x => x == "NA" || x == "Completed").ToList().Count ==4) { model.FINAL_Status = "Completed"; } //如果全是Not Start 就是 Not Start else if (listObj.Where(x => x == "Not Start").ToList().Count == 4) { model.FINAL_Status = "Not Start"; } //如果其中有一项是In progress 或Not Start 是 In progress else if (listObj.Where(x => x == "In progress" || x == "Not Start").ToList().Count >= 1) { model.FINAL_Status = "In progress"; } #endregion if (!string.IsNullOrEmpty(Id)) { var newModel = Funs.DB.Transfer_Telecom.FirstOrDefault(x => x.Id == Id); if (newModel != null) { newModel.Telecom = txtTelecom.Text; newModel.SystemName = txtSystemName.Text; newModel.Subsystem = txtSubsystem.Text; newModel.Test_Package = txtTest_Package.Text; newModel.Installation = ddlInstallation.SelectedValue; newModel.Communication = ddlCommunication.SelectedValue; newModel.CableLaying = ddlCableLaying.SelectedValue; newModel.FunctionTest = ddlFunctionTest.SelectedValue; newModel.FINAL_Status = model.FINAL_Status; newModel.Descriptions = txtDescriptions.Text; } } else { model.Id = Id = Guid.NewGuid().ToString(); Funs.DB.Transfer_Telecom.InsertOnSubmit(model); } Funs.DB.SubmitChanges(); ShowNotify("保存成功", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } } }