Exemplo n.º 1
0
        public void LoadDoUong(string maDanhMuc)
        {
            var ResourceManager = new System.Resources.ResourceManager("ThietKeChucNang.Properties.Resources", typeof(Resources).Assembly);

            foreach (var item in bllBanHang.LoadDoUong(maDanhMuc))
            {
                Panel pnlDoUongItem = new Panel();
                pnlDoUongItem.Width  = 150;
                pnlDoUongItem.Height = 250;

                Label lblGiaBan = new Label();
                lblGiaBan.Text      = item.Gia.ToString() + " VNĐ";
                lblGiaBan.ForeColor = Color.Red;
                lblGiaBan.Dock      = DockStyle.Top;
                lblGiaBan.Font      = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                Label lblTenDoUong = new Label();
                lblTenDoUong.Text = item.TenDoUong.ToString();
                lblTenDoUong.Dock = DockStyle.Top;
                lblTenDoUong.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                //Label lblMaDoUong = new Label();
                //lblMaDoUong.Text = item.MaDoUong.ToString();
                //lblMaDoUong.ForeColor = Color.BlueViolet;
                //lblMaDoUong.Dock = DockStyle.Top;
                //lblMaDoUong.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                PictureBox picDoUongItem = new PictureBox();
                picDoUongItem.Width     = 150;
                picDoUongItem.Height    = 150;
                picDoUongItem.BackColor = Color.FromArgb(255, 87, 34);
                picDoUongItem.Dock      = DockStyle.Top;
                picDoUongItem.SizeMode  = PictureBoxSizeMode.StretchImage;
                //object obj = ResourceManager.GetObject(item.HinhMinhHoa.ToString());
                //picDoUongItem.BackgroundImage = ((System.Drawing.Bitmap)(obj));
                try
                {
                    //string path = @"D:\ThucHanh\PhatTrienPhanMem\QuanLyQuanCafe\Images\DoUong\";
                    picDoUongItem.Image = Image.FromFile(imagesPath + item.HinhMinhHoa.ToString());
                }
                catch (Exception)
                {
                    picDoUongItem.Image = null;
                }
                Button btnAddToBill = new Button();
                btnAddToBill.Width     = 150;
                btnAddToBill.Height    = 35;
                btnAddToBill.BackColor = Color.Green;
                btnAddToBill.Text      = "+";
                btnAddToBill.Font      = new System.Drawing.Font("Microsoft Sans Serif", 13.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                btnAddToBill.TextAlign = ContentAlignment.MiddleCenter;
                btnAddToBill.FlatStyle = FlatStyle.Flat;
                btnAddToBill.FlatAppearance.BorderSize = 0;
                btnAddToBill.Cursor = Cursors.Hand;
                btnAddToBill.Dock   = DockStyle.Top;
                btnAddToBill.Name   = item.MaDoUong.ToString();
                btnAddToBill.Tag    = item.Gia.ToString();
                btnAddToBill.Click += BtnAddToBill_Click;


                pnlDoUongItem.Controls.Add(btnAddToBill);
                pnlDoUongItem.Controls.Add(lblGiaBan);
                pnlDoUongItem.Controls.Add(lblTenDoUong);
                //pnlDoUongItem.Controls.Add(lblMaDoUong);
                pnlDoUongItem.Controls.Add(picDoUongItem);


                fpnlDoUong.Controls.Add(pnlDoUongItem);
            }
        }