Bonjour,

Je cherche à faire une boucle sur les dates d'un MonthCalender afin d’exécuter une requête oracle SQplus.

je fais une multiselection (par exemple 3 à 4 dates).

j'ai bien la 1ere date et la dernière avec les paramètres suivants:

monthCalendar1.SelectionStart;
monthCalendar1.SelectionEnd;

Mais je voudrais faire une boucle sur l'ensemble des dates sélectionnées pour exécuter ma requête Oracle SQLPLUS pour chaque Date.

J'ai bien trouvé pour l’exécution de la requête, je veux juste faire une boucle sur les dates sélectionnées pour lancer à chaque fois la requête avec la bonne date.

J'ai beau cherché sur internet depuis 3 jours je n'ai rien trouvé me permettant de la faire facilement

Merci de votre aide.

Cordialement

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
 
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client; // ODP.NET Oracle managed provider
using System.Diagnostics;
 
 
 
 
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
 
            // Initialisation des paramètres de l'application
            InitializeComponent();
 
            // Paramètrage du calendrier
            SelectionRange range = monthCalendar1.SelectionRange;
            DateTime start = range.Start;
            DateTime end = range.End;
 
            // Alternatively, you can use the SelectionStart and End properties.
            DateTime startB = monthCalendar1.SelectionStart;
            DateTime endB = monthCalendar1.SelectionEnd;
 
 
            string filepath = "C:\\Applics\\RequeteurCTI";
            DirectoryInfo dirinfo = new DirectoryInfo(filepath);
            FileInfo[] images = dirinfo.GetFiles("*.SQL");
            foreach (FileInfo image in images)
            {
                checkedListBox1.Items.Add(image.Name);
            }
        }
 
 
 
        private void monthCalendar1_DateChanged(object sender, System.Windows.Forms.DateRangeEventArgs e)
        {
            //Recuperation des dates selectionnées dans le calendrier de l'application
            DateTime date = e.Start;
            List<DateTime> selectedDates = new List<DateTime>();
            while (date.Date <= e.End.Date)
            {
                selectedDates.Add(date);
                date = date.AddDays(1);
            }
            this.monthCalendar1.BoldedDates = selectedDates.ToArray();
            this.Invalidate();
 
            // Show the start and end dates in the text box.
            MessageBox.Show ( "Date Changed: Start =  " +
                e.Start.ToShortDateString() + " : End = " + e.End.ToShortDateString());
        }
 
 
 
        private void button2_Click(object sender, EventArgs e)
        //Sortie de l'application
        {
 
            Application.Exit();
        }
 
 
        public void Btn_Lancer_Click(object sender, EventArgs e)
            //Bouton Lancer
        {
 
            {
 
 
                //Declaration variable pour test SQLplus sans boucle
 
                string s = "@C:\\Applics\\RequeteurCTI\\GENDTW001.SQL";
 
                monthCalendar1.SelectionRange.Start.ToString();
 
 
            DateTime startD = monthCalendar1.SelectionStart;
            DateTime endD = monthCalendar1.SelectionEnd;
 
            monthCalendar1.SelectionRange = new SelectionRange(startD, endD);
 
 
 
 
                Process myprocess = new Process();
                ProcessStartInfo psinfo = new ProcessStartInfo();
                myprocess.StartInfo.FileName = "sqlplus.exe";
                //Fonctionnel
                // myprocess.StartInfo.Arguments = "Q1_RTB_GNSYS_GBQ_CDTM/Q1_RTB@Q1_RTB.SIG @C:\\Applics\\RequeteurCTI\\GENDTW001.SQL 12/05/2014 20140512_gendtw001.txt";
                //myprocess.StartInfo.Arguments = "Q1_RTB_GNSYS_GBQ_CDTM/Q1_RTB@Q1_RTB.SIG" + " " + s + " " + dateStartStr + " " + monthCalendar1.SelectionEnd.ToString("yyyyMMdd") + "_gendtw001.txt";
                //myprocess.WorkingDirectory = @"C:\Applics\RequeteurCTI\";
 
                myprocess.Start();
 
                myprocess.Close();
 
 
                //Validation de la date séléctionnée dans le calendrier
                //MessageBox.Show(monthCalendar1.SelectionEnd.ToString("yyyyMMdd"));
 
              }  
 
            }
 
 
        void myProcess_OutputDataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e)
        {
            MessageBox.Show(e.Data);
        }
 
        void myProcess_Exited(object sender, EventArgs e)
        {
            MessageBox.Show("Exit");
        }
 
        void myProcess_ErrorDataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e)
        {
            MessageBox.Show(e.Data);
        }
 
 
 
        private void monthCalendar1_MouseDown(object sender, MouseEventArgs e)
        {
            MonthCalendar.HitTestInfo info = monthCalendar1.HitTest(e.Location);
            if (info.HitArea == MonthCalendar.HitArea.Date)
            {
                if (monthCalendar1.BoldedDates.Contains(info.Time))
                    monthCalendar1.RemoveBoldedDate(info.Time);
                else
                    monthCalendar1.AddBoldedDate(info.Time);
                monthCalendar1.UpdateBoldedDates();
            }
        }
 
 
        private void monthCalendar1_DateSelected(object sender, DateRangeEventArgs e)
        {
 
        }
 
 
 
    }
 
 
}