示例#1
0
        private void dicToTable(clsListEmployees listAgent)
        {
            tabAgent = new DataTable();
            tabAgent.Columns.Add("Code", listAgent.Elements.First().Code.GetType());
            tabAgent.Columns.Add("Fullname", listAgent.Elements.First().Fullname.GetType());
            tabAgent.Columns.Add("Gender", listAgent.Elements.First().Gender.GetType());
            tabAgent.Columns.Add("Lang", listAgent.Elements.First().Lang.GetType());
            tabAgent.Columns.Add("CityZone", listAgent.Elements.First().Cityzone.GetType());
            tabAgent.Columns.Add("Pic", listAgent.Elements.First().Pic.GetType());
            tabAgent.Columns.Add("ID", listAgent.Elements.First().ID.GetType());

            foreach (clsEmployee row in listAgent.Elements)
            {
                tabAgent.Rows.Add(row.Code, row.Fullname, row.Gender, row.Lang, row.Cityzone, row.Pic, row.ID);
            }
        }
 // 7 fnc.Load Employees
 public clsListEmployees fncGetEmployees()
 {
     try
     {
         // 1. Objet clsListEmployees
         clsListEmployees ListEmployees = new clsListEmployees();
         // 2. Execute open connection
         Command.Connection = Connection.OpenConnection();
         // 3. Execute stored procedure
         Command.CommandText = "selectEmployees";
         // 4. Execute specify the command type
         Command.CommandType = CommandType.StoredProcedure;
         // 5. Execute the Reader
         Read = Command.ExecuteReader();
         // 6. Load the list
         while (Read.Read())
         {
             // variables
             string   number, name, lastName, email, img, sexe, active;
             DateTime hiringDate;
             int      idemployee, idagencies;
             decimal  salary;
             idemployee = Read.GetInt32(Read.GetOrdinal("idemployee"));
             number     = Read.GetString(Read.GetOrdinal("Number"));
             name       = Read.GetString(Read.GetOrdinal("Name"));
             lastName   = Read.GetString(Read.GetOrdinal("Last Name"));
             email      = Read.GetString(Read.GetOrdinal("Email"));
             img        = Read.GetString(Read.GetOrdinal("img"));
             hiringDate = Read.GetDateTime(Read.GetOrdinal("Hiring Date"));
             salary     = Read.GetDecimal(Read.GetOrdinal("salary"));
             sexe       = Read.GetString(Read.GetOrdinal("sexe"));
             active     = Read.GetString(Read.GetOrdinal("active"));
             idagencies = Read.GetInt32(Read.GetOrdinal("idagencies"));
             ListEmployees.fncAdd(new clsEmployee(idemployee, number, name, lastName, email, img, active, sexe, salary, idagencies, hiringDate));
         }
         // 7. Close Read Connection
         Read.Close();
         // 8. Make the return
         return(ListEmployees);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error in the Model getting the employees list from data base : " + ex.Message);
         return(null);
     }
 }
示例#3
0
        private void dicToTable(clsListEmployees listEmp)
        {
            empTable = new DataTable();

            empTable.CaseSensitive = false;

            empTable.Columns.Add("Code", listEmp.Elements.First().Code.GetType());
            empTable.Columns.Add("Fullname", listEmp.Elements.First().Fullname.GetType());
            empTable.Columns.Add("Gender", listEmp.Elements.First().Gender.GetType());
            empTable.Columns.Add("Lang", listEmp.Elements.First().Lang.GetType());
            empTable.Columns.Add("CityZone", listEmp.Elements.First().Cityzone.GetType());
            empTable.Columns.Add("Type", listEmp.Elements.First().Employeetype.GetType());
            empTable.Columns.Add("Username", listEmp.Elements.First().Username.GetType());
            empTable.Columns.Add("Password", listEmp.Elements.First().Password.GetType());

            foreach (clsEmployee row in listEmp.Elements)
            {
                empTable.Rows.Add(row.Code, row.Fullname, row.Gender, row.Lang, row.Cityzone, row.Employeetype, row.Username, row.Password);
            }
        }
示例#4
0
 public clsCompany(string vName, clsListEmployees vEmployees)
 {
     this.Name      = vName;
     this.Employees = vEmployees;
 }