private void dataGridViewX1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) { ePhieuThue pthuethanhtoan = new ePhieuThue(); if (Convert.ToBoolean(dataGridViewX1.Rows[e.RowIndex].Cells[0].EditedFormattedValue) == true) { string maphieu = dataGridViewX1.Rows[e.RowIndex].Cells[1].Value.ToString(); pthuethanhtoan = busPT.layPhieuThueTheoMaPhieu(maphieu); lstthanhtoan.Add(pthuethanhtoan); thanhtoan += Double.Parse(pthuethanhtoan.Phitramuon.ToString()); lblTienThanhToan.Text = thanhtoan.ToString(); } else { ePhieuThue ptxoa = new ePhieuThue(); string maphieu = dataGridViewX1.Rows[e.RowIndex].Cells[1].Value.ToString(); foreach (var item in lstthanhtoan) { if (item.Maphieuthue == maphieu) { ptxoa = item; } } lstthanhtoan.Remove(ptxoa); thanhtoan -= Double.Parse(ptxoa.Phitramuon.ToString()); lblTienThanhToan.Text = thanhtoan.ToString(); } } }
private void dataGridViewX1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 7) { ePhieuThue pthuethanhtoan = new ePhieuThue(); if (Convert.ToBoolean(dataGridViewX1.Rows[e.RowIndex].Cells[7].EditedFormattedValue) == true) { //MessageBox.Show("Test"); string maphieu = dataGridViewX1.Rows[e.RowIndex].Cells[0].Value.ToString(); pthuethanhtoan = busPT.layPhieuThueTheoMaPhieu(maphieu); lstPhieuHuy.Add(pthuethanhtoan); } else { ePhieuThue ptxoa = new ePhieuThue(); string maphieu = dataGridViewX1.Rows[e.RowIndex].Cells[0].Value.ToString(); foreach (var item in lstPhieuHuy) { if (item.Maphieuthue == maphieu) { ptxoa = item; } } lstPhieuHuy.Remove(ptxoa); } } }