예제 #1
0
 //Helper Methods
 private bool GET_CURRENTLY_SELECTED_RECIPE_DATA(out RECIPE_DATA DATA) //Gets the record currently selected in the DGV.
 {
     EVENTS.LOG_MESSAGE(1, "ENTER");
     DATA = new RECIPE_DATA();
     try
     {
         int SELECTED_INDEX = DGV_RECIPE_TABLE.SelectedRows[0].Index;
         DATA.part_number     = RECIPE_TABLE_LOCAL.Rows[SELECTED_INDEX]["part_number"].ToString();
         DATA.checksheet_type = RECIPE_TABLE_LOCAL.Rows[SELECTED_INDEX]["checksheet_type"].ToString();
         DATA.csv_location    = RECIPE_TABLE_LOCAL.Rows[SELECTED_INDEX]["csv_location"].ToString();
         DATA.key_sequence    = RECIPE_TABLE_LOCAL.Rows[SELECTED_INDEX]["key_sequence"].ToString();
         DATA.timestamp_col   = int.Parse(RECIPE_TABLE_LOCAL.Rows[SELECTED_INDEX]["timestamp_col"].ToString());
         DATA.a_col           = int.Parse(RECIPE_TABLE_LOCAL.Rows[SELECTED_INDEX]["a_col"].ToString());
         DATA.b_col           = int.Parse(RECIPE_TABLE_LOCAL.Rows[SELECTED_INDEX]["b_col"].ToString());
         DATA.c_col           = int.Parse(RECIPE_TABLE_LOCAL.Rows[SELECTED_INDEX]["c_col"].ToString());
         DATA.d_col           = int.Parse(RECIPE_TABLE_LOCAL.Rows[SELECTED_INDEX]["d_col"].ToString());
         DATA.e_col           = int.Parse(RECIPE_TABLE_LOCAL.Rows[SELECTED_INDEX]["e_col"].ToString());
         DATA.f_col           = int.Parse(RECIPE_TABLE_LOCAL.Rows[SELECTED_INDEX]["f_col"].ToString());
         DATA.g_col           = int.Parse(RECIPE_TABLE_LOCAL.Rows[SELECTED_INDEX]["g_col"].ToString());
         DATA.h_col           = int.Parse(RECIPE_TABLE_LOCAL.Rows[SELECTED_INDEX]["h_col"].ToString());
         DATA.i_col           = int.Parse(RECIPE_TABLE_LOCAL.Rows[SELECTED_INDEX]["i_col"].ToString());
         DATA.j_col           = int.Parse(RECIPE_TABLE_LOCAL.Rows[SELECTED_INDEX]["j_col"].ToString());
         DATA.k_col           = int.Parse(RECIPE_TABLE_LOCAL.Rows[SELECTED_INDEX]["k_col"].ToString());
         DATA.l_col           = int.Parse(RECIPE_TABLE_LOCAL.Rows[SELECTED_INDEX]["l_col"].ToString());
         DATA.m_col           = int.Parse(RECIPE_TABLE_LOCAL.Rows[SELECTED_INDEX]["m_col"].ToString());
         EVENTS.LOG_MESSAGE(1, "EXIT_SUCCESS");
         return(true);
     }
     catch (Exception EX)
     {
         EVENTS.LOG_MESSAGE(2, "EXCEPTION", EX.Message);
         EVENTS.LOG_MESSAGE(1, "EXIT_FAIL");
         return(false);
     }
 }
