private void btnAdd_Click(object sender, EventArgs e) { //..........................................Getting Data from UI......................................... u.first_name = txtFirstName.Text; u.last_name = txtLastName.Text; u.email = txtEmail.Text; u.username = txtUsername.Text; u.password = txtPassword.Text; u.contact = txtContact.Text; u.address = txtAddress.Text; u.user_type = cnbUserType.Text; u.added_date = DateTime.Now; u.gender = cnbGender.Text; //Getting User Name From Logged In User string LoggedInUser = frmLogin.LoggedIn; userBLL usr = daL.GetIDFromUserName(LoggedInUser); u.added_by = usr.id; //Inserting Data into Database bool success = daL.Insert(u); //if data is successfully inserted value of success will be true if (success == true) { MessageBox.Show("User succesfully created."); clear(); } else { MessageBox.Show("Failed to create user"); } //Refreshing Data Grid View DataTable dt = daL.Select(); dgvUsers.DataSource = dt; }