Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Cancel naviagation bar add new record

$
0
0

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);
                }
            }

         




Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>