コード例 #1
0
        public GroupeDTO get(String idGroupe)
        {
            MySqlCommand    cmd    = new MySqlCommand(queryRead, connexion);
            MySqlDataReader reader = null;
            GroupeDTO       result = new GroupeDTO();

            try
            {
                connexion.Open();
                cmd.Parameters.AddWithValue("@idgroupe", idGroupe);
                reader = cmd.ExecuteReader();
                reader.Read();
                result.IdGroupe     = reader.GetString("idgroupe");
                result.IdActivite   = reader.GetString("idactivite");
                result.NumeroGroupe = reader.GetString("numerogroupe");
                result.Prix         = reader.GetDecimal("prix");
            }

            /*  catch (Exception e)
             * {
             *    Console.Write(e.Message);
             * }*/
            finally
            {
                connexion.Close();
            }
            return(result);
        }
コード例 #2
0
        public List <GroupeDTO> getAllByActivite(String idActivite)
        {
            MySqlCommand     cmd    = new MySqlCommand(queryReadByActivite, connexion);
            MySqlDataReader  reader = null;
            List <GroupeDTO> result = new List <GroupeDTO>();

            try
            {
                connexion.Open();
                cmd.Parameters.AddWithValue("@idactivite", idActivite);
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    GroupeDTO a = new GroupeDTO();
                    a.IdGroupe     = reader.GetString("idgroupe");
                    a.IdActivite   = idActivite;
                    a.NumeroGroupe = reader.GetString("numerogroupe");
                    a.Prix         = reader.GetDecimal("prix");
                    result.Add(a);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Erreur dans la requete getAll");
                Console.Write(e.Message);
            }
            finally
            {
                connexion.Close();
            }
            return(result);
        }
コード例 #3
0
        public async Task <IActionResult> PostAttributionGroupe([FromBody] GroupeDTO groupeDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await _context.Database.BeginTransactionAsync();

            try{
                var users = groupeDTO.Membre.ToArray();
                var user1 = await _context.Utilisateurs.FirstOrDefaultAsync(u => u.UserName.Equals(users[0]));

                if (groupeDTO.GroupeId == 0)
                {
                    var user2 = await _context.Utilisateurs.FirstOrDefaultAsync(u => u.UserName.Equals(users[1]));

                    await _context.Groupes.AddAsync(new Groupe());

                    await _context.SaveChangesAsync();

                    var groupeCréé = await _context.Groupes.LastAsync();

                    await _context.AttributionGroupes.AddAsync(new AttributionGroupe
                    {
                        GroupeId      = groupeCréé.GroupeId,
                        UtilisateurId = user1.Id
                    });

                    await _context.SaveChangesAsync();

                    await _context.AttributionGroupes.AddAsync(new AttributionGroupe
                    {
                        GroupeId      = groupeCréé.GroupeId,
                        UtilisateurId = user2.Id
                    });
                }
                else
                {
                    await _context.AttributionGroupes.AddAsync(new AttributionGroupe
                    {
                        GroupeId      = groupeDTO.GroupeId,
                        UtilisateurId = user1.Id
                    });
                }

                await _context.SaveChangesAsync();

                _context.Database.CommitTransaction();

                var dictionnary = new Dictionary <string, int>();
                dictionnary.Add("NumeroChat", _context.Groupes.Last().GroupeId);
                return(Ok(dictionnary));
            }
            catch
            {
                return(BadRequest());
            }
        }
コード例 #4
0
 private void dataGridView3_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 4)
     {
         GroupeDTO groupeDTO = (GroupeDTO)dataGridView3.Rows[e.RowIndex].Cells[4].Tag;
         if (groupeDTO != null)
         {
             MenuGroupe form = new MenuGroupe(groupeDTO);
             form.Owner = this;
             form.ShowDialog();
         }
     }
 }
コード例 #5
0
        public FormulaireGroupe(GroupeDTO groupeDTO)
        {
            InitializeComponent();

            if (groupeDTO != null)
            {
                this.mode      = "Modifier";
                this.groupeDTO = groupeDTO;
                remplir();
            }
            else
            {
                this.mode      = "Créer";
                this.groupeDTO = new GroupeDTO();
            }
            this.Text = mode;
        }
コード例 #6
0
        private void button4_Click(object sender, EventArgs e)//Chercher Groupe par id
        {
            labelMessageGroupe.Text = "";
            String idGroupe = textBox4.Text;

            try
            {
                GroupeDTO  groupeDTO = DbCreateur.ServiceGroupe.findById(idGroupe);
                MenuGroupe form      = new MenuGroupe(groupeDTO);
                form.Owner = this;
                form.ShowDialog();
            }
            catch
            {
                labelMessageGroupe.Text = "ID introuvable";
            }
        }
コード例 #7
0
        public void delete(GroupeDTO groupeDTO)
        {
            MySqlCommand cmd = new MySqlCommand(queryDelete, connexion);

            cmd.Parameters.AddWithValue("@idgroupe", groupeDTO.IdGroupe);;
            try
            {
                connexion.Open();
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
            }
            finally
            {
                connexion.Close();
            }
        }
