コード例 #1
0
        /// <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);
            }
        }
コード例 #2
0
ファイル: Tram.cs プロジェクト: marouanopen/ICT4Reals
 /// <summary>
 /// Creation of a new tram
 /// </summary>
 /// <param name="id">id of the tram</param>
 /// <param name="type">tram type</param>
 /// <param name="rail">rail on which the tram should be placed on</param>
 /// <param name="driver">the driver of the tram</param>
 /// <param name="status">1= OK 2= Dirty 3= Defect 4= DirtyAndDefect</param>
 public Tram(int id, string type, Rail rail, User driver, int status, bool onRail)
 {
     this.Id = id;
     this.Type = type;
     this.Rail = rail;
     this.Driver = driver;
     Status = (Status)status;
     OnRail = onRail;
 }
コード例 #3
0
 /// <summary>
 /// not implemented
 /// </summary>
 /// <param name="rail"></param>
 /// <returns></returns>
 public bool BlockRail(Rail rail)
 {
     throw new NotImplementedException();
 }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: marouanopen/ICT4Reals
 /// <summary>
 /// accurs when button "btnSpoorStatusAanpassen" is clicked
 /// </summary>
 /// <param name="sender">the control that was pressed</param>
 /// <param name="e"></param>
 private void btnSpoorStatusAanpassen_Click(object sender, EventArgs e)
 {
     Rail rail = new Rail(Convert.ToInt32(cbSpoorStatusSpoor.SelectedValue), false, false, 1);
     int status = 0;
     if (cbSpoorStatusStatus.Text == "Blokkeer")
     {
         status = 1;
         Control c = groupBox1.Controls.Find("spoor" + Convert.ToInt32(cbSpoorStatusSpoor.Text), true).FirstOrDefault();
         if (c.BackColor != Color.DarkRed)
         {
             if (rail.BlockRail(Convert.ToInt32(cbSpoorStatusSpoor.Text), status) == true)
             {
                 c.BackColor = Color.DarkRed;
             }
         }
         else if (c.BackColor == Color.DarkRed)
         {
             MessageBox.Show("Rails is al geblokkeerd!");
         }
     }
     if (cbSpoorStatusStatus.Text == "Deblokkeer")
     {
         status = 0;
         Control c = groupBox1.Controls.Find("spoor" + Convert.ToInt32(cbSpoorStatusSpoor.Text), true).FirstOrDefault();
         if (c.BackColor != Color.White)
         {
             if (rail.BlockRail(Convert.ToInt32(cbSpoorStatusSpoor.Text), status) == true)
             {
                 c.BackColor = Color.White;
             }
         }
         else if (c.BackColor == Color.White)
         {
             MessageBox.Show("Rails is al gedeblokkeerd!");
         }
     }
 }