예제 #1
0
 //Hàm load form Giỏ hàng
 private void GioHang_Load(object sender, EventArgs e)
 {
     resizeForm();                              // resizeForm
     setupUIFlowlayoutPanel();                  //Đổ dữ liệu vào FlowlayoutPanel
     listGioHangTemp = parent.ListGioHang;      // gán giá trị của Listgiohangtemp bằng giá trị ListGiohang trong MainPage
     reloadTotalPrice();                        // load lại tổng giá
     listProduct = productBAL.GetDataProduct(); // gán dữ liệu từ GetDataProduct vào ListProduct
     enablePay();                               // cho biến button hiện
 }
예제 #2
0
        //setup gia dien nguoi dùng (phần danh sách sản phẩm trong panel main)
        private void SetupUI()
        {
            //lay thong tin tat ca sản pham
            ProductList = productBAL.GetDataProduct();
            //duyen tat ca san pham trong danh sach
            for (int i = 0; i < ProductList.Count; i++)
            {

                //danh sach co hinh dang nhu sau
                //la 1 flowlayoutpanel
                //gom nhieu panel nhu the nay

                /*---------------------
                 * -   picturebox     -
                 * -                  -
                 * -                  -
                 * -                  -
                 * -                  -
                 * --------------------
                 * -    label ten sp  -
                 * --------------------
                 * -     label gia    -
                 * --------------------*/

                //tao 1 panel chua ptb, label name, label gia
                Panel pnl = new Panel();
                //dinh dang height width
                pnl.Width = Convert.ToInt32(250);
                pnl.Height = Convert.ToInt32(fpnlProduct.Height / 2);

                
                
                //tao moi 1 ptb va dinh dang height width
                PictureBox ptb = new PictureBox();
                ptb.Location = pnl.Location;
                ptb.Height = Convert.ToInt32(pnl.Height * 0.7);
                ptb.Width = pnl.Width;
                ptb.SizeMode = PictureBoxSizeMode.Zoom;
                //load hình với sizemode là zoom
                ptb.LoadAsync(ProductList[i].LinkImg);
                //gan tag bang vi tri cua no trong danh sach sản phẩm
                ptb.Tag = i.ToString();
                //add ptb vao panel 
                pnl.Controls.Add(ptb);
                //tao action click vao hình se hien len thong tin chi tiet
                ptb.Click += Picturebox_click;
                //tao 1 label name va dinh vi vi tri x = bang voi vi tri x cua panel cha, y= chieu cao cua picturebox , height va width
                Label lbName = new Label();
                lbName.Location = new Point(Convert.ToInt32(pnl.Location.X), pnl.Location.Y + ptb.Height);
                lbName.Width = pnl.Width;
                lbName.Height = Convert.ToInt32(pnl.Height * 0.15);
                lbName.Text = ProductList[i].ProductName;//lay ten sản pham tu i trong danh sach sp
                lbName.Font = new Font("Arial", 15, FontStyle.Regular);
                lbName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // alight center
                pnl.Controls.Add(lbName);//them lbname vao panel
                //label gia tương tự . có vấn đề liên hệ Lê Anh Đức gmail: [email protected]
                Label lbPrice = new Label();
                lbPrice.Location = new Point(Convert.ToInt32(pnl.Location.X), pnl.Location.Y + ptb.Height + lbName.Height);
                lbPrice.Width = pnl.Width;
                lbPrice.Height = Convert.ToInt32(pnl.Height * 0.15);
                lbPrice.Text = ProductList[i].Dongia;
                lbPrice.Font = new Font("Arial", 13, FontStyle.Regular);
                lbPrice.TextAlign = System.Drawing.ContentAlignment.TopCenter;
                pnl.Controls.Add(lbPrice);
                //add panel 1 san pham vao flowlayoutPanel
                fpnlProduct.Controls.Add(pnl);
            }

            //thiet lap label hien ten user , height width location nam ben trái center vertical so voi panel toolbox
            //button xem thong tin user nam ben duoi ten user
            
            


            //hinh anh toolbox nhu vay ne
            /*--------------------------------------------------------------------------------------------
             * -  panel trái             -                                 -         panel phải          -
             * -  chua tenuser           -        title                    -       chua 1 ptb va label   -label hien thi so sp trong gio hang
             * -------------------------------------------------------------------------------------------
            */

            //panel ben phải trong paneltoolbox
            //them ptb vao pnel phai load hinh anh xe day hang len
            pnlToolRight.Controls.Add(ptbGioHang);
            ptbGioHang.LoadAsync("https://icon-library.com/images/white-shopping-cart-icon/white-shopping-cart-icon-9.jpg");
            ptbGioHang.SizeMode = PictureBoxSizeMode.Zoom;
            //thiet lap kich thuoc vi tri cho ptb
            ptbGioHang.Height = Convert.ToInt32(pnlToolRight.Height);
            ptbGioHang.Width = Convert.ToInt32(pnlToolRight.Width / 3);
            ptbGioHang.Click += gioHang_click;
            //them label so luong sp vao panel phai
            pnlToolRight.Controls.Add(lbGioHang);
            lbGioHang.Font = lbInfo.Font = new Font("Arial", Convert.ToInt32(pnlToolBox.Height * 0.09), FontStyle.Regular);
            lbGioHang.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            lbGioHang.Height = ptbGioHang.Height;
            lbGioHang.ForeColor = Color.White;
            lbGioHang.Click += gioHang_click;

            lbGioHang.Width = Convert.ToInt32(pnlToolRight.Width * 0.7);
            lbGioHang.Location = new Point(ptbGioHang.Width, ptbGioHang.Location.Y);
        }