Once the user begins the add new process by clicking on the + on the navigation bar How do I stop it and send them back to the record they were viewing? In this case when the user tries to login and they are already logged in I want to give them a message they are already logged in and return then to where they were before the add new started.
// ************************************************* // Determine if the user is already logged in // ************************************************* using (SqlConnection conn = new SqlConnection(Properties.Settings.Default.LazerMaintenance_Conn)) { try { string query = "SELECT TOP 1 * FROM Shift_Log WHERE Operator = '" + UserID + "' ORDER BY Login_Date DESC;"; SqlDataAdapter da = new SqlDataAdapter(query, conn); DataTable dt = new DataTable(); da.Fill(dt); //if (dt.Rows.Count >= 1) if ( (DateTime)dt.Rows[0]["Logout_Date"] == null || (DateTime)dt.Rows[0]["Logout_Date"] > DateTime.Today) { MessageBox.Show("You are already loged in "); return; } else { } } catch (Exception ex) { // write exception info to log or anything else MessageBox.Show("Error occured! : " + ex); } }