示例#1
0
        private void btn_ajouter_Click(object sender, EventArgs e)
        {
            Ordinateur ordi = null;

            if (txt_marque.Text != "" && txt_modele.Text != "" && txt_eMarque.Text != "")
            {
                Ecran ec = new Ecran(txt_eMarque.Text, int.Parse(txt_eTaille.Text), (TypeEcran)Enum.Parse(typeof(TypeEcran), cmb_eType.Text));

                if (rb_tDesktop.Checked)
                {
                    if (txt_souris.Text != "" && txt_clavier.Text != "")
                    {
                        ordi = new DesktopPC(txt_marque.Text, txt_modele.Text, dtp_garantie.Value, ckb_graveur.Checked, pb_photo.Image, ec, txt_clavier.Text, txt_souris.Text);
                    }
                    else
                    {
                        MessageBox.Show("veuillez remplir tous les champs");
                    }
                }
                else
                {
                    if (txt_autonomie.Text != "")
                    {
                        ordi = new LaptopPC(txt_marque.Text, txt_modele.Text, dtp_garantie.Value, ckb_graveur.Checked, pb_photo.Image, ec, double.Parse(txt_autonomie.Text), btn_couleur.BackColor);
                    }
                    else
                    {
                        MessageBox.Show("veuillez remplir tous les champs");
                    }
                }

                SystemeExploitation se;
                for (int i = 0; i < cklb_se.CheckedItems.Count; i++)
                {
                    se = Program.RechercheSEparStr(cklb_se.CheckedItems[i].ToString());
                    ordi.AjouterSE(se);
                }
                Program.parc.Add(ordi);
                cmb_nserie.Items.Add(ordi.NSerie.ToString());
            }
            else
            {
                MessageBox.Show("veuillez remplir tous les champs");
            }
        }
        public static void FillDepartment()
        {
            var indexOffset = 0;

            for (int i = 0; i < departments.GetLength(0); i++)
            {
                int lengthForJagged = 0;
                for (int j = 0; j < departments.GetLength(1); j++)
                {
                    if (departments[i, j] > 0)
                    {
                        lengthForJagged += departments[i, j];
                    }
                }

                organization[i] = new Computer[lengthForJagged];
                for (int j = 0; j < departments.GetLength(1); j++)
                {
                    for (int k = 0; k < departments[i, j]; k++)
                    {
                        switch (j)
                        {
                        case 0:
                            organization[i][indexOffset] = new DesctopPC();
                            break;

                        case 1:
                            organization[i][indexOffset] = new LaptopPC();
                            break;

                        default:
                            organization[i][indexOffset] = new ServerPC();
                            break;
                        }

                        CollectStatistic(i, indexOffset);
                        indexOffset++;
                    }
                }
                indexOffset = 0;
            }
        }
 private void cmb_nserie_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmb_nserie.SelectedIndex != -1)
     {
         Ordinateur ordi = Program.RechercherParNserie(long.Parse(cmb_nserie.Text));
         if (ordi != null)
         {
             txt_marque.Text     = ordi.Marque;
             txt_modele.Text     = ordi.Modele;
             ckb_graveur.Checked = ordi.Graveur;
             dtp_garantie.Value  = ordi.DateDebutGarantie;
             txt_eMarque.Text    = ordi.EcranOrdi.Marque;
             txt_eTaille.Text    = ordi.EcranOrdi.Taille.ToString();
             cmb_eType.Text      = ordi.EcranOrdi.TEcran.ToString();
             pb_photo.Image      = ordi.Photo;
             for (int i = 0; i < cklb_se.Items.Count; i++)
             {
                 cklb_se.SetItemChecked(i, ordi.isSEinstalled(cklb_se.Items[i].ToString()));
             }
             if (ordi is DesktopPC)
             {
                 DesktopPC dpc = (DesktopPC)ordi;
                 txt_souris.Text     = dpc.Souris;
                 txt_clavier.Text    = dpc.Clavier;
                 rb_tDesktop.Checked = true;
             }
             else
             {
                 LaptopPC lpc = (LaptopPC)ordi;
                 txt_autonomie.Text    = lpc.Autonomie.ToString();
                 btn_couleur.BackColor = lpc.Couleur;
                 rb_tLabtop.Checked    = true;
             }
         }
         else
         {
             MessageBox.Show("N° de serie introuvable");
         }
     }
 }