154 lines
6.2 KiB
Plaintext
154 lines
6.2 KiB
Plaintext
Compile function Copy_QUOTE_Record_To_SQL(Connection, Key, Record)
|
|
|
|
/*****************************************************************************\
|
|
Copies the given QUOTE record to the MSSQL database.
|
|
|
|
History
|
|
-------
|
|
06/08/2010 KRF Original Programmer
|
|
\*****************************************************************************/
|
|
|
|
Declare function SQL_Write, SQL_Write_MV, SQL_Format
|
|
Ans = ""
|
|
|
|
// Parse record into a dimensioned array for speed
|
|
Dim Rec(55)
|
|
MatParse Record into Rec
|
|
|
|
// List of key names and their values
|
|
Keys = "SEQ":@VM:SQL_Format(Key, "INT")
|
|
|
|
// List of data fields and their values
|
|
DataFields = "CUST_NO" :@VM:SQL_Format(Rec(1), "INT"):@FM
|
|
DataFields := "NAME_NO" :@VM:SQL_Format(Rec(2), "INT"):@FM
|
|
DataFields := "FAX" :@VM:SQL_Format(Rec(3), "STR"):@FM
|
|
DataFields := "IFAX" :@VM:SQL_Format(Rec(4), "STR"):@FM
|
|
DataFields := "ENTRY_ID" :@VM:SQL_Format(Rec(5), "STR"):@FM
|
|
DataFields := "ENTRY_DATE" :@VM:SQL_Format(Rec(6), "DATE"):@FM
|
|
DataFields := "PROD_SPEC_ID" :@VM:SQL_Format(Rec(7), "INT"):@FM
|
|
DataFields := "REQ_QUOTE_NUM" :@VM:SQL_Format(Rec(8), "STR"):@FM
|
|
DataFields := "TERMS" :@VM:SQL_Format(Rec(9), "STR"):@FM
|
|
DataFields := "STATUS" :@VM:SQL_Format(Rec(10), "STR"):@FM
|
|
DataFields := "EXP_DATE" :@VM:SQL_Format(Rec(11), "DATE"):@FM
|
|
// 12 N/A
|
|
// 13 - 17 below
|
|
DataFields := "COMMENTS" :@VM:SQL_Format(Rec(18), "STR", 1):@FM
|
|
DataFields := "SPEC_BILL_INST" :@VM:SQL_Format(Rec(19), "STR", 1):@FM
|
|
DataFields := "SPEC_SHIP_INST" :@VM:SQL_Format(Rec(20), "STR", 1):@FM
|
|
// 21 - 22 below
|
|
DataFields := "FINAL_LAYER" :@VM:SQL_Format(Rec(23), "BIT"):@FM
|
|
DataFields := "INQUIRY_STATUS" :@VM:SQL_Format(Rec(24), "STR"):@FM
|
|
DataFields := "SALES_COMMENTS" :@VM:SQL_Format(Rec(25), "STR"):@FM
|
|
DataFields := "QUOTE_OLD_ID" :@VM:SQL_Format(Rec(26), "INT"):@FM
|
|
DataFields := "PRIOR_QUOTE_ID" :@VM:SQL_Format(Rec(27), "INT"):@FM
|
|
// 28 below
|
|
DataFields := "QUOTE_TYPE" :@VM:SQL_Format(Rec(29), "STR"):@FM
|
|
DataFields := "OTHER_FOB_POINT" :@VM:SQL_Format(Rec(30), "STR"):@FM
|
|
DataFields := "EXP_DATE_WARN" :@VM:SQL_Format(Rec(31), "BIT"):@FM
|
|
// 32 - 34 below
|
|
// 35 N/A
|
|
// 36 - 40 below
|
|
DataFields := "NOTES" :@VM:SQL_Format(Rec(41), "STR"):@FM
|
|
DataFields := "PROC_DESC" :@VM:SQL_Format(Rec(42), "STR"):@FM
|
|
DataFields := "LABEL_DESC" :@VM:SQL_Format(Rec(43), "STR"):@FM
|
|
// 45 below
|
|
DataFields := "VISION_BILL_TO_CUST_NO" :@VM:SQL_Format(Rec(46), "STR"):@FM
|
|
DataFields := "COMM_INVOICE_UNIT_PRICE" :@VM:SQL_Format(Rec(47), "DEC", 2):@FM
|
|
DataFields := "COMM_INVOICE_REJ_UNIT_PRICE":@VM:SQL_Format(Rec(48), "DEC", 2)
|
|
// 49 - 54 below
|
|
|
|
// Write the data to the SQL database
|
|
Ans = SQL_Write(Connection, "QUOTE", Keys, DataFields)
|
|
|
|
//-------------------------------------------------------------------------------------------------
|
|
// Multi-valued Fields
|
|
|
|
If Ans EQ "" AND Rec(13) NE "" then
|
|
|
|
// Detail section
|
|
MvFields = "DETAIL":@FM:SQL_Format(Rec(13), "STR"):@RM
|
|
MvFields := "SETUP_CHARGE":@FM:SQL_Format(Rec(14), "DEC", "2"):@RM
|
|
MvFields := "QUANTITY":@FM:SQL_Format(Rec(15), "INT"):@RM
|
|
MvFields := "PRICE":@FM:SQL_Format(Rec(16), "DEC", "2"):@RM
|
|
MvFields := "SRP_CHARGE":@FM:SQL_Format(Rec(21), "DEC", "2"):@RM
|
|
MvFields := "DELIV_DATE":@FM:SQL_Format(Rec(22), "DATE"):@RM
|
|
MvFields := "EPI_PART_NO":@FM:SQL_Format(Rec(45), "STR")
|
|
|
|
// Write the data to the SQL database
|
|
Ans = SQL_Write_MV(Connection, "QUOTE_DETAILS", Keys, MvFields);
|
|
|
|
end
|
|
|
|
If Ans EQ "" AND Rec(32) NE "" then
|
|
|
|
// Procedure Steps Section
|
|
MvFields = "PROC_STEP":@FM:SQL_Format(Rec(32), "INT"):@RM
|
|
MvFields := "PROC_STEP_PSN":@FM:SQL_Format(Rec(33), "INT"):@RM
|
|
MvFields := "PROC_STEP_DESC":@FM:SQL_Format(Rec(34), "STR")
|
|
|
|
// Write the data to the SQL database
|
|
Ans = SQL_Write_MV(Connection, "QUOTE_PROC_STEPS", Keys, MvFields);
|
|
|
|
end
|
|
|
|
If Ans EQ "" AND Rec(28) NE "" then
|
|
|
|
// Previous production Spec IDs
|
|
MvFields = "PREV_PROD_SPEC_IDS":@FM:SQL_Format(Rec(28), "INT")
|
|
|
|
// Write the data to the SQL database
|
|
Ans = SQL_Write_MV(Connection, "QUOTE_PREV_PROC_SPECS", Keys, MvFields);
|
|
end
|
|
|
|
If Ans EQ "" AND Rec(17) NE "" then
|
|
|
|
// Signatures
|
|
MvFields = "SIGNATURES":@FM:SQL_Format(Rec(17), "STR")
|
|
|
|
// Write the data to the SQL database
|
|
Ans = SQL_Write_MV(Connection, "QUOTE_SIGNATURES", Keys, MvFields);
|
|
|
|
end
|
|
|
|
If Ans EQ "" AND Rec(51) NE "" then
|
|
|
|
// Comm Invoice Add section
|
|
MvFields = "COMM_INVOICE_ADD_ITEM_QTY":@FM:SQL_Format(Rec(50), "INT"):@RM
|
|
MvFields := "COMM_INVOICE_ADD_ITEM_DESC":@FM:SQL_Format(Rec(49), "STR"):@RM
|
|
MvFields := "COMM_INVOICE_ADD_ITEM_UNIT_pRICE":@FM:SQL_Format(Rec(51), "DEC", 2)
|
|
|
|
// Write the data to the SQL database
|
|
Ans = SQL_Write_MV(Connection, "QUOTE_COMM_INVOICE_ADD", Keys, MvFields);
|
|
|
|
end
|
|
|
|
|
|
If Ans EQ "" AND Rec(54) NE "" then
|
|
|
|
// Comm Invoice test section
|
|
MvFields = "COMM_INVOICE_TEST_WFR_QTY":@FM:SQL_Format(Rec(52), "INT"):@RM
|
|
MvFields := "COMM_INVOICE_TEST_WFR_DESC":@FM:SQL_Format(Rec(53), "STR"):@RM
|
|
MvFields := "COMM_INVOICE_TEST_WFR_UNIT_PRICE":@FM:SQL_Format(Rec(54), "DEC", 2)
|
|
|
|
// Write the data to the SQL database
|
|
Ans = SQL_Write_MV(Connection, "QUOTE_COMM_INVOICE_TEST", Keys, MvFields);
|
|
|
|
end
|
|
|
|
If Ans EQ "" AND Rec(36) NE "" then
|
|
|
|
// EXP_DT_CHANGE_LOG
|
|
MvFields = "ED_CHANGE_DT":@FM:SQL_Format(Rec(36), "DATE"):@RM
|
|
MvFields := "ED_CURR_EXP_DT":@FM:SQL_Format(Rec(37), "DATE"):@RM
|
|
MvFields := "ED_NEW_EXP_DT":@FM:SQL_Format(Rec(38), "DATE"):@RM
|
|
MvFields := "ED_CHANGE_BY":@FM:SQL_Format(Rec(39), "STR"):@RM
|
|
MvFields := "ED_COMMENTS":@FM:SQL_Format(Rec(40), "STR")
|
|
|
|
// Write the data to the SQL database
|
|
Ans = SQL_Write_MV(Connection, "QUOTE_EXP_DT_CHANGE_LOG", Keys, MvFields);
|
|
|
|
end
|
|
|
|
|
|
Return Ans
|