Autor Beitrag
Becks16
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 405



BeitragVerfasst: Do 05.07.07 15:13 
Hallo

Ich bin grade dabei in meiner Kalkulation eine Provisionsstaffel einzubauen, die errechnet sich aus dem Nettoverkaufspreis das problem ist jetzt aber das je nach dem wie viel rabatt ich gebe die Prozente sinken
(habe ein editfeld mit dem Nettoverkaufspreis, Listenpreis und aus dem beiden feldern errechnet er den Rabatt)

hier mal die Staffelung

0 % -12 %
0,01 - 4,99 % - 11 %
5,00 - 9,99 % - 9 %

und so weiter ....

jetzt möchte ich ganz gerne das er mir die Prov. auch ausrechnet

möchte das in eine schleifen einbauen weiß aber nicht wirklich wie vielleicht habt ihr paar anregungen das ich einen anfang habe

vielen dank schon mal im vorraus

_________________
Ich bin Dumm und weiss nichts :-)
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 05.07.07 15:17 
Wie liegen die Werte vor? Nur in den Edits? Für was ne Schleife?

_________________
Markus Kinzler.
Becks16 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 405



BeitragVerfasst: Do 05.07.07 15:24 
hey hey

also die werte liegen nur in den Edits vor werden auch nicht gespeichert ( errechnen sich aus den einzelnen Position die mit preise in der Datenbank hinterlegt sind)


mfg

_________________
Ich bin Dumm und weiss nichts :-)
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 05.07.07 15:27 
Dann berechne doch gleich die Provision mit.

_________________
Markus Kinzler.
Becks16 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 405



BeitragVerfasst: Do 05.07.07 15:32 
ja das will ich ja auch , wenn ich immer die gleiche Prov. bekomme ist das ja kein problem aber je mehr Rabatt desto weniger gibt es an Prozenten .... das ist mein problem wie ich das eingebaut bekomme

_________________
Ich bin Dumm und weiss nichts :-)
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 05.07.07 15:36 
Beim Lesen aus der Datenbank berechnen und Eintragen.

_________________
Markus Kinzler.
Becks16 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 405



BeitragVerfasst: Do 05.07.07 15:37 
meinst du jetzt die Provionsstaffen in die Datenbank mit einbauen oder wie ?

_________________
Ich bin Dumm und weiss nichts :-)
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 05.07.07 15:39 
Am Besten ja. Die werden sich ja nicht ständig ändern.

_________________
Markus Kinzler.
Becks16 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 405



BeitragVerfasst: Do 05.07.07 15:42 
aber da kann ich doch nicht von 5,01 bis 10,00 % eingeben oder doch ? und dazu muss er ja noch wissen wenn der rabatt in diesem bereich ist das ich dann nur noch 9 % Prov. bekomme

_________________
Ich bin Dumm und weiss nichts :-)
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 05.07.07 15:50 
Kommt darauf an wie du das in der Datenbank anlegst
ausblenden SQL-Anweisung
1:
select satz from provision where rabatt between <unten> and <oben>;					

_________________
Markus Kinzler.
azubi_20
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 593

WinXP SP2, Ubuntu 8.4
D7 Enterp., D2005 Prof., Java (Eclipse 3.4.0)
BeitragVerfasst: Do 05.07.07 15:52 
Du erstellst in deiner DB eine neue Tabelle "Provision" mit folgenden Spalten: Anfangswert, Endwert, Provisionssatz. Diese füllst du dann mit deinen Werten. Dann kannst du den Provisionssatz für deinen Rabatt ziehen : Select Provisionssatz from Provision where rabatt between Anfangswert and Endwert;
Becks16 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 405



BeitragVerfasst: Do 05.07.07 16:02 
also die Tabelle habe ich jetzt angelegt ...bei deiner sql anweisung steht jetzt where rabatt ( aber die höhe des rabattes muss er sich ja aus dem Editfeld holen , der rabatt steht ja in der tabelle nicht drin)

