ComboBox mit Problemchen ;)

axelfxxx

Mitglied
Hallo leute ;)

Ich übe mich mal wieder ein bischen in c# und stoße schon wieder auf Probleme !

Ich möchte ein kleines Faxberechnungsprogramm schreiben, wo ich an Hand einer ComboBox ( Die ist mit Zeitzohnen befüllt ) und der Eingabe von Minuten eine Berechnung durchführe. D.h. Nehmen wir Deutschland: Alle 12 Sekunden bezahlt der Kunde 0,15 Cent.

Meine Frage ist:

Wie übergebe ich die Zeitzohne und die Angabe an Minuten an das vorhandene Label und rechne nun z.b. Deutschland: (Minuten * 60 (um Sekunden zu bekommen!!) ) / 12 * 0,15

PS. Ich hab noch ein Button: Gebühren berechnen *gg* Mein Code :
Code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace faxberechnung
{
	/// <summary>
	/// Zusammenfassung für Form1.
	/// </summary>
	public class Fax : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox grpb1;
		public System.Windows.Forms.ComboBox cmb;
		private System.Windows.Forms.GroupBox time;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Label label1;
		/// <summary>
		/// Erforderliche Designervariable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Fax()
		{
			//
			// Erforderlich für die Windows Form-Designerunterstützung
			//
			InitializeComponent();

		}

		/// <summary>
		/// Die verwendeten Ressourcen bereinigen.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Vom Windows Form-Designer generierter Code
		/// <summary>
		/// Erforderliche Methode für die Designerunterstützung. 
		/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
		/// </summary>
		private void InitializeComponent()
		{
			this.grpb1 = new System.Windows.Forms.GroupBox();
			this.cmb = new System.Windows.Forms.ComboBox();
			this.time = new System.Windows.Forms.GroupBox();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.button1 = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.grpb1.SuspendLayout();
			this.time.SuspendLayout();
			this.SuspendLayout();
			// 
			// grpb1
			// 
			this.grpb1.Controls.Add(this.cmb);
			this.grpb1.Location = new System.Drawing.Point(8, 8);
			this.grpb1.Name = "grpb1";
			this.grpb1.Size = new System.Drawing.Size(216, 64);
			this.grpb1.TabIndex = 1;
			this.grpb1.TabStop = false;
			this.grpb1.Text = "(1) Land";
			// 
			// cmb
			// 
			this.cmb.Items.AddRange(new object[] {
													 "Deutschland",
													 "Euro 1",
													 "Euro2",
													 "Restliche Länder",
													 "Usa & Kannada"});
			this.cmb.Location = new System.Drawing.Point(16, 24);
			this.cmb.Name = "cmb";
			this.cmb.Size = new System.Drawing.Size(192, 21);
			this.cmb.Sorted = true;
			this.cmb.TabIndex = 0;
			this.cmb.Text = "Bitte Land wählen...";
			this.cmb.SelectedIndexChanged += new System.EventHandler(this.cmb_SelectedIndexChanged);
			// 
			// time
			// 
			this.time.Controls.Add(this.textBox1);
			this.time.Location = new System.Drawing.Point(8, 80);
			this.time.Name = "time";
			this.time.Size = new System.Drawing.Size(216, 72);
			this.time.TabIndex = 2;
			this.time.TabStop = false;
			this.time.Text = "(2) Zeitangabe in MIN";
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(16, 32);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(184, 20);
			this.textBox1.TabIndex = 0;
			this.textBox1.Text = "Bitte hier die Zeit eintragen";
			this.textBox1.Click += new System.EventHandler(this.textBox1_Click);
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(232, 16);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(192, 23);
			this.button1.TabIndex = 4;
			this.button1.Text = "(3) Gebühren berechnen...";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// label1
			// 
			this.label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label1.Location = new System.Drawing.Point(232, 48);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(192, 120);
			this.label1.TabIndex = 5;
			// 
			// Fax
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.BackColor = System.Drawing.SystemColors.ActiveBorder;
			this.ClientSize = new System.Drawing.Size(442, 186);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.time);
			this.Controls.Add(this.grpb1);
			this.Controls.Add(this.button1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
			this.Name = "Fax";
			this.Text = "Faxberechnung";
			this.grpb1.ResumeLayout(false);
			this.time.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// Der Haupteinstiegspunkt für die Anwendung.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Fax());
		}

		
		private void textBox1_Click(object sender, System.EventArgs e)
		{
			this.textBox1.Text ="";
		}
		private void cmb_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			string first = cmb.SelectedText.ToString();
		}
		private void button1_Click(object sender, System.EventArgs e)
		{
			this.button1.Text ="";
		}
	}
}

Nun noch folgenses Problem: Der Berechnungscode verändert sich andauernd:
Euro 1: geteilt durch 7,2 mal 0,15
Euro 2: /5,63 * 0,15

u.s.w.

Ich bedanke mich jetzt schon im vorraus.

MFG
axelfxxx
 
hat sich schon erledigt :))

hier der Code:
Code:
try 
			{
				string first = cmb.SelectedItem.ToString();
				double minute = Convert.ToDouble(text.Text);
				double de = minute * 60 / 12 * 0.15 + 1.5;
				double eu1 = minute * 60 / 7.2 * 0.15 + 1.5;
				double eu2 = minute * 60 / 5.63 * 0.15 + 1.5;
				double usa = minute * 60 / 5 * 0.15 + 1.5;
				double res = minute * 60 / 2.31 * 0.15 + 1.5;
			
				if (first.Equals("Deutschland"))
				{
					this.label1.Text = "Sie faxten in Zeitzohne: " + first + " für " +  "\n" + de + " Euro inkl. Grundgebühr für die erste Seite";
					this.info.Text = "Deutschland: Alle 12 Sekunden 0,15 Euro !";
				}
				else if(first.Equals("Euro 1"))
				{
					this.label1.Text = "Sie faxten in Zeitzohne: " + first + " für " + "\n" + eu1 + " Euro inkl. Grundgebühr für die erste Seite";
					this.info.Text = "Euro 1: Alle 7,2 Sekunden 0,15 Euro !";
				}
				else if(first.Equals("Euro 2"))
				{
					this.label1.Text = "Sie faxten in Zeitzohne: " + first + " für " +  "\n" + eu2 + " Euro inkl. Grundgebühr für die erste Seite";
					this.info.Text = "Euro 2: Alle 5,63 Sekunden 0,15 Euro !";
				}
				else if(first.Equals("USA & Cannada"))
				{
					this.label1.Text = "Sie faxten in Zeitzohne: " + first + " für " +  "\n" + usa + " Euro inkl. Grundgebühr für die erste Seite";
					this.info.Text = "USA & Cannada: Alle 5 Sekunden 0,15 Euro !";
				}
				else if(first.Equals("Restliche Länder"))
				{
					this.label1.Text = "Sie faxten in Zeitzohne: " + first + " für " +  "\n" + res + " Euro inkl. Grundgebühr für die erste Seite";
					this.info.Text = "Restliche Länder: Alle 2,31 Sekunden 0,15 Euro !";
				}
				else
					MessageBox.Show("Bitte irgendwas eingebnen");
			}
			catch(System.NullReferenceException)
			{
				MessageBox.Show("Bitte nicht vergessen das Land einzugeben !!", "Eingabefehler");
			}
			catch(System.FormatException)
			{
				MessageBox.Show("Biite eine Minuteneingabe nicht vergessen !!", "Eingabefehler");
			}
            
		}
 
Zurück