Files
SGGL_SHJ/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldAppearanceCheckEdit.aspx.cs
T

113 lines
4.8 KiB
C#

using BLL;
using System;
using System.Linq;
namespace FineUIPro.Web.HJGL.WeldingManage
{
public partial class WeldAppearanceCheckEdit : PageBase
{
private string AppearanceCheckId
{
get { return (string)ViewState["AppearanceCheckId"]; }
set { ViewState["AppearanceCheckId"] = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack) return;
btnClose.OnClientClick = ActiveWindow.GetHideReference();
AppearanceCheckId = Request.Params["AppearanceCheckId"] ?? Guid.NewGuid().ToString();
BindWeldJoints();
Person_PersonsService.InitUserProjectIdUnitIdRoleIdDropDownList(ddlCheckPerson, CurrUser.LoginProjectId, null, null, true);
var model = WeldAppearanceCheckService.GetById(AppearanceCheckId);
if (model == null)
{
ddlQualified.SelectedValue = "1";
ddlCheckPerson.SelectedValue = CurrUser.PersonId;
dpCheckTime.SelectedDate = DateTime.Now;
return;
}
ddlWeldJoint.SelectedValue = model.WeldJointId;
ddlQualified.SelectedValue = model.IsQualified ? "1" : "0";
ddlCheckPerson.SelectedValue = model.CheckPerson;
dpCheckTime.SelectedDate = model.CheckTime;
txtRemark.Text = model.Remark;
numWeldReinforcement.Text = ToText(model.WeldReinforcement);
numWeldHeight.Text = ToText(model.WeldHeight);
numWeldWidth.Text = ToText(model.WeldWidth);
txtSurfaceDefect.Text = model.SurfaceDefect;
numPreheatTemperature.Text = ToText(model.PreheatTemperature);
numInterpassTemperature.Text = ToText(model.InterpassTemperature);
}
private void BindWeldJoints()
{
var data = WeldAppearanceCheckService.GetWeldedJoints(CurrUser.LoginProjectId, null, null, 0, 10000)
.Select(x => new { x.WeldJointId, Name = x.PipelineCode + " / " + x.WeldJointCode }).ToList();
ddlWeldJoint.DataTextField = "Name";
ddlWeldJoint.DataValueField = "WeldJointId";
ddlWeldJoint.DataSource = data;
ddlWeldJoint.DataBind();
}
protected void btnSave_Click(object sender, EventArgs e)
{
if (!CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, CurrUser.PersonId,
Const.HJGL_WeldAppearanceCheckMenuId, Const.BtnSave))
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
try
{
WeldAppearanceCheckService.Save(new Model.WeldAppearanceCheckInput
{
AppearanceCheckId = AppearanceCheckId,
ProjectId = CurrUser.LoginProjectId,
WeldJointId = ddlWeldJoint.SelectedValue,
IsQualified = ddlQualified.SelectedValue == "1",
CheckPerson = ddlCheckPerson.SelectedValue,
CheckTime = dpCheckTime.SelectedDate,
Remark = txtRemark.Text.Trim(),
WeldReinforcement = ToDecimal(numWeldReinforcement.Text),
WeldHeight = ToDecimal(numWeldHeight.Text),
WeldWidth = ToDecimal(numWeldWidth.Text),
SurfaceDefect = txtSurfaceDefect.Text.Trim(),
PreheatTemperature = ToDecimal(numPreheatTemperature.Text),
InterpassTemperature = ToDecimal(numInterpassTemperature.Text),
CreateUser = CurrUser.PersonId
});
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
catch (ArgumentException ex)
{
ShowNotify(ex.Message, MessageBoxIcon.Warning);
}
catch (Exception ex)
{
Alert.ShowInTop(ex.Message, MessageBoxIcon.Warning);
}
}
protected void btnAttach_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(string.Format(
"../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/HJGL/WeldingManage/WeldAppearanceCheck&menuId={1}&edit=1",
AppearanceCheckId, Const.HJGL_WeldAppearanceCheckMenuId)));
}
private static decimal? ToDecimal(string value)
{
decimal result;
return decimal.TryParse(value, out result) ? result : (decimal?)null;
}
private static string ToText(decimal? value)
{
return value.HasValue ? value.Value.ToString() : string.Empty;
}
}
}