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