예제 #1
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 = panelCon.BackColor;
            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.Size     = lbSMa.Size;
            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.Size     = lbSten.Size;
            lbTen1.Click   += (object s, EventArgs e) => { PickSanPham(Int32.Parse(ma), panel); };
            lbTen1.AutoSize = lbSten.AutoSize;
            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    = HamChung.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);
        }
예제 #2
0
        private void addRow(DataRow item)
        {
            Panel panel = new Panel();
            Panel line  = new Panel();

            PictureBox pictureBox       = new PictureBox();
            Label      lbTen            = new Label();
            Label      lbDonGia         = new Label();
            Label      lbThanhTienTitle = new Label();

            Label   lbThanhTien = new Label();
            Button  btnGiamSL   = new Button();
            Button  btnTangSL   = new Button();
            Button  btnDelete   = new Button();
            TextBox txtsL       = new TextBox();

            // panel
            panel.BackColor = Color.FromArgb(24, 30, 54);
            panel.Dock      = DockStyle.Top;
            panel.Font      = label1.Font;
            panel.Size      = new Size(658, 144);
            panelParent.Controls.Add(panel);

            // panel line
            line.Size      = new Size(658, 12);
            line.Dock      = DockStyle.Bottom;
            line.BackColor = Color.White;

            panel.Controls.Add(line);

            // btn xoa
            btnDelete.Text = "Xóa";
            if (FindId != 0)
            {
                btnDelete.Enabled = false;
            }
            btnDelete.Font      = label1.Font;
            btnDelete.Location  = new Point(9, 10);
            btnDelete.ForeColor = Color.Red;
            btnDelete.Size      = new Size(64, 116);
            btnDelete.Click    += (object sender, EventArgs e) =>
            {
                Delete(Int32.Parse(item[4].ToString()));
            };
            panel.Controls.Add(btnDelete);
            // anh sach
            pictureBox.Size     = new Size(115, 121);
            pictureBox.Location = new Point(79, 6);
            pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
            pictureBox.Image    = HamChung.GetImageFromString(item[3].ToString());
            panel.Controls.Add(pictureBox);

            // lb tên
            lbTen.Text      = item[0].ToString();
            lbTen.Location  = new Point(235, 24);
            lbTen.AutoSize  = false;
            lbTen.Size      = new Size(260, 60);
            lbTen.Font      = label1.Font;
            lbTen.ForeColor = Color.White;
            panel.Controls.Add(lbTen);
            // lb dongia giá
            //lbDonGia.Font = new Font(Font.FontFamily, 12);
            lbDonGia.Text      = (item[1].ToString() + " đồng");
            lbDonGia.Location  = new Point(235, 87);
            lbDonGia.ForeColor = Color.White;
            panel.Controls.Add(lbDonGia);
            // btn giam
            btnGiamSL.Text = "-";
            btnGiamSL.Font = label1.Font;
            btnGiamSL.Size = new Size(33, 25);
            if (FindId != 0)
            {
                btnGiamSL.Enabled = false;
            }
            btnGiamSL.Location  = new Point(545, 22);
            btnGiamSL.BackColor = Color.White;
            btnGiamSL.ForeColor = Color.Black;
            btnGiamSL.Click    += (object sender, EventArgs e) =>
            {
                GiamSoSach(item[4].ToString(), Int32.Parse(item[4].ToString()), Int32.Parse(item[1].ToString()));
            };
            panel.Controls.Add(btnGiamSL);

            // txt số lượng
            txtsL.Text      = item[2].ToString();
            txtsL.Name      = "txt" + item[4].ToString();
            txtsL.Location  = new Point(584, 22);
            txtsL.ForeColor = Color.Black;
            txtsL.Size      = new Size(46, 25);
            if (FindId != 0)
            {
                txtsL.ReadOnly = true;
            }
            txtsL.TextAlign    = HorizontalAlignment.Center;
            txtsL.Font         = label1.Font;
            txtsL.TextChanged += (object sender, EventArgs e) =>
            {
                EditSL(item[4].ToString(), Int32.Parse(item[4].ToString()), Int32.Parse(item[1].ToString()));
            };
            panel.Controls.Add(txtsL);

            // btn tang
            btnTangSL.Text      = "+";
            btnTangSL.Size      = new Size(33, 25);
            btnTangSL.ForeColor = Color.Black;
            btnTangSL.Location  = new Point(640, 22);
            btnTangSL.Font      = label1.Font;
            if (FindId != 0)
            {
                btnTangSL.Enabled = false;
            }
            btnTangSL.BackColor = Color.White;
            btnTangSL.Click    += (object sender, EventArgs e) =>
            {
                TangSlSach(item[4].ToString(), Int32.Parse(item[4].ToString()), Int32.Parse(item[1].ToString()));
            };
            panel.Controls.Add(btnTangSL);

            // lb thanh  tiền  tilte
            lbThanhTienTitle.Text      = "Thành tiền";
            lbThanhTienTitle.Location  = new Point(570, 59);
            lbThanhTienTitle.ForeColor = Color.White;
            lbThanhTienTitle.Font      = label1.Font;
            panel.Controls.Add(lbThanhTienTitle);

            // lb thanh  tiền
            lbThanhTien.Text      = (Int32.Parse(item[1].ToString()) * Int32.Parse(item[2].ToString())).ToString();
            lbThanhTien.Name      = "txttien" + Int32.Parse(item[4].ToString());
            lbThanhTien.Location  = new Point(580, 100);
            lbThanhTien.Font      = label1.Font;
            lbThanhTien.ForeColor = Color.White;
            panel.Controls.Add(lbThanhTien);
        }
