Source code of file oscpmwin_v0.1.2.189/currencyedit.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 currencyedit;
0023:   
0024:   interface
0025:   
0026:   uses
0027:     Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
0028:     Dialogs, StdCtrls, Spin, Buttons, oscpmdata;
0029:   
0030:   type
0031:     Topm_Form_CurrencyEdit = class(TForm)
0032:       opm_Label_CurrencyName: TLabel;
0033:       opm_Edit_CurrencyName: TEdit;
0034:       opm_Label_CurrencyCode: TLabel;
0035:       opm_Label_CurrencyLSymbol: TLabel;
0036:       opm_Edit_CurrencyLSymbol: TEdit;
0037:       opm_Label_CurrencyRSymbol: TLabel;
0038:       opm_Edit_CurrencyRSymbol: TEdit;
0039:       opm_Edit_CurrencyDecimalP: TEdit;
0040:       opm_Label_CurrencyDecimalP: TLabel;
0041:       opm_Label_CurrencyThousandP: TLabel;
0042:       opm_Edit_CurrencyThousandP: TEdit;
0043:       opm_SpinEdit_CurrencyPrecision: TSpinEdit;
0044:       opm_Label_CurrencyPrecision: TLabel;
0045:       opm_Edit_CurrencyValue: TEdit;
0046:       opm_Label_CurrencyValue: TLabel;
0047:       opm_BitBtn_CurrencyOk: TBitBtn;
0048:       opm_BitBtn_CurrencyCancel: TBitBtn;
0049:       opm_Edit_CurrencyExample: TEdit;
0050:       opm_ComboBox_CurrencyCode: TComboBox;
0051:       procedure FormCreate(Sender: TObject);
0052:       procedure FormShow(Sender: TObject);
0053:       procedure opm_BitBtn_CurrencyOkClick(Sender: TObject);
0054:       procedure opm_Edit_CurrencyLSymbolExit(Sender: TObject);
0055:       procedure opm_SpinEdit_CurrencyPrecisionChange(Sender: TObject);
0056:       procedure opm_ComboBox_CurrencyCodeExit(Sender: TObject);
0057:     private
0058:       PROCEDURE PRopm_Update_CurrExample;
0059:     public
0060:       CU_AddEdit : BOOLEAN;
0061:       CU_Currency : opmR_Currency;
0062:     end;
0063:   
0064:   
0065:   CONST
0066:     opm_Currency_Example = '149-999-999=999999999';
0067:   
0068:   var
0069:     opm_Form_CurrencyEdit: Topm_Form_CurrencyEdit;
0070:     opm_Currency_ISOCodes : STRING;
0071:   
0072:   implementation
0073:   
0074:   {$R *.dfm}
0075:   
0076:   USES gnugettext, dataman, attention;
0077:   
0078:   
0079:   {$R iso4217_codes.RES}
0080:   
0081:   
0082:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0083:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0084:   procedure Topm_Form_CurrencyEdit.FormCreate(Sender: TObject);
0085:   begin
0086:     CU_AddEdit := FALSE;
0087:     CU_Currency.ID := -1;
0088:     opm_Edit_CurrencyName.MaxLength := opmC_CurrName_MaxLen;
0089:     opm_ComboBox_CurrencyCode.MaxLength := opmC_CurrCode_MaxLen;
0090:     opm_Edit_CurrencyLSymbol.MaxLength := opmC_CurrLSymbol_MaxLen;
0091:     opm_Edit_CurrencyRSymbol.MaxLength := opmC_CurrRSymbol_MaxLen;
0092:     opm_Edit_CurrencyDecimalP.MaxLength := opmC_CurrDecSep_MaxLen;
0093:     opm_Edit_CurrencyThousandP.MaxLength := opmC_CurrThoSep_MaxLen;
0094:     opm_SpinEdit_CurrencyPrecision.MinValue := opmC_CurrPrecision_Min;
0095:     opm_SpinEdit_CurrencyPrecision.MaxValue := opmC_CurrPrecision_Max;
0096:     opm_Edit_CurrencyValue.MaxLength := opmC_CurrValue_MaxLen;
0097:     opm_Edit_CurrencyExample.BorderStyle := bsNone;
0098:     opm_Currency_ISOCodes := FNopm_StringFromResource ('iso4217_codes');
0099:     opm_ComboBox_CurrencyCode.Items.Text := opm_Currency_ISOCodes;
0100:     TranslateComponent (self);
0101:   end;
0102:   
0103:   
0104:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0105:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0106:   procedure Topm_Form_CurrencyEdit.FormShow(Sender: TObject);
0107:   begin
0108:     IF (CU_AddEdit = TRUE) THEN
0109:       BEGIN
0110:         opm_Form_CurrencyEdit.Caption := _('Currency configuration');
0111:         CU_Currency.ID := -1;
0112:         opm_Edit_CurrencyName.Text := '';
0113:         opm_ComboBox_CurrencyCode.Text := opmC_Def_CurrCode;
0114:         opm_Edit_CurrencyLSymbol.Text := opmC_Def_CurrLSymbol;
0115:         opm_Edit_CurrencyRSymbol.Text := opmC_Def_CurrRSymbol;
0116:         opm_Edit_CurrencyDecimalP.Text := opmC_Def_CurrDecSep;
0117:         opm_Edit_CurrencyThousandP.Text := opmC_Def_CurrThoSep;
0118:         opm_SpinEdit_CurrencyPrecision.Value := opmC_Def_CurrPrecision;
0119:         opm_Edit_CurrencyValue.Text := INTTOSTR (opmC_Def_CurrValue);
0120:       END
0121:     ELSE
0122:       BEGIN
0123:         opm_Form_CurrencyEdit.Caption := _('Currency configuration') + ' (' + INTTOSTR (CU_Currency.ID) + ' - ' + CU_Currency.Name + ', ' + CU_Currency.Code + ')';
0124:         opm_Edit_CurrencyName.Text := CU_Currency.Name;
0125:         opm_ComboBox_CurrencyCode.Text := CU_Currency.Code;
0126:         opm_Edit_CurrencyLSymbol.Text := CU_Currency.Left;
0127:         opm_Edit_CurrencyRSymbol.Text := CU_Currency.Right;
0128:         opm_Edit_CurrencyDecimalP.Text := CU_Currency.DecimalSep;
0129:         opm_Edit_CurrencyThousandP.Text := CU_Currency.ThousandSep;
0130:         opm_SpinEdit_CurrencyPrecision.Value := CU_Currency.Precision;
0131:         opm_Edit_CurrencyValue.Text := CURRTOSTR (CU_Currency.Value);
0132:       END;
0133:     PRopm_Update_CurrExample;
0134:   end;
0135:   
0136:   
0137:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0138:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0139:   procedure Topm_Form_CurrencyEdit.opm_BitBtn_CurrencyOkClick(Sender: TObject);
0140:   begin
0141:     CU_Currency.Name := FNopm_CleanString (opm_Edit_CurrencyName.Text);
0142:     CU_Currency.Code := ANSIUPPERCASE (FNopm_CleanString (opm_ComboBox_CurrencyCode.Text));
0143:     CU_Currency.Left := FNopm_CleanString (opm_Edit_CurrencyLSymbol.Text);
0144:     CU_Currency.Right := FNopm_CleanString (opm_Edit_CurrencyRSymbol.Text);
0145:     CU_Currency.DecimalSep := FNopm_CleanString (opm_Edit_CurrencyDecimalP.Text);
0146:     CU_Currency.ThousandSep := FNopm_CleanString (opm_Edit_CurrencyThousandP.Text);
0147:     CU_Currency.Precision := ABS (opm_SpinEdit_CurrencyPrecision.Value);
0148:     CU_Currency.Value := ABS (STRTOCURR (FNopm_CleanNumber (opm_Edit_CurrencyValue.Text, opmC_ValIsCurrency)));
0149:     IF (CU_Currency.Value = 0) THEN
0150:       BEGIN
0151:         opm_Edit_CurrencyValue.Text := CURRTOSTR (CU_Currency.Value);
0152:         opm_Form_CurrencyEdit.FocusControl (opm_Edit_CurrencyValue);
0153:         FNopm_Message (_('The currency value cannot be zero.'), mtWarning, [mbOk], opmG_UISilent);
0154:         ModalResult := mrNone;
0155:       END
0156:     ELSE IF (CU_Currency.Name = '') THEN
0157:       BEGIN
0158:         opm_Edit_CurrencyName.Text := CU_Currency.Name;
0159:         opm_Form_CurrencyEdit.FocusControl (opm_Edit_CurrencyName);
0160:         FNopm_Message (_('The currency name cannot be empty.'), mtWarning, [mbOk], opmG_UISilent);
0161:         ModalResult := mrNone;
0162:       END
0163:     ELSE IF (CU_Currency.Code = '') THEN
0164:       BEGIN
0165:         opm_ComboBox_CurrencyCode.Text := CU_Currency.Code;
0166:         opm_Form_CurrencyEdit.FocusControl (opm_ComboBox_CurrencyCode);
0167:         FNopm_Message (_('The currency code cannot be empty.'), mtWarning, [mbOk], opmG_UISilent);
0168:         ModalResult := mrNone;
0169:       END
0170:     ELSE
0171:       ModalResult := mrOk;
0172:   end;
0173:   
0174:   
0175:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0176:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0177:   PROCEDURE Topm_Form_CurrencyEdit.PRopm_Update_CurrExample;
0178:   VAR
0179:     ExampleStr : STRING;
0180:     IntPart, DecPart : STRING;
0181:   BEGIN
0182:     ExampleStr := opm_Currency_Example;
0183:     IntPart := COPY (ExampleStr, 1, (ANSIPOS ('=', ExampleStr) - 1));
0184:     IntPart := COPY (IntPart, 1, LENGTH (ExampleStr));
0185:     DecPart := COPY (ExampleStr, (ANSIPOS ('=', ExampleStr) + 1), opm_SpinEdit_CurrencyPrecision.Value);
0186:     ExampleStr := IntPart + '=' + DecPart;
0187:     ExampleStr := STRINGREPLACE (ExampleStr, '-', opm_Edit_CurrencyThousandP.Text, [rfReplaceAll]);
0188:     ExampleStr := STRINGREPLACE (ExampleStr, '=', opm_Edit_CurrencyDecimalP.Text, []);
0189:     opm_Edit_CurrencyExample.Text := opm_Edit_CurrencyLSymbol.Text + ' ' + ExampleStr + ' ' + opm_Edit_CurrencyRSymbol.Text;
0190:   END;
0191:   
0192:   
0193:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0194:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0195:   procedure Topm_Form_CurrencyEdit.opm_Edit_CurrencyLSymbolExit(Sender: TObject);
0196:   begin
0197:     PRopm_Update_CurrExample;
0198:   end;
0199:   
0200:   
0201:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0202:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0203:   procedure Topm_Form_CurrencyEdit.opm_SpinEdit_CurrencyPrecisionChange(Sender: TObject);
0204:   begin
0205:     PRopm_Update_CurrExample;
0206:   end;
0207:   
0208:   
0209:   
0210:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0211:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0212:   procedure Topm_Form_CurrencyEdit.opm_ComboBox_CurrencyCodeExit(Sender: TObject);
0213:   begin
0214:     opm_ComboBox_CurrencyCode.Text := COPY (opm_ComboBox_CurrencyCode.Text, 1, 3);
0215:   end;
0216:   
0217:   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