Пример #1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (checkFields())
            {
                // Nouveau sejour de patient
                Sejour sejour = new Sejour();
                sejour.PatientID  = patient.ID;
                sejour.MedID      = medecin.MedID;
                sejour.LitID      = lit.ID;
                sejour.Telephone  = xbPhone.IsChecked;
                sejour.Television = xbTV.IsChecked;
                sejour.PreDispo   = predispo;
                decimal totalfacture = 0;
                if (xbPhone.IsChecked.Value)
                {
                    totalfacture += 7.50M;
                }
                if (xbTV.IsChecked.Value)
                {
                    totalfacture += 42.50M;
                }
                Chambre chambre = mgr.BDD.Chambres.Where(x => x.ID == lit.ChambreID).FirstOrDefault();
                if (chambre.Type.Trim() == "SemiPrivé" && predispo == 0)
                {
                    totalfacture += 267;
                }
                if (chambre.Type.Trim() == "Privé" && predispo < 2)
                {
                    totalfacture += 571;
                }
                sejour.TotalFacture = totalfacture;
                sejour.DateDebut    = DateTime.Now;

                mgr.BDD.Sejours.Add(sejour);
                mgr.SaveChanges();
                lit.Occupe = true;
                mgr.SaveChanges();
                clearFields();
                actualiser();

                txtBoxPredispo.Text = "• Sejour enregistré!";
            }
            else
            {
                // En cas d'erreur
                txtBoxErreur.Text = message;
                message           = String.Empty;
            }
        }