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.
Architecture
Thin WinForms client over raw MSSQL. No web service layer; printer logic runs locally on a workstation.
| File | Role |
|---|---|
Printing.vb | Main logic: receipt generation via Excel interop, print dispatch, printer loader. |
Connection.vb | SQL and Excel connection helpers, AES-decrypted connection strings. |
Form1.Designer.vb | WinForms shell embedding the receipt user control. |
so_print.resx | Resources/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)
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)
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()
PrinterSettings.PrinterName.switch_docs(type, group_location)
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)
getItem1(objectName, tableName, displayField, searchField)
queryItemOnDatabase(Database_Name, Table_Name, Lookup_Column, Resulting_Column, condition)
ExcelConnection(FileName, query)
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.
| Database | Purpose |
|---|---|
erpdata_new | SO header/detail for receipt population. |
mcjim_all_prog | Print flags, XZ header/detail, store mappings. |
barcode_data | Store company and territory lookups. |
Workflow
| Trigger | Action |
|---|---|
| User selects area | Loads printers / store group. |
| Batch SO button | Returns queued SOs, loops into generateReceipt across areas. |
| Batch XZ button | Returns queued XZOUTs, loops into xzout_receipt across areas. |
| After print | Updates SO flag c_print_flag = 'N' or XZ status c_status = 'P'/'E'. |