Basf_TCC7/HJGL/FineUIPro.Web/HotProcessHard/HotProessReportEdit.aspx.cs

141 lines
5.4 KiB
C#

using System;
using BLL;
namespace FineUIPro.Web.HotProcessHard
{
public partial class HotProessReportEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string HotProessReportId
{
get
{
return (string)ViewState["HotProessReportId"];
}
set
{
ViewState["HotProessReportId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
HotProessReportId = Request.Params["HotProessReportId"];
if (!string.IsNullOrEmpty(HotProessReportId))
{
Model.HotProess_Report report = BLL.HotProessReportService.GetHotProessReportById(HotProessReportId);
if (report != null)
{
if (!string.IsNullOrEmpty(report.WeldJointId))
{
this.hdWeldJointId.Text = report.WeldJointId;
}
if (report.PointCount.HasValue)
{
this.txtPointCount.Text = report.PointCount.ToString();
}
this.txtRequiredT.Text = report.RequiredT;
this.txtActualT.Text = report.ActualT;
this.txtRequestTime.Text = report.RequestTime;
this.txtActualTime.Text = report.ActualTime;
this.txtRecordChartNo.Text = report.RecordChartNo;
}
}
else
{
string hotProessTrustItemId = Request.Params["HotProessTrustItemId"];
if (!string.IsNullOrEmpty(hotProessTrustItemId))
{
var hotProessTrustItem = BLL.HotProessTrustItemService.GetHotProessTrustItemById(hotProessTrustItemId);
if (hotProessTrustItem != null)
{
if (!string.IsNullOrEmpty(hotProessTrustItem.WeldJointId))
{
this.hdWeldJointId.Text = hotProessTrustItem.WeldJointId;
}
}
}
}
var jot = BLL.Pipeline_WeldJointService.GetViewWeldJointById(this.hdWeldJointId.Text);
if (jot != null)
{
this.txtWeldJointCode.Text = jot.WeldJointCode;
}
}
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
SaveData();
ShowNotify(Resources.Lan.SaveSuccessfully, MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
/// <summary>
/// 提交数据
/// </summary>
private void SaveData()
{
Model.HotProess_Report newReport = new Model.HotProess_Report();
newReport.PointCount = Funs.GetNewInt(this.txtPointCount.Text.Trim());
newReport.RequiredT = this.txtRequiredT.Text.Trim();
newReport.ActualT = this.txtActualT.Text.Trim();
newReport.RequestTime = this.txtRequestTime.Text.Trim();
newReport.ActualTime = this.txtActualTime.Text.Trim();
newReport.RecordChartNo = this.txtRecordChartNo.Text.Trim();
if (!string.IsNullOrEmpty(HotProessReportId))
{
newReport.HotProessReportId = HotProessReportId;
BLL.HotProessReportService.UpdateHotProessReport(newReport);
}
else
{
newReport.WeldJointId = this.hdWeldJointId.Text;
newReport.HotProessTrustItemId = Request.Params["HotProessTrustItemId"];
newReport.HotProessReportId = SQLHelper.GetNewID(typeof(Model.HotProess_Report));
HotProessReportId = newReport.HotProessReportId;
BLL.HotProessReportService.AddHotProessReport(newReport);
}
}
#endregion
#region
/// <summary>
/// 上传附件资源
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
string edit = "0"; // 表示能打开附件上传窗口,但不能上传附件
if (string.IsNullOrEmpty(HotProessReportId))
{
SaveData();
}
edit = "1";
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/HJGL/HotProcessHard&menuId={1}&edit={2}", HotProessReportId, Const.HotProessTrustMenuId, edit)));
}
#endregion
}
}