Пример #1
0
        // GET: Centres/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Centre centre = db.Centres.Find(id);

            if (centre == null)
            {
                return(HttpNotFound());
            }
            ViewBag.addressId = new SelectList(db.Addresses, "AdressId", "Country", centre.addressId);
            return(View(centre));
        }
Пример #2
0
        public void AjouterCentre(int id, String description)
        {
            c   = new Centre(id, description);
            cDA = new CentreDA();
            Boolean test = cDA.insert(c);

            if (test == true)
            {
                MessageBox.Show("L'ajout de cette organisation est effectué avec succes", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Erreur de l'insertion", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public ActionResult AddDepartment(Centre model)
        {
            if (db.Centre.Any(c => c.Name == model.Name))
            {
                ModelState.AddModelError("Name", "Name already present!");
                return(View(model));
            }

            db.Centre.Add(model);
            db.SaveChanges();

            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Added Centre", "Centres");

            return(RedirectToAction("DepartmentList"));
        }
        public ActionResult EditDepartment(int id, Centre model)
        {
            var department = db.Centre.Single(c => c.Id == id);

            department.Name        = model.Name;
            department.Description = model.Description;
            department.Status      = model.Status;
            department.Contact     = model.Contact;
            department.Location    = model.Location;

            db.SaveChanges();

            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Updated Centre Details", "Centre");

            return(RedirectToAction("DepartmentList"));
        }
Пример #5
0
        public async Task <IActionResult> Create([Bind("Id,Name,Type")] Centre centre)
        {
            if (ModelState.IsValid)
            {
                _context.Add(centre);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Type"] = new List <SelectListItem> {
                new SelectListItem {
                    Text = AdoptionCentreString, Value = AdoptionCentreString
                }, new SelectListItem {
                    Text = CleansingCentreString, Value = CleansingCentreString
                }
            };
            return(View(centre));
        }
Пример #6
0
 public CentreDashboardInformation(
     Centre centre,
     AdminUser adminUser,
     int delegateCount,
     int courseCount,
     int adminCount,
     int supportTicketCount,
     int?centreRank
     )
 {
     Centre             = centre;
     FirstName          = adminUser.FirstName;
     CategoryName       = adminUser.CategoryName;
     DelegateCount      = delegateCount;
     CourseCount        = courseCount;
     AdminCount         = adminCount;
     SupportTicketCount = supportTicketCount;
     CentreRank         = centreRank;
 }
Пример #7
0
        /// <summary>
        /// Utilisation d'un delegates car modification ou ajout seul la faonction controleur change
        /// </summary>
        /// <param name="fct"></param>
        private void AjoutModif(ADDUpd fct)
        {
            try
            {
                int numcentre = (centre == null) ? 0 : centre.NumCentre;

                Centre tmp = new Centre(numcentre, txtTel.Text, txtAdresse.Text, null, (Secteur)cbSecteur.SelectedItem, txtNomCentre.Text, client);
                // int i = ctrlClient.AjouterCentre(tmp);
                int i = fct(tmp);

                if (centre == null)
                {
                    centre = new Centre();
                }
                centre           = tmp;
                centre.NumCentre = i;

                if (equipements.Count != 0 && mode == Mode.MODIFICATION)
                {
                    ctrlClient.DelEquipement(i);
                }

                if (i != 0 && bsEquipement.Count != 0)
                {
                    //Ajout liste equipements
                    foreach (Equipement equi in bsEquipement)
                    {
                        equi.Centre = new Centre {
                            NumCentre = i
                        };
                        int f = ctrlClient.AjouterEquipement(equi);
                    }
                }

                mode = Mode.LECTURE;
                Affichage(mode);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #8
0
        public async Task <Centre> Add(Centre newCentre)
        {
            if (_centreRepository
                .Search(c => c.Name.ToLower() == newCentre.Name.ToLower())
                .Result.Any())
            {
                return(null);
            }

            var org = await _organisationService.GetById(newCentre.OrganisationId);

            if (org == null)
            {
                return(null);
            }

            await _centreRepository.Add(newCentre);

            return(newCentre);
        }
Пример #9
0
 public bool AddScoreCard(ScoreCardEnveloppe enveloppe)
 {
     // connection bdd
     using (var context = new LQDMEntities())
     {
         // on trouve le centre de rattachement
         Centre centre = context.Centre.Where(_ => _.CleExterne == enveloppe.CentreCle).FirstOrDefault();
         if (centre == null)
         {
             // on essaye d'enregistrer une feuille sans identifier le centre
             return(false);
         }
         // on prends l'évenement (par défaut l'évenement Standard)
         Evenement         e  = context.Evenement.Where(_ => _.CentreCentreId == centre.CentreId && _.TypeEvenement == typeEvenement.Standard).FirstOrDefault();
         LQModel.ScoreCard sc = new LQModel.ScoreCard(enveloppe.scoreCard, e);
         context.ScoreCard.Add(sc);
         context.SaveChanges();
     }
     return(true);
 }
        public CertificateInformation(
            Centre centreDetails,
            string?delegateFirstName,
            string delegateLastName,
            string courseName,
            DateTime completionDate,
            string certificateModifier
            )
        {
            SignatureImage  = centreDetails.SignatureImage;
            CentreLogo      = centreDetails.CentreLogo;
            ContactForename = centreDetails.ContactForename;
            ContactSurname  = centreDetails.ContactSurname;
            CentreName      = centreDetails.CentreName;

            DelegateFirstName   = delegateFirstName;
            DelegateLastName    = delegateLastName;
            CourseName          = courseName;
            CompletionDate      = completionDate;
            CertificateModifier = certificateModifier;
        }
Пример #11
0
 public JsonResult GetScoreCard(DateTime dt, string pseudo, string nomCentre)
 {
     if (string.IsNullOrEmpty(pseudo) || string.IsNullOrEmpty(nomCentre))
     {
         return(null);
     }
     using (var context = new LQDMEntities())
     {
         Centre centre = context.Centre.Where(_ => _.Nom.ToLower() == nomCentre.ToLower()).FirstOrDefault();
         if (centre == null)
         {
             // on essaye d'enregistrer une feuille sans identifier le centre
             return(null);
         }
         LQModel.ScoreCard sc = context.ScoreCard.Where(_ => _.dt == dt && _.pseudo == pseudo && _.EvenementCentreCentreId == centre.CentreId).FirstOrDefault();
         //string json = JsonConvert.SerializeObject(sc.ToScoreCardLight());
         JsonResult jResult = new JsonResult();
         jResult.Data = sc.ToScoreCardLight();
         return(jResult);
     }
 }
Пример #12
0
        public JsonResult GetGames(string nomCentre)
        {
            if (string.IsNullOrEmpty(nomCentre))
            {
                return(null);
            }
            using (var context = new LQDMEntities())
            {
                Centre centre = context.Centre.Where(_ => _.Nom.ToLower() == nomCentre.ToLower()).FirstOrDefault();
                if (centre == null)
                {
                    // on essaye d'enregistrer une feuille sans identifier le centre
                    return(null);
                }
                List <LQModel.ScoreCard> lstSc = context.ScoreCard.Where(_ => _.EvenementCentreCentreId == centre.CentreId).ToList();

                JsonResult jResult = new JsonResult();
                jResult.Data = lstSc.Select(_ => _.dt).Distinct();
                return(jResult);
            }
        }
Пример #13
0
        public Centre AddCentre(CreateCentreResource resource)
        {
            var address = new CentreAddress
            {
                Line1      = resource.AddressLine1,
                Line2      = resource.AddressLine2,
                CityOrTown = resource.AddressCityOrTown,
                Province   = resource.Province,
                ZipCode    = resource.ZipCode
            };

            var newCenter = new Centre
            {
                Name    = resource.Name,
                Address = address
            };

            _context.Centres.Add(newCenter);
            _context.SaveChanges();

            return(newCenter);
        }
Пример #14
0
        /// <summary>
        /// Affilie un centre à un belligérant.
        /// </summary>
        /// <param name="region">Région dont le centre est à affilier.</param>
        /// <param name="occupation">Occupation du centre.</param>
        /// <param name="carte">Image représentant la carte.</param>
        /// <param name="outilsGraphiques">Outils graphiques utilisés pour effectuer le dessin.</param>
        public static void AffilieCentre(Centre region, OccupationCentre occupation, Image carte, Graphics outilsGraphiques)
        {
            if (region.EstUnCentre == true)
            {
                /// Les centres mesurent 7x7 pixels.
                Pen traceurContour = new Pen(Color.Black);
                if (occupation.PossesseurCentre == EBelligerant.Palavin)
                {
                    traceurContour = new Pen(Color.Red);
                }

                outilsGraphiques.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
                outilsGraphiques.DrawRectangle(traceurContour, region.CoordonneesCentre.X, region.CoordonneesCentre.Y, 7, 7);

                Color couleur = Convertisseurs.VersCouleur(occupation.PossesseurCentre);
                Brush traceur = new SolidBrush(couleur);
                outilsGraphiques.FillRectangle(traceur, region.CoordonneesCentre.X + 1, region.CoordonneesCentre.Y + 1, 6, 6);
            }
            else
            {
                throw new Exception(String.Format("La région {0} ne contient pas de centre.", region.Nom));
            }
        }
Пример #15
0
 public CentreDashboardViewModel(
     Centre centre,
     string?firstName,
     string?categoryName,
     string userIpAddress,
     int delegates,
     int courses,
     int admins,
     int supportTickets,
     int?centreRank,
     int unacknowledgedNotificationsCount
     )
 {
     CentreDetails               = new DashboardCentreDetailsViewModel(centre, userIpAddress, centreRank);
     FirstName                   = string.IsNullOrWhiteSpace(firstName) ? "User" : firstName;
     CourseCategory              = categoryName ?? "all";
     NumberOfDelegates           = delegates;
     NumberOfCourses             = courses;
     NumberOfAdmins              = admins;
     NumberOfSupportTickets      = supportTickets;
     ViewNotificationsButtonText = "View " + unacknowledgedNotificationsCount + " notification" +
                                   DisplayStringHelper.GetPluralitySuffix(unacknowledgedNotificationsCount);
 }
 public CentreConfigurationViewModel(Centre centre)
 {
     CentreId             = centre.CentreId;
     CentreName           = centre.CentreName;
     RegionName           = centre.RegionName;
     NotifyEmail          = centre.NotifyEmail;
     BannerText           = centre.BannerText;
     SignatureImage       = centre.SignatureImage;
     CentreLogo           = centre.CentreLogo;
     ContactForename      = centre.ContactForename;
     ContactSurname       = centre.ContactSurname;
     ContactEmail         = centre.ContactEmail;
     ContactTelephone     = centre.ContactTelephone;
     CentreTelephone      = centre.CentreTelephone;
     CentreEmail          = centre.CentreEmail;
     CentrePostcode       = centre.CentrePostcode;
     ShowCentreOnMap      = centre.ShowOnMap;
     OpeningHours         = centre.OpeningHours;
     CentreWebAddress     = centre.CentreWebAddress;
     OrganisationsCovered = centre.OrganisationsCovered;
     TrainingVenues       = centre.TrainingVenues;
     OtherInformation     = centre.OtherInformation;
 }
Пример #17
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ComunaId,Type,Url,Acronym,CompanyId,Name,Address")] Centre centre)
        {
            var isAuthorized = User.IsInRole(Constants.ContactAdministratorsRole);

            if (!isAuthorized)
            {
                return(RedirectToAction("AccessDenied", "Account"));
            }

            if (centre == null || id != centre.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(centre);
                    await _context.SaveChangesAsync().ConfigureAwait(false);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CentreExists(centre.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["CompanyId"] = new SelectList(_context.Company, "Id", "Id", centre.CompanyId);
            return(View(centre));
        }
Пример #18
0
 public Boolean insert(Object o)
 {
     try
     {
         Centre c           = (Centre)o;
         int    id          = c.id;
         String description = c.description;
         string req         = string.Format("insert into Centre values (" + id + ",'" + description + "')");
         cmd.Connection = cn;
         cn.Open();
         cmd.CommandText = req;
         cmd.ExecuteNonQuery();
         return(true);
     }
     catch (OleDbException ex)
     {
         System.Console.WriteLine("error :" + ex.Message);
         return(false);
     }
     finally
     {
         cn.Close();
     }
 }
Пример #19
0
        public clsPoint Intersect(clsCircle c1, bool firstSolution)
        {
            double  a  = 0;
            clsLine l1 = default(clsLine);

            if (mdlGeometry.Dist(Centre, c1.Centre) > Radius + c1.Radius)
            {
                return(null);
            }
            if (mdlGeometry.Dist(Centre, c1.Centre) < Abs(Radius - c1.Radius))
            {
                return(null);
            }
            l1 = new clsLine(Centre.Copy(), c1.Centre.Copy());
            a  = Acos((Radius * Radius + l1.Length * l1.Length - c1.Radius * c1.Radius) / (2 * Radius * l1.Length));
            //Cosine rule
            if (firstSolution == false)
            {
                a = -a;
            }
            l1.Rotate(a);
            l1.Length = Radius;
            return(l1.P2);
        }
Пример #20
0
        public async Task <IActionResult> Create([Bind("Id,ComunaId,Type,Url,Acronym,CompanyId,Name,Address")] Centre centre)
        {
            if (centre == null)
            {
                return(NotFound());
            }

            var isAuthorized = User.IsInRole(Constants.ContactAdministratorsRole);

            if (!isAuthorized)
            {
                return(RedirectToAction("AccessDenied", "Account"));
            }

            if (ModelState.IsValid)
            {
                _context.Add(centre);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToAction("Index"));
            }
            ViewData["CompanyId"] = new SelectList(_context.Company, "Id", "Id", centre.CompanyId);
            return(View(centre));
        }
Пример #21
0
        /// <summary>
        /// Initialise le dictionnaire des régions.
        /// </summary>
        /// <param name="fichierACharger">Chemin d'accès au fichier à charger contenant le dictionnaire des régions.</param>
        private void InitialiseDictionnaireRegions(String fichierACharger)
        {
            this.DictionnaireRecrutement = new Dictionary <EBelligerant, List <String> >();
            this.dictionnaireRegions     = new Dictionary <string, GRegion>();
            this.DictionnaireOccupation  = new Dictionary <string, OccupationRegion>();
            using (StreamReader lecteur = new StreamReader(fichierACharger))
            {
                foreach (String nomRegion in this.ListeNomsRegions)
                {
                    String   donnees           = lecteur.ReadLine();
                    String[] donneesDetaillees = donnees.Split(';');

                    if (donneesDetaillees[0] == nomRegion)
                    {
                        String       abreviation      = donneesDetaillees[1];
                        Boolean      centre           = Boolean.Parse(donneesDetaillees[2]);
                        ETypeRegion  typeRegion       = (ETypeRegion)(Int32.Parse(donneesDetaillees[3]));
                        Coordonnees  coordonneesUnite = Coordonnees.Convertit(donneesDetaillees[4]);
                        EBelligerant possesseurUnite  = (EBelligerant)(Int32.Parse(donneesDetaillees[5]));
                        EUnite       unite            = (EUnite)(Int32.Parse(donneesDetaillees[6]));

                        if (centre == false)
                        {
                            GRegion nouvelleRegion = new GRegion(nomRegion, abreviation, typeRegion, coordonneesUnite);
                            this.dictionnaireRegions.Add(nomRegion, nouvelleRegion);

                            OccupationRegion occupation = new OccupationRegion(nomRegion, unite, possesseurUnite);
                            this.DictionnaireOccupation.Add(nomRegion, occupation);
                        }
                        else
                        {
                            Coordonnees  coordonneesCentre = Coordonnees.Convertit(donneesDetaillees[7]);
                            EBelligerant possesseurCentre  = (EBelligerant)(Int32.Parse(donneesDetaillees[8]));

                            EBelligerant recrutement = (EBelligerant)(Int32.Parse(donneesDetaillees[9]));

                            Centre nouveauCentre = new Centre(
                                nomRegion,
                                abreviation,
                                typeRegion,
                                coordonneesUnite,
                                coordonneesCentre,
                                recrutement);
                            this.dictionnaireRegions.Add(nomRegion, nouveauCentre);

                            OccupationCentre occupation = new OccupationCentre(nomRegion, unite, possesseurUnite, possesseurCentre);
                            this.DictionnaireOccupation.Add(nomRegion, occupation);

                            if (recrutement != EBelligerant.Aucun)
                            {
                                if (this.DictionnaireRecrutement.ContainsKey(recrutement))
                                {
                                    this.DictionnaireRecrutement[recrutement].Add(nomRegion);
                                }
                                else
                                {
                                    this.DictionnaireRecrutement.Add(recrutement, new List <String>()
                                    {
                                        nomRegion
                                    });
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new Exception("Le fichier de régions ne correspond pas à la matrice d'adjacence.");
                    }
                }

                String retraite = lecteur.ReadLine();
                while (retraite != null)
                {
                    String[] retraiteDetaillee = retraite.Split(';');

                    String       attaquant  = retraiteDetaillee[0];
                    EBelligerant possesseur = Convertisseurs.VersEBelligerant(retraiteDetaillee[1]);
                    String       region     = retraiteDetaillee[2];
                    EUnite       typeUnite  = Convertisseurs.VersEUnite(retraiteDetaillee[3]);

                    OrdreRegional nouvelleRetraite = new OrdreRegional(typeUnite, possesseur, region, attaquant);
                    this.ListeRetraites.Add(nouvelleRetraite);

                    retraite = lecteur.ReadLine();
                }
            }
        }
Пример #22
0
        /// <summary>
        /// Sauvegarde les données de la partie courante.
        /// </summary>
        /// <param name="cheminDictionnaireRegions">Fichier dans lequel sauvegarder le dictionnaire des régions.</param>
        public void Sauvegarde(String cheminDictionnaireRegions)
        {
            using (StreamWriter redacteur = new StreamWriter(cheminDictionnaireRegions))
            {
                foreach (String nomRegion in this.ListeNomsRegions)
                {
                    GRegion regionASauvegarder = this.DictionnaireRegions[nomRegion];
                    String  abreviation        = regionASauvegarder.Abreviation;
                    String  centre             = regionASauvegarder.EstUnCentre.ToString();
                    String  typeRegion         = ((Int32)(regionASauvegarder.TypeRegion)).ToString();
                    String  coordonneesUnites  = regionASauvegarder.CoordonneesUnite.Convertit();

                    OccupationRegion occupationASauvegarder = this.DictionnaireOccupation[nomRegion];
                    String           possesseurUnite        = ((Int32)(occupationASauvegarder.PossesseurUnite)).ToString();
                    String           unite = ((Int32)(occupationASauvegarder.TypeUnite)).ToString();

                    String donneesCompletes;
                    if (regionASauvegarder.EstUnCentre == false)
                    {
                        donneesCompletes = String.Format(
                            "{0};{1};{2};{3};{4};{5};{6}",
                            nomRegion,
                            abreviation,
                            centre,
                            typeRegion,
                            coordonneesUnites,
                            possesseurUnite,
                            unite);
                    }
                    else
                    {
                        Centre centreASAuvegarder = regionASauvegarder as Centre;
                        String coordonneesCentre  = centreASAuvegarder.CoordonneesCentre.Convertit();

                        OccupationCentre occupationCentre = occupationASauvegarder as OccupationCentre;
                        String           possesseurCentre = ((Int32)(occupationCentre.PossesseurCentre)).ToString();

                        String recrutement = ((Int32)(centreASAuvegarder.Recrutement)).ToString();

                        donneesCompletes = String.Format(
                            "{0};{1};{2};{3};{4};{5};{6};{7};{8};{9}",
                            nomRegion,
                            abreviation,
                            centre,
                            typeRegion,
                            coordonneesUnites,
                            possesseurUnite,
                            unite,
                            coordonneesCentre,
                            possesseurCentre,
                            recrutement);
                    }

                    redacteur.WriteLine(donneesCompletes);
                }

                foreach (var retraite in this.ListeRetraites)
                {
                    redacteur.WriteLine(
                        "{0};{1};{2};{3}",
                        retraite.Attaquant,
                        retraite.Possesseur,
                        retraite.Region,
                        retraite.TypeUnite);
                }
            }
        }
Пример #23
0
 protected override void RenderOverlayAfterBaskets(RenderManager.CameraInfo cameraInfo) => Centre.RenderCircle(new OverlayData(cameraInfo)
 {
     Width = Radius * 2
 });
Пример #24
0
        public byte[] Serialize()
        {
            using (MemoryStream stream = new MemoryStream())
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    writer.Write(Centre.Serialize());
                    writer.Write(CollRadius);
                    writer.Write(NumVertices);

                    foreach (TRVertex vert in Vertices)
                    {
                        writer.Write(vert.Serialize());
                    }

                    writer.Write(NumNormals);

                    if (NumNormals > 0)
                    {
                        foreach (TRVertex normal in Normals)
                        {
                            writer.Write(normal.Serialize());
                        }
                    }
                    else
                    {
                        foreach (ushort light in Lights)
                        {
                            writer.Write(light);
                        }
                    }

                    writer.Write(NumTexturedRectangles);
                    foreach (TRFace4 face in TexturedRectangles)
                    {
                        writer.Write(face.Serialize());
                    }

                    writer.Write(NumTexturedTriangles);
                    foreach (TRFace3 face in TexturedTriangles)
                    {
                        writer.Write(face.Serialize());
                    }

                    writer.Write(NumColouredRectangles);
                    foreach (TRFace4 face in ColouredRectangles)
                    {
                        writer.Write(face.Serialize());
                    }

                    writer.Write(NumColouredTriangles);
                    foreach (TRFace3 face in ColouredTriangles)
                    {
                        writer.Write(face.Serialize());
                    }

                    // 4-byte alignment for mesh data
                    long padding = writer.BaseStream.Position % 4;
                    for (int i = 0; i < padding; i++)
                    {
                        writer.Write((byte)0);
                    }

                    return(stream.ToArray());
                }
        }
Пример #25
0
 /// <summary>
 /// Выводит на экран информацию о квадрате
 /// </summary>
 public override void ShowInfo()
 {
     Console.WriteLine(Name + ":\n" + Centre.ToString() + "\nColour-" + Colour + "\nSides: " + Sides[0] + "," + Sides[1] + "," + Sides[2] + "," + Sides[3] + "\nPerimetr=" + GetPerimetr() + "\nSquare=" + GetSquare() + "\n");
 }
Пример #26
0
        /// <summary>
        /// Ajoute un centre dans la table Centre de la base de donnée maintinfo
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public int AddCentre(Centre c)
        {
            //  c.AddProduit(p);

            using (DbConnection db = DAOConnection.GetConnexion())
            {
                using (DbCommand cde = db.CreateCommand())
                {
                    cde.CommandText = "[dbo].[AddCentre]";
                    cde.CommandType = CommandType.StoredProcedure;


                    // Nom
                    DbParameter odbP1 = cde.CreateParameter();
                    odbP1.DbType        = System.Data.DbType.String;
                    odbP1.Direction     = System.Data.ParameterDirection.Input;
                    odbP1.ParameterName = "@nomCentre";
                    odbP1.Value         = c.NomCentre;
                    cde.Parameters.Add(odbP1);
                    // Id secteur
                    DbParameter odbP2 = cde.CreateParameter();
                    odbP2.DbType        = System.Data.DbType.Int32;
                    odbP2.Direction     = System.Data.ParameterDirection.Input;
                    odbP2.ParameterName = "@idSecteur";
                    odbP2.Value         = c.Secteur.CodeSecteur;
                    cde.Parameters.Add(odbP2);

                    // telephone
                    DbParameter odbP3 = cde.CreateParameter();
                    odbP3.DbType        = System.Data.DbType.String;
                    odbP3.Direction     = System.Data.ParameterDirection.Input;
                    odbP3.ParameterName = "@telCentre";
                    odbP3.Value         = c.TelCentre;
                    cde.Parameters.Add(odbP3);

                    // idCentre
                    DbParameter odbP4 = cde.CreateParameter();
                    odbP4.DbType        = System.Data.DbType.Int32;
                    odbP4.Direction     = System.Data.ParameterDirection.Output;
                    odbP4.ParameterName = "@idCentre";
                    cde.Parameters.Add(odbP4);

                    // Adresse
                    DbParameter odbP5 = cde.CreateParameter();
                    odbP5.DbType        = System.Data.DbType.String;
                    odbP5.Direction     = System.Data.ParameterDirection.Input;
                    odbP5.ParameterName = "@AdresseCentre";
                    odbP5.Value         = c.AdresseCentre;
                    cde.Parameters.Add(odbP5);

                    // CLIENT
                    DbParameter odbP6 = cde.CreateParameter();
                    odbP6.DbType        = System.Data.DbType.Int32;
                    odbP6.Direction     = System.Data.ParameterDirection.Input;
                    odbP6.ParameterName = "@numClient";
                    odbP6.Value         = c.Client.NumClient;
                    cde.Parameters.Add(odbP6);

                    try
                    {
                        int n = cde.ExecuteNonQuery();

                        if (n != 1)
                        {
                            throw new DAOExceptionClient("L'opération n'a pas été réalisée");
                        }
                        // récup du parametre de sortie



                        return((int)odbP4.Value);
                    }
                    catch (DbException de)
                    {
                        throw new DAOExceptionClient("[DAO] AddCentre \n" + de.Message, de);
                    }
                } // fin using command
            }     // fin using connection
        }
Пример #27
0
 public new void Rotate(double theta)
 {
     Centre.Rotate(theta);
     Angle1 = Angle1 + theta;
     Angle2 = Angle2 + theta;
 }
Пример #28
0
 /// <summary>
 /// Выводит на экран информацию о окружности
 /// </summary>
 public override void ShowInfo()
 {
     Console.WriteLine(Name + ":\n" + Centre.ToString() + "\nColour-" + Colour + "\nRadius: " + Radius + "\nPerimetr=" + GetPerimetr() + "\nSquare=" + GetSquare() + "\n");
 }
Пример #29
0
        public static void Initialize(UsersContext context)
        {
            if (context.UserTypes.Any())
            {
                return;
            }

            var userTypes = new UserType[]
            {
                new UserType {
                    Name = "Admin"
                },
                new UserType {
                    Name = "Tutor"
                },
                new UserType {
                    Name = "Learner"
                },
                new UserType {
                    Name = "Other"
                }
            };

            foreach (var userType in userTypes)
            {
                context.UserTypes.Add(userType);
            }

            context.SaveChanges();

            if (context.Organisations.Any())
            {
                return;
            }

            var orgs = new Organisation[]
            {
                new Organisation {
                    Name = "WEST"
                },
                new Organisation {
                    Name = "Tribal"
                },
                new Organisation {
                    Name = "Others"
                },
                new Organisation {
                    Name = "ACT Training Group"
                }
            };

            foreach (var org in orgs)
            {
                context.Organisations.Add(org);
            }
            context.SaveChanges();

            if (context.Centres.Any())
            {
                return;
            }

            var centres = new Centre[]
            {
                new Centre {
                    OrganisationId = orgs.Single(o => o.Name == "ACT Training Group").Id, Name = "Academy of Hair and Beauty"
                },
                new Centre {
                    OrganisationId = orgs.Single(o => o.Name == "ACT Training Group").Id, Name = "ACT Enhance"
                },
                new Centre {
                    OrganisationId = orgs.Single(o => o.Name == "ACT Training Group").Id, Name = "ACT Staff Initial Assessments"
                }
            };

            if (context.Users.Any())
            {
                return;
            }

            foreach (var centre in centres)
            {
                context.Centres.Add(centre);
            }
            context.SaveChanges();

            var users = new User[]
            {
                new User
                {
                    Username       = "******",
                    FirstName      = "Admin0 FN",
                    LastName       = "Admin0 LN",
                    OrganisationId = 1,
                    Birthdate      = DateTime.Parse("1990-01-01"),
                    TypeId         = 1,
                    Status         = true
                },
                new User
                {
                    Username       = "******",
                    FirstName      = "Tutor0 FN",
                    LastName       = "Tutor0 LN",
                    OrganisationId = 2,
                    Birthdate      = DateTime.Parse("1991-01-01"),
                    TypeId         = 2,
                    Status         = true
                },
                new User
                {
                    Username       = "******",
                    FirstName      = "Learner0 FN",
                    LastName       = "Learner0 LN",
                    OrganisationId = 2,
                    Birthdate      = DateTime.Parse("2005-01-01"),
                    TypeId         = 3,
                    Status         = true
                }
            };

            foreach (var user in users)
            {
                context.Users.Add(user);
            }
            context.SaveChanges();


            if (context.Groups.Any())
            {
                return;
            }

            var groups = new Group[] {
                new Group {
                    Name = "default"
                }
            };

            foreach (var group in groups)
            {
                context.Groups.Add(group);
            }
            context.SaveChanges();

            if (context.Learners.Any())
            {
                return;
            }

            var learnerUsers = users.Where(u => u.TypeId == 3);
            var learners     = new List <Learner>();

            foreach (var learnerUser in learnerUsers)
            {
                var learner = new Learner {
                    UserId = learnerUser.Id, GroupId = 1
                };
                learners.Add(learner);
                context.Learners.Add(learner);
            }
            context.SaveChanges();

            if (context.Courses.Any())
            {
                return;
            }

            var courses = new Course[] {
                new Course {
                    Name = "Application of Number 2015", IconPath = "./assets/image/esm.png"
                },
                new Course {
                    Name = "Communication (English) 2015", IconPath = "./assets/image/esl.png"
                },
                new Course {
                    Name = "Communication (Welsh) 2015", IconPath = "./assets/image/esw.png"
                },
                new Course {
                    Name = "Digital Literacy", IconPath = "./assets/image/esd.png"
                },
                new Course {
                    Name = "ESOL", IconPath = "./assets/image/esol.png"
                }
            };

            foreach (var course in courses)
            {
                context.Courses.Add(course);
            }
            context.SaveChanges();


            if (context.LearnerStatuses.Any())
            {
                return;
            }


            var learnerStatuses = new LearnerStatus[] {
                new LearnerStatus {
                    LearnerId = learners.Single(l => l.User.Username == "learner0").Id,
                    CourseId  = courses.Single(c => c.Name == "Application of Number 2015").Id
                },
                new LearnerStatus {
                    LearnerId = learners.Single(l => l.User.Username == "learner0").Id,
                    CourseId  = courses.Single(c => c.Name == "ESOL").Id
                }
            };

            foreach (var learnerStatus in learnerStatuses)
            {
                context.LearnerStatuses.Add(learnerStatus);
            }
            context.SaveChanges();
        }
Пример #30
0
        public void SeedData()
        {
            this.Database.Migrate();

            if (this.Utilisateurs.Count() == 0)
            {
                var seedDevData   = Environment.GetEnvironmentVariable("APP_GENERATE_DEV_DATA");
                var adminPassword = Environment.GetEnvironmentVariable("APP_ADMIN_PASSWORD");

                if (!string.IsNullOrEmpty(seedDevData) && (seedDevData == "1" || seedDevData.ToLower() == "true"))
                {
                    // ****** Sièges
                    var siege75 = new Siege
                    {
                        Nom     = "AD75",
                        Adresse = "rue du siège 75000 PARIS",
                    };

                    this.Sieges.Add(siege75);

                    // ****** Centres
                    var centre_paris = new Centre
                    {
                        Nom     = "Paris",
                        Adresse = "5 rue de Paris 75000 PARIS",
                        Siege   = siege75,
                    };

                    this.Centres.Add(centre_paris);

                    var centre = new Centre
                    {
                        Nom     = "Lyon",
                        Adresse = "5 rue de Lyon 69000 Lyon",
                        Siege   = siege75,
                    };

                    this.Centres.Add(centre);

                    // ****** Utilisateurs
                    var testadmin = new Utilisateur
                    {
                        Centre = null,
                        Login  = "******",
                    };

                    if (string.IsNullOrEmpty(adminPassword))
                    {
                        adminPassword = "******";
                    }

                    testadmin.SetPassword(adminPassword);
                    this.Utilisateurs.Add(testadmin);

                    var adminparis = new Utilisateur
                    {
                        Centre = centre_paris,
                        Login  = "******",
                    };

                    adminparis.SetPassword("adminparis");
                    this.Utilisateurs.Add(adminparis);

                    // ****** Bénévoles
                    var benevole1 = new Benevole
                    {
                        Prenom    = "Bernard",
                        Nom       = "TOTO",
                        Telephone = "00000000",
                        Adresses  = new List <Adresse>
                        {
                            new Adresse
                            {
                                Centre         = centre,
                                AdresseLigne1  = "1 rue de david",
                                CodePostal     = "69000",
                                Ville          = "Lyon",
                                DistanceCentre = 80,
                            },
                            new Adresse
                            {
                                DateChangement = new DateTime(2017, 2, 1),
                                Centre         = centre,
                                AdresseLigne1  = "26 rue de david",
                                CodePostal     = "69000",
                                Ville          = "Lyon",
                                DistanceCentre = 84,
                            },
                            new Adresse
                            {
                                DateChangement = new DateTime(2017, 3, 1),
                                Centre         = centre_paris,
                                AdresseLigne1  = "1 rue de jules",
                                CodePostal     = "75005",
                                Ville          = "Paris",
                                DistanceCentre = 65,
                                IsCurrent      = true,
                            }
                        },
                    };

                    this.Benevoles.Add(benevole1);

                    this.Benevoles.Add(new Benevole
                    {
                        Prenom    = "Anne",
                        Nom       = "TUTU",
                        Telephone = "00000000",
                        Adresses  = new List <Adresse>
                        {
                            new Adresse
                            {
                                Centre         = centre,
                                AdresseLigne1  = "1 rue d'anne",
                                CodePostal     = "13000",
                                Ville          = "Marseille",
                                DistanceCentre = 10,
                                IsCurrent      = true,
                            }
                        }
                    });

                    this.Benevoles.Add(new Benevole
                    {
                        Prenom    = "Gérard",
                        Nom       = "TITI",
                        Telephone = "00000000",
                        Adresses  = new List <Adresse>
                        {
                            new Adresse
                            {
                                Centre         = centre_paris,
                                AdresseLigne1  = "1 rue de gérard",
                                CodePostal     = "75015",
                                Ville          = "Paris",
                                DistanceCentre = 65.5m,
                                IsCurrent      = true,
                            }
                        }
                    });

                    this.Benevoles.Add(new Benevole
                    {
                        Prenom    = "Daniel",
                        Nom       = "ROBERT",
                        Telephone = "00000000",
                        Adresses  = new List <Adresse>
                        {
                            new Adresse
                            {
                                Centre         = centre_paris,
                                AdresseLigne1  = "1 rue de daniel",
                                CodePostal     = "78000",
                                Ville          = "Cergy",
                                DistanceCentre = 80,
                                IsCurrent      = true,
                            }
                        }
                    });

                    // ****** Pointages
                    this.Pointages.Add(new Pointage
                    {
                        Benevole       = benevole1,
                        Adresse        = benevole1.Adresses.First(),
                        Date           = new DateTime(2017, 1, 15),
                        NbDemiJournees = 2,
                    });

                    this.Pointages.Add(new Pointage
                    {
                        Benevole       = benevole1,
                        Adresse        = benevole1.Adresses.Skip(1).First(),
                        Date           = new DateTime(2017, 2, 28),
                        NbDemiJournees = 2,
                    });

                    this.Pointages.Add(new Pointage
                    {
                        Benevole       = benevole1,
                        Adresse        = benevole1.Adresses.Skip(2).First(),
                        Date           = new DateTime(2017, 03, 03),
                        NbDemiJournees = 1,
                    });

                    this.Pointages.Add(new Pointage
                    {
                        Benevole       = benevole1,
                        Adresse        = benevole1.Adresses.Skip(2).First(),
                        Date           = new DateTime(2017, 03, 05),
                        NbDemiJournees = 1,
                    });
                }
                else
                {
                    // ****** Siège
                    var siege = new Siege
                    {
                        Nom     = "AD68",
                        Adresse = "9 avenue d’Italie 68110 ILLZACH",
                    };

                    this.Sieges.Add(siege);

                    // ****** Utilisateurs
                    var admin = new Utilisateur
                    {
                        Centre = null,
                        Login  = "******",
                    };

                    if (string.IsNullOrEmpty(adminPassword))
                    {
                        adminPassword = "******";
                    }

                    admin.SetPassword(adminPassword);
                    this.Utilisateurs.Add(admin);
                }

                // ****** Frais
                this.Frais.Add(new Frais
                {
                    Annee            = 2017,
                    TauxKilometrique = 0.308m,
                });

                this.Frais.Add(new Frais
                {
                    Annee            = 2018,
                    TauxKilometrique = 0.308m,
                });

                this.SaveChanges();
            }
        }