예제 #2
0
 /// <summary>
 /// This method labels all the columns in TABLE in accordance with DATA.
 /// </summary>
 /// <param name="TABLE">The table to label.</param>
 /// <param name="DATA">The structure that holds the labelling.</param>
 public static void LABEL_DATATABLE_COLUMNS(ref DataTable TABLE, RECIPE_DATA DATA)
 {
     if (DATA.a_col >= 0)
     {
         TABLE.Columns[DATA.a_col].ColumnName = "A";
     }
     if (DATA.b_col >= 0)
     {
         TABLE.Columns[DATA.b_col].ColumnName = "B";
     }
     if (DATA.c_col >= 0)
     {
         TABLE.Columns[DATA.c_col].ColumnName = "C";
     }
     if (DATA.d_col >= 0)
     {
         TABLE.Columns[DATA.d_col].ColumnName = "D";
     }
     if (DATA.e_col >= 0)
     {
         TABLE.Columns[DATA.e_col].ColumnName = "E";
     }
     if (DATA.f_col >= 0)
     {
         TABLE.Columns[DATA.f_col].ColumnName = "F";
     }
     if (DATA.g_col >= 0)
     {
         TABLE.Columns[DATA.g_col].ColumnName = "G";
     }
     if (DATA.h_col >= 0)
     {
         TABLE.Columns[DATA.h_col].ColumnName = "H";
     }
     if (DATA.i_col >= 0)
     {
         TABLE.Columns[DATA.i_col].ColumnName = "I";
     }
     if (DATA.j_col >= 0)
     {
         TABLE.Columns[DATA.j_col].ColumnName = "J";
     }
     if (DATA.k_col >= 0)
     {
         TABLE.Columns[DATA.k_col].ColumnName = "K";
     }
     if (DATA.l_col >= 0)
     {
         TABLE.Columns[DATA.l_col].ColumnName = "L";
     }
     if (DATA.m_col >= 0)
     {
         TABLE.Columns[DATA.m_col].ColumnName = "M";
     }
     if (DATA.timestamp_col >= 0)
     {
         TABLE.Columns[DATA.timestamp_col].ColumnName = "TimeStamp";
     }
 }
