コード例 #1
0
        private void NewDevice(object sender, EventArgs e)
        {
            int nextid = Convert.ToInt32(Session["nextID"]);
            filtr = Convert.ToString(Session["Filtr"]);

            switch (filtr)
            {
                case "Lamp":

                    Lamp newLamp;
                    newLamp = new Lamp("Лампа " + nextid, false, 50);
                    deviceList.Add(nextid, newLamp);
                    DevicePanel.Controls.Add(new FormForDevice(nextid, deviceList));


                    break;

                case "Fridge":

                    Fridge newFridge;
                    newFridge = new Fridge("Холодильник " + nextid, false, false, 1);
                    deviceList.Add(nextid, newFridge);
                    DevicePanel.Controls.Add(new FormForDevice(nextid, deviceList));

                    break;

                case "TR":

                    TapeRecoder newTR;
                    newTR = new TapeRecoder("Музыкальный центр " + nextid, false, false, 20);
                    deviceList.Add(nextid, newTR);
                    DevicePanel.Controls.Add(new FormForDevice(nextid, deviceList));

                    break;

                case "Cond":

                    Conditioner newCond;
                    newCond = new Conditioner("Кондиционер " + nextid, false, 2);
                    deviceList.Add(nextid, newCond);
                    DevicePanel.Controls.Add(new FormForDevice(nextid, deviceList));

                    break;

                case "TV":

                    TeleVision newTV;

                    newTV = new TeleVision("Телевизор " + nextid, false, 50);
                    deviceList.Add(nextid, newTV);
                    DevicePanel.Controls.Add(new FormForDevice(nextid, deviceList));

                    break;

                case "Kettle":

                    Kettle newKettle;

                    newKettle = new Kettle("Чайник " + nextid, false);
                    deviceList.Add(nextid, newKettle);
                    DevicePanel.Controls.Add(new FormForDevice(nextid, deviceList));

                    break;
            }



            nextid++;
            Session["nextID"] = nextid;
        }
コード例 #2
0
        private void NewDevice(object sender, EventArgs e)
        {
            int nextid = Convert.ToInt32(Session["nextID"]);

            filtr = Convert.ToString(Session["Filtr"]);

            switch (filtr)
            {
            case "Lamp":

                Lamp newLamp;
                newLamp = new Lamp("Лампа " + nextid, false, 50);
                deviceList.Add(nextid, newLamp);
                DevicePanel.Controls.Add(new FormForDevice(nextid, deviceList));


                break;

            case "Fridge":

                Fridge newFridge;
                newFridge = new Fridge("Холодильник " + nextid, false, false, 1);
                deviceList.Add(nextid, newFridge);
                DevicePanel.Controls.Add(new FormForDevice(nextid, deviceList));

                break;

            case "TR":

                TapeRecoder newTR;
                newTR = new TapeRecoder("Музыкальный центр " + nextid, false, false, 20);
                deviceList.Add(nextid, newTR);
                DevicePanel.Controls.Add(new FormForDevice(nextid, deviceList));

                break;

            case "Cond":

                Conditioner newCond;
                newCond = new Conditioner("Кондиционер " + nextid, false, 2);
                deviceList.Add(nextid, newCond);
                DevicePanel.Controls.Add(new FormForDevice(nextid, deviceList));

                break;

            case "TV":

                TeleVision newTV;

                newTV = new TeleVision("Телевизор " + nextid, false, 50);
                deviceList.Add(nextid, newTV);
                DevicePanel.Controls.Add(new FormForDevice(nextid, deviceList));

                break;

            case "Kettle":

                Kettle newKettle;

                newKettle = new Kettle("Чайник " + nextid, false);
                deviceList.Add(nextid, newKettle);
                DevicePanel.Controls.Add(new FormForDevice(nextid, deviceList));

                break;
            }



            nextid++;
            Session["nextID"] = nextid;
        }