Example #1
0
 public bool Push(RForm vAdd)
 {
     if (IsFull)
     {
         Maximum = RConvert.ToInt(RConvert.ToFloat(Maximum) * 1.20f);
     }
     if (!IsFull)
     {
         try {
             if (objectarr[iCount] == null)
             {
                 objectarr[iCount] = new RForm();
             }
             objectarr[iCount] = vAdd;                   //debug performance (change objectarr to refvarr (& rewrite call logic!)(?))
             iCount++;
             //sLogLine="debug_push{iCount:"+iCount.ToString()+"}";
             return(true);
         }
         catch (Exception exn) {
             RReporting.ShowExn(exn, "RFormStack Push", "adding rform to stack {iCount:" + iCount.ToString() + "}");
         }
         return(false);
     }
     else
     {
         RReporting.ShowErr("RFormStack is full", "RFormStack Push", "adding rform to stack {vAdd:" + ((vAdd == null)?"null":"non-null") + "; iCount:" + iCount.ToString() + "; }");
         return(false);
     }
 }
Example #2
0
        public RForm Pop()
        {
            //RReporting.WriteLine("debug rform pop iCount="+iCount.ToString()+" and "+(IsEmpty?"is":"is not")+" empty.");
            RForm vReturn = null;

            if (iCount <= 0)
            {
                if (iCount == 0)
                {
                    return(null);
                }
                else                   //else <0
                {
                    RReporting.Warning("RFormStack iCount was less than zero so setting to zero.", "taking rform from stack", "RForm Pop {iCount:" + iCount.ToString() + "}");
                    iCount = 0;
                    return(null);
                }
            }
            else
            {
                iCount--;
                try {
                    vReturn = objectarr[iCount];                   //this is correct since decremented first
                }
                catch (Exception exn) {
                    RReporting.ShowExn(exn, "RFormStack Pop", "accessing RFormStack index {at:" + iCount.ToString() + "}");
                }
            }
            return(vReturn);
        }        //end Pop
Example #3
0
 public bool Poke(int iRel, RForm objectVal)
 {
     try {
         if (iRel < iCount_PlusFirstIsOneAfterLast)
         {
             arrobjects[Wrap(iFirst + iRel)] = objectVal;
             return(true);
         }
     }
     catch (Exception exn) {
         RReporting.ShowExn(exn);
     }
     return(false);
 }
Example #4
0
 private bool PokeAbs(int iAbs, RForm objectVal)
 {
     try {
         if (InUsedRange(iAbs))
         {
             arrobjects[iAbs] = objectVal;
             return(true);
         }
     }
     catch (Exception exn) {
         RReporting.ShowExn(exn);
     }
     return(false);
 }
Example #5
0
        public RForm Deq()           //Dequeue
        //sLogLine=("debug deq iCount_PlusFirstIsOneAfterLast="+iCount_PlusFirstIsOneAfterLast.ToRForm()+" and "+(IsEmpty?"is":"is not")+" empty.");
        {
            RForm objectReturn = null;

            if (!IsEmpty)
            {
                int iReturn = iFirst;
                iFirst = Wrap(iFirst + 1);               //modify first since dequeueing
                iCount_PlusFirstIsOneAfterLast--;
                objectReturn        = arrobjects[iReturn];
                arrobjects[iReturn] = null;
            }
            return(objectReturn);
        }
Example #6
0
 private void cmd_begin_manual_Click(object sender, EventArgs e)
 {
     if (lst_manual.SelectedItems.Count != 0)
     {
         this.Close();
         TestLoader tlk = new TestLoader(_fe);
         tlk.SetHumanID();
         if (tlk.HumanID != 0)
         {
             RForm rf = new RForm(int.Parse(lst_manual.SelectedItems[0].SubItems[0].Text), tlk.HumanID, _ge, _fe);
             rf.WindowState = FormWindowState.Maximized;
             rf.ShowDialog();
             this.Close();
         }
     }
     else
     {
         MessageBox.Show("Необходимо выбрать тест");
     }
 }
