Beispiel #1
0
        public void BeginAnnuler(object param)
        {
            try
            {
                if (SelectedReservations.EtatOperation == "RESERVEE")
                {
                    var result = MessageBox.Show("Voulez vous vraiment annuler cette reservation ?", "Message", MessageBoxButton.YesNo, MessageBoxImage.Question);

                    if (result == MessageBoxResult.Yes)
                    {
                        var canresult = from res in GlobalData.modelRP.Cancelations
                                        where res.Etat == "ACTIF"
                                        select res;

                        if (canresult != null && canresult.Count() != 0)
                        {
                            Cancelations can = canresult.FirstOrDefault();

                            switch (can.idCancelationRules)
                            {
                            case 1:

                                GetCancelFeeTotal(can);

                                break;

                            case 2:
                                GetCancelFeeFirstLast(can);
                                break;

                            case 3:
                                GetCancelFeeFirstLast(can);
                                break;

                            default:
                                break;
                            }
                        }

                        Load();
                    }
                }
            }
            catch (Exception)
            {
            }
        }
        private static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("pt-BR");
            //var tempArgs = new List<string>() { "--emissoes" };
            //var tempArgs = new List<string>() { "--cancelamentos" };
            //var tempArgs = new List<string>() { "--emissoes", "--cancelamentos" };
            foreach (var arg in args)
            {
                switch (arg)
                {
                case "--emissoes":
                    Issuances.Process();
                    break;

                case "--cancelamentos":
                    Cancelations.Process();
                    break;

                default:
                    Console.WriteLine("Argumento Inválido!");
                    break;
                }
            }
        }
