예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <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));
        }
예제 #3
0
        /// <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));
        }
예제 #4
0
        /// <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));
        }