Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string plate_number = textBox1.Text;

            //JSON is disko
            DataExtraction de = new DataExtraction();

            json = de.GetJsonFromDisk();

            bool found = false;

            foreach (var obj in json.plates)
            {
                if (obj.p_number == plate_number)
                {
                    found = true;
                }
            }

            if (found)
            {
                label1.Text      = "Vehicle wanted";
                label1.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                label1.Text      = "No records found";
                label1.ForeColor = System.Drawing.Color.Black;
            }
        }
Esempio n. 2
0
        public void refrestView()
        {
            labelsOwners  = new Label[10];
            licensePlates = new Label[10];
            delete        = new PictureBox[10];

            records1 = new List <PlateRecord>();

            DataExtraction de = new DataExtraction();

            obj = de.GetJsonFromDisk();

            foreach (var json in obj.plates)
            {
                records1.Add(new PlateRecord((String)json.owner, (String)json.id, (String)json.p_number, (String)json.e_number, (String)json.b_number));
            }

            for (int a = 0; a < 10; a++)
            {
                if (records1.Count > a)
                {
                    labelsOwners[a] = new Label
                    {
                        Text     = records1[a].Owner,
                        Location = new System.Drawing.Point(165, a * 25 + 38),
                        Font     = new System.Drawing.Font("Verdana", 14)
                    };
                    this.Controls.Add(labelsOwners[a]);

                    licensePlates[a] = new Label
                    {
                        Text     = records1[a].P_number,
                        Location = new System.Drawing.Point(10, a * 25 + 38),
                        Font     = new System.Drawing.Font("Verdana", 14)
                    };
                    this.Controls.Add(licensePlates[a]);

                    delete[a] = new PictureBox
                    {
                        Location = new System.Drawing.Point(280, a * 25 + 38),
                        Image    = Image.FromFile("../../../Resources/trashbin.png"),
                        Size     = new Size(20, 20),
                        SizeMode = PictureBoxSizeMode.StretchImage,
                        Name     = a.ToString()
                    };
                    this.Controls.Add(delete[a]);

                    delete[a].Click += (e, s) => {
                        PictureBox p = (PictureBox)e;
                        obj.plates[Int32.Parse(p.Name)].Remove();
                        de.writeToJson(obj.ToString());

                        this.Close();
                        (new ControlPanel()).Show();
                    };
                }
            }
        }
Esempio n. 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            string license_plate = textBox1.Text;
            string owner         = textBox3.Text;
            string engine_number = textBox2.Text;
            string body_number   = textBox4.Text;

            DataExtraction de   = new DataExtraction();
            dynamic        json = de.GetJsonFromDisk();

            JObject record = new JObject();

            record["owner"]    = owner;
            record["p_number"] = license_plate;
            record["e_number"] = engine_number;
            record["b_number"] = body_number;
            record["id"]       = json.plates.Count + 1;

            json.plates.Add(record);
            de.writeToJson(json.ToString());

            this.Close();
            cp.refrestView();
        }