public static bool Delete(BanHangChiTiet data) { try { if (data != null) { BanHangChiTiet objDb = GetById(data.Id); if (objDb != null) { dbContext.BanHangChiTiets.DeleteOnSubmit(objDb); return true; } } } catch { } CreateSQlConnection(); return false; }
private void detach_BanHangChiTiets(BanHangChiTiet entity) { this.SendPropertyChanging(); entity.BanHang = null; }
private void attach_BanHangChiTiets(BanHangChiTiet entity) { this.SendPropertyChanging(); entity.BanHang = this; }
partial void DeleteBanHangChiTiet(BanHangChiTiet instance);
partial void UpdateBanHangChiTiet(BanHangChiTiet instance);
partial void InsertBanHangChiTiet(BanHangChiTiet instance);
public static bool Update(BanHangChiTiet data) { return BanHangChiTietDao.Update(data); }
public static bool Insert(BanHangChiTiet data) { return BanHangChiTietDao.Insert(data); }
public static bool Delete(BanHangChiTiet data) { return BanHangChiTietDao.Delete(data); }
private bool InsertDataBanHangChiTiet(DTO.BanHang dataBanHang) { for (int i = 0; i < dgvThongTin.Rows.Count - 1; i++) //foreach (DataGridViewRow row in dgvThongTin.Rows) { DTO.BanHangChiTiet data = new DTO.BanHangChiTiet(); data.IdBanHang = dataBanHang.Id; data.IdSanPham = ConvertUtil.ConvertToInt(dgvThongTin[colIdSanPham.Name, i].Value); data.TonDau = ConvertUtil.ConvertToInt(dgvThongTin[colTonDau.Name, i].Value); data.ThuHoiNgayTruoc = ConvertUtil.ConvertToInt(dgvThongTin[colThuHoiNgayTruoc.Name, i].Value); data.Nhan = ConvertUtil.ConvertToInt(dgvThongTin[colNhan.Name, i].Value); data.Ban = ConvertUtil.ConvertToInt(dgvThongTin[colBan.Name, i].Value); data.TonCuoi = ConvertUtil.ConvertToInt(dgvThongTin[colTonCuoi.Name, i].Value); data.Gia = ConvertUtil.ConvertToInt(dgvThongTin[colGia.Name, i].Value.ToString().Replace(Constant.SYMBOL_LINK_MONEY, string.Empty)); data.ThanhTien = ConvertUtil.ConvertToInt(dgvThongTin[colThanhTien.Name, i].Value.ToString().Replace(Constant.SYMBOL_LINK_MONEY, string.Empty)); data.ThuHoi = ConvertUtil.ConvertToInt(dgvThongTin[colThuHoi.Name, i].Value); data.DiemMoi = ConvertUtil.ConvertToInt(dgvThongTin[colDiemMoi.Name, i].Value); data.LuotBan = ConvertUtil.ConvertToInt(dgvThongTin[colLuotBan.Name, i].Value); if (!BanHangChiTietBus.Insert(data)) { return false; } else { dgvThongTin[colId.Name, i].Value = data.Id; } } return true; }
private bool UpdateDataBanHangChiTiet(DTO.BanHang dataBanHang) { foreach (DataGridViewRow row in dgvThongTin.Rows) { if (!string.IsNullOrEmpty(row.Cells[colId.Name].Value.ToString())) { DTO.BanHangChiTiet data = BanHangChiTietBus.GetById(ConvertUtil.ConvertToInt(row.Cells[colId.Name].Value)); data.Ban = ConvertUtil.ConvertToInt(row.Cells[colBan.Name].Value); data.ThuHoi = ConvertUtil.ConvertToInt(row.Cells[colThuHoi.Name].Value); data.ThanhTien = ConvertUtil.ConvertToInt(row.Cells[colThanhTien.Name].Value.ToString().Replace(Constant.SYMBOL_LINK_MONEY, string.Empty)); if (!BanHangChiTietBus.Update(data)) { return false; } } else { DTO.BanHangChiTiet data = new DTO.BanHangChiTiet(); data.IdBanHang = dataBanHang.Id; data.IdSanPham = ConvertUtil.ConvertToInt(row.Cells[colIdSanPham.Name].Value); data.Gia = ConvertUtil.ConvertToInt(row.Cells[colGia.Name].Value.ToString().Replace(Constant.SYMBOL_LINK_MONEY, string.Empty)); data.Ban = ConvertUtil.ConvertToInt(row.Cells[colBan.Name].Value); data.ThuHoi = ConvertUtil.ConvertToInt(row.Cells[colThuHoi.Name].Value); data.ThanhTien = ConvertUtil.ConvertToInt(row.Cells[colThanhTien.Name].Value.ToString().Replace(Constant.SYMBOL_LINK_MONEY, string.Empty)); if (!BanHangChiTietBus.Insert(data)) { return false; } } } return true; }
public static bool Update(BanHangChiTiet data) { try { if (data != null) { dbContext.SubmitChanges(); return true; } return false; } catch { return false; } }
public static bool Insert(BanHangChiTiet data) { try { dbContext.BanHangChiTiets.InsertOnSubmit(data); dbContext.SubmitChanges(); return true; } catch { return false; } }