private void ok_Click(object sender, EventArgs e) { bool flag = false, flag_same = false; Account acc = new Account(); if (text_username.Text.Trim() != "") { flag_same = acc.hasSameUsername(text_username.Text); if (!flag_same) { flag = acc.updateUserByUsername(text_username.Text, text_realname.Text, globleUserRight, globleUsername); if (flag) { MessageBox.Show("数据保存成功!"); this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("数据保存失败,请检查网络连接!"); } } else { MessageBox.Show("已经存在同名用户!", "禁止操作", MessageBoxButtons.OK, MessageBoxIcon.Warning); text_username.Focus(); return; } } else { MessageBox.Show("用户名不能为空!", "禁止操作", MessageBoxButtons.OK, MessageBoxIcon.Warning); text_username.Focus(); return; } }