Comment mettre à jour un onglet (TabPage) ?

Résolu
cs_vinok Messages postés 36 Date d'inscription jeudi 12 octobre 2006 Statut Membre Dernière intervention 29 mars 2013 - 2 févr. 2009 à 18:41
cs_vinok Messages postés 36 Date d'inscription jeudi 12 octobre 2006 Statut Membre Dernière intervention 29 mars 2013 - 4 févr. 2009 à 00:53
Bonjour,

Je veux faire un planning comme ceci :

A chaque changement de semaine (clique sur l'un des boutons "semaine précédente" et "semaine suivante"), il faut mettre à jour les combobox contenues dans une groupbox,
 elle-meme contenue dans un TabPage.
L'application est reliée à une base de données de type SqlServer qui contient les horaires et les personnes (guibert,dupont etc..) et les activités (fitness,séance kiné etc)..
Comment faire ??

7 réponses

fcaruso Messages postés 18 Date d'inscription vendredi 15 avril 2005 Statut Membre Dernière intervention 10 février 2009
3 févr. 2009 à 23:32
Pour répondre a ta question :
Si tu veux faire un truc rapide, tu peux travailler en direct sur les DataTable ou un Reader, MS n'a pas inventé ca pour rien ;-)
Si tu veux faire un truc propre, lisible, maintenable et evolutif, sincerement : Oui. On parle souvent de la DAL ( data access layer ) et de la BLL ( business access layer ).

Là tout dépends de ton objectif, je n'ai fait que te dire ce que je ferais moi, apres tu en fais ce que tu veux...

Tu va surtout gagner en lisibilité dans un 1er temps : Manipuler des objets et des collections "Metier" est tellement plus evident et clair quand on en a fait l'experience.

En fait l'idée de base à retenir c'est juste de bien séparer chaque chose :
- La création des combo à un endroit ( dans la Form ou un UserControl )
- Le chargement à un autre endroit (que tu pourra reutiliser sans avoir a recreer tes combo, si tu change de semaine)
- Si possible se faciliter la representation finale ( class Activite ) par quelquechose de tres lisible ( des objets metiers ) et tres manipulables ( un DataReader ne va que dans un sens par exemple (while Read()) et on ne peut rechercher simplement dedans sans relancer une requete SQL... alors que dans une List... )

Bref
A+
Fab
3
cs_vinok Messages postés 36 Date d'inscription jeudi 12 octobre 2006 Statut Membre Dernière intervention 29 mars 2013
2 févr. 2009 à 18:53
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="ProgId" content="Word.Document" />
<meta name="Generator" content="Microsoft Word 12" />
<meta name="Originator" content="Microsoft Word 12" />
<link rel="File-List" href="file:///C:%5CUsers%5CVinok%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml" />
<link rel="themeData" href="file:///C:%5CUsers%5CVinok%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx" />
<link rel="colorSchemeMapping" href="file:///C:%5CUsers%5CVinok%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml" />
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:HyphenationZone>21</w:HyphenationZone>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>FR</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]-->
<!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;
mso-font-charset:0;
mso-generic-font-family:roman;
mso-font-pitch:variable;
mso-font-signature:-1610611985 1107304683 0 0 159 0;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:-1610611985 1073750139 0 0 159 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-unhide:no;
mso-style-qformat:yes;
mso-style-parent:"";
margin-top:0cm;
margin-right:0cm;
margin-bottom:10.0pt;
margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:Calibri;
mso-fareast-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;
mso-fareast-language:EN-US;}
.MsoChpDefault
{mso-style-type:export-only;
mso-default-props:yes;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:Calibri;
mso-fareast-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;
mso-fareast-language:EN-US;}
.MsoPapDefault
{mso-style-type:export-only;
margin-bottom:10.0pt;
line-height:115%;}
@page Section1
{size:595.3pt 841.9pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;
mso-header-margin:35.4pt;
mso-footer-margin:35.4pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Tableau Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"Times New Roman";
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;}
</style>
<![endif]-->

voici le code si ça peut aider à comprendre...










public

SqlConnection conn;






 






GroupBox