예제 #3
0
        private void GENERATE_PARAMETERS(RECIPE_DATA DATA, out SQL_PARAMETER[] PARAMS) //Populates the parameters structure used in SQL commands.
        {
            EVENTS.LOG_MESSAGE(1, "ENTER");
            //Create the parameter array we're going to pass to the EXECUTE_COMMAND function.
            PARAMS = new SQL_PARAMETER[18];
            for (int i = 0; i < PARAMS.Length; i++) //Since this is an array of a custom type, loop through and initialize each element...
            {
                PARAMS[i] = new SQL_PARAMETER();
            }

            //Define the escape strings. These are the strings that will subsitute in data in the COMMAND_STRING.
            PARAMS[0].ESCAPE_STRING  = "?part_number";
            PARAMS[1].ESCAPE_STRING  = "?checksheet_type";
            PARAMS[2].ESCAPE_STRING  = "?key_sequence";
            PARAMS[3].ESCAPE_STRING  = "?csv_location";
            PARAMS[4].ESCAPE_STRING  = "?timestamp_col";
            PARAMS[5].ESCAPE_STRING  = "?a_col";
            PARAMS[6].ESCAPE_STRING  = "?b_col";
            PARAMS[7].ESCAPE_STRING  = "?c_col";
            PARAMS[8].ESCAPE_STRING  = "?d_col";
            PARAMS[9].ESCAPE_STRING  = "?e_col";
            PARAMS[10].ESCAPE_STRING = "?f_col";
            PARAMS[11].ESCAPE_STRING = "?g_col";
            PARAMS[12].ESCAPE_STRING = "?h_col";
            PARAMS[13].ESCAPE_STRING = "?i_col";
            PARAMS[14].ESCAPE_STRING = "?j_col";
            PARAMS[15].ESCAPE_STRING = "?k_col";
            PARAMS[16].ESCAPE_STRING = "?l_col";
            PARAMS[17].ESCAPE_STRING = "?m_col";

            //Define all the data that ties to the escape strings.
            PARAMS[0].STRING_TO_INSERT  = DATA.part_number;
            PARAMS[1].STRING_TO_INSERT  = DATA.checksheet_type;
            PARAMS[2].STRING_TO_INSERT  = DATA.key_sequence;
            PARAMS[3].STRING_TO_INSERT  = DATA.csv_location;
            PARAMS[4].STRING_TO_INSERT  = DATA.timestamp_col.ToString();
            PARAMS[5].STRING_TO_INSERT  = DATA.a_col.ToString();
            PARAMS[6].STRING_TO_INSERT  = DATA.b_col.ToString();
            PARAMS[7].STRING_TO_INSERT  = DATA.c_col.ToString();
            PARAMS[8].STRING_TO_INSERT  = DATA.d_col.ToString();
            PARAMS[9].STRING_TO_INSERT  = DATA.e_col.ToString();
            PARAMS[10].STRING_TO_INSERT = DATA.f_col.ToString();
            PARAMS[11].STRING_TO_INSERT = DATA.g_col.ToString();
            PARAMS[12].STRING_TO_INSERT = DATA.h_col.ToString();
            PARAMS[13].STRING_TO_INSERT = DATA.i_col.ToString();
            PARAMS[14].STRING_TO_INSERT = DATA.j_col.ToString();
            PARAMS[15].STRING_TO_INSERT = DATA.k_col.ToString();
            PARAMS[16].STRING_TO_INSERT = DATA.l_col.ToString();
            PARAMS[17].STRING_TO_INSERT = DATA.m_col.ToString();
            EVENTS.LOG_MESSAGE(1, "EXIT_SUCCESS");
        }
        //Constructor
        public FORM_ADD_RECIPE(DataTable CHECKSHEET_TYPE_DATA_TABLE, RECIPE_DATA CURRENT_RECIPE_DATA = null) //Logged and documented.
        {
            InitializeComponent();
            EVENTS.LOG_MESSAGE(1, "INITIALIZE");

            SEQUENCE_DATATABLE.Columns.Add("Keys");
            //For each row in the datatable passed on initialization, add the data to the listbox.
            foreach (DataRow ROW in CHECKSHEET_TYPE_DATA_TABLE.Rows)
            {
                LISTBOX_CHECKSHEET_TYPE.Items.Add(ROW.ItemArray[0].ToString());
            }
            EVENTS.LOG_MESSAGE(3, "Checksheet types loaded.");

            //Format all the color assigners.
            GRP_BOX_COLUMN_ASSIGNERS.Enabled = false;
            EVENTS.LOG_MESSAGE(3, "Assigner controls disabled.");

            BTN_A.BackColor = ColorTranslator.FromHtml("#CC99C9");
            BTN_B.BackColor = ColorTranslator.FromHtml("#9EC1CF");
            BTN_C.BackColor = ColorTranslator.FromHtml("#9EE09E");
            BTN_D.BackColor = ColorTranslator.FromHtml("#FDFD97");
            BTN_E.BackColor = ColorTranslator.FromHtml("#FEB144");
            BTN_F.BackColor = ColorTranslator.FromHtml("#FF6663");
            BTN_G.BackColor = ColorTranslator.FromHtml("#CC99C9");

            BTN_H.BackColor         = ColorTranslator.FromHtml("#9EC1CF");
            BTN_I.BackColor         = ColorTranslator.FromHtml("#9EE09E");
            BTN_J.BackColor         = ColorTranslator.FromHtml("#FDFD97");
            BTN_K.BackColor         = ColorTranslator.FromHtml("#FEB144");
            BTN_L.BackColor         = ColorTranslator.FromHtml("#FF6663");
            BTN_M.BackColor         = ColorTranslator.FromHtml("#CC99C9");
            BTN_TIMESTAMP.BackColor = Color.Pink;
            EVENTS.LOG_MESSAGE(3, "Assigner colors set.");

            //If this form is being created as a edit recipe, rather than a new recipe...
            if (CURRENT_RECIPE_DATA != null)
            {
                EVENTS.LOG_MESSAGE(3, "Form call is an edit request.");
                LOAD_IN_EDIT_DATA(CURRENT_RECIPE_DATA);
                TXT_BOX_PART_NUM.Enabled        = false;
                LISTBOX_CHECKSHEET_TYPE.Enabled = false;
            }
            else
            {
                EVENTS.LOG_MESSAGE(3, "Form call is a new request.");
            }
            KEY_LOGGER_SETUP();
            FORM_MAIN.OK_TO_CLOSE_ADD_RECIPE_FORM += new EventHandler(CLOSE);
            EVENTS.LOG_MESSAGE(3, "Close EventHandler installed.");
            EVENTS.LOG_MESSAGE(1, "EXIT_SUCCESS");
        }
