Source code of file oscpmwin_v0.4.1.692/runmod.pas from the
osCommerce Product Manager for Windows.


0000:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001:   osCommerce Product Manager for Windows (oscpmwin).
0002:   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, Classes, Graphics, Controls, Forms,
0028:     StdCtrls, Buttons, 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_RunmodConfirm: TGroupBox;
0040:       opm_ListView_RunmodConfirm: TListView;
0041:       opm_BitBtn_RunmodConfirm: TBitBtn;
0042:       opm_PopupMenu_Runmod: TPopupMenu;
0043:       opm_PopMenuItem_RunmodCopy: TMenuItem;
0044:       opm_PopMenuItem_RunmodCopyDiff: TMenuItem;
0045:       opm_PopMenuItem_RunmodCopyEqual: TMenuItem;
0046:       opm_PopMenuItem_RunmodCopyUnknown: TMenuItem;
0047:       opm_PopMenuItem_RunmodCopyRestricted: TMenuItem;
0048:       opm_StatusBar_PEdit: TStatusBar;
0049:       opm_Memo_RunmodDetails: TMemo;
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, 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_Memo_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_Memo_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_Memo_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 FNopm_WebDB_Query (opmG_WBUploadURL, USyncSQL + ' ' + WSyncSQL, opmG_DBQuery_Recordset);
0406:             opm_ProgressBar_Runmod.Position := ExcCount;
0407:           END;
0408:         opm_Label_RunmodStatus.Caption := _('Done updating database.');
0409:         opm_Runmod_CanClose := TRUE;
0410:         opm_Form_Runmod.ModalResult := mrAll;
0411:       END;
0412:   end;
0413:   
0414:   
0415:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0416:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0417:   PROCEDURE Topm_Form_Runmod.opm_PopMenuItem_RunmodCopyClick (Sender: TObject);
0418:   VAR
0419:     ExportText : STRING;
0420:   BEGIN
0421:     PRopm_Create_ConfirmExportList (ExportText, opmG_ExchangeList, opmC_SyncResult_Any);
0422:     Clipboard.AsText := ExportText;
0423:   END;
0424:   
0425:   
0426:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0427:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0428:   procedure Topm_Form_Runmod.opm_PopMenuItem_RunmodCopyDiffClick(Sender: TObject);
0429:   VAR
0430:     ExportText : STRING;
0431:   BEGIN
0432:     PRopm_Create_ConfirmExportList (ExportText, opmG_ExchangeList, opmC_SyncResult_Diff);
0433:     Clipboard.AsText := ExportText;
0434:   END;
0435:   
0436:   
0437:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0438:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0439:   procedure Topm_Form_Runmod.opm_PopMenuItem_RunmodCopyEqualClick(Sender: TObject);
0440:   VAR
0441:     ExportText : STRING;
0442:   BEGIN
0443:     PRopm_Create_ConfirmExportList (ExportText, opmG_ExchangeList, opmC_SyncResult_Equal);
0444:     Clipboard.AsText := ExportText;
0445:   END;
0446:   
0447:   
0448:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0449:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0450:   procedure Topm_Form_Runmod.opm_PopMenuItem_RunmodCopyUnknownClick(Sender: TObject);
0451:   VAR
0452:     ExportText : STRING;
0453:   BEGIN
0454:     PRopm_Create_ConfirmExportList (ExportText, opmG_ExchangeList, opmC_SyncResult_Unknown);
0455:     Clipboard.AsText := ExportText;
0456:   END;
0457:   
0458:   
0459:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0460:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0461:   procedure Topm_Form_Runmod.opm_PopMenuItem_RunmodCopyRestrictedClick(Sender: TObject);
0462:   VAR
0463:     ExportText : STRING;
0464:   BEGIN
0465:     PRopm_Create_ConfirmExportList (ExportText, opmG_ExchangeList, opmC_SyncResult_Restricted);
0466:     Clipboard.AsText := ExportText;
0467:   END;
0468:   
0469:   
0470:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0471:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0472:   PROCEDURE Topm_Form_Runmod.PRopm_Create_ConfirmExportList (VAR ExportString : STRING;
0473:                                                              VAR ExportList : opmT_ExchangeList;
0474:                                                                  SelectType : LONGINT);
0475:   VAR
0476:     ExportLine : STRING;
0477:     CurProd : LONGINT;
0478:   BEGIN
0479:     ExportString := '';
0480:     ExportLine := '';
0481:     FOR CurProd := 0 TO (opmG_TotalExchangeItems - 1) DO
0482:       BEGIN
0483:         IF (ExportList[CurProd].Status = opmC_SyncResult_Unknown) THEN
0484:           BEGIN
0485:             IF ((SelectType = opmC_SyncResult_Any) OR (SelectType = opmC_SyncResult_Unknown)) THEN
0486:               BEGIN
0487:                 ExportLine := ExportLine + ExportList[CurProd].IndexString + opmC_ExportSeparator;
0488:                 ExportLine := ExportLine + _('Unknown sync product') + opmC_ExportSeparator;
0489:                 ExportLine := ExportLine + ExportList[CurProd].CurrentString + opmC_ExportSeparator + ExportList[CurProd].ResultString;
0490:               END;
0491:           END
0492:         ELSE IF (ExportList[CurProd].Status = opmC_SyncResult_Equal) THEN
0493:           BEGIN
0494:             IF ((SelectType = opmC_SyncResult_Any) OR (SelectType = opmC_SyncResult_Equal)) THEN
0495:               BEGIN
0496:                 ExportLine := ExportLine + ExportList[CurProd].IndexString + opmC_ExportSeparator;
0497:                 ExportLine := ExportLine + _('Unchanged sync product') + opmC_ExportSeparator;
0498:                 ExportLine := ExportLine + ExportList[CurProd].CurrentString + opmC_ExportSeparator + ExportList[CurProd].ResultString;
0499:               END;
0500:           END
0501:         ELSE IF (ExportList[CurProd].Status = opmC_SyncResult_Diff) THEN
0502:           BEGIN
0503:             IF ((SelectType = opmC_SyncResult_Any) OR (SelectType = opmC_SyncResult_Diff)) THEN
0504:               BEGIN
0505:                 ExportLine := ExportLine + ExportList[CurProd].IndexString + opmC_ExportSeparator;
0506:                 ExportLine := ExportLine + _('Different sync product') + opmC_ExportSeparator;
0507:                 ExportLine := ExportLine + ExportList[CurProd].CurrentString + opmC_ExportSeparator + ExportList[CurProd].ResultString;
0508:               END;
0509:           END
0510:         ELSE IF (ExportList[CurProd].Status = opmC_SyncResult_Restricted) THEN
0511:           BEGIN
0512:             IF ((SelectType = opmC_SyncResult_Any) OR (SelectType = opmC_SyncResult_Restricted)) THEN
0513:               BEGIN
0514:                 ExportLine := ExportLine + ExportList[CurProd].IndexString + opmC_ExportSeparator;
0515:                 ExportLine := ExportLine + _('Invalid sync product') + opmC_ExportSeparator;
0516:                 ExportLine := ExportLine + ExportList[CurProd].CurrentString + opmC_ExportSeparator + ExportList[CurProd].ResultString;
0517:               END;
0518:           END;
0519:         IF (ExportLine <> '') THEN ExportString := ExportString + ExportLine + #13#10;
0520:         ExportLine := '';
0521:       END;
0522:   END;
0523:   
0524:   
0525:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0526:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0527:   FUNCTION FNopm_Sort_ExchangeList (Item1, Item2: TListItem; Column: INTEGER) : INTEGER; STDCALL;
0528:   BEGIN
0529:     CASE Column OF
0530:     2, 3 :
0531:       IF (opm_Runmod_LastOrderType = FALSE) THEN
0532:         FNopm_Sort_ExchangeList := ROUND ((STRTOCURRDEF (Item1.SubItems[Column - 1], 0) - STRTOCURRDEF (Item2.SubItems[Column - 1], 0)))
0533:       ELSE
0534:         FNopm_Sort_ExchangeList := ROUND ((STRTOCURRDEF (Item1.SubItems[Column - 1], 0) - STRTOCURRDEF (Item2.SubItems[Column - 1], 0)) * -1);
0535:     0 :
0536:       IF (opm_Runmod_LastOrderType = FALSE) THEN
0537:         FNopm_Sort_ExchangeList := ROUND ((Item1.ImageIndex - Item2.ImageIndex))
0538:       ELSE
0539:         FNopm_Sort_ExchangeList := ROUND ((Item1.ImageIndex - Item2.ImageIndex) * -1);
0540:     ELSE
0541:       IF (opm_Runmod_LastOrderType = FALSE) THEN
0542:         FNopm_Sort_ExchangeList := AnsiCompareText (Item1.SubItems[Column - 1], Item2.SubItems[Column - 1])
0543:       ELSE
0544:         FNopm_Sort_ExchangeList := ((AnsiCompareText (Item1.SubItems[Column - 1], Item2.SubItems[Column - 1])) * -1);
0545:     END;
0546:   END;
0547:   
0548:   
0549:   
0550:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0551:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0552:   procedure Topm_Form_Runmod.opm_ListView_RunmodConfirmColumnClick (Sender: TObject; Column: TListColumn);
0553:   begin
0554:     IF (Column.Index >= 0) AND (Column.Index <= 3) THEN
0555:       BEGIN
0556:         opm_ListView_RunmodConfirm.Column[opm_Runmod_LastOrderColumn].ImageIndex := -1;
0557:         IF (opm_Runmod_LastOrderColumn = Column.Index) THEN
0558:           opm_Runmod_LastOrderType := NOT (opm_Runmod_LastOrderType)
0559:         ELSE
0560:           opm_Runmod_LastOrderType := FALSE;
0561:         IF (opm_Runmod_LastOrderType = TRUE) THEN
0562:           Column.ImageIndex := 8
0563:         ELSE
0564:           Column.ImageIndex := 9;
0565:         opm_Runmod_LastOrderColumn := Column.Index;
0566:         TListView (Sender).CustomSort (@FNopm_Sort_ExchangeList, Column.Index);
0567:       END;
0568:   end;
0569:   
0570:   
0571:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0572:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0573:   procedure Topm_Form_Runmod.opm_ListView_RunmodConfirmCustomDrawItem (Sender: TCustomListView; Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
0574:   begin
0575:     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;
0576:   end;
0577:   
0578:   end.
 
 
NA fum/lmd: 2007.07.15
Copyright ©1994-2017 by Mario A. Valdez-Ramírez.
no siga este enlace / do not follow this link