Ejemplo n.º 1
0
        private void GetAnh(int id)
        {
            var dataAnh = conn.getDataTable("SELECT id,sanphamId,title,anh FROM AnhSanPham where sanphamId = " + id);

            btnXoaAnh1.Visible = false;
            btnXoaAnh2.Visible = false;
            if (dataAnh.Rows.Count > 0)
            {
                if (dataAnh.Rows.Count == 1)
                {
                    picAnh1.Image      = Ham.GetImageFromString(dataAnh.Rows[0][3].ToString());
                    btnXoaAnh1.Tag     = dataAnh.Rows[0][0].ToString();
                    btnXoaAnh1.Visible = true;
                }
                else
                {
                    picAnh1.Image      = Ham.GetImageFromString(dataAnh.Rows[0][3].ToString());
                    picAnh2.Image      = Ham.GetImageFromString(dataAnh.Rows[1][3].ToString());
                    btnXoaAnh1.Tag     = dataAnh.Rows[0][0].ToString();
                    btnXoaAnh2.Tag     = dataAnh.Rows[1][0].ToString();
                    btnXoaAnh2.Visible = true;
                    btnXoaAnh1.Visible = true;
                }
            }
            else
            {
                picAnh1.Image = null;
                picAnh2.Image = null;
            }
        }
Ejemplo n.º 2
0
        private void getAnh()
        {
            var data = conn.getDataTable("select top 2 anh from ANhSanPham where sanphamId = " + Id);

            if (data.Rows.Count > 0)
            {
                if (data.Rows.Count == 1)
                {
                    picAnhBig.Image = Ham.GetImageFromString(data.Rows[0][0].ToString());
                    picAnh1.Image   = Ham.GetImageFromString(data.Rows[0][0].ToString());
                }
                else
                {
                    picAnhBig.Image = Ham.GetImageFromString(data.Rows[0][0].ToString());
                    picAnh1.Image   = Ham.GetImageFromString(data.Rows[0][0].ToString());
                    picAnh2.Image   = Ham.GetImageFromString(data.Rows[1][0].ToString());
                }
            }
        }
