예제 #1
0
파일: TileBuilder.cs 프로젝트: Oman/Maleos
 public void AddTileItem(string groupName, string tileName, string htmlContent)
 {
     DevExpress.XtraEditors.TileItem item = new DevExpress.XtraEditors.TileItem();
     foreach (TileGroup group in Tile.Groups) {
         if (groupName.Equals(group.Name)) {
             item.Name = tileName;
             item.Text = htmlContent;
             item.IsLarge = true;
             group.Items.Add(item);
         }
     }
 }
        private void timKiem()
        {
            this.tileGroup1.Items.Clear();
            MatHang matHang = new MatHang();
            matHang.TenMatHang = this.teTenSanPham.Text;

            matHang.MaLoaiMatHang = this.lueLoaiSanPham.EditValue == null ? "" : this.lueLoaiSanPham.EditValue.ToString();
            matHang.MaNhaSanXuat = this.lueNhaSX.EditValue == null ? "" : this.lueNhaSX.EditValue.ToString();

            DataTable data = _MatHangBUS.TimKiemMatHangDonGian(matHang);

            for (int i = 0; i < data.Rows.Count; i++)
            {
                DevExpress.XtraEditors.TileItem tileItem1 = new DevExpress.XtraEditors.TileItem();
                DevExpress.XtraEditors.TileItemElement tileItemElement1 = new DevExpress.XtraEditors.TileItemElement();

                tileItem1.Id = i;
                tileItem1.ItemSize = DevExpress.XtraEditors.TileItemSize.Large;
                tileItemElement1.TextAlignment = TileItemContentAlignment.TopLeft;
                DataTable dt = _HinhAnhBUS.LayHinhMatHang(data.Rows[i].ItemArray[0].ToString());
                if (dt != null && dt.Rows.Count > 0)
                {
                    tileItem1.BackgroundImage = Base64ToImage(dt.Rows[0].ItemArray[0].ToString());
                    tileItem1.BackgroundImageScaleMode = DevExpress.XtraEditors.TileItemImageScaleMode.Stretch;
                }
                else
                {
                    tileItem1.BackgroundImage = Image.FromFile("Resources\\defaultimg.png");
                    tileItem1.BackgroundImageScaleMode = DevExpress.XtraEditors.TileItemImageScaleMode.Stretch;
                }
                tileItem1.Image = global::QuanLyCuaHangLinhKienDienThoai.Properties.Resources.blackboard1;
                tileItem1.ImageScaleMode = DevExpress.XtraEditors.TileItemImageScaleMode.NoScale;
                tileItem1.ImageAlignment = DevExpress.XtraEditors.TileItemContentAlignment.MiddleCenter;

                CauHinhDienThoai ch = _CauHinhDienThoaiBUS.LayCauHinhByMaMatHang(data.Rows[i].ItemArray[0].ToString());

                tileItemElement1.Text = data.Rows[i].ItemArray[1].ToString() + "\n";
                if (ch != null)
                {
                    if (data.Rows[i].ItemArray[3].ToString().CompareTo("Điện thoại") == 0)
                    {
                        tileItemElement1.Text += "Kích thước màn hình: " + ch.KichThuocManHinh + " inch\n";
                        tileItemElement1.Text += "Số Sim: " + ch.SoSim + "\n";
                        tileItemElement1.Text += "Bộ nhớ ram: " + ch.Ram + " MB\n";
                        tileItemElement1.Text += "Hệ điều hành: " + ch.HeDieuHanh + "\n";
                        tileItemElement1.Text += "Bộ nhớ trong: " + ch.BoNho + "MB\n";
                        tileItemElement1.Text += "Dung lượng pin: " + ch.DungLuongPin + " mAh\n";
                    }

                    MatHang mh = new MatHang();
                    mh.MaMatHang = data.Rows[i].ItemArray[0].ToString();
                    DataTable dt3 = _MatHangBUS.LayThongTinDonGiaVaNhaSanXuat(mh);
                    decimal giatien = 0;
                    if (dt3 != null&&dt3.Rows.Count >0)
                    {
                        giatien = Convert.ToDecimal(dt3.Rows[0].ItemArray[5].ToString());
                    }
                    tileItemElement1.Text += "Giá: " + giatien.ToString("0.00").Replace(".00", "") +" VNĐ\n";
                }

                tileItem1.Name = tileItemElement1.Text;
                tileItem1.Elements.Add(tileItemElement1);
                this.tileGroup1.Items.Add(tileItem1);
            }
        }