Exemplo n.º 1
0
        public ClinicInfoManageViewModel()
        {
            if (App.Current != null)
            {
                _esClinicContext = App.Current.EsClinicContext;
            }

            LogoImg = new BitmapImage(new Uri("/ESClinic;component/Resources/Placeholder.jpg", UriKind.Relative));
            NotifyOfPropertyChange(() => LogoImg);

            var info = _esClinicContext.ClinicInfoes.FirstOrDefault();

            if (info != null)
            {
                _info         = info;
                ClinicName    = info.Name;
                ClinicAddress = info.Address;
                ClinicPhone   = info.Phone;
                if (info.Logo != null)
                {
                    LogoImg = ImageDataConverter.BytesToBitmapImage(info.Logo);
                    NotifyOfPropertyChange(() => LogoImg);
                }
            }
            else
            {
                _info = new ClinicInfo();
                _esClinicContext.ClinicInfoes.Add(_info);
                _esClinicContext.SaveChanges();
            }
        }
        public void AddUser()
        {
            var newuser = new User()
            {
                Name = Name
            };

            _esClinicContext.Users.Add(newuser);
            _esClinicContext.SaveChanges();
            Users.Add(newuser);
        }
Exemplo n.º 3
0
        public void AddProduct()
        {
            var product = new Product()
            {
                BrandName   = BrandName,
                GenericDrug = GenericDrug,
                Quantity    = Quantity,
                Price       = Price,
                Type        = Type,
                Country     = Country,
                Exp         = Exp
            };

            _esClinicContext.Products.Add(product);
            _esClinicContext.SaveChanges();
            Products.Add(product);
        }
Exemplo n.º 4
0
        public void Finished()
        {
            try
            {
                SaveEsResult();
                var esRecord = new EndoscopyRecord()
                {
                    EndoscopyTypeId = SelectedEsType.EndoScopyTypeId,
                    SessionId       = _sessionId,
                    Result          = _esResult
                };
                _esClinicContext.EndoscopyRecords.Add(esRecord);
                _esClinicContext.SaveChanges();

                SelectPhotos();
                if (Photos.Count > 6)
                {
                    MessageBox.Show("Số hình nội soi nhiều hơn 6 tấm!");
                    return;
                }
                foreach (var esPhoto in Photos.Select(photo => new EndoscopyPhoto()
                {
                    EndoscopyRecordId = esRecord.EndoscopyRecordId,
                    Photo = ImageDataConverter.BitmapSourceToBytes(photo.Photo)
                }))
                {
                    _esClinicContext.EndoscopyPhotoes.Add(esPhoto);
                }
                _esClinicContext.SaveChanges();

                _events.Publish(esRecord, action => { Task.Factory.StartNew(action); });
            }
            catch (Exception)
            {
                MessageBox.Show("Dữ liệu không đầy đủ!\n\nVui lòng kiểm lại thông tin mục nội soi.");
            }
            finally
            {
                TryClose();
            }
        }
 public void SaveDrugs()
 {
     foreach (var importProduct in ImportProducts)
     {
         var p = _esClinicContext.Products.First(pp => pp.ProductId == importProduct.ProductId);
         p.Quantity += importProduct.Quantity;
         p.Price     = Price;
         p.Exp       = Exp;
     }
     _esClinicContext.SaveChanges();
     Stage = "Đã lưu";
 }
Exemplo n.º 6
0
        public void AddService()
        {
            var servicetype = new ServiceType()
            {
                Name = Name, Price = Price
            };

            _esClinicContext.ServiceTypes.Add(servicetype);
            _esClinicContext.SaveChanges();

            ServiceTypes.Add(servicetype);
        }
Exemplo n.º 7
0
        public void AddSurcharge()
        {
            var surcharge = new Surcharge()
            {
                Name = Name, Price = Price
            };

            _esClinicContext.Surcharges.Add(surcharge);
            _esClinicContext.SaveChanges();

            Surcharges.Add(surcharge);
        }
        public void AddEsType()
        {
            var esType = new EndoscopyType()
            {
                Name = Name, Pattern = Pattern
            };

            _esClinicContext.EndoscopyTypes.Add(esType);
            _esClinicContext.SaveChanges();

            EsTypes.Add(esType);
        }
Exemplo n.º 9
0
        public void Finished()
        {
            if (_currentSession == null)
            {
                return;
            }

            foreach (var drug in Drugs)
            {
                var product = drug.Product;
                //product.Quantity -= drug.Quantity;
                _esClinicContext.Entry(product).State = EntityState.Modified;
            }
            _currentSession.Fare   = Fare;
            _currentSession.Change = Change;
            _currentSession.Stage  = ClinicStage.Finished;
            _esClinicContext.Entry(_currentSession).State = EntityState.Modified;
            _esClinicContext.Entry(SelectedPayor).State   = EntityState.Deleted;
            _esClinicContext.SaveChanges();
        }
Exemplo n.º 10
0
 public void OkPatient()
 {
     if (SelectedPatient == 0)
     {
         return;
     }
     try
     {
         var visitor = new Visitor()
         {
             PatientId = SelectedPatient
         };
         _esClinicContext.Visitors.Add(visitor);
         _esClinicContext.SaveChanges();
         visitor.Patient = _esClinicContext.Patients.First(p => p.PatientId == visitor.PatientId);
         Visitors.Add(visitor);
         Visitors.Refresh();
     }
     catch (Exception)
     {
         MessageBox.Show("Không thể bệnh nhân!");
     }
 }