Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(QueryString["id"]))
                {
                    btnSave.Enabled = false;
                }
                else
                {
                    userId = QueryString["id"];
                    if (!Page.IsPostBack)
                    {
                        DataFrom dataFrom = new DataFrom();
                        string   userName = dataFrom.GetScalar("select name from s_user where id='" + userId + "'");
                        literalUsers.Text = String.Format("{0}[{1}]", userName, userId);

                        string sql = @"SELECT s_role.ID,s_role.NAME,case when s_roleuser.RoleID is null then 0 else 1 end as issel 
 FROM s_role
 left join  s_roleuser on s_roleuser.RoleID=s_role.ID and s_roleuser.uid='" + userId + @"'
 WHERE s_role.Iflag>0 and '" + CurrentUser.DepID + "' like s_role.depid+'%'";

                        dataFrom.BindListCtrl(sql, chkListRoles, false);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("初始化失败", ex);
                RedirectError("初始化失败,请稍候再试。原因:" + ex.Message);
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            name = QueryString[Constants.MYQUERY_NAME];
            if (!Page.IsPostBack)
            {
                WebHelper.SetControlAttributes(btnSubmit, new TextBoxVal[] { txtTitle, HtmlUrl, AspxUrl });
                if (CurrentUser.IsAdmin())//仅管理员才能操作
                {
                    HtmlUrl.Enabled = true;
                    DepId.Enabled   = true;
                    divUp.Visible   = true;
                    btnUp.Visible   = true;
                    WebHelper.SetAttributesOfFile(fileHtml);
                    WebHelper.SetAttributesOfFile(fileXml);
                }
                else
                {
                    HtmlUrl.Enabled = false;
                    DepId.Enabled   = false;
                    divUp.Visible   = false;
                    btnUp.Visible   = false;
                }
                try
                {
                    DataFrom dataFrom = new DataFrom();
                    dataFrom.BindListCtrl(String.Format("select id,case when parentid='0' then '' else '  ' end+name from f_city where iflag=1 and (parentid='{0}' or id='{0}') order by parentid,id", CurrentUser.DepID), DepId, CurrentUser.IsAdmin());
                    if (!String.IsNullOrEmpty(name))
                    {
                        HtmlUrl.Text = name;
                        DataTable dt = dataFrom.GetDataTable("select Title,AspxUrl,depid from HtmlTemplate where HtmlUrl='" + name + "'");
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            txtTitle.Text = dt.Rows[0]["Title"].ToString();
                            AspxUrl.Text  = dt.Rows[0]["AspxUrl"].ToString();
                            WebHelper.SetSelCtrl(dt.Rows[0]["depid"].ToString(), DepId);
                        }
                        Content.Text = TxtHelper.GetString(WebHelper.GetMyXmlPath() + "\\tpl\\" + name + Constants.HTML_SUFFIX);

                        XmlDocument doc = FromXml.GetXml(name);
                        if (doc == null)
                        {
                            txtXml.Text = XmlHelper.GetXmlDocument(true).DocumentElement.OuterXml;
                        }
                        else
                        {
                            txtXml.Text = XmlHelper.GetFormatXml(doc);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error("初始化失败", ex);
                    RedirectError("初始化失败,请稍候再试。原因:" + ex.Message);
                    return;
                }
            }
        }