Esempio n. 1
0
 /// <summary>
 /// 验证管理员信息
 /// </summary>
 /// <param name="userID">用户名</param>
 /// <param name="pwd">密码</param>
 /// <param name="selAll">是否筛选所有用户</param>
 public UserItem CheckUser(string userID, string pwd, bool selAll)
 {
     UserItem item = new UserItem();
     _DbParameter[] pars ={
                             new _DbParameter().Set("@UID", DbType.String, userID),
                             new _DbParameter().Set("@PWD", DbType.String, pwd)
                         };
     int rows = 0;
     using (IDataReader reader = conn.ExecutePager("[User]", "[ID], [UserID], [Password], [Name], [LastIP], [LastTime], [Locked]", "[UserID] = @UID AND [Password] = @PWD" + (selAll ? string.Empty : " AND [Locked] = 0"), null, null, 1, 1, pars, ref rows))
     {
         while (reader.Read())
         {
             item.ID = reader.GetInt32(0);
             item.UserID = reader.GetString(1);
             item.Password = reader.GetString(2);
             item.Name = reader.GetString(3);
             item.LastIP = reader.GetString(4);
             item.LastTime = reader.GetDateTime(5);
             item.Locked = reader.GetInt32(6) == 0 ? false : true;
         }
     }
     return item;
 }
Esempio n. 2
0
 /// <summary>
 /// 获取管理员信息
 /// </summary>
 /// <param name="id">用户编号</param>
 public UserItem GetUser(int id)
 {
     UserItem item = new UserItem();
     int rows = 0;
     using (IDataReader reader = conn.ExecutePager("[User]", "[ID], [UserID], [Password], [Name], [LastIP], [LastTime], [Locked]", string.Format("[ID] = {0}", id), null, null, 1, 1, ref rows))
     {
         while (reader.Read())
         {
             item.ID = reader.GetInt32(0);
             item.UserID = reader.GetString(1);
             item.Password = reader.GetString(2);
             item.Name = reader.GetString(3);
             item.LastIP = reader.GetString(4);
             item.LastTime = reader.GetDateTime(5);
             item.Locked = reader.GetInt32(6) == 0 ? false : true;
         }
     }
     return item;
 }
Esempio n. 3
0
 /// <summary>
 /// 修改一个管理员用户
 /// </summary>
 /// <param name="value">用户资料</param>
 public int UpdateUser(UserItem value)
 {
     _DbParameter[] pars ={
                             new _DbParameter().Set("@UID", DbType.String, value.UserID),
                             new _DbParameter().Set("@PWD", DbType.String, value.Password),
                             new _DbParameter().Set("@Name", DbType.String, value.Name),
                             new _DbParameter().Set("@LastIP", DbType.String, value.LastIP),
                             new _DbParameter().Set("@LastTime", DbType.String, value.LastTime.ToString("yyyy-MM-dd HH:mm:ss")),
                             new _DbParameter().Set("@Locked", DbType.Int32, value.Locked ? 1 : 0),
                             new _DbParameter().Set("@ID", DbType.Int32, value.ID)
                         };
     conn.ExecuteNonQuery("UPDATE [User] SET [UserID] = @UID, [Password] = @PWD, [Name] = @Name, [LastIP] = @LastIP, [LastTime] = @LastTime, [Locked] = @Locked WHERE [ID] = @ID", pars);
     return value.ID;
 }
Esempio n. 4
0
 /// <summary>
 /// 选择用户
 /// </summary>
 /// <param name="intCurPage">当前页码</param>
 /// <param name="btePerPage">每页数量</param>
 /// <returns>返回页面数据列表</returns>
 public DataList<UserItem> SelectUser(int intCurPage, int btePerPage)
 {
     DataList<UserItem> list = new DataList<UserItem>();
     int rows = 0;
     using (IDataReader reader = conn.ExecutePager("[User]", "[ID], [UserID], [Password], [Name], [LastIP], [LastTime], [Locked]", null, null, null, intCurPage, btePerPage, ref rows))
     {
         while (reader.Read())
         {
             UserItem item = new UserItem();
             item.ID = reader.GetInt32(0);
             item.UserID = reader.GetString(1);
             item.Password = reader.GetString(2);
             item.Name = reader.GetString(3);
             item.LastIP = reader.GetString(4);
             item.LastTime = reader.GetDateTime(5);
             item.Locked = reader.GetInt32(6) == 0 ? false : true;
             list.Add(item);
         }
     }
     list.Number = rows;
     return list;
 }
Esempio n. 5
0
 /// <summary>
 /// 添加一个管理员用户
 /// </summary>
 /// <param name="value">用户资料</param>
 public int InsertUser(UserItem value)
 {
     int id = 0;
     _DbParameter[] pars ={
                             new _DbParameter().Set("@UID", DbType.String, value.UserID),
                             new _DbParameter().Set("@PWD", DbType.String, value.Password),
                             new _DbParameter().Set("@Name", DbType.String, value.Name),
                             new _DbParameter().Set("@LastIP", DbType.String, value.LastIP),
                             new _DbParameter().Set("@LastTime", DbType.String, value.LastTime.ToString("yyyy-MM-dd HH:mm:ss")),
                             new _DbParameter().Set("@Locked", DbType.Int32, value.Locked ? 1 : 0)
                         };
     conn.ExecuteNonQuery("INSERT INTO [User] ([UserID], [Password], [Name], [LastIP], [LastTime], [Locked]) VALUES (@UID, @PWD, @Name, @LastIP, @LastTime, @Locked)", pars);
     id = Convert.ToInt32(conn.ExecuteNewField("[User]", null, null));
     return id;
 }
Esempio n. 6
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();
 }