Source code of file oscpmwin_v0.1.1.652/runmod.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 runmod;
0023:
0024: interface
0025:
0026: uses
0027: Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
0028: Dialogs, StdCtrls, Buttons, ExtCtrls, ComCtrls, modules, Menus;
0029:
0030: CONST
0031: OPM_AUTOSTARTMOD = WM_USER + 1235;
0032:
0033: type
0034: Topm_Form_Runmod = class(TForm)
0035: opm_GroupBox_RunmodMain: TGroupBox;
0036: opm_BitBtn_RunmodCancel: TBitBtn;
0037: opm_ProgressBar_Runmod: TProgressBar;
0038: opm_Label_RunmodStatus: TLabel;
0039: opm_GroupBox_RunmodDetails: TGroupBox;
0040: opm_Memo_RunmodDetails: TMemo;
0041: opm_GroupBox_RunmodConfirm: TGroupBox;
0042: opm_ListView_RunmodConfirm: TListView;
0043: opm_BitBtn_RunmodConfirm: TBitBtn;
0044: opm_PopupMenu_Runmod: TPopupMenu;
0045: opm_PopMenuItem_RunmodCopy: TMenuItem;
0046: opm_PopMenuItem_RunmodCopyDiff: TMenuItem;
0047: opm_PopMenuItem_RunmodCopyEqual: TMenuItem;
0048: opm_PopMenuItem_RunmodCopyUnknown: TMenuItem;
0049: opm_PopMenuItem_RunmodCopyRestricted: TMenuItem;
0050: procedure FormShow(Sender: TObject);
0051: procedure FormClose(Sender: TObject; var Action: TCloseAction);
0052: procedure FormCreate(Sender: TObject);
0053: procedure opm_BitBtn_RunmodConfirmClick(Sender: TObject);
0054: procedure opm_PopMenuItem_RunmodCopyClick(Sender: TObject);
0055: procedure opm_PopMenuItem_RunmodCopyDiffClick(Sender: TObject);
0056: procedure opm_PopMenuItem_RunmodCopyEqualClick(Sender: TObject);
0057: procedure opm_PopMenuItem_RunmodCopyUnknownClick(Sender: TObject);
0058: procedure opm_ListView_RunmodConfirmColumnClick(Sender: TObject;
0059: Column: TListColumn);
0060: procedure opm_PopMenuItem_RunmodCopyRestrictedClick(Sender: TObject);
0061: private
0062: PROCEDURE PRopm_Create_ConfirmExportList (VAR ExportString : STRING; VAR ExportList : opmT_ExchangeList; SelectType : LONGINT);
0063: public
0064: PROCEDURE AutoStart (VAR AutoStartMsg: TMessage); MESSAGE OPM_AUTOSTARTMOD;
0065: FUNCTION opm_FNFeedModule : BOOLEAN;
0066: PROCEDURE PRopm_RenderConfirmDisplay (VAR SyncList : opmT_ExchangeList; VAR ListControl : TListView);
0067: PROCEDURE PRopm_CleanExchangeList (VAR SyncList : opmT_ExchangeList);
0068: end;
0069:
0070: var
0071: opm_Form_Runmod : Topm_Form_Runmod;
0072: opm_Runmod_CanClose : BOOLEAN;
0073: opm_Runmod_CanSync : BOOLEAN;
0074: opm_Runmod_Stat : STRING;
0075: opm_Runmod_LastOrderColumn : LONGINT;
0076: opm_Runmod_LastOrderType : BOOLEAN;
0077:
0078:
0079: FUNCTION FNopm_Sort_ExchangeList (Item1, Item2: TListItem; Column: INTEGER) : INTEGER; STDCALL;
0080:
0081:
0082: implementation
0083:
0084: Uses gnugettext, main, oscpmdata, balloons, dataman, clipbrd, network;
0085:
0086: {$R *.dfm}
0087:
0088:
0089:
0090:
0091: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0092: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0093: FUNCTION Topm_Form_Runmod.opm_FNFeedModule : BOOLEAN;
0094: VAR
0095: ExcCount : LONGINT;
0096: QueryData, RespData : STRING;
0097: RespType : LONGINT;
0098: BEGIN
0099: opm_FNFeedModule := TRUE;
0100: opm_ProgressBar_Runmod.Min := 0;
0101: opm_ProgressBar_Runmod.Max := (opmG_TotalExchangeItems - 1);
0102: opm_ProgressBar_Runmod.Step := ROUND (opmG_TotalExchangeItems / 20);
0103: opm_ProgressBar_Runmod.Position := 0;
0104: FOR ExcCount := 0 TO (opmG_TotalExchangeItems - 1) DO
0105: BEGIN
0106: QueryData := opmG_ExchangeList[ExcCount].IndexString;
0107: REPEAT
0108: RespType := opm_FNQueryMod (QueryData, RespData);
0109: CASE RespType OF
0110: opmC_ModRet_Null :
0111: BEGIN
0112: opm_FNFeedModule := FALSE;
0113: BREAK;
0114: END;
0115: opmC_ModRet_Stat : opm_Runmod_Stat := opm_Runmod_Stat + #13#10 + RespData;
0116: opmC_ModRet_Data :
0117: BEGIN
0118: IF ((RespData = opmC_ModNACode) OR (RespData = opmC_ModErrorCode)) THEN
0119: opmG_ExchangeList[ExcCount].ResultString := ''
0120: ELSE
0121: opmG_ExchangeList[ExcCount].ResultString := RespData;
0122: END;
0123: END;
0124: QueryData := '';
0125: UNTIL (RespType <> opmC_ModRet_Stat);
0126: opm_ProgressBar_Runmod.Position := ExcCount;
0127: END;
0128: opm_Runmod_Stat := opm_Runmod_Stat + #13#10 + opm_PRAskStatsMod;
0129: END;
0130:
0131:
0132:
0133: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0134: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0135: PROCEDURE Topm_Form_Runmod.AutoStart (VAR AutoStartMsg: TMessage);
0136: VAR
0137: IsConnected : BOOLEAN;
0138: ConnTries : LONGINT;
0139: StartupTime : REAL;
0140: BEGIN
0141: IsConnected := FALSE;
0142: opm_Runmod_CanSync := TRUE;
0143: opm_Form_Runmod.Left := (opm_Form_Main.Left + 50);
0144: opm_Form_Runmod.Top := (opm_Form_Main.Top + 50);
0145: Application.ProcessMessages;
0146: opm_Label_RunmodStatus.Caption := _('Connecting to module...');
0147: FOR ConnTries := 1 TO opmG_ModConnRetries DO
0148: BEGIN
0149: opm_Label_RunmodStatus.Caption := _('Connecting to module...') + ' ' + INTTOSTR (ConnTries) + '/' + INTTOSTR (opmG_ModConnRetries);
0150: StartupTime := GetTickCount;
0151: REPEAT
0152: Application.ProcessMessages;
0153: UNTIL ((GetTickCount - StartupTime) > opmG_ModConnWait);
0154: IsConnected := opm_FNConnectMod (opmC_Localhost, opm_CurrentModuleRecord.Port);
0155: IF (IsConnected = TRUE) THEN BREAK;
0156: END;
0157: IF (IsConnected = TRUE) THEN
0158: BEGIN
0159: opm_Label_RunmodStatus.Caption := _('Exchanging with module...');
0160: IF ((opm_CurrentModuleRecord.IndexData <> '') AND
0161: (opm_CurrentModuleRecord.ResultData <> '')) THEN
0162: IF (opm_FNFeedModule = TRUE) THEN
0163: BEGIN
0164: opm_Label_RunmodStatus.Caption := _('Disconnecting from module...');
0165: opm_PRDisconnectMod;
0166: opm_Label_RunmodStatus.Caption := _('Done with the module.');
0167: END
0168: ELSE
0169: BEGIN
0170: opm_Label_RunmodStatus.Caption := _('Module error!');
0171: opm_PRDisconnectMod;
0172: opm_Runmod_CanSync := FALSE;
0173: END;
0174: END
0175: ELSE
0176: BEGIN
0177: opm_Label_RunmodStatus.Caption := _('Module error!');
0178: opm_Runmod_CanSync := FALSE;
0179: END;
0180: opm_ProgressBar_Runmod.Visible := FALSE;
0181: opm_BitBtn_RunmodCancel.Enabled := TRUE;
0182: opm_BitBtn_RunmodCancel.Visible := TRUE;
0183: opm_Memo_RunmodDetails.Lines.Text := opm_Runmod_Stat;
0184: IF (opm_Runmod_CanSync = TRUE) THEN
0185: BEGIN
0186: opm_BitBtn_RunmodConfirm.Enabled := TRUE;
0187: opm_BitBtn_RunmodConfirm.Visible := TRUE;
0188: PRopm_CleanExchangeList (opmG_ExchangeList);
0189: PRopm_RenderConfirmDisplay (opmG_ExchangeList, opm_ListView_RunmodConfirm);
0190: opm_GroupBox_RunmodConfirm.Visible := TRUE;
0191: END;
0192: opm_GroupBox_RunmodDetails.Visible := TRUE;
0193: opm_Runmod_CanClose := TRUE;
0194: END;
0195:
0196:
0197:
0198:
0199: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0200: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0201: PROCEDURE Topm_Form_Runmod.PRopm_RenderConfirmDisplay (VAR SyncList : opmT_ExchangeList;
0202: VAR ListControl : TListView);
0203: VAR
0204: CurProd : LONGINT;
0205: CurItem : TListItem;
0206: BEGIN
0207: ListControl.Column[opm_Runmod_LastOrderColumn].ImageIndex := -1;
0208: opm_Runmod_Stat := '';
0209: opm_Runmod_LastOrderColumn := 0;
0210: ListControl.Items.BeginUpdate;
0211: ListControl.Items.Clear;
0212: FOR CurProd := 0 TO (opmG_TotalExchangeItems - 1) DO
0213: BEGIN
0214: CurItem := ListControl.Items.Add;
0215: CASE SyncList[CurProd].Status OF
0216: opmC_SyncResult_Equal : CurItem.ImageIndex := 3;
0217: opmC_SyncResult_Diff : CurItem.ImageIndex := 4;
0218: opmC_SyncResult_Unknown : CurItem.ImageIndex := 5;
0219: opmC_SyncResult_Restricted : CurItem.ImageIndex := 1;
0220: END;
0221: CurItem.SubItems.Add (SyncList[CurProd].IndexString);
0222: CurItem.SubItems.Add (SyncList[CurProd].CurrentString);
0223: CurItem.SubItems.Add (SyncList[CurProd].ResultString);
0224: END;
0225: ListControl.Column[opm_Runmod_LastOrderColumn].ImageIndex := 9;
0226: ListControl.CustomSort (@FNopm_Sort_ExchangeList, opm_Runmod_LastOrderColumn);
0227: ListControl.Items.EndUpdate;
0228: END;
0229:
0230:
0231:
0232: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0233: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0234: PROCEDURE Topm_Form_Runmod.PRopm_CleanExchangeList (VAR SyncList : opmT_ExchangeList);
0235: VAR
0236: CurProd : LONGINT;
0237: BEGIN
0238: FOR CurProd := 0 TO (opmG_TotalExchangeItems - 1) DO
0239: BEGIN
0240: IF ((opm_CurrentModuleRecord.ResultData = opmC_SyncField_ProductQuantity) OR
0241: (opm_CurrentModuleRecord.ResultData = opmC_SyncField_ProductStatus)) THEN
0242: SyncList[CurProd].ResultString := FNopm_CleanNumber (SyncList[CurProd].ResultString, opmC_ValIsIntegerEmpty)
0243: ELSE IF ((opm_CurrentModuleRecord.ResultData = opmC_SyncField_ProductPrice) OR
0244: (opm_CurrentModuleRecord.ResultData = opmC_SyncField_ProductWeight)) THEN
0245: BEGIN
0246: SyncList[CurProd].CurrentString := FNopm_CleanNumber (SyncList[CurProd].CurrentString, opmC_ValIsFloatEmpty);
0247: SyncList[CurProd].ResultString := FNopm_CleanNumber (SyncList[CurProd].ResultString, opmC_ValIsFloatEmpty);
0248: END
0249: ELSE IF (opm_CurrentModuleRecord.ResultData = opmC_SyncField_ProductQuantity) THEN
0250: SyncList[CurProd].ResultString := FNopm_CleanString (SyncList[CurProd].ResultString);
0251: { Set status }
0252: IF (SyncList[CurProd].ResultString = '') THEN
0253: SyncList[CurProd].Status := opmC_SyncResult_Unknown
0254: ELSE IF (SyncList[CurProd].CurrentString = SyncList[CurProd].ResultString) THEN
0255: SyncList[CurProd].Status := opmC_SyncResult_Equal
0256: ELSE SyncList[CurProd].Status := opmC_SyncResult_Diff;
0257: IF (SyncList[CurProd].Status = opmC_SyncResult_Diff) THEN
0258: BEGIN
0259: IF ((opm_CurrentModuleRecord.ResultData = opmC_SyncField_ProductPrice) AND
0260: (STRTOFLOATDEF (SyncList[CurProd].ResultString, 0) = 0) AND (opmG_UIAllowZeroPrice = 0)) THEN
0261: SyncList[CurProd].Status := opmC_SyncResult_Restricted
0262: ELSE IF ((opm_CurrentModuleRecord.ResultData = opmC_SyncField_ProductQuantity) AND
0263: (STRTOFLOATDEF (SyncList[CurProd].ResultString, 0) < 0) AND (opmG_UIAllowNegativeQuantity = 0)) THEN
0264: SyncList[CurProd].Status := opmC_SyncResult_Restricted;
0265: END;
0266: END;
0267: END;
0268:
0269:
0270:
0271:
0272: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0273: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0274: PROCEDURE Topm_Form_Runmod.FormShow (Sender: TObject);
0275: BEGIN
0276: opm_Runmod_CanClose := FALSE;
0277: opm_Runmod_CanSync := FALSE;
0278: opm_BitBtn_RunmodCancel.Enabled := FALSE;
0279: opm_BitBtn_RunmodCancel.Visible := FALSE;
0280: opm_BitBtn_RunmodConfirm.Enabled := FALSE;
0281: opm_BitBtn_RunmodConfirm.Visible := FALSE;
0282: opm_GroupBox_RunmodDetails.Visible := FALSE;
0283: opm_GroupBox_RunmodConfirm.Visible := FALSE;
0284: opm_ProgressBar_Runmod.Visible := TRUE;
0285: opm_ProgressBar_Runmod.Position := 0;
0286: opm_Form_Runmod.Caption := _('Synchronization with external module');
0287: opm_Runmod_LastOrderType := FALSE;
0288: opm_ListView_RunmodConfirm.Items.BeginUpdate;
0289: opm_ListView_RunmodConfirm.Items.Clear;
0290: opm_ListView_RunmodConfirm.Items.EndUpdate;
0291: opmG_TotalExchangeItems := opm_Form_Main.FNopm_Create_ExchangeList (opmG_ExchangeList, opm_CurrentModuleRecord.IndexData, opm_CurrentModuleRecord.ResultData);
0292: opm_Memo_RunmodDetails.Lines.Text := '';
0293: PostMessage (Handle, OPM_AUTOSTARTMOD, 0, LONGINT (Sender));
0294: END;
0295:
0296:
0297: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0298: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0299: procedure Topm_Form_Runmod.FormClose (Sender: TObject; var Action: TCloseAction);
0300: begin
0301: IF (opm_Runmod_CanClose = FALSE) THEN
0302: Action := caNone
0303: ELSE
0304: BEGIN
0305: opm_ListView_RunmodConfirm.Items.BeginUpdate;
0306: opm_ListView_RunmodConfirm.Items.Clear;
0307: opm_ListView_RunmodConfirm.Items.EndUpdate;
0308: END;
0309: end;
0310:
0311:
0312:
0313: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0314: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0315: procedure Topm_Form_Runmod.FormCreate(Sender: TObject);
0316: begin
0317: opm_ListView_RunmodConfirm.Columns.Clear;
0318: opm_ListView_RunmodConfirm.Checkboxes := FALSE;
0319: opm_ListView_RunmodConfirm.ReadOnly := TRUE;
0320: opm_ListView_RunmodConfirm.DoubleBuffered := TRUE;
0321: opm_ListView_RunmodConfirm.ViewStyle := vsReport;
0322: opm_ListView_RunmodConfirm.Columns.Add;
0323: opm_ListView_RunmodConfirm.Columns.Add;
0324: opm_ListView_RunmodConfirm.Columns.Add;
0325: opm_ListView_RunmodConfirm.Columns.Add;
0326: opm_ListView_RunmodConfirm.Columns.Items[0].Caption := '';
0327: opm_ListView_RunmodConfirm.Columns.Items[1].Caption := _('IndexSyncValue');
0328: opm_ListView_RunmodConfirm.Columns.Items[2].Caption := _('CurrentTargetValue');
0329: opm_ListView_RunmodConfirm.Columns.Items[3].Caption := _('NewTargetValue');
0330: opm_ListView_RunmodConfirm.Columns.Items[1].Alignment := opmC_Def_Col20Align;
0331: opm_ListView_RunmodConfirm.Columns.Items[2].Alignment := opmC_Def_Col21Align;
0332: opm_ListView_RunmodConfirm.Columns.Items[3].Alignment := opmC_Def_Col22Align;
0333: IF (opmG_UIHotTracking > 0) THEN
0334: BEGIN
0335: opm_ListView_RunmodConfirm.HotTrack := FALSE;
0336: opm_ListView_RunmodConfirm.HotTrackStyles := [htHandPoint, htUnderlineHot];
0337: END
0338: ELSE
0339: BEGIN
0340: opm_ListView_RunmodConfirm.HotTrack := FALSE;
0341: opm_ListView_RunmodConfirm.HotTrackStyles := [];
0342: END;
0343: IF (opmG_UIRememberDisplay > 0) THEN
0344: BEGIN
0345: opm_ListView_RunmodConfirm.Column[0].Width := opmG_UICol0X;
0346: opm_ListView_RunmodConfirm.Column[1].Width := opmG_UICol20X;
0347: opm_ListView_RunmodConfirm.Column[2].Width := opmG_UICol21X;
0348: opm_ListView_RunmodConfirm.Column[3].Width := opmG_UICol22X;
0349: END
0350: ELSE
0351: BEGIN
0352: opm_ListView_RunmodConfirm.Column[0].Width := opmC_Def_Col0X;
0353: opm_ListView_RunmodConfirm.Column[1].Width := opmC_Def_Col20X;
0354: opm_ListView_RunmodConfirm.Column[2].Width := opmC_Def_Col21X;
0355: opm_ListView_RunmodConfirm.Column[3].Width := opmC_Def_Col22X;
0356: END;
0357: TranslateComponent (self);
0358: end;
0359:
0360:
0361: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0362: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0363: procedure Topm_Form_Runmod.opm_BitBtn_RunmodConfirmClick(Sender: TObject);
0364: VAR
0365: ExcCount : LONGINT;
0366: USyncSQL, WSyncSQL : STRING;
0367: begin
0368: IF (opm_Runmod_CanSync = TRUE) THEN
0369: BEGIN
0370: opm_Label_RunmodStatus.Caption := _('Updating products database...');
0371: opm_BitBtn_RunmodCancel.Enabled := FALSE;
0372: opm_BitBtn_RunmodCancel.Visible := FALSE;
0373: opm_BitBtn_RunmodConfirm.Enabled := FALSE;
0374: opm_BitBtn_RunmodConfirm.Visible := FALSE;
0375: opm_GroupBox_RunmodDetails.Visible := FALSE;
0376: opm_GroupBox_RunmodConfirm.Visible := FALSE;
0377: opm_ProgressBar_Runmod.Visible := TRUE;
0378: opm_ProgressBar_Runmod.Min := 0;
0379: opm_ProgressBar_Runmod.Max := (opmG_TotalExchangeItems - 1);
0380: opm_ProgressBar_Runmod.Step := ROUND (opmG_TotalExchangeItems / 20);
0381: opm_ProgressBar_Runmod.Position := 0;
0382: FOR ExcCount := 0 TO (opmG_TotalExchangeItems - 1) DO
0383: BEGIN
0384: IF (opmG_ExchangeList[ExcCount].Status = opmC_SyncResult_Diff) THEN
0385: BEGIN
0386: IF ((opm_CurrentModuleRecord.ResultData = opmC_SyncField_ProductQuantity) OR
0387: (opm_CurrentModuleRecord.ResultData = opmC_SyncField_ProductPrice) OR
0388: (opm_CurrentModuleRecord.ResultData = opmC_SyncField_ProductWeight) OR
0389: (opm_CurrentModuleRecord.ResultData = opmC_SyncField_ProductStatus)) THEN
0390: USyncSQL := 'update ' + opmG_DBTable_Products + ' set ' + opm_CurrentModuleRecord.ResultData + '=' + opmG_ExchangeList[ExcCount].ResultString
0391: ELSE IF (opm_CurrentModuleRecord.ResultData = opmC_SyncField_ProductQuantity) THEN
0392: USyncSQL := 'update ' + opmG_DBTable_Products + ' set ' + opm_CurrentModuleRecord.ResultData + '="' + opmG_ExchangeList[ExcCount].ResultString + '"'
0393: ELSE
0394: USyncSQL := '';
0395: IF (opm_CurrentModuleRecord.IndexData = opmC_SyncField_ProductID) THEN
0396: WSyncSQL := 'where ' + opmC_SyncField_ProductID + '=' + opmG_ExchangeList[ExcCount].IndexString
0397: ELSE IF (opm_CurrentModuleRecord.IndexData = opmC_SyncField_ProductModel) THEN
0398: WSyncSQL := 'where ' + opmC_SyncField_ProductModel + '="' + opmG_ExchangeList[ExcCount].IndexString + '"'
0399: ELSE
0400: WSyncSQL := '';
0401: END;
0402: IF ((USyncSQL <> '') AND (WSyncSQL <> '')) THEN
0403: FNopm_ExecQuery (USyncSQL + ' ' + WSyncSQL, opmC_SQLUpdate);
0404: opm_ProgressBar_Runmod.Position := ExcCount;
0405: END;
0406: opm_Label_RunmodStatus.Caption := _('Done updating database.');
0407: opm_Runmod_CanClose := TRUE;
0408: opm_Form_Runmod.ModalResult := mrAll;
0409: END;
0410: end;
0411:
0412:
0413: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0414: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0415: PROCEDURE Topm_Form_Runmod.opm_PopMenuItem_RunmodCopyClick (Sender: TObject);
0416: VAR
0417: ExportText : STRING;
0418: BEGIN
0419: PRopm_Create_ConfirmExportList (ExportText, opmG_ExchangeList, opmC_SyncResult_Any);
0420: Clipboard.AsText := ExportText;
0421: END;
0422:
0423:
0424: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0425: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0426: procedure Topm_Form_Runmod.opm_PopMenuItem_RunmodCopyDiffClick(Sender: TObject);
0427: VAR
0428: ExportText : STRING;
0429: BEGIN
0430: PRopm_Create_ConfirmExportList (ExportText, opmG_ExchangeList, opmC_SyncResult_Diff);
0431: Clipboard.AsText := ExportText;
0432: END;
0433:
0434:
0435: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0436: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0437: procedure Topm_Form_Runmod.opm_PopMenuItem_RunmodCopyEqualClick(Sender: TObject);
0438: VAR
0439: ExportText : STRING;
0440: BEGIN
0441: PRopm_Create_ConfirmExportList (ExportText, opmG_ExchangeList, opmC_SyncResult_Equal);
0442: Clipboard.AsText := ExportText;
0443: END;
0444:
0445:
0446: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0447: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0448: procedure Topm_Form_Runmod.opm_PopMenuItem_RunmodCopyUnknownClick(Sender: TObject);
0449: VAR
0450: ExportText : STRING;
0451: BEGIN
0452: PRopm_Create_ConfirmExportList (ExportText, opmG_ExchangeList, opmC_SyncResult_Unknown);
0453: Clipboard.AsText := ExportText;
0454: END;
0455:
0456:
0457: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0458: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0459: procedure Topm_Form_Runmod.opm_PopMenuItem_RunmodCopyRestrictedClick(Sender: TObject);
0460: VAR
0461: ExportText : STRING;
0462: BEGIN
0463: PRopm_Create_ConfirmExportList (ExportText, opmG_ExchangeList, opmC_SyncResult_Restricted);
0464: Clipboard.AsText := ExportText;
0465: END;
0466:
0467:
0468: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0469: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0470: PROCEDURE Topm_Form_Runmod.PRopm_Create_ConfirmExportList (VAR ExportString : STRING;
0471: VAR ExportList : opmT_ExchangeList;
0472: SelectType : LONGINT);
0473: VAR
0474: ExportLine : STRING;
0475: CurProd : LONGINT;
0476: BEGIN
0477: ExportString := '';
0478: ExportLine := '';
0479: FOR CurProd := 0 TO (opmG_TotalExchangeItems - 1) DO
0480: BEGIN
0481: IF (ExportList[CurProd].Status = opmC_SyncResult_Unknown) THEN
0482: BEGIN
0483: IF ((SelectType = opmC_SyncResult_Any) OR (SelectType = opmC_SyncResult_Unknown)) THEN
0484: BEGIN
0485: ExportLine := ExportLine + ExportList[CurProd].IndexString + opmC_ExportSeparator;
0486: ExportLine := ExportLine + _('Unknown sync product') + opmC_ExportSeparator;
0487: ExportLine := ExportLine + ExportList[CurProd].CurrentString + opmC_ExportSeparator + ExportList[CurProd].ResultString;
0488: END;
0489: END
0490: ELSE IF (ExportList[CurProd].Status = opmC_SyncResult_Equal) THEN
0491: BEGIN
0492: IF ((SelectType = opmC_SyncResult_Any) OR (SelectType = opmC_SyncResult_Equal)) THEN
0493: BEGIN
0494: ExportLine := ExportLine + ExportList[CurProd].IndexString + opmC_ExportSeparator;
0495: ExportLine := ExportLine + _('Unchanged sync product') + opmC_ExportSeparator;
0496: ExportLine := ExportLine + ExportList[CurProd].CurrentString + opmC_ExportSeparator + ExportList[CurProd].ResultString;
0497: END;
0498: END
0499: ELSE IF (ExportList[CurProd].Status = opmC_SyncResult_Diff) THEN
0500: BEGIN
0501: IF ((SelectType = opmC_SyncResult_Any) OR (SelectType = opmC_SyncResult_Diff)) THEN
0502: BEGIN
0503: ExportLine := ExportLine + ExportList[CurProd].IndexString + opmC_ExportSeparator;
0504: ExportLine := ExportLine + _('Different sync product') + opmC_ExportSeparator;
0505: ExportLine := ExportLine + ExportList[CurProd].CurrentString + opmC_ExportSeparator + ExportList[CurProd].ResultString;
0506: END;
0507: END
0508: ELSE IF (ExportList[CurProd].Status = opmC_SyncResult_Restricted) THEN
0509: BEGIN
0510: IF ((SelectType = opmC_SyncResult_Any) OR (SelectType = opmC_SyncResult_Restricted)) THEN
0511: BEGIN
0512: ExportLine := ExportLine + ExportList[CurProd].IndexString + opmC_ExportSeparator;
0513: ExportLine := ExportLine + _('Invalid sync product') + opmC_ExportSeparator;
0514: ExportLine := ExportLine + ExportList[CurProd].CurrentString + opmC_ExportSeparator + ExportList[CurProd].ResultString;
0515: END;
0516: END;
0517: IF (ExportLine <> '') THEN ExportString := ExportString + ExportLine + #13#10;
0518: ExportLine := '';
0519: END;
0520: END;
0521:
0522:
0523: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0524: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0525: FUNCTION FNopm_Sort_ExchangeList (Item1, Item2: TListItem; Column: INTEGER) : INTEGER; STDCALL;
0526: BEGIN
0527: CASE Column OF
0528: 2, 3 :
0529: IF (opm_Runmod_LastOrderType = FALSE) THEN
0530: FNopm_Sort_ExchangeList := ROUND ((STRTOFLOATDEF (Item1.SubItems[Column - 1], 0) - STRTOFLOATDEF (Item2.SubItems[Column - 1], 0)))
0531: ELSE
0532: FNopm_Sort_ExchangeList := ROUND ((STRTOFLOATDEF (Item1.SubItems[Column - 1], 0) - STRTOFLOATDEF (Item2.SubItems[Column - 1], 0)) * -1);
0533: 0 :
0534: IF (opm_Runmod_LastOrderType = FALSE) THEN
0535: FNopm_Sort_ExchangeList := ROUND ((Item1.ImageIndex - Item2.ImageIndex))
0536: ELSE
0537: FNopm_Sort_ExchangeList := ROUND ((Item1.ImageIndex - Item2.ImageIndex) * -1);
0538: ELSE
0539: IF (opm_Runmod_LastOrderType = FALSE) THEN
0540: FNopm_Sort_ExchangeList := AnsiCompareText (Item1.SubItems[Column - 1], Item2.SubItems[Column - 1])
0541: ELSE
0542: FNopm_Sort_ExchangeList := ((AnsiCompareText (Item1.SubItems[Column - 1], Item2.SubItems[Column - 1])) * -1);
0543: END;
0544: END;
0545:
0546:
0547:
0548: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0549: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0550: procedure Topm_Form_Runmod.opm_ListView_RunmodConfirmColumnClick (Sender: TObject; Column: TListColumn);
0551: begin
0552: IF (Column.Index >= 0) AND (Column.Index <= 3) THEN
0553: BEGIN
0554: opm_ListView_RunmodConfirm.Column[opm_Runmod_LastOrderColumn].ImageIndex := -1;
0555: IF (opm_Runmod_LastOrderColumn = Column.Index) THEN
0556: opm_Runmod_LastOrderType := NOT (opm_Runmod_LastOrderType)
0557: ELSE
0558: opm_Runmod_LastOrderType := FALSE;
0559: IF (opm_Runmod_LastOrderType = TRUE) THEN
0560: Column.ImageIndex := 8
0561: ELSE
0562: Column.ImageIndex := 9;
0563: opm_Runmod_LastOrderColumn := Column.Index;
0564: TListView (Sender).CustomSort (@FNopm_Sort_ExchangeList, Column.Index);
0565: END;
0566: end;
0567:
0568:
0569: end.