Пример #1
0
        public void ThemDH(int MaKH, string MaDH, int thanhtien, DataGridView g, string diachi, string TinhThanh, string QuanHuyen)
        {
            DonHang D = new DonHang();

            D.MaDonHang        = MaDH;
            D.MaKhachHang      = MaKH;
            D.ThanhTienDonHang = thanhtien;
            D.NgayMuaHang      = DateTime.Today;
            D.DiaChiGiaoHang   = diachi;
            D.Tinh_ThanhPho    = TinhThanh;
            D.Quan_Huyen       = QuanHuyen;
            da.ThemDH(D);
            for (int i = 0; i < g.Rows.Count; i++)
            {
                CTDH CT = new CTDH();
                CT.MaDonHang = MaDH;
                string a    = (g.Rows[i].Cells[0].Value.ToString());
                int    Masp = da.TimMaSanPham(a);
                CT.MaSanPham = Masp;
                CT.Gia       = int.Parse(g.Rows[i].Cells[1].Value.ToString());
                CT.SoLuong   = int.Parse(g.Rows[i].Cells[2].Value.ToString());
                da.THEMCTDH(CT);
            }
        }