private void editProfileButton_Click(object sender, EventArgs e) { UserDialogue dialogue = new UserDialogue(4, memberName); if (dialogue.ShowDialog(this) == DialogResult.OK) { memberName = dialogue.RoleName; MessageBox.Show("修改成功!", "提示"); } }
private void addUserButton_Click(object sender, EventArgs e) { UserDialogue dialogue = new UserDialogue(0, ""); addUserButton.Enabled = false; if (dialogue.ShowDialog(this) == DialogResult.OK && userInfo != null) { StreamReader sr = null; StreamWriter sw = null; string content = null; string line; try { sr = File.OpenText("users.dat"); while ((line = sr.ReadLine()) != null) { content += (line + "\r\n"); if (line.StartsWith("#")) { foreach (string role in userInfo["role"].Split(new char[] { ',' })) { if (line.Split(new char[] { '#' })[1].Equals(role)) { content += (userInfo["userName"] + "|" + userInfo["password"] + "|" + userInfo["realName"] + "|" + userInfo["birthday"] + "|" + userInfo["joinDate"] + "|" + userInfo["techLevel"] + "\r\n"); break; } } } } } catch (FileNotFoundException fe) { Console.WriteLine(fe.StackTrace); MessageBox.Show("读取用户数据信息失败!", "提示"); return; } finally { if (sr != null) sr.Close(); } try { sw = File.CreateText("users.dat"); sw.Write(content); } catch (FileNotFoundException fe) { Console.WriteLine(fe.StackTrace); MessageBox.Show("写入用户数据信息失败!", "提示"); return; } finally { if (sw != null) sw.Close(); } RefreshTreeView(); } addUserButton.Enabled = true; }
private void EditProfileButton_Click(object sender, EventArgs e) { UserDialogue dialogue = new UserDialogue(1, ""); if (dialogue.ShowDialog(this) == DialogResult.OK) { MessageBox.Show("修改成功!", "提示"); } }