Example #7
0
 public bool Enq(RForm objectAdd)           //Enqueue
 {
     if (!IsFull)
     {
         try {
             arrobjects[NewIndex] = objectAdd;
             iCount_PlusFirstIsOneAfterLast++;
             //sLogLine="debug enq iCount_PlusFirstIsOneAfterLast="+iCount_PlusFirstIsOneAfterLast.ToRForm();
             return(true);
         }
         catch (Exception exn) {
             RReporting.ShowExn(exn, "accessing RFormq array", "RFormq Enq(" + RReporting.RFormMessage(objectAdd, false) + ") {enqueue-at:" + NewIndex.ToRForm() + "}");
         }
         return(false);
     }
     else
     {
         RReporting.ShowErr("RFormQ is full, can't enqueue", "RFormQ Enq(" + ((objectAdd == null)?"null RForm":"non-null") + ") {used:" + iCount_PlusFirstIsOneAfterLast.ToRForm() + "}");
         return(false);
     }
 }
        public ActionResult AddPush(ViewModelAddPush model, int? id)
        {
            if (AccessSalon(id).IsFalse())
            {
                return RedirectError();
            }


            if (ModelState.IsValid)
            {
                var form = new RForm();
                var prestation = form.Get("prestations");

                if (prestation.IsNullOrEmpty())
                {
                    ViewBag.Error =
                        "Erreur lors de la récupération des prestations, vous devez en selectionner au moins une";
                }
                else
                {
                    var tabPrestations = prestation.Contains(",")
                    ? prestation.Split(',').ToList()
                    : new List<string>
                    {
                        prestation
                    };

                    if (tabPrestations.IsEmpty())
                    {
                        ViewBag.Error =
                            "Erreur lors de la récupération des prestations, vous devez en selectionner au moins une";
                    }
                    else
                    {
                        var date = form.Get("Date");
                        if (date.IsNullOrEmpty())
                        {
                            ViewBag.Error =
                            "Erreur lors de la récupération de la date, vous devez en selectionner une";
                        }
                        else
                        {
                            model.Form.Date = date.StringToDateTime();
                            if (Bdd.AddPush(id, tabPrestations, model))
                            {
                                TempData["Success"] = "Push bien ajouté";
                                return RedirectToRoute("Backend_salon_gererpush", new { id = id });
                            }

                            ViewBag.Error = "Erreur lors de l'ajout du push";
                        }
                    }
                }
            }

            var prestations = Bdd.GetTypePrestationsSalon(id);
            model.TypePrestations = prestations;
            model.SetTypePrestation(prestations);
            model.Authorize = Bdd.AuthorizeAddPush(id);
            return View(model);
        }
Example #9
0
        /// <summary>
        ///     Permet d'ajouter un salon
        /// </summary>
        /// <param name="admin">AdministrateurFranchise</param>
        /// <param name="salon">Salon</param>
        /// <returns>bool</returns>
        public int AddSalon(ViewModelFormAddSalon model = null)
        {
            try
            {
                if (model.IsNull()) return 0;
                
                var salon = new Salon
                {
                    FicheSalon = new FicheSalon
                    {
                        JourOuvertures = GetDisponibiliteInit(),
                        Adresse = model.Adresse,
                        CodePostal = model.CodePostal,
                        Pays = model.Pays,
                        Ville = model.NomVille,
                        NombreEmployes = 0,
                        Nom = model.NomSalon,
                        Description = model.DescriptionSalon
                    },
                    ListeAvis = new List<Avis>(),
                    ListeEmployes = new List<Employe>(),
                    Moyenne = 0,
                    PrestationClients = new List<ReservationClient>(),
                    IdAbonnement = model.AbonnementId,
                    
                };
                if (salon.IsNull()) return 0;

                //On regarde si il y a une photo de profil du salon
                var rform = new RForm();
                salon.FicheSalon.ImageProfil = rform.GetImage("~/Content/ImagesSalons/", "file", 400, 400);

                Salons.Add(salon);

                SaveChanges();
                return salon.Id;
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    foreach (var ve in eve.ValidationErrors)
                    {
                        var g = ve.ErrorMessage;
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                            ve.PropertyName, ve.ErrorMessage);
                    }
                }
                return 0;
            }
        }
