/// <summary> /// 插入用户 /// </summary> /// <param name="userName"></param> /// <param name="passWord"></param> /// <returns></returns> public static bool InsertUser(LengNinUser user, All.Class.DataReadAndWrite conn) { string tmpUse = ""; for (int i = 0; i < user.Use.Length; i++) { tmpUse = string.Format("{0},'{1}'", tmpUse, user.Use[i]); } return(conn.Write(string.Format("insert into SetUsersLengNin values('{0}','{1}','{2:yyyy-MM-dd HH:mm:ss}'{3})", user.Text, user.Word, DateTime.Now, tmpUse)) >= 1); }
/// <summary> /// 获取用户名设置 /// </summary> /// <returns></returns> public static List <LengNinUser> GetAllUser(All.Class.DataReadAndWrite conn) { List <LengNinUser> user = new List <LengNinUser>(); LengNinUser tmpUserSet; using (DataTable dt = conn.Read("select * from SetUsersLengNin order by InTime")) { if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { tmpUserSet = new LengNinUser(); tmpUserSet.Text = All.Class.Num.ToString(dt.Rows[i]["UserName"]); tmpUserSet.Word = All.Class.Num.ToString(dt.Rows[i]["UserPassword"]); for (int j = 0; j < cMain.AllLengNinQiCount; j++) { tmpUserSet.Use[j] = All.Class.Num.ToBool(dt.Rows[i][string.Format("use{0}", j)]); } user.Add(tmpUserSet); } } } return(user); }
/// <summary> /// 更新用户 /// </summary> /// <param name="user"></param> /// <returns></returns> public static bool UpdateUser(LengNinUser user, All.Class.DataReadAndWrite conn) { DeleteUser(user.Text, conn); return(InsertUser(user, conn)); }