예제 #5
0
        private void ADD_EDIT_RECIPE(object sender, EventArgs e) //Both the "Add Recipe" button and the "Edit Recipe" button call this.
        {
            EVENTS.LOG_MESSAGE(1, "ENTER");

            //Check if form is open.
            FormCollection COLLECTION = Application.OpenForms; //Get a collection of all the open forms.

            foreach (Form FORM in COLLECTION)                  //Go through each open form...
            {
                if (FORM.Name == "FORM_ADD_RECIPE")            //If the evaluated form has the same name as the form we're about to open...
                {
                    FORM.BringToFront();                       //Bring the form to the front.
                    EVENTS.LOG_MESSAGE(2, "Form already open.");
                    EVENTS.LOG_MESSAGE(1, "EXIT_FAIL");
                    return; //Exit.
                }
            }

            //Get the listings of checksheet types from the SQL DB, this will be used to populate a list box on the new form.
            DataTable CHECKSHEET_DATA = DB.GET_TABLE(Properties.DB.Default.CHECKSHEET_TABLE, Properties.DB.Default.CHECKSHEET_TABLE_COLUMN_SCHEMA); //Get the checksheet data listing to pass over to the form.

            //Determine if the edit button is what called this method. If it is, we have to get the currently selected recipe.
            if ((Button)sender == BTN_EDIT_RECIPE)                                                   //Cast the sender into a button type and check if it is BTN_EDIT. If it is...
            {
                RECIPE_DATA CURRENT_RECORD = new RECIPE_DATA();                                      //Create a blank RECIPE_DATA object.
                bool        SUCCESS        = GET_CURRENTLY_SELECTED_RECIPE_DATA(out CURRENT_RECORD); //Populate the object and store if it was a success. Function will return true on success.
                if (SUCCESS)
                {
                    var ADD_FORM = new FORM_ADD_RECIPE(CHECKSHEET_DATA, CURRENT_RECORD); //Create a new form with optional CURRENT_RECORD attached.
                                                                                         //FORM_ADD_RECIPE recognizes optional record attachment as a request to edit rather than add.
                    ADD_FORM.Show();                                                     //Show the form.
                    ADD_FORM.DATA_READY += new EventHandler(PROCESS_ADD_RECIPE_DATA);    //Add handler for when the form has its data all set.
                }
                else //If getting data was unsuccessful...
                {
                    EVENTS.LOG_MESSAGE(1, "EXIT_FAIL");
                    return;
                }
            }
            else
            {
                var ADD_FORM = new FORM_ADD_RECIPE(CHECKSHEET_DATA);              //Create a blank form.
                ADD_FORM.Show();                                                  //Show the form.
                ADD_FORM.DATA_READY += new EventHandler(PROCESS_ADD_RECIPE_DATA); //Add handler for when the form has its data all set.
            }
            EVENTS.LOG_MESSAGE(1, "EXIT_SUCCESS");
        }