initPlanningGroupbox(DateTime debut,object activité)






       
/* dessine
une grille de textbox pour les plannings */







 







        {






           
//Etablissement
de la connexion







            conn = bdd.testConnection();






            conn.Open();






           








           
GroupBox
g = newGroupBox();






           
ComboBox[,]
t = newComboBox[16,
7];






           
DateTime
dh;






           
SqlDataReader
rd, rd2;






           








            #region
Requetes






           
string
req = "select s.NUMSALARIÉ,NOMSALARIÉ,PRENSALARIÉ
from salarié as s,dispenser as d";






                   req+= " WHERE 
s.NUMSALARIÉ=d.NUMSALARIÉ AND NUMACTIVITÉ=@act";






 







           
string
req2 = "select s.NUMSALARIÉ,NOMSALARIÉ,PRENSALARIÉ
from salarié as s,dispenser as d";






            req2 += "
where s.NUMSALARIÉ=d.NUMSALARIÉ and HEURE=@dh and NUMACTIVITÉ=@act2";






            #endregion






 







          








           
//requete
de remplissage des combobox







           
SqlCommand
cmd=newSqlCommand(req,conn);






           
SqlParameter
act = newSqlParameter("@act", SqlDbType.Int);






            act.Value = activité;






            cmd.Parameters.Add(act);






 







           
//requete
de remplissage de l'item sélectionné







           
SqlCommand
cmd2 = newSqlCommand(req2,
conn);






           
SqlParameter
dh_p = newSqlParameter("@dh", SqlDbType.DateTime);






           
SqlParameter
act2 = newSqlParameter("@act2", SqlDbType.Int);






            act2.Value = activité;






            cmd2.Parameters.Add(dh_p);






            cmd2.Parameters.Add(act2);






   








            #region
creation
des combobox






           
//textbox
initiale







           
int
pos_l = 6;//abcisse de la textbox






           
int
pos_c = 19;//ordonnée de la textbox






           
Point
p = newPoint(pos_l,
pos_c);






           
for
(int i = 1; i <= 15; i++)






               
for
(int j = 1; j <= 6; j++)






                {






 







                    t[i, j] = newComboBox();






                    rd=cmd.ExecuteReader();






                   








                   
while
(rd.Read())






                    {






                    
   t[i, j].Items.Add(rd["NOMSALARIÉ"].ToString()+"
"+rd["PRENSALARIÉ"].ToString());






                        t[i, j].ValueMember =
rd["NUMSALARIÉ"].ToString();






                     








                    }






                    rd.Close();






                    dh=date2Horaire(j,i);






                    cmd2.Parameters["@dh"].Value = dh;






                    rd2 = cmd2.ExecuteReader();






                   
while
(rd2.Read())






                    {






                       
if(j==dh.Day)






                            t[i,
j].SelectedItem = rd2["NOMSALARIÉ"].ToString()
+ " " + rd2["PRENSALARIÉ"].ToString();






                    }






                    rd2.Close();






                   
//taille
initiale







                    t[i, j].Size = newSize(81, 21);






                    t[i, j].Location = newPoint(pos_l,
pos_c);






                   
if
(j > 5)






                    {






                       
//position initiale en 1ere colonne







                        pos_l = 6;






                        pos_c += 26;






                    }






                   
else







                    {






                        pos_l += 87;






                    }






                   
//surlignage
de l'horaire en cours







                   
if
((DateTime.Now.Hour i + 7) && (j
toutDate.Jour2Numero(DateTime.Now.DayOfWeek.ToString())))






                        t[i, j].BackColor = Color.LightGreen;






                    g.Controls.Add(t[i, j]);






                }






            #endregion






            g.Location = new System.Drawing.Point(94,
35);






            g.Name = "planningGroupBox";






            g.Size = new
System.Drawing.Size(564, 421);






           

return g;





private

void FormPlanning_Load(object
sender, EventArgs e)






        {






            d_debutDateTimePicker.Value =
mettreALundi(d_debutDateTimePicker.Value);






            d_finDateTimePicker.Value =
d_debutDateTimePicker.Value.AddDays(5);






 







           
//Etablissement
de la connexion







            conn = bdd.testConnection();






    
       conn.Open();






 







           
string
req = "select NUMACTIVITÉ,LIBACTIVITÉ from
ACTIVITÉ";






           
SqlCommand
cmd = newSqlCommand(req,
conn);






           
SqlDataReader
rd1 = cmd.ExecuteReader();






           
int
i = 0;






           
while
(rd1.Read())






            {






               
//propriétés
de l'onglet en cours







               
TabPage
t = newTabPage(rd1["LIBACTIVITÉ"].ToString());






                t.Location = new System.Drawing.Point(4,
22);






                t.Name = rd1["LIBACTIVITÉ"].ToString();






                t.Padding = new System.Windows.Forms.Padding(3);






                t.Size = new System.Drawing.Size(654,
462);






                t.TabIndex = i;






                t.Tag = rd1["NUMACTIVITÉ"];






                t.Text = rd1["LIBACTIVITÉ"].ToString();






                t.UseVisualStyleBackColor = true;






               
menuPlanningTabControl.Controls.Add(t);






                t.ResumeLayout(false);






 







               
//affichage
des jours de la semaine







                #region
/*Labels
jours*/






               
Label
lblLun = newLabel();






               
Label
lblMar = newLabel();






               
Label
lblMer = newLabel();






               
Label
lblJeu = newLabel();






               
Label
lblVen = newLabel();






               
Label
lblSam = newLabel();






               
//







               
//
lblLun







               
//







                lblLun.AutoSize = true;






                lblLun.Location = new System.Drawing.Point(127,
16);






                lblLun.Name = "lblLun";






                lblLun.Size = new System.Drawing.Size(33,
13);






                lblLun.TabIndex = 21;






                lblLun.Text = "Lundi";






               
// //
lblMar







               
//







                lblMar.AutoSize = true;






                lblMar.Location = new System.Drawing.Point(216,
16);






                lblMar.Name = "lblMar";






                lblMar.Size = new System.Drawing.Size(33,
13);






                lblMar.TabIndex = 22;






                lblMar.Text = "Mardi";






               
//
lblMer







               
//







                lblMer.AutoSize = true;






                lblMer.Location = new System.Drawing.Point(294,
16);






                lblMer.Name = "lblMer";






                lblMer.Size = new System.Drawing.Size(48,
13);






                lblMer.TabIndex = 23;






                lblMer.Text = "Mercredi";






               
// //
lblJeu







               
//







                lblJeu.AutoSize = true;






                lblJeu.Location = new System.Drawing.Point(391,
16);






                lblJeu.Name = "lblJeu";






                lblJeu.Size = new System.Drawing.Size(32,
13);






                lblJeu.TabIndex = 24;






                lblJeu.Text = "Jeudi";






               
//







               
//
lblVen







               
//







                lblVen.AutoSize = true;






                lblVen.Location = new System.Drawing.Point(480,
16);






                lblVen.Name = "lblVen";






                lblVen.Size = new System.Drawing.Size(49,
13);






                lblVen.TabIndex = 25;






                lblVen.Text = "Vendredi";






               
//







               
//
lblsam







             
  
//







                lblSam.AutoSize = true;






                lblSam.Location = new System.Drawing.Point(567,
16);






                lblSam.Name = "lblsam";






                lblSam.Size = new System.Drawing.Size(42,
13);






                lblSam.TabIndex = 26;






                lblSam.Text = "Samedi";






                t.Controls.Add(lblLun);






                t.Controls.Add(lblMar);






                t.Controls.Add(lblMer);






                t.Controls.Add(lblJeu);






                t.Controls.Add(lblVen);






                t.Controls.Add(lblSam);






               
//







                #endregion






               
t.Controls.Add(initHoraireGroupbox());






               
t.Controls.Add(initPlanningGroupbox(d_debutDateTimePicker.Value,
t.Tag));






                i++;






            }






    
       rd1.Close();






            conn.Close();






        }






       
DateTime
mettreALundi(DateTime d)






        {






           








            d.AddDays(d.Day - (d.Day + 1));






           
return
d;






        }






       
private
void semPrec_bt_Click(object
sender, EventArgs e)






        {






            d_debutDateTimePicker.Value =
d_debutDateTimePicker.Value.AddDays(-7);






            d_finDateTimePicker.Value =
d_finDateTimePicker.Value.AddDays(-7);






        }






       
private
void semSuiv_bt_Click(object
sender, EventArgs e)






        {






            d_debutDateTimePicker.Value =
d_debutDateTimePicker.Value.AddDays(7);






            d_finDateTimePicker.Value =
d_finDateTimePicker.Value.AddDays(7);






        }






 







       
private
void d_debutDateTimePicker_ValueChanged(object sender, EventArgs
e)






        {






            /////????????????????????????????////////






        }
0
fcaruso Messages postés 18 Date d'inscription vendredi 15 avril 2005 Statut Membre Dernière intervention 10 février 2009
2 févr. 2009 à 21:20
Commence par totalement séparer le code de création des combobox et le code qui va les remplir. Tu verra tout deviendra plus clair.

Puis attention, la double boucle execute quand meme 90 requetes SQL.
L'idée serait d'avoir une methode de remplissage qui n'execute qu'une seule requete.

Aussi en C# on commence les tableau à 0, pas à 1  : for (int i = 1; i <= 15; i++) -> for (int i = 0; i < 15; i++)

Fabrice
0
cs_vinok Messages postés 36 Date d'inscription jeudi 12 octobre 2006 Statut Membre Dernière intervention 29 mars 2013
3 févr. 2009 à 19:43
Wè j'avoue qu'en terme de complexité, ça pourrait être mieux..
J'ai pris note de ce que tu m'as dit, mais maintenant ça marche encore moins bien, et le temps d'execution est plus long !
J'ai séparé la conception de la grille de Comboboxs de son remplissage et jme retrouve forcément avec 2 fois + de boucles FOR.
Ensuite, pour les 90 requêtes sql, jvoi pa trop comment faire autrement : ce sont  les coordonnées [ligne,colonne] que j'utilise pr  le jour et l'horaire, paramètres de ma requête SQL..
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
fcaruso Messages postés 18 Date d'inscription vendredi 15 avril 2005 Statut Membre Dernière intervention 10 février 2009
3 févr. 2009 à 21:02
Evite HEURE=@dh dans ta requete. c'est à cause de ca que tu en fais des tonnes.

En fait meix est de faire une classe "Activite" avec des properties publiques qui correspondent à NUMSALARIÉ NOMSALARIÉ PRENSALARIÉ HEURE NUMACTIVITÉ.

Ensuite tu fais une methode "List GetActivite(int numSalarie)" qui fabrique un List a partir du reader. Apres, la liste est en mémoire et beaucoup simple à utiliser qu'un DataReader et tres performante dans la proc de remplissage, avec soit des "foreach(Activite ain activites) if (a.Heure==1) " soit  "activite.Where(a=>a.Heure==1)" si tu as System.Linq.

Quelques conseils : evite au maximum de travailler en direct sur les objets de données comme un Reader ou une DataTable, surtout dans le code des forms ( a bannir absolument ), essaye de centraliser et minimiser le nombre de methodes qui utilisent l'acces à la base dans tes objets, et privilegie des classes "metier" comme "Activite" et des collections pour travailler.

Bon courage

Fabrice
0
cs_vinok Messages postés 36 Date d'inscription jeudi 12 octobre 2006 Statut Membre Dernière intervention 29 mars 2013
3 févr. 2009 à 21:32
alors selon toi jdevrai faire des classes-métiers pour tous mes objets?
J'ai un dataset qui est relié à la base, on ne peut pas l'exploiter?
shéma du dataset:

Jte remercie avoir pris le temps de me répondre, jv voir pour encaspuler ça dans des classes
0
cs_vinok Messages postés 36 Date d'inscription jeudi 12 octobre 2006 Statut Membre Dernière intervention 29 mars 2013
4 févr. 2009 à 00:53
wè c clair..
okay...
bin va falloir faire plein de classes avc ttes les propriétés et tt..
Jte remercie pour les infos, c sympa.
A bientot !
0
Rejoignez-nous