277 lines
13 KiB
C#
277 lines
13 KiB
C#
|
using BLL;
|
|||
|
using BLL.CQMS.Comprehensive;
|
|||
|
using System;
|
|||
|
using System.Linq;
|
|||
|
|
|||
|
namespace FineUIPro.Web.CQMS.Comprehensive
|
|||
|
{
|
|||
|
public partial class InspectionMachineEdit : PageBase
|
|||
|
{
|
|||
|
#region 定义变量
|
|||
|
/// <summary>
|
|||
|
/// 主键
|
|||
|
/// </summary>
|
|||
|
public string InspectionMachineId
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["InspectionMachineId"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["InspectionMachineId"] = 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);
|
|||
|
|
|||
|
if (CurrUser.UnitId == null || CurrUser.UserId == Const.sysglyId|| CommonService.GetProjectUnitType(this.CurrUser.LoginProjectId, this.CurrUser.UnitId) == BLL.Const.ProjectUnitType_1)
|
|||
|
{
|
|||
|
this.drpUnitId.Enabled = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
drpUnitId.SelectedValue = CurrUser.UnitId;
|
|||
|
this.drpUnitId.Enabled = false;
|
|||
|
}
|
|||
|
BLL.CNProfessionalService.InitCNProfessionalDownList(this.drpCNProfessionalId, true);
|
|||
|
|
|||
|
this.InspectionMachineId = Request.Params["InspectionMachineId"];
|
|||
|
Model.Comprehensive_InspectionMachine inspectionMachine = BLL.InspectionMachineService.GetInspectionMachineById(this.InspectionMachineId);
|
|||
|
if (inspectionMachine != null)
|
|||
|
{
|
|||
|
this.InspectionMachineId = inspectionMachine.InspectionMachineId;
|
|||
|
this.hdAttachUrl.Text = this.InspectionMachineId;
|
|||
|
if (!string.IsNullOrEmpty(inspectionMachine.UnitId))
|
|||
|
{
|
|||
|
this.drpUnitId.SelectedValue = inspectionMachine.UnitId;
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(inspectionMachine.CNProfessionalId))
|
|||
|
{
|
|||
|
this.drpCNProfessionalId.SelectedValue = inspectionMachine.CNProfessionalId;
|
|||
|
}
|
|||
|
this.rblInspectionType.SelectedValue = inspectionMachine.InspectionType;
|
|||
|
this.txtInspectionMachineCode.Text = inspectionMachine.InspectionMachineCode;
|
|||
|
this.txtInspectionMachineName.Text = inspectionMachine.InspectionMachineName;
|
|||
|
this.txtSpecificationModel.Text = inspectionMachine.SpecificationModel;
|
|||
|
if (inspectionMachine.NextTestDate != null)
|
|||
|
{
|
|||
|
this.txtNextTestDate.Text = string.Format("{0:yyyy-MM-dd}", inspectionMachine.NextTestDate);
|
|||
|
}
|
|||
|
this.txtTestCycle.Text = inspectionMachine.TestCycle;
|
|||
|
this.rblIsVerification.SelectedValue = inspectionMachine.IsVerification.HasValue && inspectionMachine.IsVerification == true ? "true" : "false";
|
|||
|
if (inspectionMachine.InspectionDate != null)
|
|||
|
{
|
|||
|
this.txtInspectionDate.Text = string.Format("{0:yyyy-MM-dd}", inspectionMachine.InspectionDate);
|
|||
|
}
|
|||
|
this.rblIsOnSite.SelectedValue = inspectionMachine.IsOnSite.HasValue && inspectionMachine.IsOnSite == true ? "true" : "false";
|
|||
|
this.rblIsCheckOK.SelectedValue = inspectionMachine.IsCheckOK.HasValue && inspectionMachine.IsCheckOK == true ? "true" : "false";
|
|||
|
if (inspectionMachine.LeaveDate.HasValue)
|
|||
|
{
|
|||
|
this.txtLeaveDate.Text = string.Format("{0:yyyy-MM-dd}", inspectionMachine.LeaveDate);
|
|||
|
}
|
|||
|
if (inspectionMachine.UnitsCount.HasValue)
|
|||
|
{
|
|||
|
this.txtUnitsCount.Text = inspectionMachine.UnitsCount.ToString();
|
|||
|
}
|
|||
|
var currApprove = InspectionMachineApproveService.GetCurrentApprove(inspectionMachine.InspectionMachineId);
|
|||
|
if (currApprove != null)
|
|||
|
{ //重新编制 编制人 可以 显示 提交 保存按钮
|
|||
|
|
|||
|
if (currApprove.ApproveType == BLL.Const.Comprehensive_ReCompile && inspectionMachine.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 (inspectionMachine.Status == BLL.Const.Comprehensive_Compile && inspectionMachine.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.txtInspectionDate.Readonly = true;
|
|||
|
this.drpUnitId.Readonly = true;
|
|||
|
this.drpCNProfessionalId.Readonly = true;
|
|||
|
this.txtInspectionMachineCode.Readonly = true;
|
|||
|
this.txtInspectionMachineName.Readonly = true;
|
|||
|
this.txtLeaveDate.Readonly = true;
|
|||
|
this.txtNextTestDate.Readonly = true;
|
|||
|
this.txtInspectionDate.Readonly = true;
|
|||
|
this.txtSpecificationModel.Readonly = true;
|
|||
|
this.txtTestCycle.Readonly = true;
|
|||
|
this.txtUnitsCount.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.Comprehensive_InspectionMachine inspectionMachone = new Model.Comprehensive_InspectionMachine();
|
|||
|
inspectionMachone.ProjectId = this.CurrUser.LoginProjectId;
|
|||
|
if (this.drpUnitId.SelectedValue != BLL.Const._Null)
|
|||
|
{
|
|||
|
inspectionMachone.UnitId = this.drpUnitId.SelectedValue;
|
|||
|
}
|
|||
|
if (this.drpCNProfessionalId.SelectedValue != BLL.Const._Null)
|
|||
|
{
|
|||
|
inspectionMachone.CNProfessionalId = this.drpCNProfessionalId.SelectedValue;
|
|||
|
}
|
|||
|
inspectionMachone.InspectionType = this.rblInspectionType.SelectedValue;
|
|||
|
inspectionMachone.InspectionMachineCode = this.txtInspectionMachineCode.Text.Trim();
|
|||
|
inspectionMachone.InspectionMachineName = this.txtInspectionMachineName.Text.Trim();
|
|||
|
inspectionMachone.SpecificationModel = this.txtSpecificationModel.Text.Trim();
|
|||
|
inspectionMachone.NextTestDate = Funs.GetNewDateTime(this.txtNextTestDate.Text);
|
|||
|
inspectionMachone.TestCycle = this.txtTestCycle.Text.Trim();
|
|||
|
inspectionMachone.IsVerification = this.rblIsVerification.SelectedValue == "true" ? true : false;
|
|||
|
inspectionMachone.InspectionDate = Funs.GetNewDateTime(this.txtInspectionDate.Text);
|
|||
|
inspectionMachone.IsOnSite = this.rblIsOnSite.SelectedValue == "true" ? true : false;
|
|||
|
inspectionMachone.IsCheckOK = this.rblIsCheckOK.SelectedValue == "true" ? true : false;
|
|||
|
inspectionMachone.LeaveDate = Funs.GetNewDateTime(this.txtLeaveDate.Text);
|
|||
|
inspectionMachone.UnitsCount = Funs.GetNewInt(this.txtUnitsCount.Text.Trim());
|
|||
|
if (string.IsNullOrEmpty(this.InspectionMachineId))
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(this.hdAttachUrl.Text))
|
|||
|
{
|
|||
|
inspectionMachone.InspectionMachineId = this.hdAttachUrl.Text;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
inspectionMachone.InspectionMachineId = SQLHelper.GetNewID(typeof(Model.Comprehensive_InspectionMachine));
|
|||
|
this.hdAttachUrl.Text = inspectionMachone.InspectionMachineId;
|
|||
|
}
|
|||
|
|
|||
|
var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == inspectionMachone.InspectionMachineId);
|
|||
|
if (sour == null || string.IsNullOrEmpty(sour.AttachUrl))
|
|||
|
{
|
|||
|
Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
inspectionMachone.CompileMan = this.CurrUser.UserId;
|
|||
|
inspectionMachone.CompileDate = DateTime.Now;
|
|||
|
inspectionMachone.Status = BLL.Const.Comprehensive_Compile;
|
|||
|
BLL.InspectionMachineService.AddInspectionMachine(inspectionMachone);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
inspectionMachone.InspectionMachineId = this.InspectionMachineId;
|
|||
|
var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == this.InspectionMachineId);
|
|||
|
if (sour == null || string.IsNullOrEmpty(sour.AttachUrl))
|
|||
|
{
|
|||
|
Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
var model = Funs.DB.Comprehensive_InspectionMachine.Where(u => u.InspectionMachineId == this.InspectionMachineId).FirstOrDefault();
|
|||
|
if (model != null)
|
|||
|
{
|
|||
|
|
|||
|
inspectionMachone.Status = model.Status;
|
|||
|
}
|
|||
|
|
|||
|
BLL.InspectionMachineService.UpdateInspectionMachine(inspectionMachone);
|
|||
|
}
|
|||
|
//Project_CQMSDataService.StatisticalData(this.CurrUser.LoginProjectId, Project_CQMSDataService.CQMSDateType.MeasuringInstruments);
|
|||
|
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_InspectionMachine));
|
|||
|
}
|
|||
|
Model.Comprehensive_InspectionMachine inspectionMachine = BLL.InspectionMachineService.GetInspectionMachineById(this.InspectionMachineId);
|
|||
|
if (inspectionMachine == null || ((inspectionMachine.CompileMan == CurrUser.UserId && inspectionMachine.Status == BLL.Const.Comprehensive_Compile) || (inspectionMachine.CompileMan == CurrUser.UserId && inspectionMachine.Status == BLL.Const.Comprehensive_ReCompile)))
|
|||
|
{
|
|||
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/CQMS/inspectionMachone&menuId={1}", this.hdAttachUrl.Text, BLL.Const.InspectionMachineMenuId)));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/CQMS/inspectionMachone&menuId={1}", this.hdAttachUrl.Text, BLL.Const.InspectionMachineMenuId)));
|
|||
|
}
|
|||
|
}
|
|||
|
#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.InspectionMachineMenuId);
|
|||
|
if (buttonList.Count > 0)
|
|||
|
{
|
|||
|
if (buttonList.Contains(BLL.Const.BtnSave))
|
|||
|
{
|
|||
|
this.btnSave.Hidden = false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|