WebDocs · SO Printing

SO Printing Documentation

Legacy VB.NET Windows Forms app that generates and prints Sales Order (SO) and XZOUT receipts through Excel interop. It pulls live data from multiple MSSQL databases, formats into printable Excel sheets, and sends directly to area-based printers.

Receipt Printing
Generates SO and XZOUT Excel receipts for thermal/desktop printers.
Multi-DB
Reads from ERP, dashboard, and barcode databases live.
Area Printers
Routes output by store group/area: Area 1–4, MJ, etc.

Architecture

Thin WinForms client over raw MSSQL. No web service layer; printer logic runs locally on a workstation.

FileRole
Printing.vbMain logic: receipt generation via Excel interop, print dispatch, printer loader.
Connection.vbSQL and Excel connection helpers, AES-decrypted connection strings.
Form1.Designer.vbWinForms shell embedding the receipt user control.
so_print.resxResources/assets for the form.

Printing.vb

Core module. Opens Excel, styles cells, queries DB, populates headers/items/totals, prints, and updates print flags.

Key Subroutines

generateReceipt(SO_Number, Area_Location)
Builds an Excel workbook for one SO. Queries SO header/details from erpdata_new. Prints quantities, discounts, totals, salesman, source, and timestamp. Saves as SO_<Area>.xls and calls PrintOutEx() to the selected area printer.
xzout_receipt(xzout_number, Area_Location)
Builds an Excel XZOUT receipt. Reads xz_header, enumerates associated SOs/SRs, totals qty/gross/net, and certifies by salesman. Updates status to P on success, E on exception.
load_printers()
Populates printer dropdown with installed printers plus preset area groups. Default printer is PrinterSettings.PrinterName.
switch_docs(type, group_location)
Routes batch jobs between SO and XZ flows for a given store group.

Excel Styling

Custom styles: HeaderStyle, HeaderText, HeaderBold, Normaltext, soNum, strFnt, dtFnt. Fonts: FontA11, FontB22, Calibri. Column width and margins are tuned for thermal receipt paper.

Connection.vb

MSSQL helper with 3 named connection slots and AES-decrypted embedded credentials.

Helpers

connection1/2/3(query)
Runs a raw SQL string through SqlCommand on respective connection, fills DataSet.
getItem1(objectName, tableName, displayField, searchField)
Single-field lookup helper.
queryItemOnDatabase(Database_Name, Table_Name, Lookup_Column, Resulting_Column, condition)
Parameterized DB lookup across attached databases.
ExcelConnection(FileName, query)
OLEDB read against an Excel workbook.

Forms / UI

Single Form1 container hosting a nested so_print control.

Controls seen in Printing.vb: ComboBox1 printers, ComboBox2 area/location, CheckBox1/2, NumericUpDown1/2, Timer1, and two action buttons for SO batch and XZ batch.

Databases

Queries reference live databases directly. Connection strings are AES-encrypted in settings.

DatabasePurpose
erpdata_newSO header/detail for receipt population.
mcjim_all_progPrint flags, XZ header/detail, store mappings.
barcode_dataStore company and territory lookups.

Workflow

TriggerAction
User selects areaLoads printers / store group.
Batch SO buttonReturns queued SOs, loops into generateReceipt across areas.
Batch XZ buttonReturns queued XZOUTs, loops into xzout_receipt across areas.
After printUpdates SO flag c_print_flag = 'N' or XZ status c_status = 'P'/'E'.