/// <summary> /// constructor /// </summary> public Administration() { GetRailList = new List<Rail>(); GetTramList = new List<Tram>(); foreach(Dictionary<string, object> R in addatabase.GetAllRails()) { bool status = false; if(Convert.ToInt32(R["blokkeer"]) == 0) { status = false; } else { status = true; } Rail r = new Rail(Convert.ToInt32(R["spoorid"]), status , false, Convert.ToInt32(R["remiseid"])); GetRailList.Add(r); } foreach (Dictionary<string, object> T in addatabase.GetAllTrams()) { Rail rail = null; int status = 0; bool onRail = false; if ((string)T["status"] == "Ok") { status = 1; } if ((string)T["status"] == "Vies") { status = 2; } if ((string)T["status"] == "Defect") { status = 3; } if ((string)T["status"] == "ViesEnDefect") { status = 4; } if (Convert.ToInt32(T["aanwezigopspoor"]) == 0) { onRail = false; } else { onRail = true; } foreach(Rail R in Administration.GetRailList) { if(R.Id == Convert.ToInt32(T["spoorid"])) { rail = R; } } Tram t = new Tram(Convert.ToInt32(T["tramid"]), (string)T["type"], rail, LoggedInUser, status, onRail); GetTramList.Add(t); } }
/// <summary> /// notimplemented /// </summary> /// <param name="tram"></param> /// <returns></returns> public string ChangeTramStatus(Tram tram) { throw new NotImplementedException(); }
public void UpdateTramList() { foreach (Dictionary<string, object> T in addatabase.GetAllTrams()) { Rail rail = null; int status = 0; bool onRail = false; if ((string)T["status"] == "Ok") { status = 1; } if ((string)T["status"] == "Vies") { status = 2; } if ((string)T["status"] == "Defect") { status = 3; } if ((string)T["status"] == "ViesEnDefect") { status = 4; } if (Convert.ToInt32(T["aanwezigopspoor"]) == 0) { onRail = false; } else { onRail = true; } foreach (Rail R in Administration.GetRailList) { if (R.Id == Convert.ToInt32(T["spoorid"])) { rail = R; } } Tram t = new Tram(Convert.ToInt32(T["tramid"]), (string)T["type"], rail, LoggedInUser, status, onRail); GetTramList.Add(t); } }
/// <summary> /// notimplemented /// </summary> /// <param name="tram"></param> /// <returns></returns> public bool TramToDepartment(Tram tram) { throw new NotImplementedException(); }
/// <summary> /// not implemented /// </summary> /// <param name="tram"></param> /// <returns></returns> public bool MoveTram(Tram tram) { throw new NotImplementedException(); }
/// <summary> /// occurs when the button toevoegen is clicked /// </summary> /// <param name="sender">the control that was pressed</param> /// <param name="e"></param> private void btnToevoegenToevoegen_Click(object sender, EventArgs e) { int tramOnRail = 0; int status = 0; if (cbToevoegenStatus.Text == "Ok") { status = 1; } if (cbToevoegenStatus.Text == "Vies") { status = 2; } if (cbToevoegenStatus.Text == "Defect") { status = 3; } if (cbToevoegenStatus.Text == "Vies en defect") { status = 4; } if (cbTramOnRail.Checked) { tramOnRail = 1; } Tram tram = new Tram(1, "test", new Rail(1, true, false, 1), new User(2323, "test", "test", 1), 1, true); Control c = groupBox1.Controls.Find("spoor" + Convert.ToInt32(cbToevoegenLocatie.Text), true).FirstOrDefault(); if (c.BackColor == Color.White) { if (tram.AddTram(Convert.ToInt32(tbToevoegenNaam.Text), Convert.ToInt32(cbToevoegenLocatie.Text), status, tramOnRail) == true) { if (tramOnRail == 1) { c.Text = tbToevoegenNaam.Text; c.BackColor = Color.DimGray; tram.OnRail = true; } administration.UpdateTramList(); //remiseRefresh(); } } else { MessageBox.Show("Kan hier geen tram plaatsen!"); } }
/// <summary> /// occurs when the button btnDetailsVerwijderen is clicked /// </summary> /// <param name="sender">the control that was pressed</param> /// <param name="e"></param> private void btnDetailsVerwijderen_Click(object sender, EventArgs e) { Tram tram = new Tram(1, "test", new Rail(1, true, false, 1), new User(2323, "test", "test", 1), 1, true); if (tram.DeleteTram(Convert.ToInt32(tbDetailsNaam.Text)) == true) { Control c = groupBox1.Controls.Find("spoor" + Convert.ToInt32(cbDetailsLocatie.Text), true).FirstOrDefault(); c.Text = ""; c.BackColor = Color.White; } }
/// <summary> /// occurs when the button btnDetailsAanpassen is clicked /// </summary> /// <param name="sender">the control that was pressed</param> /// <param name="e"></param> private void btnDetailsAanpassen_Click(object sender, EventArgs e) { Tram tram = new Tram(1, "test", new Rail(1, true, false, 1), new User(2323, "test", "test", 1), 1, true); int status = 0; if (cbDetailsStatus.Text == "Ok") { status = 1; } if (cbDetailsStatus.Text == "Vies") { status = 2; } if (cbDetailsStatus.Text == "Defect") { status = 3; } if (cbDetailsStatus.Text == "Vies en defect") { status = 4; } if (tram.MoveTram(Convert.ToInt32(tbDetailsNaam.Text), Convert.ToInt32(cbDetailsLocatie.Text), status) == true) { foreach (Control control in groupBox1.Controls) { if (control.Text == tbDetailsNaam.Text) { control.Text = ""; control.BackColor = Color.White; } } Control c = groupBox1.Controls.Find("spoor" + Convert.ToInt32(cbDetailsLocatie.Text), true).FirstOrDefault(); c.Text = tbDetailsNaam.Text; c.BackColor = Color.DimGray; } }