示例#1
0
 /// <summary>
 /// 取得用户列表窗体
 /// </summary>
 /// <returns>返回用户列表代码</returns>
 public string List()
 {
     StringBuilder sr = new StringBuilder();
     UserData usrData = new UserData(conn);
     string myUserId = _ac.Get()[0];
     if (SiteFun.IsPost)
     {
         int id = SiteFun.ToInt(SiteFun.Post("id"));
         if (SiteFun.ToInt(SiteFun.Post("delete")) == 0)
         {
             bool locked = SiteFun.ToInt(SiteFun.Post("locked")) == 0 ? false : true;
             usrData.UpdateUserLocked(id, locked);
         }
         else { usrData.DeleteUser(id); }
         sr.Append(AdminUI.SuccessBox(SiteDat.GetLan("MsgUpdateDat")));
     }
     sr.Append(AdminUI.AdminBoxStart(true));
     sr.Append(HtmlUI.TableStart());
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("UserId")));
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("LastIp")));
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("LastDt")));
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Locked")));
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Delete")));
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Operate")));
     sr.Append(HtmlUI.TrFinal());
     //下面三行是分页设置
     int page = SiteFun.ToInt(SiteFun.Query("page"));
     if (page < 1) { page = 1; }
     int pageSize = 20;
     DataList<UserItem> list = usrData.SelectUser(page, pageSize);
     int i = 1;
     foreach (UserItem vItem in list)
     {
         i++;
         sr.Append(HtmlUI.FormStart());
         sr.Append(HtmlUI.TrStart(i % 2 == 0 ? " cRow" : null));
         sr.Append(HtmlUI.CreateTd(HtmlUI.Link(SiteFun.HtmlEncode(vItem.UserID), string.Format("?act=user&amp;mode=post&amp;id={0}", vItem.ID))));
         sr.Append(HtmlUI.CreateTd(SiteFun.HtmlEncode(vItem.LastIP)));
         sr.Append(HtmlUI.CreateTd(vItem.LastTime));
         sr.Append(HtmlUI.CreateTd(myUserId.ToUpper() == vItem.UserID.ToUpper() ? "--" : HtmlUI.CheckBoxInput("locked", 1, vItem.Locked)));
         sr.Append(HtmlUI.CreateTd(myUserId.ToUpper() == vItem.UserID.ToUpper() ? "--" : HtmlUI.CheckBoxInput("delete", 1, false)));
         sr.Append(HtmlUI.CreateTd(HtmlUI.HiddenInput("id", vItem.ID) + HtmlUI.SubmitButton(SiteDat.GetLan("BtnSave"))));
         sr.Append(HtmlUI.TrFinal());
         sr.Append(HtmlUI.FormFinal());
     }
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTd(new SitePages().Make(list.Number, page, pageSize, "?act=user&amp;mode=list&amp;page={0}"), 6, null));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TableFinal());
     sr.Append(AdminUI.AdminBoxFinal());
     return sr.ToString();
 }