コード例 #1
0
        public void RequestedHolidayList(DataGridView table, bool valid)
        {
            try
            {
                // Gte all pending holiday requests
                var requestedQuery = (from a in db.holidays
                                      where a.Status == "Pending"
                                      select a).ToList();


                if (requestedQuery.Any())
                {
                    foreach (var item in requestedQuery.ToList())
                    {
                        // Remove the requests which either match or break constraints
                        if (valid == cc.CheckConstraints(item.HolidayID, item.employee.StaffID.ToString()).Any())
                        {
                            requestedQuery.Remove(item);
                        }
                    }

                    // Sort the list if any request have been made in peak times
                    List <holiday> priortised = pc.Prioritise(requestedQuery, cc);

                    // Format the infomation
                    table.DataSource = (from a in priortised
                                        select new
                    {
                        a.HolidayID,
                        a.employee.StaffID,
                        a.employee.FirstName,
                        a.employee.LastName,
                        a.StartDate,
                        a.EndDate
                    }).ToList();
                }
                else
                {
                    //List<holiday> priortised = pc.Prioritise(requestedQuery, cc);


                    //table.DataSource = (from a in priortised
                    //                    select new
                    //                    {
                    //                        a.HolidayID,
                    //                        a.employee.StaffID,
                    //                        a.employee.FirstName,
                    //                        a.employee.LastName,
                    //                        a.StartDate,
                    //                        a.EndDate
                    //                    }).ToList();
                    MessageBox.Show("No Pending Holiday Requests");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                throw;
            }
        }
コード例 #2
0
        internal static bool IsImplicitlyConvertible(Type source, Type destination)
        {
            if (destination.IsGenericParameter)
            {
                if (ConstraintChecker.CheckConstraints(
                        null,
                        destination.DeclaringType,
                        new[] { destination },
                        new[] { source },
                        SourceSpan.None,
                        true))
                {
                    return(true);
                }
            }

            if (source.IsGenericType &&
                destination.IsGenericType &&
                !source.IsGenericTypeDefinition)
            {
                if (destination.IsGenericTypeDefinition)
                {
                    return(source.GetGenericTypeDefinition() == destination);
                }

                var sArgs = source.GetGenericArguments();
                var dArgs = destination.GetGenericArguments();

                if (sArgs.Length == dArgs.Length)
                {
                    var success = !sArgs
                                  .Where((t, i) => !dArgs[i].IsGenericParameter && !AreAssignable(t, dArgs[i]))
                                  .Any();

                    if (success)
                    {
                        return(true);
                    }
                }
            }

            return(IsIdentityConversion(source, destination) ||
                   IsImplicitNumericConversion(source, destination) ||
                   IsImplicitReferenceConversion(source, destination) ||
                   IsImplicitBoxingConversion(source, destination));
        }