예제 #1
0
        /// <summary>
        /// This is the main method that does the copying. It calls the SQLLaptop class
        /// to do the inserting and the return result is the rows affected by the call.
        /// If there are more than 0 rows, it will let the user know how many rows were affect.
        /// If not it will display the error and a tip
        /// </summary>
        /// <returns></returns>
        private bool CopyContent()
        {
            bool copyStatus = false;

            DataTable dataTable1 = new DataTable();
            DataTable dataTable2 = new DataTable();

            int rowsAffected = SQLLaptop.InsertInto(connectionString1Database,
                                                    selectedCombo1Table, selectedCombo2Table, selectedCombo1Database, selectedCombo2Database);

            if (rowsAffected >= 1)
            {
                lbl_Error_Copy.Show();
                LabelChanger.ChangeColor("Green", lbl_Error_Copy);
                LabelChanger.ChangeText("Successfully Copied. " + rowsAffected + " rows have been affected.", lbl_Error_Copy);
            }
            else
            {
                // Clear the new table that didnt work
                lbl_Error_Copy.Show();
                LabelChanger.ChangeColor("Red", lbl_Error_Copy);
                LabelChanger.ChangeText("Error when copying the tables. Double check your entered schema name and table. (eg. dbo.test)", lbl_Error_Copy);
                cb_Table_2.SelectedIndex = -1;
            }

            return(copyStatus);
        }
예제 #2
0
        /// <summary>
        /// This method handles the event that the sign in button on the left side is pressed.
        /// We will check to see if the user can sign in. If they can, lets notify them that
        /// their connection was successful and load the combobox with the database list on the left.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Signin_1_Click(object sender, EventArgs e)
        {
            // Check that user 1 can successfully connect. If he can, lets prompt the result
            lbl_Error_User_1.Show();
            string connectionString = SignInChecker(USER_ONE);

            if (connectionString != "Failed")
            {
                LabelChanger.ChangeText("Successfully Logged in.", lbl_Error_User_1);
                LabelChanger.ChangeColor("Green", lbl_Error_User_1);
                SQLLaptop.LoadSchemaList(connectionString, cb_DataBase_1);
                connectionString1 = connectionString;
                if (assignmentRequirement)
                {
                    connectionString2 = connectionString1;
                    SQLLaptop.LoadSchemaList(connectionString, cb_DataBase_2);
                }
            }
            else
            {
                LabelChanger.ChangeText("Invalid Credentials.", lbl_Error_User_1);
                LabelChanger.ChangeColor("Red", lbl_Error_User_1);
                connectionString1 = "Failed";
            }
        }
예제 #3
0
        /// <summary>
        /// This method handles the sign in button on the right side. Its pretty identicle to the above
        /// method, but handles the right side fields and right side combo box.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Signin_2_Click(object sender, EventArgs e)
        {
            lbl_Error_User_2.Show();
            // Find the provider. If none is selected, loop through them all


            string connectionString = SignInChecker(USER_TWO);

            if (connectionString != "Failed")
            {
                LabelChanger.ChangeText("Successfully Logged in.", lbl_Error_User_2);
                LabelChanger.ChangeColor("Green", lbl_Error_User_2);
                SQLLaptop.LoadSchemaList(connectionString, cb_DataBase_2);
                connectionString2 = connectionString;
            }
            else
            {
                LabelChanger.ChangeText("Invalid Credentials.", lbl_User_2);
                LabelChanger.ChangeColor("Red", lbl_Error_User_2);
                connectionString2 = "Failed";
            }
        }
예제 #4
0
        /// <summary>
        /// This method is support in non-assignment mode. Is just duplicates the first account
        /// into the second account
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Same_Account(object sender, EventArgs e)
        {
            HideSecondUserLogin();

            // Retrieve information from the first sign in form
            string connectionString = SignInChecker(USER_ONE);

            lbl_Error_User_2.Show();
            // If successfully logged in, display success
            if (connectionString != "Failed")
            {
                SQLLaptop.LoadSchemaList(connectionString, cb_DataBase_2);
                LabelChanger.ChangeText("Successfully Logged in.", lbl_Error_User_2);
                LabelChanger.ChangeColor("Green", lbl_Error_User_2);
                connectionString2 = connectionString;
            }
            else
            {
                LabelChanger.ChangeText("Invalid Credentials.", lbl_User_2);
                LabelChanger.ChangeColor("Red", lbl_Error_User_2);
            }
            // else if failed to log in, display error
        }