private void btnAdd_Click(object sender, EventArgs e) { var dr = MessageBox.Show(ConstantInfo.CONFIRM_ADD_NEW, "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr != DialogResult.Yes) { return; } try { // Validate if (Validate()) { // Check the existing username if (!UserFactory.CheckIsUserExisting(txtUserName.Text.Trim())) { // Insert to database var userInfo = new tblUser(); BindControlToData(ref userInfo); // Insert to database UserFactory.Insert(userInfo); _parrent.BindData(UserFactory.SelectAllUser()); //TODO: Need to check number of rows are effected MessageBox.Show(ConstantInfo.MESSAGE_INSERT_SUCESSFULLY); //get userInfor after insert tblUser user = UserFactory.getUserByUserName(txtUserName.Text.Trim()); _userID = user.UserID; //show tab listGroup and ListPermissior tabControl1.TabPages.Add(_tabGroup); tabControl1.TabPages.Add(_tabPermission); btnAdd.Enabled = false; EnableTab(_tabUser, false); btnClose.Enabled = true; //this.Close(); } else { MessageBox.Show(ConstantInfo.MESSAGE_USERNAME_EXISTING); } } } catch (Exception ex) { logger.Error(ex.ToString()); if (GlobalInfo.IsDebug) { MessageBox.Show(ex.ToString()); } } }