You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
161 lines
5.0 KiB
C#
161 lines
5.0 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace B_GOP01XX_XX2_K03_Aufgabe_5_P_Ostmann
|
|
{
|
|
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Form1_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
public double TimeToSec(int stunden, int minuten, double sekunden)
|
|
{
|
|
double sekundenGesamt = sekunden + (Convert.ToDouble(minuten * 60) + (Convert.ToDouble(stunden * 3600)));
|
|
return sekundenGesamt;
|
|
}
|
|
|
|
public void SecToTime(double sekunden)
|
|
{
|
|
|
|
int Stunden = Convert.ToInt16(sekunden) / 3600;
|
|
int Minuten = ((Convert.ToInt16(sekunden) - (Convert.ToInt16(sekunden) / 3600) * 3600)) / 60;
|
|
double Sekunden = sekunden % 60;
|
|
|
|
differenz_stunden.Text = Convert.ToString(Stunden);
|
|
differenz_minuten.Text = Convert.ToString(Minuten);
|
|
differenz_sekunden.Text = String.Format("{0:F3}", Sekunden);
|
|
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
int t1stunden = Convert.ToInt16(t1_stunden.Text);
|
|
int t1minuten = Convert.ToInt16(t1_minuten.Text);
|
|
double t1sekunden = Convert.ToDouble(t1_sekunden.Text);
|
|
|
|
double t1_gesamt = TimeToSec(t1stunden, t1minuten, t1sekunden);
|
|
|
|
int t2stunden = Convert.ToInt16(t2_stunden.Text);
|
|
int t2minuten = Convert.ToInt16(t2_minuten.Text);
|
|
double t2sekunden = Convert.ToDouble(t2_sekunden.Text);
|
|
|
|
double t2_gesamt = TimeToSec(t2stunden, t2minuten, t2sekunden);
|
|
|
|
MessageBox.Show("Ausgabe der Werte aus den Feldern " + Convert.ToString(t1_gesamt) + "\n Test Test " + Convert.ToString(t2_gesamt) + " Testende");
|
|
|
|
double SekundenDifferenz = t2_gesamt - t1_gesamt;
|
|
SecToTime(SekundenDifferenz);
|
|
}
|
|
|
|
private void t1_stunden_TextChanged(object sender, EventArgs e)
|
|
{
|
|
int val = 0;
|
|
bool res = Int32.TryParse(t1_stunden.Text, out val);
|
|
if (res == true && val > -1 && val < 24 || t1_stunden.Text ==(""))
|
|
{
|
|
// add record
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Bitte keine Werte höher als 23 eingeben!");
|
|
t1_stunden.Text = String.Empty;
|
|
return;
|
|
}
|
|
}
|
|
|
|
private void t2_stunden_TextChanged(object sender, EventArgs e)
|
|
{
|
|
int val = 0;
|
|
bool res = Int32.TryParse(t2_stunden.Text, out val);
|
|
if (res == true && val > -1 && val < 24 || t1_stunden.Text == (""))
|
|
{
|
|
// add record
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Bitte keine Werte höher als 23 eingeben!");
|
|
t2_stunden.Text = String.Empty;
|
|
return;
|
|
}
|
|
}
|
|
|
|
private void t1_minuten_TextChanged(object sender, EventArgs e)
|
|
{
|
|
int val = 0;
|
|
bool res = Int32.TryParse(t1_minuten.Text, out val);
|
|
if (res == true && val > -1 && val < 60 || t1_stunden.Text == (""))
|
|
{
|
|
// add record
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Bitte keine Werte höher als 59 eingeben!");
|
|
t1_minuten.Text = String.Empty;
|
|
return;
|
|
}
|
|
}
|
|
|
|
private void t2_minuten_TextChanged(object sender, EventArgs e)
|
|
{
|
|
int val = 0;
|
|
bool res = Int32.TryParse(t2_minuten.Text, out val);
|
|
if (res == true && val > -1 && val < 60 || t1_stunden.Text == (""))
|
|
{
|
|
// add record
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Bitte keine Werte höher als 59 eingeben!");
|
|
t2_minuten.Text = String.Empty;
|
|
return;
|
|
}
|
|
}
|
|
|
|
private void t1_sekunden_TextChanged(object sender, EventArgs e)
|
|
{
|
|
double val = 0.0;
|
|
bool res = double.TryParse(t1_sekunden.Text, out val);
|
|
if (res == true && val > 0.001 && val < 59.999)
|
|
{
|
|
// add record
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Bitte keine Werte höher als 59,999 eingeben!");
|
|
t1_sekunden.Text = String.Empty;
|
|
return;
|
|
}
|
|
}
|
|
|
|
private void t2_sekunden_TextChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
double val = 0.0;
|
|
bool res = double.TryParse(t2_sekunden.Text, out val);
|
|
if (res == true && val > 0.001 && val < 59.999 )
|
|
{
|
|
// add record
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Bitte keine Werte höher als 59,999 eingeben!");
|
|
t2_sekunden.Text = String.Empty;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|