Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Hoadonbanthuoc hd = new Hoadonbanthuoc();

            hd.KhachhangID = Global.khachhangID;
            hd.Ngayviet    = DateTime.Now;
            hd.NhanvienID  = Global.nhanvienID;
            int id = APIs.InsertHoadon(hd);

            //hd.HoadonbanghangID = APIs.GetHoadonIDByHoadon(hd);
            foreach (Thuoc sp in Global.lstItemBuy)
            {
                CTHoadonbanthuoc ct = new CTHoadonbanthuoc();
                ct.HoadonbanthuocID = id;
                ct.Thuoc            = sp.ThuocID;
                ct.Soluong          = sp.Soluong;
                ct.Dongia           = sp.Dongia;
                APIs.InsertCTHoadon(ct);
                APIs.UpdateThuoc(sp.ThuocID, (int)sp.Soluong);
            }
            MessageBox.Show("Thanh toán thành công!");
            passData(true);
            this.Close();
        }