Пример #1
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");
        }
Пример #2
0
        public DataSet Get_Schemes_Record(int?id)
        {
            SQL_PARAMETER[] sql = new SQL_PARAMETER[1];

            if (!string.IsNullOrEmpty(id.ToString()))
            {
                sql[0] = new SQL_PARAMETER("@id", DbType.Int32, id);
            }
            else
            {
                sql[0] = new SQL_PARAMETER("@id", DbType.Int32, DBNull.Value);
            }
            DataSet ds = CM_SERVER_DB.GetDataSet("Api_Get_Schemes_Record", sql);

            return(ds);
        }
Пример #3
0
        private void PROCESS_ADD_RECIPE_DATA(object sender, EventArgs e) //Called once the FORM_ADD_RECIPE is ready to submit.
        {
            EVENTS.LOG_MESSAGE(1, "ENTER");
            //Extract data out of arguments and build query string.
            var DATA = (RECIPE_DATA)e; //Specify the exact type of EventArgs.

            //Create an array of SQL parameters. Since its a custom type we have to recurse through it to fully initialize.
            var 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();
            }
            GENERATE_PARAMETERS(DATA, out PARAMS);

            //Build the command string.
            string COMMAND_STRING = CREATE_ADD_RECORD_STRING(DATA, PARAMS);

            //Check to make sure there is no current entry that matches for part number and checksheet type.
            foreach (DataRow RECORD in RECIPE_TABLE_LOCAL.Rows)
            {
                if (RECORD["part_number"].ToString() == DATA.part_number &&
                    RECORD["checksheet_type"].ToString() == DATA.checksheet_type) //If there is a record with the same part number and checksheet...
                {
                    string MESSAGE;
                    MESSAGE = "A recipe for the part number and checksheet type already exists. Would you like to overwrite this recipe?";
                    DialogResult CHOICE = MessageBox.Show(MESSAGE, "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    EVENTS.LOG_MESSAGE(2, MESSAGE);
                    if (CHOICE == DialogResult.No)
                    {
                        EVENTS.LOG_MESSAGE(2, "User selected NO.");
                        OK_TO_CLOSE_ADD_RECIPE_FORM?.Invoke(null, null);
                        EVENTS.LOG_MESSAGE(1, "EXIT_FAIL");
                        return;
                    }
                    if (CHOICE == DialogResult.Cancel)
                    {
                        EVENTS.LOG_MESSAGE(2, "User selected CANCEL.");
                        EVENTS.LOG_MESSAGE(1, "EXIT_FAIL");
                        return;
                    }
                    EVENTS.LOG_MESSAGE(2, "User selected YES.");
                    COMMAND_STRING = CREATE_MODIFY_RECORD_STRING();
                }
            }

            OK_TO_CLOSE_ADD_RECIPE_FORM?.Invoke(null, null); //notify the form that its ok to close, we're past the point where a user can cancel.

            //Issue the command.
            int RESULT = DB.EXECUTE_COMMAND(COMMAND_STRING, PARAMS);

            //If a negative 1 is returned, this means failure.
            if (RESULT == -1)
            {
                string MESSAGE;
                MESSAGE = "EXECUTE_COMMAND method failed. Record was not added. See log for details.";
                MessageBox.Show(MESSAGE, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                EVENTS.LOG_MESSAGE(2, MESSAGE);
                EVENTS.LOG_MESSAGE(1, "EXIT_FAIL");
                return;
            }
            UPDATE_TABLE(null, null);
            EVENTS.LOG_MESSAGE(1, "EXIT_SUCCESS");
        }