private void btnAdd_Click(object sender, EventArgs e) { bool login = true; lblUserName.Visible = lblPassword.Visible = false; if (string.IsNullOrEmpty(txtUserName.Text)) { lblUserName.Visible = true; login = false; } if (string.IsNullOrEmpty(txtPassword.Text)) { lblPassword.Visible = true; login = false; } if (login) { JsMd5 m = new JsMd5(); var s = Tool.service.AddUser(txtUserName.Text, m.md5(txtPassword.Text).ToString()); Model.Result res = JsonConvert.DeserializeObject <Model.Result>(s); if (res.Succeed) { MessageBox.Show(res.Message); } else { BindData(); } } }
private void Login() { bool login = true; label3.Visible = lblUserName.Visible = lblPassword.Visible = false; if (string.IsNullOrEmpty(txtUserName.Text)) { lblUserName.Visible = true; login = false; } if (string.IsNullOrEmpty(txtPassword.Text)) { lblPassword.Visible = true; login = false; } if (login) { JsMd5 m = new JsMd5(); var result = Tool.service.UserLogin(txtUserName.Text, m.md5(txtPassword.Text).ToString()); if (string.IsNullOrEmpty(result)) { label3.Visible = true; } else { Model.User user = JsonConvert.DeserializeObject <Model.User>(result); UserInfo.SetUserInfo(user.UserName, user.IsAdmin == "是"); this.DialogResult = DialogResult.OK; this.Close(); } } }