コード例 #8
0
        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                this.dataGridView1.Rows.Clear();
                textBox1.Text = "";
                textBox2.Text = "";
                textBox3.Text = "";
                label6.Text   = "Message : ";
                groupeDTO     = null;
                listSeanceDTO = null;
                lastSeanceDTO = null;

                groupeDTO = (GroupeDTO)comboBox2.SelectedItem;
                EnseigneDTO enseigneDTO = CentreView.DbCreateur.ServicePersonne.getEnseigneByGroupId(groupeDTO.IdGroupe);
                PersonneDTO professeur  = CentreView.DbCreateur.ServicePersonne.findById(int.Parse(enseigneDTO.IdPersonne));

                this.dataGridView1.Rows.Clear();
                listSeanceDTO = CentreView.DbCreateur.ServiceGroupe.getAllSeancesByGroupId(groupeDTO.IdGroupe);
                lastSeanceDTO = listSeanceDTO.Last();

                textBox1.Text = "" + listSeanceDTO.Count;
                textBox2.Text = lastSeanceDTO.DateFin.Day + " / " + lastSeanceDTO.DateFin.Month + " / " + lastSeanceDTO.DateFin.Year;
                textBox3.Text = "" + groupeDTO.Prix;

                listSeanceDTO.ForEach(delegate(SeanceDTO seance)
                {
                    int i = this.dataGridView1.Rows.Add();
                    dataGridView1.Rows[i].Cells[0].Value = seance.DateDebut.DayOfWeek;
                    dataGridView1.Rows[i].Cells[1].Value = seance.DateDebut.Hour + "h";
                    dataGridView1.Rows[i].Cells[2].Value = seance.DateFin.Hour + "h";
                    dataGridView1.Rows[i].Cells[3].Value = professeur.Prenom + " " + professeur.Nom;
                });
            }
            catch (Exception ee)
            {
                label6.Text += "Erreur dans le chargement des séances du groupe " + groupeDTO.NumeroGroupe;
                Console.WriteLine("Erreur dans la requete get all seances");
                Console.Write(ee.Message);
            }
        }
コード例 #9
0
ファイル: ViewHoraire.cs プロジェクト: naveros/CentreSportif
        private void calendar1_Layout(object sender, LayoutEventArgs e)
        {
            DateTime viewStart = DateTime.Today;
            DateTime viewEnd   = DateTime.Today.AddDays(7);

            calendar1.ViewStart = viewStart;
            calendar1.ViewEnd   = viewEnd;
            label1.Text         = viewStart.ToShortDateString();

            List <AbonnementDTO> abonnements = CentreView.DbCreateur.ServicePersonne.getAllAbonnements(personneDTO);

            foreach (AbonnementDTO abonnement in abonnements)
            {
                GroupeDTO        groupe  = CentreView.DbCreateur.ServiceGroupe.findById(abonnement.IdGroupe);
                List <SeanceDTO> seances = CentreView.DbCreateur.ServiceGroupe.getAllSeancesByGroupId(abonnement.IdGroupe);
                foreach (SeanceDTO seance in seances)
                {
                    ActiviteDTO  activite = CentreView.DbCreateur.ServiceActivite.findById(groupe.IdActivite);
                    CalendarItem item     = new CalendarItem(calendar1, seance.DateDebut, seance.DateFin, activite.Nom);
                    items.Add(item);
                }
            }
            calendar1.Items.AddRange(items);
        }
コード例 #10
0
        public String add(GroupeDTO groupeDTO)
        {
            String       id  = "null";
            MySqlCommand cmd = new MySqlCommand(queryCreate, connexion);

            cmd.Parameters.AddWithValue("@idactivite", groupeDTO.IdActivite);
            cmd.Parameters.AddWithValue("@numerogroupe", groupeDTO.NumeroGroupe);
            cmd.Parameters.AddWithValue("@prix", groupeDTO.Prix);
            try
            {
                connexion.Open();
                cmd.ExecuteNonQuery();
                id = cmd.LastInsertedId.ToString();
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
            }
            finally
            {
                connexion.Close();
            }
            return(id);
        }
コード例 #11
0
 public void delete(GroupeDTO groupeDTO)
 {
     this.groupeDAO.delete(groupeDTO);
 }
コード例 #12
0
 public void update(GroupeDTO groupeDTO)
 {
     this.groupeDAO.update(groupeDTO);
 }
コード例 #13
0
 public String creer(GroupeDTO groupeDTO)
 {
     return(groupeDAO.add(groupeDTO));
 }
コード例 #14
0
ファイル: MenuGroupe.cs プロジェクト: naveros/CentreSportif
 public MenuGroupe(GroupeDTO groupeDTO)
 {
     InitializeComponent();
     this.groupeDTO = groupeDTO;
     remplir();
 }
コード例 #15
0
 public ViewGroupe(GroupeDTO groupeDTO)
 {
     InitializeComponent();
     this.groupeDTO = groupeDTO;
 }