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(); }
private void dataGridView1_SelectionChanged(object sender, EventArgs e) { int id = int.Parse(dataGridView1.CurrentRow.Cells["ThuocID"].Value.ToString()); currThuoc = APIs.GetThuocByID(id)[0]; IsInsert = true; SetDataInfoForm(currThuoc, 0); }
private void listView1_SelectedIndexChanged(object sender, EventArgs e) { int ID = int.Parse(listView1.SelectedItems[0].Text); int numm = int.Parse(listView1.SelectedItems[0].SubItems[2].Text); currThuoc = APIs.GetThuocByID(ID)[0]; SetDataInfoForm(currThuoc, numm); IsInsert = false; }
private void button1_Click(object sender, EventArgs e) { DialogResult dialog = MessageBox.Show("Bạn muốn thanh toán?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dialog == DialogResult.OK) { if (listView1.Items.Count != 0) { Global.lstItemBuy.Clear(); foreach (ListViewItem it in listView1.Items) { Thuoc sp = APIs.GetThuocByID(int.Parse(it.Text))[0]; sp.Soluong = int.Parse(it.SubItems[2].Text); Global.lstItemBuy.Add(sp); } if (checkBox1.Checked) { Global.khachhangID = APIs.GetKhachhangByName(comboKhachhang.Text).KhachhangID; Global.Tenkhachhang = comboKhachhang.Text; Global.Diachi = APIs.GetKhachhangByName(comboKhachhang.Text).Diachi; } else { if (textBoxKhachhang.Text == "" || textBoxDiachi.Text == "") { MessageBox.Show("Bạn chưa nhập thông tin khách hàng!"); return; } Global.khachhangID = 1; Global.Tenkhachhang = textBoxKhachhang.Text; Global.Diachi = textBoxDiachi.Text; } Hoadon hd = new Hoadon(); hd.passData = PassData; hd.ShowDialog(); } else { MessageBox.Show("Bạn chưa chọn món hàng nào!"); } } }