Exemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         foreach (DataGridViewRow r in sanctionneDataGridView.Rows)
         {
             if ((bool)r.Cells["Confirmer"].FormattedValue == true)
             {
                 BibliothèqueDataSetTableAdapters.QueriesTableAdapter q = new BibliothèqueDataSetTableAdapters.QueriesTableAdapter();
                 int      nb = int.Parse(q.NbrSanction(r.Cells[2].Value.ToString()).Value.ToString());
                 DateTime d  = DateTime.Now.Add(new TimeSpan(7, 0, 0, 0));
                 if (nb == 1)
                 {
                     d = d.Add(new TimeSpan(7, 0, 0, 0));
                 }
                 else
                 if (nb > 1)
                 {
                     d = d.Add(new TimeSpan(21, 0, 0, 0));
                 }
                 Program.ds.Emprunteur_Sanctionne.AddEmprunteur_SanctionneRow(Program.ds.Emprunter.FindByCodePret(int.Parse(r.Cells[0].Value.ToString())), DateTime.Now,
                                                                              d, "Sanctionne");
             }
         }
         Program.emprunteurSanctioneTA.Update(Program.ds.Emprunteur_Sanctionne);
         MessageBox.Show("l'opperation est fait avec succes!");
     }
     catch (Exception ex) { MessageBox.Show(ex.Message); }
 }
        private void Historique_Load(object sender, EventArgs e)
        {
            this.filierTableAdapter.Fill(this.bibliothèqueDataSet.Filier);
            this.typeEmprunteurTableAdapter.Fill(this.bibliothèqueDataSet.TypeEmprunteur);
            remplire();
            DataView dv = new DataView(Program.ds.Emprunter);

            dv.RowFilter             = "ID_Emprunteur='" + ID + "'";
            dataGridView1.DataSource = dv;
            NbPretsLbl.Text          = dv.Count.ToString();
            BibliothèqueDataSetTableAdapters.QueriesTableAdapter nb = new BibliothèqueDataSetTableAdapters.QueriesTableAdapter();
            NbSanctionLbl.Text = nb.NbrSanction(ID).Value.ToString();
        }