Source code of file oscpmwin_v0.1.1.652/main.pas from the
osCommerce Product Manager for Windows.
0000: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001: osCommerce Product Manager for Windows (oscpmwin).
0002: Copyright �2003,2004,2005 by Mario A. Valdez-Ramirez.
0003:
0004: You can contact Mario A. Valdez-Ramirez
0005: by email at mario@mariovaldez.org or paper mail at
0006: Olmos 809, San Nicolas, NL. 66495, Mexico.
0007:
0008: This program is free software; you can redistribute it and/or modify
0009: it under the terms of the GNU General Public License as published by
0010: the Free Software Foundation; either version 2 of the License, or (at
0011: your option) any later version.
0012:
0013: This program is distributed in the hope that it will be useful, but
0014: WITHOUT ANY WARRANTY; without even the implied warranty of
0015: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0016: General Public License for more details.
0017:
0018: You should have received a copy of the GNU General Public License
0019: along with this program; if not, write to the Free Software
0020: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0021: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0022: UNIT main;
0023:
0024: INTERFACE
0025:
0026: USES
0027: Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
0028: ToolWin, ComCtrls, DB, ExtCtrls, Menus, StdCtrls, Grids,
0029: DBGrids, DBTables, ImgList, Buttons, clipbrd, oscpmdata, Dialogs, ShlObj, modules,
0030: FR_Class, FR_DSet;
0031:
0032: TYPE
0033: Topm_Form_Main = CLASS (TForm)
0034: N1: TMenuItem;
0035: N2: TMenuItem;
0036: N3: TMenuItem;
0037: N4: TMenuItem;
0038: N8: TMenuItem;
0039: opm_DBGrid_DEBUG: TDBGrid;
0040: opm_DataSource_DEBUG: TDataSource;
0041: opm_ImageList_List: TImageList;
0042: opm_ImageList_Status: TImageList;
0043: opm_ImageList_Tree: TImageList;
0044: opm_Image_Status: TImage;
0045: opm_ListView_Main: TListView;
0046: opm_MainMenu_Main: TMainMenu;
0047: opm_MenuItem_About: TMenuItem;
0048: opm_MenuItem_Catalog: TMenuItem;
0049: opm_MenuItem_Config: TMenuItem;
0050: opm_MenuItem_Connect: TMenuItem;
0051: opm_MenuItem_Database: TMenuItem;
0052: opm_MenuItem_Disconnect: TMenuItem;
0053: opm_MenuItem_Exit: TMenuItem;
0054: opm_MenuItem_Help: TMenuItem;
0055: opm_MenuItem_License: TMenuItem;
0056: opm_MenuItem_Product: TMenuItem;
0057: opm_MenuItem_ProductAdd: TMenuItem;
0058: opm_MenuItem_ProductCopyAsText: TMenuItem;
0059: opm_MenuItem_ProductDel: TMenuItem;
0060: opm_MenuItem_ProductEdit: TMenuItem;
0061: opm_MenuItem_ProductExport: TMenuItem;
0062: opm_MenuItem_ProductSelAll: TMenuItem;
0063: opm_MenuItem_RefreshCategories: TMenuItem;
0064: opm_MenuItem_RefreshProducts: TMenuItem;
0065: opm_MenuItem_SearchProduct: TMenuItem;
0066: opm_Panel_DEBUG: TPanel;
0067: opm_Panel_Main: TPanel;
0068: opm_PopMenuItem_CatCollapse2: TMenuItem;
0069: opm_PopMenuItem_CatCollapse: TMenuItem;
0070: opm_PopMenuItem_CatExpand2: TMenuItem;
0071: opm_PopMenuItem_CatExpand: TMenuItem;
0072: opm_PopMenuItem_ConnConn: TMenuItem;
0073: opm_PopMenuItem_ConnDisconn: TMenuItem;
0074: opm_PopMenuItem_HideDebug: TMenuItem;
0075: opm_PopMenuItem_PAdd: TMenuItem;
0076: opm_PopMenuItem_PAvailability: TMenuItem;
0077: opm_PopMenuItem_PAvailable: TMenuItem;
0078: opm_PopMenuItem_PCat: TMenuItem;
0079: opm_PopMenuItem_PCopyAsText: TMenuItem;
0080: opm_PopMenuItem_PDelete: TMenuItem;
0081: opm_PopMenuItem_PEdit: TMenuItem;
0082: opm_PopMenuItem_PExport: TMenuItem;
0083: opm_PopMenuItem_PMan: TMenuItem;
0084: opm_PopMenuItem_PMod: TMenuItem;
0085: opm_PopMenuItem_PModel: TMenuItem;
0086: opm_PopMenuItem_PNotAvailable: TMenuItem;
0087: opm_PopMenuItem_PPrice: TMenuItem;
0088: opm_PopMenuItem_PQuantity: TMenuItem;
0089: opm_PopMenuItem_PSelAll: TMenuItem;
0090: opm_PopMenuItem_PSpecial: TMenuItem;
0091: opm_PopMenuItem_PWeight: TMenuItem;
0092: opm_PopupMenu_CatList: TPopupMenu;
0093: opm_PopupMenu_Connection: TPopupMenu;
0094: opm_PopupMenu_Debug: TPopupMenu;
0095: opm_PopupMenu_PList: TPopupMenu;
0096: opm_ProgressBar_Main: TProgressBar;
0097: opm_ProgressBar_Sec: TProgressBar;
0098: opm_SaveDialog_Export: TSaveDialog;
0099: opm_Splitter_Debug: TSplitter;
0100: opm_Splitter_Main: TSplitter;
0101: opm_StatusBar_Main: TStatusBar;
0102: opm_TreeView_Main: TTreeView;
0103: opm_MenuItem_Tools: TMenuItem;
0104: opm_MenuItem_ExternalModules: TMenuItem;
0105: N7: TMenuItem;
0106: opm_PopMenuItem_CatRename: TMenuItem;
0107: opm_PopMenuItem_PPrint: TMenuItem;
0108: opm_MenuItem_ProductPrint: TMenuItem;
0109: opm_PrintDialog_Print: TPrintDialog;
0110: opm_frReport_ProdList: TfrReport;
0111: opm_frUserDataset_ProdList: TfrUserDataset;
0112: opm_PopMenuItem_PCopyAsPre: TMenuItem;
0113: opm_MenuItem_ProductCopyAsPre: TMenuItem;
0114: opm_MenuItem_ProductCopy: TMenuItem;
0115: opm_PopMenuItem_PCopy: TMenuItem;
0116: opm_PopMenuItem_CatDelete: TMenuItem;
0117: opm_PopMenuItem_CatAdd: TMenuItem;
0118: opm_ImageList_Toolbar: TImageList;
0119: opm_ToolBar_Main: TToolBar;
0120: opm_ToolButton_Connect: TToolButton;
0121: opm_ToolButton_Disconnect: TToolButton;
0122: opm_ToolButton_Config: TToolButton;
0123: opm_ToolButton_Refresh: TToolButton;
0124: opm_ToolButton_AddProduct: TToolButton;
0125: opm_ToolButton_EditProduct: TToolButton;
0126: opm_ToolButton_Search: TToolButton;
0127: opm_ToolButton_Sep3: TToolButton;
0128: opm_ToolButton_Sep4: TToolButton;
0129: opm_ToolButton_Sep6: TToolButton;
0130: opm_ToolButton_DeleteProduct: TToolButton;
0131: opm_Panel_ToolbarLanguage: TPanel;
0132: opm_ToolButton_Sep1: TToolButton;
0133: opm_ComboBox_DisplayLang: TComboBox;
0134: opm_ToolButton_Exit: TToolButton;
0135: opm_ToolButton_ExportProduct: TToolButton;
0136: opm_ToolButton_PrintProduct: TToolButton;
0137: opm_ToolButton_AddCat: TToolButton;
0138: opm_ToolButton_RenCat: TToolButton;
0139: opm_ToolButton_DelCat: TToolButton;
0140: opm_ToolButton_Sep2: TToolButton;
0141: N5: TMenuItem;
0142: opm_MenuItem_CategoryAdd: TMenuItem;
0143: opm_MenuItem_CategoryDelete: TMenuItem;
0144: opm_MenuItem_CategoryRename: TMenuItem;
0145: opm_ImageList_MainMenu: TImageList;
0146: opm_Panel_ToolbarQuickSearch: TPanel;
0147: Sep7: TToolButton;
0148: opm_Edit_QuickSearch: TEdit;
0149: opm_SpeedButton_QuickSearch: TSpeedButton;
0150: opm_MenuItem_CheckUpdates: TMenuItem;
0151: N6: TMenuItem;
0152: N9: TMenuItem;
0153: opm_MenuItem_ManAdd: TMenuItem;
0154: opm_MenuItem_ManDelete: TMenuItem;
0155: opm_MenuItem_ManRename: TMenuItem;
0156: opm_MenuItem_Backup: TMenuItem;
0157: procedure FormClose(Sender: TObject; var Action: TCloseAction);
0158: procedure FormCreate(Sender: TObject);
0159: procedure opm_ComboBox_DisplayLangSelect(Sender: TObject);
0160: procedure opm_ListView_MainDblClick(Sender: TObject);
0161: procedure opm_MenuItem_AboutClick(Sender: TObject);
0162: procedure opm_MenuItem_ConfigClick(Sender: TObject);
0163: procedure opm_MenuItem_ConnectClick(Sender: TObject);
0164: procedure opm_MenuItem_DisconnectClick(Sender: TObject);
0165: procedure opm_MenuItem_ExitClick(Sender: TObject);
0166: procedure opm_MenuItem_LicenseClick(Sender: TObject);
0167: procedure opm_MenuItem_RefreshCategoriesClick(Sender: TObject);
0168: procedure opm_MenuItem_RefreshProductsClick(Sender: TObject);
0169: procedure opm_MenuItem_SearchProductClick(Sender: TObject);
0170: procedure opm_PopMenuItem_CatCollapse2Click(Sender: TObject);
0171: procedure opm_PopMenuItem_CatCollapseClick(Sender: TObject);
0172: procedure opm_PopMenuItem_CatExpand2Click(Sender: TObject);
0173: procedure opm_PopMenuItem_CatExpandClick(Sender: TObject);
0174: procedure opm_PopMenuItem_HideDebugClick(Sender: TObject);
0175: procedure opm_PopMenuItem_PAddClick(Sender: TObject);
0176: procedure opm_PopMenuItem_PAvailableClick(Sender: TObject);
0177: procedure opm_PopMenuItem_PCatClick(Sender: TObject);
0178: procedure opm_PopMenuItem_PCopyAsTextClick(Sender: TObject);
0179: procedure opm_PopMenuItem_PDeleteClick(Sender: TObject);
0180: procedure opm_PopMenuItem_PExportClick(Sender: TObject);
0181: procedure opm_PopMenuItem_PManClick(Sender: TObject);
0182: procedure opm_PopMenuItem_PModelClick(Sender: TObject);
0183: procedure opm_PopMenuItem_PNotAvailableClick(Sender: TObject);
0184: procedure opm_PopMenuItem_PPriceClick(Sender: TObject);
0185: procedure opm_PopMenuItem_PQuantityClick(Sender: TObject);
0186: procedure opm_PopMenuItem_PSelAllClick(Sender: TObject);
0187: procedure opm_PopMenuItem_PSpecialClick(Sender: TObject);
0188: procedure opm_PopMenuItem_PWeightClick(Sender: TObject);
0189: procedure opm_TreeView_MainChange(Sender: TObject; Node: TTreeNode);
0190: procedure opm_TreeView_MainCollapsing(Sender: TObject; Node: TTreeNode; var AllowCollapse: Boolean);
0191: procedure opm_TreeView_MainContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean);
0192: procedure opm_TreeView_MainDblClick(Sender: TObject);
0193: procedure opm_TreeView_MainDragDrop(Sender, Source: TObject; X, Y: Integer);
0194: procedure opm_TreeView_MainDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
0195: procedure opm_TreeView_MainExpanding(Sender: TObject; Node: TTreeNode; var AllowExpansion: Boolean);
0196: procedure opm_TreeView_MainKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
0197: procedure opm_TreeView_MainKeyPress(Sender: TObject; var Key: Char);
0198: procedure opm_MenuItem_ExternalModulesClick(Sender: TObject);
0199: procedure opm_PopMenuItem_CatRenameClick(Sender: TObject);
0200: procedure opm_TreeView_MainMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
0201: procedure opm_ListView_MainColumnClick(Sender: TObject; Column: TListColumn);
0202: procedure opm_PopMenuItem_PPrintClick(Sender: TObject);
0203: procedure opm_frReport_ProdListGetValue(const ParName: String; var ParValue: Variant);
0204: procedure opm_frUserDataset_ProdListCheckEOF(Sender: TObject; var Eof: Boolean);
0205: procedure opm_frUserDataset_ProdListFirst(Sender: TObject);
0206: procedure opm_frUserDataset_ProdListNext(Sender: TObject);
0207: procedure opm_PopMenuItem_PCopyAsPreClick(Sender: TObject);
0208: procedure FormShow(Sender: TObject);
0209: procedure opm_PopMenuItem_CatDeleteClick(Sender: TObject);
0210: procedure opm_PopMenuItem_CatAddClick(Sender: TObject);
0211: procedure opm_ListView_MainKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
0212: procedure opm_ListView_MainChange(Sender: TObject; Item: TListItem; Change: TItemChange);
0213: procedure opm_SpeedButton_QuickSearchClick(Sender: TObject);
0214: procedure opm_Edit_QuickSearchKeyPress(Sender: TObject; var Key: Char);
0215: procedure opm_MenuItem_CheckUpdatesClick(Sender: TObject);
0216: procedure opm_MenuItem_ManAddClick(Sender: TObject);
0217: procedure opm_MenuItem_ManRenameClick(Sender: TObject);
0218: procedure opm_MenuItem_ManDeleteClick(Sender: TObject);
0219: procedure opm_MenuItem_BackupClick(Sender: TObject);
0220: private
0221: FUNCTION FNopm_Apply_Operation (SourceValue, Conversion: STRING; ValueType : INTEGER; AllowNegative : BOOLEAN) : STRING;
0222: FUNCTION FNopm_GetProductByID (ProdID, LangID : LONGINT; VAR ProdList : opmT_ProductList) : opmR_Product;
0223: FUNCTION FNopm_GetRealLangIDByIndex (VAR LangList : opmT_LanguageList; LangIndex : LONGINT) : LONGINT;
0224: PROCEDURE PRopm_Update_StatusBar (ConnectedStat, ProgressStat, SecProgress : LONGINT; StatusString : STRING; ProductTotal : LONGINT; CurCurr : STRING);
0225: PROCEDURE PRopm_AddCatTreeNode (VAR CatList : opmT_CategoryList; CatCurrentID : LONGINT; CurNode : TTreeNode; TreeDepth : INTEGER);
0226: PROCEDURE PRopm_AddProduct (NewProdRecord : opmR_Product; SingleDescList : opmT_SingleDescList);
0227: PROCEDURE PRopm_ClearCategoryList (VAR CatList : TStringList);
0228: PROCEDURE PRopm_ClearLanguageList (VAR LangList : TStringList);
0229: PROCEDURE PRopm_ClearManufacturerList (VAR ManList : TStringList);
0230: PROCEDURE PRopm_ClearProductList (VAR ListView : TListView);
0231: PROCEDURE PRopm_ClearTaxList (VAR TaxList : TStringList);
0232: PROCEDURE PRopm_Disconnect;
0233: PROCEDURE PRopm_Create_ExportList (VAR ExportString : STRING; VAR CatList : opmT_CategoryList; VAR ManList : opmT_ManufacturerList; JustifyCols : BOOLEAN);
0234: PROCEDURE PRopm_DeleteProduct (ProdID : LONGINT);
0235: PROCEDURE PRopm_LoadCategoryBoxList (VAR CatList : opmT_CategoryList; CatCurrentID, TreeDepth : LONGINT; VAR CatIndex : LONGINT; VAR CatBoxList : TStringList);
0236: PROCEDURE PRopm_LoadCategoryList (VAR CatList : opmT_CategoryList; VAR CatBoxList : TStringList);
0237: PROCEDURE PRopm_LoadConfiguration;
0238: PROCEDURE PRopm_LoadLanguageList (VAR LangList : opmT_LanguageList);
0239: PROCEDURE PRopm_LoadManufacturerList (VAR ManList : opmT_ManufacturerList; VAR ManBoxList : TStringList);
0240: PROCEDURE PRopm_LoadProductListByCat (ProductCat : LONGINT; VAR ProdList : opmT_ProductList; VAR DescList : opmT_DescriptionList);
0241: PROCEDURE PRopm_LoadTaxList (VAR TaxList : opmT_TaxList; VAR TaxBoxList : TStringList);
0242: PROCEDURE PRopm_Connect;
0243: PROCEDURE PRopm_RenderCategoryDisplay (VAR CatList : opmT_CategoryList; VAR TreeControl : TTreeView; CurCatID : LONGINT);
0244: PROCEDURE PRopm_RenderLanguageDisplay (VAR ListControl : TComboBox; VAR LangList : opmT_LanguageList);
0245: PROCEDURE PRopm_RenderProductDisplay (VAR CatList : opmT_CategoryList; VAR ManList : opmT_ManufacturerList; VAR ProdList : opmT_ProductList; VAR ListControl : TListView; CurProdID : LONGINT);
0246: PROCEDURE PRopm_SaveConfiguration;
0247: PROCEDURE PRopm_SearchProducts (PCategory, PManufacturer: LONGINT; PModel, PName, PDesc : STRING; PSPrice, PImgURL, PAvailable : LONGINT; VAR ProdList : opmT_ProductList; VAR DescList : opmT_DescriptionList; MultiString : STRING);
0248: PROCEDURE PRopm_SetControls_Disconnected;
0249: PROCEDURE PRopm_SetDisplay (RememberVisual : WORD);
0250: PROCEDURE PRopm_SetControls_FullConnected;
0251: PROCEDURE PRopm_SetUnknown;
0252: PROCEDURE PRopm_UpdateProdData (ProdID : LONGINT; ProdTable, ProdField, ProdDataStr : STRING; PDataIsNum : BOOLEAN; SecIDField, SecIDData : STRING; SQLQueryType : INTEGER);
0253: PROCEDURE PRopm_UpdateProduct (CurProdRecord, NewProdRecord : opmR_Product; SingleDescList : opmT_SingleDescList);
0254: PROCEDURE PRopm_UpdateCatName (CatData : opmT_SingleCatList; TotalCats : LONGINT);
0255: PROCEDURE PRopm_AddCategory (CatData : opmT_SingleCatList; TotalCats : LONGINT; ParentCat : LONGINT);
0256: PROCEDURE PRopm_DeleteCategory (CatID : LONGINT);
0257: PROCEDURE PRopm_ResetVars;
0258: PROCEDURE PRopm_Valid_CatOps (WeAreConnected : BOOLEAN; SelectedCat : TTreeNode);
0259: PROCEDURE PRopm_Valid_ProdOps (WeAreConnected : BOOLEAN; SelectedProduct : TListItem; SelectedProds : LONGINT; SelectedCat : TTreeNode);
0260: PROCEDURE PRopm_Valid_GralOps (WeAreConnected : BOOLEAN);
0261: FUNCTION FNopm_LoadCurrency : opmR_Currency;
0262: FUNCTION FNopm_ClearCurrency : opmR_Currency;
0263: PROCEDURE QuickSearch (QSString : STRING);
0264: public
0265: FUNCTION FNopm_GetCategory (VAR CatList : opmT_CategoryList; CatID : LONGINT; SearchBy : INTEGER) : opmR_Category;
0266: FUNCTION FNopm_GetManufacturer (VAR ManList : opmT_ManufacturerList; ManID : LONGINT; SearchBy : INTEGER) : opmR_Manufacturer;
0267: FUNCTION FNopm_GetDescriptionByID (ProdID, LangID : LONGINT; VAR DescList : opmT_DescriptionList) : opmR_Description;
0268: PROCEDURE PRopm_SetUILang (LangISOID : STRING);
0269: FUNCTION FNopm_Create_ExchangeList (VAR ExchangeList : opmT_ExchangeList; IndexData, TargetData : STRING) : LONGINT;
0270: PROCEDURE PRopm_Reload_ProductList (SearchLoad : BOOLEAN);
0271: PROCEDURE PRopm_GetCategory_Data (CatID : LONGINT; VAR CatData : opmT_SingleCatList);
0272: end;
0273:
0274:
0275: var
0276: opm_Form_Main: Topm_Form_Main;
0277:
0278:
0279: FUNCTION FNopm_Sort_ProductList (Item1, Item2: TListItem; Column: INTEGER) : INTEGER; STDCALL;
0280:
0281: implementation
0282:
0283: USES gnugettext, config, license, about, pedit, pimgzoom, search, askuser,
0284: balloons, regconfig, attention, dataman, network, askupload, imageman, runmod,
0285: colorsel, printers, strutils, math, askcat, ShellApi;
0286:
0287: {$R *.dfm}
0288:
0289:
0290:
0291: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0292: Enable/disable those controls valid when the client is
0293: connected and the product list is downloaded.
0294: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0295: PROCEDURE Topm_Form_Main.PRopm_SetControls_FullConnected;
0296: BEGIN
0297: IF (opmG_UseSSH > 0) THEN
0298: PRopm_Update_StatusBar (opmC_ConnStatYesSSH, opmC_ProgressIgnore, opmC_ProgressIgnore, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code)
0299: ELSE
0300: PRopm_Update_StatusBar (opmC_ConnStatYes, opmC_ProgressIgnore, opmC_ProgressIgnore, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
0301: opm_ListView_Main.Enabled := TRUE;
0302: opm_TreeView_Main.Enabled := TRUE;
0303: opm_ComboBox_DisplayLang.Enabled := TRUE;
0304: opm_WeAreConnected := TRUE;
0305: PRopm_Valid_GralOps (opm_WeAreConnected);
0306: PRopm_Valid_CatOps (opm_WeAreConnected, NIL);
0307: PRopm_Valid_ProdOps (opm_WeAreConnected, NIL, 0, NIL);
0308: END;
0309:
0310:
0311: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0312: Enable/disable those controls valid when the client is
0313: disconnected.
0314: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0315: PROCEDURE Topm_Form_Main.PRopm_SetControls_Disconnected;
0316: BEGIN
0317: PRopm_Update_StatusBar (opmC_ConnStatNo, opmC_ProgressIgnore, opmC_ProgressIgnore, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
0318: opm_ListView_Main.Enabled := FALSE;
0319: opm_TreeView_Main.Enabled := FALSE;
0320: opm_ComboBox_DisplayLang.Enabled := FALSE;
0321: opm_WeAreConnected := FALSE;
0322: PRopm_Valid_GralOps (opm_WeAreConnected);
0323: PRopm_Valid_CatOps (opm_WeAreConnected, NIL);
0324: PRopm_Valid_ProdOps (opm_WeAreConnected, NIL, 0, NIL);
0325: END;
0326:
0327:
0328: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0329: Enable/disable those controls valid when the the state
0330: of the client connection is unknown (or waiting for a
0331: connection).
0332: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0333: PROCEDURE Topm_Form_Main.PRopm_SetUnknown;
0334: BEGIN
0335: PRopm_Update_StatusBar (opmC_ConnStatUnknown, opmC_ProgressIgnore, opmC_ProgressIgnore, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
0336: opm_ListView_Main.Enabled := FALSE;
0337: opm_TreeView_Main.Enabled := FALSE;
0338: PRopm_Valid_GralOps (opm_WeAreConnected);
0339: PRopm_Valid_CatOps (opm_WeAreConnected, NIL);
0340: PRopm_Valid_ProdOps (opm_WeAreConnected, NIL, 0, NIL);
0341: END;
0342:
0343:
0344: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0345: Open a connection to the database server.
0346: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0347: PROCEDURE Topm_Form_Main.PRopm_Connect;
0348: VAR
0349: StrResult : STRING;
0350: BEGIN
0351: StrResult := '';
0352: PRopm_SetUnknown;
0353: IF (opmG_DBStorePass = 0) THEN
0354: BEGIN
0355: opm_Form_AskUser.AU_Title := _('Connecting to database...');
0356: opm_Form_AskUser.AU_Directions := _('Enter the database password');
0357: opm_Form_AskUser.AU_TextOrList := TRUE;
0358: opm_Form_AskUser.AU_PassChar := opmC_PasswordChar;
0359: opm_Form_AskUser.AU_MaxLen := opmC_DBPassword_MaxLen;
0360: opm_Form_AskUser.AU_DataText := opmG_DBPassword;
0361: IF (opm_Form_AskUser.ShowModal = mrOk) THEN opmG_DBPassword := opm_Form_AskUser.AU_DataText ELSE opmG_DBPassword := '';
0362: opm_Form_AskUser.AU_Title := _('Connecting to database...');
0363: opm_Form_AskUser.AU_Directions := _('Enter the SSH password');
0364: opm_Form_AskUser.AU_TextOrList := TRUE;
0365: opm_Form_AskUser.AU_PassChar := opmC_PasswordChar;
0366: opm_Form_AskUser.AU_MaxLen := opmC_DBPassword_MaxLen;
0367: opm_Form_AskUser.AU_DataText := opmG_SSHPassword;
0368: IF (opm_Form_AskUser.ShowModal = mrOk) THEN opmG_SSHPassword := opm_Form_AskUser.AU_DataText ELSE opmG_SSHPassword := '';
0369: END;
0370: Screen.Cursor := opmC_Wait_Mouse;
0371: IF (opmG_UseSSH > 0) THEN
0372: BEGIN
0373: IF (FNopm_CheckStallTunnel = TRUE) THEN
0374: BEGIN
0375: IF (FNopm_Message (_('It seems there is already a SSH encrypted tunnel. Do you want to close it before creating a new one?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes) THEN
0376: PRopm_StopExternalAppByName (opmC_Def_SSHExe);
0377: END;
0378: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressIgnore, opmC_ProgressIgnore, _('Creating SSH encrypted tunnel...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
0379: IF (FNopm_OpenSSHTunnel (opmC_Def_SSHLocalHost, opmG_DBHost, opmG_SSHLocalPort, opmG_DBPort, opmG_SSHUsername, opmG_SSHPassword, opmG_UISSHDebug) = FALSE) THEN
0380: StrResult := _('Cannot connect SSH encrypted tunnel.');
0381: END;
0382: IF (StrResult = '') THEN
0383: IF (opmG_UseSSH > 0) THEN
0384: BEGIN
0385: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressIgnore, opmC_ProgressIgnore, _('Connecting to database server...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
0386: StrResult := FNopm_OpenDBConnection (opmC_Def_SSHLocalHost, opmC_Def_SSHLocalPort, opmG_DBProtocol, opmG_DBDatabase, opmG_DBUsername, opmG_DBPassword, opmG_DBCompress);
0387: IF (StrResult <> '') THEN PRopm_CloseSSHTunnel;
0388: END
0389: ELSE
0390: BEGIN
0391: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressIgnore, opmC_ProgressIgnore, _('Connecting to database server...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
0392: StrResult := FNopm_OpenDBConnection (opmG_DBHost, opmG_DBPort, opmG_DBProtocol, opmG_DBDatabase, opmG_DBUsername, opmG_DBPassword, opmG_DBCompress);
0393: END;
0394: Screen.Cursor := opmC_Normal_Mouse;
0395: IF (StrResult = '') THEN
0396: BEGIN
0397: PRopm_ResetVars;
0398: {PRopm_SetControls_FullConnected;}
0399: END
0400: ELSE
0401: BEGIN
0402: PRopm_SetControls_Disconnected;
0403: FNopm_Message (StrResult, mtError, [mbOk], opmG_UISilent);
0404: END;
0405: END;
0406:
0407:
0408: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0409: Closes the connection to the database server.
0410: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0411: PROCEDURE Topm_Form_Main.PRopm_Disconnect;
0412: VAR
0413: StrResult : STRING;
0414: BEGIN
0415: PRopm_SetUnknown;
0416: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressIgnore, opmC_ProgressIgnore, _('Disconnecting to database server...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
0417: Screen.Cursor := opmC_Wait_Mouse;
0418: StrResult := FNopm_CloseDBConnection;
0419: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressIgnore, opmC_ProgressIgnore, _('Disconnecting SSH encrypted tunnel...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
0420: PRopm_CloseSSHTunnel;
0421: Screen.Cursor := opmC_Normal_Mouse;
0422: PRopm_Update_StatusBar (opmC_ConnStatNo, opmC_ProgressNone, opmC_ProgressNone, _('Disconnected from database server.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
0423: PRopm_SetControls_Disconnected;
0424: PRopm_ResetVars;
0425: IF (StrResult <> '') THEN FNopm_Message (StrResult, mtError, [mbOk], opmG_UISilent);
0426: END;
0427:
0428: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0429: Takes a source value, a target conversion value, and a value type.
0430: Then applies the operation or target value to the source value and
0431: return the result (in an integer or currency type according to the
0432: value type). The target values can be simple numbers or operations.
0433: A simple value will simply overwrite the source value with the target
0434: one. An operation will transform the source value. Valid operations
0435: are addition (+X), substraction (-X), percetage increase (+X%),
0436: percentage decrease (-X%).
0437: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0438: FUNCTION Topm_Form_Main.FNopm_Apply_Operation (SourceValue, Conversion : STRING;
0439: ValueType : INTEGER; AllowNegative : BOOLEAN) : STRING;
0440: VAR
0441: TmpOperand, TmpSource, TmpTarget : CURRENCY;
0442: TmpValue : STRING;
0443: BEGIN
0444: TmpValue := FNopm_CleanNumber (Conversion, opmC_ValIsNumOp);
0445: TmpOperand := STRTOCURR (FNopm_CleanNumber (Conversion, opmC_ValIsFloat));
0446: TmpSource := STRTOCURR (FNopm_CleanNumber (SourceValue, opmC_ValIsFloat));
0447: IF (TmpValue[LENGTH (TmpValue)] = '%') THEN
0448: BEGIN
0449: TmpOperand := (TmpSource / 100) * TmpOperand;
0450: END;
0451: IF ((TmpValue[1] = '-') OR (TmpValue[1] = '+')) THEN
0452: BEGIN
0453: TmpTarget := TmpSource + TmpOperand;
0454: IF (AllowNegative = FALSE) THEN IF (TmpTarget < 0) THEN TmpTarget := 0;
0455: END
0456: ELSE
0457: BEGIN
0458: TmpTarget := ABS (TmpOperand);
0459: END;
0460: IF (ValueType = opmC_ValIsInteger) THEN
0461: BEGIN
0462: FNopm_Apply_Operation := INTTOSTR (ROUND (TmpTarget));
0463: END
0464: ELSE
0465: BEGIN
0466: FNopm_Apply_Operation := FloatToStrF (TmpTarget, ffFixed, 15, 2);
0467: END;
0468: END;
0469:
0470:
0471: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0472: Shows the configuration form and then check if any values were
0473: changed (in the global configuration vars) to apply those changes
0474: to the user interface.
0475: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0476: procedure Topm_Form_Main.opm_MenuItem_ConfigClick(Sender: TObject);
0477: begin
0478: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Configuring...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
0479: IF (opm_Form_Config.ShowModal = mrOk) THEN
0480: BEGIN
0481: IF (opmG_UIDragDrop > 0) THEN
0482: opm_ListView_Main.DragMode := dmAutomatic
0483: ELSE
0484: opm_ListView_Main.DragMode := dmManual;
0485: PRopm_SetUILang (opmG_UIGUILang);
0486: PRmvHint_EnableHints ((opmG_UIToolTips > 0));
0487: IF (opmG_UIDBDebug > 0) THEN
0488: BEGIN
0489: opm_DataSource_DEBUG.Enabled := TRUE;
0490: opm_DBGrid_DEBUG.Enabled := TRUE;
0491: opm_DBGrid_DEBUG.Visible := TRUE;
0492: opm_Panel_DEBUG.Visible := TRUE;
0493: END
0494: ELSE
0495: BEGIN
0496: opm_DataSource_DEBUG.Enabled := FALSE;
0497: opm_DBGrid_DEBUG.Enabled := FALSE;
0498: opm_DBGrid_DEBUG.Visible := FALSE;
0499: opm_Panel_DEBUG.Visible := FALSE;
0500: END;
0501: IF (opmG_UIWBDebug > 0) THEN
0502: BEGIN
0503: opm_Form_PEdit.opm_Memo_UploadDEBUG.Enabled := TRUE;
0504: opm_Form_PEdit.opm_Memo_UploadDEBUG.Visible := TRUE;
0505: END
0506: ELSE
0507: BEGIN
0508: opm_Form_PEdit.opm_Memo_UploadDEBUG.Enabled := FALSE;
0509: opm_Form_PEdit.opm_Memo_UploadDEBUG.Visible := FALSE;
0510: END;
0511: END;
0512: opm_PRAddModules_ToMenu (opm_MenuItem_ExternalModules);
0513: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Configuration done.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
0514: end;
0515:
0516: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0517: Terminates the application.
0518: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0519: procedure Topm_Form_Main.opm_MenuItem_ExitClick(Sender: TObject);
0520: begin
0521: Close;
0522: end;
0523:
0524: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0525: Opens the DB connection, load the language, category and manufacturer
0526: lists in memory, build the language menu and the category tree,
0527: clears the product list and enable some controls.
0528: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0529: procedure Topm_Form_Main.opm_MenuItem_ConnectClick(Sender: TObject);
0530: VAR
0531: ResStr : STRING;
0532: begin
0533: IF (FNopm_Send_Command (opmG_WBUploadURL, 'capa', '', ResStr)) THEN
0534: BEGIN
0535: opmG_Capa_MorePics6 := (POS (opmC_Capa_MorePics6, ResStr) > 0);
0536: opmG_Capa_TotalB2B := (POS (opmC_Capa_TotalB2B, ResStr) > 0);
0537: opmG_Capa_PollBooth := (POS (opmC_Capa_PollBooth, ResStr) > 0);
0538: opmG_Capa_HeaderTags := (POS (opmC_Capa_HeaderTags, ResStr) > 0);
0539: END
0540: ELSE
0541: BEGIN
0542: opmG_Capa_MorePics6 := FALSE;
0543: opmG_Capa_TotalB2B := FALSE;
0544: opmG_Capa_PollBooth := FALSE;
0545: opmG_Capa_HeaderTags := FALSE;
0546: FNopm_Message (_('There was an error while trying to get the osCommerce addons list. Assuming the store is a plain osCommerce store.'), mtWarning, [mbOk], opmG_UISilent);
0547: END;
0548: PRopm_Connect;
0549: IF (FNopm_ConnectionState = TRUE) THEN
0550: BEGIN
0551: PRopm_LoadLanguageList (opmG_LanguageList);
0552: PRopm_LoadCategoryList (opmG_CategoryList, opmG_CategoryBoxList);
0553: PRopm_LoadManufacturerList (opmG_ManufacturerList, opmG_ManufacturerBoxList);
0554: PRopm_LoadTaxList (opmG_TaxList, opmG_TaxBoxList);
0555: opm_CurrentCurrency := FNopm_LoadCurrency;
0556: PRopm_RenderLanguageDisplay (opm_ComboBox_DisplayLang, opmG_LanguageList);
0557: PRopm_RenderCategoryDisplay (opmG_CategoryList, opm_TreeView_Main, opm_CurrentCategory);
0558: PRopm_ClearProductList (opm_ListView_Main);
0559: PRopm_SetControls_FullConnected;
0560: END;
0561: end;
0562:
0563:
0564: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0565: Closes the DB connection, clear the language, category, manufacturer
0566: and product lists, clear the display of the language menu, product list
0567: and category tree, and enable some controls.
0568: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0569: procedure Topm_Form_Main.opm_MenuItem_DisconnectClick(Sender: TObject);
0570: begin
0571: PRopm_Disconnect;
0572: IF (FNopm_ConnectionState = FALSE) THEN
0573: BEGIN
0574: PRopm_ClearLanguageList (opmG_LanguageBoxList);
0575: PRopm_ClearCategoryList (opmG_CategoryBoxList);
0576: PRopm_ClearManufacturerList (opmG_ManufacturerBoxList);
0577: PRopm_ClearTaxList (opmG_TaxBoxList);
0578: opm_CurrentCurrency := FNopm_ClearCurrency;
0579: PRopm_ClearProductList (opm_ListView_Main);
0580: PRopm_RenderLanguageDisplay (opm_ComboBox_DisplayLang, opmG_LanguageList);
0581: PRopm_RenderCategoryDisplay (opmG_CategoryList, opm_TreeView_Main, opm_CurrentCategory);
0582: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
0583: opmG_Capa_MorePics6 := FALSE;
0584: opmG_Capa_TotalB2B := FALSE;
0585: opmG_Capa_PollBooth := FALSE;
0586: opmG_Capa_HeaderTags := FALSE;
0587: END;
0588: end;
0589:
0590:
0591: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0592: Creates some objects, load the configuration from the Windows registry,
0593: reset all vars, set several parameters of the visual components,
0594: set the language of the user interface.
0595: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0596: procedure Topm_Form_Main.FormCreate(Sender: TObject);
0597: begin
0598: opmG_TMPPath := FNopm_GetTemporaryPath;
0599: opm_DataSource_DEBUG.DataSet := opmG_DBQuery;
0600: opm_CurrentLang := 0;
0601: PRopm_LoadConfiguration;
0602: PRopm_ResetVars;
0603: PRopm_ResetLog;
0604: PRopm_SetDisplay (opmG_UIRememberDisplay);
0605: PRopm_SetControls_Disconnected;
0606: opm_PRLoad_ModuleList;
0607: opm_PRAddModules_ToMenu (opm_MenuItem_ExternalModules);
0608: IF (FNopm_CheckLanguage (opmG_UIGUILang) = FALSE) THEN UseLanguage (opmC_Def_GUILang) ELSE UseLanguage (opmG_UIGUILang);
0609: TP_GlobalIgnoreClass(TField);
0610: TP_GlobalIgnoreClass(TDBGrid);
0611: TranslateComponent (self);
0612: PRmvHint_EnableHints (opmG_UIToolTips > 0);
0613: end;
0614:
0615:
0616: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0617: Resets some variables used to keep track of the product information.
0618: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0619: PROCEDURE Topm_Form_Main.PRopm_ResetVars;
0620: BEGIN
0621: opm_TotalCategories := 0;
0622: opm_TotalManufacturers := 0;
0623: opm_TotalLanguages := 0;
0624: opm_TotalProducts := 0;
0625: opm_TotalTaxes := 0;
0626: opm_CurrentCategory := 0;
0627: opm_CurrentMan := 0;
0628: opm_CurrentProdID := 0;
0629: opm_Search_PCategory := 0;
0630: opm_Search_PManufacturer := 0;
0631: opm_Search_PModel := '';
0632: opm_Search_PName := '';
0633: opm_CanExpandTree_Flag := TRUE;
0634: opm_WeAreSearching := FALSE;
0635: opm_WeAreConnected := FALSE;
0636: opmG_PList_LastOrderColumn := 4;
0637: opmG_PList_LastOrderType := FALSE;
0638: END;
0639:
0640:
0641:
0642: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0643: Loads the configuration options from the Windows registry.
0644: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0645: PROCEDURE Topm_Form_Main.PRopm_LoadConfiguration;
0646: BEGIN
0647: opmG_DBHost := FNopm_CleanHostName (FNReg_ReadSetting ('OSCHost', opmC_Def_Host, opmC_RegistryKey, opmC_RKConfig));
0648: opmG_DBPort := FNopm_StrToInt (FNReg_ReadSetting ('OSCPort', INTTOSTR (opmC_Def_Port), opmC_RegistryKey, opmC_RKConfig));
0649: opmG_DBProtocol := FNReg_ReadSetting ('OSCProtocol', opmC_Def_Protocol, opmC_RegistryKey, opmC_RKConfig);
0650: opmG_ETABase := FNopm_StrToInt (FNReg_ReadSetting ('OSCETABase', opmC_Def_ETABase, opmC_RegistryKey, opmC_RKConfig));
0651: opmG_DBDatabase := FNReg_ReadSetting ('OSCDatabase', opmC_Def_Database, opmC_RegistryKey, opmC_RKConfig);
0652: opmG_DBTable_Categories := FNReg_ReadSetting ('OSCTable01', opmC_Def_DBTable_Categories, opmC_RegistryKey, opmC_RKConfig);
0653: opmG_DBTable_Manufacturers := FNReg_ReadSetting ('OSCTable02', opmC_Def_DBTable_Manufacturers, opmC_RegistryKey, opmC_RKConfig);
0654: opmG_DBTable_Languages := FNReg_ReadSetting ('OSCTable03', opmC_Def_DBTable_Languages, opmC_RegistryKey, opmC_RKConfig);
0655: opmG_DBTable_Products := FNReg_ReadSetting ('OSCTable04', opmC_Def_DBTable_Products, opmC_RegistryKey, opmC_RKConfig);
0656: opmG_DBTable_Specials := FNReg_ReadSetting ('OSCTable05', opmC_Def_DBTable_Specials, opmC_RegistryKey, opmC_RKConfig);
0657: opmG_DBTable_ProductsDescription := FNReg_ReadSetting ('OSCTable06', opmC_Def_DBTable_ProductsDescription, opmC_RegistryKey, opmC_RKConfig);
0658: opmG_DBTable_TaxClass := FNReg_ReadSetting ('OSCTable07', opmC_Def_DBTable_TaxClass, opmC_RegistryKey, opmC_RKConfig);
0659: opmG_DBTable_Currencies := FNReg_ReadSetting ('OSCTable08', opmC_Def_DBTable_Currencies, opmC_RegistryKey, opmC_RKConfig);
0660: opmG_DBTable_Configuration := FNReg_ReadSetting ('OSCTable09', opmC_Def_DBTable_Configuration, opmC_RegistryKey, opmC_RKConfig);
0661: opmG_DBTable_ProductsToCategories := FNReg_ReadSetting ('OSCTable10', opmC_Def_DBTable_ProductsToCategories, opmC_RegistryKey, opmC_RKConfig);
0662: opmG_DBTable_CategoriesDescription := FNReg_ReadSetting ('OSCTable11', opmC_Def_DBTable_CategoriesDescription, opmC_RegistryKey, opmC_RKConfig);
0663: opmG_DBTable_TaxRates := FNReg_ReadSetting ('OSCTable13', opmC_Def_DBTable_TaxRates, opmC_RegistryKey, opmC_RKConfig);
0664: opmG_DBTable_ManufacturersInfo := FNReg_ReadSetting ('OSCTable14', opmC_Def_DBTable_ManufacturersInfo, opmC_RegistryKey, opmC_RKConfig);
0665: opmG_DBUsername := FNReg_ReadSetting ('OSCUsername', opmC_Def_Username, opmC_RegistryKey, opmC_RKConfig);
0666: opmG_DBPassword := FNReg_ReadSetting ('OSCPassword', opmC_Def_Password, opmC_RegistryKey, opmC_RKConfig);
0667: opmG_WBImgURL := FNReg_ReadSetting ('OSCImgURL', opmC_Def_ImgURL, opmC_RegistryKey, opmC_RKConfig);
0668: opmG_WBUploadURL := FNReg_ReadSetting ('OSCUploadURL', opmC_Def_UploadURL, opmC_RegistryKey, opmC_RKConfig);
0669: opmG_WBProxyHost := FNopm_CleanHostName (FNReg_ReadSetting ('OSCProxyHost', opmC_Def_ProxyHost, opmC_RegistryKey, opmC_RKConfig));
0670: opmG_WBProxyPort := FNopm_StrToInt (FNReg_ReadSetting ('OSCProxyPort', INTTOSTR (opmC_Def_ProxyPort), opmC_RegistryKey, opmC_RKConfig));
0671: opmG_DBConnWait := FNopm_StrToInt (FNReg_ReadSetting ('OSCDBConnWait', INTTOSTR (opmC_Def_DBConnWait), opmC_RegistryKey, opmC_RKConfig));
0672: opmG_ModConnWait := FNopm_StrToInt (FNReg_ReadSetting ('OSCModConnWait', INTTOSTR (opmC_Def_ModConnWait), opmC_RegistryKey, opmC_RKConfig));
0673: opmG_SSHConnWait := FNopm_StrToInt (FNReg_ReadSetting ('OSCSSHConnWait', INTTOSTR (opmC_Def_SSHConnWait), opmC_RegistryKey, opmC_RKConfig));
0674: opmG_DBConnRetries := FNopm_StrToInt (FNReg_ReadSetting ('OSCDBConnRetries', INTTOSTR (opmC_Def_DBConnRetries), opmC_RegistryKey, opmC_RKConfig));
0675: opmG_ModConnRetries := FNopm_StrToInt (FNReg_ReadSetting ('OSCModConnRetries', INTTOSTR (opmC_Def_ModConnRetries), opmC_RegistryKey, opmC_RKConfig));
0676: opmG_WBImgX := FNopm_StrToInt (FNReg_ReadSetting ('OSCImgX', INTTOSTR (opmC_Def_ImgX), opmC_RegistryKey, opmC_RKConfig));
0677: opmG_WBImgY := FNopm_StrToInt (FNReg_ReadSetting ('OSCImgY', INTTOSTR (opmC_Def_ImgY), opmC_RegistryKey, opmC_RKConfig));
0678: opmG_WBImgQ := FNopm_StrToInt (FNReg_ReadSetting ('OSCImgQ', INTTOSTR (opmC_Def_ImgQ), opmC_RegistryKey, opmC_RKConfig));
0679: opmG_WBPaddingColor := FNopm_StrToInt (FNReg_ReadSetting ('OSCPaddingColor', INTTOSTR (opmC_Def_PaddingColor), opmC_RegistryKey, opmC_RKConfig));
0680: IF (opmG_WBImgURL[LENGTH (opmG_WBImgURL)] <> '/') THEN opmG_WBImgURL := opmG_WBImgURL + '/';
0681: opm_CurrentLang := ABS (FNopm_StrToInt (FNReg_ReadSetting ('OSCLanguage', INTTOSTR (opmC_Def_DisplayLang), opmC_RegistryKey, opmC_RKRoot)));
0682: opmG_UIHotTracking := FNopm_StrToInt (FNReg_ReadSetting ('OSCHotTracking', INTTOSTR (opmC_Def_HotTracking), opmC_RegistryKey, opmC_RKConfig));
0683: opmG_UIClickLoad := FNopm_StrToInt (FNReg_ReadSetting ('OSCAutoLoad', INTTOSTR (opmC_Def_AutoLoad), opmC_RegistryKey, opmC_RKConfig));
0684: opmG_UIDragDrop := FNopm_StrToInt (FNReg_ReadSetting ('OSCDragDrop', INTTOSTR (opmC_Def_DragDrop), opmC_RegistryKey, opmC_RKConfig));
0685: opmG_UIImgDragDrop := FNopm_StrToInt (FNReg_ReadSetting ('OSCImgDragDrop', INTTOSTR (opmC_Def_ImgDragDrop), opmC_RegistryKey, opmC_RKConfig));
0686: opmG_UIToolTips := FNopm_StrToInt (FNReg_ReadSetting ('OSCToolTips', INTTOSTR (opmC_Def_ToolTips), opmC_RegistryKey, opmC_RKConfig));
0687: opmG_DBCompress := FNopm_StrToInt (FNReg_ReadSetting ('OSCCompress', INTTOSTR (opmC_Def_Compress), opmC_RegistryKey, opmC_RKConfig));
0688: opmG_UseProxy := FNopm_StrToInt (FNReg_ReadSetting ('OSCUseProxy', INTTOSTR (opmC_Def_UseProxy), opmC_RegistryKey, opmC_RKConfig));
0689: opmG_ProxyApply := FNopm_StrToInt (FNReg_ReadSetting ('OSCProxyApply', INTTOSTR (opmC_Def_ProxyApply), opmC_RegistryKey, opmC_RKConfig));
0690: opmG_UseSSH := FNopm_StrToInt (FNReg_ReadSetting ('OSCUseSSH', INTTOSTR (opmC_Def_UseSSH), opmC_RegistryKey, opmC_RKConfig));
0691: opmG_SSHUsername := FNReg_ReadSetting ('OSCSSHUsername', opmC_Def_SSHUsername, opmC_RegistryKey, opmC_RKConfig);
0692: opmG_SSHPassword := FNReg_ReadSetting ('OSCSSHPassword', opmC_Def_SSHPassword, opmC_RegistryKey, opmC_RKConfig);
0693: opmG_SSHLocalPort := FNopm_StrToInt (FNReg_ReadSetting ('OSCSSHLocalPort', INTTOSTR (opmC_Def_SSHLocalPort), opmC_RegistryKey, opmC_RKConfig));
0694: opmG_DBStorePass := FNopm_StrToInt (FNReg_ReadSetting ('OSCStorePass', INTTOSTR (opmC_Def_StorePass), opmC_RegistryKey, opmC_RKConfig));
0695: opmG_UISilent := FNopm_StrToInt (FNReg_ReadSetting ('OSCSilent', INTTOSTR (opmC_Def_Silent), opmC_RegistryKey, opmC_RKConfig));
0696: opmG_UIConfirmDels := FNopm_StrToInt (FNReg_ReadSetting ('OSCConfirmDels', INTTOSTR (opmC_Def_ConfirmDels), opmC_RegistryKey, opmC_RKConfig));
0697: opmG_UIConfirmDrag := FNopm_StrToInt (FNReg_ReadSetting ('OSCConfirmDrag', INTTOSTR (opmC_Def_ConfirmDrag), opmC_RegistryKey, opmC_RKConfig));
0698: opmG_UIConfirmMods := FNopm_StrToInt (FNReg_ReadSetting ('OSCConfirmMods', INTTOSTR (opmC_Def_ConfirmMods), opmC_RegistryKey, opmC_RKConfig));
0699: opmG_UIAllowZeroPrice := FNopm_StrToInt (FNReg_ReadSetting ('OSCAllowZeroPrice', INTTOSTR (opmC_Def_AllowZeroPrice), opmC_RegistryKey, opmC_RKConfig));
0700: opmG_UIAllowEditImageName := FNopm_StrToInt (FNReg_ReadSetting ('OSCAllowEditImageName', INTTOSTR (opmC_Def_AllowEditImageName), opmC_RegistryKey, opmC_RKConfig));
0701: opmG_UIAllowNegativeQuantity := FNopm_StrToInt (FNReg_ReadSetting ('OSCAllowNegativeQuantity', INTTOSTR (opmC_Def_AllowNegativeQuantity), opmC_RegistryKey, opmC_RKConfig));
0702: opmG_UIAutoDownImg := FNopm_StrToInt (FNReg_ReadSetting ('OSCAutoDownImg', INTTOSTR (opmC_Def_AutoDownImg), opmC_RegistryKey, opmC_RKConfig));
0703: opmG_UIFontName := FNReg_ReadSetting ('UIFontName', opmC_DefaultFont, opmC_RegistryKey, opmC_RKVisual);
0704: opmG_UIFontHeight := FNopm_StrToInt (FNReg_ReadSetting ('UIFontHeight', INTTOSTR (opmC_DefaultFontHeight), opmC_RegistryKey, opmC_RKVisual));
0705: opmG_UIFontCharset := FNopm_StrToInt (FNReg_ReadSetting ('UIFontCharset', INTTOSTR (opmC_DefaultFontCharset), opmC_RegistryKey, opmC_RKVisual));
0706: opmG_Clip_ColSize := FNopm_StrToInt (FNReg_ReadSetting ('Clip_ColSize', INTTOSTR (opmC_Def_Clip_ColSize), opmC_RegistryKey, opmC_RKVisual));
0707: opmG_PRNDirectPrint := FNopm_StrToInt (FNReg_ReadSetting ('PRNDirectPrint', INTTOSTR (opmC_Def_PRNDirectPrint), opmC_RegistryKey, opmC_RKVisual));
0708: opmG_Past_PAvailDate := FNopm_StrToInt (FNReg_ReadSetting ('PastAvailDate', INTTOSTR (opmC_Def_Past_PAvailDate), opmC_RegistryKey, opmC_RKVisual));
0709: opmG_Past_PManufacturer := FNopm_StrToInt (FNReg_ReadSetting ('PastManufacturer', INTTOSTR (opmC_Def_Past_PManufacturer), opmC_RegistryKey, opmC_RKVisual));
0710: opmG_Past_PTaxClass := FNopm_StrToInt (FNReg_ReadSetting ('PastTaxClass', INTTOSTR (opmC_Def_Past_PTaxClass), opmC_RegistryKey, opmC_RKVisual));
0711: opmG_Past_PImageDir := FNReg_ReadSetting ('PastImageDir', opmC_Def_Past_PImageDir, opmC_RegistryKey, opmC_RKVisual);
0712: opmG_WBNoCacheImg := FNopm_StrToInt (FNReg_ReadSetting ('OSCNoCacheImg', INTTOSTR (opmC_Def_NoCacheImg), opmC_RegistryKey, opmC_RKConfig));
0713: opmG_WBResizeImg := FNopm_StrToInt (FNReg_ReadSetting ('OSCResizeImg', INTTOSTR (opmC_Def_ResizeImg), opmC_RegistryKey, opmC_RKConfig));
0714: opmG_WBPaddingImg := FNopm_StrToInt (FNReg_ReadSetting ('OSCPaddingImg', INTTOSTR (opmC_Def_PaddingImg), opmC_RegistryKey, opmC_RKConfig));
0715: opmG_WBKeepARImg := FNopm_StrToInt (FNReg_ReadSetting ('OSCKeepARImg', INTTOSTR (opmC_Def_KeepARImg), opmC_RegistryKey, opmC_RKConfig));
0716: opmG_WBSmartRename := FNopm_StrToInt (FNReg_ReadSetting ('OSCSmartRename', INTTOSTR (opmC_Def_SmartRename), opmC_RegistryKey, opmC_RKConfig));
0717: opmG_UIConfirmExit := FNopm_StrToInt (FNReg_ReadSetting ('OSCConfirmExit', INTTOSTR (opmC_Def_ConfirmExit), opmC_RegistryKey, opmC_RKConfig));
0718: opmG_DBDebugLog := FNopm_StrToInt (FNReg_ReadSetting ('OSCDBDebugLog', INTTOSTR (opmC_Def_DBDebugLog), opmC_RegistryKey, opmC_RKConfig));
0719: opmG_UIDBDebug := FNopm_StrToInt (FNReg_ReadSetting ('OSCDBDebug', INTTOSTR (opmC_Def_DBDebug), opmC_RegistryKey, opmC_RKConfig));
0720: opmG_UISSHDebug := FNopm_StrToInt (FNReg_ReadSetting ('OSCSSHDebug', INTTOSTR (opmC_Def_SSHDebug), opmC_RegistryKey, opmC_RKConfig));
0721: opmG_UIWBDebug := FNopm_StrToInt (FNReg_ReadSetting ('OSCWBDebug', INTTOSTR (opmC_Def_WBDebug), opmC_RegistryKey, opmC_RKConfig));
0722: opmG_UIGUILang := FNReg_ReadSetting ('OSCGUILang', opmC_Def_GUILang, opmC_RegistryKey, opmC_RKConfig);
0723: IF (FNopm_CheckLanguage (opmG_UIGUILang) = FALSE) THEN opmG_UIGUILang := opmC_Def_GUILang;
0724: opmG_UIRememberDisplay := FNopm_StrToInt (FNReg_ReadSetting ('OSCRememberPosition', INTTOSTR (opmC_Def_RememberDisplay), opmC_RegistryKey, opmC_RKConfig));
0725: opmG_UIWindow_XSize := ABS (FNopm_StrToInt (FNReg_ReadSetting ('OSCWinX', INTTOSTR (opmC_DefWindow_XSize), opmC_RegistryKey, opmC_RKVisual)));
0726: IF ((opmG_UIWindow_XSize < opmC_MinWindow_XSize) OR (opmG_UIWindow_XSize > opmC_MaxWindow_XSize)) THEN opmG_UIWindow_XSize := opmC_DefWindow_XSize;
0727: opmG_UIWindow_YSize := ABS (FNopm_StrToInt (FNReg_ReadSetting ('OSCWinY', INTTOSTR (opmC_DefWindow_YSize), opmC_RegistryKey, opmC_RKVisual)));
0728: IF ((opmG_UIWindow_YSize < opmC_MinWindow_YSize) OR (opmG_UIWindow_YSize > opmC_MaxWindow_YSize)) THEN opmG_UIWindow_YSize := opmC_DefWindow_YSize;
0729: opmG_UICatList_XSize := ABS (FNopm_StrToInt (FNReg_ReadSetting ('OSCListX', INTTOSTR (opmC_DefCatList_Size), opmC_RegistryKey, opmC_RKVisual)));
0730: IF ((opmG_UICatList_XSize < opmC_MinCatList_Size) OR (opmG_UICatList_XSize > opmC_MaxCatList_Size)) THEN opmG_UICatList_XSize := opmC_DefCatList_Size;
0731: IF ((opmG_UICatList_XSize + 100) > opmG_UIWindow_XSize) THEN opmG_UIWindow_XSize := opmG_UICatList_XSize + 100;
0732: opmG_UICol0X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col0X', INTTOSTR (opmC_Def_Col0X), opmC_RegistryKey, opmC_RKVisual)));
0733: IF (opmG_UICol0X < opmC_MinColX) THEN opmG_UICol0X := opmC_MinColX;
0734: opmG_UICol1X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col1X', INTTOSTR (opmC_Def_Col1X), opmC_RegistryKey, opmC_RKVisual)));
0735: IF (opmG_UICol1X < opmC_MinColX) THEN opmG_UICol1X := opmC_MinColX;
0736: opmG_UICol2X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col2X', INTTOSTR (opmC_Def_Col2X), opmC_RegistryKey, opmC_RKVisual)));
0737: IF (opmG_UICol2X < opmC_MinColX) THEN opmG_UICol2X := opmC_MinColX;
0738: opmG_UICol3X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col3X', INTTOSTR (opmC_Def_Col3X), opmC_RegistryKey, opmC_RKVisual)));
0739: IF (opmG_UICol3X < opmC_MinColX) THEN opmG_UICol3X := opmC_MinColX;
0740: opmG_UICol4X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col4X', INTTOSTR (opmC_Def_Col4X), opmC_RegistryKey, opmC_RKVisual)));
0741: IF (opmG_UICol4X < opmC_MinColX) THEN opmG_UICol4X := opmC_MinColX;
0742: opmG_UICol5X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col5X', INTTOSTR (opmC_Def_Col5X), opmC_RegistryKey, opmC_RKVisual)));
0743: IF (opmG_UICol5X < opmC_MinColX) THEN opmG_UICol5X := opmC_MinColX;
0744: opmG_UICol6X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col6X', INTTOSTR (opmC_Def_Col6X), opmC_RegistryKey, opmC_RKVisual)));
0745: IF (opmG_UICol6X < opmC_MinColX) THEN opmG_UICol6X := opmC_MinColX;
0746: opmG_UICol7X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col7X', INTTOSTR (opmC_Def_Col7X), opmC_RegistryKey, opmC_RKVisual)));
0747: IF (opmG_UICol7X < opmC_MinColX) THEN opmG_UICol7X := opmC_MinColX;
0748: opmG_UICol8X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col8X', INTTOSTR (opmC_Def_Col8X), opmC_RegistryKey, opmC_RKVisual)));
0749: IF (opmG_UICol8X < opmC_MinColX) THEN opmG_UICol8X := opmC_MinColX;
0750: opmG_UICol9X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col9X', INTTOSTR (opmC_Def_Col9X), opmC_RegistryKey, opmC_RKVisual)));
0751: IF (opmG_UICol9X < opmC_MinColX) THEN opmG_UICol9X := opmC_MinColX;
0752: opmG_UICol10X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col10X', INTTOSTR (opmC_Def_Col10X), opmC_RegistryKey, opmC_RKVisual)));
0753: IF (opmG_UICol10X < opmC_MinColX) THEN opmG_UICol10X := opmC_MinColX;
0754: opmG_UICol20X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col20X', INTTOSTR (opmC_Def_Col20X), opmC_RegistryKey, opmC_RKVisual)));
0755: IF (opmG_UICol20X < opmC_MinColX) THEN opmG_UICol20X := opmC_MinColX;
0756: opmG_UICol21X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col21X', INTTOSTR (opmC_Def_Col21X), opmC_RegistryKey, opmC_RKVisual)));
0757: IF (opmG_UICol20X < opmC_MinColX) THEN opmG_UICol21X := opmC_MinColX;
0758: opmG_UICol22X := ABS (FNopm_StrToInt (FNReg_ReadSetting ('Col22X', INTTOSTR (opmC_Def_Col22X), opmC_RegistryKey, opmC_RKVisual)));
0759: IF (opmG_UICol20X < opmC_MinColX) THEN opmG_UICol22X := opmC_MinColX;
0760: PRReg_ReadPastList ('Host', opmC_RegistryKey, opmC_RKServers, opmG_PastHost_BoxList, opmC_MaxPast_Servers);
0761: PRReg_ReadPastList ('Database', opmC_RegistryKey, opmC_RKServers, opmG_PastDatabase_BoxList, opmC_MaxPast_Databases);
0762: PRReg_ReadPastList ('Username', opmC_RegistryKey, opmC_RKServers, opmG_PastUsername_BoxList, opmC_MaxPast_Usernames);
0763: PRReg_ReadPastList ('SSHUsername', opmC_RegistryKey, opmC_RKServers, opmG_PastSSHUsername_BoxList, opmC_MaxPast_SSHUsernames);
0764: PRReg_ReadPastList ('ImgURL', opmC_RegistryKey, opmC_RKServers, opmG_PastImgURL_BoxList, opmC_MaxPast_ImgURL);
0765: PRReg_ReadPastList ('UploadURL', opmC_RegistryKey, opmC_RKServers, opmG_PastUploadURL_BoxList, opmC_MaxPast_UploadURL);
0766: PRReg_ReadPastList ('Proxy', opmC_RegistryKey, opmC_RKServers, opmG_PastProxy_BoxList, opmC_MaxPast_Proxy);
0767: END;
0768:
0769:
0770: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0771: Saves some configuration options to the Windows registry.
0772: Only options about the user interface are stored here, other
0773: options are stored when running the configuration form.
0774: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0775: PROCEDURE Topm_Form_Main.PRopm_SaveConfiguration;
0776: BEGIN
0777: PRReg_WriteSetting ('OSCWinX', INTTOSTR (opm_Form_Main.Width), opmC_RegistryKey, opmC_RKVisual);
0778: PRReg_WriteSetting ('OSCWinY', INTTOSTR (opm_Form_Main.Height), opmC_RegistryKey, opmC_RKVisual);
0779: PRReg_WriteSetting ('OSCListX', INTTOSTR (opm_TreeView_Main.Width), opmC_RegistryKey, opmC_RKVisual);
0780: PRReg_WriteSetting ('Col0X', INTTOSTR (opm_ListView_Main.Column[0].Width), opmC_RegistryKey, opmC_RKVisual);
0781: PRReg_WriteSetting ('Col1X', INTTOSTR (opm_ListView_Main.Column[1].Width), opmC_RegistryKey, opmC_RKVisual);
0782: PRReg_WriteSetting ('Col2X', INTTOSTR (opm_ListView_Main.Column[2].Width), opmC_RegistryKey, opmC_RKVisual);
0783: PRReg_WriteSetting ('Col3X', INTTOSTR (opm_ListView_Main.Column[3].Width), opmC_RegistryKey, opmC_RKVisual);
0784: PRReg_WriteSetting ('Col4X', INTTOSTR (opm_ListView_Main.Column[4].Width), opmC_RegistryKey, opmC_RKVisual);
0785: PRReg_WriteSetting ('Col5X', INTTOSTR (opm_ListView_Main.Column[5].Width), opmC_RegistryKey, opmC_RKVisual);
0786: PRReg_WriteSetting ('Col6X', INTTOSTR (opm_ListView_Main.Column[6].Width), opmC_RegistryKey, opmC_RKVisual);
0787: PRReg_WriteSetting ('Col7X', INTTOSTR (opm_ListView_Main.Column[7].Width), opmC_RegistryKey, opmC_RKVisual);
0788: PRReg_WriteSetting ('Col8X', INTTOSTR (opm_ListView_Main.Column[8].Width), opmC_RegistryKey, opmC_RKVisual);
0789: PRReg_WriteSetting ('Col9X', INTTOSTR (opm_ListView_Main.Column[9].Width), opmC_RegistryKey, opmC_RKVisual);
0790: PRReg_WriteSetting ('Col10X', INTTOSTR (opm_ListView_Main.Column[10].Width), opmC_RegistryKey, opmC_RKVisual);
0791: PRReg_WriteSetting ('Col20X', INTTOSTR (opm_Form_Runmod.opm_ListView_RunmodConfirm.Column[1].Width), opmC_RegistryKey, opmC_RKVisual);
0792: PRReg_WriteSetting ('Col21X', INTTOSTR (opm_Form_Runmod.opm_ListView_RunmodConfirm.Column[2].Width), opmC_RegistryKey, opmC_RKVisual);
0793: PRReg_WriteSetting ('Col22X', INTTOSTR (opm_Form_Runmod.opm_ListView_RunmodConfirm.Column[3].Width), opmC_RegistryKey, opmC_RKVisual);
0794: PRReg_WriteSetting ('OSCLanguage', INTTOSTR (opm_CurrentLang), opmC_RegistryKey, opmC_RKRoot);
0795: PRReg_WriteSetting ('OSCGUILang', opmG_UIGUILang, opmC_RegistryKey, opmC_RKConfig);
0796: PRReg_WriteSetting ('PastAvailDate', INTTOSTR (opmG_Past_PAvailDate), opmC_RegistryKey, opmC_RKVisual);
0797: PRReg_WriteSetting ('PastManufacturer', INTTOSTR (opmG_Past_PManufacturer), opmC_RegistryKey, opmC_RKVisual);
0798: PRReg_WriteSetting ('PastTaxClass', INTTOSTR (opmG_Past_PTaxClass), opmC_RegistryKey, opmC_RKVisual);
0799: PRReg_WriteSetting ('PastImageDir', opmG_Past_PImageDir, opmC_RegistryKey, opmC_RKVisual);
0800: END;
0801:
0802:
0803:
0804: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0805: Sets several parameters of the visual components before
0806: starting.
0807: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0808: PROCEDURE Topm_Form_Main.PRopm_SetDisplay (RememberVisual : WORD);
0809: BEGIN
0810: opm_Form_Main.DoubleBuffered := TRUE;
0811: opm_Form_Main.Caption := opmC_AppName1 + ' ' + opmC_Version + ' (build ' + opmG_ExeBuildVersion + ')';
0812: opm_Form_Main.Constraints.MinWidth := opmC_MinWindow_XSize;
0813: opm_Form_Main.Constraints.MinHeight := opmC_MinWindow_YSize;
0814: opm_Form_Main.Constraints.MaxWidth := opmC_MaxWindow_XSize;
0815: opm_Form_Main.Constraints.MaxHeight := opmC_MaxWindow_YSize;
0816:
0817: opm_StatusBar_Main.Height := 16 + (opmC_Bevel_Size * 2);
0818: opm_StatusBar_Main.Panels[0].Width := 16 + (opmC_Bevel_Size * 2);
0819: opm_StatusBar_Main.Panels[1].Width := opmC_DefGauge_Size + (opmC_Bevel_Size * 2);
0820: opm_StatusBar_Main.Panels[2].Width := opmC_DefGauge_Size + (opmC_Bevel_Size * 2);
0821: opm_StatusBar_Main.Panels[3].Width := opmC_DefCatList_Size;
0822: opm_StatusBar_Main.Panels[4].Width := opmC_DefCatList_Size;
0823: opm_StatusBar_Main.Panels[5].Width := opmC_DefCurPan_Size;
0824: opm_StatusBar_Main.Panels[6].Width := opmC_DefMemPan_Size;
0825:
0826: opm_ProgressBar_Main.Parent := opm_StatusBar_Main;
0827: opm_ProgressBar_Main.Top := (opmC_Bevel_Size + 1);
0828: opm_ProgressBar_Main.Left := 16 + (opmC_Bevel_Size * 2) + (opmC_Bevel_Size + 1);
0829: opm_ProgressBar_Main.Height := (opm_StatusBar_Main.Height - (opmC_Bevel_Size * 2));
0830: opm_ProgressBar_Main.Width := opmC_DefGauge_Size;
0831: opm_ProgressBar_Main.Min := 0;
0832: opm_ProgressBar_Main.Max := 100;
0833:
0834: opm_ProgressBar_Sec.Parent := opm_StatusBar_Main;
0835: opm_ProgressBar_Sec.Top := (opmC_Bevel_Size + 1);
0836: opm_ProgressBar_Sec.Left := 16 + (opmC_Bevel_Size * 4) + (opmC_Bevel_Size + 1) + opmC_DefGauge_Size;
0837: opm_ProgressBar_Sec.Height := (opm_StatusBar_Main.Height - (opmC_Bevel_Size * 2));
0838: opm_ProgressBar_Sec.Width := opmC_DefGauge_Size;
0839: opm_ProgressBar_Sec.Min := 0;
0840: opm_ProgressBar_Sec.Max := 100;
0841:
0842: opm_Image_Status.Parent := opm_StatusBar_Main;
0843: opm_Image_Status.Top := (opmC_Bevel_Size + 1);
0844: opm_Image_Status.Left := (opmC_Bevel_Size + 1);
0845: opm_Image_Status.Height := (opm_StatusBar_Main.Height - (opmC_Bevel_Size * 2));
0846: opm_Image_Status.Width := 16;
0847: opm_ImageList_Status.GetIcon (0, opm_Image_Status.Picture.Icon);
0848:
0849: opm_TreeView_Main.ReadOnly := TRUE;
0850: opm_TreeView_Main.DoubleBuffered := TRUE;
0851: opm_TreeView_Main.Constraints.MinWidth := opmC_MinCatList_Size;
0852: opm_ListView_Main.Columns.Clear;
0853: opm_ListView_Main.Checkboxes := FALSE;
0854: opm_ListView_Main.ReadOnly := TRUE;
0855: opm_ListView_Main.RowSelect := TRUE;
0856: opm_ListView_Main.MultiSelect := TRUE;
0857: opm_ListView_Main.DoubleBuffered := TRUE;
0858: opm_ListView_Main.ViewStyle := vsReport;
0859: opm_ListView_Main.Columns.Add;
0860: opm_ListView_Main.Columns.Add;
0861: opm_ListView_Main.Columns.Add;
0862: opm_ListView_Main.Columns.Add;
0863: opm_ListView_Main.Columns.Add;
0864: opm_ListView_Main.Columns.Add;
0865: opm_ListView_Main.Columns.Add;
0866: opm_ListView_Main.Columns.Add;
0867: opm_ListView_Main.Columns.Add;
0868: opm_ListView_Main.Columns.Add;
0869: opm_ListView_Main.Columns.Add;
0870: opm_ListView_Main.Columns.Items[0].Caption := _('Available');
0871: opm_ListView_Main.Columns.Items[1].Caption := _('ID');
0872: opm_ListView_Main.Columns.Items[2].Caption := _('Model');
0873: opm_ListView_Main.Columns.Items[3].Caption := _('Category');
0874: opm_ListView_Main.Columns.Items[4].Caption := _('Name');
0875: opm_ListView_Main.Columns.Items[5].Caption := _('Manufacturer');
0876: opm_ListView_Main.Columns.Items[6].Caption := _('Quantity');
0877: opm_ListView_Main.Columns.Items[7].Caption := _('Price');
0878: opm_ListView_Main.Columns.Items[8].Caption := _('Weight');
0879: opm_ListView_Main.Columns.Items[9].Caption := _('Availability date');
0880: opm_ListView_Main.Columns.Items[10].Caption := _('Image');
0881: opm_ListView_Main.Columns.Items[0].Alignment := opmC_Def_Col0Align;
0882: opm_ListView_Main.Columns.Items[1].Alignment := opmC_Def_Col1Align;
0883: opm_ListView_Main.Columns.Items[2].Alignment := opmC_Def_Col2Align;
0884: opm_ListView_Main.Columns.Items[3].Alignment := opmC_Def_Col3Align;
0885: opm_ListView_Main.Columns.Items[4].Alignment := opmC_Def_Col4Align;
0886: opm_ListView_Main.Columns.Items[5].Alignment := opmC_Def_Col5Align;
0887: opm_ListView_Main.Columns.Items[6].Alignment := opmC_Def_Col6Align;
0888: opm_ListView_Main.Columns.Items[7].Alignment := opmC_Def_Col7Align;
0889: opm_ListView_Main.Columns.Items[8].Alignment := opmC_Def_Col8Align;
0890: opm_ListView_Main.Columns.Items[9].Alignment := opmC_Def_Col9Align;
0891: opm_ListView_Main.Columns.Items[10].Alignment := opmC_Def_Col10Align;
0892: IF (opmG_UIHotTracking > 0) THEN
0893: BEGIN
0894: opm_TreeView_Main.HotTrack := TRUE;
0895: opm_ListView_Main.HotTrack := FALSE;
0896: opm_ListView_Main.HotTrackStyles := [htHandPoint, htUnderlineHot];
0897: END
0898: ELSE
0899: BEGIN
0900: opm_TreeView_Main.HotTrack := FALSE;
0901: opm_ListView_Main.HotTrack := FALSE;
0902: opm_ListView_Main.HotTrackStyles := [];
0903: END;
0904: IF (opmG_UIDragDrop > 0) THEN
0905: opm_ListView_Main.DragMode := dmAutomatic
0906: ELSE
0907: opm_ListView_Main.DragMode := dmManual;
0908:
0909: IF (opmG_UIDBDebug > 0) THEN
0910: BEGIN
0911: opm_DataSource_DEBUG.Enabled := TRUE;
0912: opm_DBGrid_DEBUG.Enabled := TRUE;
0913: opm_DBGrid_DEBUG.Visible := TRUE;
0914: opm_Panel_DEBUG.Visible := TRUE;
0915: END
0916: ELSE
0917: BEGIN
0918: opm_DataSource_DEBUG.Enabled := FALSE;
0919: opm_DBGrid_DEBUG.Enabled := FALSE;
0920: opm_DBGrid_DEBUG.Visible := FALSE;
0921: opm_Panel_DEBUG.Visible := FALSE;
0922: END;
0923: IF (RememberVisual > 0) THEN
0924: BEGIN
0925: opm_Form_Main.Width := opmG_UIWindow_XSize;
0926: opm_Form_Main.Height := opmG_UIWindow_YSize;
0927: opm_TreeView_Main.Width := opmG_UICatList_XSize;
0928: opm_ListView_Main.Column[0].Width := opmG_UICol0X;
0929: opm_ListView_Main.Column[1].Width := opmG_UICol1X;
0930: opm_ListView_Main.Column[2].Width := opmG_UICol2X;
0931: opm_ListView_Main.Column[3].Width := opmG_UICol3X;
0932: opm_ListView_Main.Column[4].Width := opmG_UICol4X;
0933: opm_ListView_Main.Column[5].Width := opmG_UICol5X;
0934: opm_ListView_Main.Column[6].Width := opmG_UICol6X;
0935: opm_ListView_Main.Column[7].Width := opmG_UICol7X;
0936: opm_ListView_Main.Column[8].Width := opmG_UICol8X;
0937: opm_ListView_Main.Column[9].Width := opmG_UICol9X;
0938: opm_ListView_Main.Column[10].Width := opmG_UICol10X;
0939: END
0940: ELSE
0941: BEGIN
0942: opm_Form_Main.Width := opmC_DefWindow_XSize;
0943: opm_Form_Main.Height := opmC_DefWindow_YSize;
0944: opm_TreeView_Main.Width := opmC_DefCatList_Size;
0945: opm_ListView_Main.Column[0].Width := opmC_Def_Col0X;
0946: opm_ListView_Main.Column[1].Width := opmC_Def_Col1X;
0947: opm_ListView_Main.Column[2].Width := opmC_Def_Col2X;
0948: opm_ListView_Main.Column[3].Width := opmC_Def_Col3X;
0949: opm_ListView_Main.Column[4].Width := opmC_Def_Col4X;
0950: opm_ListView_Main.Column[5].Width := opmC_Def_Col5X;
0951: opm_ListView_Main.Column[6].Width := opmC_Def_Col6X;
0952: opm_ListView_Main.Column[7].Width := opmC_Def_Col7X;
0953: opm_ListView_Main.Column[8].Width := opmC_Def_Col8X;
0954: opm_ListView_Main.Column[9].Width := opmC_Def_Col9X;
0955: opm_ListView_Main.Column[10].Width := opmC_Def_Col10X;
0956: END;
0957: END;
0958:
0959:
0960:
0961: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0962: Updates the status bar information according to the parameters:
0963: connection status (to change connection icon), main progress bar,
0964: secondary progress bar, message caption and total products.
0965: Any option can be left unchanged.
0966: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0967: PROCEDURE Topm_Form_Main.PRopm_Update_StatusBar (ConnectedStat, ProgressStat, SecProgress : LONGINT; StatusString : STRING; ProductTotal : LONGINT; CurCurr : STRING);
0968: BEGIN
0969: IF (StatusString <> '') THEN
0970: opm_StatusBar_Main.Panels[3].Text := StatusString;
0971: IF (ProgressStat <> opmC_ProgressIgnore) THEN
0972: BEGIN
0973: opm_ProgressBar_Main.Position := ProgressStat;
0974: END;
0975: IF (SecProgress <> opmC_ProgressIgnore) THEN
0976: BEGIN
0977: opm_ProgressBar_Sec.Position := SecProgress;
0978: END;
0979: IF (ConnectedStat <> opmC_ConnStatIgnore) THEN
0980: BEGIN
0981: opm_ImageList_Status.GetIcon (ConnectedStat, opm_Image_Status.Picture.Icon);
0982: END;
0983: IF (ProductTotal <> opmC_PTotalIgnore) THEN
0984: opm_StatusBar_Main.Panels[4].Text := INTTOSTR (ProductTotal) + ' ' + _('products');
0985: IF (CurCurr <> '') THEN
0986: opm_StatusBar_Main.Panels[5].Text := CurCurr
0987: ELSE
0988: opm_StatusBar_Main.Panels[5].Text := _('???');
0989: opm_StatusBar_Main.Panels[6].Text := _('Mem:') + ' ' + INTTOSTR (FNopm_GetMemoryLoad) + '%';
0990: END;
0991:
0992:
0993:
0994: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0995: Load the list of categories in memory and populate the
0996: category boxlist.
0997: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0998: PROCEDURE Topm_Form_Main.PRopm_LoadCategoryList (VAR CatList : opmT_CategoryList; VAR CatBoxList : TStringList);
0999: VAR
1000: CurCat : LONGINT;
1001: BEGIN
1002: CatList[0].ID := -1;
1003: CatList[0].Parent := 0;
1004: CatList[0].Name := '';
1005: CurCat := 1;
1006: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 50, opmC_ProgressNone, _('Getting category list...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
1007: IF (FNopm_ExecQuery ('select ' + opmG_DBTable_Categories + '.categories_id, ' + opmG_DBTable_Categories + '.parent_id, ' + opmG_DBTable_CategoriesDescription + '.categories_name from ' + opmG_DBTable_Categories + ', ' + opmG_DBTable_CategoriesDescription + ' where ' + opmG_DBTable_CategoriesDescription + '.categories_id= ' + opmG_DBTable_Categories + '.categories_id and language_id=' + INTTOSTR (opm_CurrentLang) + ' ORDER BY ' + opmG_DBTable_CategoriesDescription + '.categories_name', opmC_SQLSelect) > 0) THEN
1008: BEGIN
1009: IF (opmG_DBQuery.Active = TRUE) THEN
1010: BEGIN
1011: Screen.Cursor := opmC_Wait_Mouse;
1012: PRopm_WriteLog ('BEGIN record loading (LoadCatList)...');
1013: opmG_DBQuery.First;
1014: WHILE NOT opmG_DBQuery.EOF DO
1015: BEGIN
1016: CatList[CurCat].ID := opmG_DBQuery.Fields[0].AsInteger;
1017: CatList[CurCat].Parent := opmG_DBQuery.Fields[1].AsInteger;
1018: CatList[CurCat].Name := FNopm_CleanString (opmG_DBQuery.Fields[2].AsString);
1019: IF (CatList[CurCat].Name = '') THEN CatList[CurCat].Name := opmC_Unamed_Cat;
1020: INC (CurCat);
1021: opmG_DBQuery.Next;
1022: END;
1023: PRopm_WriteLog ('END record loading.');
1024: Screen.Cursor := opmC_Normal_Mouse;
1025: END;
1026: END;
1027:
1028:
1029:
1030: {
1031: HERE GO THE VIRTUAL CATEGORIES DEFINITIONS...
1032:
1033: CatList[CurCat].ID := opmC_SC_TrashCanID;
1034: CatList[CurCat].Parent := opmC_SC_Parent;
1035: CatList[CurCat].Name := _('Deleted products');
1036: CatList[CurCat].TreeIndex := opmC_SC_TrashCanIndex;
1037: CatList[CurCat].ListIndex := opmC_SC_TrashCanIndex;
1038: INC (CurCat);
1039:
1040: }
1041:
1042:
1043:
1044:
1045:
1046: opm_TotalCategories := CurCat;
1047: CatBoxList.Clear;
1048: PRopm_LoadCategoryBoxList (CatList, 0, 0, CurCat, CatBoxList);
1049: CatList[0].ID := 0;
1050: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Got category list.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
1051: END;
1052:
1053:
1054:
1055: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1056: Scan the category list and recursively build the category boxlist.
1057: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1058: PROCEDURE Topm_Form_Main.PRopm_LoadCategoryBoxList (VAR CatList : opmT_CategoryList; CatCurrentID, TreeDepth : LONGINT; VAR CatIndex : LONGINT; VAR CatBoxList : TStringList);
1059: VAR
1060: CurCat : LONGINT;
1061: BEGIN
1062: IF (CatCurrentID = 0) THEN CatIndex := 0;
1063: FOR CurCat := 0 TO (opm_TotalCategories - 1) DO
1064: BEGIN
1065: IF ((CatList[CurCat].Parent = CatCurrentID) AND (CatList[CurCat].Parent < opmC_SC_Parent)) THEN
1066: BEGIN
1067: CatBoxList.Add (STRINGOFCHAR (opmC_CatList_Spacer, (TreeDepth * 2)) + CatList[CurCat].Name);
1068: CatList[CurCat].ListIndex := CatIndex;
1069: INC (CatIndex);
1070: PRopm_LoadCategoryBoxList (CatList, CatList[CurCat].ID, (TreeDepth + 1), CatIndex, CatBoxList);
1071: END;
1072: END;
1073: END;
1074:
1075:
1076: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1077: Recursively build the category tree view.
1078: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1079: PROCEDURE Topm_Form_Main.PRopm_AddCatTreeNode (VAR CatList : opmT_CategoryList; CatCurrentID : LONGINT; CurNode : TTreeNode; TreeDepth : INTEGER);
1080: VAR
1081: CurCat : LONGINT;
1082: NewNode : TTreeNode;
1083: BEGIN
1084: FOR CurCat := 0 TO (opm_TotalCategories - 1) DO
1085: BEGIN
1086: IF ((CatList[CurCat].Parent = CatCurrentID) AND (CatList[CurCat].ID > 0) AND (CatList[CurCat].Parent < opmC_SC_Parent)) THEN
1087: BEGIN
1088: NewNode := opm_TreeView_Main.Items.AddChild (CurNode, CatList[CurCat].Name);
1089: NewNode.ImageIndex := 2;
1090: NewNode.SelectedIndex := 3;
1091: CatList[CurCat].TreeIndex := NewNode.AbsoluteIndex;
1092: PRopm_AddCatTreeNode (CatList, CatList[CurCat].ID, NewNode, (TreeDepth + 1));
1093: END;
1094: END;
1095: END;
1096:
1097:
1098: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1099: Loads the list of manufacturers and populate the
1100: manufacturer boxlist.
1101: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1102: PROCEDURE Topm_Form_Main.PRopm_LoadManufacturerList (VAR ManList : opmT_ManufacturerList; VAR ManBoxList : TStringList);
1103: VAR
1104: CurMan : LONGINT;
1105: BEGIN
1106: ManBoxList.Clear;
1107: ManList[0].ID := 0;
1108: ManList[0].Name := '';
1109: ManList[0].ListIndex := 0;
1110: ManBoxList.Add ('');
1111: CurMan := 1;
1112: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 50, opmC_ProgressNone, _('Getting manufacturers list...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
1113: IF (FNopm_ExecQuery ('select manufacturers_id, manufacturers_name from ' + opmG_DBTable_Manufacturers + ' order by manufacturers_name', opmC_SQLSelect) > 0) THEN
1114: BEGIN
1115: IF (opmG_DBQuery.Active = TRUE) THEN
1116: BEGIN
1117: Screen.Cursor := opmC_Wait_Mouse;
1118: PRopm_WriteLog ('BEGIN record loading (LoadManList)...');
1119: opmG_DBQuery.First;
1120: WHILE NOT opmG_DBQuery.EOF DO
1121: BEGIN
1122: ManList[CurMan].ID := opmG_DBQuery.Fields[0].AsInteger;
1123: ManList[CurMan].Name := FNopm_CleanString (opmG_DBQuery.Fields[1].AsString);
1124: IF (ManList[CurMan].Name = '') THEN ManList[CurMan].Name := opmC_Unamed_Man;
1125: ManBoxList.Add (ManList[CurMan].Name);
1126: ManList[CurMan].ListIndex := CurMan;
1127: INC (CurMan);
1128: opmG_DBQuery.Next;
1129: END;
1130: PRopm_WriteLog ('END record loading.');
1131: Screen.Cursor := opmC_Normal_Mouse;
1132: END;
1133: END;
1134: opm_TotalManufacturers := CurMan;
1135: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Got manufacturers list.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
1136: END;
1137:
1138:
1139: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1140: Loads the list of available languages and populate the
1141: language boxlist.
1142: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1143: PROCEDURE Topm_Form_Main.PRopm_LoadLanguageList (VAR LangList : opmT_LanguageList);
1144: VAR
1145: CurLang : LONGINT;
1146: DisplayLangValid : BOOLEAN;
1147: BEGIN
1148: CurLang := 0;
1149: DisplayLangValid := FALSE;
1150: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 50, opmC_ProgressNone, _('Getting languages list...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
1151: opmG_LanguageBoxList.Clear;
1152: IF (FNopm_ExecQuery ('select languages_id, name from ' + opmG_DBTable_Languages + ' order by name', opmC_SQLSelect) > 0) THEN
1153: BEGIN
1154: IF (opmG_DBQuery.Active = TRUE) THEN
1155: BEGIN
1156: Screen.Cursor := opmC_Wait_Mouse;
1157: PRopm_WriteLog ('BEGIN record loading (LoadLangList)...');
1158: opmG_DBQuery.First;
1159: WHILE NOT opmG_DBQuery.EOF DO
1160: BEGIN
1161: LangList[CurLang].ID := opmG_DBQuery.Fields[0].AsInteger;
1162: LangList[CurLang].Name := FNopm_CleanString (opmG_DBQuery.Fields[1].AsString);
1163: IF (opm_CurrentLang = opmG_DBQuery.Fields[0].AsInteger) THEN DisplayLangValid := TRUE;
1164: LangList[CurLang].ListIndex := CurLang;
1165: opmG_LanguageBoxList.Add (LangList[CurLang].Name);
1166: INC (CurLang);
1167: opmG_DBQuery.Next;
1168: END;
1169: PRopm_WriteLog ('END record loading.');
1170: Screen.Cursor := opmC_Normal_Mouse;
1171: END;
1172: END;
1173: opm_TotalLanguages := CurLang;
1174: IF (DisplayLangValid = FALSE) THEN opm_CurrentLang := opmC_Def_DisplayLang;
1175: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Got languages list.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
1176: END;
1177:
1178:
1179: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1180: Loads the product list according to the given category.
1181: This routine don't modify the current display.
1182: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1183: PROCEDURE Topm_Form_Main.PRopm_LoadProductListByCat (ProductCat : LONGINT; VAR ProdList : opmT_ProductList; VAR DescList : opmT_DescriptionList);
1184: VAR
1185: CurProd : LONGINT;
1186: SQLStr : STRING;
1187: BEGIN
1188: BEGIN
1189: CurProd := 0;
1190: opm_WeAreSearching := FALSE;
1191: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 50, opmC_ProgressNone, _('Getting products list...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
1192: IF (opmG_Capa_MorePics6 = FALSE) THEN
1193: BEGIN
1194: IF (ProductCat > 0) THEN
1195: SQLStr := 'select ' + opmG_DBTable_Products + '.products_id, ' + opmG_DBTable_Products + '.products_quantity, ' + opmG_DBTable_Products + '.products_model, ' +
1196: opmG_DBTable_Products + '.products_price, ' + opmG_DBTable_Products + '.products_weight, ' + opmG_DBTable_Products + '.manufacturers_id, ' +
1197: opmG_DBTable_ProductsDescription + '.products_name, ' + opmG_DBTable_Products + '.products_status, ' + opmG_DBTable_ProductsDescription + '.products_description, ' +
1198: opmG_DBTable_ProductsDescription + '.products_url, ' + opmG_DBTable_Products + '.products_image, ' +
1199: opmG_DBTable_Specials + '.specials_new_products_price, ' + opmG_DBTable_ProductsDescription + '.language_id, ' +
1200: opmG_DBTable_Products + '.products_tax_class_id, ' + opmG_DBTable_ProductsDescription + '.products_viewed, ' +
1201: 'DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_available, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_added, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_last_modified, "%Y-%m-%d %H:%i:%S") ' +
1202: 'from ' + opmG_DBTable_Products + ', ' + opmG_DBTable_ProductsDescription + ', ' + opmG_DBTable_ProductsToCategories + ' ' +
1203: 'left join ' + opmG_DBTable_Specials + ' ON ' + opmG_DBTable_Products + '.products_id = ' + opmG_DBTable_Specials + '.products_id ' +
1204: 'where ' + opmG_DBTable_Products + '.products_id=' + opmG_DBTable_ProductsDescription + '.products_id ' +
1205: 'and ' + opmG_DBTable_ProductsToCategories + '.products_id=' + opmG_DBTable_Products + '.products_id and ' +
1206: opmG_DBTable_ProductsToCategories + '.categories_id=' + INTTOSTR (ProductCat) + ' ' +
1207: 'order by ' + opmG_DBTable_ProductsDescription + '.products_name'
1208: ELSE
1209: SQLStr := 'select ' + opmG_DBTable_Products + '.products_id, ' + opmG_DBTable_Products + '.products_quantity, ' + opmG_DBTable_Products + '.products_model, ' +
1210: opmG_DBTable_Products + '.products_price, ' + opmG_DBTable_Products + '.products_weight, ' + opmG_DBTable_Products + '.manufacturers_id, ' +
1211: opmG_DBTable_ProductsDescription + '.products_name, ' + opmG_DBTable_Products + '.products_status, ' + opmG_DBTable_ProductsDescription + '.products_description, ' +
1212: opmG_DBTable_ProductsDescription + '.products_url, ' + opmG_DBTable_Products + '.products_image, ' +
1213: opmG_DBTable_Specials + '.specials_new_products_price, ' + opmG_DBTable_ProductsDescription + '.language_id, ' +
1214: opmG_DBTable_Products + '.products_tax_class_id, ' + opmG_DBTable_ProductsDescription + '.products_viewed, ' +
1215: 'DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_available, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_added, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_last_modified, "%Y-%m-%d %H:%i:%S") ' +
1216: 'from ' + opmG_DBTable_Products + ', ' + opmG_DBTable_ProductsDescription + ' ' +
1217: 'left join ' + opmG_DBTable_Specials + ' ON ' + opmG_DBTable_Products + '.products_id = ' + opmG_DBTable_Specials + '.products_id ' +
1218: 'LEFT JOIN ' + opmG_DBTable_ProductsToCategories + ' ON ' + opmG_DBTable_ProductsToCategories + '.products_id = ' + opmG_DBTable_Products + '.products_id ' +
1219: 'where ' + opmG_DBTable_Products + '.products_id=' + opmG_DBTable_ProductsDescription + '.products_id ' +
1220: 'and (' + opmG_DBTable_ProductsToCategories + '.categories_id is null ' +
1221: 'or ' + opmG_DBTable_ProductsToCategories + '.categories_id < 1) ' +
1222: 'order by ' + opmG_DBTable_ProductsDescription + '.products_name';
1223: END
1224: ELSE
1225: BEGIN
1226: IF (ProductCat > 0) THEN
1227: SQLStr := 'select ' + opmG_DBTable_Products + '.products_id, ' + opmG_DBTable_Products + '.products_quantity, ' + opmG_DBTable_Products + '.products_model, ' +
1228: opmG_DBTable_Products + '.products_price, ' + opmG_DBTable_Products + '.products_weight, ' + opmG_DBTable_Products + '.manufacturers_id, ' +
1229: opmG_DBTable_ProductsDescription + '.products_name, ' + opmG_DBTable_Products + '.products_status, ' + opmG_DBTable_ProductsDescription + '.products_description, ' +
1230: opmG_DBTable_ProductsDescription + '.products_url, ' + opmG_DBTable_Products + '.products_image, ' +
1231: opmG_DBTable_Specials + '.specials_new_products_price, ' + opmG_DBTable_ProductsDescription + '.language_id, ' +
1232: opmG_DBTable_Products + '.products_tax_class_id, ' + opmG_DBTable_ProductsDescription + '.products_viewed, ' +
1233: 'DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_available, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_added, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_last_modified, "%Y-%m-%d %H:%i:%S") ' +
1234: ', products_subimage1, products_subimage2, products_subimage3, products_subimage4, products_subimage5, products_subimage6 ' +
1235: 'from ' + opmG_DBTable_Products + ', ' + opmG_DBTable_ProductsDescription + ', ' + opmG_DBTable_ProductsToCategories + ' ' +
1236: 'left join ' + opmG_DBTable_Specials + ' ON ' + opmG_DBTable_Products + '.products_id = ' + opmG_DBTable_Specials + '.products_id ' +
1237: 'where ' + opmG_DBTable_Products + '.products_id=' + opmG_DBTable_ProductsDescription + '.products_id ' +
1238: 'and ' + opmG_DBTable_ProductsToCategories + '.products_id=' + opmG_DBTable_Products + '.products_id and ' +
1239: opmG_DBTable_ProductsToCategories + '.categories_id=' + INTTOSTR (ProductCat) + ' ' +
1240: 'order by ' + opmG_DBTable_ProductsDescription + '.products_name'
1241: ELSE
1242: SQLStr := 'select ' + opmG_DBTable_Products + '.products_id, ' + opmG_DBTable_Products + '.products_quantity, ' + opmG_DBTable_Products + '.products_model, ' +
1243: opmG_DBTable_Products + '.products_price, ' + opmG_DBTable_Products + '.products_weight, ' + opmG_DBTable_Products + '.manufacturers_id, ' +
1244: opmG_DBTable_ProductsDescription + '.products_name, ' + opmG_DBTable_Products + '.products_status, ' + opmG_DBTable_ProductsDescription + '.products_description, ' +
1245: opmG_DBTable_ProductsDescription + '.products_url, ' + opmG_DBTable_Products + '.products_image, ' +
1246: opmG_DBTable_Specials + '.specials_new_products_price, ' + opmG_DBTable_ProductsDescription + '.language_id, ' +
1247: opmG_DBTable_Products + '.products_tax_class_id, ' + opmG_DBTable_ProductsDescription + '.products_viewed, ' +
1248: 'DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_available, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_added, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_last_modified, "%Y-%m-%d %H:%i:%S") ' +
1249: ', products_subimage1, products_subimage2, products_subimage3, products_subimage4, products_subimage5, products_subimage6 ' +
1250: 'from ' + opmG_DBTable_Products + ', ' + opmG_DBTable_ProductsDescription + ' ' +
1251: 'left join ' + opmG_DBTable_Specials + ' ON ' + opmG_DBTable_Products + '.products_id = ' + opmG_DBTable_Specials + '.products_id ' +
1252: 'LEFT JOIN ' + opmG_DBTable_ProductsToCategories + ' ON ' + opmG_DBTable_ProductsToCategories + '.products_id = ' + opmG_DBTable_Products + '.products_id ' +
1253: 'where ' + opmG_DBTable_Products + '.products_id=' + opmG_DBTable_ProductsDescription + '.products_id ' +
1254: 'and (' + opmG_DBTable_ProductsToCategories + '.categories_id is null ' +
1255: 'or ' + opmG_DBTable_ProductsToCategories + '.categories_id < 1) ' +
1256: 'order by ' + opmG_DBTable_ProductsDescription + '.products_name';
1257: END;
1258: IF (FNopm_ExecQuery (SQLStr, opmC_SQLSelect) > 0) THEN
1259: BEGIN
1260: IF (opmG_DBQuery.Active = TRUE) THEN
1261: BEGIN
1262: Screen.Cursor := opmC_Wait_Mouse;
1263: PRopm_WriteLog ('BEGIN record loading (LoadProdList)...');
1264: opmG_DBQuery.First;
1265: WHILE NOT opmG_DBQuery.EOF DO
1266: BEGIN
1267: ProdList[CurProd].ID := opmG_DBQuery.Fields[0].AsInteger;
1268: ProdList[CurProd].Model := FNopm_CleanString (opmG_DBQuery.Fields[2].AsString);
1269: ProdList[CurProd].Quantity := opmG_DBQuery.Fields[1].AsInteger;
1270: ProdList[CurProd].Price := opmG_DBQuery.Fields[3].AsCurrency;
1271: ProdList[CurProd].Weight := opmG_DBQuery.Fields[4].AsFloat;
1272: ProdList[CurProd].ManufacturerID := opmG_DBQuery.Fields[5].AsInteger;
1273: ProdList[CurProd].CategoryID := ProductCat;
1274: ProdList[CurProd].DisplayName := FNopm_CleanString (opmG_DBQuery.Fields[6].AsString);
1275: IF (ProdList[CurProd].DisplayName = '') THEN ProdList[CurProd].DisplayName := opmC_Unamed_Prod;
1276: ProdList[CurProd].Available := opmG_DBQuery.Fields[7].AsInteger;
1277: ProdList[CurProd].ImageURL := FNopm_CleanString (opmG_DBQuery.Fields[10].AsString);
1278: ProdList[CurProd].Special := opmG_DBQuery.Fields[11].AsCurrency;
1279: ProdList[CurProd].LanguageID := opmG_DBQuery.Fields[12].AsInteger;
1280: ProdList[CurProd].Tax := opmG_DBQuery.Fields[13].AsInteger;
1281:
1282: IF (opmG_Capa_MorePics6 = TRUE) THEN
1283: BEGIN
1284: ProdList[CurProd].ImageURL1 := FNopm_CleanString (opmG_DBQuery.Fields[18].AsString);
1285: ProdList[CurProd].ImageURL2 := FNopm_CleanString (opmG_DBQuery.Fields[19].AsString);
1286: ProdList[CurProd].ImageURL3 := FNopm_CleanString (opmG_DBQuery.Fields[20].AsString);
1287: ProdList[CurProd].ImageURL4 := FNopm_CleanString (opmG_DBQuery.Fields[21].AsString);
1288: ProdList[CurProd].ImageURL5 := FNopm_CleanString (opmG_DBQuery.Fields[22].AsString);
1289: ProdList[CurProd].ImageURL6 := FNopm_CleanString (opmG_DBQuery.Fields[23].AsString);
1290: END
1291: ELSE
1292: BEGIN
1293: ProdList[CurProd].ImageURL1 := '';
1294: ProdList[CurProd].ImageURL2 := '';
1295: ProdList[CurProd].ImageURL3 := '';
1296: ProdList[CurProd].ImageURL4 := '';
1297: ProdList[CurProd].ImageURL5 := '';
1298: ProdList[CurProd].ImageURL6 := '';
1299: END;
1300:
1301: ProdList[CurProd].CreationDate := FNopm_StringToDate (opmG_DBQuery.Fields[16].AsString);
1302: IF (ProdList[CurProd].CreationDate < opmG_Fallback_DateTime) THEN
1303: ProdList[CurProd].CreationDate := opmG_Fallback_DateTime;
1304: ProdList[CurProd].ChangeDate := FNopm_StringToDate (opmG_DBQuery.Fields[17].AsString);
1305: IF (ProdList[CurProd].ChangeDate < ProdList[CurProd].CreationDate) THEN
1306: ProdList[CurProd].ChangeDate := ProdList[CurProd].CreationDate;
1307: ProdList[CurProd].AvailDate := FNopm_StringToDate (opmG_DBQuery.Fields[15].AsString);
1308: IF (ProdList[CurProd].AvailDate < ProdList[CurProd].CreationDate) THEN
1309: ProdList[CurProd].AvailDate := ProdList[CurProd].CreationDate;
1310:
1311: DescList[CurProd].ID := opmG_DBQuery.Fields[0].AsInteger;
1312: DescList[CurProd].Name := FNopm_CleanString (opmG_DBQuery.Fields[6].AsString);
1313: IF (DescList[CurProd].Name = '') THEN DescList[CurProd].Name := opmC_Unamed_Prod;
1314: DescList[CurProd].Description := FNopm_CleanString (opmG_DBQuery.Fields[8].AsString);
1315: DescList[CurProd].URL := FNopm_CleanString (opmG_DBQuery.Fields[9].AsString);
1316: DescList[CurProd].Viewed := opmG_DBQuery.Fields[14].AsInteger;
1317: DescList[CurProd].LanguageID := opmG_DBQuery.Fields[12].AsInteger;
1318: INC (CurProd);
1319: opmG_DBQuery.Next;
1320: END;
1321: PRopm_WriteLog ('END record loading.');
1322: Screen.Cursor := opmC_Normal_Mouse;
1323: END;
1324: END;
1325: opm_TotalProducts := CurProd;
1326: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Got products list.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
1327: END;
1328: END;
1329:
1330:
1331: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1332: Loads the list of available tax classes into
1333: the taxes boxlist.
1334: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1335: PROCEDURE Topm_Form_Main.PRopm_LoadTaxList (VAR TaxList : opmT_TaxList; VAR TaxBoxList : TStringList);
1336: VAR
1337: CurTax : LONGINT;
1338: BEGIN
1339: TaxBoxList.Clear;
1340: TaxList[0].ID := 0;
1341: TaxList[0].Name := '';
1342: TaxList[0].ListIndex := 0;
1343: TaxList[0].SumRate := 0;
1344: TaxBoxList.Add ('');
1345: CurTax := 1;
1346: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 50, opmC_ProgressNone, _('Getting taxes list...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
1347: IF (FNopm_ExecQuery ('select ' + opmG_DBTable_TaxClass + '.tax_class_id, tax_class_title, sum(tax_rate) from ' + opmG_DBTable_TaxClass + ' left join ' + opmG_DBTable_TaxRates + ' on ' + opmG_DBTable_TaxClass + '.tax_class_id=' + opmG_DBTable_TaxRates + '.tax_class_id group by tax_class_id order by tax_class_title', opmC_SQLSelect) > 0) THEN
1348: BEGIN
1349: IF (opmG_DBQuery.Active = TRUE) THEN
1350: BEGIN
1351: Screen.Cursor := opmC_Wait_Mouse;
1352: PRopm_WriteLog ('BEGIN record loading (LoadTaxList)...');
1353: opmG_DBQuery.First;
1354: WHILE NOT opmG_DBQuery.EOF DO
1355: BEGIN
1356: TaxList[CurTax].ID := opmG_DBQuery.Fields[0].AsInteger;
1357: TaxList[CurTax].Name := FNopm_CleanString (opmG_DBQuery.Fields[1].AsString);
1358: TaxList[CurTax].SumRate := opmG_DBQuery.Fields[2].AsFloat;
1359: IF (TaxList[CurTax].Name = '') THEN TaxList[CurTax].Name := opmC_Unamed_Tax;
1360: TaxList[CurTax].Name := TaxList[CurTax].Name + ' (' + CURRTOSTR (TaxList[CurTax].SumRate) + '%)';
1361: TaxBoxList.Add (TaxList[CurTax].Name);
1362: TaxList[CurTax].ListIndex := CurTax;
1363: INC (CurTax);
1364: opmG_DBQuery.Next;
1365: END;
1366: PRopm_WriteLog ('END record loading.');
1367: Screen.Cursor := opmC_Normal_Mouse;
1368: END;
1369: END;
1370: opm_TotalTaxes := CurTax;
1371: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Got taxes list.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
1372: END;
1373:
1374:
1375:
1376:
1377: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1378: Loads the current currency record
1379: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1380: FUNCTION Topm_Form_Main.FNopm_LoadCurrency : opmR_Currency;
1381: VAR
1382: CurCurrR : opmR_Currency;
1383: BEGIN
1384: CurCurrR.Code := '';
1385: CurCurrR.Left := '';
1386: CurCurrR.Right := '';
1387: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 50, opmC_ProgressNone, _('Getting current currency...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
1388: IF (FNopm_ExecQuery ('select ' + opmG_DBTable_Currencies + '.code, ' + opmG_DBTable_Currencies + '.symbol_left, ' + opmG_DBTable_Currencies + '.symbol_right from ' +
1389: opmG_DBTable_Currencies + ', ' + opmG_DBTable_Configuration + ' where ' +
1390: opmG_DBTable_Configuration + '.configuration_key="DEFAULT_CURRENCY" and ' +
1391: opmG_DBTable_Configuration + '.configuration_value=' + opmG_DBTable_Currencies + '.code', opmC_SQLSelect) > 0) THEN
1392: BEGIN
1393: IF (opmG_DBQuery.Active = TRUE) THEN
1394: BEGIN
1395: Screen.Cursor := opmC_Wait_Mouse;
1396: opmG_DBQuery.First;
1397: CurCurrR.Code := TRIM (opmG_DBQuery.Fields[0].AsString);
1398: CurCurrR.Left := TRIM (opmG_DBQuery.Fields[1].AsString);
1399: CurCurrR.Right := TRIM (opmG_DBQuery.Fields[2].AsString);
1400: Screen.Cursor := opmC_Normal_Mouse;
1401: END;
1402: END;
1403: FNopm_LoadCurrency := CurCurrR;
1404: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Got current currency.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
1405: END;
1406:
1407:
1408: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1409: Clears the current currency record
1410: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1411: FUNCTION Topm_Form_Main.FNopm_ClearCurrency : opmR_Currency;
1412: VAR
1413: CurCurrR : opmR_Currency;
1414: BEGIN
1415: CurCurrR.Code := '';
1416: CurCurrR.Left := '';
1417: CurCurrR.Right := '';
1418: FNopm_ClearCurrency := CurCurrR;
1419: END;
1420:
1421:
1422:
1423:
1424: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1425: Start the building of the category tree.
1426: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1427: PROCEDURE Topm_Form_Main.PRopm_RenderCategoryDisplay (VAR CatList : opmT_CategoryList; VAR TreeControl : TTreeView; CurCatID : LONGINT);
1428: VAR
1429: MainNode, CurrentNode : TTreeNode;
1430: CurCat : opmR_Category;
1431: CatCount : LONGINT;
1432: BEGIN
1433: PRopm_WriteLog ('RenderCategoryDisplay BEGIN');
1434: TreeControl.Items.BeginUpdate;
1435: TreeControl.Items.Clear;
1436: IF (opm_TotalCategories > 0) THEN
1437: BEGIN
1438: MainNode := TreeControl.Items.AddFirst (NIL, opmG_DBHost);
1439: MainNode.ImageIndex := 0;
1440: MainNode.SelectedIndex := 1;
1441: PRopm_AddCatTreeNode (CatList, 0, MainNode, 0);
1442: FOR CatCount := 0 TO (opm_TotalCategories - 1) DO
1443: IF (CatList[CatCount].Parent = opmC_SC_Parent) THEN
1444: BEGIN
1445: CurrentNode := TreeControl.Items.Add (MainNode, CatList[CatCount].Name);
1446: CatList[CatCount].TreeIndex := CurrentNode.AbsoluteIndex;
1447: CurrentNode.ImageIndex := CatList[CatCount].ID - opmC_SC_BaseID + 3;
1448: CurrentNode.SelectedIndex := CatList[CatCount].ID - opmC_SC_BaseID + 4;
1449: END;
1450: TreeControl.FullCollapse;
1451: TreeControl.Items[0].Expand (FALSE);
1452: END;
1453: CurCat := FNopm_GetCategory (CatList, CurCatID, opmC_FindByID);
1454: IF ((CurCat.TreeIndex > 0) AND (TreeControl.Items.Count >= CurCat.TreeIndex)) THEN
1455: TreeControl.Items[CurCat.TreeIndex].Selected := TRUE;
1456: TreeControl.Items.EndUpdate;
1457: PRopm_WriteLog ('RenderCategoryDisplay END');
1458: END;
1459:
1460:
1461: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1462: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1463: PROCEDURE Topm_Form_Main.PRopm_RenderLanguageDisplay (VAR ListControl : TComboBox; VAR LangList : opmT_LanguageList);
1464: VAR
1465: CurLang : LONGINT;
1466: DisplayLangIndex : LONGINT;
1467: BEGIN
1468: PRopm_WriteLog ('RenderLanguageDisplay BEGIN');
1469: ListControl.Items.Clear;
1470: ListControl.Items := opmG_LanguageBoxList;
1471: DisplayLangIndex := -1;
1472: FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
1473: IF (opm_CurrentLang = LangList[CurLang].ID) THEN DisplayLangIndex := CurLang;
1474: ListControl.ItemIndex := DisplayLangIndex;
1475: PRopm_WriteLog ('RenderLanguageDisplay END');
1476: END;
1477:
1478:
1479: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1480: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1481: PROCEDURE Topm_Form_Main.PRopm_RenderProductDisplay (VAR CatList : opmT_CategoryList; VAR ManList : opmT_ManufacturerList; VAR ProdList : opmT_ProductList; VAR ListControl : TListView; CurProdID : LONGINT);
1482: VAR
1483: CurProd, DispProd : LONGINT;
1484: CurItem : TListItem;
1485: CurMan : opmR_Manufacturer;
1486: CurCat : opmR_Category;
1487: BEGIN
1488: PRopm_WriteLog ('RenderProductDisplay BEGIN');
1489: ListControl.Column[opmG_PList_LastOrderColumn].ImageIndex := -1;
1490: ListControl.Items.BeginUpdate;
1491: ListControl.Items.Clear;
1492: DispProd := 0;
1493: FOR CurProd := 0 TO (opm_TotalProducts - 1) DO
1494: BEGIN
1495: IF (ProdList[CurProd].LanguageID = opm_CurrentLang) THEN
1496: BEGIN
1497: CurItem := ListControl.Items.Add;
1498: IF (ProdList[CurProd].Available > 0) THEN CurItem.ImageIndex := 0 ELSE CurItem.ImageIndex := 1;
1499: CurItem.SubItems.Add (INTTOSTR (ProdList[CurProd].ID));
1500: CurItem.SubItems.Add (ProdList[CurProd].Model);
1501: CurCat := FNopm_GetCategory (CatList, ProdList[CurProd].CategoryID, opmC_FindByID);
1502: CurItem.SubItems.Add (CurCat.Name);
1503: CurItem.SubItems.Add (ProdList[CurProd].DisplayName);
1504: CurMan := FNopm_GetManufacturer (ManList, ProdList[CurProd].ManufacturerID, opmC_FindByID);
1505: CurItem.SubItems.Add (CurMan.Name);
1506: CurItem.SubItems.Add (INTTOSTR (ProdList[CurProd].Quantity));
1507: IF (ProdList[CurProd].Special > 0) THEN
1508: CurItem.SubItems.Add (FNopm_CleanNumber (CURRTOSTR (ProdList[CurProd].Special), opmC_ValIsFloat))
1509: ELSE
1510: CurItem.SubItems.Add (FNopm_CleanNumber (CURRTOSTR (ProdList[CurProd].Price), opmC_ValIsFloat));
1511: CurItem.SubItems.Add (FLOATTOSTR (ProdList[CurProd].Weight));
1512: CurItem.SubItems.Add (FNopm_DateToString (ProdList[CurProd].AvailDate));
1513: CurItem.SubItems.Add ('');
1514: IF (ProdList[CurProd].Special > 0) THEN CurItem.SubItemImages[6] := 2;
1515: IF ((ProdList[CurProd].ImageURL1 <> '') OR
1516: (ProdList[CurProd].ImageURL2 <> '') OR
1517: (ProdList[CurProd].ImageURL3 <> '') OR
1518: (ProdList[CurProd].ImageURL4 <> '') OR
1519: (ProdList[CurProd].ImageURL5 <> '') OR
1520: (ProdList[CurProd].ImageURL6 <> '')) THEN
1521: CurItem.SubItemImages[9] := 10
1522: ELSE IF (ProdList[CurProd].ImageURL <> '') THEN
1523: CurItem.SubItemImages[9] := 6
1524: ELSE
1525: CurItem.SubItemImages[9] := 7;
1526: INC (DispProd);
1527: IF (CurProdID = ProdList[CurProd].ID) THEN
1528: BEGIN
1529: ListControl.Selected := CurItem;
1530: ListControl.ItemFocused := CurItem;
1531: END;
1532: END;
1533: END;
1534: ListControl.Column[opmG_PList_LastOrderColumn].ImageIndex := 9;
1535: ListControl.CustomSort (@FNopm_Sort_ProductList, opmG_PList_LastOrderColumn);
1536: ListControl.Items.EndUpdate;
1537: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressIgnore, opmC_ProgressIgnore, '', DispProd, opm_CurrentCurrency.Code);
1538: PRopm_WriteLog ('RenderProductDisplay END');
1539: END;
1540:
1541:
1542: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1543: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1544: PROCEDURE Topm_Form_Main.PRopm_ClearCategoryList (VAR CatList : TStringList);
1545: BEGIN
1546: CatList.Clear;
1547: opm_CurrentCategory := 0;
1548: opm_TotalCategories := 0;
1549: END;
1550:
1551:
1552: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1553: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1554: PROCEDURE Topm_Form_Main.PRopm_ClearLanguageList (VAR LangList : TStringList);
1555: BEGIN
1556: LangList.Clear;
1557: opm_TotalLanguages := 0;
1558: END;
1559:
1560:
1561: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1562: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1563: PROCEDURE Topm_Form_Main.PRopm_ClearManufacturerList (VAR ManList : TStringList);
1564: BEGIN
1565: ManList.Clear;
1566: opm_TotalManufacturers := 0;
1567: END;
1568:
1569:
1570: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1571: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1572: PROCEDURE Topm_Form_Main.PRopm_ClearTaxList (VAR TaxList : TStringList);
1573: BEGIN
1574: TaxList.Clear;
1575: opm_TotalTaxes := 0;
1576: END;
1577:
1578:
1579: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1580: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1581: PROCEDURE Topm_Form_Main.PRopm_ClearProductList (VAR ListView : TListView);
1582: BEGIN
1583: ListView.Items.BeginUpdate;
1584: ListView.Items.Clear;
1585: ListView.Items.EndUpdate;
1586: opm_TotalProducts := 0;
1587: END;
1588:
1589:
1590: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1591: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1592: PROCEDURE Topm_Form_Main.PRopm_SearchProducts (PCategory, PManufacturer: LONGINT;
1593: PModel, PName, PDesc : STRING;
1594: PSPrice, PImgURL, PAvailable : LONGINT;
1595: VAR ProdList : opmT_ProductList;
1596: VAR DescList : opmT_DescriptionList;
1597: MultiString : STRING);
1598: VAR
1599: SelectStr, FromStr, WhereStr, OrderStr : STRING;
1600: CurProd : LONGINT;
1601: BEGIN
1602: IF (opmG_Capa_MorePics6 = FALSE) THEN
1603: SelectStr := 'select ' + opmG_DBTable_Products + '.products_id, ' + opmG_DBTable_Products + '.products_quantity, ' + opmG_DBTable_Products + '.products_model, ' + opmG_DBTable_Products + '.products_price, ' + opmG_DBTable_Products + '.products_weight, ' + opmG_DBTable_Products + '.manufacturers_id, ' +
1604: '' + opmG_DBTable_ProductsDescription + '.products_name, ' + opmG_DBTable_Products + '.products_status, ' + opmG_DBTable_ProductsDescription + '.products_description, ' + opmG_DBTable_ProductsDescription + '.products_url, ' + opmG_DBTable_Products + '.products_image, ' +
1605: '' + opmG_DBTable_Specials + '.specials_new_products_price, ' + opmG_DBTable_ProductsToCategories + '.categories_id, ' + opmG_DBTable_ProductsDescription + '.language_id, ' + opmG_DBTable_Products + '.products_tax_class_id, ' + opmG_DBTable_ProductsDescription + '.products_viewed, ' +
1606: 'DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_available, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_added, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_last_modified, "%Y-%m-%d %H:%i:%S")'
1607: ELSE
1608: SelectStr := 'select ' + opmG_DBTable_Products + '.products_id, ' + opmG_DBTable_Products + '.products_quantity, ' + opmG_DBTable_Products + '.products_model, ' + opmG_DBTable_Products + '.products_price, ' + opmG_DBTable_Products + '.products_weight, ' + opmG_DBTable_Products + '.manufacturers_id, ' +
1609: '' + opmG_DBTable_ProductsDescription + '.products_name, ' + opmG_DBTable_Products + '.products_status, ' + opmG_DBTable_ProductsDescription + '.products_description, ' + opmG_DBTable_ProductsDescription + '.products_url, ' + opmG_DBTable_Products + '.products_image, ' +
1610: '' + opmG_DBTable_Specials + '.specials_new_products_price, ' + opmG_DBTable_ProductsToCategories + '.categories_id, ' + opmG_DBTable_ProductsDescription + '.language_id, ' + opmG_DBTable_Products + '.products_tax_class_id, ' + opmG_DBTable_ProductsDescription + '.products_viewed, ' +
1611: 'DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_available, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_date_added, "%Y-%m-%d %H:%i:%S"), DATE_FORMAT(' + opmG_DBTable_Products + '.products_last_modified, "%Y-%m-%d %H:%i:%S"), ' +
1612: 'products_subimage1, products_subimage2, products_subimage3, products_subimage4, products_subimage5, products_subimage6';
1613: FromStr := ' from ' + opmG_DBTable_Products + ', ' + opmG_DBTable_ProductsDescription + ', ' + opmG_DBTable_ProductsToCategories + ' left join ' + opmG_DBTable_Specials + ' ON ' + opmG_DBTable_Products + '.products_id = ' + opmG_DBTable_Specials + '.products_id where';
1614: OrderStr := ' order by ' + opmG_DBTable_ProductsDescription + '.products_name';
1615: IF (PCategory > 0) THEN
1616: WhereStr := WhereStr + ' ' + opmG_DBTable_ProductsToCategories + '.products_id=' + opmG_DBTable_Products + '.products_id and ' + opmG_DBTable_ProductsToCategories + '.categories_id=' + INTTOSTR (PCategory)
1617: ELSE
1618: WhereStr := WhereStr + ' ' + opmG_DBTable_ProductsToCategories + '.products_id=' + opmG_DBTable_Products + '.products_id';
1619: IF (PManufacturer > 0) THEN
1620: IF (WhereStr <> '')
1621: THEN WhereStr := WhereStr + ' and ' + opmG_DBTable_Products + '.manufacturers_id=' + INTTOSTR (PManufacturer)
1622: ELSE WhereStr := WhereStr + ' ' + opmG_DBTable_Products + '.manufacturers_id=' + INTTOSTR (PManufacturer);
1623: IF (MultiString <> '') THEN
1624: BEGIN
1625: MultiString := FNopm_CleanSQLString (MultiString, TRUE);
1626: IF (WhereStr <> '') THEN WhereStr := WhereStr + ' and ' ELSE WhereStr := WhereStr + ' ';
1627: WhereStr := WhereStr + '(' + opmG_DBTable_Products + '.products_model like "%' + MultiString + '%"';
1628: WhereStr := WhereStr + ' or ' + opmG_DBTable_ProductsDescription + '.products_name like "%' + MultiString + '%"';
1629: WhereStr := WhereStr + ' or ' + opmG_DBTable_ProductsDescription + '.products_description like "%' + MultiString + '%")';
1630: END
1631: ELSE
1632: BEGIN
1633: IF (PModel <> '') THEN
1634: IF (WhereStr <> '')
1635: THEN WhereStr := WhereStr + ' and ' + opmG_DBTable_Products + '.products_model like "%' + FNopm_CleanSQLString (PModel, TRUE) + '%"'
1636: ELSE WhereStr := WhereStr + ' ' + opmG_DBTable_Products + '.products_model like "%' + FNopm_CleanSQLString (PModel, TRUE) + '%"';
1637: IF (PName <> '') THEN
1638: IF (WhereStr <> '')
1639: THEN WhereStr := WhereStr + ' and ' + opmG_DBTable_ProductsDescription + '.products_name like "%' + FNopm_CleanSQLString (PName, TRUE) + '%"'
1640: ELSE WhereStr := WhereStr + ' ' + opmG_DBTable_ProductsDescription + '.products_name like "%' + FNopm_CleanSQLString (PName, TRUE) + '%"';
1641: IF (PDesc <> '') THEN
1642: IF (WhereStr <> '')
1643: THEN WhereStr := WhereStr + ' and ' + opmG_DBTable_ProductsDescription + '.products_description like "%' + FNopm_CleanSQLString (PDesc, TRUE) + '%"'
1644: ELSE WhereStr := WhereStr + ' ' + opmG_DBTable_ProductsDescription + '.products_description like "%' + FNopm_CleanSQLString (PDesc, TRUE) + '%"';
1645: END;
1646: IF (PAvailable = opmC_SearchYes) THEN
1647: IF (WhereStr <> '')
1648: THEN WhereStr := WhereStr + ' and ' + opmG_DBTable_Products + '.products_status > 0'
1649: ELSE WhereStr := WhereStr + ' ' + opmG_DBTable_Products + '.products_status > 0'
1650: ELSE IF (PAvailable = opmC_SearchNo) THEN
1651: IF (WhereStr <> '')
1652: THEN WhereStr := WhereStr + ' and ' + opmG_DBTable_Products + '.products_status = 0'
1653: ELSE WhereStr := WhereStr + ' ' + opmG_DBTable_Products + '.products_status = 0';
1654: IF (PImgURL = opmC_SearchYes) THEN
1655: IF (WhereStr <> '')
1656: THEN WhereStr := WhereStr + ' and ' + '(' + opmG_DBTable_Products + '.products_image <> "" and ' + opmG_DBTable_Products + '.products_image IS NOT NULL)'
1657: ELSE WhereStr := WhereStr + ' (' + opmG_DBTable_Products + '.products_image <> "" and ' + opmG_DBTable_Products + '.products_image IS NOT NULL)'
1658: ELSE IF (PImgURL = opmC_SearchNo) THEN
1659: IF (WhereStr <> '')
1660: THEN WhereStr := WhereStr + ' and ' + '(' + opmG_DBTable_Products + '.products_image = "" or ' + opmG_DBTable_Products + '.products_image IS NULL)'
1661: ELSE WhereStr := WhereStr + ' (' + opmG_DBTable_Products + '.products_image = "" or ' + opmG_DBTable_Products + '.products_image IS NULL)';
1662: IF (PSPrice = opmC_SearchYes) THEN
1663: IF (WhereStr <> '')
1664: THEN WhereStr := WhereStr + ' and ' + opmG_DBTable_Specials + '.specials_new_products_price > 0'
1665: ELSE WhereStr := WhereStr + ' ' + opmG_DBTable_Specials + '.specials_new_products_price > 0'
1666: ELSE IF (PSPrice = opmC_SearchNo) THEN
1667: IF (WhereStr <> '')
1668: THEN WhereStr := WhereStr + ' and (' + opmG_DBTable_Specials + '.specials_new_products_price = 0 or ' + opmG_DBTable_Specials + '.specials_new_products_price IS NULL)'
1669: ELSE WhereStr := WhereStr + ' (' + opmG_DBTable_Specials + '.specials_new_products_price = 0 or ' + opmG_DBTable_Specials + '.specials_new_products_price IS NULL)';
1670: IF (WhereStr <> '')
1671: THEN WhereStr := WhereStr + ' and ' + opmG_DBTable_Products + '.products_id=' + opmG_DBTable_ProductsDescription + '.products_id'
1672: ELSE WhereStr := WhereStr + ' ' + opmG_DBTable_Products + '.products_id=' + opmG_DBTable_ProductsDescription + '.products_id';
1673: CurProd := 0;
1674: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 50, opmC_ProgressNone, _('Getting products list...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
1675: opm_WeAreSearching := TRUE;
1676: IF (FNopm_ExecQuery (SelectStr + FromStr + WhereStr + OrderStr, opmC_SQLSelect) > 0) THEN
1677: BEGIN
1678: IF (opmG_DBQuery.Active = TRUE) THEN
1679: BEGIN
1680: Screen.Cursor := opmC_Wait_Mouse;
1681: PRopm_WriteLog ('BEGIN record loading (LoadSearchList)...');
1682: opmG_DBQuery.First;
1683: WHILE NOT opmG_DBQuery.EOF DO
1684: BEGIN
1685: ProdList[CurProd].ID := opmG_DBQuery.Fields[0].AsInteger;
1686: ProdList[CurProd].Model := FNopm_CleanString (opmG_DBQuery.Fields[2].AsString);
1687: ProdList[CurProd].Quantity := opmG_DBQuery.Fields[1].AsInteger;
1688: ProdList[CurProd].Price := opmG_DBQuery.Fields[3].AsCurrency;
1689: ProdList[CurProd].Weight := opmG_DBQuery.Fields[4].AsFloat;
1690: ProdList[CurProd].ManufacturerID := opmG_DBQuery.Fields[5].AsInteger;
1691: ProdList[CurProd].CategoryID := opmG_DBQuery.Fields[12].AsInteger;
1692: ProdList[CurProd].DisplayName := FNopm_CleanString (opmG_DBQuery.Fields[6].AsString);
1693: IF (TRIM (ProdList[CurProd].DisplayName) = '') THEN ProdList[CurProd].DisplayName := opmC_Unamed_Prod;
1694: ProdList[CurProd].Available := opmG_DBQuery.Fields[7].AsInteger;
1695: ProdList[CurProd].ImageURL := FNopm_CleanString (opmG_DBQuery.Fields[10].AsString);
1696: ProdList[CurProd].Special := opmG_DBQuery.Fields[11].AsCurrency;
1697: ProdList[CurProd].LanguageID := opmG_DBQuery.Fields[13].AsInteger;
1698: ProdList[CurProd].Tax := opmG_DBQuery.Fields[14].AsInteger;
1699:
1700: ProdList[CurProd].CreationDate := FNopm_StringToDate (opmG_DBQuery.Fields[17].AsString);
1701: IF (ProdList[CurProd].CreationDate < opmG_Fallback_DateTime) THEN
1702: ProdList[CurProd].CreationDate := opmG_Fallback_DateTime;
1703: ProdList[CurProd].ChangeDate := FNopm_StringToDate (opmG_DBQuery.Fields[18].AsString);
1704: IF (ProdList[CurProd].ChangeDate < ProdList[CurProd].CreationDate) THEN
1705: ProdList[CurProd].ChangeDate := ProdList[CurProd].CreationDate;
1706: ProdList[CurProd].AvailDate := FNopm_StringToDate (opmG_DBQuery.Fields[16].AsString);
1707: IF (ProdList[CurProd].AvailDate < ProdList[CurProd].CreationDate) THEN
1708: ProdList[CurProd].AvailDate := ProdList[CurProd].CreationDate;
1709:
1710: IF (opmG_Capa_MorePics6 = TRUE) THEN
1711: BEGIN
1712: ProdList[CurProd].ImageURL1 := FNopm_CleanString (opmG_DBQuery.Fields[19].AsString);
1713: ProdList[CurProd].ImageURL2 := FNopm_CleanString (opmG_DBQuery.Fields[20].AsString);
1714: ProdList[CurProd].ImageURL3 := FNopm_CleanString (opmG_DBQuery.Fields[21].AsString);
1715: ProdList[CurProd].ImageURL4 := FNopm_CleanString (opmG_DBQuery.Fields[22].AsString);
1716: ProdList[CurProd].ImageURL5 := FNopm_CleanString (opmG_DBQuery.Fields[23].AsString);
1717: ProdList[CurProd].ImageURL6 := FNopm_CleanString (opmG_DBQuery.Fields[24].AsString);
1718: END
1719: ELSE
1720: BEGIN
1721: ProdList[CurProd].ImageURL1 := '';
1722: ProdList[CurProd].ImageURL2 := '';
1723: ProdList[CurProd].ImageURL3 := '';
1724: ProdList[CurProd].ImageURL4 := '';
1725: ProdList[CurProd].ImageURL5 := '';
1726: ProdList[CurProd].ImageURL6 := '';
1727: END;
1728:
1729: DescList[CurProd].ID := opmG_DBQuery.Fields[0].AsInteger;
1730: DescList[CurProd].Name := FNopm_CleanString (opmG_DBQuery.Fields[6].AsString);
1731: IF (TRIM (DescList[CurProd].Name) = '') THEN DescList[CurProd].Name := opmC_Unamed_Prod;
1732: DescList[CurProd].Description := FNopm_CleanString (opmG_DBQuery.Fields[8].AsString);
1733: DescList[CurProd].URL := FNopm_CleanString (opmG_DBQuery.Fields[9].AsString);
1734: DescList[CurProd].Viewed := opmG_DBQuery.Fields[15].AsInteger;
1735: DescList[CurProd].LanguageID := opmG_DBQuery.Fields[13].AsInteger;
1736: INC (CurProd);
1737:
1738: opmG_DBQuery.Next;
1739: END;
1740: PRopm_WriteLog ('END record loading [' + INTTOSTR (CurProd) + '].');
1741: Screen.Cursor := opmC_Normal_Mouse;
1742: END;
1743: END;
1744: opm_TotalProducts := CurProd;
1745: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Got products list.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
1746: END;
1747:
1748:
1749:
1750:
1751: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1752: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1753: FUNCTION Topm_Form_Main.FNopm_GetCategory (VAR CatList : opmT_CategoryList; CatID : LONGINT; SearchBy : INTEGER) : opmR_Category;
1754: VAR
1755: CurCatR : opmR_Category;
1756: CurCat : LONGINT;
1757: BEGIN
1758: CurCatR.ID := 0;
1759: CurCatR.Parent := 0;
1760: CurCatR.Name := '';
1761: CurCatR.ListIndex := 0;
1762: CurCatR.TreeIndex := 0;
1763: FNopm_GetCategory := CurCatR;
1764: IF (SearchBy = opmC_FindByID) THEN
1765: FOR CurCat := 0 TO (opm_TotalCategories - 1) DO
1766: BEGIN
1767: IF (CatList[CurCat].ID = CatID) THEN
1768: BEGIN
1769: CurCatR.ID := CatList[CurCat].ID;
1770: CurCatR.Parent := CatList[CurCat].Parent;
1771: CurCatR.Name := CatList[CurCat].Name;
1772: CurCatR.ListIndex := CatList[CurCat].ListIndex;
1773: CurCatR.TreeIndex := CatList[CurCat].TreeIndex;
1774: FNopm_GetCategory := CurCatR;
1775: BREAK;
1776: END;
1777: END
1778: ELSE IF (SearchBy = opmC_FindByIndex) THEN
1779: FOR CurCat := 0 TO (opm_TotalCategories - 1) DO
1780: BEGIN
1781: IF (CatList[CurCat].ListIndex = CatID) THEN
1782: BEGIN
1783: CurCatR.ID := CatList[CurCat].ID;
1784: CurCatR.Parent := CatList[CurCat].Parent;
1785: CurCatR.Name := CatList[CurCat].Name;
1786: CurCatR.ListIndex := CatList[CurCat].ListIndex;
1787: CurCatR.TreeIndex := CatList[CurCat].TreeIndex;
1788: FNopm_GetCategory := CurCatR;
1789: BREAK;
1790: END;
1791: END
1792: ELSE
1793: FOR CurCat := 0 TO (opm_TotalCategories - 1) DO
1794: BEGIN
1795: IF (CatList[CurCat].TreeIndex = CatID) THEN
1796: BEGIN
1797: CurCatR.ID := CatList[CurCat].ID;
1798: CurCatR.Parent := CatList[CurCat].Parent;
1799: CurCatR.Name := CatList[CurCat].Name;
1800: CurCatR.ListIndex := CatList[CurCat].ListIndex;
1801: CurCatR.TreeIndex := CatList[CurCat].TreeIndex;
1802: FNopm_GetCategory := CurCatR;
1803: BREAK;
1804: END;
1805: END;
1806: END;
1807:
1808:
1809:
1810: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1811: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1812: PROCEDURE Topm_Form_Main.PRopm_GetCategory_Data (CatID : LONGINT; VAR CatData : opmT_SingleCatList);
1813: VAR
1814: CurCat : LONGINT;
1815: MaxCat : LONGINT;
1816: CurLang : LONGINT;
1817: TmpCatList : opmT_SingleCatList;
1818: BEGIN
1819: CatData[0].ID := -1;
1820: CatData[0].Parent := 0;
1821: CatData[0].Name := '';
1822: CatData[0].LanguageID := -1;
1823: CurCat := 0;
1824: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 50, opmC_ProgressNone, _('Getting single category data...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
1825: IF (FNopm_ExecQuery ('select ' + opmG_DBTable_Categories + '.categories_id, ' + opmG_DBTable_Categories + '.parent_id, ' + opmG_DBTable_CategoriesDescription + '.categories_name, ' + opmG_DBTable_CategoriesDescription + '.language_id from ' + opmG_DBTable_Categories + ' left join ' + opmG_DBTable_CategoriesDescription + ' on ' + opmG_DBTable_Categories + '.categories_id=' + opmG_DBTable_CategoriesDescription + '.categories_id where ' + opmG_DBTable_Categories + '.categories_id=' + INTTOSTR (CatID) + ' ORDER BY ' + opmG_DBTable_CategoriesDescription + '.language_id', opmC_SQLSelect) > 0) THEN
1826: BEGIN
1827: IF (opmG_DBQuery.Active = TRUE) THEN
1828: BEGIN
1829: Screen.Cursor := opmC_Wait_Mouse;
1830: PRopm_WriteLog ('BEGIN record loading (LoadCatDataList)...');
1831: opmG_DBQuery.First;
1832: WHILE NOT opmG_DBQuery.EOF DO
1833: BEGIN
1834: CatData[CurCat].ID := opmG_DBQuery.Fields[0].AsInteger;
1835: CatData[CurCat].Parent := opmG_DBQuery.Fields[1].AsInteger;
1836: CatData[CurCat].Name := FNopm_CleanString (opmG_DBQuery.Fields[2].AsString);
1837: CatData[CurCat].LanguageID := opmG_DBQuery.Fields[3].AsInteger;
1838: IF (CatData[CurCat].Name = '') THEN CatData[CurCat].Name := opmC_Unamed_Cat;
1839: INC (CurCat);
1840: opmG_DBQuery.Next;
1841: END;
1842: PRopm_WriteLog ('END record loading.');
1843: Screen.Cursor := opmC_Normal_Mouse;
1844: END;
1845: MaxCat := (CurCat - 1);
1846: FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
1847: BEGIN
1848: TmpCatList[CurLang].ID := -1;
1849: TmpCatList[CurLang].Parent := 0;
1850: TmpCatList[CurLang].Name := '';
1851: TmpCatList[CurLang].LanguageID := -1;
1852: END;
1853: FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
1854: BEGIN
1855: FOR CurCat := 0 TO MaxCat DO
1856: BEGIN
1857: IF (CatData[CurCat].LanguageID = opmG_LanguageList[CurLang].ID) THEN
1858: BEGIN
1859: TmpCatList[CurLang] := CatData[CurCat];
1860: BREAK;
1861: END;
1862: END;
1863: END;
1864: CatData := TmpCatList;
1865: { Sort the array... }
1866: { FOR CurCat := 0 TO (MaxCat) DO
1867: BEGIN
1868: CatIndex := CurCat;
1869: FOR CatCount2 := (CurCat + 1) TO (MaxCat) DO
1870: IF (CatData[CatIndex].LanguageID > CatData[CatCount2].LanguageID) THEN CatIndex := CatCount2;
1871: opm_SwapCatRecord := CatData[CatIndex];
1872: CatData[CatIndex] := CatData[CurCat];
1873: CatData[CurCat] := opm_SwapCatRecord;
1874: END;}
1875: END;
1876: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Got single category data.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
1877: END;
1878:
1879:
1880:
1881: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1882: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1883: FUNCTION Topm_Form_Main.FNopm_GetRealLangIDByIndex (VAR LangList : opmT_LanguageList; LangIndex : LONGINT) : LONGINT;
1884: VAR
1885: CurLang : LONGINT;
1886: BEGIN
1887: FNopm_GetRealLangIDByIndex := 0;
1888: FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
1889: BEGIN
1890: IF (LangList[CurLang].ListIndex = LangIndex) THEN
1891: BEGIN
1892: FNopm_GetRealLangIDByIndex := LangList[CurLang].ID;
1893: BREAK;
1894: END;
1895: END;
1896: END;
1897:
1898:
1899:
1900: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1901: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1902: FUNCTION Topm_Form_Main.FNopm_GetManufacturer (VAR ManList : opmT_ManufacturerList; ManID : LONGINT; SearchBy : INTEGER) : opmR_Manufacturer;
1903: VAR
1904: CurManR : opmR_Manufacturer;
1905: CurMan : LONGINT;
1906: BEGIN
1907: CurManR.ID := 0;
1908: CurManR.Name := '';
1909: CurManR.ListIndex := 0;
1910: FNopm_GetManufacturer := CurManR;
1911: IF (SearchBy = opmC_FindByID) THEN
1912: FOR CurMan := 0 TO (opm_TotalManufacturers - 1) DO
1913: BEGIN
1914: IF (ManList[CurMan].ID = ManID) THEN
1915: BEGIN
1916: CurManR.ID := ManList[CurMan].ID;
1917: CurManR.Name := ManList[CurMan].Name;
1918: CurManR.ListIndex := ManList[CurMan].ListIndex;
1919: FNopm_GetManufacturer := CurManR;
1920: BREAK;
1921: END;
1922: END
1923: ELSE
1924: FOR CurMan := 0 TO (opm_TotalManufacturers - 1) DO
1925: BEGIN
1926: IF (ManList[CurMan].ListIndex = ManID) THEN
1927: BEGIN
1928: CurManR.ID := ManList[CurMan].ID;
1929: CurManR.Name := ManList[CurMan].Name;
1930: CurManR.ListIndex := ManList[CurMan].ListIndex;
1931: FNopm_GetManufacturer := CurManR;
1932: BREAK;
1933: END;
1934: END;
1935: END;
1936:
1937:
1938:
1939: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1940: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1941: FUNCTION Topm_Form_Main.FNopm_GetProductByID (ProdID, LangID : LONGINT; VAR ProdList : opmT_ProductList) : opmR_Product;
1942: VAR
1943: CurProdR : opmR_Product;
1944: CurProd : LONGINT;
1945: BEGIN
1946: CurProdR.ID := -1;
1947: FNopm_GetProductByID := CurProdR;
1948: FOR CurProd := 0 TO (opm_TotalProducts - 1) DO
1949: BEGIN
1950: IF ((ProdList[CurProd].ID = ProdID) AND (ProdList[CurProd].LanguageID = LangID)) THEN
1951: BEGIN
1952: CurProdR.ID := ProdList[CurProd].ID;
1953: CurProdR.Model := ProdList[CurProd].Model;
1954: CurProdR.Quantity := ProdList[CurProd].Quantity;
1955: CurProdR.Price := ProdList[CurProd].Price;
1956: CurProdR.Weight := ProdList[CurProd].Weight;
1957: CurProdR.ManufacturerID := ProdList[CurProd].ManufacturerID;
1958: CurProdR.CategoryID := ProdList[CurProd].CategoryID;
1959: CurProdR.DisplayName := ProdList[CurProd].DisplayName;
1960: CurProdR.Available := ProdList[CurProd].Available;
1961: CurProdR.ImageURL := ProdList[CurProd].ImageURL;
1962: CurProdR.ImageURL1 := ProdList[CurProd].ImageURL1;
1963: CurProdR.ImageURL2 := ProdList[CurProd].ImageURL2;
1964: CurProdR.ImageURL3 := ProdList[CurProd].ImageURL3;
1965: CurProdR.ImageURL4 := ProdList[CurProd].ImageURL4;
1966: CurProdR.ImageURL5 := ProdList[CurProd].ImageURL5;
1967: CurProdR.ImageURL6 := ProdList[CurProd].ImageURL6;
1968: CurProdR.Special := ProdList[CurProd].Special;
1969: CurProdR.LanguageID := ProdList[CurProd].LanguageID;
1970: CurProdR.Tax := ProdList[CurProd].Tax;
1971: CurProdR.CreationDate := ProdList[CurProd].CreationDate;
1972: CurProdR.ChangeDate := ProdList[CurProd].ChangeDate;
1973: CurProdR.AvailDate := ProdList[CurProd].AvailDate;
1974: FNopm_GetProductByID := CurProdR;
1975: BREAK;
1976: END;
1977: END;
1978: END;
1979:
1980:
1981:
1982: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1983: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
1984: FUNCTION Topm_Form_Main.FNopm_GetDescriptionByID (ProdID, LangID : LONGINT; VAR DescList : opmT_DescriptionList) : opmR_Description;
1985: VAR
1986: CurDescR : opmR_Description;
1987: CurDesc : LONGINT;
1988: BEGIN
1989: CurDescR.ID := -1;
1990: FNopm_GetDescriptionByID := CurDescR;
1991: FOR CurDesc := 0 TO (opm_TotalProducts - 1) DO
1992: BEGIN
1993: IF ((DescList[CurDesc].ID = ProdID) AND (DescList[CurDesc].LanguageID = LangID)) THEN
1994: BEGIN
1995: CurDescR.ID := DescList[CurDesc].ID;
1996: CurDescR.Name := DescList[CurDesc].Name;
1997: CurDescR.Description := DescList[CurDesc].Description;
1998: CurDescR.URL := DescList[CurDesc].URL;
1999: CurDescR.LanguageID := DescList[CurDesc].LanguageID;
2000: CurDescR.Viewed := DescList[CurDesc].Viewed;
2001: FNopm_GetDescriptionByID := CurDescR;
2002: BREAK;
2003: END;
2004: END;
2005: END;
2006:
2007:
2008:
2009:
2010:
2011: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2012: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2013: procedure Topm_Form_Main.opm_TreeView_MainChange(Sender: TObject; Node: TTreeNode);
2014: begin
2015: IF (opm_TreeView_Main.Selected <> NIL) THEN
2016: BEGIN
2017: opm_CurrentCatRecord := FNopm_GetCategory (opmG_CategoryList, Node.AbsoluteIndex, opmC_FindByNode);
2018: opm_CurrentCategory := opm_CurrentCatRecord.ID;
2019: IF (opm_CurrentCatRecord.ID < opmC_SC_BaseID) THEN
2020: BEGIN
2021: IF (opmG_UIClickLoad > 0) THEN
2022: BEGIN
2023: PRopm_Sound ('MenuPopup', opmG_UISilent);
2024: PRopm_LoadProductListByCat (opm_CurrentCategory, opmG_ProductList, opmG_DescriptionList);
2025: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
2026: IF (opm_CurrentCatRecord.ID > 0) THEN
2027: PRopm_Valid_CatOps (opm_WeAreConnected, opm_TreeView_Main.Selected)
2028: ELSE
2029: PRopm_Valid_CatOps (opm_WeAreConnected, NIL);
2030: PRopm_Valid_ProdOps (opm_WeAreConnected, opm_ListView_Main.Selected, opm_ListView_Main.SelCount, opm_TreeView_Main.Selected);
2031: END;
2032: END
2033: ELSE
2034: BEGIN
2035: { CLICK IN SPECIAL NODE, PROCESS HERE... }
2036: PRopm_Valid_CatOps (opm_WeAreConnected, NIL);
2037: PRopm_Valid_ProdOps (opm_WeAreConnected, NIL, 0, NIL);
2038: END
2039: END
2040: ELSE
2041: BEGIN
2042: PRopm_Valid_CatOps (opm_WeAreConnected, NIL);
2043: PRopm_Valid_ProdOps (opm_WeAreConnected, NIL, 0, NIL);
2044: END;
2045: end;
2046:
2047:
2048: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2049: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2050: procedure Topm_Form_Main.opm_MenuItem_RefreshCategoriesClick (Sender: TObject);
2051: begin
2052: PRopm_LoadLanguageList (opmG_LanguageList);
2053: PRopm_LoadCategoryList (opmG_CategoryList, opmG_CategoryBoxList);
2054: PRopm_LoadManufacturerList (opmG_ManufacturerList, opmG_ManufacturerBoxList);
2055: PRopm_LoadTaxList (opmG_TaxList, opmG_TaxBoxList);
2056: opm_CurrentCurrency := FNopm_LoadCurrency;
2057: PRopm_RenderLanguageDisplay (opm_ComboBox_DisplayLang, opmG_LanguageList);
2058: PRopm_RenderCategoryDisplay (opmG_CategoryList, opm_TreeView_Main, opm_CurrentCategory);
2059: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
2060: end;
2061:
2062:
2063: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2064: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2065: procedure Topm_Form_Main.opm_MenuItem_RefreshProductsClick(Sender: TObject);
2066: VAR
2067: CurItem : TListItem;
2068: BEGIN
2069: CurItem := opm_ListView_Main.Selected;
2070: IF (CurItem <> NIL) THEN opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
2071: PRopm_Reload_ProductList (opm_WeAreSearching);
2072: end;
2073:
2074:
2075: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2076: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2077: procedure Topm_Form_Main.opm_ComboBox_DisplayLangSelect(Sender: TObject);
2078: begin
2079: PRopm_Sound ('MenuPopup', opmG_UISilent);
2080: opm_CurrentLang := FNopm_GetRealLangIDByIndex (opmG_LanguageList, opm_ComboBox_DisplayLang.ItemIndex);
2081: PRopm_LoadLanguageList (opmG_LanguageList);
2082: PRopm_LoadCategoryList (opmG_CategoryList, opmG_CategoryBoxList);
2083: PRopm_LoadManufacturerList (opmG_ManufacturerList, opmG_ManufacturerBoxList);
2084: PRopm_LoadTaxList (opmG_TaxList, opmG_TaxBoxList);
2085: opm_CurrentCurrency := FNopm_LoadCurrency;
2086: PRopm_RenderLanguageDisplay (opm_ComboBox_DisplayLang, opmG_LanguageList);
2087: PRopm_RenderCategoryDisplay (opmG_CategoryList, opm_TreeView_Main, opm_CurrentCategory);
2088: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
2089: end;
2090:
2091: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2092: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2093: procedure Topm_Form_Main.opm_MenuItem_SearchProductClick(Sender: TObject);
2094: begin
2095: IF (opm_Form_SearchProduct.ShowModal = mrOk) THEN
2096: BEGIN
2097: PRopm_SearchProducts (opm_Search_PCategory, opm_Search_PManufacturer, opm_Search_PModel, opm_Search_PName, opm_Search_PDesc, opm_Search_PSPrice, opm_Search_PImagURL, opm_Search_PAvailable, opmG_ProductList, opmG_DescriptionList, '');
2098: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
2099: PRopm_Valid_ProdOps (opm_WeAreConnected, opm_ListView_Main.Selected, opm_ListView_Main.SelCount, NIL);
2100: END;
2101: end;
2102:
2103:
2104:
2105: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2106: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2107: procedure Topm_Form_Main.opm_ListView_MainDblClick(Sender: TObject);
2108: var
2109: CurItem : TListItem;
2110: CurLang : LONGINT;
2111: begin
2112: CurItem := opm_ListView_Main.Selected;
2113: IF (CurItem <> NIL) THEN
2114: BEGIN
2115: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
2116: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
2117: FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
2118: opm_CurrentSingleDescList[CurLang] := FNopm_GetDescriptionByID (opm_CurrentProdRecord.ID, opmG_LanguageList[CurLang].ID, opmG_DescriptionList);
2119: IF (opm_Form_PEdit.ShowModal = mrOk) THEN
2120: BEGIN
2121: PRopm_UpdateProduct (opm_CurrentProdRecord, opm_CurrentPEditRecord, opm_CurrentSingleDescList);
2122: END;
2123: END;
2124: end;
2125:
2126:
2127:
2128:
2129:
2130: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2131: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2132: PROCEDURE Topm_Form_Main.PRopm_UpdateProduct (CurProdRecord, NewProdRecord : opmR_Product; SingleDescList : opmT_SingleDescList);
2133: VAR
2134: UStrProducts, UStrProdCats, IStrProdCats, DStrProdDesc, IStrProdDesc, DStrProdSpec, IStrProdSpec : STRING;
2135: CurLang : LONGINT;
2136: BEGIN
2137: IF ((CurProdRecord.Model <> NewProdRecord.Model) OR
2138: (CurProdRecord.Quantity <> NewProdRecord.Quantity) OR
2139: (CurProdRecord.ManufacturerID <> NewProdRecord.ManufacturerID) OR
2140: (CurProdRecord.CategoryID <> NewProdRecord.CategoryID) OR
2141: (CurProdRecord.Price <> NewProdRecord.Price) OR
2142: (CurProdRecord.Weight <> NewProdRecord.Weight) OR
2143: (CurProdRecord.Available <> NewProdRecord.Available) OR
2144: (CurProdRecord.Special <> NewProdRecord.Special) OR
2145: (CurProdRecord.Tax <> NewProdRecord.Tax) OR
2146: (CurProdRecord.AvailDate <> NewProdRecord.AvailDate) OR
2147: (CurProdRecord.ImageURL <> NewProdRecord.ImageURL) OR
2148: (CurProdRecord.ImageURL1 <> NewProdRecord.ImageURL1) OR
2149: (CurProdRecord.ImageURL2 <> NewProdRecord.ImageURL2) OR
2150: (CurProdRecord.ImageURL3 <> NewProdRecord.ImageURL3) OR
2151: (CurProdRecord.ImageURL4 <> NewProdRecord.ImageURL4) OR
2152: (CurProdRecord.ImageURL5 <> NewProdRecord.ImageURL5) OR
2153: (CurProdRecord.ImageURL6 <> NewProdRecord.ImageURL6)) THEN
2154: BEGIN
2155: UStrProducts := '';
2156: UStrProdCats := '';
2157: IStrProdCats := '';
2158: DStrProdSpec := '';
2159: IStrProdSpec := '';
2160: IF (opmG_UIConfirmMods = 0) OR ((opmG_UIConfirmMods > 0) AND (FNopm_Message (_('Do you really want to update this product?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
2161: BEGIN
2162: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Updating product record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2163: IF (opmG_Capa_MorePics6 = FALSE) THEN
2164: UStrProducts := 'update ' + opmG_DBTable_Products + ' set products_model="' + NewProdRecord.Model + '",'
2165: + ' products_quantity=' + INTTOSTR (NewProdRecord.Quantity) + ','
2166: + ' manufacturers_id=' + INTTOSTR (NewProdRecord.ManufacturerID) + ','
2167: + ' products_image="' + TRIM (NewProdRecord.ImageURL) + '",'
2168: + ' products_price=' + CURRTOSTR (NewProdRecord.Price) + ','
2169: + ' products_weight=' + FLOATTOSTR (NewProdRecord.Weight) + ','
2170: + ' products_status=' + INTTOSTR (NewProdRecord.Available) + ','
2171: + ' products_last_modified=now()' + ', '
2172: + ' products_tax_class_id=' + INTTOSTR (NewProdRecord.Tax) + ', '
2173: + ' products_date_available="' + FNopm_DateToString (NewProdRecord.AvailDate) + '"'
2174: + ' where products_id=' + INTTOSTR (NewProdRecord.ID)
2175: ELSE
2176: UStrProducts := 'update ' + opmG_DBTable_Products + ' set products_model="' + NewProdRecord.Model + '",'
2177: + ' products_quantity=' + INTTOSTR (NewProdRecord.Quantity) + ','
2178: + ' manufacturers_id=' + INTTOSTR (NewProdRecord.ManufacturerID) + ','
2179: + ' products_image="' + TRIM (NewProdRecord.ImageURL) + '",'
2180: + ' products_price=' + CURRTOSTR (NewProdRecord.Price) + ','
2181: + ' products_weight=' + FLOATTOSTR (NewProdRecord.Weight) + ','
2182: + ' products_status=' + INTTOSTR (NewProdRecord.Available) + ','
2183: + ' products_last_modified=now()' + ', '
2184: + ' products_tax_class_id=' + INTTOSTR (NewProdRecord.Tax) + ', '
2185: + ' products_date_available="' + FNopm_DateToString (NewProdRecord.AvailDate) + '", '
2186: + ' products_subimage1="' + TRIM (NewProdRecord.ImageURL1) + '",'
2187: + ' products_subimage2="' + TRIM (NewProdRecord.ImageURL2) + '",'
2188: + ' products_subimage3="' + TRIM (NewProdRecord.ImageURL3) + '",'
2189: + ' products_subimage4="' + TRIM (NewProdRecord.ImageURL4) + '",'
2190: + ' products_subimage5="' + TRIM (NewProdRecord.ImageURL5) + '",'
2191: + ' products_subimage6="' + TRIM (NewProdRecord.ImageURL6) + '"'
2192: + ' where products_id=' + INTTOSTR (NewProdRecord.ID);
2193: IF (CurProdRecord.CategoryID <> NewProdRecord.CategoryID) THEN
2194: BEGIN
2195: UStrProdCats := 'delete from ' + opmG_DBTable_ProductsToCategories + ''
2196: + ' where products_id=' + INTTOSTR (NewProdRecord.ID) + ' and categories_id=' + INTTOSTR (CurProdRecord.CategoryID);
2197: IStrProdCats := 'insert into ' + opmG_DBTable_ProductsToCategories + ' (products_id, categories_id)' + ''
2198: + ' values (' + INTTOSTR (CurProdRecord.ID) + ', ' + INTTOSTR (NewProdRecord.CategoryID) + ')';
2199: END
2200: ELSE
2201: BEGIN
2202: UStrProdCats := '';
2203: IStrProdCats := '';
2204: END;
2205: IF (CurProdRecord.Special <> NewProdRecord.Special) THEN
2206: DStrProdSpec := 'delete from ' + opmG_DBTable_Specials + '' + ''
2207: + ' where products_id=' + INTTOSTR (NewProdRecord.ID)
2208: ELSE
2209: DStrProdSpec := '';
2210: IF ((ROUND (NewProdRecord.Special) > 0) AND (CurProdRecord.Special <> NewProdRecord.Special)) THEN
2211: IStrProdSpec := 'insert into ' + opmG_DBTable_Specials + ' (products_id, specials_new_products_price, specials_date_added, specials_last_modified)' + ''
2212: + ' values (' + INTTOSTR (NewProdRecord.ID) + ', ' + CURRTOSTR (NewProdRecord.Special) + ', now(), now())'
2213: ELSE
2214: IStrProdSpec := '';
2215: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 18, opmC_ProgressNone, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2216: IF (UStrProducts <> '') THEN FNopm_ExecQuery (UStrProducts, opmC_SQLUpdate);
2217: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 36, opmC_ProgressNone, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2218: IF (UStrProdCats <> '') THEN FNopm_ExecQuery (UStrProdCats, opmC_SQLUpdate);
2219: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 52, opmC_ProgressNone, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2220: IF (IStrProdCats <> '') THEN FNopm_ExecQuery (IStrProdCats, opmC_SQLInsert);
2221: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 70, opmC_ProgressNone, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2222: IF (DStrProdSpec <> '') THEN FNopm_ExecQuery (DStrProdSpec, opmC_SQLDelete);
2223: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 88, opmC_ProgressNone, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2224: IF (IStrProdSpec <> '') THEN FNopm_ExecQuery (IStrProdSpec, opmC_SQLInsert);
2225: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 100, opmC_ProgressNone, _('Product record updated.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2226: END;
2227: END;
2228: DStrProdDesc := 'delete from ' + opmG_DBTable_ProductsDescription + ''
2229: + ' where products_id=' + INTTOSTR (NewProdRecord.ID);
2230: FNopm_ExecQuery (DStrProdDesc, opmC_SQLDelete);
2231: FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
2232: IF (SingleDescList[CurLang].ID > 0) THEN
2233: BEGIN
2234: IStrProdDesc := 'insert into ' + opmG_DBTable_ProductsDescription + ' (products_name, products_description, products_url, products_id, language_id)' + ''
2235: + ' values ("' + FNopm_CleanSQLString (SingleDescList[CurLang].Name, FALSE) + '",'
2236: + ' "' + FNopm_CleanSQLString (SingleDescList[CurLang].Description, FALSE) + '",'
2237: + ' "' + FNopm_CleanSQLString (SingleDescList[CurLang].URL, FALSE) + '", '
2238: + INTTOSTR (SingleDescList[CurLang].ID) + ', ' + INTTOSTR (SingleDescList[CurLang].LanguageID) + ')';
2239: FNopm_ExecQuery (IStrProdDesc, opmC_SQLInsert);
2240: PRopm_Update_StatusBar (opmC_ConnStatIgnore, (CurLang * ROUND (100 / opmC_Max_Languages_PerList)), opmC_ProgressNone, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2241: END;
2242: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Reloading product list.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2243: opm_CurrentCategory := opm_CurrentCatRecord.ID;
2244: PRopm_Reload_ProductList (opm_WeAreSearching);
2245: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Product list loaded.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2246: END;
2247:
2248:
2249:
2250:
2251: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2252: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2253: PROCEDURE Topm_Form_Main.PRopm_UpdateProdData (ProdID : LONGINT; ProdTable, ProdField, ProdDataStr : STRING;
2254: PDataIsNum : BOOLEAN; SecIDField, SecIDData : STRING;
2255: SQLQueryType : INTEGER);
2256: VAR
2257: UStrProducts, DStrProducts : STRING;
2258: BEGIN
2259: UStrProducts := '';
2260: DStrProducts := '';
2261: IF (ProdID > 0) AND (ProdTable <> '') AND (ProdField <> '') AND (ProdDataStr <> '') THEN
2262: BEGIN
2263: IF (opmG_UIConfirmMods = 0) OR ((opmG_UIConfirmMods > 0) AND (FNopm_Message (_('Do you really want to update this product?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
2264: BEGIN
2265: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 0, opmC_ProgressIgnore, _('Updating product record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2266: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 50, opmC_ProgressIgnore, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2267: IF (SQLQueryType = opmC_SQLUpdate) THEN
2268: BEGIN
2269: IF (PDataIsNum = TRUE) THEN
2270: UStrProducts := 'update ' + ProdTable + ' set ' + ProdField + '=' + ProdDataStr + ''
2271: + ' where products_id=' + INTTOSTR (ProdID)
2272: ELSE
2273: UStrProducts := 'update ' + ProdTable + ' set ' + ProdField + '="' + FNopm_CleanSQLString (ProdDataStr, FALSE) + '"'
2274: + ' where products_id=' + INTTOSTR (ProdID);
2275: IF (SecIDField <> '') THEN UStrProducts := UStrProducts + ' and ' + SecIDField + '=' + SecIDData;
2276: FNopm_ExecQuery (UStrProducts, opmC_SQLUpdate);
2277: END;
2278: IF ((SQLQueryType = opmC_SQLDelIns) OR (SQLQueryType = opmC_SQLDelInsNoZero)) THEN
2279: BEGIN
2280: DStrProducts := 'delete from ' + ProdTable + '' + ' where products_id=' + INTTOSTR (ProdID);
2281: IF (PDataIsNum = TRUE) THEN
2282: BEGIN
2283: IF NOT ((SQLQueryType = opmC_SQLDelInsNoZero) AND (STRTOFLOAT (ProdDataStr) = 0)) THEN
2284: UStrProducts := 'insert into ' + ProdTable + ' (products_id, ' + ProdField + ')' + ''
2285: + ' values (' + INTTOSTR (ProdID) + ', ' + FNopm_CleanSQLString (ProdDataStr, FALSE) + ')';
2286: END
2287: ELSE
2288: BEGIN
2289: IF NOT ((SQLQueryType = opmC_SQLDelInsNoZero) AND (ProdDataStr = '')) THEN
2290: UStrProducts := 'insert into ' + ProdTable + ' (products_id, ' + ProdField + ')' + ''
2291: + ' values (' + INTTOSTR (ProdID) + ', "' + FNopm_CleanSQLString (ProdDataStr, FALSE) + '")';
2292: END;
2293: FNopm_ExecQuery (DStrProducts, opmC_SQLUpdate);
2294: FNopm_ExecQuery (UStrProducts, opmC_SQLUpdate);
2295: END;
2296: IF (SQLQueryType = opmC_SQLInsert) THEN
2297: BEGIN
2298: IF (PDataIsNum = TRUE) THEN
2299: UStrProducts := 'insert into ' + ProdTable + ' (products_id, ' + ProdField + ')' + ''
2300: + ' values (' + INTTOSTR (ProdID) + ', ' + FNopm_CleanSQLString (ProdDataStr, FALSE) + ')'
2301: ELSE
2302: UStrProducts := 'insert into ' + ProdTable + ' (products_id, ' + ProdField + ')' + ''
2303: + ' values (' + INTTOSTR (ProdID) + ', "' + FNopm_CleanSQLString (ProdDataStr, FALSE) + '")';
2304: FNopm_ExecQuery (UStrProducts, opmC_SQLUpdate);
2305: END;
2306: END;
2307: END;
2308: END;
2309:
2310:
2311: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2312: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2313: PROCEDURE Topm_Form_Main.PRopm_DeleteProduct (ProdID : LONGINT);
2314: VAR
2315: DStrProducts, DStrProdDesc, DStrProdSpec, DStrProdCats : STRING;
2316: ResStr : STRING;
2317: BEGIN
2318: IF (ProdID > 0) THEN
2319: BEGIN
2320: opm_CurrentProdRecord := FNopm_GetProductByID (ProdID, opm_CurrentLang, opmG_ProductList);
2321: IF (opmG_UIConfirmDels = 0) OR ((opmG_UIConfirmDels > 0) AND (FNopm_Message (_('Do you really want to delete this product?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
2322: BEGIN
2323: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 18, opmC_ProgressIgnore, _('Deleting product record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2324: PRopm_Prepare_HTTPClient (NIL, NIL, ((opmG_UseProxy > 0) AND (opmG_ProxyApply IN [0, 1])));
2325: DStrProducts := 'delete from ' + opmG_DBTable_Products + ' where products_id=' + INTTOSTR (ProdID);
2326: DStrProdCats := 'delete from ' + opmG_DBTable_ProductsToCategories + ' where products_id=' + INTTOSTR (ProdID);
2327: DStrProdSpec := 'delete from ' + opmG_DBTable_Specials + ' where products_id=' + INTTOSTR (ProdID);
2328: DStrProdDesc := 'delete from ' + opmG_DBTable_ProductsDescription + ' where products_id=' + INTTOSTR (ProdID);
2329: IF (FNopm_ExecQuery (DStrProducts, opmC_SQLUpdate) >= 0) THEN
2330: BEGIN
2331: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 36, opmC_ProgressIgnore, _('Deleting product record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2332: FNopm_Send_Command (opmG_WBUploadURL, 'delete', opm_CurrentProdRecord.ImageURL, ResStr);
2333: IF (opmG_Capa_MorePics6 = TRUE) THEN
2334: BEGIN
2335: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 38, opmC_ProgressIgnore, _('Deleting product record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2336: FNopm_Send_Command (opmG_WBUploadURL, 'delete', opm_CurrentProdRecord.ImageURL1, ResStr);
2337: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 41, opmC_ProgressIgnore, _('Deleting product record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2338: FNopm_Send_Command (opmG_WBUploadURL, 'delete', opm_CurrentProdRecord.ImageURL2, ResStr);
2339: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 43, opmC_ProgressIgnore, _('Deleting product record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2340: FNopm_Send_Command (opmG_WBUploadURL, 'delete', opm_CurrentProdRecord.ImageURL3, ResStr);
2341: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 46, opmC_ProgressIgnore, _('Deleting product record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2342: FNopm_Send_Command (opmG_WBUploadURL, 'delete', opm_CurrentProdRecord.ImageURL4, ResStr);
2343: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 48, opmC_ProgressIgnore, _('Deleting product record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2344: FNopm_Send_Command (opmG_WBUploadURL, 'delete', opm_CurrentProdRecord.ImageURL5, ResStr);
2345: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 51, opmC_ProgressIgnore, _('Deleting product record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2346: FNopm_Send_Command (opmG_WBUploadURL, 'delete', opm_CurrentProdRecord.ImageURL6, ResStr);
2347: END;
2348: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 54, opmC_ProgressIgnore, _('Deleting product record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2349: FNopm_ExecQuery (DStrProdCats, opmC_SQLUpdate);
2350: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 72, opmC_ProgressIgnore, _('Deleting product record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2351: FNopm_ExecQuery (DStrProdSpec, opmC_SQLUpdate);
2352: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 90, opmC_ProgressIgnore, _('Deleting product record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2353: FNopm_ExecQuery (DStrProdDesc, opmC_SQLUpdate);
2354: END;
2355: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 0, opmC_ProgressIgnore, _('Product deleted.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2356: END;
2357: END;
2358: END;
2359:
2360:
2361:
2362:
2363: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2364: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2365: PROCEDURE Topm_Form_Main.PRopm_AddProduct (NewProdRecord : opmR_Product; SingleDescList : opmT_SingleDescList);
2366: VAR
2367: IStrProducts, IStrProdCats, IStrProdDesc, IStrProdSpec, IStrCheckID : STRING;
2368: LastID : LONGINT;
2369: CurLang : LONGINT;
2370: BEGIN
2371: LastID := 0;
2372: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Adding product record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2373: IF (opmG_Capa_MorePics6 = FALSE) THEN
2374: IStrProducts := 'insert into ' + opmG_DBTable_Products + ' (products_model, products_quantity, manufacturers_id, products_price, products_weight, products_status, products_last_modified, products_date_added, products_tax_class_id, products_date_available, products_image)' + ''
2375: + ' values ("' + NewProdRecord.Model + '", '
2376: + INTTOSTR (NewProdRecord.Quantity) + ', ' + INTTOSTR (NewProdRecord.ManufacturerID) + ', '
2377: + CURRTOSTR (NewProdRecord.Price) + ', ' + FLOATTOSTR (NewProdRecord.Weight) + ', '
2378: + INTTOSTR (NewProdRecord.Available) + ', ' + 'now(), now(), '
2379: + INTTOSTR (NewProdRecord.Tax) + ', "' + FNopm_DateToString (NewProdRecord.AvailDate) + '", "' + TRIM (NewProdRecord.ImageURL) + '")'
2380: ELSE
2381: IStrProducts := 'insert into ' + opmG_DBTable_Products + ' (products_model, products_quantity, manufacturers_id, products_price, products_weight, products_status, products_last_modified, products_date_added, products_tax_class_id, products_date_available, products_image, '
2382: + 'products_subimage1, products_subimage2, products_subimage3, products_subimage4, products_subimage5, products_subimage6)' + ''
2383: + ' values ("' + NewProdRecord.Model + '", '
2384: + INTTOSTR (NewProdRecord.Quantity) + ', ' + INTTOSTR (NewProdRecord.ManufacturerID) + ', '
2385: + CURRTOSTR (NewProdRecord.Price) + ', ' + FLOATTOSTR (NewProdRecord.Weight) + ', '
2386: + INTTOSTR (NewProdRecord.Available) + ', ' + 'now(), now(), '
2387: + INTTOSTR (NewProdRecord.Tax) + ', "' + FNopm_DateToString (NewProdRecord.AvailDate) + '", "' + TRIM (NewProdRecord.ImageURL) + '", "'
2388: + TRIM (NewProdRecord.ImageURL1) + '", "' + TRIM (NewProdRecord.ImageURL2) + '", "' + TRIM (NewProdRecord.ImageURL3) + '", "'
2389: + TRIM (NewProdRecord.ImageURL4) + '", "' + TRIM (NewProdRecord.ImageURL3) + '", "' + TRIM (NewProdRecord.ImageURL6) + '")';
2390: IStrCheckID := 'select products_id from ' + opmG_DBTable_Products + ' where products_id=last_insert_id()';
2391: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 30, opmC_ProgressNone, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2392: FNopm_ExecQuery (IStrProducts, opmC_SQLInsert);
2393: IF (FNopm_ExecQuery (IStrCheckID, opmC_SQLSelect) > 0) THEN
2394: IF (opmG_DBQuery.Active = TRUE) THEN
2395: BEGIN
2396: opmG_DBQuery.First;
2397: LastID := opmG_DBQuery.Fields[0].AsInteger;
2398: END;
2399: IF (LastID > 0) THEN
2400: BEGIN
2401: IF (NewProdRecord.CategoryID >= 0) THEN
2402: IStrProdCats := 'insert into ' + opmG_DBTable_ProductsToCategories + ' (products_id, categories_id)' + ''
2403: + ' values (' + INTTOSTR (LastID) + ', ' + INTTOSTR (NewProdRecord.CategoryID) + ')'
2404: ELSE IStrProdCats := '';
2405: IF (ROUND (NewProdRecord.Special) > 0) THEN
2406: IStrProdSpec := 'insert into ' + opmG_DBTable_Specials + ' (products_id, specials_new_products_price, specials_date_added, specials_last_modified)' + ''
2407: + ' values (' + INTTOSTR (LastID) + ', ' + CURRTOSTR (NewProdRecord.Special) + ', now(), now())'
2408: ELSE
2409: IStrProdSpec := '';
2410: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 60, opmC_ProgressNone, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2411: FNopm_ExecQuery (IStrProdCats, opmC_SQLInsert);
2412: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 90, opmC_ProgressNone, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2413: IF (IStrProdSpec <> '') THEN FNopm_ExecQuery (IStrProdSpec, opmC_SQLInsert);
2414: END;
2415: FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
2416: IF (SingleDescList[CurLang].ID = opmC_InsertProdID) THEN
2417: BEGIN
2418: IStrProdDesc := 'insert into ' + opmG_DBTable_ProductsDescription + ' (products_name, products_description, products_url, products_id, language_id, products_viewed)' + ''
2419: + ' values ("' + FNopm_CleanSQLString (SingleDescList[CurLang].Name, FALSE) + '",'
2420: + ' "' + FNopm_CleanSQLString (SingleDescList[CurLang].Description, FALSE) + '",'
2421: + ' "' + FNopm_CleanSQLString (SingleDescList[CurLang].URL, FALSE) + '", '
2422: + INTTOSTR (LastID) + ', ' + INTTOSTR (SingleDescList[CurLang].LanguageID) + ', 0)';
2423: FNopm_ExecQuery (IStrProdDesc, opmC_SQLInsert);
2424: PRopm_Update_StatusBar (opmC_ConnStatIgnore, (CurLang * ROUND (100 / opmC_Max_Languages_PerList)), opmC_ProgressNone, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2425: END;
2426: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 100, opmC_ProgressNone, _('Product record added.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2427: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Reloading product list.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2428: opm_CurrentCategory := opm_CurrentCatRecord.ID;
2429: PRopm_Reload_ProductList (opm_WeAreSearching);
2430: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Product list loaded.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2431: END;
2432:
2433:
2434:
2435: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2436: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2437: PROCEDURE Topm_Form_Main.PRopm_Valid_CatOps (WeAreConnected : BOOLEAN; SelectedCat : TTreeNode);
2438: BEGIN
2439: IF (WeAreConnected = TRUE) THEN
2440: BEGIN
2441: opm_MenuItem_RefreshCategories.Enabled := TRUE;
2442: opm_MenuItem_ManAdd.Enabled := TRUE;
2443: opm_MenuItem_ManRename.Enabled := TRUE;
2444: opm_MenuItem_ManDelete.Enabled := TRUE;
2445: opm_MenuItem_SearchProduct.Enabled := TRUE;
2446: opm_MenuItem_Backup.Enabled := TRUE;
2447: opm_ToolButton_Search.Enabled := TRUE;
2448: opm_Edit_QuickSearch.Enabled := TRUE;
2449: opm_SpeedButton_QuickSearch.Enabled := TRUE;
2450: IF (SelectedCat <> NIL) THEN
2451: BEGIN
2452: opm_MenuItem_CategoryAdd.Enabled := TRUE;
2453: opm_ToolButton_AddCat.Enabled := TRUE;
2454: opm_PopMenuItem_CatAdd.Enabled := TRUE;
2455: opm_MenuItem_CategoryRename.Enabled := TRUE;
2456: opm_ToolButton_RenCat.Enabled := TRUE;
2457: opm_PopMenuItem_CatRename.Enabled := TRUE;
2458: opm_MenuItem_CategoryDelete.Enabled := TRUE;
2459: opm_ToolButton_DelCat.Enabled := TRUE;
2460: opm_PopMenuItem_CatDelete.Enabled := TRUE;
2461: opm_PopMenuItem_CatExpand2.Enabled := TRUE;
2462: opm_PopMenuItem_CatCollapse2.Enabled := TRUE;
2463: opm_PopMenuItem_CatExpand.Enabled := TRUE;
2464: opm_PopMenuItem_CatCollapse.Enabled := TRUE;
2465: END
2466: ELSE
2467: BEGIN
2468: opm_MenuItem_CategoryAdd.Enabled := FALSE;
2469: opm_ToolButton_AddCat.Enabled := FALSE;
2470: opm_PopMenuItem_CatAdd.Enabled := FALSE;
2471: opm_MenuItem_CategoryRename.Enabled := FALSE;
2472: opm_ToolButton_RenCat.Enabled := FALSE;
2473: opm_PopMenuItem_CatRename.Enabled := FALSE;
2474: opm_MenuItem_CategoryDelete.Enabled := FALSE;
2475: opm_ToolButton_DelCat.Enabled := FALSE;
2476: opm_PopMenuItem_CatDelete.Enabled := FALSE;
2477: opm_PopMenuItem_CatExpand2.Enabled := FALSE;
2478: opm_PopMenuItem_CatCollapse2.Enabled := FALSE;
2479: opm_PopMenuItem_CatExpand.Enabled := FALSE;
2480: opm_PopMenuItem_CatCollapse.Enabled := FALSE;
2481: END;
2482: END
2483: ELSE
2484: BEGIN
2485: opm_MenuItem_RefreshCategories.Enabled := FALSE;
2486: opm_MenuItem_ManAdd.Enabled := FALSE;
2487: opm_MenuItem_ManRename.Enabled := FALSE;
2488: opm_MenuItem_ManDelete.Enabled := FALSE;
2489: opm_MenuItem_SearchProduct.Enabled := FALSE;
2490: opm_MenuItem_Backup.Enabled := FALSE;
2491: opm_ToolButton_Search.Enabled := FALSE;
2492: opm_Edit_QuickSearch.Enabled := FALSE;
2493: opm_SpeedButton_QuickSearch.Enabled := FALSE;
2494: opm_MenuItem_CategoryAdd.Enabled := FALSE;
2495: opm_ToolButton_AddCat.Enabled := FALSE;
2496: opm_PopMenuItem_CatAdd.Enabled := FALSE;
2497: opm_MenuItem_CategoryRename.Enabled := FALSE;
2498: opm_ToolButton_RenCat.Enabled := FALSE;
2499: opm_PopMenuItem_CatRename.Enabled := FALSE;
2500: opm_MenuItem_CategoryDelete.Enabled := FALSE;
2501: opm_ToolButton_DelCat.Enabled := FALSE;
2502: opm_PopMenuItem_CatDelete.Enabled := FALSE;
2503: opm_PopMenuItem_CatExpand2.Enabled := FALSE;
2504: opm_PopMenuItem_CatCollapse2.Enabled := FALSE;
2505: opm_PopMenuItem_CatExpand.Enabled := FALSE;
2506: opm_PopMenuItem_CatCollapse.Enabled := FALSE;
2507: END;
2508: END;
2509:
2510:
2511: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2512: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2513: PROCEDURE Topm_Form_Main.PRopm_Valid_ProdOps (WeAreConnected : BOOLEAN; SelectedProduct : TListItem; SelectedProds : LONGINT; SelectedCat : TTreeNode);
2514: BEGIN
2515: IF (WeAreConnected = TRUE) THEN
2516: BEGIN
2517: IF (((SelectedCat <> NIL) OR (SelectedProduct <> NIL)) AND (SelectedProds < 2)) THEN
2518: BEGIN
2519: opm_MenuItem_ProductAdd.Enabled := TRUE;
2520: opm_ToolButton_AddProduct.Enabled := TRUE;
2521: opm_PopMenuItem_PAdd.Enabled := TRUE;
2522: END
2523: ELSE
2524: BEGIN
2525: opm_MenuItem_ProductAdd.Enabled := FALSE;
2526: opm_ToolButton_AddProduct.Enabled := FALSE;
2527: opm_PopMenuItem_PAdd.Enabled := FALSE;
2528: END;
2529: IF (SelectedCat <> NIL) THEN
2530: BEGIN
2531: opm_MenuItem_RefreshProducts.Enabled := TRUE;
2532: opm_MenuItem_ProductSelAll.Enabled := TRUE;
2533: opm_PopMenuItem_PSelAll.Enabled := TRUE;
2534: opm_ToolButton_Refresh.Enabled := TRUE;
2535: END
2536: ELSE
2537: BEGIN
2538: opm_MenuItem_RefreshProducts.Enabled := FALSE;
2539: opm_MenuItem_ProductSelAll.Enabled := FALSE;
2540: opm_PopMenuItem_PSelAll.Enabled := FALSE;
2541: opm_ToolButton_Refresh.Enabled := FALSE;
2542: END;
2543: IF (SelectedProduct <> NIL) THEN
2544: BEGIN
2545: IF (SelectedProds > 1) THEN
2546: BEGIN
2547: opm_MenuItem_ProductEdit.Enabled := FALSE;
2548: opm_ToolButton_EditProduct.Enabled := FALSE;
2549: opm_PopMenuItem_PEdit.Enabled := FALSE;
2550: opm_PopMenuItem_PModel.Enabled := FALSE;
2551: opm_PopMenuItem_PWeight.Enabled := FALSE;
2552: END
2553: ELSE
2554: BEGIN
2555: opm_MenuItem_ProductEdit.Enabled := TRUE;
2556: opm_ToolButton_EditProduct.Enabled := TRUE;
2557: opm_PopMenuItem_PEdit.Enabled := TRUE;
2558: opm_PopMenuItem_PModel.Enabled := TRUE;
2559: opm_PopMenuItem_PWeight.Enabled := TRUE;
2560: END;
2561: opm_MenuItem_ProductDel.Enabled := TRUE;
2562: opm_MenuItem_ProductCopy.Enabled := TRUE;
2563: opm_MenuItem_ProductCopyAsText.Enabled := TRUE;
2564: opm_MenuItem_ProductCopyAsPre.Enabled := TRUE;
2565: opm_MenuItem_ProductExport.Enabled := TRUE;
2566: opm_MenuItem_ProductPrint.Enabled := TRUE;
2567: opm_ToolButton_DeleteProduct.Enabled := TRUE;
2568: opm_ToolButton_ExportProduct.Enabled := TRUE;
2569: opm_ToolButton_PrintProduct.Enabled := TRUE;
2570: opm_PopMenuItem_PMod.Enabled := TRUE;
2571: opm_PopMenuItem_PAvailability.Enabled := TRUE;
2572: opm_PopMenuItem_PAvailable.Enabled := TRUE;
2573: opm_PopMenuItem_PNotAvailable.Enabled := TRUE;
2574: opm_PopMenuItem_PPrice.Enabled := TRUE;
2575: opm_PopMenuItem_PSpecial.Enabled := TRUE;
2576: opm_PopMenuItem_PQuantity.Enabled := TRUE;
2577: opm_PopMenuItem_PCat.Enabled := TRUE;
2578: opm_PopMenuItem_PMan.Enabled := TRUE;
2579: opm_PopMenuItem_PDelete.Enabled := TRUE;
2580: opm_PopMenuItem_PCopy.Enabled := TRUE;
2581: opm_PopMenuItem_PCopyAsText.Enabled := TRUE;
2582: opm_PopMenuItem_PCopyAsPre.Enabled := TRUE;
2583: opm_PopMenuItem_PExport.Enabled := TRUE;
2584: opm_PopMenuItem_PPrint.Enabled := TRUE;
2585: END
2586: ELSE
2587: BEGIN
2588: opm_MenuItem_ProductEdit.Enabled := FALSE;
2589: opm_MenuItem_ProductDel.Enabled := FALSE;
2590: opm_MenuItem_ProductCopy.Enabled := FALSE;
2591: opm_MenuItem_ProductCopyAsText.Enabled := FALSE;
2592: opm_MenuItem_ProductCopyAsPre.Enabled := FALSE;
2593: opm_MenuItem_ProductExport.Enabled := FALSE;
2594: opm_MenuItem_ProductPrint.Enabled := FALSE;
2595: opm_ToolButton_EditProduct.Enabled := FALSE;
2596: opm_ToolButton_DeleteProduct.Enabled := FALSE;
2597: opm_ToolButton_ExportProduct.Enabled := FALSE;
2598: opm_ToolButton_PrintProduct.Enabled := FALSE;
2599: opm_PopMenuItem_PEdit.Enabled := FALSE;
2600: opm_PopMenuItem_PMod.Enabled := FALSE;
2601: opm_PopMenuItem_PAvailability.Enabled := FALSE;
2602: opm_PopMenuItem_PAvailable.Enabled := FALSE;
2603: opm_PopMenuItem_PNotAvailable.Enabled := FALSE;
2604: opm_PopMenuItem_PPrice.Enabled := FALSE;
2605: opm_PopMenuItem_PSpecial.Enabled := FALSE;
2606: opm_PopMenuItem_PQuantity.Enabled := FALSE;
2607: opm_PopMenuItem_PCat.Enabled := FALSE;
2608: opm_PopMenuItem_PMan.Enabled := FALSE;
2609: opm_PopMenuItem_PModel.Enabled := FALSE;
2610: opm_PopMenuItem_PWeight.Enabled := FALSE;
2611: opm_PopMenuItem_PDelete.Enabled := FALSE;
2612: opm_PopMenuItem_PCopy.Enabled := FALSE;
2613: opm_PopMenuItem_PCopyAsText.Enabled := FALSE;
2614: opm_PopMenuItem_PCopyAsPre.Enabled := FALSE;
2615: opm_PopMenuItem_PExport.Enabled := FALSE;
2616: opm_PopMenuItem_PPrint.Enabled := FALSE;
2617: END;
2618: END
2619: ELSE
2620: BEGIN
2621: opm_MenuItem_RefreshProducts.Enabled := FALSE;
2622: opm_MenuItem_ProductAdd.Enabled := FALSE;
2623: opm_MenuItem_ProductEdit.Enabled := FALSE;
2624: opm_MenuItem_ProductDel.Enabled := FALSE;
2625: opm_MenuItem_ProductSelAll.Enabled := FALSE;
2626: opm_MenuItem_ProductCopy.Enabled := FALSE;
2627: opm_MenuItem_ProductCopyAsText.Enabled := FALSE;
2628: opm_MenuItem_ProductCopyAsPre.Enabled := FALSE;
2629: opm_MenuItem_ProductExport.Enabled := FALSE;
2630: opm_MenuItem_ProductPrint.Enabled := FALSE;
2631: opm_ToolButton_Refresh.Enabled := FALSE;
2632: opm_ToolButton_AddProduct.Enabled := FALSE;
2633: opm_ToolButton_EditProduct.Enabled := FALSE;
2634: opm_ToolButton_DeleteProduct.Enabled := FALSE;
2635: opm_ToolButton_ExportProduct.Enabled := FALSE;
2636: opm_ToolButton_PrintProduct.Enabled := FALSE;
2637: opm_PopMenuItem_PEdit.Enabled := FALSE;
2638: opm_PopMenuItem_PMod.Enabled := FALSE;
2639: opm_PopMenuItem_PAvailability.Enabled := FALSE;
2640: opm_PopMenuItem_PAvailable.Enabled := FALSE;
2641: opm_PopMenuItem_PNotAvailable.Enabled := FALSE;
2642: opm_PopMenuItem_PPrice.Enabled := FALSE;
2643: opm_PopMenuItem_PSpecial.Enabled := FALSE;
2644: opm_PopMenuItem_PQuantity.Enabled := FALSE;
2645: opm_PopMenuItem_PCat.Enabled := FALSE;
2646: opm_PopMenuItem_PMan.Enabled := FALSE;
2647: opm_PopMenuItem_PModel.Enabled := FALSE;
2648: opm_PopMenuItem_PWeight.Enabled := FALSE;
2649: opm_PopMenuItem_PAdd.Enabled := FALSE;
2650: opm_PopMenuItem_PDelete.Enabled := FALSE;
2651: opm_PopMenuItem_PSelAll.Enabled := FALSE;
2652: opm_PopMenuItem_PCopy.Enabled := FALSE;
2653: opm_PopMenuItem_PCopyAsText.Enabled := FALSE;
2654: opm_PopMenuItem_PCopyAsPre.Enabled := FALSE;
2655: opm_PopMenuItem_PExport.Enabled := FALSE;
2656: opm_PopMenuItem_PPrint.Enabled := FALSE;
2657: END;
2658: END;
2659:
2660:
2661: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2662: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2663: PROCEDURE Topm_Form_Main.PRopm_Valid_GralOps (WeAreConnected : BOOLEAN);
2664: BEGIN
2665: IF (WeAreConnected = TRUE) THEN
2666: BEGIN
2667: opm_MenuItem_Connect.Enabled := FALSE;
2668: opm_ToolButton_Connect.Enabled := FALSE;
2669: opm_PopMenuItem_ConnConn.Enabled := FALSE;
2670: opm_MenuItem_Disconnect.Enabled := TRUE;
2671: opm_ToolButton_Disconnect.Enabled := TRUE;
2672: opm_PopMenuItem_ConnDisconn.Enabled := TRUE;
2673: END
2674: ELSE
2675: BEGIN
2676: opm_MenuItem_Connect.Enabled := TRUE;
2677: opm_ToolButton_Connect.Enabled := TRUE;
2678: opm_PopMenuItem_ConnConn.Enabled := TRUE;
2679: opm_MenuItem_Disconnect.Enabled := FALSE;
2680: opm_ToolButton_Disconnect.Enabled := FALSE;
2681: opm_PopMenuItem_ConnDisconn.Enabled := FALSE;
2682: END;
2683: END;
2684:
2685:
2686:
2687:
2688:
2689:
2690: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2691: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2692: procedure Topm_Form_Main.opm_ListView_MainChange(Sender: TObject; Item: TListItem; Change: TItemChange);
2693: begin
2694: PRopm_Valid_ProdOps (opm_WeAreConnected, opm_ListView_Main.Selected, opm_ListView_Main.SelCount, opm_TreeView_Main.Selected);
2695: end;
2696:
2697:
2698: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2699: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2700: PROCEDURE Topm_Form_Main.PRopm_Reload_ProductList (SearchLoad : BOOLEAN);
2701: BEGIN
2702: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Reloading product list.'), 0, opm_CurrentCurrency.Code);
2703: IF (SearchLoad = FALSE) THEN
2704: BEGIN
2705: opm_CurrentCategory := opm_CurrentCatRecord.ID;
2706: PRopm_LoadProductListByCat (opm_CurrentCategory, opmG_ProductList, opmG_DescriptionList);
2707: END
2708: ELSE
2709: BEGIN
2710: PRopm_SearchProducts (opm_Search_PCategory, opm_Search_PManufacturer, opm_Search_PModel, opm_Search_PName, opm_Search_PDesc, opm_Search_PSPrice, opm_Search_PImagURL, opm_Search_PAvailable, opmG_ProductList, opmG_DescriptionList, '');
2711: END;
2712: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
2713: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Product list loaded.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2714: END;
2715:
2716:
2717: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2718: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2719: procedure Topm_Form_Main.opm_PopMenuItem_PAvailableClick(Sender: TObject);
2720: VAR
2721: CurItem : TListItem;
2722: ProgStep, Progress : LONGINT;
2723: BEGIN
2724: CurItem := opm_ListView_Main.Selected;
2725: Progress := 0;
2726: IF (CurItem <> NIL) THEN
2727: BEGIN
2728: ProgStep := ROUND (100 / opm_ListView_Main.SelCount);
2729: opm_ListView_Main.Enabled := FALSE;
2730: WHILE (CurItem <> NIL) DO
2731: BEGIN
2732: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressIgnore, Progress, _('Updating availability...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2733: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
2734: PRopm_UpdateProdData (opm_CurrentProdID, opmG_DBTable_Products, 'products_status', '1', TRUE, '', '', opmC_SQLUpdate);
2735: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
2736: INC (Progress, ProgStep);
2737: END;
2738: PRopm_Reload_ProductList (opm_WeAreSearching);
2739: opm_ListView_Main.Enabled := TRUE;
2740: opm_Form_Main.FocusControl (opm_ListView_Main);
2741: END;
2742: END;
2743:
2744: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2745: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2746: procedure Topm_Form_Main.opm_PopMenuItem_PNotAvailableClick(Sender: TObject);
2747: VAR
2748: CurItem : TListItem;
2749: ProgStep, Progress : LONGINT;
2750: BEGIN
2751: CurItem := opm_ListView_Main.Selected;
2752: Progress := 0;
2753: IF (CurItem <> NIL) THEN
2754: BEGIN
2755: ProgStep := ROUND (100 / opm_ListView_Main.SelCount);
2756: opm_ListView_Main.Enabled := FALSE;
2757: WHILE (CurItem <> NIL) DO
2758: BEGIN
2759: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressIgnore, Progress, _('Updating availability...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2760: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
2761: PRopm_UpdateProdData (opm_CurrentProdID, opmG_DBTable_Products, 'products_status', '0', TRUE, '', '', opmC_SQLUpdate);
2762: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
2763: INC (Progress, ProgStep);
2764: END;
2765: PRopm_Reload_ProductList (opm_WeAreSearching);
2766: opm_ListView_Main.Enabled := TRUE;
2767: opm_Form_Main.FocusControl (opm_ListView_Main);
2768: END;
2769: END;
2770:
2771: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2772: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2773: procedure Topm_Form_Main.opm_PopMenuItem_PPriceClick(Sender: TObject);
2774: VAR
2775: CurItem : TListItem;
2776: Operand, NewPrice : STRING;
2777: FirstPass, CanContinue : BOOLEAN;
2778: ProgStep, Progress : LONGINT;
2779: BEGIN
2780: CurItem := opm_ListView_Main.Selected;
2781: FirstPass := TRUE;
2782: CanContinue := TRUE;
2783: Progress := 0;
2784: IF (CurItem <> NIL) THEN
2785: BEGIN
2786: ProgStep := ROUND (100 / opm_ListView_Main.SelCount);
2787: opm_ListView_Main.Enabled := FALSE;
2788: WHILE (CurItem <> NIL) DO
2789: BEGIN
2790: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressIgnore, Progress, _('Updating prices...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2791: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
2792: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
2793: IF (FirstPass = TRUE) THEN
2794: BEGIN
2795: IF (opm_ListView_Main.SelCount > 1) THEN
2796: BEGIN
2797: opm_Form_AskUser.AU_Title := _('Change price for products');
2798: opm_Form_AskUser.AU_DataText := '0.00';
2799: END
2800: ELSE
2801: BEGIN
2802: opm_Form_AskUser.AU_Title := _('Change price for product ') + opm_CurrentProdRecord.DisplayName;
2803: opm_Form_AskUser.AU_DataText := CURRTOSTR (opm_CurrentProdRecord.Price);
2804: END;
2805: opm_Form_AskUser.AU_Directions := _('Type the new price (xxx, -xxx, +xxx, -xxx%, +xxx%):') + ' [' + TRIM (opm_CurrentCurrency.Code + ' ' + opm_CurrentCurrency.Left + ' ' + opm_CurrentCurrency.Right) + ']';
2806: opm_Form_AskUser.AU_TextOrList := TRUE;
2807: opm_Form_AskUser.AU_PassChar := #0;
2808: opm_Form_AskUser.AU_MaxLen := opmC_ProdPrice_MaxLen;
2809: FirstPass := FALSE;
2810: IF (opm_Form_AskUser.ShowModal = mrOk) THEN CanContinue := TRUE ELSE CanContinue := FALSE;
2811: Operand := FNopm_CleanNumber (opm_Form_AskUser.AU_DataText, opmC_ValIsNumOp);
2812: END;
2813: IF (CanContinue = TRUE) THEN
2814: BEGIN
2815: NewPrice := FNopm_Apply_Operation (CURRTOSTR (opm_CurrentProdRecord.Price), Operand, opmC_ValIsFloat, FALSE);
2816: IF ((STRTOCURR (NewPrice) = 0) AND (opmG_UIAllowZeroPrice = 0)) THEN
2817: FNopm_Message (_('Zero value not allowed.'), mtError, [mbOk], opmG_UISilent)
2818: ELSE
2819: PRopm_UpdateProdData (opm_CurrentProdID, opmG_DBTable_Products, 'products_price', NewPrice, TRUE, '', '', opmC_SQLUpdate);
2820: END
2821: ELSE BREAK;
2822: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
2823: INC (Progress, ProgStep);
2824: END;
2825: IF (CanContinue = TRUE) THEN PRopm_Reload_ProductList (opm_WeAreSearching);
2826: opm_ListView_Main.Enabled := TRUE;
2827: opm_Form_Main.FocusControl (opm_ListView_Main);
2828: END;
2829: END;
2830:
2831: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2832: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2833: procedure Topm_Form_Main.opm_PopMenuItem_PSpecialClick(Sender: TObject);
2834: VAR
2835: CurItem : TListItem;
2836: NewSpecial : STRING;
2837: FirstPass, CanContinue : BOOLEAN;
2838: ProgStep, Progress : LONGINT;
2839: BEGIN
2840: CurItem := opm_ListView_Main.Selected;
2841: FirstPass := TRUE;
2842: CanContinue := TRUE;
2843: Progress := 0;
2844: IF (CurItem <> NIL) THEN
2845: BEGIN
2846: ProgStep := ROUND (100 / opm_ListView_Main.SelCount);
2847: opm_ListView_Main.Enabled := FALSE;
2848: WHILE (CurItem <> NIL) DO
2849: BEGIN
2850: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressIgnore, Progress, _('Updating special prices...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2851: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
2852: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
2853: IF (FirstPass = TRUE) THEN
2854: BEGIN
2855: IF (opm_ListView_Main.SelCount > 1) THEN
2856: BEGIN
2857: opm_Form_AskUser.AU_Title := _('Change special price for products');
2858: opm_Form_AskUser.AU_DataText := '0.00';
2859: END
2860: ELSE
2861: BEGIN
2862: opm_Form_AskUser.AU_Title := _('Change special price for product ') + opm_CurrentProdRecord.DisplayName;
2863: opm_Form_AskUser.AU_DataText := CURRTOSTR (opm_CurrentProdRecord.Price);
2864: END;
2865: opm_Form_AskUser.AU_Directions := _('Type the new special price (xxx, -xxx, +xxx, -xxx%, +xxx%, 0 to disable):') + ' [' + TRIM (opm_CurrentCurrency.Code + ' ' + opm_CurrentCurrency.Left + ' ' + opm_CurrentCurrency.Right) + ']';
2866: opm_Form_AskUser.AU_TextOrList := TRUE;
2867: opm_Form_AskUser.AU_PassChar := #0;
2868: opm_Form_AskUser.AU_MaxLen := opmC_ProdSpecial_MaxLen;
2869: FirstPass := FALSE;
2870: IF (opm_Form_AskUser.ShowModal = mrOk) THEN CanContinue := TRUE ELSE CanContinue := FALSE;
2871: NewSpecial := FNopm_CleanNumber (opm_Form_AskUser.AU_DataText, opmC_ValIsNumOp);
2872: END;
2873: IF (CanContinue = TRUE) THEN PRopm_UpdateProdData (opm_CurrentProdID, opmG_DBTable_Specials, 'specials_new_products_price', FNopm_Apply_Operation (CURRTOSTR (opm_CurrentProdRecord.Price), NewSpecial, opmC_ValIsFloat, FALSE), TRUE, '', '', opmC_SQLDelInsNoZero) ELSE BREAK;
2874: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
2875: INC (Progress, ProgStep);
2876: END;
2877: IF (CanContinue = TRUE) THEN PRopm_Reload_ProductList (opm_WeAreSearching);
2878: opm_ListView_Main.Enabled := TRUE;
2879: opm_Form_Main.FocusControl (opm_ListView_Main);
2880: END;
2881: END;
2882:
2883: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2884: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2885: procedure Topm_Form_Main.opm_PopMenuItem_PQuantityClick(Sender: TObject);
2886: VAR
2887: CurItem : TListItem;
2888: Operand, NewQuantity : STRING;
2889: FirstPass, CanContinue : BOOLEAN;
2890: ProgStep, Progress : LONGINT;
2891: BEGIN
2892: CurItem := opm_ListView_Main.Selected;
2893: FirstPass := TRUE;
2894: CanContinue := TRUE;
2895: Progress := 0;
2896: IF (CurItem <> NIL) THEN
2897: BEGIN
2898: ProgStep := ROUND (100 / opm_ListView_Main.SelCount);
2899: opm_ListView_Main.Enabled := FALSE;
2900: WHILE (CurItem <> NIL) DO
2901: BEGIN
2902: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressIgnore, Progress, _('Updating quantity...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2903: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
2904: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
2905: IF (FirstPass = TRUE) THEN
2906: BEGIN
2907: IF (opm_ListView_Main.SelCount > 1) THEN
2908: BEGIN
2909: opm_Form_AskUser.AU_Title := _('Change quantity for products');
2910: opm_Form_AskUser.AU_DataText := '0';
2911: END
2912: ELSE
2913: BEGIN
2914: opm_Form_AskUser.AU_Title := _('Change quantity for product ') + opm_CurrentProdRecord.DisplayName;
2915: opm_Form_AskUser.AU_DataText := INTTOSTR (opm_CurrentProdRecord.Quantity);
2916: END;
2917: opm_Form_AskUser.AU_Directions := _('Type the new quantity (xxx, -xxx, +xxx, -xxx%, +xxx%):');
2918: opm_Form_AskUser.AU_TextOrList := TRUE;
2919: opm_Form_AskUser.AU_PassChar := #0;
2920: opm_Form_AskUser.AU_MaxLen := opmC_ProdQuantity_MaxLen;
2921: FirstPass := FALSE;
2922: IF (opm_Form_AskUser.ShowModal = mrOk) THEN CanContinue := TRUE ELSE CanContinue := FALSE;
2923: Operand := FNopm_CleanNumber (opm_Form_AskUser.AU_DataText, opmC_ValIsNumOp);
2924: END;
2925: IF (CanContinue = TRUE) THEN
2926: BEGIN
2927: NewQuantity := FNopm_Apply_Operation (INTTOSTR (opm_CurrentProdRecord.Quantity), Operand, opmC_ValIsInteger, (opmG_UIAllowNegativeQuantity = 1));
2928: IF ((STRTOINT (NewQuantity) < 0) AND (opmG_UIAllowNegativeQuantity = 0)) THEN
2929: FNopm_Message (_('Negative value not allowed.'), mtError, [mbOk], opmG_UISilent)
2930: ELSE
2931: PRopm_UpdateProdData (opm_CurrentProdID, opmG_DBTable_Products, 'products_quantity', NewQuantity, TRUE, '', '', opmC_SQLUpdate);
2932: END
2933: ELSE BREAK;
2934: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
2935: INC (Progress, ProgStep);
2936: END;
2937: IF (CanContinue = TRUE) THEN PRopm_Reload_ProductList (opm_WeAreSearching);
2938: opm_ListView_Main.Enabled := TRUE;
2939: opm_Form_Main.FocusControl (opm_ListView_Main);
2940: END;
2941: END;
2942:
2943: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2944: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2945: procedure Topm_Form_Main.opm_PopMenuItem_PManClick(Sender: TObject);
2946: VAR
2947: CurItem : TListItem;
2948: CurMan : opmR_Manufacturer;
2949: FirstPass, CanContinue : BOOLEAN;
2950: ProgStep, Progress : LONGINT;
2951: begin
2952: CurItem := opm_ListView_Main.Selected;
2953: FirstPass := TRUE;
2954: CanContinue := TRUE;
2955: Progress := 0;
2956: IF (CurItem <> NIL) THEN
2957: BEGIN
2958: ProgStep := ROUND (100 / opm_ListView_Main.SelCount);
2959: opm_ListView_Main.Enabled := FALSE;
2960: WHILE (CurItem <> NIL) DO
2961: BEGIN
2962: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressIgnore, Progress, _('Updating manufacturer...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
2963: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
2964: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
2965: IF (FirstPass = TRUE) THEN
2966: BEGIN
2967: opm_CurrentManRecord := FNopm_GetManufacturer (opmG_ManufacturerList, opm_CurrentProdRecord.ManufacturerID, opmC_FindByID);
2968: opm_Form_AskUser.AU_DataList := opmG_ManufacturerBoxList;
2969: IF (opm_ListView_Main.SelCount > 1) THEN
2970: BEGIN
2971: opm_Form_AskUser.AU_Title := _('Change manufacturer for products');
2972: opm_Form_AskUser.AU_ListItem := 0;
2973: END
2974: ELSE
2975: BEGIN
2976: opm_Form_AskUser.AU_Title := _('Change manufacturer for product ') + opm_CurrentProdRecord.DisplayName;
2977: opm_Form_AskUser.AU_ListItem := opm_CurrentManRecord.ListIndex;
2978: END;
2979: opm_Form_AskUser.AU_Directions := _('Select the new manufacturer:');
2980: opm_Form_AskUser.AU_TextOrList := FALSE;
2981: FirstPass := FALSE;
2982: IF (opm_Form_AskUser.ShowModal = mrOk) THEN CanContinue := TRUE ELSE CanContinue := FALSE;
2983: CurMan := FNopm_GetManufacturer (opmG_ManufacturerList, opm_Form_AskUser.AU_ListItem, opmC_FindByIndex);
2984: END;
2985: IF (CanContinue = TRUE) THEN PRopm_UpdateProdData (opm_CurrentProdID, opmG_DBTable_Products, 'manufacturers_id', INTTOSTR (CurMan.ID), TRUE, '', '', opmC_SQLUpdate) ELSE BREAK;
2986: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
2987: INC (Progress, ProgStep);
2988: END;
2989: IF (CanContinue = TRUE) THEN PRopm_Reload_ProductList (opm_WeAreSearching);
2990: opm_ListView_Main.Enabled := TRUE;
2991: opm_Form_Main.FocusControl (opm_ListView_Main);
2992: END;
2993: end;
2994:
2995: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2996: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
2997: procedure Topm_Form_Main.opm_PopMenuItem_PCatClick(Sender: TObject);
2998: VAR
2999: CurItem : TListItem;
3000: CurCat : opmR_Category;
3001: FirstPass, CanContinue : BOOLEAN;
3002: ProgStep, Progress : LONGINT;
3003: BEGIN
3004: CurItem := opm_ListView_Main.Selected;
3005: FirstPass := TRUE;
3006: CanContinue := TRUE;
3007: Progress := 0;
3008: IF (CurItem <> NIL) THEN
3009: BEGIN
3010: ProgStep := ROUND (100 / opm_ListView_Main.SelCount);
3011: opm_ListView_Main.Enabled := FALSE;
3012: WHILE (CurItem <> NIL) DO
3013: BEGIN
3014: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressIgnore, Progress, _('Updating category...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
3015: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3016: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
3017: IF (FirstPass = TRUE) THEN
3018: BEGIN
3019: opm_CurrentCatRecord := FNopm_GetCategory (opmG_CategoryList, opm_CurrentProdRecord.CategoryID, opmC_FindByID);
3020: opm_Form_AskUser.AU_DataList := opmG_CategoryBoxList;
3021: IF (opm_ListView_Main.SelCount > 1) THEN
3022: BEGIN
3023: opm_Form_AskUser.AU_Title := _('Change category for products');
3024: opm_Form_AskUser.AU_ListItem := opm_CurrentCatRecord.ListIndex;
3025: END
3026: ELSE
3027: BEGIN
3028: opm_Form_AskUser.AU_Title := _('Change category for product ') + opm_CurrentProdRecord.DisplayName;
3029: opm_Form_AskUser.AU_ListItem := opm_CurrentCatRecord.ListIndex;
3030: END;
3031: opm_Form_AskUser.AU_Directions := _('Select the new category:');
3032: opm_Form_AskUser.AU_TextOrList := FALSE;
3033: FirstPass := FALSE;
3034: IF (opm_Form_AskUser.ShowModal = mrOk) THEN CanContinue := TRUE ELSE CanContinue := FALSE;
3035: CurCat := FNopm_GetCategory (opmG_CategoryList, opm_Form_AskUser.AU_ListItem, opmC_FindByIndex);
3036: END;
3037: IF (CanContinue = TRUE) THEN
3038: PRopm_UpdateProdData (opm_CurrentProdID, opmG_DBTable_ProductsToCategories, 'categories_id', INTTOSTR (CurCat.ID), TRUE, 'categories_id', INTTOSTR (opm_CurrentProdRecord.CategoryID), opmC_SQLUpdate)
3039: ELSE BREAK;
3040: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
3041: INC (Progress, ProgStep);
3042: END;
3043: IF (CanContinue = TRUE) THEN PRopm_Reload_ProductList (opm_WeAreSearching);
3044: opm_ListView_Main.Enabled := TRUE;
3045: opm_Form_Main.FocusControl (opm_ListView_Main);
3046: END;
3047: end;
3048:
3049: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3050: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3051: procedure Topm_Form_Main.opm_TreeView_MainDragDrop (Sender, Source: TObject; X, Y: Integer);
3052: VAR
3053: DropNode : TTreeNode;
3054: CurCat : opmR_Category;
3055: CurProdR : opmR_Product;
3056: CurProd : LONGINT;
3057: CurItem : TListItem;
3058: FirstPass, CanContinue : BOOLEAN;
3059: ProgStep, Progress : LONGINT;
3060: begin
3061: IF ((Source IS TListView) AND (opmG_UIDragDrop > 0) AND (opm_TreeView_Main.Selected <> NIL)) THEN
3062: BEGIN
3063: DropNode := opm_TreeView_Main.GetNodeAt (X, Y);
3064: CurItem := opm_ListView_Main.Selected;
3065: FirstPass := TRUE;
3066: CanContinue := TRUE;
3067: Progress := 0;
3068: IF ((CurItem <> NIL) AND (DropNode <> NIL)) THEN
3069: BEGIN
3070: ProgStep := ROUND (100 / opm_ListView_Main.SelCount);
3071: opm_ListView_Main.Enabled := FALSE;
3072: WHILE (CurItem <> NIL) DO
3073: BEGIN
3074: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressIgnore, Progress, _('Updating category...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
3075: CurProd := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3076: CurProdR := FNopm_GetProductByID (CurProd, opm_CurrentLang, opmG_ProductList);
3077: CurCat := FNopm_GetCategory (opmG_CategoryList, DropNode.AbsoluteIndex, opmC_FindByNode);
3078: IF (CurCat.ID < opmC_SC_BaseID) THEN
3079: BEGIN
3080: IF (FirstPass = TRUE) THEN
3081: BEGIN
3082: IF (opmG_UIConfirmDrag > 0) THEN
3083: IF (FNopm_Message (_('Do you want to move these products to category ') + CurCat.Name + '?', mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes) THEN
3084: CanContinue := TRUE
3085: ELSE
3086: CanContinue := FALSE;
3087: FirstPass := FALSE;
3088: END;
3089: IF (CurCat.ID > 0) THEN
3090: IF (CanContinue = TRUE) THEN
3091: IF (CurProdR.CategoryID > 0) THEN
3092: BEGIN
3093: PRopm_UpdateProdData (CurProdR.ID, opmG_DBTable_ProductsToCategories, 'categories_id', INTTOSTR (CurCat.ID), TRUE, 'categories_id', INTTOSTR (CurProdR.CategoryID), opmC_SQLUpdate);
3094: END
3095: ELSE
3096: BEGIN
3097: PRopm_UpdateProdData (CurProdR.ID, opmG_DBTable_ProductsToCategories, 'categories_id', INTTOSTR (CurCat.ID), TRUE, 'categories_id', INTTOSTR (CurProdR.CategoryID), opmC_SQLDelIns);
3098: END
3099: ELSE BREAK;
3100: END;
3101: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
3102: INC (Progress, ProgStep);
3103: END;
3104: END;
3105: IF (CanContinue = TRUE) THEN PRopm_Reload_ProductList (opm_WeAreSearching);
3106: opm_ListView_Main.Enabled := TRUE;
3107: opm_Form_Main.FocusControl (opm_ListView_Main);
3108: END;
3109: end;
3110:
3111:
3112: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3113: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3114: procedure Topm_Form_Main.opm_PopMenuItem_PModelClick(Sender: TObject);
3115: VAR
3116: CurItem : TListItem;
3117: BEGIN
3118: CurItem := opm_ListView_Main.Selected;
3119: IF (CurItem <> NIL) THEN
3120: BEGIN
3121: opm_ListView_Main.Enabled := FALSE;
3122: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3123: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
3124: opm_Form_AskUser.AU_Title := _('Change model for product ') + opm_CurrentProdRecord.DisplayName;
3125: opm_Form_AskUser.AU_Directions := _('Type the new model:');
3126: opm_Form_AskUser.AU_TextOrList := TRUE;
3127: opm_Form_AskUser.AU_PassChar := #0;
3128: opm_Form_AskUser.AU_MaxLen := opmC_ProdModel_MaxLen;
3129: opm_Form_AskUser.AU_DataText := FNopm_CleanString (opm_CurrentProdRecord.Model);
3130: IF (opm_Form_AskUser.ShowModal = mrOk) THEN
3131: BEGIN
3132: PRopm_UpdateProdData (opm_CurrentProdID, opmG_DBTable_Products, 'products_model', FNopm_CleanSQLString (opm_Form_AskUser.AU_DataText, FALSE), FALSE, '', '', opmC_SQLUpdate);
3133: END;
3134: PRopm_Reload_ProductList (opm_WeAreSearching);
3135: opm_ListView_Main.Enabled := TRUE;
3136: opm_Form_Main.FocusControl (opm_ListView_Main);
3137: END;
3138: END;
3139:
3140: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3141: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3142: procedure Topm_Form_Main.opm_PopMenuItem_PWeightClick(Sender: TObject);
3143: VAR
3144: CurItem : TListItem;
3145: NewWeight : STRING;
3146: BEGIN
3147: CurItem := opm_ListView_Main.Selected;
3148: IF (CurItem <> NIL) THEN
3149: BEGIN
3150: opm_ListView_Main.Enabled := FALSE;
3151: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3152: opm_CurrentProdRecord := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
3153: opm_Form_AskUser.AU_Title := _('Change weight for product ') + opm_CurrentProdRecord.DisplayName;
3154: opm_Form_AskUser.AU_Directions := _('Type the new weight:');
3155: opm_Form_AskUser.AU_TextOrList := TRUE;
3156: opm_Form_AskUser.AU_PassChar := #0;
3157: opm_Form_AskUser.AU_MaxLen := opmC_ProdWeight_MaxLen;
3158: opm_Form_AskUser.AU_DataText := FLOATTOSTR (opm_CurrentProdRecord.Weight);
3159: IF (opm_Form_AskUser.ShowModal = mrOk) THEN
3160: BEGIN
3161: NewWeight := FNopm_CleanNumber (opm_Form_AskUser.AU_DataText, opmC_ValIsNumOp);
3162: PRopm_UpdateProdData (opm_CurrentProdID, opmG_DBTable_Products, 'products_weight', FNopm_Apply_Operation (FLOATTOSTR (opm_CurrentProdRecord.Weight), NewWeight, opmC_ValIsFloat, FALSE), TRUE, '', '', opmC_SQLUpdate);
3163: END;
3164: PRopm_Reload_ProductList (opm_WeAreSearching);
3165: opm_ListView_Main.Enabled := TRUE;
3166: opm_Form_Main.FocusControl (opm_ListView_Main);
3167: END;
3168: END;
3169:
3170: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3171: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3172: procedure Topm_Form_Main.opm_PopMenuItem_CatExpandClick(Sender: TObject);
3173: begin
3174: opm_TreeView_Main.FullExpand;
3175: end;
3176:
3177: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3178: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3179: procedure Topm_Form_Main.opm_PopMenuItem_CatCollapseClick(Sender: TObject);
3180: begin
3181: opm_TreeView_Main.FullCollapse;
3182: end;
3183:
3184: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3185: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3186: procedure Topm_Form_Main.opm_PopMenuItem_CatExpand2Click(Sender: TObject);
3187: begin
3188: opm_TreeView_Main.Selected.Expanded := TRUE;
3189: end;
3190:
3191: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3192: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3193: procedure Topm_Form_Main.opm_PopMenuItem_CatCollapse2Click(Sender: TObject);
3194: begin
3195: opm_TreeView_Main.Selected.Expanded := FALSE;
3196: end;
3197:
3198: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3199: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3200: procedure Topm_Form_Main.opm_TreeView_MainContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean);
3201: begin
3202: opm_TreeView_Main.Selected := opm_TreeView_Main.GetNodeAt (MousePos.X, MousePos.Y);
3203: end;
3204:
3205: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3206: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3207: procedure Topm_Form_Main.opm_TreeView_MainKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
3208: begin
3209: CASE Key OF
3210: VK_SPACE, VK_RETURN : opm_TreeView_Main.Selected.Expanded := NOT (opm_TreeView_Main.Selected.Expanded);
3211: VK_DELETE : opm_PopMenuItem_CatDeleteClick (Sender);
3212: VK_INSERT : opm_PopMenuItem_CatAddClick (Sender);
3213: END;
3214: end;
3215:
3216: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3217: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3218: procedure Topm_Form_Main.opm_TreeView_MainKeyPress(Sender: TObject; var Key: Char);
3219: begin
3220: IF ((Key = ' ') OR (Key = #13)) THEN
3221: Key := #0;
3222: end;
3223:
3224:
3225: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3226: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3227: procedure Topm_Form_Main.opm_TreeView_MainDragOver (Sender, Source: TObject;
3228: X, Y: Integer; State: TDragState;
3229: var Accept: Boolean);
3230: begin
3231: IF ((Source IS TListView) AND (opmG_UIDragDrop > 0)) THEN
3232: BEGIN
3233: Accept := TRUE;
3234: END
3235: ELSE
3236: BEGIN
3237: Accept := FALSE;
3238: END;
3239: end;
3240:
3241: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3242: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3243: procedure Topm_Form_Main.opm_MenuItem_LicenseClick(Sender: TObject);
3244: begin
3245: opm_Form_License.ShowModal;
3246: end;
3247:
3248:
3249: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3250: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3251: procedure Topm_Form_Main.opm_MenuItem_AboutClick(Sender: TObject);
3252: begin
3253: opm_Form_About.ShowModal;
3254: {$IFDEF OSCPMDEBUG}
3255: FNopm_Message (_('THIS IS A SPECIAL DEBUG-VERSION. Use it only to report crashes and fatal errors. DO NOT DISTRIBUTE. The full open-source version can be found in the website.'), mtInformation, [mbOk], opmG_UISilent);
3256: {$ENDIF}
3257: end;
3258:
3259: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3260: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3261: procedure Topm_Form_Main.opm_PopMenuItem_HideDebugClick(Sender: TObject);
3262: begin
3263: opmG_UIDBDebug := 0;
3264: PRReg_WriteSetting ('OSCDBDebug', INTTOSTR (opmG_UIDBDebug), opmC_RegistryKey, opmC_RKConfig);
3265: opm_DataSource_DEBUG.Enabled := FALSE;
3266: opm_DBGrid_DEBUG.Enabled := FALSE;
3267: opm_DBGrid_DEBUG.Visible := FALSE;
3268: opm_Panel_DEBUG.Visible := FALSE;
3269: end;
3270:
3271: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3272: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3273: procedure Topm_Form_Main.FormClose(Sender: TObject; var Action: TCloseAction);
3274: begin
3275: IF (opmG_UIConfirmExit > 0) THEN
3276: BEGIN
3277: IF (FNopm_Message (_('Do you really want to quit the ') + opmC_AppName1 +'?', mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes) THEN
3278: BEGIN
3279: Application.HelpCommand (HELP_QUIT, 0);
3280: Action := caFree;
3281: FNopm_CloseDBConnection;
3282: PRopm_CloseSSHTunnel;
3283: PRopm_SaveConfiguration;
3284: END
3285: ELSE
3286: Action := caNone;
3287: END
3288: ELSE
3289: BEGIN
3290: FNopm_CloseDBConnection;
3291: PRopm_CloseSSHTunnel;
3292: PRopm_SaveConfiguration;
3293: END;
3294: end;
3295:
3296: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3297: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3298: procedure Topm_Form_Main.opm_TreeView_MainDblClick(Sender: TObject);
3299: begin
3300: IF (opm_CurrentCatRecord.ID < opmC_SC_BaseID) THEN
3301: IF (opmG_UIClickLoad <= 0) THEN
3302: BEGIN
3303: PRopm_LoadProductListByCat (opm_CurrentCategory, opmG_ProductList, opmG_DescriptionList);
3304: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
3305: PRopm_Valid_CatOps (opm_WeAreConnected, opm_TreeView_Main.Selected);
3306: PRopm_Valid_ProdOps (opm_WeAreConnected, opm_ListView_Main.Selected, opm_ListView_Main.SelCount, opm_TreeView_Main.Selected);
3307: END;
3308: end;
3309:
3310: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3311: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3312: procedure Topm_Form_Main.opm_TreeView_MainExpanding(Sender: TObject; Node: TTreeNode; var AllowExpansion: Boolean);
3313: begin
3314: AllowExpansion := opm_CanExpandTree_Flag;
3315: opm_CanExpandTree_Flag := TRUE;
3316: end;
3317:
3318: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3319: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3320: procedure Topm_Form_Main.opm_TreeView_MainCollapsing(Sender: TObject; Node: TTreeNode; var AllowCollapse: Boolean);
3321: begin
3322: AllowCollapse := opm_CanExpandTree_Flag;
3323: opm_CanExpandTree_Flag := TRUE;
3324: end;
3325:
3326:
3327:
3328: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3329: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3330: PROCEDURE Topm_Form_Main.PRopm_SetUILang (LangISOID : STRING);
3331: BEGIN
3332: IF (FNopm_CheckLanguage (LangISOID) = FALSE) THEN LangISOID := opmC_Def_GUILang;
3333: UseLanguage(LangISOID);
3334: TranslateComponent (opm_Form_Main);
3335: TranslateComponent (opm_Form_License);
3336: TranslateComponent (opm_Form_About);
3337: TranslateComponent (opm_Form_PEdit);
3338: TranslateComponent (opm_Form_ImageZoom);
3339: TranslateComponent (opm_Form_SearchProduct);
3340: TranslateComponent (opm_Form_UploadImage);
3341: TranslateComponent (opm_Form_AskUser);
3342: TranslateComponent (opm_Form_Config);
3343: TranslateComponent (opm_Form_Runmod);
3344: TranslateComponent (opm_Form_Colorsel);
3345: END;
3346:
3347:
3348:
3349:
3350: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3351: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3352: procedure Topm_Form_Main.opm_PopMenuItem_PDeleteClick(Sender: TObject);
3353: VAR
3354: CurItem : TListItem;
3355: ProgStep, Progress : LONGINT;
3356: BEGIN
3357: CurItem := opm_ListView_Main.Selected;
3358: Progress := 0;
3359: IF (CurItem <> NIL) THEN
3360: BEGIN
3361: ProgStep := ROUND (100 / opm_ListView_Main.SelCount);
3362: opm_ListView_Main.Enabled := FALSE;
3363: WHILE (CurItem <> NIL) DO
3364: BEGIN
3365: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressIgnore, Progress, _('Deleting product...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
3366: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3367: PRopm_DeleteProduct (opm_CurrentProdID);
3368: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
3369: INC (Progress, ProgStep);
3370: END;
3371: PRopm_Reload_ProductList (opm_WeAreSearching);
3372: opm_ListView_Main.Enabled := TRUE;
3373: opm_Form_Main.FocusControl (opm_ListView_Main);
3374: END;
3375: end;
3376:
3377:
3378: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3379: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3380: procedure Topm_Form_Main.opm_PopMenuItem_PAddClick(Sender: TObject);
3381: VAR
3382: CurLang : LONGINT;
3383: begin
3384: opm_CurrentPEditRecord.ID := 0;
3385: opm_CurrentPEditRecord.Model := '';
3386: opm_CurrentPEditRecord.Quantity := 0;
3387: opm_CurrentPEditRecord.Price := 0;
3388: opm_CurrentPEditRecord.Weight := 0;
3389: opm_CurrentPEditRecord.ManufacturerID := opmG_Past_PManufacturer;
3390: opm_CurrentPEditRecord.CategoryID := opm_CurrentCategory;
3391: opm_CurrentPEditRecord.DisplayName := '';
3392: opm_CurrentPEditRecord.Available := 1;
3393: opm_CurrentPEditRecord.ImageURL := '';
3394: opm_CurrentPEditRecord.ImageURL1 := '';
3395: opm_CurrentPEditRecord.ImageURL2 := '';
3396: opm_CurrentPEditRecord.ImageURL3 := '';
3397: opm_CurrentPEditRecord.ImageURL4 := '';
3398: opm_CurrentPEditRecord.ImageURL5 := '';
3399: opm_CurrentPEditRecord.ImageURL6 := '';
3400: opm_CurrentPEditRecord.Special := 0;
3401: opm_CurrentPEditRecord.LanguageID := opm_CurrentLang;
3402: opm_CurrentPEditRecord.Tax := opmG_Past_PTaxClass;
3403: opm_CurrentPEditRecord.AvailDate := opmG_Past_PAvailDate;
3404: opm_CurrentPEditRecord.CreationDate := opmG_Past_PAvailDate;
3405: opm_CurrentPEditRecord.ChangeDate := opmG_Past_PAvailDate;
3406: opm_CurrentProdRecord := opm_CurrentPEditRecord;
3407: FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
3408: BEGIN
3409: opm_CurrentSingleDescList[CurLang].ID := opmC_InsertProdID;
3410: opm_CurrentSingleDescList[CurLang].Name := '';
3411: opm_CurrentSingleDescList[CurLang].Description := '';
3412: opm_CurrentSingleDescList[CurLang].URL := '';
3413: opm_CurrentSingleDescList[CurLang].LanguageID := opmG_LanguageList[CurLang].ID;
3414: opm_CurrentSingleDescList[CurLang].Viewed := 0;
3415: END;
3416: FOR CurLang := opm_TotalLanguages TO opmC_Max_Languages_PerList DO
3417: BEGIN
3418: opm_CurrentSingleDescList[CurLang].ID := 0;
3419: opm_CurrentSingleDescList[CurLang].Name := '';
3420: opm_CurrentSingleDescList[CurLang].Description := '';
3421: opm_CurrentSingleDescList[CurLang].URL := '';
3422: opm_CurrentSingleDescList[CurLang].LanguageID := 0;
3423: opm_CurrentSingleDescList[CurLang].Viewed := 0;
3424: END;
3425: IF (opm_Form_PEdit.ShowModal = mrOk) THEN
3426: BEGIN
3427: PRopm_AddProduct (opm_CurrentPEditRecord, opm_CurrentSingleDescList);
3428: opmG_Past_PAvailDate := ROUND (opm_CurrentPEditRecord.AvailDate);
3429: opmG_Past_PManufacturer := opm_CurrentPEditRecord.ManufacturerID;
3430: opmG_Past_PTaxClass := opm_CurrentPEditRecord.Tax;
3431: END;
3432: end;
3433:
3434:
3435:
3436: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3437: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3438: PROCEDURE Topm_Form_Main.PRopm_Create_ExportList (VAR ExportString : STRING; VAR CatList : opmT_CategoryList; VAR ManList : opmT_ManufacturerList; JustifyCols : BOOLEAN);
3439: VAR
3440: CurItem : TListItem;
3441: ExportLine : STRING;
3442: CurProd : opmR_Product;
3443: CurCat : opmR_Category;
3444: CurMan : opmR_Manufacturer;
3445: CurDesc : opmR_Description;
3446: MaxWidths : ARRAY [0..20] OF LONGINT;
3447: FmtString : ARRAY [0..20] OF STRING;
3448: BEGIN
3449: ExportString := '';
3450: opm_ListView_Main.Enabled := FALSE;
3451: IF (JustifyCols = TRUE) THEN
3452: BEGIN
3453: CurItem := opm_ListView_Main.Selected;
3454: WHILE (CurItem <> NIL) DO
3455: BEGIN
3456: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3457: CurProd := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
3458: CurCat := FNopm_GetCategory (CatList, CurProd.CategoryID, opmC_FindByID);
3459: CurMan := FNopm_GetManufacturer (ManList, CurProd.ManufacturerID, opmC_FindByID);
3460: CurDesc := FNopm_GetDescriptionByID (opm_CurrentProdID, opm_CurrentLang, opmG_DescriptionList);
3461: MaxWidths [0] := MAX (LENGTH (INTTOSTR (CurProd.ID)), MaxWidths [0]);
3462: MaxWidths [1] := MAX (LENGTH (FNopm_NumToYesNo (CurProd.Available)), MaxWidths [1]);
3463: MaxWidths [2] := MAX (LENGTH (FNopm_CleanString (CurProd.Model)), MaxWidths [2]);
3464: MaxWidths [3] := MAX (LENGTH (INTTOSTR (CurProd.CategoryID)), MaxWidths [3]);
3465: MaxWidths [4] := MAX (LENGTH (FNopm_CleanString (CurCat.Name)), MaxWidths [4]);
3466: MaxWidths [5] := MAX (LENGTH (INTTOSTR (CurProd.ManufacturerID)), MaxWidths [5]);
3467: MaxWidths [6] := MAX (LENGTH (FNopm_CleanString (CurMan.Name)), MaxWidths [6]);
3468: MaxWidths [7] := MAX (LENGTH (FNopm_CleanString (CurProd.DisplayName)), MaxWidths [7]);
3469: MaxWidths [8] := MAX (LENGTH (INTTOSTR (CurProd.Quantity)), MaxWidths [8]);
3470: MaxWidths [9] := MAX (LENGTH (FNopm_CleanNumber (CURRTOSTR (CurProd.Price), opmC_ValIsFloat)), MaxWidths [9]);
3471: MaxWidths [10] := MAX (LENGTH (FNopm_CleanNumber (CURRTOSTR (CurProd.Special), opmC_ValIsFloat)), MaxWidths [10]);
3472: MaxWidths [11] := MAX (LENGTH (FNopm_CleanNumber (CURRTOSTR (CurProd.Weight), opmC_ValIsFloat)), MaxWidths [11]);
3473: MaxWidths [12] := MAX (LENGTH (FNopm_CleanString (FNopm_NoCRLF (CurDesc.Description))), MaxWidths [12]);
3474: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
3475: END;
3476: MaxWidths [0] := MIN (opmG_Clip_ColSize, MaxWidths [0]);
3477: MaxWidths [1] := MIN (opmG_Clip_ColSize, MaxWidths [1]);
3478: MaxWidths [2] := MIN (opmG_Clip_ColSize, MaxWidths [2]);
3479: MaxWidths [3] := MIN (opmG_Clip_ColSize, MaxWidths [3]);
3480: MaxWidths [4] := MIN (opmG_Clip_ColSize, MaxWidths [4]);
3481: MaxWidths [5] := MIN (opmG_Clip_ColSize, MaxWidths [5]);
3482: MaxWidths [6] := MIN (opmG_Clip_ColSize, MaxWidths [6]);
3483: MaxWidths [7] := MIN (opmG_Clip_ColSize, MaxWidths [7]);
3484: MaxWidths [8] := MIN (opmG_Clip_ColSize, MaxWidths [8]);
3485: MaxWidths [9] := MIN (opmG_Clip_ColSize, MaxWidths [9]);
3486: MaxWidths [10] := MIN (opmG_Clip_ColSize, MaxWidths [10]);
3487: MaxWidths [11] := MIN (opmG_Clip_ColSize, MaxWidths [11]);
3488: MaxWidths [12] := MIN (opmG_Clip_ColSize, MaxWidths [12]);
3489: FmtString [0] := '%' + INTTOSTR (MaxWidths [0]) + '.' + INTTOSTR (MaxWidths [0]) + 's' + opmC_ExportJSeparator;
3490: FmtString [1] := '%-' + INTTOSTR (MaxWidths [1]) + '.' + INTTOSTR (MaxWidths [1]) + 's' + opmC_ExportJSeparator;
3491: FmtString [2] := '%-' + INTTOSTR (MaxWidths [2]) + '.' + INTTOSTR (MaxWidths [2]) + 's' + opmC_ExportJSeparator;
3492: FmtString [3] := '%' + INTTOSTR (MaxWidths [3]) + '.' + INTTOSTR (MaxWidths [3]) + 's' + opmC_ExportJSeparator;
3493: FmtString [4] := '%-' + INTTOSTR (MaxWidths [4]) + '.' + INTTOSTR (MaxWidths [4]) + 's' + opmC_ExportJSeparator;
3494: FmtString [5] := '%' + INTTOSTR (MaxWidths [5]) + '.' + INTTOSTR (MaxWidths [5]) + 's' + opmC_ExportJSeparator;
3495: FmtString [6] := '%-' + INTTOSTR (MaxWidths [6]) + '.' + INTTOSTR (MaxWidths [6]) + 's' + opmC_ExportJSeparator;
3496: FmtString [7] := '%-' + INTTOSTR (MaxWidths [7]) + '.' + INTTOSTR (MaxWidths [7]) + 's' + opmC_ExportJSeparator;
3497: FmtString [8] := '%' + INTTOSTR (MaxWidths [8]) + '.' + INTTOSTR (MaxWidths [8]) + 's' + opmC_ExportJSeparator;
3498: FmtString [9] := '%' + INTTOSTR (MaxWidths [9]) + '.' + INTTOSTR (MaxWidths [9]) + 's' + opmC_ExportJSeparator;
3499: FmtString [10] := '%' + INTTOSTR (MaxWidths [10]) + '.' + INTTOSTR (MaxWidths [10]) + 's' + opmC_ExportJSeparator;
3500: FmtString [11] := '%' + INTTOSTR (MaxWidths [11]) + '.' + INTTOSTR (MaxWidths [11]) + 's' + opmC_ExportJSeparator;
3501: FmtString [12] := '%-' + INTTOSTR (MaxWidths [12]) + '.' + INTTOSTR (MaxWidths [12]) + 's' + opmC_ExportJSeparator;
3502: END;
3503: CurItem := opm_ListView_Main.Selected;
3504: IF (CurItem <> NIL) THEN
3505: BEGIN
3506: ExportLine := '';
3507: IF (JustifyCols = TRUE) THEN
3508: BEGIN
3509: ExportLine := ExportLine + FORMAT (FmtString [0], [_('Product ID')]);
3510: ExportLine := ExportLine + FORMAT (FmtString [1], [_('Available')]);
3511: ExportLine := ExportLine + FORMAT (FmtString [2], [_('Model')]);
3512: ExportLine := ExportLine + FORMAT (FmtString [3], [_('Category ID')]);
3513: ExportLine := ExportLine + FORMAT (FmtString [4], [_('Category name')]);
3514: ExportLine := ExportLine + FORMAT (FmtString [5], [_('Manufacturer ID')]);
3515: ExportLine := ExportLine + FORMAT (FmtString [6], [_('Manufacturer name')]);
3516: ExportLine := ExportLine + FORMAT (FmtString [7], [_('Product name')]);
3517: ExportLine := ExportLine + FORMAT (FmtString [8], [_('Quantity')]);
3518: ExportLine := ExportLine + FORMAT (FmtString [9], [_('Price')]);
3519: ExportLine := ExportLine + FORMAT (FmtString [10], [_('Special price')]);
3520: ExportLine := ExportLine + FORMAT (FmtString [11], [_('Weight')]);
3521: ExportLine := ExportLine + FORMAT (FmtString [12], [_('Description')]);
3522: ExportString := ExportString + opmC_ExportJSeparator + ExportLine + #13#10;
3523: ExportString := ExportString + DUPESTRING (opmC_ExportJHSeparator, LENGTH (opmC_ExportJSeparator + ExportLine)) + #13#10;
3524: END
3525: ELSE
3526: BEGIN
3527: ExportLine := ExportLine + _('Product ID') + opmC_ExportSeparator;
3528: ExportLine := ExportLine + _('Available') + opmC_ExportSeparator;
3529: ExportLine := ExportLine + _('Model') + opmC_ExportSeparator;
3530: ExportLine := ExportLine + _('Category ID') + opmC_ExportSeparator;
3531: ExportLine := ExportLine + _('Category name') + opmC_ExportSeparator;
3532: ExportLine := ExportLine + _('Manufacturer ID') + opmC_ExportSeparator;
3533: ExportLine := ExportLine + _('Manufacturer name') + opmC_ExportSeparator;
3534: ExportLine := ExportLine + _('Product name') + opmC_ExportSeparator;
3535: ExportLine := ExportLine + _('Quantity') + opmC_ExportSeparator;
3536: ExportLine := ExportLine + _('Price') + opmC_ExportSeparator;
3537: ExportLine := ExportLine + _('Special price') + opmC_ExportSeparator;
3538: ExportLine := ExportLine + _('Weight') + opmC_ExportSeparator;
3539: ExportLine := ExportLine + _('Description') + opmC_ExportSeparator;
3540: ExportString := ExportString + ExportLine + #13#10;
3541: END;
3542: ExportLine := '';
3543: WHILE (CurItem <> NIL) DO
3544: BEGIN
3545: IF (JustifyCols = TRUE) THEN
3546: BEGIN
3547: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3548: CurProd := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
3549: CurCat := FNopm_GetCategory (CatList, CurProd.CategoryID, opmC_FindByID);
3550: CurMan := FNopm_GetManufacturer (ManList, CurProd.ManufacturerID, opmC_FindByID);
3551: CurDesc := FNopm_GetDescriptionByID (opm_CurrentProdID, opm_CurrentLang, opmG_DescriptionList);
3552: ExportLine := ExportLine + FORMAT (FmtString [0], [INTTOSTR (CurProd.ID)]);
3553: ExportLine := ExportLine + FORMAT (FmtString [1], [FNopm_NumToYesNo (CurProd.Available)]);
3554: ExportLine := ExportLine + FORMAT (FmtString [2], [FNopm_CleanString (CurProd.Model)]);
3555: ExportLine := ExportLine + FORMAT (FmtString [3], [INTTOSTR (CurProd.CategoryID)]);
3556: ExportLine := ExportLine + FORMAT (FmtString [4], [FNopm_CleanString (CurCat.Name)]);
3557: ExportLine := ExportLine + FORMAT (FmtString [5], [INTTOSTR (CurProd.ManufacturerID)]);
3558: ExportLine := ExportLine + FORMAT (FmtString [6], [FNopm_CleanString (CurMan.Name)]);
3559: ExportLine := ExportLine + FORMAT (FmtString [7], [FNopm_CleanString (CurProd.DisplayName)]);
3560: ExportLine := ExportLine + FORMAT (FmtString [8], [INTTOSTR (CurProd.Quantity)]);
3561: ExportLine := ExportLine + FORMAT (FmtString [9], [FNopm_CleanNumber (CURRTOSTR (CurProd.Price), opmC_ValIsFloat)]);
3562: ExportLine := ExportLine + FORMAT (FmtString [10], [FNopm_CleanNumber (CURRTOSTR (CurProd.Special), opmC_ValIsFloat)]);
3563: ExportLine := ExportLine + FORMAT (FmtString [11], [FNopm_CleanNumber (CURRTOSTR (CurProd.Weight), opmC_ValIsFloat)]);
3564: ExportLine := ExportLine + FORMAT (FmtString [12], [FNopm_CleanString (FNopm_NoCRLF (FNopm_StripHTML (CurDesc.Description)))]);
3565: ExportString := ExportString + opmC_ExportJSeparator + ExportLine + #13#10;
3566: END
3567: ELSE
3568: BEGIN
3569: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3570: CurProd := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
3571: CurCat := FNopm_GetCategory (CatList, CurProd.CategoryID, opmC_FindByID);
3572: CurMan := FNopm_GetManufacturer (ManList, CurProd.ManufacturerID, opmC_FindByID);
3573: CurDesc := FNopm_GetDescriptionByID (opm_CurrentProdID, opm_CurrentLang, opmG_DescriptionList);
3574: ExportLine := ExportLine + INTTOSTR (CurProd.ID) + opmC_ExportSeparator;
3575: ExportLine := ExportLine + INTTOSTR (CurProd.Available) + opmC_ExportSeparator;
3576: ExportLine := ExportLine + FNopm_CleanString (CurProd.Model) + opmC_ExportSeparator;
3577: ExportLine := ExportLine + INTTOSTR (CurProd.CategoryID) + opmC_ExportSeparator;
3578: ExportLine := ExportLine + FNopm_CleanString (CurCat.Name) + opmC_ExportSeparator;
3579: ExportLine := ExportLine + INTTOSTR (CurProd.ManufacturerID) + opmC_ExportSeparator;
3580: ExportLine := ExportLine + FNopm_CleanString (CurMan.Name) + opmC_ExportSeparator;
3581: ExportLine := ExportLine + FNopm_CleanString (CurProd.DisplayName) + opmC_ExportSeparator;
3582: ExportLine := ExportLine + INTTOSTR (CurProd.Quantity) + opmC_ExportSeparator;
3583: ExportLine := ExportLine + FNopm_CleanNumber (CURRTOSTR (CurProd.Price), opmC_ValIsFloat) + opmC_ExportSeparator;
3584: ExportLine := ExportLine + FNopm_CleanNumber (CURRTOSTR (CurProd.Special), opmC_ValIsFloat) + opmC_ExportSeparator;
3585: ExportLine := ExportLine + FNopm_CleanNumber (CURRTOSTR (CurProd.Weight), opmC_ValIsFloat) + opmC_ExportSeparator;
3586: ExportLine := ExportLine + FNopm_CleanString (FNopm_NoCRLF (FNopm_StripHTML (CurDesc.Description))) + opmC_ExportSeparator;
3587: ExportString := ExportString + ExportLine + #13#10;
3588: END;
3589: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
3590: ExportLine := '';
3591: END;
3592: END;
3593: opm_ListView_Main.Enabled := TRUE;
3594: opm_Form_Main.FocusControl (opm_ListView_Main);
3595: END;
3596:
3597:
3598: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3599: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3600: procedure Topm_Form_Main.opm_PopMenuItem_PExportClick(Sender: TObject);
3601: VAR
3602: ExportFile : TEXTFILE;
3603: ExportText : STRING;
3604: BEGIN
3605: opm_SaveDialog_Export.DefaultExt := opmC_Def_ExportExt;
3606: opm_SaveDialog_Export.FileName := opmC_Def_ExportFilename;
3607: opm_SaveDialog_Export.Filter := _('Text record files') + ' (' + opmC_Def_ExportFilter + ')|' + opmC_Def_ExportFilter + '|' + _('All files (*.*)');
3608: opm_SaveDialog_Export.Title := _('Exporting product list...');
3609: IF (opm_SaveDialog_Export.Execute = TRUE) THEN
3610: BEGIN
3611: PRopm_Create_ExportList (ExportText, opmG_CategoryList, opmG_ManufacturerList, FALSE);
3612: TRY
3613: AssignFile (ExportFile, opm_SaveDialog_Export.FileName);
3614: Rewrite (ExportFile);
3615: WRITELN (ExportFile, ExportText);
3616: CloseFile (ExportFile);
3617: EXCEPT
3618: ON E : Exception DO
3619: BEGIN
3620: FNopm_Message (_('Error while exporting product list') + #13#10 + opm_SaveDialog_Export.FileName + #13#10 + E.Message, mtError, [mbOk], opmG_UISilent);
3621: END;
3622: END;
3623: SHAddToRecentDocs (SHARD_PATH, PCHAR (opm_SaveDialog_Export.FileName));
3624: END;
3625: END;
3626:
3627:
3628: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3629: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3630: procedure Topm_Form_Main.opm_PopMenuItem_PCopyAsTextClick(Sender: TObject);
3631: VAR
3632: ExportText : STRING;
3633: BEGIN
3634: PRopm_Create_ExportList (ExportText, opmG_CategoryList, opmG_ManufacturerList, FALSE);
3635: Clipboard.AsText := ExportText;
3636: END;
3637:
3638:
3639: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3640: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3641: procedure Topm_Form_Main.opm_PopMenuItem_PCopyAsPreClick(Sender: TObject);
3642: VAR
3643: ExportText : STRING;
3644: BEGIN
3645: PRopm_Create_ExportList (ExportText, opmG_CategoryList, opmG_ManufacturerList, TRUE);
3646: Clipboard.AsText := ExportText;
3647: END;
3648:
3649:
3650: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3651: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3652: procedure Topm_Form_Main.opm_PopMenuItem_PSelAllClick(Sender: TObject);
3653: begin
3654: opm_ListView_Main.SelectAll;
3655: end;
3656:
3657:
3658: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3659: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3660: FUNCTION Topm_Form_Main.FNopm_Create_ExchangeList (VAR ExchangeList : opmT_ExchangeList;
3661: IndexData, TargetData : STRING) : LONGINT;
3662: VAR
3663: CurItem : TListItem;
3664: CurProd : opmR_Product;
3665: ProdCount : LONGINT;
3666: BEGIN
3667: CurItem := opm_ListView_Main.Selected;
3668: ProdCount := 0;
3669: IF (CurItem <> NIL) THEN
3670: BEGIN
3671: opm_ListView_Main.Enabled := FALSE;
3672: WHILE (CurItem <> NIL) DO
3673: BEGIN
3674: opm_CurrentProdID := STRTOINT (TRIM (CurItem.SubItems.Strings[0]));
3675: CurProd := FNopm_GetProductByID (opm_CurrentProdID, opm_CurrentLang, opmG_ProductList);
3676: IF (IndexData = opmC_SyncField_ProductID) THEN
3677: ExchangeList[ProdCount].IndexString := INTTOSTR (CurProd.ID)
3678: ELSE
3679: ExchangeList[ProdCount].IndexString := CurProd.Model;
3680: IF (TargetData = opmC_SyncField_ProductQuantity) THEN
3681: ExchangeList[ProdCount].CurrentString := INTTOSTR (CurProd.Quantity)
3682: ELSE IF (TargetData = opmC_SyncField_ProductPrice) THEN
3683: ExchangeList[ProdCount].CurrentString := CURRTOSTR (CurProd.Price)
3684: ELSE IF (TargetData = opmC_SyncField_ProductImage) THEN
3685: ExchangeList[ProdCount].CurrentString := CurProd.ImageURL
3686: ELSE IF (TargetData = opmC_SyncField_ProductWeight) THEN
3687: ExchangeList[ProdCount].CurrentString := FLOATTOSTR (CurProd.Weight)
3688: ELSE IF (TargetData = opmC_SyncField_ProductStatus) THEN
3689: ExchangeList[ProdCount].CurrentString := INTTOSTR (CurProd.Available)
3690: ELSE ExchangeList[ProdCount].CurrentString := '';
3691: ExchangeList[ProdCount].ResultString := '';
3692: CurItem := opm_ListView_Main.GetNextItem (CurItem, sdAll, [isSelected]);
3693: INC (ProdCount);
3694: END;
3695: opm_ListView_Main.Enabled := TRUE;
3696: opm_Form_Main.FocusControl (opm_ListView_Main);
3697: END;
3698: FNopm_Create_ExchangeList := ProdCount;
3699: END;
3700:
3701:
3702: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3703: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3704: procedure Topm_Form_Main.opm_MenuItem_ExternalModulesClick (Sender: TObject);
3705: begin
3706: opm_PRSetValidModules (opm_MenuItem_ExternalModules, opm_ListView_Main.SelCount);
3707: end;
3708:
3709:
3710:
3711: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3712: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3713: procedure Topm_Form_Main.opm_TreeView_MainMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
3714: begin
3715: end;
3716:
3717:
3718:
3719:
3720: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3721: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3722: FUNCTION FNopm_Sort_ProductList (Item1, Item2: TListItem; Column: INTEGER) : INTEGER; STDCALL;
3723: BEGIN
3724: CASE Column OF
3725: 1, 6, 7, 8 :
3726: IF (opmG_PList_LastOrderType = FALSE) THEN
3727: FNopm_Sort_ProductList := ROUND ((STRTOFLOAT (Item1.SubItems[Column - 1]) - STRTOFLOAT (Item2.SubItems[Column - 1])))
3728: ELSE
3729: FNopm_Sort_ProductList := ROUND ((STRTOFLOAT (Item1.SubItems[Column - 1]) - STRTOFLOAT (Item2.SubItems[Column - 1])) * -1);
3730: 0 :
3731: IF (opmG_PList_LastOrderType = FALSE) THEN
3732: FNopm_Sort_ProductList := ROUND ((Item1.ImageIndex - Item2.ImageIndex))
3733: ELSE
3734: FNopm_Sort_ProductList := ROUND ((Item1.ImageIndex - Item2.ImageIndex) * -1);
3735: ELSE
3736: IF (opmG_PList_LastOrderType = FALSE) THEN
3737: FNopm_Sort_ProductList := AnsiCompareText (Item1.SubItems[Column - 1], Item2.SubItems[Column - 1])
3738: ELSE
3739: FNopm_Sort_ProductList := ((AnsiCompareText (Item1.SubItems[Column - 1], Item2.SubItems[Column - 1])) * -1);
3740: END;
3741: END;
3742:
3743:
3744: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3745: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3746: procedure Topm_Form_Main.opm_ListView_MainColumnClick(Sender: TObject; Column: TListColumn);
3747: begin
3748: IF (Column.Index >= 0) AND (Column.Index < 10) THEN
3749: BEGIN
3750: opm_ListView_Main.Column[opmG_PList_LastOrderColumn].ImageIndex := -1;
3751: IF (opmG_PList_LastOrderColumn = Column.Index) THEN
3752: opmG_PList_LastOrderType := NOT (opmG_PList_LastOrderType)
3753: ELSE
3754: opmG_PList_LastOrderType := FALSE;
3755: IF (opmG_PList_LastOrderType = TRUE) THEN
3756: Column.ImageIndex := 8
3757: ELSE
3758: Column.ImageIndex := 9;
3759: opmG_PList_LastOrderColumn := Column.Index;
3760: TListView (Sender).CustomSort (@FNopm_Sort_ProductList, Column.Index);
3761: END;
3762: end;
3763:
3764:
3765:
3766: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3767: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3768: procedure Topm_Form_Main.opm_PopMenuItem_PPrintClick(Sender: TObject);
3769: BEGIN
3770: opmG_Cur_PPrintEOF := FALSE;
3771: opmG_Cur_PPrintTitle := opmC_AppName1 + ' ' + opmC_AppName2 + ' (' + opmC_AppShortName + ') ' + opmC_Version + ' (build ' + opmG_ExeBuildVersion + ')';
3772: opmG_Cur_PPrintTitle2 := DATETIMETOSTR (NOW) + ' ' + opmG_DBHost + ' / ' + opmG_DBDatabase;
3773: TRY
3774: opm_frReport_ProdList.LoadFromFile (ExtractFilePath (Application.Exename) + opmC_DirReports + '/' + opmC_Report_ProdList1);
3775: IF (opmG_PRNDirectPrint > 0) THEN
3776: BEGIN
3777: opm_frReport_ProdList.PrepareReport;
3778: opm_frReport_ProdList.PrintPreparedReport('', 1);
3779: END
3780: ELSE opm_frReport_ProdList.ShowReport;
3781: EXCEPT
3782: ON E : Exception DO
3783: BEGIN
3784: FNopm_Message (_('Error while printing product list') + #13#10 + E.Message, mtError, [mbOk], opmG_UISilent);
3785: END;
3786: END;
3787: END;
3788:
3789:
3790: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3791: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3792: procedure Topm_Form_Main.opm_frReport_ProdListGetValue (const ParName: String; var ParValue: Variant);
3793: VAR
3794: CurCat : opmR_Category;
3795: CurMan : opmR_Manufacturer;
3796: CurDescR : opmR_Description;
3797: begin
3798: IF (ParName = 'RepTitle') THEN ParValue := opmG_Cur_PPrintTitle
3799: ELSE IF (ParName = 'RepSubtitle') THEN ParValue := opmG_Cur_PPrintTitle2
3800: ELSE IF (ParName = 'RepHeadID') THEN ParValue := _('Product ID')
3801: ELSE IF (ParName = 'RepHeadAvailable') THEN ParValue := _('Available')
3802: ELSE IF (ParName = 'RepHeadModel') THEN ParValue := _('Model')
3803: ELSE IF (ParName = 'RepHeadCategory') THEN ParValue := _('Category name')
3804: ELSE IF (ParName = 'RepHeadManufacturer') THEN ParValue := _('Manufacturer name')
3805: ELSE IF (ParName = 'RepHeadName') THEN ParValue := _('Product name')
3806: ELSE IF (ParName = 'RepHeadQuantity') THEN ParValue := _('Quantity')
3807: ELSE IF (ParName = 'RepHeadPrice') THEN ParValue := _('Price')
3808: ELSE IF (ParName = 'RepHeadSpecial') THEN ParValue := _('Special price')
3809: ELSE IF (ParName = 'RepHeadWeight') THEN ParValue := _('Weight')
3810: ELSE IF (ParName = 'RepHeadImage') THEN ParValue := _('URL')
3811: ELSE IF (ParName = 'RepHeadTax') THEN ParValue := _('Weight')
3812: ELSE IF (ParName = 'RepHeadAvailDate') THEN ParValue := _('Availability date')
3813: ELSE IF (ParName = 'RepHeadCreatDate') THEN ParValue := _('Creation date')
3814: ELSE IF (ParName = 'RepHeadChangeDate') THEN ParValue := _('Change date')
3815: ELSE IF (ParName = 'RepHeadDescription') THEN ParValue := _('Description')
3816: ELSE IF (ParName = 'RepHeadURL') THEN ParValue := _('URL')
3817: ELSE IF (ParName = 'RepHeadViewed') THEN ParValue := _('Times viewed')
3818: ELSE IF (ParName = 'ProdID') THEN ParValue := opmG_Cur_PPrintRecord.ID
3819: ELSE IF (ParName = 'ProdAvailable') THEN ParValue := FNopm_NumToYesNo (opmG_Cur_PPrintRecord.Available)
3820: ELSE IF (ParName = 'ProdModel') THEN ParValue := opmG_Cur_PPrintRecord.Model
3821: ELSE IF (ParName = 'ProdCategory') THEN
3822: BEGIN
3823: CurCat := FNopm_GetCategory (opmG_CategoryList, opmG_Cur_PPrintRecord.CategoryID, opmC_FindByID);
3824: ParValue := CurCat.Name;
3825: END
3826: ELSE IF (ParName = 'ProdManufacturer') THEN
3827: BEGIN
3828: CurMan := FNopm_GetManufacturer (opmG_ManufacturerList, opmG_Cur_PPrintRecord.ManufacturerID, opmC_FindByID);
3829: ParValue := CurMan.Name;
3830: END
3831: ELSE IF (ParName = 'ProdName') THEN ParValue := opmG_Cur_PPrintRecord.DisplayName
3832: ELSE IF (ParName = 'ProdQuantity') THEN ParValue := opmG_Cur_PPrintRecord.Quantity
3833: ELSE IF (ParName = 'ProdPrice') THEN ParValue := opmG_Cur_PPrintRecord.Price
3834: ELSE IF (ParName = 'ProdSpecial') THEN ParValue := opmG_Cur_PPrintRecord.Special
3835: ELSE IF (ParName = 'ProdWeight') THEN ParValue := opmG_Cur_PPrintRecord.Weight
3836: ELSE IF (ParName = 'ProdImage') THEN ParValue := opmG_Cur_PPrintRecord.ImageURL
3837: ELSE IF (ParName = 'ProdTax') THEN ParValue := opmG_Cur_PPrintRecord.Tax
3838: ELSE IF (ParName = 'ProdAvailDate') THEN ParValue := DATETIMETOSTR (opmG_Cur_PPrintRecord.AvailDate)
3839: ELSE IF (ParName = 'ProdCreatDate') THEN ParValue := DATETIMETOSTR (opmG_Cur_PPrintRecord.CreationDate)
3840: ELSE IF (ParName = 'ProdChangeDate') THEN ParValue := DATETIMETOSTR (opmG_Cur_PPrintRecord.ChangeDate)
3841: ELSE IF (ParName = 'ProdDescription') THEN
3842: BEGIN
3843: CurDescR := FNopm_GetDescriptionByID (opmG_Cur_PPrintRecord.ID, opm_CurrentLang, opmG_DescriptionList);
3844: ParValue := CurDescR.Description;
3845: END
3846: ELSE IF (ParName = 'ProdURL') THEN
3847: BEGIN
3848: CurDescR := FNopm_GetDescriptionByID (opmG_Cur_PPrintRecord.ID, opm_CurrentLang, opmG_DescriptionList);
3849: ParValue := CurDescR.URL;
3850: END
3851: ELSE IF (ParName = 'ProdViewed') THEN
3852: BEGIN
3853: CurDescR := FNopm_GetDescriptionByID (opmG_Cur_PPrintRecord.ID, opm_CurrentLang, opmG_DescriptionList);
3854: ParValue := CurDescR.Viewed;
3855: END;
3856: end;
3857:
3858:
3859: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3860: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3861: procedure Topm_Form_Main.opm_frUserDataset_ProdListCheckEOF(Sender: TObject; var Eof: Boolean);
3862: begin
3863: EOF := opmG_Cur_PPrintEOF;
3864: end;
3865:
3866:
3867:
3868: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3869: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3870: procedure Topm_Form_Main.opm_frUserDataset_ProdListFirst(Sender: TObject);
3871: BEGIN
3872: opmG_Cur_PPrintEOF := FALSE;
3873: opmG_Cur_PrintListItem := opm_ListView_Main.Selected;
3874: IF (opmG_Cur_PrintListItem <> NIL) THEN
3875: BEGIN
3876: opmG_Cur_PPrintID := STRTOINT (TRIM (opmG_Cur_PrintListItem.SubItems.Strings[0]));
3877: opmG_Cur_PPrintRecord := FNopm_GetProductByID (opmG_Cur_PPrintID, opm_CurrentLang, opmG_ProductList);
3878: END
3879: ELSE opmG_Cur_PPrintEOF := TRUE;
3880: end;
3881:
3882: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3883: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3884: procedure Topm_Form_Main.opm_frUserDataset_ProdListNext(Sender: TObject);
3885: begin
3886: opmG_Cur_PrintListItem := opm_ListView_Main.GetNextItem (opmG_Cur_PrintListItem, sdAll, [isSelected]);
3887: IF (opmG_Cur_PrintListItem <> NIL) THEN
3888: BEGIN
3889: opmG_Cur_PPrintID := STRTOINT (TRIM (opmG_Cur_PrintListItem.SubItems.Strings[0]));
3890: opmG_Cur_PPrintRecord := FNopm_GetProductByID (opmG_Cur_PPrintID, opm_CurrentLang, opmG_ProductList);
3891: END
3892: ELSE opmG_Cur_PPrintEOF := TRUE;
3893: end;
3894:
3895:
3896: procedure Topm_Form_Main.FormShow(Sender: TObject);
3897: begin
3898: {$IFDEF OSCPMDEBUG}
3899: FNopm_Message (_('THIS IS A SPECIAL DEBUG-VERSION. Use it only to report crashes and fatal errors. DO NOT DISTRIBUTE. The full open-source version can be found in the website.'), mtInformation, [mbOk], opmG_UISilent);
3900: {$ENDIF}
3901: end;
3902:
3903:
3904:
3905: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3906: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3907: procedure Topm_Form_Main.opm_PopMenuItem_CatDeleteClick (Sender: TObject);
3908: begin
3909: IF ((opm_CurrentCategory > 0) AND (opm_CurrentCatRecord.ID < opmC_SC_BaseID)) THEN
3910: BEGIN
3911: PRopm_DeleteCategory (opm_CurrentCategory);
3912: END;
3913: end;
3914:
3915:
3916:
3917: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3918: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3919: procedure Topm_Form_Main.opm_PopMenuItem_CatAddClick(Sender: TObject);
3920: VAR
3921: CatParent : LONGINT;
3922: begin
3923: IF ((opm_CurrentCategory >= 0) AND (opm_CurrentCatRecord.ID < opmC_SC_BaseID)) THEN
3924: BEGIN
3925: CatParent := opm_CurrentCatRecord.ID;
3926: opm_Form_AskCat.AC_Title := _('Add new category');
3927: opm_Form_AskCat.AC_Directions := _('Enter the name of the new category and its translations.');
3928: opm_Form_AskCat.AC_MaxLen := opmC_CatName_MaxLen;
3929: opm_Form_AskCat.AC_ClearCats := TRUE;
3930: IF (opm_Form_AskCat.ShowModal = mrOk) THEN PRopm_AddCategory (opm_Form_AskCat.AC_CategoryData, opm_TotalLanguages, CatParent);
3931: END;
3932: end;
3933:
3934:
3935: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3936: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3937: procedure Topm_Form_Main.opm_PopMenuItem_CatRenameClick (Sender: TObject);
3938: begin
3939: IF ((opm_CurrentCategory > 0) AND (opm_CurrentCatRecord.ID < opmC_SC_BaseID)) THEN
3940: BEGIN
3941: opm_Form_AskCat.AC_Title := _('Rename category') + ' ' + opm_CurrentCatRecord.Name;
3942: opm_Form_AskCat.AC_Directions := _('Enter the new name of the category and its translations.');
3943: opm_Form_AskCat.AC_MaxLen := opmC_CatName_MaxLen;
3944: opm_Form_AskCat.AC_ClearCats := FALSE;
3945: PRopm_GetCategory_Data (opm_CurrentCategory, opm_Form_AskCat.AC_CategoryData);
3946: IF (opm_Form_AskCat.ShowModal = mrOk) THEN PRopm_UpdateCatName (opm_Form_AskCat.AC_CategoryData, opm_TotalLanguages);
3947: END;
3948: end;
3949:
3950:
3951:
3952: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3953: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3954: PROCEDURE Topm_Form_Main.PRopm_UpdateCatName (CatData : opmT_SingleCatList; TotalCats : LONGINT);
3955: VAR
3956: CurCat : LONGINT;
3957: UStrCatName : STRING;
3958: Progress, ProgStep : LONGINT;
3959: BEGIN
3960: Progress := 0;
3961: ProgStep := ROUND (100 / TotalCats);
3962: IF (opmG_UIConfirmMods = 0) OR ((opmG_UIConfirmMods > 0) AND (FNopm_Message (_('Do you really want to update this category name?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
3963: BEGIN
3964: FOR CurCat := 0 TO (TotalCats - 1) DO
3965: BEGIN
3966: IF ((CatData[CurCat].ID > 0) AND (CatData[CurCat].Parent >= 0) AND
3967: (CatData[CurCat].Name <> '') AND (CatData[CurCat].LanguageID >= 0)) THEN
3968: BEGIN
3969: PRopm_Update_StatusBar (opmC_ConnStatIgnore, Progress, opmC_ProgressNone, _('Updating category record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
3970: UStrCatName := 'update ' + opmG_DBTable_CategoriesDescription + ' set categories_name="' + CatData[CurCat].Name + '"'
3971: + ' where categories_id=' + INTTOSTR (CatData[CurCat].ID) + ' and language_id=' + INTTOSTR (CatData[CurCat].LanguageID);
3972: FNopm_ExecQuery (UStrCatName, opmC_SQLUpdate);
3973: END;
3974: INC (Progress, ProgStep);
3975: END;
3976: PRopm_LoadCategoryList (opmG_CategoryList, opmG_CategoryBoxList);
3977: PRopm_RenderCategoryDisplay (opmG_CategoryList, opm_TreeView_Main, opm_CurrentCategory);
3978: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
3979: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Category record updated.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
3980: END;
3981: END;
3982:
3983:
3984: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3985: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
3986: PROCEDURE Topm_Form_Main.PRopm_AddCategory (CatData : opmT_SingleCatList; TotalCats : LONGINT; ParentCat : LONGINT);
3987: VAR
3988: CurCat : LONGINT;
3989: IStrCat, IStrCatDesc, IStrCheckID : STRING;
3990: Progress, ProgStep : LONGINT;
3991: LastID : LONGINT;
3992: BEGIN
3993: Progress := 10;
3994: ProgStep := ROUND (90 / TotalCats);
3995: LastID := 0;
3996: IF (ParentCat >= 0) THEN
3997: BEGIN
3998: PRopm_Update_StatusBar (opmC_ConnStatIgnore, Progress, opmC_ProgressNone, _('Adding category record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
3999: IStrCat := 'insert into ' + opmG_DBTable_Categories + ' (parent_id, date_added) values (' + INTTOSTR (ParentCat) + ', now())';
4000: IStrCheckID := 'select categories_id from ' + opmG_DBTable_Categories + ' where categories_id=last_insert_id()';
4001: FNopm_ExecQuery (IStrCat, opmC_SQLInsert);
4002: IF (FNopm_ExecQuery (IStrCheckID, opmC_SQLSelect) > 0) THEN
4003: IF (opmG_DBQuery.Active = TRUE) THEN
4004: BEGIN
4005: opmG_DBQuery.First;
4006: LastID := opmG_DBQuery.Fields[0].AsInteger;
4007: END;
4008: END;
4009: IF (LastID > 0) THEN
4010: FOR CurCat := 0 TO (TotalCats - 1) DO
4011: BEGIN
4012: IF (CatData[CurCat].LanguageID >= 0) THEN
4013: BEGIN
4014: PRopm_Update_StatusBar (opmC_ConnStatIgnore, Progress, opmC_ProgressNone, _('Adding category record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4015: IStrCatDesc := 'insert into ' + opmG_DBTable_CategoriesDescription + ' (categories_id, language_id, categories_name)'
4016: + ' values (' + INTTOSTR (LastID) + ', ' + INTTOSTR (CatData[CurCat].LanguageID) + ', "' + CatData[CurCat].Name + '")';
4017: FNopm_ExecQuery (IStrCatDesc, opmC_SQLInsert);
4018: END;
4019: INC (Progress, ProgStep);
4020: END;
4021: PRopm_LoadCategoryList (opmG_CategoryList, opmG_CategoryBoxList);
4022: PRopm_RenderCategoryDisplay (opmG_CategoryList, opm_TreeView_Main, opm_CurrentCategory);
4023: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
4024: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Category records added.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4025: END;
4026:
4027:
4028:
4029: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4030: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4031: PROCEDURE Topm_Form_Main.PRopm_DeleteCategory (CatID : LONGINT);
4032: VAR
4033: DStrCat, UStrCat, DStrCatDesc, UProdCats, SParentCat : STRING;
4034: ParentCat : LONGINT;
4035: BEGIN
4036: ParentCat := opm_CurrentCategory;
4037: IF (CatID > 0) THEN
4038: BEGIN
4039: IF (opmG_UIConfirmDels = 0) OR ((opmG_UIConfirmDels > 0) AND (FNopm_Message (_('Do you really want to delete this category?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
4040: BEGIN
4041: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 20, opmC_ProgressIgnore, _('Deleting category...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4042: ParentCat := 0;
4043: SParentCat := 'select parent_id from ' + opmG_DBTable_Categories + ' where categories_id=' + INTTOSTR (CatID);
4044: IF (FNopm_ExecQuery (SParentCat, opmC_SQLSelect) > 0) THEN
4045: IF (opmG_DBQuery.Active = TRUE) THEN
4046: BEGIN
4047: opmG_DBQuery.First;
4048: ParentCat := opmG_DBQuery.Fields[0].AsInteger;
4049: IF (ParentCat < 0) THEN ParentCat := 0;
4050: END;
4051: DStrCat := 'delete from ' + opmG_DBTable_Categories + ' where categories_id=' + INTTOSTR (CatID);
4052: UStrCat := 'update ' + opmG_DBTable_Categories + ' set parent_id=' + INTTOSTR (ParentCat) + ' where parent_id=' + INTTOSTR (CatID);
4053: DStrCatDesc := 'delete from ' + opmG_DBTable_CategoriesDescription + ' where categories_id=' + INTTOSTR (CatID);
4054: UProdCats := 'update ' + opmG_DBTable_ProductsToCategories + ' set categories_id=' + INTTOSTR (ParentCat) + ' where categories_id=' + INTTOSTR (CatID);
4055: IF (FNopm_ExecQuery (DStrCat, opmC_SQLUpdate) >= 0) THEN
4056: BEGIN
4057: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 40, opmC_ProgressIgnore, _('Moving categories from category...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4058: FNopm_ExecQuery (UStrCat, opmC_SQLUpdate);
4059: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 60, opmC_ProgressIgnore, _('Deleting category record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4060: FNopm_ExecQuery (DStrCatDesc, opmC_SQLUpdate);
4061: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 80, opmC_ProgressIgnore, _('Deleting category descriptions...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4062: FNopm_ExecQuery (UProdCats, opmC_SQLUpdate);
4063: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 100, opmC_ProgressIgnore, _('Moving products from category...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4064: END;
4065: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 0, opmC_ProgressIgnore, _('Category deleted.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4066: END;
4067: END;
4068: PRopm_LoadCategoryList (opmG_CategoryList, opmG_CategoryBoxList);
4069: PRopm_RenderCategoryDisplay (opmG_CategoryList, opm_TreeView_Main, ParentCat);
4070: PRopm_ClearProductList (opm_ListView_Main);
4071: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
4072: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Category records added.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4073: END;
4074:
4075:
4076:
4077: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4078: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4079: procedure Topm_Form_Main.opm_ListView_MainKeyDown (Sender: TObject; var Key: Word; Shift: TShiftState);
4080: begin
4081: CASE Key OF
4082: VK_RETURN : opm_ListView_MainDblClick (Sender);
4083: VK_DELETE : opm_PopMenuItem_PDeleteClick (Sender);
4084: VK_INSERT : opm_PopMenuItem_PAddClick (Sender);
4085: END;
4086:
4087: end;
4088:
4089:
4090: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4091: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4092: PROCEDURE Topm_Form_Main.QuickSearch (QSString : STRING);
4093: BEGIN
4094: QSString := TRIM (QSString);
4095: IF (QSString <> '') THEN
4096: BEGIN
4097: opm_Search_PCategory := 0;
4098: opm_Search_PManufacturer := 0;
4099: opm_Search_PModel := '';
4100: opm_Search_PName := '';
4101: opm_Search_PDesc := '';
4102: opm_Search_PSPrice := 0;
4103: opm_Search_PImagURL := 0;
4104: opm_Search_PAvailable := 0;
4105: PRopm_SearchProducts (opm_Search_PCategory, opm_Search_PManufacturer, opm_Search_PModel, opm_Search_PName, opm_Search_PDesc, opm_Search_PSPrice, opm_Search_PImagURL, opm_Search_PAvailable, opmG_ProductList, opmG_DescriptionList, QSString);
4106: PRopm_RenderProductDisplay (opmG_CategoryList, opmG_ManufacturerList, opmG_ProductList, opm_ListView_Main, opm_CurrentProdID);
4107: PRopm_Valid_ProdOps (opm_WeAreConnected, opm_ListView_Main.Selected, opm_ListView_Main.SelCount, NIL);
4108: END;
4109: END;
4110:
4111:
4112: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4113: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4114: procedure Topm_Form_Main.opm_SpeedButton_QuickSearchClick(Sender: TObject);
4115: BEGIN
4116: QuickSearch (opm_Edit_QuickSearch.Text);
4117: END;
4118:
4119:
4120: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4121: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4122: procedure Topm_Form_Main.opm_Edit_QuickSearchKeyPress(Sender: TObject; var Key: Char);
4123: BEGIN
4124: IF (ORD (Key) = VK_RETURN) THEN QuickSearch (opm_Edit_QuickSearch.Text);
4125: END;
4126:
4127:
4128:
4129: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4130: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4131: procedure Topm_Form_Main.opm_MenuItem_CheckUpdatesClick(Sender: TObject);
4132: VAR
4133: ResStr : STRING;
4134: RemoteVer, RemoteURL : STRING;
4135: CompRes : LONGINT;
4136: BEGIN
4137: RemoteVer := '';
4138: PRopm_Prepare_HTTPClient (NIL, NIL, ((opmG_UseProxy > 0) AND (opmG_ProxyApply IN [0, 2])));
4139: Screen.Cursor := opmC_Wait_Mouse;
4140: IF (FNopm_Send_SimpleCommand (opmC_CheckUpdates_URL, 'check', opmC_Version + '.' + opmG_ExeBuildVersion, ResStr) = TRUE) THEN
4141: BEGIN
4142: Screen.Cursor := opmC_Normal_Mouse;
4143: RemoteVer := TRIM (COPY (ResStr, (POS (opmC_WebScriptOKCode, ResStr) + LENGTH (opmC_WebScriptOKCode)), (POS (' http', ResStr) - LENGTH (opmC_WebScriptOKCode))));
4144: RemoteURL := TRIM (COPY (ResStr, POS (' http', ResStr), LENGTH (ResStr)));
4145: CompRes := FNopm_CompareVersions (opmC_Version + '.' + opmG_ExeBuildVersion, RemoteVer);
4146: IF (CompRes = opmC_VersionIsOlder) THEN
4147: BEGIN
4148: IF (FNopm_Message (_('There is a new version available. Do you want to download it?') + ' [' + RemoteVer + ']', mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes) THEN
4149: ShellExecute (handle,'Open', PCHAR (RemoteURL), NIL, NIL, SW_NORMAL);
4150: END
4151: ELSE
4152: FNopm_Message (_('There is not a new version available.'), mtInformation, [mbOk], opmG_UISilent);
4153: END
4154: ELSE
4155: BEGIN
4156: Screen.Cursor := opmC_Normal_Mouse;
4157: FNopm_Message (_('Cannot contact the software website. Check your network connection and proxy settings.'), mtWarning, [mbOk], opmG_UISilent);
4158: END;
4159: END;
4160:
4161:
4162: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4163: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4164: procedure Topm_Form_Main.opm_MenuItem_ManAddClick(Sender: TObject);
4165: VAR
4166: ManName : STRING;
4167: LastID : LONGINT;
4168: IStrMans, IStrCheckID, IStrManInfo : STRING;
4169: CurLang : LONGINT;
4170: BEGIN
4171: opm_Form_AskUser.AU_Title := _('Add new manufacturer');
4172: opm_Form_AskUser.AU_DataText := '';
4173: opm_Form_AskUser.AU_Directions := _('Type the name of the new manufacturer (avoid using HTML tags):');
4174: opm_Form_AskUser.AU_TextOrList := TRUE;
4175: opm_Form_AskUser.AU_PassChar := #0;
4176: opm_Form_AskUser.AU_MaxLen := opmC_ManName_MaxLen;
4177: IF (opm_Form_AskUser.ShowModal = mrOk) THEN
4178: BEGIN
4179: ManName := FNopm_CleanString (opm_Form_AskUser.AU_DataText);
4180: IF (ManName = '') THEN ManName := opmC_Unamed_Man;
4181: LastID := 0;
4182: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Adding manufacturer record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4183: IStrMans := 'insert into ' + opmG_DBTable_Manufacturers + ' (manufacturers_name, date_added, last_modified)' + ''
4184: + ' values ("' + FNopm_CleanSQLString (ManName, FALSE) + '", now(), now())';
4185: IStrCheckID := 'select manufacturers_id from ' + opmG_DBTable_Manufacturers + ' where manufacturers_id=last_insert_id()';
4186: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 50, opmC_ProgressNone, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4187: FNopm_ExecQuery (IStrMans, opmC_SQLInsert);
4188: IF (FNopm_ExecQuery (IStrCheckID, opmC_SQLSelect) > 0) THEN
4189: IF (opmG_DBQuery.Active = TRUE) THEN
4190: BEGIN
4191: opmG_DBQuery.First;
4192: LastID := opmG_DBQuery.Fields[0].AsInteger;
4193: END;
4194: IF (LastID > 0) THEN
4195: BEGIN
4196: FOR CurLang := 0 TO (opm_TotalLanguages - 1) DO
4197: BEGIN
4198: IStrManInfo := 'insert into ' + opmG_DBTable_ManufacturersInfo + ' (manufacturers_id, languages_id, manufacturers_url, url_clicked)' + ''
4199: + ' values (' + INTTOSTR (LastID) + ', ' + INTTOSTR (opmG_LanguageList[CurLang].ID) + ', "", 0)';
4200: FNopm_ExecQuery (IStrManInfo, opmC_SQLInsert);
4201: PRopm_Update_StatusBar (opmC_ConnStatIgnore, (CurLang * ROUND (100 / opmC_Max_Languages_PerList)), opmC_ProgressNone, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4202: END;
4203: END;
4204: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 100, opmC_ProgressNone, _('Manufacturer record added.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4205: PRopm_LoadManufacturerList (opmG_ManufacturerList, opmG_ManufacturerBoxList);
4206: PRopm_Reload_ProductList (opm_WeAreSearching);
4207: END;
4208: END;
4209:
4210:
4211:
4212:
4213: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4214: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4215: procedure Topm_Form_Main.opm_MenuItem_ManRenameClick(Sender: TObject);
4216: VAR
4217: CurMan : opmR_Manufacturer;
4218: ManName : STRING;
4219: UStrMans : STRING;
4220: BEGIN
4221: opm_Form_AskUser.AU_DataList := opmG_ManufacturerBoxList;
4222: opm_Form_AskUser.AU_Title := _('Rename manufacturer');
4223: opm_Form_AskUser.AU_ListItem := 0;
4224: opm_Form_AskUser.AU_Directions := _('Select the manufacturer to rename:');
4225: opm_Form_AskUser.AU_TextOrList := FALSE;
4226: IF (opm_Form_AskUser.ShowModal = mrOk) THEN
4227: BEGIN
4228: CurMan := FNopm_GetManufacturer (opmG_ManufacturerList, opm_Form_AskUser.AU_ListItem, opmC_FindByIndex);
4229: IF (CurMan.ID > 0) THEN
4230: BEGIN
4231: opm_Form_AskUser.AU_Title := _('Rename manufacturer');
4232: opm_Form_AskUser.AU_DataText := CurMan.Name;
4233: opm_Form_AskUser.AU_Directions := _('Edit the name of the manufacturer (avoid using HTML tags):');
4234: opm_Form_AskUser.AU_TextOrList := TRUE;
4235: opm_Form_AskUser.AU_PassChar := #0;
4236: opm_Form_AskUser.AU_MaxLen := opmC_ManName_MaxLen;
4237: IF (opm_Form_AskUser.ShowModal = mrOk) THEN
4238: BEGIN
4239: IF (opmG_UIConfirmMods = 0) OR ((opmG_UIConfirmMods > 0) AND (FNopm_Message (_('Do you really want to update this manufacturer name?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
4240: BEGIN
4241: ManName := FNopm_CleanString (opm_Form_AskUser.AU_DataText);
4242: IF (ManName = '') THEN ManName := opmC_Unamed_Man;
4243: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Adding manufacturer record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4244: UStrMans := 'update ' + opmG_DBTable_Manufacturers + ' set manufacturers_name="' + FNopm_CleanSQLString (ManName, FALSE) + '" where manufacturers_id=' + INTTOSTR (CurMan.ID);
4245: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 50, opmC_ProgressNone, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4246: FNopm_ExecQuery (UStrMans, opmC_SQLUpdate);
4247: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 100, opmC_ProgressNone, _('Manufacturer record deleted.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4248: PRopm_LoadManufacturerList (opmG_ManufacturerList, opmG_ManufacturerBoxList);
4249: PRopm_Reload_ProductList (opm_WeAreSearching);
4250: END;
4251: END;
4252: END
4253: ELSE FNopm_Message (_('You must select a valid manufacturer.'), mtWarning, [mbOk], opmG_UISilent);
4254: END;
4255: END;
4256:
4257:
4258:
4259: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4260: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4261: procedure Topm_Form_Main.opm_MenuItem_ManDeleteClick(Sender: TObject);
4262: VAR
4263: CurMan : opmR_Manufacturer;
4264: DStrMans, DStrMansInfo, UStrProdMan : STRING;
4265: BEGIN
4266: opm_Form_AskUser.AU_DataList := opmG_ManufacturerBoxList;
4267: opm_Form_AskUser.AU_Title := _('Delete manufacturer');
4268: opm_Form_AskUser.AU_ListItem := 0;
4269: opm_Form_AskUser.AU_Directions := _('Select the manufacturer to delete (all products by this manufacturer will be reassigned to a null manufacturer):');
4270: opm_Form_AskUser.AU_TextOrList := FALSE;
4271: IF (opm_Form_AskUser.ShowModal = mrOk) THEN
4272: BEGIN
4273: CurMan := FNopm_GetManufacturer (opmG_ManufacturerList, opm_Form_AskUser.AU_ListItem, opmC_FindByIndex);
4274: IF (CurMan.ID > 0) THEN
4275: BEGIN
4276: IF (opmG_UIConfirmDels = 0) OR ((opmG_UIConfirmDels > 0) AND (FNopm_Message (_('Do you really want to delete this manufacturer?'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes)) THEN
4277: BEGIN
4278: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Adding manufacturer record...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4279: DStrMans := 'delete from ' + opmG_DBTable_Manufacturers + ' where manufacturers_id=' + INTTOSTR (CurMan.ID);
4280: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 25, opmC_ProgressNone, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4281: FNopm_ExecQuery (DStrMans, opmC_SQLInsert);
4282: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 50, opmC_ProgressNone, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4283: DStrMansInfo := 'delete from ' + opmG_DBTable_ManufacturersInfo + ' where manufacturers_id=' + INTTOSTR (CurMan.ID);
4284: FNopm_ExecQuery (DStrMansInfo, opmC_SQLInsert);
4285: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 75, opmC_ProgressNone, '', opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4286: UStrProdMan := 'update ' + opmG_DBTable_Products + ' set manufacturers_id=0 where manufacturers_id=' + INTTOSTR (CurMan.ID);
4287: FNopm_ExecQuery (UStrProdMan, opmC_SQLUpdate);
4288: PRopm_Update_StatusBar (opmC_ConnStatIgnore, 100, opmC_ProgressNone, _('Manufacturer record deleted.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4289: PRopm_LoadManufacturerList (opmG_ManufacturerList, opmG_ManufacturerBoxList);
4290: PRopm_Reload_ProductList (opm_WeAreSearching);
4291: END;
4292: END
4293: ELSE FNopm_Message (_('You must select a valid manufacturer.'), mtWarning, [mbOk], opmG_UISilent);
4294: END;
4295: END;
4296:
4297:
4298:
4299: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4300: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
4301: procedure Topm_Form_Main.opm_MenuItem_BackupClick(Sender: TObject);
4302: VAR
4303: RecFileName : STRING;
4304: ResStr : STRING;
4305: BEGIN
4306: IF (FNopm_Message (_('Do you really want to download a database backup of the store?') + #13#10 + _('This operation may take a few minutes.'), mtConfirmation, [mbYes, mbNo], opmG_UISilent) = mrYes) THEN
4307: BEGIN
4308: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Getting database backup...'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4309: PRopm_Prepare_HTTPClient (opm_ProgressBar_Main, NIL, ((opmG_UseProxy > 0) AND (opmG_ProxyApply IN [0, 1])));
4310: IF (FNopm_Send_Command (opmG_WBUploadURL, 'noop', '', ResStr)) THEN
4311: BEGIN
4312: Screen.Cursor := opmC_Wait_Mouse;
4313: PRopm_Prepare_HTTPClient (NIL, NIL, ((opmG_UseProxy > 0) AND (opmG_ProxyApply IN [0, 1])));
4314: RecFileName := FNopm_Receive_File (opmG_WBUploadURL, 'backup', opmG_TMPPath + opmC_TmpBak_Filename);
4315: IF (RecFileName <> '') THEN
4316: BEGIN
4317: opm_SaveDialog_Export.DefaultExt := opmC_Def_BackupExt;
4318: opm_SaveDialog_Export.FileName := RecFileName;
4319: opm_SaveDialog_Export.Filter := _('Backup files') + ' (' + opmC_Def_BackupFilter + ')|' + opmC_Def_BackupFilter + '|' + _('All files (*.*)');
4320: opm_SaveDialog_Export.Title := _('Saving database backup...');
4321: IF (opm_SaveDialog_Export.Execute = TRUE) THEN
4322: BEGIN
4323: IF (MoveFile (PCHAR (opmG_TMPPath + opmC_TmpBak_Filename), PCHAR (opm_SaveDialog_Export.FileName)) = TRUE) THEN
4324: SHAddToRecentDocs (SHARD_PATH, PCHAR (opm_SaveDialog_Export.FileName))
4325: ELSE
4326: BEGIN
4327: Screen.Cursor := opmC_Normal_Mouse;
4328: FNopm_Message ('Error while downloading the database backup file.', mtError, [mbOk], opmG_UISilent);
4329: END;
4330: END;
4331: END
4332: ELSE
4333: BEGIN
4334: Screen.Cursor := opmC_Normal_Mouse;
4335: FNopm_Message ('Error while downloading the database backup file.', mtError, [mbOk], opmG_UISilent);
4336: END;
4337: Screen.Cursor := opmC_Normal_Mouse;
4338: END;
4339: PRopm_Update_StatusBar (opmC_ConnStatIgnore, opmC_ProgressNone, opmC_ProgressNone, _('Got database backup.'), opmC_PTotalIgnore, opm_CurrentCurrency.Code);
4340: END;
4341: end;
4342:
4343:
4344: END.
4345:
4346:
4347: