Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 清除缓存;
        this.Response.Expires         = -1;
        this.Response.ExpiresAbsolute = DateTime.Now.AddMonths(-1);
        this.Response.CacheControl    = "no-cache";
        #endregion 清除缓存

        try
        {
            #region 判断权限
            string pk = this.Request.QueryString["PK"];
            if (pk == null)
            {
                pk = this.Request.QueryString[this.CurrEn.PK];
            }

            UAC uac = this.CurrEn.HisUAC;
            if (uac.IsView == false)
            {
                throw new Exception("@对不起,您没有查看的权限!");
            }

            this.IsReadonly = !uac.IsUpdate;  //是否更有修改的权限.
            if (this.Request.QueryString["IsReadonly"] == "1" ||
                this.Request.QueryString["Readonly"] == "1")
            {
                this.IsReadonly = true;
            }
            #endregion

            this.ToolBar1.InitFuncEn(uac, this.CurrEn);

            this.UCEn1.IsReadonly = this.IsReadonly;
            this.UCEn1.IsShowDtl  = true;
            this.UCEn1.HisEn      = this.CurrEn;

            EnCfg ec = new EnCfg();
            ec.No = this.EnName;
            int i = ec.RetrieveFromDBSources();

            if (i >= 1)
            {
                this.UCEn1.BindV2(this.CurrEn, this.CurrEn.ToString(), this.IsReadonly, true);
            }
            else
            {
                this.UCEn1.Bind(this.CurrEn, this.CurrEn.ToString(), this.IsReadonly, true);
            }
        }
        catch (Exception ex)
        {
            this.Response.Write(ex.Message);
            Entity en = ClassFactory.GetEns(this.EnsName).GetNewEntity;
            en.CheckPhysicsTable();
            return;
        }

        this.Page.Title = this.CurrEn.EnDesc;

        #region 设置事件
        if (this.Btn_DelFile != null)
        {
            this.Btn_DelFile.Click += new ImageClickEventHandler(Btn_DelFile_Click);
        }

        if (this.ToolBar1.IsExit(NamesOfBtn.New))
        {
            this.ToolBar1.GetLinkBtnByID(NamesOfBtn.New).Click += new System.EventHandler(this.ToolBar1_ButtonClick);
        }

        if (this.ToolBar1.IsExit(NamesOfBtn.Save))
        {
            this.ToolBar1.GetLinkBtnByID(NamesOfBtn.Save).Click += new System.EventHandler(this.ToolBar1_ButtonClick);
        }

        if (this.ToolBar1.IsExit(NamesOfBtn.SaveAndClose))
        {
            this.ToolBar1.GetLinkBtnByID(NamesOfBtn.SaveAndClose).Click += new System.EventHandler(this.ToolBar1_ButtonClick);
        }

        if (this.ToolBar1.IsExit(NamesOfBtn.SaveAndNew))
        {
            this.ToolBar1.GetLinkBtnByID(NamesOfBtn.SaveAndNew).Click += new System.EventHandler(this.ToolBar1_ButtonClick);
        }

        if (this.ToolBar1.IsExit(NamesOfBtn.Delete))
        {
            this.ToolBar1.GetLinkBtnByID(NamesOfBtn.Delete).Click += new System.EventHandler(this.ToolBar1_ButtonClick);
        }

        AttrFiles fls = this.CurrEn.EnMap.HisAttrFiles;
        foreach (AttrFile fl in fls)
        {
            if (this.UCEn1.IsExit("Btn_DelFile" + fl.FileNo))
            {
                this.UCEn1.GetImageButtonByID("Btn_DelFile" + fl.FileNo).Click += new ImageClickEventHandler(Btn_DelFile_X_Click);
            }
        }
        #endregion 设置事件

        //此处增加一个判断删除成功的逻辑,办法不太好,暂用,added by liuxc,2015-11-10
        if (!IsPostBack)
        {
            if (Request["DeleteOver"] == "1")
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "showmsg", "alert('删除成功!');", true);
            }
        }
    }