Example #10
0
        /// <summary>
        ///     Permet de mettre à jour les informations du salon
        /// </summary>
        /// <param name="idSalon">Id du salon</param>
        /// <param name="model">Le form</param>
        /// <returns>bool</returns>
        public bool UpdateSalon(int? idSalon, ViewModelFormUpdateSalon model = null)
        {
            try
            {
                if (model.IsNull() || idSalon.IsNull()) return false;

                //Création de la nouvelle liste d'ouverture
                var listeJours = CreateListeJourOuvertures(model);
                if (listeJours.IsEmpty()) return false;

                //On récup le salon
                var salon = GetSalonById(idSalon);
                if (salon.IsNull()) return false;

                if (LoadFicheSalon(salon).IsFalse()) return false;


                //Update des infos du salon
                Entry(salon.FicheSalon).State = EntityState.Modified;
                salon.FicheSalon.Adresse = model.Adresse;
                salon.FicheSalon.CodePostal = model.CodePostal;
                salon.FicheSalon.Pays = model.Pays;
                salon.FicheSalon.Nom = model.NomSalon;
                salon.FicheSalon.Ville = model.NomVille;
                salon.FicheSalon.Description = model.DescriptionSalon;

                //On regarde si il y a une photo de profil du salon
                var rform = new RForm();
                var filename = rform.GetImage("~/Content/ImagesSalons/", "file", 400, 400);
                if (filename.IsNotNullOrEmpty())
                    salon.FicheSalon.ImageProfil = filename;

                //Update jour ouverture
                foreach (var jour1 in salon.FicheSalon.JourOuvertures.Where(j => j.IsNotNull()))
                {
                    foreach (
                        var jour2 in
                            listeJours.Where(j => j.IsNotNull()).Where(jour2 => jour2.Jour.Id.Equals(jour1.IdJour)))
                    {
                        jour1.CreneauMatin = jour2.CreneauMatin;
                        jour1.CreneauAprem = jour2.CreneauAprem;
                        break;
                    }
                }

                SaveChanges();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
        public ActionResult UpdateInfoEmploye(ViewModelFormInfoEmployeFranchise model, int? id)
        {
            if (adminFranchise.IsNull() || Bdd.AccessEmploye(id, adminFranchise).IsFalse())
            {
                return RedirectError();
            }

            if (id.IsNull())
            {
                TempData["Error"] = "Erreur lors de la récupération des informations";
                return RedirectToRoute("Backend_franchise_profilemploye", new { id = id });
            }

            //On récup l'id salon en parameter
            var form = new RForm();
            var nom = form.Get("FormEmploye.Nom");
            var prenom = form.Get("FormEmploye.Prenom");
            var genre = form.Get("FormEmploye.GenreId");
            var email = form.Get("FormEmploye.Email");

            if (nom.IsNullOrEmpty() || prenom.IsNullOrEmpty() || genre.IsNullOrEmpty() || email.IsNullOrEmpty())
            {
                TempData["Error"] = "Erreur lors de la récupération des informations";
            }
            else
            {
                if (Bdd.UpdateEmploye(id, nom, prenom, email, genre))
                {
                    TempData["Success"] = "L'employé a bien été modifié";
                }
                else
                {
                    TempData["Error"] = "Erreur lors de la modification de l'employé";
                }
            }

            return RedirectToRoute("Backend_franchise_profilemploye", new { id = id });
        }
        public ActionResult AddSalonToEmploye(ViewModelFormAddSalonToEmploye model, int? id)
        {
            if (adminFranchise.IsNull() || Bdd.AccessEmploye(id, adminFranchise).IsFalse())
            {
                return RedirectError();
            }

            if(model.IsNull() || id.IsNull())
            {
                TempData["Error"] = "Erreur lors de la récupération des informations";
                return RedirectToRoute("Backend_franchise_profilemploye", new {id = id});
            }

            //On récup l'id salon en parameter
            var form = new RForm();
            var idsalon = form.Get("FormAddSalonToEmploye.IdSalon").ToInt();

            if (idsalon < 0)
            {
                TempData["Error"] = "Erreur lors de l'ajout du salon à l'employé";
            }
            else
            {
                if (Bdd.AddSalonToEmploye(idsalon, id))
                {
                    TempData["Success"] = "Le salon a bien été ajouté à l'employé";
                }
                else
                {
                    TempData["Error"] = "Erreur lors de l'ajout du salon à l'employé";
                }
            }

            return RedirectToRoute("Backend_franchise_profilemploye", new { id = id });
        }