public static bool Delete(DinhLuong data, User user) { try { if (data != null) { dbContext.DinhLuongs.DeleteOnSubmit(data); dbContext.SubmitChanges(); return true; } } catch { //return false; } CreateSQlConnection(); return false; }
public static bool Update(DinhLuong data, User user) { return DinhLuongDao.Update(data, user); }
public static bool Insert(DinhLuong data, User user) { return DinhLuongDao.Insert(data, user); }
public static bool Delete(DinhLuong data, User user) { return DinhLuongDao.Delete(data, user); }
partial void DeleteDinhLuong(DinhLuong instance);
partial void UpdateDinhLuong(DinhLuong instance);
partial void InsertDinhLuong(DinhLuong instance);
private void detach_DinhLuongs(DinhLuong entity) { this.SendPropertyChanging(); entity.SanPham = null; }
private void detach_DinhLuongs(DinhLuong entity) { this.SendPropertyChanging(); entity.NguyenLieu = null; }
private void UpdateDinhLuong() { if (!DeleteDataHoaDonDetail()) { return; } for (int i = 0; i < dgvThongTin.RowCount; i++) { if (dgvThongTin[colId.Name, i].Value != null && !string.IsNullOrEmpty(dgvThongTin[colId.Name, i].Value.ToString())) { DTO.DinhLuong dataDL = DinhLuongBus.GetById(ConvertUtil.ConvertToInt(dgvThongTin[colId.Name, i].Value)); dataDL.IdNguyenLieu = ConvertUtil.ConvertToInt(dgvThongTin[colIdNL.Name, i].Value); dataDL.SoLuong = ConvertUtil.ConvertToDouble(dgvThongTin[colUocLuong.Name, i].Value); dataDL.GhiChu = dgvThongTin[colGhiChu.Name, i].Value == null ? string.Empty : dgvThongTin[colGhiChu.Name, i].Value.ToString(); if (!DinhLuongBus.Update(dataDL, FormMain.user)) { if (MessageBox.Show(Constant.MESSAGE_UPDATE_ERROR + Constant.MESSAGE_NEW_LINE + Constant.MESSAGE_EXIT, Constant.CAPTION_ERROR, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { this.Dispose(); } return; } } else { DTO.DinhLuong dataDL = new DTO.DinhLuong(); dataDL.IdSanPham = data.Id; dataDL.IdNguyenLieu = ConvertUtil.ConvertToInt(dgvThongTin[colIdNL.Name, i].Value); dataDL.SoLuong = ConvertUtil.ConvertToDouble(dgvThongTin[colUocLuong.Name, i].Value); dataDL.GhiChu = dgvThongTin[colGhiChu.Name, i].Value == null ? string.Empty : dgvThongTin[colGhiChu.Name, i].Value.ToString(); if (!DinhLuongBus.Insert(dataDL, FormMain.user)) { if (MessageBox.Show(Constant.MESSAGE_UPDATE_ERROR + Constant.MESSAGE_NEW_LINE + Constant.MESSAGE_EXIT, Constant.CAPTION_ERROR, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { this.Dispose(); } return; } } } if (MessageBox.Show(string.Format(Constant.MESSAGE_UPDATE_SUCCESS, "Sản phẩm " + data.MaSanPham) + Constant.MESSAGE_NEW_LINE + Constant.MESSAGE_EXIT, Constant.CAPTION_CONFIRMATION, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { this.Dispose(); } }
public static bool Update(DinhLuong data, User user) { try { if (data != null) { dbContext.SubmitChanges(); return true; } return false; } catch { return false; } }
public static bool Insert(DinhLuong data, User user) { try { dbContext.DinhLuongs.InsertOnSubmit(data); dbContext.SubmitChanges(); return true; } catch { return false; } }