Beispiel #1
0
        private void AddUC_Load(object sender, EventArgs e)
        {
            //samo prvo ispisivanje mesta iz baze (brojac k obezbedjuje samo jedan ulazak u ovaj deo koda)
            if (k == 0)
            {
                SqlConnection  con = new SqlConnection("data source=DESKTOP-L1JRQG0;initial catalog=parking_servis;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"");
                SqlDataAdapter sda = new SqlDataAdapter("Select * From parkingmesto; ", con);
                DataTable      dt  = new DataTable();
                sda.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    int i = 0;
                    while (i < dt.Rows.Count)
                    {
                        mesta m = new mesta();
                        m.oznaka         = dt.Rows[i][0].ToString();
                        m.trenutnoStanje = int.Parse(dt.Rows[i][1].ToString());
                        m.id             = int.Parse(dt.Rows[i][2].ToString());
                        m.x = int.Parse(dt.Rows[i][3].ToString());
                        m.y = int.Parse(dt.Rows[i][4].ToString());

                        int orijentacija = int.Parse(dt.Rows[i][6].ToString());

                        int x_pos = m.x;
                        int y_pos = m.y;

                        IconButton btn = new IconButton();
                        //iscrtavanje standardnih mesta A1-A5, A10-A24
                        if (orijentacija == 0)
                        {
                            btn.Location = new Point(m.x, m.y);
                            btn.Name     = m.oznaka;
                            //  btn.Text = m.oznaka;
                            btn.Size = new Size(80, 45);
                            btn.BringToFront();
                        }
                        else
                        {
                            btn.Location = new Point(m.x, m.y);
                            btn.Name     = m.oznaka;
                            //btn.Text = m.oznaka;
                            btn.Size = new Size(48, 80);
                            btn.BringToFront();
                            btn.BackColor = Color.Green;
                        }
                        if (m.trenutnoStanje == 0)
                        {
                            btn.BackColor = Color.Green;
                        }
                        else
                        {
                            btn.IconChar  = IconChar.CarSide;
                            btn.IconColor = Color.Red;
                            btn.IconSize  = 45;
                            // btn.BackColor = Color.Red;
                        }

                        this.Controls.Add(btn);
                        listamesta.Add(m);
                        i++;
                        //brojac mesta u bazi
                        count++;
                    }
                    k = 1;          //ispisana su sva mesta zatecena u bazi --> ne ulazi vise ovde
                    count++;        //prebrojana su sva mesta prvobitno zatecena u bazi, postavi brojac id na vrednost sledeceg
                }
                else
                {
                    MessageBox.Show("Error loading parking space");
                }
            }
        }
Beispiel #2
0
        private void User_Load(object sender, EventArgs e)
        {
            SqlConnection  con = new SqlConnection("data source=AMINA;initial catalog=parking_servis;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;");
            SqlDataAdapter sda = new SqlDataAdapter("Select * From parkingmesto; ", con);
            DataTable      dt  = new DataTable();

            sda.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                int i = 0;
                while (i < dt.Rows.Count)
                {
                    mesta m = new mesta();
                    m.oznaka         = dt.Rows[i][0].ToString();
                    m.trenutnoStanje = int.Parse(dt.Rows[i][1].ToString());
                    m.id             = int.Parse(dt.Rows[i][2].ToString());
                    m.x = int.Parse(dt.Rows[i][3].ToString());
                    m.y = int.Parse(dt.Rows[i][4].ToString());

                    int orijentacija = int.Parse(dt.Rows[i][6].ToString());

                    int x_pos = m.x;
                    int y_pos = m.y;

                    Button btn = new Button();

                    if (orijentacija == 0)
                    {
                        btn.Location = new Point(m.x, m.y);
                        btn.Name     = m.oznaka;
                        btn.Text     = m.oznaka;
                        btn.Size     = new Size(80, 45);
                        btn.BringToFront();
                        btn.Click += new EventHandler(this.button_click);
                    }
                    else
                    {
                        btn.Location = new Point(m.x, m.y);
                        btn.Name     = m.oznaka;
                        btn.Text     = m.oznaka;
                        btn.Size     = new Size(48, 80);
                        btn.BringToFront();
                        btn.BackColor = Color.Transparent;
                        btn.Click    += new EventHandler(this.button_click);
                    }
                    if (m.trenutnoStanje == 0)
                    {
                        btn.BackColor = Color.Transparent;
                    }
                    else
                    {
                        btn.BackColor = Color.Red;
                    }

                    this.Controls.Add(btn);
                    listamesta.Add(m);
                    i++;
                }
            }
            else
            {
                MessageBox.Show("Error loading parking space");
            }
        }