예제 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         int userId = GetUserId;
         if (userId != 0)
         {
             DataSet dsActionStruct = TablesBLL.GetTableFields("Action", null);        //操作表结构数据集
             ViewState["dsActionStruct"] = dsActionStruct;
             DataSet dsMyActionStruct = TablesBLL.GetTableFields("User_Action", null); //用户-操作表结构数据集
             ViewState["dsMyActionStruct"] = dsMyActionStruct;
             DataSet dsMetaData = MetaDataDAL.GetGroupMetaData();
             ViewState["dsMetaData"] = dsMetaData;
             DataSet myActions = ActionDAL.GetUserActionByUserID(userId);
             ViewState["myActions"] = myActions;
             DataSet sysActions = ActionDAL.GetAllActions();
             ViewState["sysActions"] = sysActions;
             DataTable dt = GetBindData(userId, myActions, sysActions, dsMetaData, dsActionStruct, dsMyActionStruct);
             BindGV(gvActions, dt);
         }
         else
         {
             lbErr.Text = "请先登录";
         }
         //btnClose.Click += btnClose_Click;
     }
     btnSave.Click += btnSave_Click;
 }
        /// <summary>
        /// 绑定表单中的常量数据
        /// </summary>
        private void BindFormData()
        {
            DataSet   dsMetaData = MetaDataDAL.GetGroupMetaData();
            DataTable dtStatus   = MetaDataBLL.GetMetaDataByGroup("ProjectTask_Status", dsMetaData);

            dtStatus.TableName = "状态";
            DDLBind(ddlStatus, dtStatus, "0", "ItemID", "Title");
        }
예제 #3
0
        /// <summary>
        /// 根据计划ID获取计划的类型:(操作)单操作计划、(计划)多操作计划、(已删除)已删除计划、(计划操作)计划的操作
        /// </summary>
        /// <param name="planId">计划ID</param>
        /// <param name="dtPlans">计划表</param>
        /// <param name="dtActions">操作表</param>
        /// <returns></returns>
        private string GetPlanTypeByPlanID(long planId, DataTable dtPlans, DataTable dtActions)
        {
            string planType = "";

            DataRow[] drsPlan = dtPlans.Select("PlanID=" + planId);
            if (drsPlan.Length <= 0)
            {
                planType = "已删除";
            }
            else
            {
                DataRow drPlan   = drsPlan[0];
                long    actionId = SystemDataExtension.GetInt32(drPlan, "ActionID"); //计划对应的操作ID
                long    parentId = SystemDataExtension.GetInt32(drPlan, "ParentID"); //计划的父级ID,若为0,则为计划,否则为多操作计划关联的某一个操作
                if (parentId == 0)
                {
                    DataRow[] drsActions = dtActions.Select("ActionID=" + actionId);
                    if (drsActions.Length > 0)
                    {
                        DataRow drAction = drsActions[0];
                        int     typeId   = SystemDataExtension.GetInt16(drAction, "ItemTypeID");
                        if (typeId != 0)
                        {
                            //获取元数据集合
                            DataSet dsMetaData = MetaDataDAL.GetGroupMetaData();
                            ViewState["dsMetaData"] = dsMetaData;
                            DataTable dtActionType  = MetaDataBLL.GetMetaDataByGroup("Action", dsMetaData);
                            DataRow[] drsActionType = dtActionType.Select("ItemID=" + typeId);
                            if (drsActionType.Length > 0)
                            {
                                planType = SystemDataExtension.GetString(drsActionType[0], "Title");
                            }
                        }
                    }
                }
                else
                {
                    planType = "计划操作";
                }
            }
            return(planType);
        }
        /// <summary>
        /// 任务列表行绑定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvTasks_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (((Label)e.Row.FindControl("lbStatus")) != null)
            {
                DataSet   dsMetaData = MetaDataDAL.GetGroupMetaData();
                DataTable dtStatus   = MetaDataBLL.GetMetaDataByGroup("ProjectTask_Status", dsMetaData);
                dtStatus.TableName = "任务状态表";
                Label  lbStatus  = (Label)e.Row.FindControl("lbStatus");
                string initValue = ((HiddenField)e.Row.FindControl("hdfStatus")).Value;
                if (string.IsNullOrEmpty(initValue))
                {
                    initValue = "0";
                }
                DataRow[] drs = dtStatus.Select("ItemID=" + int.Parse(initValue));
                if (drs.Length > 0)
                {
                    DataRow dr = drs[0];
                    lbStatus.Text = SystemDataExtension.GetString(dr, "Title");
                }
            }
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (((Label)e.Row.FindControl("lbPercent")) != null)
                {
                    Label  lbPercent = (Label)e.Row.FindControl("lbPercent");
                    string value     = lbPercent.Text;
                    if (!value.Contains("%"))
                    {
                        lbPercent.Text = value + "%";
                    }
                    value = value.TrimEnd('%');
                    int percent = 0;
                    if (!string.IsNullOrEmpty(value))
                    {
                        percent = int.TryParse(value, out percent) ? percent : 0;;
                    }
                    string htmlColor = GetColorByPercent(percent);
                    lbPercent.ForeColor = ColorTranslator.FromHtml(htmlColor);
                    //e.Row.Style.Add(HtmlTextWriterStyle.BackgroundColor, GetColorByPercent(percent));
                }
                if (((Label)e.Row.FindControl("lbTitle")) != null)//标题标签
                {
                    Label  lbTitle     = (Label)e.Row.FindControl("lbTitle");
                    string tTtitle     = lbTitle.Text;
                    int    titleLength = webObj.TitleLength;
                    int    blankCount  = tTtitle.Length - tTtitle.TrimStart().Length;
                    if (tTtitle.Length > titleLength + blankCount)                             //标题内容大于20个
                    {
                        lbTitle.Text = tTtitle.Substring(0, titleLength + blankCount) + "..."; //截取20个显示,其他用“...”号代替
                    }
                    lbTitle.ToolTip = tTtitle;                                                 //鼠标放上去显示全部信息
                }
                if (((Label)e.Row.FindControl("lbDescription")) != null)                       //标题标签
                {
                    Label  lbDescription = (Label)e.Row.FindControl("lbDescription");
                    string tDesc         = lbDescription.Text;
                    int    titleLength   = webObj.TitleLength;
                    if (tDesc.Length > titleLength * 2)                                   //标题内容大于20个
                    {
                        lbDescription.Text = tDesc.Substring(0, titleLength * 2) + "..."; //截取2*webObj.TitleLength个字符,其他用“...”号代替
                    }
                    lbDescription.ToolTip = tDesc;                                        //鼠标放上去显示全部信息
                }

                string    taskId = DataBinder.Eval(e.Row.DataItem, "ID").ToString();
                DataTable dtDoc  = TaskDAL.GetDocsByTaskID(long.Parse(taskId)).Tables[0];
                if (dtDoc.Rows.Count > 0)
                {
                    DataRow   dr      = dtDoc.Rows[0];
                    string    docLink = SystemDataExtension.GetString(dr, "DocLink");
                    HyperLink lnkDoc  = (HyperLink)e.Row.FindControl("lnkDoc");
                    if (!string.IsNullOrEmpty(docLink))
                    {
                        lnkDoc.NavigateUrl = docLink;
                        lnkDoc.Target      = "_blank";
                        lnkDoc.ToolTip     = "点击查看并编辑项目/任务文档";
                        lnkDoc.ImageUrl    = "../../../../_layouts/15/VSProject/images/Docs.png";
                        lnkDoc.ImageHeight = 20;
                    }
                    else
                    {
                        lnkDoc.Enabled = false;
                    }
                }

                e.Row.Attributes.Add("onmouseover", "if(this!=prevselitem){this.style.backgroundColor='#E6F2FB'}"); //当鼠标停留时更改背景色
                e.Row.Attributes.Add("onmouseout", "if(this!=prevselitem){this.style.backgroundColor='#ffffff'}");  //当鼠标移开时还原背景色
                e.Row.Attributes.Add("onclick", e.Row.ClientID + ".checked=true;selectx(this)");
            }
            int userId = VSDLL.Common.Users.UserID;

            if (userId == 0)//未登录,隐藏任务管理按钮列
            {
                e.Row.Cells[8].Visible = false;
            }
            else
            {
                e.Row.Cells[8].Visible = true;
                //HiddenField hdfParentID = (HiddenField)e.Row.FindControl("hdfParentID");

                //if (string.IsNullOrEmpty(hdfParentID.Value)|| hdfParentID.Value=="0")
                //{
                //    LinkButton lnkDel = (LinkButton)e.Row.FindControl("lnkDel");
                //    lnkDel.OnClientClick = "return confirm('这是一个项目,删除后将同时删除项目下级的所有的任务,确定仍要删除吗?')";
                //}
            }
        }