Vous êtes sur la page 1sur 5

namespace WindowsFormsApplication1 { class Tabula { public List<Gate> gateList;

public Tabula() { gateList = new List<Gate>(); }

} } class Gate { public Gate(string INnazov, UInt16 INodletH, UInt16 INodletM, string INdestinacia) { nazov = INnazov; odletHod = INodletH; odletMin = INodletM; destinacia = INdestinacia; }

public override string ToString() { return nazov + " " + odletHod + ":" + odletMin + " " + destinacia; }

public public public public } }

string UInt16 UInt16 string

nazov; odletHod; odletMin; destinacia;

namespace WindowsFormsApplication1 { public partial class Form1 : Form { Tabula MyTab = new Tabula(); int index = 0;

public Form1()

{ InitializeComponent(); } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { try { UInt16 pomCasH = UInt16.Parse(comboBox2.Text.Substring(0, 2)); UInt16 pomCasM = UInt16.Parse(comboBox2.Text.Substring(3, 2));

if (pomCasH <= 12 && pomCasH >= 0 && pomCasM >= 0 && pomCasM <= 59) {

Gate pomGate = new Gate(comboBox1.Text, pomCasH, pomCasM, comboBox3.Text); MyTab.gateList.Add(pomGate); label1.Text = ""; label1.Text = MyTab.gateList[index].ToString();

label2.Text = ""; foreach (Gate g in MyTab.gateList) { label2.Text += g.ToString() + "\n"; }

index++; } } catch (Exception) { label1.Text = ""; label1.Text = "Zly format casu"; } } private void button6_Click(object sender, EventArgs e) { index-=1; if (index < 0) { index = 0; }

label1.Text = ""; label1.Text = MyTab.gateList[index].ToString(); } private void Form1_Load(object sender, EventArgs e) {

Tabula MyTab = new Tabula(); label1.Text = ""; label2.Text = ""; label3.Text = "Aktualny"; label4.Text = "Vsetky";

} private void button5_Click(object sender, EventArgs e) { index++; if (index > (MyTab.gateList.Count()-1)) { index = MyTab.gateList.Count()-1; } label1.Text = ""; label1.Text = MyTab.gateList[index].ToString(); } private void button2_Click(object sender, EventArgs e) { string nazovPom=comboBox1.Text; Gate pomGate=null; for (int i = 0; i < MyTab.gateList.Count(); i++) { if (MyTab.gateList[i].nazov == nazovPom) { pomGate = MyTab.gateList[i]; break; } }

if (pomGate != null) { index = MyTab.gateList.IndexOf(pomGate); MyTab.gateList.Remove(pomGate);

} label2.Text = ""; foreach (Gate g in MyTab.gateList) { label2.Text += g.ToString() + "\n"; } } private void button3_Click(object sender, EventArgs e) { string nazovPom = comboBox1.Text; Gate pomGate = null; for (int i = 0; i < MyTab.gateList.Count(); i++) { if (MyTab.gateList[i].nazov == nazovPom) { pomGate = MyTab.gateList[i]; break; } }

if (pomGate != null) { label1.Text = ""; label1.Text = pomGate.ToString(); } else { label1.Text = ""; label1.Text = "Nenaslo sa"; }

} private void button4_Click(object sender, EventArgs e) { string nazovPom = comboBox1.Text; //Gate pomGate = null; try { UInt16 pomCasH = UInt16.Parse(comboBox2.Text.Substring(0, 2)); UInt16 pomCasM = UInt16.Parse(comboBox2.Text.Substring(3, 2));

if (pomCasH <= 12 && pomCasH >= 0 && pomCasM >= 0 && pomCasM <= 59) { for (int i = 0; i < MyTab.gateList.Count(); i++) { if (MyTab.gateList[i].nazov == nazovPom) { MyTab.gateList[i].nazov = comboBox1.Text; MyTab.gateList[i].destinacia = comboBox3.Text; MyTab.gateList[i].odletHod = pomCasH; MyTab.gateList[i].odletMin = pomCasM; index = i; break; } }

label1.Text = ""; label1.Text = MyTab.gateList[index].ToString();

label2.Text = ""; foreach (Gate g in MyTab.gateList) { label2.Text += g.ToString() + "\n"; } } } catch (Exception) { label1.Text = ""; label1.Text = "Zly format casu"; } } } }

Vous aimerez peut-être aussi