_________________
Ich bin Dumm und weiss nichts :-)
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 05.07.07 16:09 
ausblenden SQL-Anweisung
1:
select satz from provision where :rabatt between <unten> and <oben>;					

ausblenden Delphi-Quelltext
1:
query.ParamByName('rabatt').asString := Edit.Text;					

_________________
Markus Kinzler.
Becks16 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 405



BeitragVerfasst: Do 05.07.07 16:19 
hm ok sorry das ich da noch mal nach frage aber da bin ich irgendwie zu blöd zu

die sql anweisung habe ich eingebaut

jetzt muss ich das ganze ja noch im Quelltext einbauen (zum ablauf kurz wenn ich den Button bereche Drücke dann rechnet er mir den Listenpreis aus, den Verkaufspreis gebe ich selber ein und wenn der steht rechnet er den Rabatt aus und gleichzeitig soll ich denn noch die Provision mit dazu )


mfg

_________________
Ich bin Dumm und weiss nichts :-)
Becks16 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 405



BeitragVerfasst: Fr 06.07.07 09:28 
hallo

also diesen quelltext habe ich jetzt mit hilfe von mkinzler
ausblenden Delphi-Quelltext
1:
2:
3:
f_kalkulation.qu_prov.Parameters.ParamByName('rabatt').Value := StrToFloat(edit_rabatt.Text);
f_kalkulation.qu_prov.Open;
edit_provision.Text := FloatToStr( StrToFloat(edit_verkaufspreis.Text) * f_kalkulation.qu_prov.FieldByname('prov').Value / 100);


das programm läuft auch durch aber im edit_provision zeigt er mir nichts an da kommt nur die fehlermeldung

Im Projekt Projekt1.exe ist eine exception der Klasse EVariantError aufgetreten. Meldung "Ungültige Variant-Typumwandlung".....

könnt ihr mir dabei helfen

mfg

_________________
Ich bin Dumm und weiss nichts :-)
uko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 220
Erhaltene Danke: 1

Win XP, VISTA, WIndows 7
Delphi 2007/2010 Prof
BeitragVerfasst: Fr 06.07.07 10:42 
Vor der Verwendung des Ergebnisses auf NULL testen!

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
// Test auf NULL
// if not VarIsNull(f_kalkulation.qu_prov.FieldByname('prov')) then
edit_provision.Text := FloatToStr( StrToFloat(edit_verkaufspreis.Text) * f_kalkulation.qu_prov.FieldByname('prov').Value / 100);
// else
// edit_provision.Text := '0';


Schau mal in der HIlfe unter VarIsNull oder VarIsNumeric nach, welches Du besser brauchen kannst.


Grüße,
Uli
Becks16 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 405



BeitragVerfasst: Fr 06.07.07 11:00 
das verstehe ich jetzt nicht ganz

soll er in der Datenbank das Feld prov auf 0 setzen oder wie ?

er soll mir ja jetzt anhand des ausgerechneten rabattes ausrechnen wieviel provison ich bekomme und die provsionssätze stehen in der datenbank drin ...


mfg

_________________
Ich bin Dumm und weiss nichts :-)
Agawain
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 460

win xp
D5, MySQL, devxpress
BeitragVerfasst: Fr 06.07.07 11:04 
Hi

Du mußt bei der Verwendung von Variantdatentypen auf Null testen.
Null bedeutet nichts, nada, niente und nicht 0.

Wahrscheinlich hast Du nichts in der Ergebnismenge der Abfrage.
Weis nicht, ob Du es getan hast, aber vor Setzen des Parameters muß die Abfrage geschlossen werden.

Gruß

Aga
Becks16 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 405



BeitragVerfasst: Fr 06.07.07 11:08 
aha ok erst mal danke für eure hilfe

und wie mach ich das mit dem null testen ?

mfg

_________________
Ich bin Dumm und weiss nichts :-)
Agawain
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 460

win xp
D5, MySQL, devxpress
BeitragVerfasst: Fr 06.07.07 11:11 
hat Dir uko doch schon geschrieben

if Variable not Null then