using BLL; using System; using System.Linq; namespace FineUIPro.Web.CQMS.Comprehensive { public partial class InspectionTestPlanEdit : PageBase { #region 定义变量 /// /// 主键 /// public string Id { get { return (string)ViewState["Id"]; } set { ViewState["Id"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GetButtonPower(); BLL.CNProfessionalService.InitCNProfessionalDownList(this.drpCNProfessionalId, true); BLL.UnitService.InitUnitDownList(this.drpUnitId, this.CurrUser.LoginProjectId, true); this.Id = Request.Params["Id"]; var model = BLL.InspectionTestPlanService.Detail(this.Id); if (model != null) { this.hdAttachUrl.Text = this.Id; if (!string.IsNullOrEmpty(model.UnitId)) { this.drpUnitId.SelectedValue = model.UnitId; } if (!string.IsNullOrEmpty(model.CNProfessionalId)) { this.drpCNProfessionalId.SelectedValue = model.CNProfessionalId; } this.txtPlanCode.Text = model.PlanCode; this.txtPlanName.Text = model.PlanName; if (model.ApprovalDate != null) { this.txtApprovalDate.Text = string.Format("{0:yyyy-MM-dd}", model.ApprovalDate); } this.txtAuditMan.Text = model.AuditMan; this.txtApprovalMan.Text = model.ApprovalMan; this.txtRemarks.Text = model.Remarks; } else { this.txtApprovalDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); } } } #endregion #region 附件上传 /// /// 附件上传 /// /// /// protected void btnAttach_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.hdAttachUrl.Text)) //新增记录 { this.hdAttachUrl.Text = SQLHelper.GetNewID(typeof(Model.Comprehensive_MajorPlanApproval)); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/CQMS/InsTestPlan&menuId={1}", this.hdAttachUrl.Text, BLL.Const.Inspection_Test_PlanMenuId))); } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (drpUnitId.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择报批单位!", MessageBoxIcon.Warning); return; } if (drpCNProfessionalId.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择专业!", MessageBoxIcon.Warning); return; } var majorPlanApproval = new Model.Inspection_Test_Plan(); majorPlanApproval.ProjectId = this.CurrUser.LoginProjectId; if (this.drpUnitId.SelectedValue != BLL.Const._Null) { majorPlanApproval.UnitId = this.drpUnitId.SelectedValue; } if (this.drpCNProfessionalId.SelectedValue != BLL.Const._Null) { majorPlanApproval.CNProfessionalId = this.drpCNProfessionalId.SelectedValue; } majorPlanApproval.PlanCode = this.txtPlanCode.Text.Trim(); majorPlanApproval.PlanName = this.txtPlanName.Text.Trim(); if (!string.IsNullOrEmpty(this.txtApprovalDate.Text)) { majorPlanApproval.ApprovalDate = Convert.ToDateTime(this.txtApprovalDate.Text); } majorPlanApproval.AuditMan = this.txtAuditMan.Text.Trim(); majorPlanApproval.ApprovalMan = this.txtApprovalMan.Text.Trim(); majorPlanApproval.Remarks = this.txtRemarks.Text.Trim(); if (string.IsNullOrEmpty(this.Id)) { if (!string.IsNullOrEmpty(this.hdAttachUrl.Text)) { majorPlanApproval.Id = this.hdAttachUrl.Text; } else { majorPlanApproval.Id = SQLHelper.GetNewID(typeof(Model.Comprehensive_MajorPlanApproval)); this.hdAttachUrl.Text = majorPlanApproval.Id; } majorPlanApproval.CreateMan = this.CurrUser.UserId; majorPlanApproval.CreateDate = DateTime.Now; BLL.InspectionTestPlanService.Insert(majorPlanApproval); } else { majorPlanApproval.Id = this.Id; BLL.InspectionTestPlanService.Update(majorPlanApproval); } ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private void GetButtonPower() { if (Request.Params["value"] == BLL.Const._Null) { return; } var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.Inspection_Test_PlanMenuId); if (buttonList.Count() > 0) { if (buttonList.Contains(BLL.Const.BtnSave)) { this.btnSave.Hidden = false; } } } #endregion } }