Пример #1
0
 /// <summary>
 /// 提交用户数据
 /// </summary>
 /// <returns>返回发布用户代码</returns>
 public string Post()
 {
     StringBuilder sr = new StringBuilder();
     int id = SiteFun.ToInt(SiteFun.Query("id"));
     UserData usrData = new UserData(conn);
     //取得默认值
     UserItem old = usrData.GetUser(id);
     if (SiteFun.IsPost)
     {
         UserItem postVal = new UserItem();
         string myUserId = _ac.Get()[0];
         postVal.ID = id;
         postVal.UserID = SiteFun.Post("userId");
         postVal.Name = SiteFun.Post("name");
         postVal.Password = SiteFun.Encryption(SiteFun.Post("password"));
         postVal.LastIP = old.LastIP;
         postVal.LastTime = old.LastTime;
         if (myUserId.ToUpper() != old.UserID.ToUpper()) { postVal.Locked = SiteFun.ToInt(SiteFun.Post("locked")) == 0 ? false : true; }
         if (string.IsNullOrEmpty(postVal.Password)) { postVal.Password = old.Password; }
         if (string.IsNullOrEmpty(postVal.UserID) || usrData.ExistsUserID(postVal.UserID, postVal.ID)) { sr.Append(AdminUI.ErrorBox(SiteDat.GetLan("MsgNoUserIdOrExists"))); }
         else
         {
             if (string.IsNullOrEmpty(postVal.Password)) { sr.Append(AdminUI.ErrorBox(SiteDat.GetLan("MsgNoPwd"))); }
             else
             {
                 if (string.IsNullOrEmpty(postVal.Name)) { sr.Append(AdminUI.ErrorBox(SiteDat.GetLan("MsgNoNickName"))); }
                 else
                 {
                     if (postVal.ID == 0) { usrData.InsertUser(postVal); sr.Append(AdminUI.SuccessBox(SiteDat.GetLan("MsgInsertDat"), "?act=user&mode=list")); }
                     else { usrData.UpdateUser(postVal); sr.Append(AdminUI.SuccessBox(SiteDat.GetLan("MsgUpdateDat"), "?act=user&mode=list")); }
                 }
             }
         }
         old = postVal;
     }
     sr.Append(AdminUI.AdminBoxStart(true));
     sr.Append(HtmlUI.FormStart());
     sr.Append(HtmlUI.TableStart("onCenter"));
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("UserId")) + HtmlUI.CreateTd(HtmlUI.Input("userId", 15, null, SiteFun.HtmlEncode(old.UserID))));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Pwd")) + HtmlUI.CreateTd(HtmlUI.PasswordInput("password", 30, null, null)));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("NickName")) + HtmlUI.CreateTd(HtmlUI.Input("name", 15, null, old.Name)));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("LastIp")) + HtmlUI.CreateTd(SiteFun.HtmlEncode(old.LastIP)));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("LastDt")) + HtmlUI.CreateTd(old.LastTime));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Virtue")) + HtmlUI.CreateTd(HtmlUI.CheckBoxInput(SiteDat.GetLan("Locked"), "locked", 1, old.Locked)));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh() + HtmlUI.CreateTd(HtmlUI.SubmitButton() + HtmlUI.ResetButton()));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TableFinal());
     sr.Append(HtmlUI.FormFinal());
     sr.Append(AdminUI.AdminBoxFinal());
     return sr.ToString();
 }