Esempio n. 1
0
        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            int       HoadonID    = int.Parse(dataGridView1.CurrentRow.Cells["HoadonbanthuocID"].Value.ToString());
            int       KhachhangID = int.Parse(dataGridView1.CurrentRow.Cells["KhachhangID"].Value.ToString());
            Khachhang kh          = APIs.GetKhachhangByID(KhachhangID);

            txtTenKH.Text  = kh.Tenkhachhang;
            txtDiachi.Text = kh.Diachi;
            List <CTHoadonbanthuoc> lst = APIs.LstCTByHoadonID(HoadonID);

            listView1.Items.Clear();
            float total = 0;

            for (int i = 0; i < lst.Count; i++)
            {
                CTHoadonbanthuoc ct   = lst[i];
                ListViewItem     item = new ListViewItem();
                item.Text = (i + 1).ToString();
                Thuoc t = APIs.GetThuocByID(ct.Thuoc)[0];
                item.SubItems.Add(t.Tenthuoc);
                item.SubItems.Add(t.Donvitinh);
                item.SubItems.Add(ct.Soluong.ToString());
                item.SubItems.Add((ct.Dongia * 1000).ToString());
                total += (float)ct.Soluong * (float)ct.Dongia * 1000;
                item.SubItems.Add((ct.Soluong * ct.Dongia * 1000).ToString());
                listView1.Items.Add(item);
            }
            txtTotal.Text = total.ToString();
        }
Esempio n. 2
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();
        }
Esempio n. 3
0
 public static void InsertCTHoadon(CTHoadonbanthuoc ct)
 {
     mydata.CTHoadonbanthuocs.Add(ct);
     mydata.SaveChanges();
 }