public string Sua(BoiBiaCungBDO entityBDO) { BOI_BIA_CUNG entity = db.BOI_BIA_CUNG.Where(x => x.ID == entityBDO.ID).SingleOrDefault(); var kq = ""; if (entity != null) { try { kq = KiemTraTrung(entityBDO.Ten, entityBDO.ID); if (kq != "") { return(kq); } ChuyenBDOThanhDAO(entityBDO, entity); db.Entry(entity).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); kq = string.Format("Lưu mục tin {0} thành công", entity.ID);//trả về số Id } catch { kq = string.Format("Sửa mục tin {0} không thành công!", entity.ID); } } else { return(kq = string.Format("Mục tin {0} không tồn tại!", entity.ID)); } return(kq); }
private void ChuyenBDOThanhDAO(BoiBiaCungBDO entityBDO, BOI_BIA_CUNG entityDAO) { entityDAO.ID = entityBDO.ID; entityDAO.ten = entityBDO.Ten; entityDAO.dien_giai = entityBDO.DienGiai; entityDAO.BHR = entityBDO.BHR; entityDAO.toc_do_tam_gio = entityBDO.TocDoTamGio; entityDAO.phi_keo_met_vuong = entityBDO.PhiKeoMetVuong; entityDAO.thoi_gian_chuan_bi = entityBDO.ThoiGianChuanBi; entityDAO.day_so_luong = entityBDO.DaySoLuong; entityDAO.day_loi_nhuan = entityBDO.DayLoiNhuan; entityDAO.ma_01 = entityBDO.Ma_01; entityDAO.don_vi_tinh = entityBDO.DonViTinh; entityDAO.day_so_luong_niem_yet = entityBDO.DaySoLuongNiemYet; entityDAO.thu_tu = entityBDO.ThuTu; }
public string Them(BoiBiaCungBDO entityBDO) { string kq = ""; try { kq = KiemTraTrung(entityBDO.Ten); if (kq != "") { return(kq); } BOI_BIA_CUNG entity = new BOI_BIA_CUNG(); ChuyenBDOThanhDAO(entityBDO, entity); db.BOI_BIA_CUNG.Add(entity); db.SaveChanges(); kq = string.Format("Mục tin:{0}", entity.ID); } catch { kq = string.Format("Thêm Mục tin {0} lỗi!", entityBDO.ID); } return(kq); }