Exemple #1
0
        private void btnSupprimerContrat_Click(object sender, RoutedEventArgs e)
        {
            Contrat SupprCont = dtgContrat.SelectedItem as Contrat;

            cContrat.Remove(SupprCont);

            cContrat.Clear();
            cContrat = bdd.SelectContrat();
            dtgContrat.ItemsSource = cContrat;
        }
Exemple #2
0
        public static List <Contrat> SelectContrat()
        {
            //Select statement
            string query = "SELECT * FROM Collaboration";

            //Create a list to store the result
            List <Contrat>  dbContrat  = new List <Contrat>();
            List <Pigiste>  dbPigiste  = SelectPigiste();
            List <Magazine> dbMagazine = SelectMagazine();

            //Ouverture connection
            if (bdd.OpenConnection() == true)
            {
                //Creation Command MySQL
                MySqlCommand cmd = new MySqlCommand(query, connection);
                //Création d'un DataReader et execution de la commande
                MySqlDataReader dataReader = cmd.ExecuteReader();

                //Lecture des données et stockage dans la collection
                while (dataReader.Read())
                {
                    Pigiste  trouvepigiste  = dbPigiste.Find(r => r.NumPigiste == Convert.ToInt16(dataReader["NumPigiste"]));
                    Magazine trouveMagazine = dbMagazine.Find(r => r.NumMagzine == Convert.ToInt16(dataReader["NumMagazine"]));

                    Contrat leContrat = new Contrat
                                            (Convert.ToInt32(dataReader["NumCollaboration"]),
                                            Convert.ToString(dataReader["LettreAccordCollaboration"]),
                                            Convert.ToInt32(dataReader["MontantCollaboration"]),
                                            Convert.ToInt32(dataReader["MontantNCollaboration"]),
                                            Convert.ToBoolean(dataReader["EtatCollaboration"]),
                                            Convert.ToBoolean(dataReader["FactureCollaboration"]),
                                            Convert.ToInt32(dataReader["AgessaCollaboration"]),
                                            trouvepigiste,
                                            trouveMagazine,
                                            Convert.ToString(dataReader["DatePaiementCollaboration"]));
                    dbContrat.Add(leContrat);
                }

                //fermeture du Data Reader
                dataReader.Close();

                //fermeture Connection
                bdd.CloseConnection();

                //retour de la collection pour être affichée
                return(dbContrat);
            }
            else
            {
                return(dbContrat);
            }
        }
Exemple #3
0
        private void dtgContrat_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (dtgContrat.SelectedIndex == -1)
            {
                dtgContrat.SelectedIndex = 0;
            }
            Contrat selectedContrat = dtgContrat.SelectedItem as Contrat;

            txtNumContrat.Text           = Convert.ToString(selectedContrat.NumContrat);
            txtLettreAccordContrat.Text  = Convert.ToString(selectedContrat.LettreAccordContrat);
            txtMontantBrutContrat.Text   = Convert.ToString(selectedContrat.MontantBrutContrat);
            txtMontantNetContrat.Text    = Convert.ToString(selectedContrat.MontantNetContrat);
            chkFacture.IsChecked         = Convert.ToBoolean(selectedContrat.FactureContrat);
            chkAgessa.IsChecked          = Convert.ToBoolean(selectedContrat.DeclarationAgessaContrat);
            cboEtatContrat.SelectedIndex = Convert.ToInt32(selectedContrat.EtatContrat);
            cboPigiste.SelectedItem      = selectedContrat.PigisteContrat;
            cboMagazine.SelectedItem     = selectedContrat.MagazineContrat;
            dtpPaiment.Text = Convert.ToString(selectedContrat.DatePaiment);
        }
Exemple #4
0
        private void btnAjouterContrat_Click(object sender, RoutedEventArgs e)
        {
            Pigiste LePigiste = cboPigiste.SelectedItem as Pigiste;

            if (txtLettreAccordContrat.Text == "")
            {
                La = "la-";
                La = La + Convert.ToString(txtNumContrat.Text) + "-" + LePigiste.NumPigiste;
                Contrat unContrat = new Contrat
                                    (
                    cContrat.Count + 1,
                    La,
                    Convert.ToDouble(txtMontantBrutContrat.Text),
                    Convert.ToDouble(txtMontantNetContrat.Text),
                    Convert.ToBoolean(chkAgessa.IsChecked),
                    Convert.ToBoolean(chkFacture.IsChecked),
                    cboEtatContrat.SelectedIndex,
                    (Pigiste)cboPigiste.SelectedItem,
                    (Magazine)cboMagazine.SelectedItem,
                    dtpPaiment.Text
                                    );
                bdd.InsertContrat(La,
                                  Convert.ToDouble(txtMontantBrutContrat.Text),
                                  Convert.ToDouble(txtMontantNetContrat.Text),
                                  cboEtatContrat.SelectedIndex,
                                  Convert.ToBoolean(chkFacture.IsChecked),
                                  Convert.ToBoolean(chkAgessa.IsChecked),
                                  (Pigiste)cboPigiste.SelectedItem,
                                  (Magazine)cboMagazine.SelectedItem);
                cContrat.Add(unContrat);
                cContrat.Clear();
                cContrat = bdd.SelectContrat();
                dtgContrat.ItemsSource = cContrat;
            }
            else
            {
                Contrat unContrat = new Contrat
                                    (
                    cContrat.Count + 1,
                    txtLettreAccordContrat.Text,
                    Convert.ToDouble(txtMontantBrutContrat.Text),
                    Convert.ToDouble(txtMontantNetContrat.Text),
                    Convert.ToBoolean(chkAgessa.IsChecked),
                    Convert.ToBoolean(chkFacture.IsChecked),
                    cboEtatContrat.SelectedIndex,
                    (Pigiste)cboPigiste.SelectedItem,
                    (Magazine)cboMagazine.SelectedItem,
                    dtpPaiment.Text
                                    );
                bdd.InsertContrat(La,
                                  Convert.ToDouble(txtMontantBrutContrat.Text),
                                  Convert.ToDouble(txtMontantNetContrat.Text),
                                  cboEtatContrat.SelectedIndex,
                                  Convert.ToBoolean(chkFacture.IsChecked),
                                  Convert.ToBoolean(chkAgessa.IsChecked),
                                  (Pigiste)cboPigiste.SelectedItem,
                                  (Magazine)cboMagazine.SelectedItem);
                cContrat.Add(unContrat);
                cContrat.Clear();
                cContrat = bdd.SelectContrat();
                dtgContrat.ItemsSource = cContrat;
            }
        }