Ejemplo n.º 3
0
        private void createDienThoai(int id, string tenSp, int giaKm, int giaBan, int luotxem, string anh, int sl)
        {
            Panel panel = new Panel();

            PictureBox pic       = new PictureBox();
            Label      hethang   = new Label();
            Label      ten       = new Label();
            Label      gia       = new Label();
            Label      giaGach   = new Label();
            Label      view      = new Label();
            Label      viewCount = new Label();
            IconButton button    = new IconButton();

            // location
            w = (panelMau.Width + 10) * count;

            if (panelShowSP.Width < w + 70)
            {
                w     = 0;
                count = 0;
                h    += panelMau.Height + 20;
            }
            count++;


            // panel
            panel.Dock        = panelMau.Dock;
            panel.Size        = panelMau.Size;
            panel.BorderStyle = panelMau.BorderStyle;
            panel.Cursor      = panelMau.Cursor;
            panel.BackColor   = panelMau.BackColor;
            panel.Click      += (object s, EventArgs e) =>
            {
                OpenChiTietSanPham(id);
            };
            panel.Location = new Point(20 + w, h);
            //het hang
            if (sl == 0)
            {
                hethang.Text      = lbHetHang.Text;
                hethang.ForeColor = lbHetHang.ForeColor;
                hethang.Location  = lbHetHang.Location;
                hethang.Font      = lbHetHang.Font;
                hethang.AutoSize  = true;
                panel.Controls.Add(hethang);
            }

            // anh sp
            pic.Location = pictureMau.Location;
            pic.Size     = pictureMau.Size;
            pic.Image    = String.IsNullOrEmpty(anh) ? null : Ham.GetImageFromString(anh);
            pic.SizeMode = PictureBoxSizeMode.Zoom;
            pic.Click   += (object s, EventArgs e) =>
            {
                OpenChiTietSanPham(id);
            };
            panel.Controls.Add(pic);
            // ten sp
            ten.Location  = lbTenMau.Location;
            ten.Text      = tenSp;
            ten.ForeColor = lbTenMau.ForeColor;
            ten.Font      = lbTenMau.Font;
            ten.AutoSize  = lbTenMau.AutoSize;
            ten.Size      = lbTenMau.Size;
            ten.Click    += (object s, EventArgs e) =>
            {
                OpenChiTietSanPham(id);
            };
            panel.Controls.Add(ten);
            // gia
            if (giaKm == 0)
            {
                giaKm = giaBan;
            }
            else
            {
                giaGach.Location  = lbGiaGachMau.Location;
                giaGach.Font      = lbGiaGachMau.Font;
                giaGach.ForeColor = lbGiaGachMau.ForeColor;
                giaGach.Text      = String.Format("{0:#,##0.##}", giaBan) + " đ";
                giaGach.Click    += (object s, EventArgs e) =>
                {
                    OpenChiTietSanPham(id);
                };
                panel.Controls.Add(giaGach);
            }
            gia.Location  = lbGiaMau.Location;
            gia.Font      = lbGiaMau.Font;
            gia.AutoSize  = true;
            gia.ForeColor = lbGiaMau.ForeColor;
            gia.Text      = String.Format("{0:#,##0.##}", giaKm) + " đ";
            gia.Click    += (object s, EventArgs e) =>
            {
                OpenChiTietSanPham(id);
            };
            panel.Controls.Add(gia);
            // gia gach giữa



            // VIEW COUNT
            viewCount.Location  = lbViewCountMau.Location;
            viewCount.Font      = lbViewCountMau.Font;
            viewCount.ForeColor = lbViewCountMau.ForeColor;
            viewCount.Text      = luotxem.ToString();
            viewCount.Click    += (object s, EventArgs e) =>
            {
                OpenChiTietSanPham(id);
            };
            panel.Controls.Add(viewCount);
            // VIEW
            view.Location  = lbViewMau.Location;
            view.Font      = lbViewMau.Font;
            view.ForeColor = lbViewMau.ForeColor;
            view.Text      = lbViewMau.Text;
            view.Click    += (object s, EventArgs e) =>
            {
                OpenChiTietSanPham(id);
            };
            panel.Controls.Add(view);

            // button dat hang
            button.Location  = btnDatMau.Location;
            button.IconChar  = btnDatMau.IconChar;
            button.BackColor = btnDatMau.BackColor;
            button.ForeColor = btnDatMau.ForeColor;
            if (sl == 0)
            {
                button.Enabled = false;
            }
            button.Click += (object sender, EventArgs e) =>
            {
                DatHang(id, giaKm, 1);
            };
            button.Size              = btnDatMau.Size;
            button.Font              = btnDatMau.Font;
            button.IconColor         = btnDatMau.IconColor;
            button.IconSize          = btnDatMau.IconSize;
            button.TextAlign         = btnDatMau.TextAlign;
            button.Text              = btnDatMau.Text;
            button.FlatStyle         = btnDatMau.FlatStyle;
            button.TextImageRelation = btnDatMau.TextImageRelation;

            panel.Controls.Add(button);

            panelShowSP.Controls.Add(panel);
        }
