Example #1
0
    private void DataPlay()
    {
        this.ddlisenabled.Items.Insert(0, "是");
        this.ddlisenabled.Items.Insert(1, "否");

        //加载权限和全权用户
        HyoaClass.Hyoa_role Hyoa_role = new HyoaClass.Hyoa_role();
        DataTable dtrole = Hyoa_role.Getroles();
        if (dtrole.Rows.Count > 0)
        {
            this.ddlrole.DataSource = dtrole;
            this.ddlrole.DataTextField = "hy_rolename";
            this.ddlrole.DataValueField = "hy_roleid";
            this.ddlrole.DataBind();
            this.ddlrole.Items.Insert(0, new ListItem("--请选择--", ""));
            this.ddlrole.SelectedIndex = 0;

            this.ddlqqrole.DataSource = dtrole;
            this.ddlqqrole.DataTextField = "hy_rolename";
            this.ddlqqrole.DataValueField = "hy_roleid";
            this.ddlqqrole.DataBind();
            this.ddlqqrole.Items.Insert(0, new ListItem("--请选择--", ""));
            this.ddlqqrole.SelectedIndex = 0;
        }

        if (this.Request.QueryString["op"] != null)
        {
            this.txtop.Value = this.Request.QueryString["op"].ToString();           //新增还是修改

            //判断当前用户是否有保存的权限
            HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global();
            if (Hyoa_global.isHaveRole("Role9999", this.Session["hyuid"].ToString()))
            {
                this.btn_submit.Visible = true; //保存
            }
            else
            {
                this.btn_submit.Visible = false; //保存
            }

            //旧文档
            if (this.Request.QueryString["op"] == "modify")
            {
                if (this.Request.QueryString["id"] != null)
                {
                    //根据roleid得到信息
                    this.txtmudelid.Value = this.Request.QueryString["id"].ToString();
                    HyoaClass.Hyoa_mudel Hyoa_mudel = new HyoaClass.Hyoa_mudel();
                    DataTable dt = Hyoa_mudel.Getmudel(this.txtmudelid.Value);
                    if (dt.Rows.Count > 0)
                    {
                        this.txtid.Text = this.Request.QueryString["id"].ToString();
                        this.txtname.Value = dt.Rows[0]["hy_mudelname"].ToString();
                        this.txtsort.Value = dt.Rows[0]["hy_sort"].ToString();

                        if (dt.Rows[0]["hy_isenabled"].ToString() == "是")
                            this.ddlisenabled.SelectedIndex = 0;
                        else
                            this.ddlisenabled.SelectedIndex = 1;

                        this.ddlrole.SelectedValue = dt.Rows[0]["hy_roleid"].ToString();
                        this.ddlqqrole.SelectedValue = dt.Rows[0]["hy_qqroleid"].ToString();
                    }
                    dt.Clear();
                    this.txtid.Enabled = false;
                }
            }
            else
            {
                this.txtid.Text = "Mudel";
                //自动获取最大排序号,然后+2
                HyoaClass.Hyoa_mudel Hyoa_mudel = new HyoaClass.Hyoa_mudel();
                DataTable dt_maxsort = Hyoa_mudel.GetMaxmudelsort();
                if (dt_maxsort.Rows.Count > 0)
                    txtsort.Value = (int.Parse(dt_maxsort.Rows[0]["hy_sort"].ToString()) + 2).ToString();
                else
                    txtsort.Value = "1";
            }
        }
    }