Esempio n. 1
0
 /// <summary>
 /// Load Object
 /// </summary>
 /// <param name="reader"></param>
 /// <param name="worker"></param>
 private static void LoadObject(MySqlDataReader reader, Educator worker)
 {
     worker.UID        = Convert.ToInt32(reader[FieldName.UID]);
     worker.FirstName  = reader[FieldName.FirstName] as string;
     worker.Surname    = reader[FieldName.Surname] as string;
     worker.WLVL_Level = reader[FieldName.WLVL_Level] as string;
     // -----------------------------------------------------------------------------------------
     worker.UpdateDateTime   = Convert.ToDateTime((reader[FieldName.UpdateDateTime]));
     worker.UserIdUpdatedBy  = reader[FieldName.UserIdUpdatedBy] as string;
     worker.CreationDateTime = Convert.ToDateTime((reader[FieldName.CreationDateTime]));
     worker.UserIdCreatedBy  = reader[FieldName.UserIdCreatedBy] as string;
     worker.RecordVersion    = Convert.ToInt32(reader[FieldName.RecordVersion]);
     worker.IsVoid           = reader[FieldName.IsVoid] as string;
 }
Esempio n. 2
0
        /// <summary>
        /// List clients
        /// </summary>
        /// <param name="userID"></param>
        public static List <Educator> ListS()
        {
            var workerListX = new List <Educator>();

            using (var connection = new MySqlConnection(ConnectionString.GetConnectionString()))
            {
                var commandString = string.Format(
                    " SELECT " +
                    FieldString() +
                    "   FROM Worker " +
                    "  WHERE IsVoid = 'N' " +
                    "  ORDER BY UID ASC "
                    );

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    connection.Open();

                    try
                    {
                        using (MySqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                var worker = new Educator();
                                LoadObject(reader, worker);

                                workerListX.Add(worker);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        string error = ex.ToString();
                        LogFile.WriteToTodaysLogFile(ex.ToString(), "", "", "Client.cs");
                    }
                }
            }

            return(workerListX);
        }