private void btnThem_Click(object sender, EventArgs e) { if (this.cbTenThuoc.SelectedIndex < 0) { return; } var selectedItem = (DTO.ThuocDTO) this.cbTenThuoc.SelectedItem; if (this.listOfMedicineAdded.Find(t => t.MaThuoc == selectedItem.MaThuoc) != null) { return; } var thuoc = new Model.ThuocView() { MaThuoc = selectedItem.MaThuoc, TenThuoc = selectedItem.TenThuoc, GhiChu = this.txtGhiChu.getText, SoLuong = int.Parse(this.txtSoLuong.Text) }; this.listOfMedicineAdded.Add(thuoc); this.reloadData(); this.activeConfirmChanged(); }
private void btnSaveChanged_Click(object sender, EventArgs e) { var index = this.gridView1.GetSelectedRows().First(); var selectedItem = (DTO.ThuocDTO) this.cbTenThuoc.SelectedItem; var thuoc = new Model.ThuocView() { MaThuoc = selectedItem.MaThuoc, TenThuoc = selectedItem.TenThuoc, GhiChu = this.txtGhiChu.Text, SoLuong = int.Parse(this.txtSoLuong.Text) }; this.listOfMedicineAdded.Insert(index, thuoc); this.listOfMedicineAdded.RemoveAt(index + 1); this.reloadData(); }