//add Shoping Cart

        private void gunaGradientButton2_Click(object sender, EventArgs e)
        {
            int    PriceG;
            string sL, tensp, masp, colorsp, sizesp;

            if (tbPrice.Text == "" || tbTen.Text.StartsWith(" ") || colorG == null || sizeG == null)
            {
                MessageBox.Show("Điền đầy đủ Thông tin");
            }
            else
            {
                if (cbListColor.Items.Count > 0 && cbListSize.Items.Count > 0)
                {
                    List <CartGioHang> newlistUser = new List <CartGioHang>();
                    List <GioHang>     newListGH   = new List <GioHang>();
                    PriceG  = int.Parse(tbPrice.Text);
                    sL      = tbSoLuong.Text;
                    tensp   = tbTen.Text;
                    masp    = maspG;
                    colorsp = colorG;
                    sizesp  = sizeG;
                    GioHang sp = new GioHang(masp, tensp, PriceG, sL, colorsp, sizesp);
                    newListGH.Add(sp);

                    if (DataSanPham.Them_GioHang(sp))
                    {
                        MessageBox.Show("Thêm Success,Kiểm tra Giỏ hàng");
                        if (frm == null)
                        {
                            frm = new GioHangfrm();
                        }
                        frm.HienThi(newlistUser, newListGH);
                    }
                    else
                    {
                        MessageBox.Show("Thêm Thất Bại");
                    }
                }
                else
                {
                    MessageBox.Show("Size và Color chưa có ");
                }
            }
        }
Beispiel #2
0
        private void Them_Click(object sender, EventArgs e)
        {
            if (MaDonBan.Text == "")
            {
                MessageBox.Show("Vui long nhap ma don ban");
                return;
            }
            GioHang a = new GioHang();

            a.MaDonBan = MaDonBan.Text;
            a.SoDT     = SDT.Text;
            a.HoTen    = HoTen.Text;
            a.MaSach   = cbbMaSach.SelectedItem.ToString();
            a.SoLuong  = Convert.ToInt32(numericUpDown1.Value.ToString());
            a.GiaTien  = BLL_QuanLy.Instance.Bll_GetGiaTienByMaSach(a.MaSach) * a.SoLuong;
            list.Add(a);
            dataGridView2.DataSource = null;
            dataGridView2.DataSource = list;
            HoTen.Enabled            = false;
            SDT.Enabled = false;
        }