Example #1
0
        /// <summary>
        /// 页面初始化
        /// </summary>
        /// <param name="id">操作ID</param>
        protected void PageInit(string id)
        {
            if (!string.IsNullOrEmpty(id))
            {
                //把操作id方法在隐藏域之中供修改的时候用
                hidId.Value = id;
                //实例化工作汇报实体
                MWorkReport modelMWorkReport = new MWorkReport();
                //实例化业务层
                BIndividual bllBIndividual = new BIndividual();
                modelMWorkReport = bllBIndividual.GetWorkReport(Utils.GetInt(id));
                if (modelMWorkReport != null)
                {
                    //汇报标题
                    this.txtTitle.Text = modelMWorkReport.Title;
                    //汇报人
                    this.txtUserName.Text = modelMWorkReport.OperatorName;
                    //部门id
                    this.SelectSection1.SectionID = modelMWorkReport.DepartmentId.ToString();
                    //部门名称
                    this.SelectSection1.SectionName = modelMWorkReport.Department;
                    //汇报时间
                    this.txtDateTime.Text = modelMWorkReport.IssueTime.ToShortDateString();
                    //汇报内容
                    this.txtContent.Text = modelMWorkReport.Content;
                    //附件
                    if (!string.IsNullOrEmpty(modelMWorkReport.UploadUrl))
                    {
                        string[] strlist = modelMWorkReport.UploadUrl.Split('|');
                        if (strlist.Length == 2)
                        {
                            this.lclFile.Text = "<span class='upload_filename'>&nbsp;<a href='" + strlist[1] + "' title='" + strlist[0] + "' target='_blank'>查看附件</a><a href='javascript:void(0);' onclick='WorkReportEditPage.RemoveVisaFile(this);return false;'> <img style='vertical-align:middle' src='/images/cha.gif'></a><input type='hidden' name='hideOtherFile' value='" + modelMWorkReport.UploadUrl + "'></span>";
                        }
                    }

                    #region 审核人and ID
                    //审核人
                    string approver = "";
                    //审核人id
                    string approverid = "";
                    if (modelMWorkReport.list != null && modelMWorkReport.list.Count > 0)
                    {
                        foreach (MWorkReportCheck item in modelMWorkReport.list)
                        {
                            if (item != null)
                            {
                                //审核人
                                approver += item.Approver.Trim() + ",";
                                //审核人ID
                                approverid += item.ApproverId.Trim() + ",";
                            }
                        }
                    }
                    this.SelectSection2.SellsName = approver.TrimEnd(',');
                    this.SelectSection2.SellsID   = approverid.TrimEnd(',');
                    #endregion

                    //是否可以操作该数据
                    if (!SiteUserInfo.IsHandleElse)
                    {
                        bool IsShenpi = false;
                        if (modelMWorkReport.list != null && modelMWorkReport.list.Count > 0)
                        {
                            foreach (MWorkReportCheck model in modelMWorkReport.list)
                            {
                                if (model != null)
                                {
                                    if (model.Status == Status.已结束 || model.Status == Status.已审批)
                                    {
                                        IsShenpi = true;
                                    }
                                }
                            }
                            if (IsShenpi || modelMWorkReport.Status == Status.已审批 || (modelMWorkReport.OperatorId != null && modelMWorkReport.OperatorId != SiteUserInfo.UserId))
                            {
                                this.phdSave.Visible = false;
                            }
                        }
                    }
                }
            }
            else
            {
                txtDateTime.Text = DateTime.Now.ToShortDateString();
            }
        }
        /// <summary>
        /// 页面初始化
        /// </summary>
        /// <param name="id">操作ID</param>
        protected void PageInit(string id)
        {
            if (!string.IsNullOrEmpty(id))
            {
                BIndividual bllBIndividual = new BIndividual();
                //根据id获取汇报实体
                MWorkReport modelMWorkReport = bllBIndividual.GetWorkReport(Utils.GetInt(id));
                if (modelMWorkReport != null)
                {
                    //汇报标题
                    lblTitle.Text = modelMWorkReport.Title;
                    //汇报人
                    lblOperatorName.Text = modelMWorkReport.OperatorName;
                    //汇报部门
                    if (modelMWorkReport.DepartmentId > 0)
                    {
                        lblDepartment.Text = GetDepartmentById(modelMWorkReport.DepartmentId, SiteUserInfo.CompanyId);
                    }
                    //汇报时间
                    lblIssueTime.Text = modelMWorkReport.IssueTime.ToShortDateString();
                    if (modelMWorkReport.list != null && modelMWorkReport.list.Count > 0)
                    {
                        StringBuilder strList = new StringBuilder();
                        #region
                        strList.Append("<table width=\"99%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">");
                        strList.Append("<tr style=\"background: url(../images/y-formykinfo.gif) repeat-x center top;\">");
                        strList.Append("<td align=\"center\" bgcolor=\"#B7E0F3\" class=\"alertboxTableT\">审批人</td>");
                        strList.Append("<td height=\"23\" align=\"center\" bgcolor=\"#B7E0F3\" class=\"alertboxTableT\">审批时间</td>");
                        strList.Append("<td align=\"center\" bgcolor=\"#B7E0F3\" class=\"alertboxTableT\">审批状态</td>");
                        strList.Append("<td align=\"center\" bgcolor=\"#B7E0F3\" class=\"alertboxTableT\">审批意见</td>");
                        strList.Append(" <td align=\"center\" bgcolor=\"#B7E0F3\" class=\"alertboxTableT\">操作</td>");
                        strList.Append("</tr>");
                        #endregion
                        foreach (MWorkReportCheck item in modelMWorkReport.list)
                        {
                            if (item != null)
                            {
                                //如果审批人为自己(操作审批)
                                //if (item.Approver.Trim() == SiteUserInfo.Username && item.Status == Status.审批中)

                                if (item.ApproverId.Trim() == SiteUserInfo.UserId && item.Status == Status.审批中)
                                {
                                    #region 自己审核人
                                    strList.Append("<tr>");
                                    strList.AppendFormat("<td align=\"center\" bgcolor=\"#FFFFFF\"><strong class=\"fontred\">{0}</strong></td>", item.Approver);
                                    strList.Append("<td height=\"28\" align=\"center\" bgcolor=\"#FFFFFF\"><input name=\"txtApproveTime\"  onfocus=\"WdatePicker()\" type=\"text\" class=\"formsize120\" id=\"txtApproveTime\" size=\"30\"/></td>");
                                    strList.AppendFormat("<td align=\"center\" bgcolor=\"#FFFFFF\"><input name=\"chbStatus\" type=\"checkbox\" id=\"chbStatus\" checked=\"checked\" value=\"{0}\"/></td>", item.Id);
                                    strList.Append("<td align=\"center\" bgcolor=\"#FFFFFF\"><input name=\"txtComment\" type=\"text\" class=\"formsize180\" id=\"txtComment\" size=\"30\"/></td>");
                                    strList.Append("<td align=\"center\" bgcolor=\"#FFFFFF\"><a href=\"javascript:void(0)\" onclick=\"WorkReportApproval.IntiData()\">审批</a></td>");
                                    strList.Append("</tr>");
                                    #endregion
                                }
                                else//查看别人的审批状态
                                {
                                    #region 其他审核人
                                    string strimage      = string.Empty;
                                    string strimagetitle = string.Empty;
                                    strList.Append("<tr>");
                                    strList.AppendFormat("<td align=\"center\" bgcolor=\"#FFFFFF\"><strong>{0}</strong></td>", item.Approver);
                                    strList.AppendFormat("<td height=\"28\" align=\"center\" bgcolor=\"#FFFFFF\">{0}</td>", Utils.GetDateTime(item.ApproveTime.ToString()).ToShortDateString() == "1900-1-1" ? "" : item.ApproveTime.ToString());
                                    strList.Append("<td align=\"center\" bgcolor=\"#FFFFFF\">");
                                    #region 根据状态获取相应的图片
                                    switch (item.Status)
                                    {
                                    case Status.审批中:
                                        strimage      = "y-delupdateicon.gif";
                                        strimagetitle = "审批中";
                                        break;

                                    case Status.已结束:
                                        strimage      = "y-cuohao.gif";
                                        strimagetitle = "已结束";
                                        break;

                                    case Status.已审批:
                                        strimage      = "y-duihao.gif";
                                        strimagetitle = "已审批";
                                        break;
                                    }
                                    strList.AppendFormat("<img src=\"/images/{0}\" width=\"13\" title=\"{1}\" height=\"9\" />", strimage, strimagetitle);
                                    #endregion
                                    strList.Append("</td>");
                                    strList.AppendFormat("<td align=\"center\" bgcolor=\"#FFFFFF\">{0}</td>", item.Comment);
                                    strList.AppendFormat("<td align=\"center\" bgcolor=\"#FFFFFF\">{0}</td>", "");
                                    strList.Append("</tr>");
                                    #endregion
                                }
                            }
                        }
                        strList.Append("</table>");
                        litList.Text = strList.ToString();
                    }

                    //是否可以操作该数据
                    if (!SiteUserInfo.IsHandleElse)
                    {
                        if (modelMWorkReport.OperatorId != null && modelMWorkReport.OperatorId != SiteUserInfo.UserId)
                        {
                            this.phdPrint.Visible = false;
                        }
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// 保存按钮点击事件执行方法
        /// </summary>
        protected void PageSave()
        {
            //ajax返回信息
            string resultmsg = "";
            //实例化工作汇报实体
            MWorkReport modelMWorkReport = new MWorkReport();
            //实例化业务层
            BIndividual bllBIndividual = new BIndividual();

            if (!string.IsNullOrEmpty(hidId.Value))
            {
                //修改状态根据id获取汇报实体
                modelMWorkReport = bllBIndividual.GetWorkReport(Utils.GetInt(hidId.Value));
            }
            else
            {
                //汇报时间
                modelMWorkReport.IssueTime = DateTime.Now;
            }
            #region 显性属性(页面直接和用户交互)
            //标题
            string title = this.txtTitle.Text;
            //汇报人
            string userName = this.txtUserName.Text;
            //部门id
            string departID = Utils.GetFormValue(this.SelectSection1.SelectIDClient);
            //部门名称
            string departName = Utils.GetFormValue(this.SelectSection1.SelectNameClient);
            //汇报时间
            string dateTime = this.txtDateTime.Text;
            //汇报内容
            string content = this.txtContent.Text;
            //附件上传
            string strUploadUrl = Utils.GetFormValue(this.UploadControl1.ClientHideID);

            #region  审批人列表
            //审批人
            string   strapprover = Utils.GetFormValue(this.SelectSection2.SellsNameClient);
            string[] approver    = { "" };
            if (strapprover != null && strapprover.Contains(','))
            {
                approver = strapprover.Split(',');
            }
            else
            {
                approver[0] = strapprover;
            }
            //审核人id
            string   strapproverId = Utils.GetFormValue(this.SelectSection2.SellsIDClient);
            string[] approverId    = { "" };
            if (strapproverId != null && strapproverId.Contains(','))
            {
                approverId = strapproverId.Split(',');
            }
            else
            {
                approverId[0] = strapproverId;
            }
            List <MWorkReportCheck> list = new List <MWorkReportCheck>();
            if (approver.Length > 0)
            {
                for (int i = 0; i < approver.Length; i++)
                {
                    MWorkReportCheck modelMWorkReportCheck = new MWorkReportCheck();
                    if (approverId[i] != null)
                    {
                        //审批人id
                        modelMWorkReportCheck.ApproverId = approverId[i];
                    }
                    //审批人姓名
                    modelMWorkReportCheck.Approver = approver[i];
                    list.Add(modelMWorkReportCheck);
                }
            }
            #endregion

            #region 实体赋值
            modelMWorkReport.Title        = title;
            modelMWorkReport.OperatorName = userName;
            modelMWorkReport.OperatorId   = "";
            modelMWorkReport.DepartmentId = Utils.GetInt(departID);
            modelMWorkReport.Department   = departName;
            modelMWorkReport.IssueTime    = Utils.GetDateTime(dateTime);
            modelMWorkReport.Content      = content;
            modelMWorkReport.Status       = Status.审批中;
            #region 附件
            if (!string.IsNullOrEmpty(strUploadUrl))
            {
                //验证数据
                string[] strUploadList = strUploadUrl.Split('|');
                if (strUploadList.Length == 2)
                {
                    strUploadUrl = strUploadList[0] + "|" + strUploadList[1];
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(Utils.GetFormValue("hideOtherFile")))
                {
                    strUploadUrl = Utils.GetFormValue("hideOtherFile");
                }
            }
            modelMWorkReport.UploadUrl = strUploadUrl;
            #endregion
            modelMWorkReport.list = list;
            #endregion
            #endregion

            #region 隐性属性(id之类)
            //系统公司id
            string companyid = SiteUserInfo.CompanyId;
            modelMWorkReport.CompanyId = companyid;
            //汇报人编号
            modelMWorkReport.OperatorId = SiteUserInfo.UserId;
            #endregion
            //操作之后返回结果
            bool result = false;
            if (!string.IsNullOrEmpty(hidId.Value))
            {
                result = bllBIndividual.UpdWorkReport(modelMWorkReport);
                if (result)
                {
                    resultmsg = UtilsCommons.AjaxReturnJson("true", "修改成功");
                }
                else
                {
                    resultmsg = UtilsCommons.AjaxReturnJson("false", "修改失败,检查选用的数据是否正确");
                }
            }
            else
            {
                result = bllBIndividual.AddWorkReport(modelMWorkReport);
                if (result)
                {
                    resultmsg = UtilsCommons.AjaxReturnJson("true", "添加成功");
                }
                else
                {
                    resultmsg = UtilsCommons.AjaxReturnJson("false", "添加失败,检查选用的数据是否正确");
                }
            }
            Response.Clear();
            Response.Write(resultmsg);
            Response.End();
        }