/// <summary> /// Insert new CHITIETNHAP /// </summary> /// <param name="businessObject">CHITIETNHAP object</param> /// <returns>true for successfully saved</returns> public bool Insert(CHITIETNHAP businessObject) { if (!businessObject.IsValid) { businessObject.ShowErrorMessage();//throw new InvalidBusinessObjectException(businessObject.BrokenRulesList.ToString()); } bool ans = _dataObject.Insert(businessObject); try { NHAPTHUOCFactory NHAPTHUOCService = new NHAPTHUOCFactory(); NHAPTHUOC nhapthuoc = NHAPTHUOCService.GetAllEntities().ToList() .Where(p => p.ID == businessObject.NHAPTHUOCID) .FirstOrDefault(); NHAPTHUOCService.Update(nhapthuoc); THUOCFactory THUOCService = new THUOCFactory(); THUOC thuoc = THUOCService.GetAllEntities().ToList() .Where(p => p.ID == businessObject.THUOCID) .FirstOrDefault(); thuoc.SOLUONG += businessObject.SOLUONG; THUOCService.Update(thuoc); } catch { } return(ans); }
/// <summary> /// Update existing THUOC /// </summary> /// <param name="businessObject">THUOC object</param> /// <returns>true for successfully saved</returns> public bool Update(THUOC businessObject) { if (!businessObject.IsValid) { businessObject.ShowErrorMessage();//throw new InvalidBusinessObjectException(businessObject.BrokenRulesList.ToString()); } return(_dataObject.Update(businessObject)); }
/// <summary> /// delete by primary key /// </summary> /// <param name="keys">primary key</param> /// <returns>true for succesfully deleted</returns> public bool Delete(CHITIETCAPTHUOCKeys keys) { CHITIETCAPTHUOC businessObject = GetAllEntities().Where(p => p.ID == keys.ID).FirstOrDefault(); THUOCFactory THUOCService = new THUOCFactory(); THUOC THUOC = THUOCService.GetAllEntities().Where(p => p.ID == businessObject.THUOCID).FirstOrDefault(); THUOC.SOLUONG += businessObject.SOLUONG; THUOCService.Update(THUOC); return(_dataObject.Delete(keys)); }
/// <summary> /// Insert new CHITIETCAPTHUOC /// </summary> /// <param name="businessObject">CHITIETCAPTHUOC object</param> /// <returns>true for successfully saved</returns> public bool Insert(CHITIETCAPTHUOC businessObject) { if (!businessObject.IsValid) { businessObject.ShowErrorMessage();//throw new InvalidBusinessObjectException(businessObject.BrokenRulesList.ToString()); } THUOCFactory THUOCService = new THUOCFactory(); THUOC THUOC = THUOCService.GetAllEntities().Where(p => p.ID == businessObject.THUOCID).FirstOrDefault(); THUOC.SOLUONG -= businessObject.SOLUONG; THUOCService.Update(THUOC); return(_dataObject.Insert(businessObject)); }