private HtmlGenericControl generateDevice(Device device, DatabaseEntities db)
        {
            var brandQuery = db.Brands.Where(b => b.brand_id == device.brand_id);
            var brand = brandQuery.FirstOrDefault<Brand>();

            var operatingSystemQuery = db.OperatingSystems.Where(b => b.operating_system_id == device.operating_system_id);
            var operatingSystem = operatingSystemQuery.FirstOrDefault<OperatingSystem>();

            var displayQuery = db.Displays.Where(b => b.display_id == device.display_id);
            var display = displayQuery.FirstOrDefault<Display>();

            HtmlGenericControl deviceDiv = new HtmlGenericControl("DIV");
            deviceDiv.Attributes["class"] = "device";

            //HtmlGenericControl anchorFirst = new HtmlGenericControl("a");
            HtmlAnchor anchorFirst = new HtmlAnchor();
            anchorFirst.HRef = String.Format("~/device.aspx?id={0}", device.device_id);

            HtmlImage img = new HtmlImage();
            img.Src = String.Format("~/images/{0}/{1} {2} .jpg", brand.name, brand.name, device.device_name);

            anchorFirst.Controls.Add(img);

            HtmlGenericControl h2 = new HtmlGenericControl("h2");
            //HtmlGenericControl anchorSecond = new HtmlGenericControl("a");
            HtmlAnchor anchorSecond = new HtmlAnchor();
            anchorSecond.HRef = String.Format("~/device.aspx?id={0}", device.device_id);
            anchorSecond.InnerText = String.Format("{0} {1}", brand.name, device.device_name);
            h2.Controls.Add(anchorSecond);

            HtmlGenericControl p = new HtmlGenericControl("p");
            p.InnerText = String.Format("{0}, экран {1}, {2} ( {3} ), ОЗУ {4}, аккумулятор {5}",
                operatingSystem.name, device.screen_size, display.type, device.screen_resolution, device.ram, device.battery_capacity);

            HtmlGenericControl clrDiv = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
            clrDiv.Attributes["class"] = "clr";

            HtmlGenericControl priceDiv = new HtmlGenericControl("DIV");
            priceDiv.Attributes["class"] = "price";
            priceDiv.InnerText = String.Format("{0}", device.price);

            deviceDiv.Controls.Add(anchorFirst);
            deviceDiv.Controls.Add(h2);
            deviceDiv.Controls.Add(p);
            deviceDiv.Controls.Add(clrDiv);
            deviceDiv.Controls.Add(priceDiv);

            return deviceDiv;
        }
Beispiel #2
0
        private HtmlGenericControl generateDevice(Device device, DatabaseEntities db)
        {
            var brandQuery = db.Brands.Where(b => b.brand_id == device.brand_id);
            var brand = brandQuery.FirstOrDefault<Brand>();

            var batteryQuery = db.Batteries.Where(b => b.battery_id == device.battery_id);
            var battery = batteryQuery.FirstOrDefault<Battery>();

            var displayQuery = db.Displays.Where(b => b.display_id == device.display_id);
            var display = displayQuery.FirstOrDefault<Display>();

            var operatingSystemQuery = db.OperatingSystems.Where(b => b.operating_system_id == device.operating_system_id);
            var operatingSystem = operatingSystemQuery.FirstOrDefault<OperatingSystem>();

            var processorQuery = db.Processors.Where(b => b.processor_id == device.processor_id);
            var processor = processorQuery.FirstOrDefault<Processor>();

            var flashToDeviceQuery = db.FlashToDevices.Where(b => b.device_id == device.device_id);
            List<FlashToDevice> flashToDeviceList = flashToDeviceQuery.ToList<FlashToDevice>();
            string flashTypes = "";

            foreach (FlashToDevice type in flashToDeviceList)
            {
                var flashQuery = db.Flashes.Where(b => b.flash_id == type.flash_id);
                var flash = flashQuery.FirstOrDefault<Flash>();
                flashTypes += flash.type + " ";
            }
            if (flashTypes.Trim() == "")
                flashTypes = "Отсутсвует";

            HtmlGenericControl result = new HtmlGenericControl("div");

            HtmlGenericControl descriptionDiv = new HtmlGenericControl("div");
            descriptionDiv.Attributes["class"] = "device";
            HtmlImage img = new HtmlImage();
            img.Src = String.Format("~/images/{0}/{1} {2} .jpg", brand.name, brand.name, device.device_name);

            HtmlGenericControl h2 = new HtmlGenericControl("h2");
            h2.InnerText = "Описание";

            HtmlGenericControl pAboutBrand = new HtmlGenericControl("p");
            pAboutBrand.InnerText = String.Format("{0}", brand.information);

            //HtmlGenericControl pShortInformation = new HtmlGenericControl("p");
            //pShortInformation.InnerText = String.Format("{0}, экран {1}, {2} ( {3} ), ОЗУ {4}, аккумулятор {5}",
            //    operatingSystem.name, device.screen_size, display.type, device.screen_resolution, device.ram, device.battery_capacity);

            HtmlGenericControl clrDiv = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
            clrDiv.Attributes["class"] = "clr";

            HtmlGenericControl priceDiv = new HtmlGenericControl("DIV");
            priceDiv.Attributes["class"] = "price";
            priceDiv.InnerText = String.Format("{0}", device.price);

            descriptionDiv.Controls.Add(img);
            descriptionDiv.Controls.Add(h2);
            descriptionDiv.Controls.Add(pAboutBrand);
            //descriptionDiv.Controls.Add(pShortInformation);
            descriptionDiv.Controls.Add(clrDiv);
            descriptionDiv.Controls.Add(priceDiv);

            HtmlGenericControl h2Descr = new HtmlGenericControl("h2");
            h2Descr.InnerText = "Характеристики";

            result.Controls.Add(descriptionDiv);
            result.Controls.Add(h2Descr);

            HtmlGenericControl tableGeneral = new HtmlGenericControl("table");
            string[] keysGeneral = { "Производитель", "Операционная система", "Год выпуска"};
            string[] valuesGeneral = { brand.name, operatingSystem.name, device.release_year };
            tableGeneral = createTable("Общее", keysGeneral, valuesGeneral);
            result.Controls.Add(tableGeneral);

            HtmlGenericControl tableDisplay = new HtmlGenericControl("table");
            string[] keysDisplay = { "Тип дисплея", "Размер экрана", "Разрешение экрана", "Информация о техологии дисплея"};
            string[] valuesDisplay = { display.type, device.screen_size, device.screen_resolution, display.information };
            tableDisplay = createTable("Дисплей", keysDisplay, valuesDisplay);
            result.Controls.Add(tableDisplay);

            HtmlGenericControl tableProcessor = new HtmlGenericControl("table");
            string[] keysProcessor = { "Тип процессора" };
            string[] valuesProcessor = new string[1];
            if (processor == null)
                valuesProcessor[0] = "Неизвестно";
            else
                valuesProcessor[0] = processor.name;
            tableProcessor = createTable("Процессор", keysProcessor, valuesProcessor);
            result.Controls.Add(tableProcessor);

            HtmlGenericControl tableMemory = new HtmlGenericControl("table");
            string[] keysMemory = { "Оперативная память", "Встроенная память", "Поддержка карт памяти" };
            string[] valuesMemory = { device.ram, device.internal_memory, flashTypes};
            tableMemory = createTable("Память", keysMemory, valuesMemory);
            result.Controls.Add(tableMemory);

            HtmlGenericControl tableBattery = new HtmlGenericControl("table");
            string[] keysBattery = { "Тип батареи", "Eмкость батареи", "Информация о технологии батареи" };
            string[] valuesBatery = { battery.type, device.battery_capacity, battery.information };
            tableBattery = createTable("Батарея", keysBattery, valuesBatery);
            result.Controls.Add(tableBattery);

            return result;
        }
