示例#1
0
        private void Txt_Rech_TextChanged(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Txt_Rech.Text.Trim()))
            {
                Dgv_Dept.DataSource = Dal_Dept.GetAllDepartementsDataTable();
            }
            else
            {
                List <Departements> ListeDepartement = new List <Departements>();
                ListeDepartement = Dal_Dept.GetAllDepartementsList();

                var query = from o in ListeDepartement
                            where o.PropCode.Contains(Txt_Rech.Text) || o.PropNom.Contains(Txt_Rech.Text)
                            select o;
                Dgv_Dept.DataSource = query.ToList();
            }
        }
示例#2
0
        private void Btn_Importer_Click(object sender, EventArgs e)
        {
            var fileContent = string.Empty;
            var filePath    = string.Empty;

            using (OpenFileDialog Ofd = new OpenFileDialog()
            {
                Filter = "Fichiers Excel | *.xls; *.xlsx; *.xlsm", ValidateNames = true, Multiselect = false
            })
            {
                if (Ofd.ShowDialog() == DialogResult.OK)
                {
                    //Get the path of specified file
                    filePath = Ofd.FileName;
                    Dal_Departement     Dal_Dept = new Dal_Departement();
                    List <Departements> DeptList = Dal_Dept.GetAllDepartementsList();

                    Dal_Ens.GetDataFromExcelFile(filePath, out MydataTabX, out MydataTabY, out MydataTabA, out MydataTabB, out MydataTabC);
                    for (int i = 0; i < MydataTabA.Length; i++)
                    {
                        Departements Dept = new Departements(MydataTabB[i], MydataTabC[i]);
                        if (!DeptList.Contains(Dept))
                        {
                            Dal_Dept.AddDepartement(Dept);
                        }
                        Enseignants Ens = new Enseignants(MydataTabX[i], MydataTabY[i], MydataTabA[i], "En cours", Dept);
                        Dal_Ens.AddEnseignant(Ens);
                        fillDgvEns();
                    }
                    MessageBox.Show("Données importées avec succès", "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    /*   //Read the contents of the file into a stream
                     * var fileStream = Ofd.OpenFile();
                     *
                     * using (StreamReader reader = new StreamReader(fileStream))
                     * {
                     *     fileContent = reader.ReadToEnd();
                     * }
                     */
                }
            }

            // MessageBox.Show(fileContent, "File Content at path: " + filePath, MessageBoxButtons.OK);
        }