private void updateFutureReturnDate() { string sql = "select Date_Emprunt from Emprunter " + "where Code_Album = " + albm.Code_Album + " AND Code_Abonné = " + Form1.currentSubscriber.Code_Abonné; OleDbCommand cmd = new OleDbCommand(sql, dbConnection); OleDbDataReader reader = cmd.ExecuteReader(); List <Abonné> activeSub = new List <Abonné>(); reader.Read(); DateTime Date_Emprunt = reader.GetDateTime(0); empr = new Emprunter(Form1.currentSubscriber.Code_Abonné, albm.Code_Album, Date_Emprunt, null); label1.Text = "À Rendre le : " + empr.Date_Emprunt.AddMonths(1).ToShortDateString(); }
private void viewBox_SelectedIndexChanged(object sender, EventArgs e) { if (viewBox.SelectedItem != null) { if (inLoan) { Album albm = (Album)viewBox.SelectedItem; var newLoan = new Emprunter(Form1.currentSubscriber.Code_Abonné, albm.Code_Album, DateTime.Now, null); string sql = "select * from Emprunter " + "where Code_Abonné = " + newLoan.Code_Abonné + " AND Code_Album = " + newLoan.Code_Album; OleDbCommand cmd = new OleDbCommand(sql, dbConnection); OleDbDataReader reader = cmd.ExecuteReader(); reader.Read(); if (reader.HasRows) { string delete = "delete from Emprunter where Code_Abonné=" + reader.GetInt32(0) + " and Code_Album=" + reader.GetInt32(1); OleDbCommand cmdDele = new OleDbCommand(delete, dbConnection); cmdDele.ExecuteNonQuery(); } reader.Close(); string addBorrow = "insert into Emprunter(Code_Abonné,Code_Album,Date_Emprunt) values (" + Form1.currentSubscriber.Code_Abonné + "," + albm.Code_Album + "," + "GETDATE())"; OleDbCommand cmdAddBorrow = new OleDbCommand(addBorrow, dbConnection); cmdAddBorrow.ExecuteNonQuery(); viewBox.Items.Clear(); viewBox.Items.Add("Album emprunté !"); albumDispo_Click(sender, e); label.ForeColor = Color.DarkGreen; label.Text = "Album emprunté !!!"; timer1.Start(); Cursor.Current = Cursors.Default; } else if (inMyAlbums) { AlbumSettings a = new AlbumSettings((Album)viewBox.SelectedItem); a.ShowDialog(); viewBox.Items.Clear(); button1_Click_1(sender, e); } } else { label.ForeColor = Color.DarkRed; label.Text = "Sélectionnez une oeuvre"; } }