private void btSaveUser_Click(object sender, EventArgs e) { if (!xValidateInputUser()) { return; } using (var objDb = new clsDBUltity()) { if (_mode == emModeForm.CreateNewUser) { if (!objDb.InsertUser(txtUserName.Text, txtPassword.Text, txtFullName.Text, txtEmail.Text, cboRole.SelectedIndex)) { ShowMsg(MessageBoxIcon.Error, MSG_INSERT_ERR); return; } } else { if (!objDb.UpdateUser(_userid, txtUserName.Text, txtPassword.Text, txtFullName.Text, txtEmail.Text, cboRole.SelectedIndex)) { ShowMsg(MessageBoxIcon.Error, MSG_UPDATE_ERR); return; } } xModeUser(emModeForm.CreateNewUser); grvUser.DataSource = objDb.GetMUser(); grvUser.ClearSelection(); } }