250 lines
10 KiB
C#
250 lines
10 KiB
C#
using BLL;
|
|
using BLL.CQMS.Comprehensive;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.CQMS.Comprehensive
|
|
{
|
|
public partial class PressurePipeEdit : PageBase
|
|
{
|
|
#region 定义变量
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string PressurePipeId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["PressurePipeId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["PressurePipeId"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
GetButtonPower();
|
|
BLL.UnitService.InitUnitDownList(this.drpUnit, this.CurrUser.LoginProjectId, true);
|
|
|
|
this.btnSave.Hidden = true;
|
|
this.PressurePipeId = Request.Params["PressurePipeId"];
|
|
Model.Comprehensive_PressurePipe pressurePipe = BLL.PressurePipeService.GetPressurePipeById(this.PressurePipeId);
|
|
if (pressurePipe != null)
|
|
{
|
|
this.hdAttachUrl.Text = this.PressurePipeId;
|
|
this.PressurePipeId = pressurePipe.PressurePipeId;
|
|
if (!string.IsNullOrEmpty(pressurePipe.UnitId))
|
|
{
|
|
this.drpUnit.SelectedValue = pressurePipe.UnitId;
|
|
}
|
|
this.txtEstimateNumber.Text = pressurePipe.EstimateNumber.HasValue ? pressurePipe.EstimateNumber.ToString() : "";
|
|
this.txtActualNumber.Text = pressurePipe.ActualNumber.HasValue ? pressurePipe.ActualNumber.ToString() : "";
|
|
this.txtPackageNumber.Text = pressurePipe.PackageNumber.HasValue ? pressurePipe.PackageNumber.ToString() : "";
|
|
this.txtCompletePackageNumber.Text = pressurePipe.CompletePackageNumber.HasValue ? pressurePipe.CompletePackageNumber.ToString() : "";
|
|
this.txtPressurePipeNumber.Text = pressurePipe.PressurePipeNumber.HasValue ? pressurePipe.PressurePipeNumber.ToString() : "";
|
|
this.txtIssuedReportNumber.Text = pressurePipe.IssuedReportNumber.HasValue ? pressurePipe.IssuedReportNumber.ToString() : "";
|
|
|
|
|
|
var currApprove = PressurePipeApproveService.GetCurrentApprove(pressurePipe.PressurePipeId);
|
|
if (currApprove != null)
|
|
{ //重新编制 编制人 可以 显示 提交 保存按钮
|
|
if (currApprove.ApproveType == BLL.Const.Comprehensive_ReCompile && pressurePipe.CompileMan == CurrUser.UserId)
|
|
{
|
|
this.btnSave.Hidden = false;
|
|
}//审核状态 审核人 可以显示 提交 保存按钮
|
|
else if (currApprove.ApproveType == BLL.Const.Comprehensive_Audit && currApprove.ApproveMan == CurrUser.UserId)
|
|
{
|
|
//审核状态不可编辑
|
|
Readonly();
|
|
|
|
this.btnSave.Hidden = false;
|
|
}
|
|
}//没有当前审核人,已完成状态 或者 待提交状态
|
|
else
|
|
{
|
|
if (pressurePipe.Status == BLL.Const.Comprehensive_Compile && pressurePipe.CompileMan == CurrUser.UserId)
|
|
{
|
|
this.btnSave.Hidden = false;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
this.btnSave.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 禁止编辑
|
|
/// </summary>
|
|
public void Readonly()
|
|
{
|
|
this.txtActualNumber.Readonly = true;
|
|
this.txtCompletePackageNumber.Readonly = true;
|
|
this.txtEstimateNumber.Readonly = true;
|
|
this.txtIssuedReportNumber.Readonly = true;
|
|
this.txtPackageNumber.Readonly = true;
|
|
this.txtPressurePipeNumber.Readonly = true;
|
|
this.drpUnit.Readonly = true;
|
|
|
|
|
|
//this.btnAttach.Enabled = false;
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (drpUnit.SelectedValue == BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择所属单位!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
Model.Comprehensive_PressurePipe pressurePipe = new Model.Comprehensive_PressurePipe();
|
|
pressurePipe.Projctid = this.CurrUser.LoginProjectId;
|
|
if (!string.IsNullOrEmpty(this.txtEstimateNumber.Text))
|
|
{
|
|
pressurePipe.EstimateNumber = Convert.ToInt32(this.txtEstimateNumber.Text);
|
|
}
|
|
if (this.drpUnit.SelectedValue != BLL.Const._Null)
|
|
{
|
|
pressurePipe.UnitId = this.drpUnit.SelectedValue;
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtActualNumber.Text))
|
|
{
|
|
pressurePipe.ActualNumber = Convert.ToInt32(this.txtActualNumber.Text);
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtPackageNumber.Text))
|
|
{
|
|
pressurePipe.PackageNumber = Convert.ToInt32(this.txtPackageNumber.Text);
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtCompletePackageNumber.Text))
|
|
{
|
|
pressurePipe.CompletePackageNumber = Convert.ToInt32(this.txtCompletePackageNumber.Text);
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtPressurePipeNumber.Text))
|
|
{
|
|
pressurePipe.PressurePipeNumber = Convert.ToInt32(this.txtPressurePipeNumber.Text);
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtIssuedReportNumber.Text))
|
|
{
|
|
pressurePipe.IssuedReportNumber = Convert.ToInt32(this.txtIssuedReportNumber.Text);
|
|
}
|
|
if (string.IsNullOrEmpty(this.PressurePipeId))
|
|
{
|
|
if (!string.IsNullOrEmpty(this.hdAttachUrl.Text))
|
|
{
|
|
pressurePipe.PressurePipeId = this.hdAttachUrl.Text;
|
|
}
|
|
else
|
|
{
|
|
pressurePipe.PressurePipeId = SQLHelper.GetNewID(typeof(Model.Comprehensive_PressurePipe));
|
|
this.hdAttachUrl.Text = pressurePipe.PressurePipeId;
|
|
}
|
|
var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == pressurePipe.PressurePipeId);
|
|
if (sour == null || string.IsNullOrEmpty(sour.AttachUrl))
|
|
{
|
|
Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
pressurePipe.CompileMan = this.CurrUser.UserId;
|
|
pressurePipe.Status = BLL.Const.Comprehensive_Compile;
|
|
|
|
BLL.PressurePipeService.AddPressurePipe(pressurePipe);
|
|
}
|
|
else
|
|
{
|
|
pressurePipe.PressurePipeId = this.PressurePipeId;
|
|
var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == this.PressurePipeId);
|
|
if (sour == null || string.IsNullOrEmpty(sour.AttachUrl))
|
|
{
|
|
Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
var model = Funs.DB.Comprehensive_PressurePipe.Where(u => u.PressurePipeId == this.PressurePipeId).FirstOrDefault();
|
|
if (model != null)
|
|
{
|
|
pressurePipe.Status = model.Status;
|
|
}
|
|
|
|
BLL.PressurePipeService.UpdatePressurePipe(pressurePipe);
|
|
}
|
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region 附件上传
|
|
/// <summary>
|
|
/// 附件上传
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAttach_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(this.hdAttachUrl.Text)) //新增记录
|
|
{
|
|
this.hdAttachUrl.Text = SQLHelper.GetNewID(typeof(Model.Comprehensive_PressurePipe));
|
|
}
|
|
Model.Comprehensive_PressurePipe pressurePipe = BLL.PressurePipeService.GetPressurePipeById(this.PressurePipeId);
|
|
if (pressurePipe == null || ((pressurePipe.CompileMan == CurrUser.UserId && pressurePipe.Status == BLL.Const.Comprehensive_Compile) || (pressurePipe.CompileMan == CurrUser.UserId && pressurePipe.Status == BLL.Const.Comprehensive_ReCompile)))
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/CQMS/pressurePipe&menuId={1}", this.hdAttachUrl.Text, BLL.Const.PressurePipeMenuId)));
|
|
}
|
|
else
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/CQMS/pressurePipe&menuId={1}", this.hdAttachUrl.Text, BLL.Const.PressurePipeMenuId)));
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取按钮权限
|
|
/// <summary>
|
|
/// 获取按钮权限
|
|
/// </summary>
|
|
/// <param name="button"></param>
|
|
/// <returns></returns>
|
|
private void GetButtonPower()
|
|
{
|
|
if (Request.Params["value"] == BLL.Const._Null)
|
|
{
|
|
return;
|
|
}
|
|
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.PressurePipeMenuId);
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnSave))
|
|
{
|
|
this.btnSave.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |