beny100
Messages postés
213
Date d'inscription
vendredi 17 novembre 2006
Statut
Membre
Dernière intervention
1 avril 2009
27 déc. 2006 à 08:56
if
(
this
.radioButton2.Checked ==
true
)
// est ce que l'alarme active est cochée
{
Microsoft.Office.Interop.Excel.
_Application
Excel_App;Microsoft.Office.Interop.Excel.
_Workbook
Excel_Clsseur;Microsoft.Office.Interop.Excel.
_Worksheet
Excel_Flle;Excel_App =
new
Microsoft.Office.Interop.Excel.
ApplicationClass
();Excel_App.ReferenceStyle = Microsoft.Office.Interop.Excel.
XlReferenceStyle
.xlR1C1;Excel_App.Visible =
true
;
//false;
object
Missing = System.Reflection.
Missing
.Value;Excel_Clsseur = Excel_App.Workbooks.Add(Missing);
Microsoft.Office.Interop.Excel.
Sheets
Excel_Flles Excel_Clsseur.Sheets;Excel_Flle (Microsoft.Office.Interop.Excel.
_Worksheet
)Excel_Flles.Add(Missing, Missing, Missing, Missing);Excel_Flle = (Microsoft.Office.Interop.Excel.
_Worksheet
)Excel_Flles.Add(Missing, Missing, Missing, Missing);
if
(
this
.radioButton3.Checked ==
true
){
myQuery =
"select* from Alarme_active where type_alarme='equipmentAlarm'"
;NomFeuille =
"Alarme Equipement"
;Rempli_Feuille((Microsoft.Office.Interop.Excel.
_Worksheet
)Excel_Flles[1], myQuery, NomFeuille);
}
if
(
this
.radioButton4.Checked ==
true
){
myQuery =
"select* from Alarme_active where type_alarme='communicationsAlarm'"
;NomFeuille =
"Alarme Communication"
;Rempli_Feuille((Microsoft.Office.Interop.Excel.
_Worksheet
)Excel_Flles[1], myQuery, NomFeuille);}
if
(
this
.radioButton5.Checked ==
true
){
myQuery =
"select* from Alarme_active where type_alarme='qualityofServiceAlarm'"
;NomFeuille =
"Alarme Q.O.S"
;Rempli_Feuille((Microsoft.Office.Interop.Excel.
_Worksheet
)Excel_Flles[1], myQuery, NomFeuille);
}
if
(
this
.radioButton6.Checked ==
true
){
myQuery =
"select* from Alarme_active where type_alarme='environmentalAlarm'"
;NomFeuille =
"Alarme Environnementale"
;Rempli_Feuille((Microsoft.Office.Interop.Excel.
_Worksheet
)Excel_Flles[1], myQuery, NomFeuille);}
}
if
(
this
.radioButton6.Checked ==
false
&&
this
.radioButton5.Checked ==
false
&&
this
.radioButton4.Checked ==
false
&&
this
.radioButton3.Checked ==
false
){
MessageBox
.Show(
"choisir une alarme puis son type avant execution"
);}
if
(
this
.radioButton1.Checked ==
true
)
// est de que l'alarme active est activée
{
Microsoft.Office.Interop.Excel.
_Application
Excel_App;Microsoft.Office.Interop.Excel.
_Workbook
Excel_Clsseur;Microsoft.Office.Interop.Excel.
_Worksheet
Excel_Flle;Excel_App =
new
Microsoft.Office.Interop.Excel.
ApplicationClass
();Excel_App.ReferenceStyle = Microsoft.Office.Interop.Excel.
XlReferenceStyle
.xlR1C1;Excel_App.Visible =
true
;
//false;
object
Missing = System.Reflection.
Missing
.Value;Excel_Clsseur = Excel_App.Workbooks.Add(Missing);
Microsoft.Office.Interop.Excel.
Sheets
Excel_Flles Excel_Clsseur.Sheets;Excel_Flle (Microsoft.Office.Interop.Excel.
_Worksheet
)Excel_Flles.Add(Missing, Missing, Missing, Missing);Excel_Flle = (Microsoft.Office.Interop.Excel.
_Worksheet
)Excel_Flles.Add(Missing, Missing, Missing, Missing);
if
(
this
.radioButton3.Checked ==
true
){
myQuery =
"select type_alarme,date_debut,heure_debut,Module,management_instance,date_fin,heure_fin,criticite from Alarme_ceased where type_alarme='equipmentAlarm'"
;NomFeuille =
"Alarme Active Equipement"
;Rempli_Feuille((Microsoft.Office.Interop.Excel.
_Worksheet
)Excel_Flles[1], myQuery, NomFeuille);}
if
(
this
.radioButton3.Checked ==
false
&&
this
.radioButton4.Checked ==
false
&&
this
.radioButton5.Checked ==
false
&&
this
.radioButton6.Checked ==
false
){
MessageBox
.Show(
"choisir un type d'alarme avant execution"
);}
if
(
this
.radioButton4.Checked ==
true
){
myQuery =
"select type_alarme,date_debut,heure_debut,Module,management_instance,date_fin,heure_fin,criticite from Alarme_ceased where type_alarme='communicationsAlarm'"
;NomFeuille =
"Communication Alarme active"
;Rempli_Feuille((Microsoft.Office.Interop.Excel.
_Worksheet
)Excel_Flles[1], myQuery, NomFeuille);}
if
(
this
.radioButton5.Checked ==
true
){
myQuery =
"select type_alarme,date_debut,heure_debut,Module,management_instance,date_fin,heure_fin,criticite from Alarme_ceased where type_alarme='qualityofServiceAlarm'"
;NomFeuille =
"Alarme active Q.O.S"
;Rempli_Feuille((Microsoft.Office.Interop.Excel.
_Worksheet
)Excel_Flles[1], myQuery, NomFeuille);}
if
(
this
.radioButton6.Checked ==
true
){
myQuery =
"select type_alarme,date_debut,heure_debut,Module,management_instance,date_fin,heure_fin,criticite from Alarme_ceased where type_alarme='environmentalAlarm'"
;NomFeuille =
"Alarme active Environnement"
;Rempli_Feuille((Microsoft.Office.Interop.Excel.
_Worksheet
)Excel_Flles[1], myQuery, NomFeuille);
}
if
(
this
.radioButton6.Checked ==
false
&&
this
.radioButton5.Checked ==
false
&&
this
.radioButton4.Checked ==
false
&&
this
.radioButton3.Checked ==
false
){
MessageBox
.Show(
"choisir un type d'alarme avant execution"
);}
}
else
if
(
this
.radioButton1.Checked ==
false
&&
this
.radioButton2.Checked ==
false
){
MessageBox
.Show(
"choisissez une alarme ceased ou active puis son type"
);}
}
private
void
dateTimePicker1_ValueChanged(
object
sender,
EventArgs
e){
}
private
void
dateTimePicker2_ValueChanged(
object
sender,
EventArgs
e){
}
private
void
comboBox1_SelectedIndexChanged(
object
sender,
EventArgs
e){
}
private
void
button4_Click(
object
sender,
EventArgs
e){
Microsoft.Office.Interop.Excel.
_Application
Excel_App;Microsoft.Office.Interop.Excel.
_Workbook
Excel_Clsseur;Microsoft.Office.Interop.Excel.
_Worksheet
Excel_Flle;Excel_App =
new
Microsoft.Office.Interop.Excel.
ApplicationClass
();Excel_App.ReferenceStyle = Microsoft.Office.Interop.Excel.
XlReferenceStyle
.xlR1C1;Excel_App.Visible =
true
;
//false;
object
Missing = System.Reflection.
Missing
.Value;Excel_Clsseur = Excel_App.Workbooks.Add(Missing);
Microsoft.Office.Interop.Excel.
Sheets
Excel_Flles Excel_Clsseur.Sheets;Excel_Flle (Microsoft.Office.Interop.Excel.
_Worksheet
)Excel_Flles.Add(Missing, Missing, Missing, Missing);Excel_Flle = (Microsoft.Office.Interop.Excel.
_Worksheet
)Excel_Flles.Add(Missing, Missing, Missing, Missing);Line1 = comboBox1.Text.ToString();
if
(
this
.radioButton1.Checked ==
true
){
myQuery =
"select * from Alarme_ceased where site_name='"
+ Line1 +
"'or Module='"
+Line1+
"'"
;NomFeuille = Line1;
Rempli_Feuille((Microsoft.Office.Interop.Excel.
_Worksheet
)Excel_Flles[1], myQuery, NomFeuille);}
if
(
this
.radioButton2.Checked ==
true
){
myQuery =
"select * from Alarme_active where site_name='"
+ Line1 +
"'or Module='"
+ Line1 +
"'"
;
NomFeuille = Line1;
Rempli_Feuille((Microsoft.Office.Interop.Excel.
_Worksheet
)Excel_Flles[1], myQuery, NomFeuille);}
if
(
this
.radioButton7.Checked ==
true
){
myQuery =
"select * from Alarme_Radio where site_name='"
+ Line1 +
"'or Module='"
+ Line1 +
"'"
;
NomFeuille = Line1;
Rempli_Feuille((Microsoft.Office.Interop.Excel.
_Worksheet
)Excel_Flles[1], myQuery, NomFeuille);}
if
(
this
.radioButton7.Checked ==
false
&&
this
.radioButton2.Checked ==
false
&&
this
.radioButton1.Checked ==
false
){
MessageBox
.Show(
"choissisez d'abord une alarme"
); }
private
void Rempli_Feuille(Microsoft.Office.Interop.Excel.
_Worksheet Feuil,
string myQuery,
string Name){
// Microsoft.Office.Interop.Excel._Application Excel_App;
//Microsoft.Office.Interop.Excel._Workbook Excel_Clsseur;
//Microsoft.Office.Interop.Excel._Worksheet Excel_Flle;
// Excel_App = new Microsoft.Office.Interop.Excel.ApplicationClass();
// Excel_App.ReferenceStyle = Microsoft.Office.Interop.Excel.XlReferenceStyle.xlR1C1;
// Excel_App.Visible = false;
// object Missing = System.Reflection.Missing.Value;
// Excel_Clsseur = Excel_App.Workbooks.Add(Missing);
// Microsoft.Office.Interop.Excel.Sheets Excel_Flles = Excel_Clsseur.Sheets;
// Excel_Flle = (Microsoft.Office.Interop.Excel._Worksheet)Excel_Flles.Add(Missing, Missing, Missing, Missing);
// Excel_Flle = (Microsoft.Office.Interop.Excel._Worksheet)Excel_Flles.Add(Missing, Missing, Missing, Missing);
SqlConnection cnx =
null;
//SqlCommand command = null;
String cs =
"Database=RADIO;Data Source=localhost;Integrated Security=SSPI;Pooling =false;";
// laBarre.Value = 0;
//laBarre.Minimum = 0;
//laBarre.Maximum = TableauPackages.Count;
// laBarre.Step 1;cnx
new
SqlConnection(cs);
//**************************
SqlCommand Cmd =
new
SqlCommand();Cmd.Connection = cnx;
Cmd.CommandText = myQuery;
SqlDataReader Reader;cnx.Open();
Reader = Cmd.ExecuteReader();
int max = 0;
while (Reader.Read()) { max += 1; }Reader.Close();
Reader = Cmd.ExecuteReader();
Console.Out.WriteLine(Reader.RecordsAffected);Feuil.Name = Name;
if (Reader.HasRows){
Reader.Read();
int Len = Reader.FieldCount;
if (Len > 255){
Len = 255;
}
// laBarre.Maximum = max;Microsoft.Office.Interop.Excel.
Range Rge = Feuil.get_Range(Feuil.Cells[1, 1], Feuil.Cells[2, Len]);Feuil.get_Range(Feuil.Cells[1, 1], Feuil.Cells[1, Len]).Cells.AutoFormat(Microsoft.Office.Interop.Excel.
XlRangeAutoFormat.xlRangeAutoFormatSimple, 3, 1, 1, 10, 1, 1);
for (
int i = 1; i <= Len; i++){
Rge.Cells.Borders.Color = 5;
Rge.Cells[1, i] = Reader.GetName(i - 1);
Rge.Cells[2, i] =
"'" + Reader[i - 1].ToString();}
Feuil.get_Range(Feuil.Cells[1, 1], Feuil.Cells[1, Len]).Cells.Interior.ColorIndex = 16;
int Cpt = 3;
while (Reader.Read()){
Cursor.Current =
Cursors.WaitCursor;
Rge = Feuil.get_Range(Feuil.Cells[Cpt, 1], Feuil.Cells[Cpt, Len]);
Rge.Cells.Borders.Color = 5;
Rge.Cells.AutoFormat(Microsoft.Office.Interop.Excel.
XlRangeAutoFormat.xlRangeAutoFormatSimple, 9, 0, 0, 0, 0, 0);
for (
int i = 1; i <= Len; i++){
Rge.Cells[1, i] =
"'" + Reader[i - 1].ToString();
//Rge.Cells[1, i] = Reader[i].ToString();
}
//laBarre.PerformStep();Cpt++;
}
}
Reader.Close();
cnx.Close();
Cursor.Current =
Cursors.Default;
voici un extrait de mon code