예제 #6
0
        //Simple string/structure generators, moved into own functions for readability.
        private string CREATE_ADD_RECORD_STRING(RECIPE_DATA DATA, SQL_PARAMETER[] PARAMS) //Creates the command string for adding a new record.
        {
            EVENTS.LOG_MESSAGE(1, "ENTER");

            //Define where we're going to insert data.
            string INSERT_LOCATION = "INSERT INTO " + Properties.DB.Default.RECIPE_TABLE + " (" +
                                     "part_number," +
                                     "checksheet_type," +
                                     "key_sequence," +
                                     "csv_location," +
                                     "timestamp_col," +
                                     "a_col," +
                                     "b_col," +
                                     "c_col," +
                                     "d_col," +
                                     "e_col," +
                                     "f_col," +
                                     "g_col," +
                                     "h_col," +
                                     "i_col," +
                                     "j_col," +
                                     "k_col," +
                                     "l_col," +
                                     "m_col" +
                                     ") ";

            //Create the second part of the command string.
            string INSERT_DATA = "VALUES(";

            for (int i = 0; i < PARAMS.Length; i++)
            {
                INSERT_DATA += PARAMS[i].ESCAPE_STRING + ",";
            }
            INSERT_DATA  = INSERT_DATA.TrimEnd(',');
            INSERT_DATA += ")";

            //Construct the command.
            string COMMAND_STRING = INSERT_LOCATION + INSERT_DATA; //Combine the strings together.

            EVENTS.LOG_MESSAGE(1, "EXIT_SUCCESS");
            return(COMMAND_STRING);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            EVENTS.LOG_MESSAGE(1, "ENTER");

            //Get the currently selected recipe data.
            RECIPE_DATA DATA = new RECIPE_DATA();

            GET_CURRENTLY_SELECTED_RECIPE_DATA(out DATA);

            //Process the key sequence from the recipe into a list and table.
            SEQUENCE_LIST.Clear();
            SEQUENCE_DATATABLE.Clear();
            BACKEND.LOAD_IN_KEY_SEQUENCE(DATA.key_sequence, ref SEQUENCE_LIST, ref SEQUENCE_DATATABLE);

            //Get data from file.
            TABLE_PROCESSOR KEYENCE_PROCESSOR = new TABLE_PROCESSOR();
            DataTable       TABLE             = new DataTable();
            DataTable       INSTRUCTIONS      = INSTRUCTION_SET.CREATE_INSTRUCTION_TABLE();

            KEYENCE_PROCESSOR.PROCESS_INSTRUCTIONS(ref TABLE, ref INSTRUCTIONS, DATA.csv_location, ',');

            //Label the columns.
            BACKEND.LABEL_DATATABLE_COLUMNS(ref TABLE, DATA);

            //Check the timestamp.
            string TIME_STRING = null;

            for (int i = TABLE.Rows.Count - 1; i >= 0; i--)
            {
                TIME_STRING = TABLE.Rows[i][DATA.timestamp_col].ToString();
                if (TIME_STRING != "" && TIME_STRING != null)
                {
                    break;
                }
            }
            DateTime TIME     = DateTime.Parse(TIME_STRING);
            TimeSpan TIME_AGO = DateTime.Now.Subtract(TIME);

            if (TIME_AGO.TotalHours > 1)
            {
                string MESSAGE = string.Format("The last entry detected is {0} Days, {1} Hours and {2} Minutes old. Are you sure this is correct?",
                                               TIME_AGO.Days,
                                               TIME_AGO.Hours,
                                               TIME_AGO.Minutes);
                if (MessageBox.Show(MESSAGE, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                {
                    return;
                }
            }

            FORM_REPLAY NEW_FORM = new FORM_REPLAY();

            NEW_FORM.Show();
            NEW_FORM.TopMost = true;

            //Fill out the injection table.
            BACKEND.MOVE_CSV_DATA_INTO_INJECTION_TABLE(TABLE, INJECTION_TABLE);

            //Start the keylogger.
            REPLAY_SEQUENCE_START(null, null);

            EVENTS.LOG_MESSAGE(1, "EXIT_SUCCESS");
        }
        //Methods

        /// <summary>
        /// This method is called when the form loads and it is determined to be a "edit recipe" call rather than a "new recipe call".
        /// The method loads in passed data into all the form objects.
        /// </summary>
        /// <param name="CURRENT_RECIPE_DATA">Recipe data to load into the form fields.</param>
        private void LOAD_IN_EDIT_DATA(RECIPE_DATA CURRENT_RECIPE_DATA) //Logged and documented.
        {
            EVENTS.LOG_MESSAGE(1, "ENTER");
            TXT_BOX_PART_NUM.Text = CURRENT_RECIPE_DATA.part_number;                    //Load in part number.
            EVENTS.LOG_MESSAGE(3, "Part number loaded.");
            LISTBOX_CHECKSHEET_TYPE.SelectedItem = CURRENT_RECIPE_DATA.checksheet_type; //Load in checksheet type.
            EVENTS.LOG_MESSAGE(3, "Checksheet type loaded.");
            string MODIFIED_PATH = CURRENT_RECIPE_DATA.csv_location;                    //Load in CSV file location.

            MODIFIED_PATH.Replace(@"\", @"\\");                                         //The SQL db was squirrelly with storing slashes, it seems to be fine
            //now and not entirely needed but I don't think its hurting. I'm gonna keep it.
            TXT_BOX_KEYENCE.Text = MODIFIED_PATH;                                       //Assign the value to the textbox.
            EVENTS.LOG_MESSAGE(3, "Filepath loaded.");
            //Load CSV file into viewer.
            LOAD_CSV_DATA(null, null);

            DataTable TABLE   = new DataTable();
            bool      SUCCESS = BACKEND.EXTRACT_DATA_TABLE_FROM_DGV(ref DGV1, ref TABLE);

            if (SUCCESS)
            {
                foreach (DataColumn COLUMN in TABLE.Columns)
                {
                    if (COLUMN.Ordinal == CURRENT_RECIPE_DATA.a_col)
                    {
                        COLUMN.ColumnName = "A";
                    }
                    if (COLUMN.Ordinal == CURRENT_RECIPE_DATA.b_col)
                    {
                        COLUMN.ColumnName = "B";
                    }
                    if (COLUMN.Ordinal == CURRENT_RECIPE_DATA.c_col)
                    {
                        COLUMN.ColumnName = "C";
                    }
                    if (COLUMN.Ordinal == CURRENT_RECIPE_DATA.d_col)
                    {
                        COLUMN.ColumnName = "D";
                    }
                    if (COLUMN.Ordinal == CURRENT_RECIPE_DATA.e_col)
                    {
                        COLUMN.ColumnName = "E";
                    }
                    if (COLUMN.Ordinal == CURRENT_RECIPE_DATA.f_col)
                    {
                        COLUMN.ColumnName = "F";
                    }
                    if (COLUMN.Ordinal == CURRENT_RECIPE_DATA.g_col)
                    {
                        COLUMN.ColumnName = "G";
                    }
                    if (COLUMN.Ordinal == CURRENT_RECIPE_DATA.h_col)
                    {
                        COLUMN.ColumnName = "H";
                    }
                    if (COLUMN.Ordinal == CURRENT_RECIPE_DATA.i_col)
                    {
                        COLUMN.ColumnName = "I";
                    }
                    if (COLUMN.Ordinal == CURRENT_RECIPE_DATA.j_col)
                    {
                        COLUMN.ColumnName = "J";
                    }
                    if (COLUMN.Ordinal == CURRENT_RECIPE_DATA.k_col)
                    {
                        COLUMN.ColumnName = "K";
                    }
                    if (COLUMN.Ordinal == CURRENT_RECIPE_DATA.l_col)
                    {
                        COLUMN.ColumnName = "L";
                    }
                    if (COLUMN.Ordinal == CURRENT_RECIPE_DATA.m_col)
                    {
                        COLUMN.ColumnName = "M";
                    }
                    if (COLUMN.Ordinal == CURRENT_RECIPE_DATA.timestamp_col)
                    {
                        COLUMN.ColumnName = "TimeStamp";
                    }
                }
            }
            EVENTS.LOG_MESSAGE(3, "Column names assigned.");
            DGV1.DataSource = TABLE;
            EVENTS.LOG_MESSAGE(3, "Table bound to DGV.");
            COLOR_DGV_COLUMNS();
            BACKEND.LOAD_IN_KEY_SEQUENCE(CURRENT_RECIPE_DATA.key_sequence, ref SEQUENCE_LIST, ref SEQUENCE_DATATABLE);
            EVENTS.LOG_MESSAGE(1, "EXIT_SUCCESS");
        }
        /// <summary>
        /// This method handles checking that all data is good for saving. It is called when the save button is clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BTN_SAVE_CLICK(object sender, EventArgs e) //Logged and documented.
        {
            EVENTS.LOG_MESSAGE(1, "ENTER");

            //Check the part number is good----------------------------------------------------------------------
            string TEXT   = TXT_BOX_PART_NUM.Text;                  //Get the canidate string from the textbox.
            int    RESULT = BACKEND.VALIDATE_PART_NUMBER(ref TEXT); //Check the string validity.

            TXT_BOX_PART_NUM.Text = TEXT;                           //Reassign the string to the textbox so its capitalized.
            if (RESULT != 0)                                        //If VALIDATE_PART_NUMBER did not execute successfully...
            {
                string MESSAGE = null;
                switch (RESULT) //Determine exactly what happened and throw the appropriate message.
                {
                case (1):
                    MESSAGE = "The part number is not valid. It must be six (6) characters long.";
                    MessageBox.Show(MESSAGE, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;

                case (2):
                    MESSAGE = "The part number is not valid. The first two characters need to be letters.";
                    MessageBox.Show(MESSAGE, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;

                case (3):
                    MESSAGE = "The part number is not valid. The last four characters need to be digits.";
                    MessageBox.Show(MESSAGE, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }
                EVENTS.LOG_MESSAGE(2, "EXCEPTION", MESSAGE);
                EVENTS.LOG_MESSAGE(1, "EXIT_FAIL");
                return; //Cancel all other operations.
            }
            EVENTS.LOG_MESSAGE(3, "Part number is good.");

            //Check that a checksheet type is selected-----------------------------------------------------------
            string CHECKSHEET_TYPE = "";

            try
            {
                CHECKSHEET_TYPE = LISTBOX_CHECKSHEET_TYPE.SelectedItem.ToString();
            }
            catch (NullReferenceException)
            {
                string MESSAGE = "Please select a checksheet type.";
                MessageBox.Show(MESSAGE, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                EVENTS.LOG_MESSAGE(2, "EXCEPTION", MESSAGE);
                EVENTS.LOG_MESSAGE(1, "EXIT_FAIL");
                return; //Cancel all other operations.
            }
            EVENTS.LOG_MESSAGE(3, "Sheet type is good.");

            //Check if the keyence csv path is valid-------------------------------------------------------------
            bool IS_CSV_VALID = BACKEND.VALIDATE_FILE(TXT_BOX_KEYENCE.Text);

            if (!IS_CSV_VALID)
            {
                return;
            }
            EVENTS.LOG_MESSAGE(3, "Path is valid.");

            //Check that data has been previewed in the viewer---------------------------------------------------
            //This bit should no longer be relevant because I changed the code to automatically load whatever
            //the filepath is, but it can't hurt to keep it in case I did not think of something.
            if (DGV1.Rows.Count <= 0)
            {
                string MESSAGE = "The Keyence CSV file has not been opened and assignments have not been made.";
                MessageBox.Show(MESSAGE, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                EVENTS.LOG_MESSAGE(2, "EXCEPTION", MESSAGE);
                EVENTS.LOG_MESSAGE(1, "EXIT_FAIL");
                return; //Cancel all other operations.
            }

            //Get the DGV table for the next couple steps--------------------------------------------------------
            DataTable TABLE   = new DataTable();
            bool      SUCCESS = BACKEND.EXTRACT_DATA_TABLE_FROM_DGV(ref DGV1, ref TABLE);

            EVENTS.LOG_MESSAGE(3, "Retrieved DataTable.");

            //Check that a timestamp column is selected----------------------------------------------------------
            int TIMESTAMP_INDEX = -1;

            foreach (DataColumn COLUMN in TABLE.Columns)
            {
                if (COLUMN.ColumnName == "TimeStamp")
                {
                    TIMESTAMP_INDEX = COLUMN.Ordinal;
                }
            }
            if (TIMESTAMP_INDEX == -1)
            {
                string MESSAGE = "A timestamp column was not designated, this is required.";
                MessageBox.Show(MESSAGE, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                EVENTS.LOG_MESSAGE(2, "EXCEPTION", MESSAGE);
                EVENTS.LOG_MESSAGE(1, "EXIT_FAIL");
                return; //Cancel all other operations.
            }

            //Generate a string of all the keystrokes------------------------------------------------------------
            string KEY_SEQUENCE = "";

            foreach (string KEY in SEQUENCE_LIST)
            {
                KEY_SEQUENCE += KEY + ",";
            }
            EVENTS.LOG_MESSAGE(3, "Key sequence generated.");

            //Commit the data to the returning package-----------------------------------------------------------
            RECIPE_DATA DATA = new RECIPE_DATA();

            DATA.part_number     = TXT_BOX_PART_NUM.Text;
            DATA.checksheet_type = CHECKSHEET_TYPE;
            DATA.key_sequence    = KEY_SEQUENCE;
            DATA.csv_location    = TXT_BOX_KEYENCE.Text;
            DATA.timestamp_col   = TIMESTAMP_INDEX;
            DATA.a_col           = -1;
            DATA.b_col           = -1;
            DATA.c_col           = -1;
            DATA.d_col           = -1;
            DATA.e_col           = -1;
            DATA.f_col           = -1;
            DATA.g_col           = -1;
            DATA.h_col           = -1;
            DATA.i_col           = -1;
            DATA.j_col           = -1;
            DATA.k_col           = -1;
            DATA.l_col           = -1;
            DATA.m_col           = -1;
            if (SUCCESS)
            {
                foreach (DataColumn COLUMN in TABLE.Columns)
                {
                    switch (COLUMN.ColumnName)
                    {
                    case ("A"):
                        DATA.a_col = COLUMN.Ordinal;
                        break;

                    case ("B"):
                        DATA.b_col = COLUMN.Ordinal;
                        break;

                    case ("C"):
                        DATA.c_col = COLUMN.Ordinal;
                        break;

                    case ("D"):
                        DATA.d_col = COLUMN.Ordinal;
                        break;

                    case ("E"):
                        DATA.e_col = COLUMN.Ordinal;
                        break;

                    case ("F"):
                        DATA.f_col = COLUMN.Ordinal;
                        break;

                    case ("G"):
                        DATA.g_col = COLUMN.Ordinal;
                        break;

                    case ("H"):
                        DATA.h_col = COLUMN.Ordinal;
                        break;

                    case ("I"):
                        DATA.i_col = COLUMN.Ordinal;
                        break;

                    case ("J"):
                        DATA.j_col = COLUMN.Ordinal;
                        break;

                    case ("K"):
                        DATA.k_col = COLUMN.Ordinal;
                        break;

                    case ("L"):
                        DATA.l_col = COLUMN.Ordinal;
                        break;

                    case ("M"):
                        DATA.m_col = COLUMN.Ordinal;
                        break;
                    }
                }
                EVENTS.LOG_MESSAGE(3, "Columns assigned.");
            }
            else
            {
                string MESSAGE = "Failed to extract DGV Data";
                MessageBox.Show(MESSAGE, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                EVENTS.LOG_MESSAGE(2, "EXCEPTION", MESSAGE);
                EVENTS.LOG_MESSAGE(1, "EXIT_FAIL");
            }

            //Invoke delegate with info pack and close-----------------------------------------------------------
            DATA_READY?.Invoke(null, DATA);
            EVENTS.LOG_MESSAGE(1, "EXIT_SUCCESS");
        }