예제 #3
0
        private void createDienThoai(DataRow row)
        {
            int    id   = Int32.Parse(row[0].ToString());
            string ten  = row[1].ToString();
            string gia  = String.Format("{0:#,##0.##}", row[2].ToString());
            string view = row[3].ToString();
            string anh  = row[4].ToString();



            Panel panel = new Panel();

            PictureBox pic   = new PictureBox();
            Label      Lten  = new Label();
            Label      Lgia  = new Label();
            Label      Lview = new Label();

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

            if (panelSP.Width < w + 110)
            {
                w     = 0;
                count = 0;
                h    += panelMau.Height + 5;
            }
            count++;


            // panel
            panel.Dock        = panelMau.Dock;
            panel.Size        = panelMau.Size;
            panel.BorderStyle = panelMau.BorderStyle;
            panel.Cursor      = panelMau.Cursor;
            panel.BackColor   = panelMau.BackColor;
            panel.Cursor      = Cursors.Hand;
            panel.Click      += (object s, EventArgs e) =>
            {
                OpenChiTietSanPham(id);
            };
            panel.Location = new Point(20 + w, h);


            // anh sp
            pic.Location = picMau.Location;
            pic.Size     = picMau.Size;
            pic.Image    = String.IsNullOrEmpty(anh) ? null : HamChung.GetImageFromString(anh);
            pic.SizeMode = picMau.SizeMode;
            pic.Cursor   = Cursors.Hand;
            pic.Click   += (object s, EventArgs e) =>
            {
                OpenChiTietSanPham(id);
            };
            panel.Controls.Add(pic);
            // ten sp
            Lten.Location  = lbTenMau.Location;
            Lten.Text      = ten;
            Lten.ForeColor = lbTenMau.ForeColor;
            Lten.Font      = lbTenMau.Font;
            Lten.AutoSize  = lbTenMau.AutoSize;
            Lten.Size      = lbTenMau.Size;
            Lten.Click    += (object s, EventArgs e) =>
            {
                //OpenChiTietSanPham(id);
            };
            panel.Controls.Add(Lten);
            Lgia.Text      = gia;
            Lgia.Location  = lbGiaMau.Location;
            Lgia.Font      = lbGiaMau.Font;
            Lgia.AutoSize  = true;
            Lgia.ForeColor = lbGiaMau.ForeColor;

            Lgia.Click += (object s, EventArgs e) =>
            {
                //OpenChiTietSanPham(id);
            };
            panel.Controls.Add(Lgia);
            // gia gach giữa



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


            panelSP.Controls.Add(panel);
        }
예제 #4
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0 && e.RowIndex != -1)
            {
                ma = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
            }
            else if (e.RowIndex != -1)
            {
                ma = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
                string kho, ncc, nxb, loai;
                string anh = null;
                kho  = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
                ncc  = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();
                loai = dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString();
                var dt = cn.getDataTable("select anh from sanpham where id = " + ma);
                if (dt.Rows.Count > 0)
                {
                    anh = dt.Rows[0][0].ToString();
                }

                //AUTO KHO
                if (String.IsNullOrEmpty(kho))
                {
                    cbKho.SelectedIndex = 0;
                }
                else
                {
                    cbKho.SelectedItem = kho;
                }

                //AUTO NCC
                if (String.IsNullOrEmpty(ncc))
                {
                    cbNCC.SelectedIndex = 0;
                }
                else
                {
                    cbNCC.SelectedItem = ncc;
                }

                //AUTO LOAI
                if (String.IsNullOrEmpty(loai))
                {
                    cbLoaiSanPham.SelectedIndex = 0;
                }
                else
                {
                    cbLoaiSanPham.SelectedItem = loai;
                }

                //AUTO anh
                if (String.IsNullOrEmpty(anh))
                {
                    ptbAnh.Image = null;
                }
                else
                {
                    ptbAnh.Image = HamChung.GetImageFromString(anh);
                }
                GetAllRow();
            }
        }