/*
         *第一步,则不显示回退
         *最后一步,不允许转交
         *一切以CurStepNum为准,必须维护好这个数值
         */
        protected void Page_Load(object sender, EventArgs e)
        {
            userID = buser.GetLogin().UserID;
            if (function.isAjax())//处理AJAX
            {
                string action = Request.Form["action"];
                string value  = Request.Form["value"];
                string result = "0";
                switch (action)
                {
                case "PostDate":
                    int      id   = Convert.ToInt32(value.Split(':')[0]);
                    DateTime date = Convert.ToDateTime(value.Split(':')[1]);
                    try
                    {
                        progBll.UpdateDate(userID, id, date);
                        result = "1";
                    }
                    catch { }
                    break;
                }
                Response.Write(result); Response.Flush(); Response.End();
            }
            EGV.txtFunc = txtPageFunc;
            appID       = DataConverter.CLng(Request.QueryString["AppID"]);
            DataTable dt = buser.SelByUserID(buser.GetLogin().UserID);

            oaMod = oaBll.SelReturnModel(appID);
            if (!IsPostBack)
            {
                M_UserInfo mu = buser.GetSelect(oaMod.UserID);
                //回退权限
                if (CurrentStep.HToption > 0)
                {
                    if (oaMod.CurStepNum == 0)//如果为起始步,则不管是否有权限都不显示
                    {
                    }
                    else
                    {
                        rollBackSpan.Visible = true;
                        rollBackBtn.Visible  = true;
                        if (CurrentStep.HToption == 1)
                        {
                            rollBackDP.Items.Insert(0, new ListItem("回退至上一步", "-1"));
                        }
                        else if (CurrentStep.HToption == 2)
                        {
                            if (oaMod.IsFreePro)
                            {
                                FreeDPDataBind();
                            }
                            else
                            {
                                DPDataBind();
                            }
                            rollBackDP.Items.Insert(0, new ListItem("回退至上一步", "-1"));
                        }
                    }
                }
                //转交权限
                if (CurrentStep.Qzzjoption > 0)
                {
                    if (stepBll.IsLastStep(CurrentStep))//如果是最后一步,则也不显示
                    {
                    }
                    else
                    {
                        zjSpan.Visible = true;
                        ZJDataBind();
                        zjDP.Items.Insert(0, new ListItem("下一步", "-1"));
                    }
                }
                #region 签章
                DataTable signDT = signBll.SelByUserID(buser.GetLogin().UserID);
                if (oaMod.IsComplete)
                {
                    signTr.Visible = false;
                }
                else if (signDT != null && signDT.Rows.Count > 0)
                {
                    SignRadioBind(signDT);
                }
                else
                {
                    signTrRemind.Visible = true;
                }
                SignImgBind();
                #endregion
                //-------------------经办,审阅等权限
                if (CurrentStep.Auth(M_MisProLevel.AuthEnum.Refer, dt))
                {
                    //拥有经办权限
                    agreeBtn.Visible  = true;
                    rejectBtn.Visible = true;
                }
                else if (CurrentStep.Auth(M_MisProLevel.AuthEnum.CCUser, dt))
                {
                    //拥有抄送权限
                    DisAllAuth();
                    signTr.Visible  = true;
                    ccOPBar.Visible = true;
                    if (progBll.CheckApproval(buser.GetLogin().UserID, CurrentStep.stepNum, oaMod.ID))
                    {
                        signTr.Visible     = false;
                        ccUser_Btn.Visible = false;
                        ccUser_Lab.Visible = true;
                    }
                }
                else if (oaMod.UserID == userID)
                {
                    //发起人查看文件
                    DisAllAuth();
                }
                else
                {
                    function.WriteErrMsg("你当前无权限批复该公文!!");
                }
                //附件删除权限,拥有权限和附件的时候才显示
                if (CurrentStep.PublicAttachOption > 0 && !string.IsNullOrEmpty(oaMod.PublicAttach))
                {
                    //delAttachBtn.Visible = true;
                }
                //显示附件
                if (!string.IsNullOrEmpty(oaMod.PublicAttach))
                {
                    string[] af = oaMod.PublicAttach.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    string   h  = "";
                    for (int i = 0; i < af.Length; i++)
                    {
                        h += "<span class='disupFile'>";
                        h += GroupPic.GetShowExtension(GroupPic.GetExtName(af[i]));
                        string filename = Path.GetExtension(af[i]).ToLower().Replace(".", "");
                        if (filename == "docx" || filename == "doc" || filename == "xls" || filename == "xlsx")
                        {
                            h += af[i].Split('/')[(af[i].Split('/').Length - 1)] + "</a><a class='filea' href='/Common/ShowFlash.aspx?path=" + Server.UrlEncode(af[i]) + "&type=1' target='_blank'>(预览)</a><a href='" + af[i] + "'>(下载)</span>";
                        }
                        else
                        {
                            h += "<a href='" + af[i] + "' title='点击下载'>" + af[i].Split('/')[(af[i].Split('/').Length - 1)] + "</a></span>";
                        }
                    }
                    publicAttachTD.InnerHtml = h;
                }
                //会签
                if (CurrentStep.HQoption > 0)
                {
                    string ids = progBll.SelHQUserID(appID, CurrentStep.stepNum);
                    hqTr.Visible = true;
                    hqL.Text     = buser.GetUserNameByIDS(ids);
                    //如果用户已会签,则不显示拒绝与同意
                    if (ids.Split(',').Select(p => p).Contains(buser.GetLogin().UserID.ToString()))
                    {
                        opBar.Visible = false;
                    }
                    //显示未会签人
                    string[] allUser = CurrentStep.ReferUser.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    string   ids2    = RemoveRepeat(allUser, ids.Split(','));//未会签用户
                    if (string.IsNullOrEmpty(ids2.Replace(",", "")))
                    {
                        unHql.Text = "(会签完成!!!)";
                    }
                    else
                    {
                        unHql.Text = "(尚未会签:" + buser.GetUserNameByIDS(ids2) + ")";
                    }
                }
                if (oaMod.Status == -1 || oaMod.Status == 99 || oaMod.Status == 98)
                {
                    //如果当前流程已完成,或已被拒绝
                    //opBar.Visible = false;
                    //delAttachBtn.Visible = false;
                }
                //该栏与上一栏只能显示一个,逻辑上问题,当前是第三步,但第三步未处理完
                if (oaMod.IsFreePro && oaMod.Status == 98 && freeBll.IsLastStep(oaMod, CurrentStep))//是自由流程,已同意,并且是最后一步时,显示该栏
                {
                    Free_OP_Tr.Visible = true;
                }
                titleL.Text      = oaMod.Title;
                sendManL.Text    = mu.HoneyName;
                stepNameL.Text   = CurrentStep.stepName;
                createTimeL.Text = oaMod.CreateTime.ToString("yyyy年MM月dd日 HH:mm");
                if (oaMod.UserID == userID)//签名占位符同样筛选后输出
                {
                    txt_Content.Text = oaCom.ReplaceHolder(oaMod);
                }
                else
                {
                    txt_Content.Text = oaCom.ReplaceHolder(oaMod, "ApproveID =" + userID);
                }
                DataBind();
            }
        }