229 lines
8.4 KiB
C#
229 lines
8.4 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace FineUIPro.Web.JGZL
|
|
{
|
|
public partial class PressureTestOfPipelineSystemRecordEdit : PageBase
|
|
{
|
|
#region 定义项
|
|
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
private string RecordId
|
|
{
|
|
get { return (string)ViewState["RecordId"]; }
|
|
set { ViewState["RecordId"] = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 项目Id
|
|
/// </summary>
|
|
private string ProjectId
|
|
{
|
|
get { return (string)ViewState["ProjectId"]; }
|
|
set { ViewState["ProjectId"] = value; }
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 加载页面
|
|
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ProjectId = Request.Params["projectId"];
|
|
this.RecordId = Request.Params["recordId"];
|
|
if (!string.IsNullOrEmpty(this.RecordId))
|
|
{
|
|
var report = BLL.PressureTestOfPipelineSystemRecordService.GetPressureTestOfPipelineSystemRecordById(this.RecordId);
|
|
if (report != null)
|
|
{
|
|
this.txtSystemCode.Text = report.SystemCode;
|
|
this.txtSystemName.Text = report.SystemName;
|
|
this.txtTestConclusion.Text = report.TestConclusion;
|
|
this.txtRemark.Text = report.Remark;
|
|
|
|
var items = BLL.PressureTestOfPipelineSystemRecordItemService.GetItemByRecordId(this.RecordId);
|
|
if (items != null)
|
|
{
|
|
Grid1.DataSource = items;
|
|
Grid1.DataBind();
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 提交按钮
|
|
|
|
/// <summary>
|
|
/// 提交按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId,
|
|
Const.JGZL_PressureTestOfPipelineSystemRecordMenuId, Const.BtnSave))
|
|
{
|
|
Model.JGZL_PressureTestOfPipelineSystemRecord newReport = new Model.JGZL_PressureTestOfPipelineSystemRecord();
|
|
newReport.SystemCode = this.txtSystemCode.Text.Trim();
|
|
newReport.SystemName = this.txtSystemName.Text.Trim();
|
|
newReport.TestConclusion = this.txtTestConclusion.Text;
|
|
newReport.Remark = this.txtRemark.Text;
|
|
if (!string.IsNullOrEmpty(this.RecordId))
|
|
{
|
|
newReport.RecordId = this.RecordId;
|
|
BLL.PressureTestOfPipelineSystemRecordService.UpdatePressureTestOfPipelineSystemRecord(newReport);
|
|
}
|
|
else
|
|
{
|
|
newReport.ProjectId = this.ProjectId;
|
|
newReport.CompileMan = this.CurrUser.UserId;
|
|
newReport.CompileDate = DateTime.Now;
|
|
newReport.RecordId = SQLHelper.GetNewID(typeof(Model.JGZL_PressureTestOfPipelineSystemRecord));
|
|
this.RecordId = newReport.RecordId;
|
|
BLL.PressureTestOfPipelineSystemRecordService.AddPressureTestOfPipelineSystemRecord(newReport);
|
|
}
|
|
//保存明细
|
|
saveItem();
|
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 数据行
|
|
|
|
protected void btnAddGrid1_Click(object sender, EventArgs e)
|
|
{
|
|
Grid1.Hidden = false;
|
|
|
|
JArray teamGroupData = Grid1.GetMergedData();
|
|
List<JObject> list = new List<JObject>();
|
|
foreach (JObject teamGroupRow in teamGroupData)
|
|
{
|
|
JObject values = teamGroupRow.Value<JObject>("values");
|
|
list.Add(values);
|
|
}
|
|
|
|
JObject defaultObj = new JObject
|
|
{
|
|
{ "Id", Guid.NewGuid() },
|
|
{ "RecordId", RecordId },
|
|
{ "Part", "" },
|
|
{ "MaterialName", "" },
|
|
{ "Grade", "" },
|
|
{ "Manufacturer", "" },
|
|
{ "PlanFilmThickness", "" },
|
|
{ "ActualFilmThickness", "" },
|
|
{
|
|
"Delete3",
|
|
String.Format("<a href=\"javascript:;\" onclick=\"{0}\"><img src=\"{1}\"/></a>",
|
|
GetDeleteScriptGrid1(), IconHelper.GetResolvedIconUrl(Icon.Delete))
|
|
}
|
|
};
|
|
list.Add(defaultObj);
|
|
Grid1.DataSource = list;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
protected void Grid3_PreDataBound(object sender, EventArgs e)
|
|
{
|
|
// 设置LinkButtonField的点击客户端事件
|
|
LinkButtonField deleteField = Grid1.FindColumn("Delete3") as LinkButtonField;
|
|
deleteField.OnClientClick = GetDeleteScriptGrid1();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除提示
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private string GetDeleteScriptGrid1()
|
|
{
|
|
return Confirm.GetShowReference("删除选中行?", String.Empty, MessageBoxIcon.Question,
|
|
Grid1.GetDeleteSelectedRowsReference(), String.Empty);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 排序
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
// List<Model.BlowingCleaningItem> GetBlowingCleaningItem = this.CollectGridJointInfo();
|
|
// this.BindGrid(GetBlowingCleaningItem);
|
|
}
|
|
#endregion
|
|
|
|
#region 获取Grid数据
|
|
|
|
|
|
void saveItem()
|
|
{
|
|
List<Model.JGZL_PressureTestOfPipelineSystemRecordItem> detailLists = new List<Model.JGZL_PressureTestOfPipelineSystemRecordItem>();
|
|
JArray teamGroupData = Grid1.GetMergedData();
|
|
foreach (JObject teamGroupRow in teamGroupData)
|
|
{
|
|
JObject values = teamGroupRow.Value<JObject>("values");
|
|
int rowIndex = teamGroupRow.Value<int>("index");
|
|
Model.JGZL_PressureTestOfPipelineSystemRecordItem newDetail = new Model.JGZL_PressureTestOfPipelineSystemRecordItem
|
|
{
|
|
Id = values.Value<string>("Id"),
|
|
RecordId = RecordId,
|
|
PipelineNo = values.Value<string>("PipelineNo"),
|
|
DesignPressure = values.Value<string>("DesignPressure"),
|
|
DesignTemperature = values.Value<string>("DesignTemperature"),
|
|
TestTemperature = values.Value<string>("TestTemperature"),
|
|
TestMedium = values.Value<string>("TestMedium"),
|
|
TestMediumTemperature = values.Value<string>("TestMediumTemperature"),
|
|
TestPressure = values.Value<string>("TestPressure"),
|
|
VoltageStabilizationTime = values.Value<string>("VoltageStabilizationTime"),
|
|
};
|
|
detailLists.Add(newDetail);
|
|
}
|
|
|
|
try
|
|
{
|
|
var result = Funs.DB.JGZL_PressureTestOfPipelineSystemRecordItem.Where(a => a.RecordId == RecordId);
|
|
Funs.DB.JGZL_PressureTestOfPipelineSystemRecordItem.DeleteAllOnSubmit(result);
|
|
if (detailLists.Count > 0)
|
|
{
|
|
Funs.DB.JGZL_PressureTestOfPipelineSystemRecordItem.InsertAllOnSubmit(detailLists);
|
|
}
|
|
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
} |