CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/TestRun/ProduceProperty/PropertyRunOthersCheckEdit....

126 lines
5.7 KiB
C#

using BLL;
using System;
namespace FineUIPro.Web.TestRun.ProduceProperty
{
public partial class PropertyRunOthersCheckEdit :PageBase
{
#region
/// <summary>
/// 页面加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BLL.UnitWorkService.InitUnitWorkDropDownList(this.drpUnitWorkId, this.CurrUser.LoginProjectId, true);
BLL.UserService.InitUserDropDownList(this.drpInstallationMan, this.CurrUser.LoginProjectId, true);
string id = Request.Params["id"];
if (!string.IsNullOrEmpty(id))
{
Model.ProduceProperty_PropertyRunOthersCheck data = BLL.PropertyRunOthersCheckService.GetPropertyRunOthersCheckById(id);
if (data != null)
{
this.hdId.Text = id;
this.txtCode.Text = data.Code;
if (!string.IsNullOrEmpty(data.UnitWorkId))
{
this.drpUnitWorkId.SelectedValue = data.UnitWorkId;
}
if (!string.IsNullOrEmpty(data.InstallationMan))
{
this.drpInstallationMan.SelectedValue = data.InstallationMan;
}
this.txtRecordName.Text = data.RecordName;
this.txtRecordCode.Text = data.RecordCode;
this.txtRecordMan.Text = BLL.UserService.GetUserNameByUserId(data.RecordMan);
this.txtStartDate.Text = data.StartDate.HasValue ? string.Format("{0:yyyy-MM-dd}", data.StartDate) : "";
this.txtEndDate.Text = data.EndDate.HasValue ? string.Format("{0:yyyy-MM-dd}", data.EndDate) : "";
this.txtProfession.Text = data.Profession;
this.txtRecordInstructions.Text = data.RecordInstructions;
this.txtProblemsSolutions.Text = data.ProblemsSolutions;
this.txtRemark.Text = data.Remark;
}
}
else
{
this.txtRecordMan.Text = this.CurrUser.UserName;
}
}
}
#endregion
#region
/// <summary>
/// 附件上传
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttach_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.hdId.Text)) //新增记录
{
this.hdId.Text = SQLHelper.GetNewID(typeof(Model.ProduceProperty_PropertyRunOthersCheck));
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/TestRun/ProduceProperty/PropertyRunOthersCheck&menuId={1}", this.hdId.Text, BLL.Const.PropertyRunOthersCheckMenuId)));
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (this.drpUnitWorkId.SelectedValue == BLL.Const._Null)
{
Alert.ShowInTop("请选择考核装置!", MessageBoxIcon.Warning);
return;
}
string id = Request.Params["id"];
Model.ProduceProperty_PropertyRunOthersCheck newData = new Model.ProduceProperty_PropertyRunOthersCheck();
newData.Code = this.txtCode.Text.Trim();
newData.UnitWorkId = this.drpUnitWorkId.SelectedValue;
if (this.drpInstallationMan.SelectedValue != BLL.Const._Null)
{
newData.InstallationMan = this.drpInstallationMan.SelectedValue;
}
newData.RecordName = this.txtRecordName.Text.Trim();
newData.RecordCode = this.txtRecordCode.Text.Trim();
newData.RecordMan = this.CurrUser.UserId;
newData.StartDate = Funs.GetNewDateTime(this.txtStartDate.Text.Trim());
newData.EndDate = Funs.GetNewDateTime(this.txtEndDate.Text.Trim());
newData.Profession = this.txtProfession.Text.Trim();
newData.RecordInstructions = this.txtRecordInstructions.Text.Trim();
newData.ProblemsSolutions = this.txtProblemsSolutions.Text.Trim();
newData.Remark = this.txtRemark.Text.Trim();
newData.ProjectId = this.CurrUser.LoginProjectId;
if (!string.IsNullOrEmpty(id))
{
newData.PropertyRunOthersCheckId = id;
BLL.PropertyRunOthersCheckService.UpdatePropertyRunOthersCheck(newData);
}
else
{
if (!string.IsNullOrEmpty(this.hdId.Text))
{
newData.PropertyRunOthersCheckId = this.hdId.Text.Trim();
}
else
{
newData.PropertyRunOthersCheckId = SQLHelper.GetNewID(typeof(Model.ProduceProperty_PropertyRunOthersCheck));
this.hdId.Text = newData.PropertyRunOthersCheckId;
}
BLL.PropertyRunOthersCheckService.AddPropertyRunOthersCheck(newData);
}
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
}
}