285 lines
13 KiB
C#
285 lines
13 KiB
C#
using BLL;
|
|
using BLL.CQMS.Comprehensive;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.ThreeYearAction.FireGasSafety
|
|
{
|
|
public partial class EquipmentAndMaterialInspectionEdit : PageBase
|
|
{
|
|
#region 定义变量
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string InspectionEquipmentId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["InspectionEquipmentId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["InspectionEquipmentId"] = 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.drpUnitId, this.CurrUser.LoginProjectId, true);
|
|
this.drpUnitId.SelectedValue = CurrUser.UnitId;
|
|
BLL.CNProfessionalService.InitCNProfessionalDownList(this.drpCNProfessionalId, true);
|
|
BLL.EquipmentAndMaterialInspectionService.InitAttributeDropDownList(this.drpAttribute, true);
|
|
this.btnSave.Hidden = true;
|
|
this.InspectionEquipmentId = Request.Params["InspectionEquipmentId"];
|
|
var model = BLL.EquipmentAndMaterialInspectionService.GetEquipmentAndMaterialInspectionById(this.InspectionEquipmentId);
|
|
if (model != null)
|
|
{
|
|
this.InspectionEquipmentId = model.InspectionEquipmentId;
|
|
if (!string.IsNullOrEmpty(model.UnitId))
|
|
{
|
|
this.drpUnitId.SelectedValue = model.UnitId;
|
|
}
|
|
this.txtInspectionCode.Text = model.InspectionCode;
|
|
if (!string.IsNullOrEmpty(model.CNProfessionalId))
|
|
{
|
|
this.drpCNProfessionalId.SelectedValue = model.CNProfessionalId;
|
|
}
|
|
this.txtInspectionName.Text = model.InspectionName;
|
|
this.txtSpecifications.Text = model.Specifications;
|
|
this.txtSupplier.Text = model.Supplier;
|
|
if (model.Counts != null)
|
|
{
|
|
this.txtCounts.Text = Convert.ToString(model.Counts);
|
|
}
|
|
if (model.SamplingCount != null)
|
|
{
|
|
this.txtSamplingCount.Text = Convert.ToString(model.SamplingCount);
|
|
}
|
|
if (!string.IsNullOrEmpty(model.Attribute))
|
|
{
|
|
this.drpAttribute.SelectedValue = model.Attribute;
|
|
}
|
|
if (!string.IsNullOrEmpty(model.SamplingResult))
|
|
{
|
|
this.drpSamplingResult.SelectedValue = model.SamplingResult;
|
|
}
|
|
this.txtInspectionDate.Text = model.InspectionDate.HasValue ? string.Format("{0:yyyy-MM-dd}", model.InspectionDate) : "";
|
|
this.txtRemarkCode.Text = model.RemarkCode;
|
|
this.txtEquipmentNo.Text = model.EquipmentNO;
|
|
this.txtUsedPlace.Text = model.UsedPlace;
|
|
var currApprove = InspectionEquipmentApproveService.GetCurrentApprove(model.InspectionEquipmentId);
|
|
if (currApprove != null)
|
|
{ //重新编制 编制人 可以 显示 提交 保存按钮
|
|
if (currApprove.ApproveType == BLL.Const.Comprehensive_ReCompile && model.CompileMan == CurrUser.UserId)
|
|
{
|
|
this.btnSave.Hidden = false;
|
|
}//审核状态 审核人 可以显示 提交 保存按钮
|
|
else if (currApprove.ApproveType == BLL.Const.Comprehensive_Audit && currApprove.ApproveMan == CurrUser.UserId)
|
|
{
|
|
//审核状态不可编辑
|
|
this.txtInspectionName.Readonly = true;
|
|
this.drpUnitId.Readonly = true;
|
|
this.drpCNProfessionalId.Readonly = true;
|
|
this.txtSpecifications.Readonly = true;
|
|
this.txtSupplier.Readonly = true;
|
|
this.drpAttribute.Readonly = true;
|
|
this.drpSamplingResult.Readonly = true;
|
|
this.txtInspectionDate.Readonly = true;
|
|
this.txtRemarkCode.Readonly = true;
|
|
this.txtEquipmentNo.Readonly = true;
|
|
this.txtUsedPlace.Readonly = true;
|
|
this.txtSamplingCount.Readonly = true;
|
|
this.txtCounts.Readonly = true;
|
|
|
|
this.btnSave.Hidden = false;
|
|
}
|
|
}//没有当前审核人,已完成状态 或者 待提交状态
|
|
else
|
|
{
|
|
if (model.Status == BLL.Const.Comprehensive_Compile && model.CompileMan == CurrUser.UserId)
|
|
{
|
|
this.btnSave.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.txtInspectionDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
|
this.btnSave.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 禁止编辑
|
|
/// </summary>
|
|
public void Readonly()
|
|
{
|
|
this.txtInspectionName.Readonly = true;
|
|
this.drpUnitId.Readonly = true;
|
|
this.drpCNProfessionalId.Readonly = true;
|
|
this.txtSpecifications.Readonly = true;
|
|
this.txtSupplier.Readonly = true;
|
|
this.drpAttribute.Readonly = true;
|
|
this.drpSamplingResult.Readonly = true;
|
|
this.txtInspectionDate.Readonly = true;
|
|
this.txtRemarkCode.Readonly = true;
|
|
this.txtEquipmentNo.Readonly = true;
|
|
this.txtUsedPlace.Readonly = true;
|
|
this.txtSamplingCount.Readonly = true;
|
|
this.txtCounts.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 (this.drpUnitId.SelectedValue == BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择报验单位!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
Model.FireGasSafety_EquipmentAndMaterialInspection newmodel = new Model.FireGasSafety_EquipmentAndMaterialInspection();
|
|
newmodel.ProjectId = this.CurrUser.LoginProjectId;
|
|
newmodel.UnitId = this.drpUnitId.SelectedValue;
|
|
newmodel.InspectionCode = this.txtInspectionCode.Text.Trim();
|
|
if (this.drpCNProfessionalId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
newmodel.CNProfessionalId = this.drpCNProfessionalId.SelectedValue;
|
|
}
|
|
newmodel.InspectionName = this.txtInspectionName.Text.Trim();
|
|
newmodel.Specifications = this.txtSpecifications.Text.Trim();
|
|
newmodel.Supplier = this.txtSupplier.Text.Trim();
|
|
newmodel.EquipmentNO = this.txtEquipmentNo.Text.Trim();
|
|
newmodel.RemarkCode = this.txtRemarkCode.Text.Trim();
|
|
newmodel.Counts = this.txtCounts.Text.Trim();
|
|
newmodel.SamplingCount = this.txtSamplingCount.Text.Trim();
|
|
newmodel.UsedPlace = this.txtUsedPlace.Text.Trim();
|
|
|
|
if (this.drpAttribute.SelectedValue != BLL.Const._Null)
|
|
{
|
|
newmodel.Attribute = this.drpAttribute.SelectedValue;
|
|
}
|
|
if (this.drpSamplingResult.SelectedValue != BLL.Const._Null)
|
|
{
|
|
newmodel.SamplingResult = this.drpSamplingResult.SelectedValue;
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtInspectionDate.Text))
|
|
{
|
|
newmodel.InspectionDate = Convert.ToDateTime(this.txtInspectionDate.Text);
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(this.InspectionEquipmentId))
|
|
{
|
|
newmodel.InspectionEquipmentId = SQLHelper.GetNewID(typeof(Model.Comprehensive_InspectionPerson));
|
|
newmodel.CompileMan = this.CurrUser.UserId;
|
|
newmodel.CompileDate = DateTime.Now;
|
|
newmodel.Status = BLL.Const.Comprehensive_Compile;
|
|
var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == newmodel.InspectionEquipmentId);
|
|
if (sour == null || string.IsNullOrEmpty(sour.AttachUrl))
|
|
{
|
|
Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
BLL.EquipmentAndMaterialInspectionService.AddInspectionEquipment(newmodel);
|
|
}
|
|
else
|
|
{
|
|
newmodel.InspectionEquipmentId = this.InspectionEquipmentId;
|
|
var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == this.InspectionEquipmentId);
|
|
if (sour == null || string.IsNullOrEmpty(sour.AttachUrl))
|
|
{
|
|
Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
var oldmodel = Funs.DB.FireGasSafety_EquipmentAndMaterialInspection.Where(u => u.InspectionEquipmentId == this.InspectionEquipmentId).FirstOrDefault();
|
|
if (oldmodel == null)
|
|
{
|
|
newmodel.CompileMan = this.CurrUser.UserId;
|
|
newmodel.CompileDate = DateTime.Now;
|
|
newmodel.Status = BLL.Const.Comprehensive_Compile;
|
|
BLL.EquipmentAndMaterialInspectionService.AddInspectionEquipment(newmodel);
|
|
}
|
|
else
|
|
{
|
|
newmodel.CompileMan = oldmodel.CompileMan;
|
|
newmodel.CompileDate = oldmodel.CompileDate;
|
|
newmodel.Status = oldmodel.Status;
|
|
BLL.EquipmentAndMaterialInspectionService.UpdateInspectionEquipment(newmodel);
|
|
|
|
}
|
|
}
|
|
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.InspectionEquipmentId)) //新增记录
|
|
{
|
|
this.InspectionEquipmentId = SQLHelper.GetNewID(typeof(Model.FireGasSafety_EquipmentAndMaterialInspection));
|
|
}
|
|
var oldmodel = Funs.DB.FireGasSafety_EquipmentAndMaterialInspection.Where(u => u.InspectionEquipmentId == this.InspectionEquipmentId).FirstOrDefault();
|
|
|
|
if (oldmodel == null || ((oldmodel.CompileMan == CurrUser.UserId && oldmodel.Status == BLL.Const.Comprehensive_Compile) || (oldmodel.CompileMan == CurrUser.UserId && oldmodel.Status == BLL.Const.Comprehensive_ReCompile)))
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/EquipmentAndMaterialInspection&menuId={1}", this.InspectionEquipmentId, BLL.Const.InspectionEquipmentMenuId)));
|
|
}
|
|
else
|
|
{
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/EquipmentAndMaterialInspection&menuId={1}", this.InspectionEquipmentId, BLL.Const.InspectionEquipmentMenuId)));
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取按钮权限
|
|
/// <summary>
|
|
/// 获取按钮权限
|
|
/// </summary>
|
|
/// <param name="button"></param>
|
|
/// <returns></returns>
|
|
private void GetButtonPower()
|
|
{
|
|
if (Request.Params["value"] == "0")
|
|
{
|
|
return;
|
|
}
|
|
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.InspectionEquipmentMenuId);
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnSave))
|
|
{
|
|
this.btnSave.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |