コード例 #1
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        PEmpPermissionsData empPermissionsData = new PEmpPermissionsData();
        PEmpPermissionsBB empPermissionsBB = new PEmpPermissionsBB();
        HEemployeeBB eemployeeBB = new HEemployeeBB();
        try
        {
            //删除当前人员所有权限
            empPermissionsBB.DeleteRecordByEmp(this.EmpId, 2);

            //保存权限
            CheckBox checkBox = new CheckBox();
            foreach (DataListItem item in this.DataList1.Items)
            {
                //获取ItemoNo
                Label label = (Label)item.FindControl("itemNo");
                string itemNo = label.Text;
                if (itemNo.IndexOf('-') >= 0)
                {
                    itemNo = itemNo.Substring(itemNo.LastIndexOf('-') + 1);
                }

                foreach (System.Web.UI.Control control in item.Controls)
                {
                    if (control.GetType() == checkBox.GetType())
                    {
                        if (((CheckBox)control).Checked == true && !eemployeeBB.HasPermissions(this.EmpId, itemNo, ((CheckBox)control).ToolTip))
                        {
                            //保存权限
                            empPermissionsData.empId = this.EmpId;
                            empPermissionsData.itemNo = itemNo;
                            empPermissionsData.permissionsTypeNo = ((CheckBox)control).ToolTip;
                            empPermissionsData.isSpecial = false;
                            empPermissionsBB.AddRecord(empPermissionsData);
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            empPermissionsBB.Dispose();
            eemployeeBB.Dispose();
        }

        this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('保存成功!');", true);
    }
コード例 #2
0
    /// <summary>
    /// 根据当前人员绑定DataList
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        PEmpPermissionsBB empPermissionsBB = new PEmpPermissionsBB();
        STreeFunctionBB treeFunctionBB = new STreeFunctionBB();
        HEemployeeBB eemployeeBB = new HEemployeeBB();
        SCommBB commBB = new SCommBB();
        DataSet perDs = new DataSet();
        DataSet ds = new DataSet();
        try
        {
            HtmlInputHidden hid = (HtmlInputHidden)e.Item.FindControl("nodeId");
            string nodeId = hid.Value;

            Label label = (Label)e.Item.FindControl("itemNo");
            string itemNo = label.Text;
            if (itemNo.IndexOf('-') >= 0)
            {
                itemNo = itemNo.Substring(itemNo.LastIndexOf('-') + 1);
            }

            //除了超级管理员,其他用户只能在自己的权限列表范围之内进行分配
            if (this.IsHaveRole(1))
            {
                ds = treeFunctionBB.GetList("nodeId=" + nodeId);
            }
            else
            {
                ds = commBB.Query("select distinct permissionsTypeId,permissionsTypeNo as functionNo,permissionsTypeNm as functionNm from vSTree where empId="
                    + this.currentUser.empId.ToString() + " and nodeId=" + nodeId + " order by permissionsTypeId");
            }

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                DataRow row = ds.Tables[0].Rows[i];

                //添加文本“<TD></TD>"以控制格式
                HtmlGenericControl td = new HtmlGenericControl();
                td.InnerHtml = "</td><td>";
                e.Item.Controls.Add(td);

                CheckBox checkBox = new CheckBox();
                checkBox.ID = "checkBox" + i.ToString();
                checkBox.Text = row["functionNm"].ToString();
                checkBox.ToolTip = row["functionNo"].ToString();

                //给checkBox赋值
                if (eemployeeBB.HasPermissions(this.EmpId, itemNo, row["functionNo"].ToString()))
                {
                    checkBox.Checked = true;
                }
                e.Item.Controls.Add(checkBox);
            }
        }
        finally
        {
            empPermissionsBB.Dispose();
            treeFunctionBB.Dispose();
            eemployeeBB.Dispose();
            commBB.Dispose();
        }
    }
コード例 #3
0
ファイル: bbs.aspx.cs プロジェクト: wanghouxian2015/GMWJGit
    private void ShowIssue()
    {
        bool hasAddPermissions = false;
        bool hasAnswerPermissions = false;
        HEemployeeBB userBB = new HEemployeeBB();
        try
        {
            hasAddPermissions = (userBB.HasPermissions(this.currentUser.empId, this.itemNo, "add"));
            hasAnswerPermissions = (userBB.HasPermissions(this.currentUser.empId, this.itemNo, "answer"));
        }
        finally
        {
            userBB.Dispose();
        }

        DataSet ds = new DataSet();
        LForumQuestionBB forumQuestionBB = new LForumQuestionBB();
        try
        {
            ds = forumQuestionBB.GetList("");
            if (ds.Tables[0].Rows.Count == 0)
            {
                ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
            }
        }
        finally
        {
            forumQuestionBB.Dispose();
        }

        LForumAnswerBB forumAnswerBB = new LForumAnswerBB();
        DataSet dsAnswer = new DataSet();
        dsAnswer = forumAnswerBB.GetVList("");

        try
        {
            DataView dv = new DataView(ds.Tables[0], "", "id desc", DataViewRowState.CurrentRows);
            for (int i = 0; i < dv.Count; i++)
            {
                DataRowView row = dv[i];
                string id = row["id"].ToString();
                string questionTitle = row["questionTitle"].ToString();
                string questionContent = row["questionContent"].ToString();
                string questionEmpNm = row["questionEmpNm"].ToString();
                string questionDt = "";
                if (row["questionDt"] != DBNull.Value)
                {
                    questionDt = Convert.ToDateTime(row["questionDt"]).ToString("yyyy-MM-dd HH:mm");
                }

                sbHtml.Append("                <tr>\r\n");
                sbHtml.Append("                    <td valign=\"top\" style=\"background-color: #E3EEED\">\r\n");
                sbHtml.Append("                        <table width=\"95%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n");
                sbHtml.Append("                            <tr style=\"background-color:#e5e5e5\">\r\n");
                sbHtml.Append("                                <td style=\"height:31px\" colspan=\"4\">\r\n");
                sbHtml.Append("                                    <table width=\"92%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n");
                sbHtml.Append("                                        <tr>\r\n");
                sbHtml.Append("                                            <td style=\"width:40px; height:29px\" align=\"CENTER\">\r\n");
                sbHtml.Append("                                                <font size=\"-1\" color=\"#003300\">" + questionEmpNm + "</font></td>\r\n");
                sbHtml.Append("                                            <td style=\"width:260px; height:29px\">\r\n");
                sbHtml.Append("                                                留言日期:  " + questionDt + "</td>\r\n");
                sbHtml.Append("                                            <td style=\"width:120px; height:29px\">\r\n");
                if (hasAddPermissions)
                {
                    sbHtml.Append("                                                <strong><a href=\"javascript:openQuestion();\"><span style=\"color:#035998\">我要留言</span></a></strong>\r\n");
                }
                else
                {
                    sbHtml.Append("                                                <strong><span style=\"color:#035998\">我要留言</span></strong>\r\n");
                }
                sbHtml.Append("                                                &nbsp;&nbsp;\r\n");
                if (hasAnswerPermissions)
                {
                    sbHtml.Append("                                                <strong><a href=\"javascript:openAnswer('" + id.ToString() + "');\"><span style=\"color:#035998\">回复</span></a></strong>\r\n");
                }
                sbHtml.Append("                                                </td>\r\n");
                sbHtml.Append("                                        </tr>\r\n");
                sbHtml.Append("                                    </table>\r\n");
                sbHtml.Append("                                </td>\r\n");
                sbHtml.Append("                            </tr>\r\n");
                sbHtml.Append("                            <tr style=\"background-color:#E0E9ED\">\r\n");
                sbHtml.Append("                                <td style=\"width:4px; height:2px\">\r\n");
                sbHtml.Append("                                </td>\r\n");
                sbHtml.Append("                                <td style=\"width:78px; height:2px\">\r\n");
                sbHtml.Append("                                </td>\r\n");
                sbHtml.Append("                                <td style=\"width:4px; height:2px\">\r\n");
                sbHtml.Append("                                </td>\r\n");
                sbHtml.Append("                                <td style=\"width:470px; height:2px\">\r\n");
                sbHtml.Append("                                </td>\r\n");
                sbHtml.Append("                            </tr>\r\n");
                sbHtml.Append("                            <tr>\r\n");
                sbHtml.Append("                                <td valign=\"top\" style=\"background-color:#E3EEED\" colspan=\"4\">\r\n");
                sbHtml.Append("                                    <table width=\"98%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"\r\n");
                sbHtml.Append("                                        height=\"114\">\r\n");
                sbHtml.Append("                                        <tr>\r\n");
                sbHtml.Append("                                            <td style=\"width:465px; height:20px\" valign=\"BOTTOM\" align=\"left\">\r\n");
                sbHtml.Append("                                                <font color=\"#FF6666\">主题:</font>" + questionTitle + "</td>\r\n");
                sbHtml.Append("                                        </tr>\r\n");
                sbHtml.Append("                                        <tr>\r\n");
                sbHtml.Append("                                            <td  style=\"height:1px\">\r\n");
                sbHtml.Append("                                            </td>\r\n");
                sbHtml.Append("                                        </tr>\r\n");
                sbHtml.Append("                                        <tr>\r\n");
                sbHtml.Append("                                            <td valign=\"top\"  style=\"width:465px; height:47px\" align=\"left\">\r\n");
                sbHtml.Append("                                                <font color=\"#669900\"><strong>\r\n");
                sbHtml.Append("                                                    <hr size=\"1\" color=\"#FFFFFF\">\r\n");
                sbHtml.Append("                                                    <img src=\"../../../Images/write.gif\" width=\"23\" height=\"24\">:</strong></font>" + questionContent + "</td>\r\n");
                sbHtml.Append("                                        </tr>\r\n");
                sbHtml.Append("                                        <tr>\r\n");
                sbHtml.Append("                                            <td  style=\"height:12px\">\r\n");
                sbHtml.Append("                                            </td>\r\n");
                sbHtml.Append("                                        </tr>\r\n");

                DataView dvAnswer = new DataView(dsAnswer.Tables[0], "questionId='" + row["id"].ToString() + "'", "", DataViewRowState.CurrentRows);

                //显示答复内容
                if (dvAnswer.Count > 0)
                {
                    for (int j = 0; j < dvAnswer.Count; j++)
                    {
                        string answerContent = dvAnswer[j]["answerContent"].ToString();

                        sbHtml.Append("                                        <tr>\r\n");
                        sbHtml.Append("                                            <td style=\"height:36px\" valign=\"top\" bgcolor=\"#f2f2f2\" align=\"left\">\r\n");
                        sbHtml.Append("                                                <span style=\"color:red\"><strong>站方回复: </strong></span>" + answerContent + "\r\n");
                        sbHtml.Append("                                                <hr size=\"1\" color=\"#FFFFFF\">\r\n");
                        sbHtml.Append("                                            </td>\r\n");
                        sbHtml.Append("                                        </tr>\r\n");
                    }
                }
                else
                {
                    sbHtml.Append("                                        <tr>\r\n");
                    sbHtml.Append("                                            <td style=\"height:36px\" valign=\"top\" bgcolor=\"#f2f2f2\" align=\"left\">\r\n");
                    sbHtml.Append("                                                <span style=\"color:red\"><strong>站方回复: </strong></span>暂无回复暂\r\n");
                    sbHtml.Append("                                                <hr size=\"1\" color=\"#FFFFFF\">\r\n");
                    sbHtml.Append("                                            </td>\r\n");
                    sbHtml.Append("                                        </tr>\r\n");
                }

                sbHtml.Append("                                        <tr>\r\n");
                sbHtml.Append("                                            <td style=\"height:5px\">\r\n");
                sbHtml.Append("                                            </td>\r\n");
                sbHtml.Append("                                        </tr>\r\n");
                sbHtml.Append("                                    </table>\r\n");
                sbHtml.Append("                                </td>\r\n");
                sbHtml.Append("                            </tr>\r\n");
                sbHtml.Append("                            <tr style=\"height:2px\" colspan=\"4\">\r\n");
                sbHtml.Append("                                <td>\r\n");
                sbHtml.Append("                                </td>\r\n");
                sbHtml.Append("                            </tr>\r\n");
                sbHtml.Append("                        </table>\r\n");
                sbHtml.Append("                        <table style=\"width:95%; height:2px\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#666666\">\r\n");
                sbHtml.Append("                            <tr>\r\n");
                sbHtml.Append("                                <td>\r\n");
                sbHtml.Append("                                </td>\r\n");
                sbHtml.Append("                            </tr>\r\n");
                sbHtml.Append("                        </table>\r\n");
                sbHtml.Append("                        <table style=\"width:95%; height:5px\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n");
                sbHtml.Append("                            <tr>\r\n");
                sbHtml.Append("                                <td>\r\n");
                sbHtml.Append("                                </td>\r\n");
                sbHtml.Append("                            </tr>\r\n");
                sbHtml.Append("                        </table>\r\n");
                sbHtml.Append("                    </td>\r\n");
                sbHtml.Append("                </tr>\r\n");

            }
        }
        finally
        {
            forumAnswerBB.Dispose();
        }
    }