public static bool Delete(KhuyenMai data) { try { if (data != null) { KhuyenMai objDb = GetById(data.Id); if (objDb != null) { dbContext.KhuyenMais.DeleteOnSubmit(objDb); return true; } } } catch { } CreateSQlConnection(); return false; }
public static bool Update(KhuyenMai data) { return KhuyenMaiDao.Update(data); }
public static bool Insert(KhuyenMai data) { return KhuyenMaiDao.Insert(data); }
public static bool Delete(KhuyenMai data) { return KhuyenMaiDao.Delete(data); }
private void UpdateData() { foreach (DataGridViewRow row in dgvThongTin.Rows) { if (ConvertUtil.ConvertToInt(row.Cells[colSoLuongSanPham.Name].Value) != 0 && ConvertUtil.ConvertToInt(row.Cells[colSoLuongSanPhamKhuyenMai.Name].Value) != 0) { if (row.Cells[colId.Name].Value != null && !string.IsNullOrEmpty(row.Cells[colId.Name].Value.ToString())) { DTO.KhuyenMai data = KhuyenMaiBus.GetById(ConvertUtil.ConvertToInt(row.Cells[colId.Name].Value)); data.SoLuongSanPham = row.Cells[colSoLuongSanPham.Name].Value == null ? 0 : ConvertUtil.ConvertToInt(row.Cells[colSoLuongSanPham.Name].Value); data.SanPham1 = SanPhamBus.GetById(ConvertUtil.ConvertToInt(row.Cells[colSanPhamKhuyenMai.Name].Value)); data.SoLuongSanPhamKhuyenMai = row.Cells[colSoLuongSanPhamKhuyenMai.Name].Value == null ? 0 : ConvertUtil.ConvertToInt(row.Cells[colSoLuongSanPhamKhuyenMai.Name].Value); data.DonViLamTron = row.Cells[colDonViLamTron.Name].Value == null ? 0 : ConvertUtil.ConvertToDouble(row.Cells[colDonViLamTron.Name].Value); data.GhiChu = row.Cells[colGhiChu.Name].Value == null ? string.Empty : row.Cells[colGhiChu.Name].Value.ToString(); if (KhuyenMaiBus.Update(data)) { //this.Dispose(); } else { if (MessageBox.Show(Constant.MESSAGE_ERROR + Constant.MESSAGE_NEW_LINE + Constant.MESSAGE_EXIT, Constant.CAPTION_ERROR, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { //this.Dispose(); return; } } } else { DTO.KhuyenMai data = new DTO.KhuyenMai(); data.IdSanPham = ConvertUtil.ConvertToInt(row.Cells[colIdSanPham.Name].Value); data.SoLuongSanPham = row.Cells[colSoLuongSanPham.Name].Value == null ? 0 : ConvertUtil.ConvertToInt(row.Cells[colSoLuongSanPham.Name].Value); data.IdSanPhamKhuyenMai = ConvertUtil.ConvertToInt(row.Cells[colSanPhamKhuyenMai.Name].Value); data.SoLuongSanPhamKhuyenMai = row.Cells[colSoLuongSanPhamKhuyenMai.Name].Value == null ? 0 : ConvertUtil.ConvertToInt(row.Cells[colSoLuongSanPhamKhuyenMai.Name].Value); data.DonViLamTron = row.Cells[colDonViLamTron.Name].Value == null ? 0 : ConvertUtil.ConvertToDouble(row.Cells[colDonViLamTron.Name].Value); data.GhiChu = row.Cells[colGhiChu.Name].Value == null ? string.Empty : row.Cells[colGhiChu.Name].Value.ToString(); if (KhuyenMaiBus.Insert(data)) { //this.Dispose(); } else { if (MessageBox.Show(Constant.MESSAGE_UPDATE_ERROR + Constant.MESSAGE_NEW_LINE + Constant.MESSAGE_EXIT, Constant.CAPTION_ERROR, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { //this.Dispose(); return; } } } } } //pbSua.Enabled = false; //pbSua.Image = Image.FromFile(ConstantResource.CHUC_NANG_ICON_EDIT_DISABLE); MessageBox.Show(string.Format(Constant.MESSAGE_UPDATE_SUCCESS, "Khuyến mãi"), Constant.CAPTION_CONFIRMATION, MessageBoxButtons.OK, MessageBoxIcon.Information); }
partial void DeleteKhuyenMai(KhuyenMai instance);
partial void UpdateKhuyenMai(KhuyenMai instance);
partial void InsertKhuyenMai(KhuyenMai instance);
private void detach_KhuyenMais1(KhuyenMai entity) { this.SendPropertyChanging(); entity.SanPham1 = null; }
private void attach_KhuyenMais(KhuyenMai entity) { this.SendPropertyChanging(); entity.SanPham = this; }
public static bool Update(KhuyenMai data) { try { if (data != null) { dbContext.SubmitChanges(); return true; } return false; } catch { return false; } }
public static bool Insert(KhuyenMai data) { try { dbContext.KhuyenMais.InsertOnSubmit(data); dbContext.SubmitChanges(); return true; } catch { return false; } }