Beispiel #3
0
        private void GetCancelFeeFirstLast(Cancelations can)
        {
            Transactions Trans = SelectedReservations.Transactions.FirstOrDefault();
            List <DetailTransactions> lstDtChambres = Trans.DetailTransactions.Where(c => c.Etat == "ACTIF" && c.Produits.Categories.Libelle == "CHAMBRES").ToList();
            List <DetailPaiements>    lstDtPaie     = Trans.DetailPaiements.Where(c => c.Etat == "ACTIF").ToList();

            //Annuler les details transactions concernant la chambre
            foreach (DetailTransactions item in lstDtChambres)
            {
                item.Etat = "ANNULER";
            }

            foreach (DetailPaiements item in lstDtPaie)
            {
                item.Etat = "ANNULER";
            }

            double NbreHr = SelectedReservations.DateArrive.Value.Subtract(DateTime.Now).TotalDays;

            if (NbreHr < can.TimeFrame)
            {
                DetailTransactions trans = new DetailTransactions();
                trans.Produits = GlobalData.modelRP.Produits.Where(c => c.Libelle == "FRAIS D'ANNULATION DE LA RESERVATION").FirstOrDefault();;
                trans.Date     = DateTime.Now;
                trans.Quantite = (float)1;

                if (can.Type == 0)
                {
                    DetailTransactions dt = lstDtChambres.FirstOrDefault();

                    trans.prix = Convert.ToDecimal((double)dt.prix * can.PourcentageAfter * 0.01) + can.HandlingFee;
                }
                else
                {
                    trans.prix = Convert.ToDecimal(can.MontantAfter) + can.HandlingFee;
                }

                trans.Descriptions = "FRAIS D'ANNULATION DE LA RESERVATION " + SelectedReservations.ID;
                trans.Montant      = Convert.ToDecimal(trans.Quantite * (double)trans.prix);
                trans.Etat         = "ACTIF";
                //trans.idHotel = GlobalData.HotId;

                Trans.DetailTransactions.Add(trans);

                Trans.TotalTTC = Convert.ToDecimal(trans.Quantite * (double)trans.prix) + can.HandlingFee;
                Trans.TotalHT  = Trans.TotalTTC;
                Trans.TVA      = 0;

                if ((Trans.TotalPaye - Trans.TotalTTC) < 0)
                {
                    Trans.TotalReste = 0;

                    DetailPaiements dtPaie = new DetailPaiements();
                    dtPaie.Montant          = (double)Trans.TotalPaye;
                    dtPaie.DatePaiement     = DateTime.Now;
                    dtPaie.MethodePaiements = GlobalData.modelRP.MethodePaiements.Where(c => c.Libelle == "ESPECE").FirstOrDefault();
                    dtPaie.Transactions     = Trans;
                    dtPaie.Etat             = "ACTIF";
                    //dtPaie.idHotel = GlobalData.HotId;
                }
                else
                {
                    Trans.TotalReste = 0;
                    Trans.TotalPaye  = Trans.TotalTTC;

                    DetailPaiements dtPaie = new DetailPaiements();
                    dtPaie.Montant          = (double)Trans.TotalPaye;
                    dtPaie.DatePaiement     = DateTime.Now;
                    dtPaie.MethodePaiements = GlobalData.modelRP.MethodePaiements.Where(c => c.Libelle == "ESPECE").FirstOrDefault();
                    dtPaie.Transactions     = Trans;
                    dtPaie.Etat             = "ACTIF";
                    //dtPaie.idHotel = GlobalData.HotId;
                }

                SelectedReservations.TotalPaye  = Trans.TotalPaye;
                SelectedReservations.TotalReste = Trans.TotalReste;
                SelectedReservations.TotalTTC   = Trans.TotalTTC;
                SelectedReservations.Reduction  = Trans.Reduction;

                Trans.Etat = "PAYE";
                SelectedReservations.CancelDate    = DateTime.Now;
                SelectedReservations.Etat          = "TERMINER";
                SelectedReservations.EtatOperation = "ANNULER";

                if (SelectedReservations.Chambres != null)
                {
                    SelectedReservations.Chambres.EtatOperation = "LIBRE";
                }

                GlobalData.modelRP.SaveChanges();

                Load();

                MessageBox.Show("Operation terminée", "Message", MessageBoxButton.OK, MessageBoxImage.None);
            }
            else if (NbreHr > can.TimeFrame)
            {
                DetailTransactions trans = new DetailTransactions();
                trans.Produits = GlobalData.modelRP.Produits.Where(c => c.Libelle == "FRAIS D'ANNULATION DE LA RESERVATION").First();;
                trans.Date     = DateTime.Now;
                trans.Quantite = (float)1;

                if (can.Type == 0)
                {
                    DetailTransactions dt = lstDtChambres.FirstOrDefault();

                    trans.prix = Convert.ToDecimal((double)dt.prix * can.PourcentageBefore * 0.01) + can.HandlingFee;
                }
                else
                {
                    trans.prix = Convert.ToDecimal(can.MonantBefore) + can.HandlingFee;
                }

                trans.Descriptions = "FRAIS D'ANNULATION DE LA RESERVATION " + SelectedReservations.ID;
                trans.Montant      = Convert.ToDecimal(trans.Quantite * (double)trans.prix);
                trans.Etat         = "ACTIF";
                //trans.idHotel = GlobalData.HotId;

                Trans.DetailTransactions.Add(trans);

                Trans.TotalTTC = Convert.ToDecimal(trans.Quantite * (double)trans.prix) + can.HandlingFee;
                Trans.TotalHT  = Trans.TotalTTC;
                Trans.TVA      = 0;

                if ((Trans.TotalPaye - Trans.TotalTTC) < 0)
                {
                    Trans.TotalReste = 0;

                    DetailPaiements dtPaie = new DetailPaiements();
                    dtPaie.Montant          = (double)Trans.TotalPaye;
                    dtPaie.DatePaiement     = DateTime.Now;
                    dtPaie.MethodePaiements = GlobalData.modelRP.MethodePaiements.Where(c => c.Libelle == "ESPECE").FirstOrDefault();
                    dtPaie.Transactions     = Trans;
                    dtPaie.Etat             = "ACTIF";
                    //dtPaie.idHotel = GlobalData.HotId;
                }
                else
                {
                    Trans.TotalReste = 0;
                    Trans.TotalPaye  = Trans.TotalTTC;

                    DetailPaiements dtPaie = new DetailPaiements();
                    dtPaie.Montant          = (double)Trans.TotalPaye;
                    dtPaie.DatePaiement     = DateTime.Now;
                    dtPaie.MethodePaiements = GlobalData.modelRP.MethodePaiements.Where(c => c.Libelle == "ESPECE").FirstOrDefault();
                    dtPaie.Transactions     = Trans;
                    dtPaie.Etat             = "ACTIF";
                    //dtPaie.idHotel = GlobalData.HotId;
                }

                SelectedReservations.TotalPaye  = Trans.TotalPaye;
                SelectedReservations.TotalReste = Trans.TotalReste;
                SelectedReservations.TotalTTC   = Trans.TotalTTC;
                SelectedReservations.Reduction  = Trans.Reduction;

                Trans.Etat = "PAYE";
                SelectedReservations.CancelDate             = DateTime.Now;
                SelectedReservations.Etat                   = "TERMINER";
                SelectedReservations.EtatOperation          = "ANNULER";
                SelectedReservations.Chambres.EtatOperation = "LIBRE";


                GlobalData.modelRP.SaveChanges();

                Load();

                MessageBox.Show("Operation terminée", "Message", MessageBoxButton.OK, MessageBoxImage.None);
            }
            else
            {
            }
        }