示例#1
0
        public void DeleteUser()
        {
            File.textlist file = new PeonLib.File.textlist(definitions.path.UserList);
            if (file.Items.Count > 1)
            {
                forms.UserSelectForm f = new PeonLib.forms.UserSelectForm("Delete User");

                f.LoadFile(file);
                f.ShowDialog();

                if (f.DialogResult == DialogResult.OK)
                {
                    int  n = f.ID;
                    User u = new User(file.Items[n]);
                    User.RemoveFromLastUserProfile(u.NAME, "");
                    if (LoadCurrentUser())
                    {
                        if (mUser.NAME == u.NAME)
                        {
                            NextCurrentUser();
                        }
                    }
                    u.DestroyUser();
                    file.Items.RemoveAt(n);
                    file.WriteList();
                    UpdateAllUserScript();
                }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("You cannot delete the last user");
            }
        }
示例#2
0
文件: User.cs 项目: dgx80/peon
        static public void AddToLastUserProfile(string sUser, string sProfile)
        {
            File.textlist tx    = new PeonLib.File.textlist(definitions.path.LastUsersProfile);
            List <int>    listn = new List <int>();

            tx.Items.Add(sUser);
            tx.Items.Add(sProfile);

            tx.WriteList();
        }
示例#3
0
文件: definitions.cs 项目: dgx80/peon
 public static void SetUserConfig(string path)
 {
     UserConfig = path;
     File.textlist tx = new PeonLib.File.textlist(Root + nameconst.userconfig);
     if (tx.Items.Count < 1)
     {
         tx.Items.Add("");
     }
     tx.Items[0] = path;
     tx.WriteList();
     ReloadUserPath();
 }
示例#4
0
文件: User.cs 项目: dgx80/peon
        public void WriteLastUserProfile()
        {
            File.textlist tx = new PeonLib.File.textlist(definitions.path.LastUsersProfile);
            tx.Items.Clear();
            int n = 0;

            foreach (compte c in mlLastUserProfile)
            {
                if (++n <= 8)
                {
                    tx.Items.Add(c.sUser);
                    tx.Items.Add(c.sProfile);
                }
            }
            tx.WriteList();
        }
示例#5
0
文件: User.cs 项目: dgx80/peon
        public Profile CreateProfile(string name)
        {
            Profile prof = null;

            if (!IsProfileNameExist(name))
            {
                prof = AddProfile(name);
                prof.CreateStandardProfil();
                WriteProfileFile();
                PeonLib.File.textlist tx = new PeonLib.File.textlist(GetProfileListPath());
                tx.Sort();
                tx.WriteList();
                AddToLastUserProfile(NAME, name);
            }
            return(prof);
        }
示例#6
0
文件: User.cs 项目: dgx80/peon
        static public void RemoveFromLastUserProfile(string sUser, string sProfile)
        {
            File.textlist tx    = new PeonLib.File.textlist(definitions.path.LastUsersProfile);
            List <int>    listn = new List <int>();

            for (int i = 0; i < tx.Items.Count; i = i + 2)
            {
                if (tx.Items[i] == sUser && (tx.Items[i + 1] == sProfile || sProfile == ""))
                {
                    listn.Insert(0, i);
                }
            }
            foreach (int n in listn)
            {
                tx.Items.RemoveRange(n, 2);
            }
            tx.WriteList();
        }