Ejemplo n.º 4
0
        private void AutoGenChon(string ma, string ten, string gianhap, string sl, string anh)
        {
            Panel      panel       = new Panel();
            Panel      panelFooter = new Panel();
            Label      lbMa        = new Label();
            Label      lbTen       = new Label();
            Label      lbGia       = new Label();
            Label      lbSL        = new Label();
            Label      Anh         = new Label();
            PictureBox picture1    = new PictureBox();
            Label      lbMa1       = new Label();
            Label      lbTen1      = new Label();
            Label      lbGia1      = new Label();
            Label      lbSL1       = new Label();

            panel.Dock = panelCon.Dock;
            panel.Size = panelCon.Size;

            panel.Click    += (object s, EventArgs e) => { PickSanPham(Int32.Parse(ma), panel); };
            panel.Font      = panelCon.Font;
            panel.BackColor = Color.White;
            panelPickSP.Controls.Add(panel);

            panelFooter.Dock      = panelFooterMau.Dock;
            panelFooter.BackColor = panelFooterMau.BackColor;
            panelFooter.Size      = panelFooterMau.Size;
            panel.Controls.Add(panelFooter);


            // label ma tre
            lbMa.Text     = lbMaTren.Text;
            lbMa.Size     = lbMaTren.Size;
            lbMa.Location = lbMaTren.Location;
            lbMa.Click   += (object s, EventArgs e) => { PickSanPham(Int32.Parse(ma), panel); };
            panel.Controls.Add(lbMa);
            // label ma duoi
            lbMa1.Text     = ma;
            lbMa1.AutoSize = true;
            lbMa1.Click   += (object s, EventArgs e) => { PickSanPham(Int32.Parse(ma), panel); };
            lbMa1.Location = lbSMa.Location;
            panel.Controls.Add(lbMa1);

            // label ten tre
            lbTen.Text     = lbTenTren.Text;
            lbTen.Size     = lbTenTren.Size;
            lbTen.Click   += (object s, EventArgs e) => { PickSanPham(Int32.Parse(ma), panel); };
            lbTen.Location = lbTenTren.Location;
            panel.Controls.Add(lbTen);
            // label ten duoi
            lbTen1.Text     = ten;
            lbTen1.Location = lbSten.Location;
            lbTen1.AutoSize = lbSten.AutoSize;
            lbTen1.Size     = lbSten.Size;
            lbTen1.Click   += (object s, EventArgs e) => { PickSanPham(Int32.Parse(ma), panel); };
            panel.Controls.Add(lbTen1);

            // label gia tre
            lbGia.Text     = lbGiaNhapTren.Text;
            lbGia.Size     = lbGiaNhapTren.Size;
            lbGia.Click   += (object s, EventArgs e) => { PickSanPham(Int32.Parse(ma), panel); };
            lbGia.Location = lbGiaNhapTren.Location;
            panel.Controls.Add(lbGia);
            // label gia duoi
            lbGia1.Text     = gianhap;
            lbGia1.Size     = lbSgia.Size;
            lbGia1.Click   += (object s, EventArgs e) => { PickSanPham(Int32.Parse(ma), panel); };
            lbGia1.Location = lbSgia.Location;
            panel.Controls.Add(lbGia1);


            // label sl tre
            lbSL.Text     = lbSLTren.Text;
            lbSL.Size     = lbSLTren.Size;
            lbSL.Click   += (object s, EventArgs e) => { PickSanPham(Int32.Parse(ma), panel); };
            lbSL.Location = lbSLTren.Location;
            panel.Controls.Add(lbSL);
            // label sl duoi
            lbSL1.Text     = sl;
            lbSL1.Click   += (object s, EventArgs e) => { PickSanPham(Int32.Parse(ma), panel); };
            lbSL1.Size     = lbSsl.Size;
            lbSL1.Location = lbSsl.Location;
            panel.Controls.Add(lbSL1);

            // label anh duoi
            Anh.Text     = lbAnh.Text;
            Anh.Size     = lbAnh.Size;
            Anh.Click   += (object s, EventArgs e) => { PickSanPham(Int32.Parse(ma), panel); };
            Anh.Location = lbAnh.Location;
            panel.Controls.Add(Anh);

            picture1.Size     = picSanh1.Size;
            picture1.Image    = Ham.GetImageFromString(anh);
            picture1.Location = picSanh1.Location;
            picture1.SizeMode = picSanh1.SizeMode;
            picture1.Click   += (object s, EventArgs e) => { PickSanPham(Int32.Parse(ma), panel); };

            panel.Controls.Add(picture1);
        }