192 lines
8.5 KiB
C#
192 lines
8.5 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.CQMS.Comprehensive
|
|
{
|
|
public partial class InspectionEquipmentEdit : 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);
|
|
BLL.CNProfessionalService.InitCNProfessionalDownList(this.drpCNProfessionalId, true);
|
|
BLL.InspectionEquipmentService.InitAttributeDropDownList(this.drpAttribute, true);
|
|
|
|
this.InspectionEquipmentId = Request.Params["InspectionEquipmentId"];
|
|
var inspectionEquipment = BLL.InspectionEquipmentService.GetInspectionEquipmentById(this.InspectionEquipmentId);
|
|
if (inspectionEquipment != null)
|
|
{
|
|
this.InspectionEquipmentId = inspectionEquipment.InspectionEquipmentId;
|
|
this.hdAttachUrl.Text = this.InspectionEquipmentId;
|
|
if (!string.IsNullOrEmpty(inspectionEquipment.UnitId))
|
|
{
|
|
this.drpUnitId.SelectedValue = inspectionEquipment.UnitId;
|
|
}
|
|
this.txtInspectionCode.Text = inspectionEquipment.InspectionCode;
|
|
if (!string.IsNullOrEmpty(inspectionEquipment.CNProfessionalId))
|
|
{
|
|
this.drpCNProfessionalId.SelectedValue = inspectionEquipment.CNProfessionalId;
|
|
}
|
|
this.txtInspectionName.Text = inspectionEquipment.InspectionName;
|
|
this.txtSpecifications.Text = inspectionEquipment.Specifications;
|
|
this.txtSupplier.Text = inspectionEquipment.Supplier;
|
|
if (inspectionEquipment.Counts != null)
|
|
{
|
|
this.txtCounts.Text = Convert.ToString(inspectionEquipment.Counts);
|
|
}
|
|
if (inspectionEquipment.SamplingCount != null)
|
|
{
|
|
this.txtSamplingCount.Text = Convert.ToString(inspectionEquipment.SamplingCount);
|
|
}
|
|
if (!string.IsNullOrEmpty(inspectionEquipment.Attribute))
|
|
{
|
|
this.drpAttribute.SelectedValue = inspectionEquipment.Attribute;
|
|
}
|
|
if (!string.IsNullOrEmpty(inspectionEquipment.SamplingResult))
|
|
{
|
|
this.drpSamplingResult.SelectedValue = inspectionEquipment.SamplingResult;
|
|
}
|
|
this.txtInspectionDate.Text = inspectionEquipment.InspectionDate.HasValue ? string.Format("{0:yyyy-MM-dd}", inspectionEquipment.InspectionDate) : "";
|
|
this.txtRemarkCode.Text = inspectionEquipment.RemarkCode;
|
|
this.txtEquipmentNo.Text = inspectionEquipment.EquipmentNO;
|
|
this.txtUsedPlace.Text = inspectionEquipment.UsedPlace;
|
|
}
|
|
else
|
|
{
|
|
this.txtInspectionDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
|
}
|
|
}
|
|
}
|
|
#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_InspectionEquipment newInspectionEquipment = new Model.Comprehensive_InspectionEquipment();
|
|
newInspectionEquipment.ProjectId = this.CurrUser.LoginProjectId;
|
|
newInspectionEquipment.UnitId = this.drpUnitId.SelectedValue;
|
|
newInspectionEquipment.InspectionCode = this.txtInspectionCode.Text.Trim();
|
|
if (this.drpCNProfessionalId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
newInspectionEquipment.CNProfessionalId = this.drpCNProfessionalId.SelectedValue;
|
|
}
|
|
newInspectionEquipment.InspectionName = this.txtInspectionName.Text.Trim();
|
|
newInspectionEquipment.Specifications = this.txtSpecifications.Text.Trim();
|
|
newInspectionEquipment.Supplier = this.txtSupplier.Text.Trim();
|
|
newInspectionEquipment.EquipmentNO = this.txtEquipmentNo.Text.Trim();
|
|
newInspectionEquipment.RemarkCode = this.txtRemarkCode.Text.Trim();
|
|
newInspectionEquipment.Counts = this.txtCounts.Text.Trim();
|
|
newInspectionEquipment.SamplingCount = this.txtSamplingCount.Text.Trim();
|
|
newInspectionEquipment.UsedPlace = this.txtUsedPlace.Text.Trim();
|
|
if (this.drpAttribute.SelectedValue != BLL.Const._Null)
|
|
{
|
|
newInspectionEquipment.Attribute = this.drpAttribute.SelectedValue;
|
|
}
|
|
if (this.drpSamplingResult.SelectedValue != BLL.Const._Null)
|
|
{
|
|
newInspectionEquipment.SamplingResult = this.drpSamplingResult.SelectedValue;
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtInspectionDate.Text))
|
|
{
|
|
newInspectionEquipment.InspectionDate = Convert.ToDateTime(this.txtInspectionDate.Text);
|
|
}
|
|
if (string.IsNullOrEmpty(this.InspectionEquipmentId))
|
|
{
|
|
newInspectionEquipment.CompileMan = this.CurrUser.UserId;
|
|
newInspectionEquipment.CompileDate = DateTime.Now;
|
|
if (!string.IsNullOrEmpty(hdAttachUrl.Text))
|
|
{
|
|
newInspectionEquipment.InspectionEquipmentId = hdAttachUrl.Text;
|
|
}
|
|
else
|
|
{
|
|
newInspectionEquipment.InspectionEquipmentId = SQLHelper.GetNewID(typeof(Model.Comprehensive_InspectionPerson));
|
|
}
|
|
BLL.InspectionEquipmentService.AddInspectionEquipment(newInspectionEquipment);
|
|
}
|
|
else
|
|
{
|
|
newInspectionEquipment.InspectionEquipmentId = this.InspectionEquipmentId;
|
|
BLL.InspectionEquipmentService.UpdateInspectionEquipment(newInspectionEquipment);
|
|
}
|
|
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_InspectionEquipment));
|
|
}
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/CQMS/InspectionEquipment&menuId={1}", this.hdAttachUrl.Text, 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
|
|
}
|
|
} |