1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
public partial class purge2 : Form
{
string[] jours = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" };
string[] mois = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };
string[] ans = { "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026", "2027", "2028", "2029", "2030"};
public purge2()
{
InitializeComponent();
daystart.Items.AddRange(jours);
monthstart.Items.AddRange(mois);
yearstart.Items.AddRange(ans);
dayend.Items.AddRange(jours);
monthend.Items.AddRange(mois);
yearend.Items.AddRange(ans);
// yearstart.Text = "" + DateTime.Now.Year;
// yearend.Text = "" + DateTime.Now.Year;
daystart.SelectedIndex = 0;
dayend.SelectedIndex = 0;
monthstart.SelectedIndex = 0;
monthend.SelectedIndex = 0;
yearstart.SelectedIndex = 0;
yearend.SelectedIndex = 0;
}
private void Delete_Click(object sender, EventArgs e)
{
try
{
DateTime D1 = Convert.ToDateTime(yearstart.Text + "/" + monthstart.Text + "/" + daystart.Text + " 00:00:00.000");
DateTime D2 = Convert.ToDateTime(yearend.Text + "/" + monthend.Text + "/" + dayend.Text + " 00:00:00.000");
Program.connexion.Open();
SqlCommand myCommand = new SqlCommand("DELETE from Operation where Start_Date between '" + D1 + "' and '" + D2 + "'", Program.connexion);
myCommand.ExecuteReader(); ;
richTextBox.Text = "\n Archives between " + monthstart.Text + "/" + daystart.Text + "/" + yearstart.Text + " and " + monthend.Text + "/" + dayend.Text + "/" + yearend.Text + " are deleted succefully...";
}
catch (Exception) { richTextBox.Text = "\nNo data... "; }
Program.connexion.Close();
}
} |
Partager