Example #1
0
        // Bouton re-impression facture
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            AdmissionRecord mySelectedAfacture = (AdmissionRecord)ListAFactureTermine.SelectedItem;
            String          DescItem           = "";
            String          MontantFacture     = "0.00";
            String          DescTV             = "";
            String          DescTel            = "";
            String          DescTarif          = " tarif chambre Standard";
            TimeSpan        difference         = new TimeSpan();
            decimal         extTelRate         = 0;
            decimal         extTVRate          = 0;
            decimal         extRoomRate        = 0;
            decimal         Total = 0;

            difference = (TimeSpan)(mySelectedAfacture.DischargeDate - mySelectedAfacture.AdmitDate);
            int totjours = Convert.ToInt32(difference.TotalDays);


            if (mySelectedAfacture.Extra.Phone == true)
            {
                decimal telrate = 0;

                var gettelrate = (from p in context.Extra_Rates
                                  where p.AmenityName == "PHONE"
                                  select p).First().DailyCost;

                DescTel    = " - Option téléphone - " + gettelrate + "$ par jours ";
                telrate    = Convert.ToDecimal(gettelrate);
                extTelRate = totjours * telrate;
            }

            if (mySelectedAfacture.Extra.TV == true)
            {
                decimal tvrate = 0;

                var gettvrate = (from p in context.Extra_Rates
                                 where p.AmenityName == "TV"
                                 select p).First().DailyCost;

                DescTV    = " - Option télévision - " + gettvrate + "$ par jours ";
                tvrate    = Convert.ToDecimal(gettvrate);
                extTVRate = totjours * tvrate;
            }

            if (mySelectedAfacture.Extra.SemiPriivate == true)
            {
                decimal roomrate = 0;

                var getroomrate = (from p in context.Extra_Rates
                                   where p.AmenityName == "SEMI"
                                   select p).First().DailyCost;

                roomrate    = Convert.ToDecimal(getroomrate);
                extRoomRate = roomrate * totjours;

                DescTarif = " tarif chambre Semi-Privé " + getroomrate + "$";
            }

            if (mySelectedAfacture.Extra.Private == true)
            {
                decimal roomrate = 0;

                var getroomrate = (from p in context.Extra_Rates
                                   where p.AmenityName == "PRIVÉ"
                                   select p).First().DailyCost;

                roomrate    = Convert.ToDecimal(getroomrate);
                extRoomRate = roomrate * totjours;

                DescTarif = " tarif chambre Privé " + getroomrate + "$";
            }

            DescItem = "Hospitalisation de " + totjours.ToString() + " jours" + DescTel + DescTV + DescTarif;

            Total          = extRoomRate + extTelRate + extTVRate;
            MontantFacture = Total.ToString() + "$";

            Facture myfacture = new Facture(mySelectedAfacture, DescItem, MontantFacture);

            myfacture.ShowDialog();
        }
Example #2
0
        // Bouton genere Facture
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            AdmissionRecord mySelectedAfacture = (AdmissionRecord)ListAFacture.SelectedItem;
            String          DescItem           = "";
            String          MontantFacture     = "0.00";
            String          DescTV             = "";
            String          DescTel            = "";
            String          DescTarif          = " tarif chambre Standard";
            decimal         extTelRate         = 0;
            decimal         extTVRate          = 0;
            decimal         extRoomRate        = 0;
            decimal         Total = 0;

            TimeSpan difference = (TimeSpan)(mySelectedAfacture.DischargeDate - mySelectedAfacture.AdmitDate);
            int      totjours   = Convert.ToInt32(difference.TotalDays);


            if (mySelectedAfacture.Extra.Phone == true)
            {
                decimal telrate = 0;

                var gettelrate = (from p in context.Extra_Rates
                                  where p.AmenityName == "PHONE"
                                  select p).First().DailyCost;

                DescTel    = " - Option téléphone - " + gettelrate + "$ par jours ";
                telrate    = Convert.ToDecimal(gettelrate);
                extTelRate = totjours * telrate;
            }

            if (mySelectedAfacture.Extra.TV == true)
            {
                decimal tvrate = 0;

                var gettvrate = (from p in context.Extra_Rates
                                 where p.AmenityName == "TV"
                                 select p).First().DailyCost;

                DescTV    = " - Option télévision - " + gettvrate + "$ par jours ";
                tvrate    = Convert.ToDecimal(gettvrate);
                extTVRate = totjours * tvrate;
            }

            if (mySelectedAfacture.Extra.SemiPriivate == true)
            {
                decimal roomrate = 0;

                var getroomrate = (from p in context.Extra_Rates
                                   where p.AmenityName == "SEMI"
                                   select p).First().DailyCost;

                roomrate    = Convert.ToDecimal(getroomrate);
                extRoomRate = roomrate * totjours;

                DescTarif = " tarif chambre Semi-Privé " + getroomrate + "$";
            }

            if (mySelectedAfacture.Extra.Private == true)
            {
                decimal roomrate = 0;

                var getroomrate = (from p in context.Extra_Rates
                                   where p.AmenityName == "PRIVÉ"
                                   select p).First().DailyCost;

                roomrate    = Convert.ToDecimal(getroomrate);
                extRoomRate = roomrate * totjours;

                DescTarif = " tarif chambre Privé " + getroomrate + "$";
            }

            DescItem = "Hospitalisation de " + totjours.ToString() + " jours" + DescTel + DescTV + DescTarif;

            Total          = extRoomRate + extTelRate + extTVRate;
            MontantFacture = Total.ToString() + "$";

            Facture myfacture = new Facture(mySelectedAfacture, DescItem, MontantFacture);

            myfacture.ShowDialog();

            mySelectedAfacture.Facture = true;
            context.SubmitChanges();

            var query = from a in context.AdmissionRecords
                        where a.Facture == false && a.DischargeDate != null
                        select a;

            ObservableCollection <AdmissionRecord> myFactureList = new ObservableCollection <AdmissionRecord>();

            var getlist = query;

            foreach (var item in getlist)
            {
                myFactureList.Add(item);
            }

            var queryTemine = from a in context.AdmissionRecords
                              where a.Facture == true
                              select a;

            ObservableCollection <AdmissionRecord> myFactureListTermnine = new ObservableCollection <AdmissionRecord>();

            var getlisttermine = queryTemine;

            foreach (var item in getlisttermine)
            {
                myFactureListTermnine.Add(item);
            }

            ListAFacture.DataContext        = myFactureList;
            ListAFactureTermine.DataContext = myFactureListTermnine;
        }