private void btntcSave_Click(object sender, EventArgs e) { //Save data Model.camdochieuduongEntities camdochieuduongEntity = new Model.camdochieuduongEntities(); Model.ThuChi thuchi = new Model.ThuChi(); thuchi.LoaiGiaoDich = cmbtcthuchi.Text; thuchi.NgayNhap = DateTime.Parse(txttcngaynhap.Text); thuchi.SoTien = Convert.ToInt64(txttcsotien.Text.Replace(",", ""));; thuchi.MoTa = txttcmota.Text; camdochieuduongEntity.ThuChis.Add(thuchi); camdochieuduongEntity.SaveChanges(); showThuChi(); }
private void btntcCancel_Click(object sender, EventArgs e) { GridView gridView = gridThuChi.FocusedView as GridView; var selectId = Convert.ToInt64(gridView.GetFocusedRowCellValue("MaThuChi")); //Update Thu Chi Table Model.camdochieuduongEntities camdochieuduongEntity = new Model.camdochieuduongEntities(); Model.ThuChi TC = camdochieuduongEntity.ThuChis.Find(selectId); if (TC.NgayNhap.Value.Date == DateTime.Now.Date) { TC.Cancel = "X"; camdochieuduongEntity.SaveChanges(); showThuChi(); } else { MessageBox.Show("Không thể xóa phiếu thu chi ngày quá khứ"); } }