public static bool Delete(GiaChinhThuc data, User user) { try { if (data != null) { dbContext.GiaChinhThucs.DeleteOnSubmit(data); dbContext.SubmitChanges(); return true; } } catch { //return false; } CreateSQlConnection(); return false; }
partial void DeleteGiaChinhThuc(GiaChinhThuc instance);
partial void UpdateGiaChinhThuc(GiaChinhThuc instance);
partial void InsertGiaChinhThuc(GiaChinhThuc instance);
private void detach_GiaChinhThucs(GiaChinhThuc entity) { this.SendPropertyChanging(); entity.SanPham = null; }
private void UpdateData() { foreach (DataGridViewRow row in dgvThongTin.Rows) { if (row.Cells[colId.Name].Value != null && !string.IsNullOrEmpty(row.Cells[colId.Name].Value.ToString())) { DTO.GiaChinhThuc data = GiaChinhThucBus.GetById(ConvertUtil.ConvertToInt(row.Cells[colId.Name].Value)); data.Gia = row.Cells[colGia.Name].Value == null ? 0 : ConvertUtil.ConvertToLong(row.Cells[colGia.Name].Value.ToString().Replace(Constant.SYMBOL_LINK_MONEY, string.Empty)); if (GiaChinhThucBus.Update(data, FormMain.user)) { //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.GiaChinhThuc data = new DTO.GiaChinhThuc(); data.IdSanPham = ConvertUtil.ConvertToInt(row.Cells[colIdSanPham.Name].Value); data.Gia = row.Cells[colGia.Name].Value == null ? 0 : ConvertUtil.ConvertToLong(row.Cells[colGia.Name].Value.ToString().Replace(Constant.SYMBOL_LINK_MONEY, string.Empty)); if (GiaChinhThucBus.Insert(data, FormMain.user)) { //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, "Giá chính thức"), Constant.CAPTION_CONFIRMATION, MessageBoxButtons.OK, MessageBoxIcon.Information); }
public static bool Update(GiaChinhThuc data, User user) { try { if (data != null) { dbContext.SubmitChanges(); return true; } return false; } catch { return false; } }
public static bool Insert(GiaChinhThuc data, User user) { try { if (GetByIdSanPham(data.IdSanPham) != null) { return false; } dbContext.GiaChinhThucs.InsertOnSubmit(data); dbContext.SubmitChanges(); return true; } catch { return false; } }