Beispiel #3
0
        private void loadSideBar(Device device, DatabaseEntities db)
        {
            var brandQuery = db.Brands.Where(b => b.brand_id == device.brand_id);
            var brand = brandQuery.FirstOrDefault<Brand>();

            HtmlGenericControl title = new HtmlGenericControl("div");
            //HtmlGenericControl a = new HtmlGenericControl("a");
            HtmlAnchor a = new HtmlAnchor();
            a.HRef = String.Format("~/?brand={0}", brand.name);
            a.InnerText = brand.name;

            title.Attributes["class"] = "title";
            title.Controls.Add(a);

            HtmlGenericControl ul = new HtmlGenericControl("ul");

            List<Device> devicesList = db.Devices.Where(b => b.brand_id == device.brand_id).ToList<Device>();
            foreach (Device item in devicesList)
            {
                HtmlGenericControl li = new HtmlGenericControl("li");
                //HtmlGenericControl anchor = new HtmlGenericControl("a");
                HtmlAnchor anchor = new HtmlAnchor();
                anchor.HRef = String.Format("~/Device.aspx?id={0}", item.device_id);
                anchor.InnerText = String.Format("{0}", item.device_name);

                li.Controls.Add(anchor);
                ul.Controls.Add(li);
            }
            sidebar.Controls.Add(title);
            sidebar.Controls.Add(ul);
        }
Beispiel #4
0
        private void loadDevicePath(Device device, DatabaseEntities db)
        {
            var brandQuery = db.Brands.Where(b => b.brand_id == device.brand_id);
            var brand = brandQuery.FirstOrDefault<Brand>();

            HtmlImage firstArrow = new HtmlImage();
            firstArrow.Src = "~/images/directory_arrow.png";
            HtmlGenericControl brandDiv = new HtmlGenericControl("div");
            brandDiv.Attributes["class"] = "directory_path";
            //HtmlGenericControl brandAnchor = new HtmlGenericControl("a");
            HtmlAnchor brandAnchor = new HtmlAnchor();
            brandAnchor.HRef = "~/?brand=" + brand.name;
            brandAnchor.Attributes["id"] = "firstDirectory";
            brandAnchor.InnerText = brand.name;
            brandDiv.Controls.Add(brandAnchor);

            HtmlImage secondArrow = new HtmlImage();
            secondArrow.Src = "~/images/directory_arrow.png";

            HtmlGenericControl deviceDiv = new HtmlGenericControl("div");
            deviceDiv.Attributes["class"] = "directory_path";
            //HtmlGenericControl deviceAnchor = new HtmlGenericControl("a");
            HtmlAnchor deviceAnchor = new HtmlAnchor();
            deviceAnchor.HRef = "~/Device.aspx?id=" + device.device_id;
            deviceAnchor.Attributes["id"] = "secondDirectory";
            deviceAnchor.InnerText = device.device_name;
            deviceDiv.Controls.Add(deviceAnchor);

            path.Controls.Add(firstArrow);
            path.Controls.Add(brandDiv);
            path.Controls.Add(secondArrow);
            path.Controls.Add(deviceDiv);
        }