Files
SGGL_SHJ/SGGL/FineUIPro.Web/HJGL/PreWeld/FitupCheckEdit.aspx.cs
T

164 lines
6.4 KiB
C#

using BLL;
using System;
using System.Linq;
namespace FineUIPro.Web.HJGL.PreWeld
{
public partial class FitupCheckEdit : PageBase
{
public string FitupCheckId
{
get { return (string)ViewState["FitupCheckId"]; }
set { ViewState["FitupCheckId"] = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
btnClose.OnClientClick = ActiveWindow.GetHideReference();
FitupCheckId = Request.Params["FitupCheckId"];
var weldJointId = Request.Params["WeldJointId"];
BindWeldJoint();
BindCheckPerson();
ddlCheckResult.SelectedValue = "合格";
if (!string.IsNullOrEmpty(FitupCheckId))
{
BindData();
}
else if (!string.IsNullOrEmpty(weldJointId))
{
drpWeldJoint.SelectedValue = weldJointId;
drpWeldJoint.Enabled = false;
drpCheckPerson.SelectedValue = CurrUser.PersonId;
dpCheckTime.SelectedDate = DateTime.Now;
}
else
{
drpCheckPerson.SelectedValue = CurrUser.PersonId;
dpCheckTime.SelectedDate = DateTime.Now;
}
}
}
private void BindWeldJoint()
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var data = (from x in db.HJGL_WeldJoint
where x.ProjectId == CurrUser.LoginProjectId
orderby x.PipelineCode, x.WeldJointCode
select new
{
x.WeldJointId,
WeldJointName = x.PipelineCode + " / " + x.WeldJointCode
}).ToList();
drpWeldJoint.DataTextField = "WeldJointName";
drpWeldJoint.DataValueField = "WeldJointId";
drpWeldJoint.DataSource = data;
drpWeldJoint.DataBind();
}
}
private void BindCheckPerson()
{
Person_PersonsService.InitUserProjectIdUnitIdRoleIdDropDownList(drpCheckPerson, CurrUser.LoginProjectId, null, null, true);
}
private void BindData()
{
var model = PreWeldInspectionService.GetFitupCheckById(FitupCheckId);
if (model == null)
{
return;
}
var weldJoint = APIPreWeldInspectionService.GetPreWeldJointByWeldJointId(model.WeldJointId);
if (weldJoint != null)
{
drpWeldJoint.SelectedValue = weldJoint.WeldJointId;
drpWeldJoint.Enabled = false;
if (weldJoint.FitupGap.HasValue)
{
numFitupGap.Text = weldJoint.FitupGap.Value.ToString();
}
if (weldJoint.Misalignment.HasValue)
{
numMisalignment.Text = weldJoint.Misalignment.Value.ToString();
}
}
if (model != null)
{
if (model.FitupGap.HasValue)
{
numFitupGap.Text = model.FitupGap.Value.ToString();
}
if (model.Misalignment.HasValue)
{
numMisalignment.Text = model.Misalignment.Value.ToString();
}
if (!string.IsNullOrEmpty(model.CheckResult))
{
ddlCheckResult.SelectedValue = model.CheckResult;
}
if (!string.IsNullOrEmpty(model.CheckPerson))
{
drpCheckPerson.SelectedValue = model.CheckPerson;
}
dpCheckTime.SelectedDate = model.CheckTime;
txtUnqualifiedReason.Text = model.UnqualifiedReason;
txtRectifyRequirement.Text = model.RectifyRequirement;
txtRemark.Text = model.Remark;
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
if (!CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, CurrUser.PersonId, Const.HJGL_PreWeldFitupCheckMenuId, Const.BtnSave))
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
var item = new Model.PreWeldFitupCheckInput
{
FitupCheckId = FitupCheckId,
ProjectId = CurrUser.LoginProjectId,
WeldJointId = drpWeldJoint.SelectedValue,
FitupGap = string.IsNullOrWhiteSpace(numFitupGap.Text) ? (decimal?)null : Convert.ToDecimal(numFitupGap.Text),
Misalignment = string.IsNullOrWhiteSpace(numMisalignment.Text) ? (decimal?)null : Convert.ToDecimal(numMisalignment.Text),
CheckResult = ddlCheckResult.SelectedValue,
CheckPerson = drpCheckPerson.SelectedValue,
CheckTime = dpCheckTime.SelectedDate ?? DateTime.Now,
CreateUser = CurrUser.PersonId,
UnqualifiedReason = txtUnqualifiedReason.Text.Trim(),
RectifyRequirement = txtRectifyRequirement.Text.Trim(),
Remark = txtRemark.Text.Trim()
};
try
{
FitupCheckId = APIPreWeldInspectionService.SaveFitupCheck(item);
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
catch (ArgumentException ex)
{
ShowNotify(ex.Message, MessageBoxIcon.Warning);
}
}
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(FitupCheckId))
{
Alert.ShowInTop("请先保存组对抽检记录后再上传附件!", MessageBoxIcon.Warning);
return;
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(
string.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/HJGL/PreWeld/FitupCheck&menuId={1}&edit=1&type=-1",
FitupCheckId, Const.HJGL_PreWeldFitupCheckMenuId)));
}
}
}