예제 #1
0
 public static void SelectionSortMethod(object payableObjects, SortingDelegate sortDelegate, SortType sortOrder) //Sorting SSN in ascending order
 {
     //SortingDelegate sort = new SortingDelegate(Employee.CompareSSN);
     IPayable[] payableArray = payableObjects as IPayable[];
     for (int i = 0; i < payableArray.Length; i++)
     {
         int position = i;
         for (int j = i + 1; j < payableArray.Length; j++)
         {
             if (SortType.Ascending == sortOrder)
             {
                 if (sortDelegate(payableArray[position], payableArray[j], true) > 0)
                 {
                     position = j;
                 }
             }
             else if (SortType.Descending == sortOrder)
             {
                 if (sortDelegate(payableArray[position], payableArray[j], false) < 0)
                 {
                     position = j;
                 }
             }
         }
         if (position != i)
         {
             IPayable temp = payableArray[i];
             payableArray[i]        = payableArray[position];
             payableArray[position] = temp;
         }
     }
 }
예제 #2
0
        static void Main(string[] args)
        {
            Invoice          v1 = new Invoice("100", "Seat", 5, 60000);
            Invoice          v2 = new Invoice("101", "desk", 4, 100000);
            HourlyEmployee   h1 = new HourlyEmployee("Mostafa", "Kazemi", "52545658", 100, 10000);
            SalariedEmployee s1 = new SalariedEmployee("sadegh", "Naderi", "58545652", 3000000);

            IPayable[] list = new IPayable [4];
            list[0] = v1;
            list[1] = v2;
            list[2] = h1;
            list[3] = s1;

            double TotalPayment = 0;

            foreach (IPayable x in list)
            {
                //Console.WriteLine("\nPayment: " + x.GetPaymentAmount().ToString());
                Console.WriteLine(x.ToString() + "\nPayment: " + x.GetPaymentAmount().ToString());
                TotalPayment += x.GetPaymentAmount();
            }

            Console.WriteLine("--------------------");
            Console.WriteLine(TotalPayment.ToString());
            Console.ReadKey();
        }
예제 #3
0
    /// <summary>
    /// Method to be called for calling for sorting SSN.
    /// </summary>
    /// <param name="payableObjects"></param>
    /// <param name="sortDelegate"></param>
    /// <param name="isAscending"></param>
    public static void SelectionSortMethod(object payableObjects, SortSSNDelegate sortDelegate, bool isAscending)
    {
        IPayable[] payableArray = null;
        if (payableObjects is IPayable[])
        {
            payableArray = payableObjects as IPayable[];
        }

        for (int i = 0; i < payableArray.Length; i++)
        {
            int position = i;
            for (int j = i + 1; j < payableArray.Length; j++)
            {
                if (sortDelegate(payableArray[position], payableArray[j], isAscending) > 0) // call delegate..
                {
                    position = j;
                }
            }
            if (position != i)
            {
                IPayable temp = payableArray[i];
                payableArray[i]        = payableArray[position];
                payableArray[position] = temp;
            }
        }
    }
예제 #4
0
    public static void Main(string[] args)
    {
        IPayable[] ipObjects = new IPayable[4];

        ipObjects[0] = new Invoice(93, 42.75);
        ipObjects[1] = new SalariedEmployee("Sammy", "Gertrude", 743923731, 625.75);

        Console.WriteLine("<<< Invoice >>>\n" + ipObjects[0].ToString() + "Payement Amount: " + ipObjects[0].GetPaymentAmount() + "\n");
        Console.WriteLine("<<< Employee >>>\n" + ipObjects[1].ToString() + "Payement Amount: " + ipObjects[1].GetPaymentAmount());
    }
예제 #5
0
        static void Main(string[] args)
        {
            IPayable[] payableObjects = new IPayable[4];

            payableObjects[0] = new Invoice("2222", "Nails", 10, 9.99M);
            payableObjects[1] = new Invoice("4545", "Ladder", 2, 29.99M);
            payableObjects[2] = new Employee("Sara", "Jones", "555-555-5555", 45000M);
            payableObjects[3] = new Employee("John", "Brown", "545-555-3456", 60000M);

            foreach (var currentPayable in payableObjects)
            {
                Console.WriteLine("Payment due: {0:C}", currentPayable.GetPaymentAmount());
            }
        }
 /*
     Simple Bubble sort using pointer to function for chosing to sort
     by SSN ascending
 */
 public static void BubbleSort(IPayable[] employees, Sort sort)
 {
     for(int i = employees.Length; i > 0; i--)
     {
         for (int j = 1; j < i; j++)
         {
             IPayable temp = employees[j - 1];
             //use pointer to function
             if((sort(employees[j], employees[j - 1]) < 1)){
                 //swap
                 employees[j - 1] = employees[j];
                 employees[j] = temp;
             }//end if
         }//end for
     }//end for
 }
예제 #7
0
        public static void RebudgetItem(string recordId, int newAccountId)
        {
            AuthenticationData authData = GetAuthenticationDataAndCulture();

            IPayable         payable    = PayableFromRecordId(recordId);
            FinancialAccount newAccount = FinancialAccount.FromIdentity(newAccountId);

            if (payable.Budget.OrganizationId != authData.CurrentOrganization.Identity ||
                payable.Budget.OwnerPersonId != authData.CurrentUser.Identity ||
                newAccount.OrganizationId != authData.CurrentOrganization.Identity)
            {
                throw new UnauthorizedAccessException();
            }

            payable.SetBudget(newAccount, authData.CurrentUser);
        }
    }//end function

    /*
     *  Simple Bubble sort using pointer to function for chosing to sort
     *  by SSN ascending
     */
    public static void BubbleSort(IPayable[] employees, Sort sort)
    {
        for (int i = employees.Length; i > 0; i--)
        {
            for (int j = 1; j < i; j++)
            {
                IPayable temp = employees[j - 1];
                //use pointer to function
                if ((sort(employees[j], employees[j - 1]) < 1))
                {
                    //swap
                    employees[j - 1] = employees[j];
                    employees[j]     = temp;
                } //end if
            }     //end for
        }         //end for
    }             //end function
예제 #9
0
        static void Main(string[] args)
        {
            IPayable[] payableObjects = new IPayable[4];
            payableObjects[0] = new Invoice("GE001", "d***o", 2, 399.99M);
            payableObjects[1] = new Invoice("GE023", "black giant", 2, 599.00M);
            payableObjects[2] = new SalariedEmployee("Simon", "lobo", "562-23-2341", 1200M);
            payableObjects[3] = new SalariedEmployee("Jorgen", "Klopp", "322-55-9875", 900M);

            Console.WriteLine("Processed Polymorphically");


            foreach (var currentPay in payableObjects)
            {
                Console.WriteLine("{0}\npayment due: {1:C}\n",
                                  currentPay, currentPay.GetPaymentAmount());
            }
        } // end main
예제 #10
0
        internal async Task <FormerPaymentOrderDTO> GeneratePaymentOrder()
        {
            Assertion.Assert(FilingRequest.HasTransaction,
                             "This filing has not be linked to a transaction.");
            Assertion.Assert(!FilingRequest.HasPaymentOrder,
                             $"This filing already has a payment order.");

            var provider = this.GetTransactionProvider();

            IPayable transaction = provider.GetTransactionAsPayable(this.TransactionUID);

            FormerPaymentOrderDTO paymentOrder = await GeneratePaymentOrder(transaction).ConfigureAwait(false);

            provider.SetPaymentOrder(transaction, paymentOrder);

            return(paymentOrder);
        }
예제 #11
0
        static public async Task <FormerPaymentOrderDTO> RequestPaymentOrderData(IPayable payable)
        {
            FormerPaymentOrderDTO paymentOrderData = payable.TryGetFormerPaymentOrderData();

            if (paymentOrderData != null)
            {
                return(paymentOrderData);
            }

            IPaymentOrderProvider provider = ExternalProviders.GetPaymentOrderProvider();

            paymentOrderData = await provider.GeneratePaymentOrder(payable)
                               .ConfigureAwait(false);

            payable.SetFormerPaymentOrderData(paymentOrderData);

            return(paymentOrderData);
        }
예제 #12
0
        static private async Task <FormerPaymentOrderDTO> GeneratePaymentOrder(IPayable transaction)
        {
            try {
                bool USE_PAYMENT_ORDER_MOCK_SERVICE = ConfigurationData.Get("UsePaymentOrderMockService", false);

                if (USE_PAYMENT_ORDER_MOCK_SERVICE)
                {
                    return(PaymentOrderMockData());
                }

                return(await EPaymentsUseCases.RequestPaymentOrderData(transaction)
                       .ConfigureAwait(false));
            } catch (Exception e) {
                throw new ServiceException("GeneratePaymentOrder.ServiceUnavailable",
                                           "El servicio externo de la Secretaría de Finanzas " +
                                           "que genera las órdenes de pago no está disponible. " +
                                           "Favor de intentar más tarde.", e);
            }
        }
예제 #13
0
파일: Demo.cs 프로젝트: RCompanhoni/Study
        public static void Execute()
        {
            // create four-element IPayable array
            IPayable[] payableObjects = new IPayable[4];

            // populate array with objects that implement IPayable
            payableObjects[0] = new Invoice("01234", "seat", 2, 375.00M);
            payableObjects[1] = new Invoice("56789", "tire", 4, 79.95M);
            payableObjects[2] = new SalariedEmployee("John", "Smith", "111-11-1111", 800.00M);
            payableObjects[3] = new SalariedEmployee("Lisa", "Barnes", "888-88-8888", 1200.00M);

            Console.WriteLine("Invoices and Employees processed polymorphically:\n");

            // polymorphically process each element in array payableObjects
            foreach (var currentPayable in payableObjects)
            {
                Console.WriteLine("{0}\npayment due: {1:C}\n", currentPayable, currentPayable.GetPaymentAmount());
            }
        }
예제 #14
0
        static void Main(string[] args)
        {
            // creating the variables to hold instances of each object
            //employee 1
            string  firstName    = "Damian";
            string  lastName     = "Smith";
            int     phone        = 456544544;
            decimal salary       = 5000m;
            int     vacationDays = 10;

            FullTime newEmp = new FullTime(firstName, lastName, phone, salary, vacationDays);

            string  firstName2 = "Marian";
            string  lastName2  = "Welll";
            int     phone2     = 45642224;
            decimal rate       = 16.00m;

            PartTime newPT = new PartTime(firstName2, lastName2, phone2, rate);

            //What exactly does it means?
            //New list of objects
            List <Employee> lists = new List <Employee>();

            //adding newly created instances
            lists.Add(newEmp);
            lists.Add(newPT);

            foreach (Employee emp in lists)
            {
                Console.WriteLine(emp.ToString());
            }

            IPayable[] payableObjects = new IPayable[4];
            payableObjects[0] = new Invoice("222", "Socks", 10, 9.99M);
            payableObjects[1] = new Invoice("223", "Socksssss", 10, 9.99M);
            payableObjects[2] = new Invoice("224", "Sockszzzzzz", 10, 9.99M);
            payableObjects[3] = new Invoice("225", "Sockzzzzzs", 10, 9.99M);

            foreach (var currentPayable in payableObjects)
            {
                Console.WriteLine("Payment due: { 0:C}", currentPayable.GetPaymentAmount());
            }
        }
예제 #15
0
        static void Main(string[] args)
        {
            IPayable[] payableObjects = new IPayable[4];

            payableObjects[0] = new Invoice("01234", "seat", 2, 375.00M);
            payableObjects[1] = new Invoice("56789", "tire", 4, 79.95M);
            payableObjects[2] = new SalariedEmployee("John", "Smith",
                                                     "111-11-1111", 800.00M);
            payableObjects[3] = new SalariedEmployee("Lisa", "Barnes",
                                                     "888-88-8888", 1200.00M);

            Console.WriteLine("Invoices and Employees processed polymorphically:\n");

            foreach (var currentPayable in payableObjects)
            {
                Console.WriteLine("payment due \n{0}: {1:C}\n",
                                  currentPayable, currentPayable.GetPaymentAmount());
            }
        }
예제 #16
0
    public static void Main(string[] args)
    {
        // create six-element IPayable array
          IPayable[] payableObjects = new IPayable[6];

          // populate array with objects that implement IPayable
          payableObjects[0] = new Invoice("01234", "seat", 2, 375.00M);
          payableObjects[1] = new Invoice("56789", "tire", 4, 79.95M);
          payableObjects[2] = new SalariedEmployee("John", "Smith",
         "111-11-1111", 800.00M);

          /***** Modified code for assignment *****/

          // Add three new payable objects
          payableObjects[3] = new HourlyEmployee("Robert", "Millsaps", "222-22-2222", 12.5M, 20M);
          payableObjects[4] = new CommissionEmployee("Albert", "Einstein", "333-33-3333", 1000M, 0.314159M);
          payableObjects[5] = new BasePlusCommissionEmployee("Bill", "Gates", "444-44-4444", 1000M, 0.314159M, 1000000M);

          // Iterate over all payable objects
          foreach (IPayable currentPayable in payableObjects)
          {
         // Output string representation
         Console.WriteLine(currentPayable);

         // Increase base salary by 10% for Base Plus Commission Employee
         if (currentPayable is BasePlusCommissionEmployee)
         {
            BasePlusCommissionEmployee employee = (BasePlusCommissionEmployee)currentPayable;
            employee.BaseSalary *= 1.10M;
            // Output new base salary
            Console.WriteLine("new base salary with 10% increase is: {0:C}", employee.BaseSalary);
         }

         // Output payment for each payable object
         Console.WriteLine("payment due: {0:C}", currentPayable.GetPaymentAmount());
         Console.WriteLine();
          }

          // Freeze console window
          Console.ReadLine();

          /***** End Modified code for assignment *****/
    }
    public static void Main(string [] args)
    {
        // create four-element IPayable array
        IPayable[] payableObjects = new IPayable[6];

        // populate array with objects that implement IPayable
        payableObjects[0] = new Invoice("01234", "seat", 2, 375.00M);
        payableObjects[1] = new Invoice("56789", "tire", 4, 79.95M);
        payableObjects[2] = new SalariedEmployee("John", "Smith", "111-11-1111", 800.00M);
        payableObjects[3] = new HourlyEmployee("Bob", "Bobson", "222-22-2222", 16.75M, 40M );
        payableObjects[4] = new CommissionEmployee("Sally", "Seashore", "333-33-3333", 10000M, .06M );
        payableObjects[5] = new BasePlusCommissionEmployee("Bob", "Lewis", "444-44-4444", 5000M, .04M, 300M, .1M);

        Console.WriteLine("Invoices and Employees process polymorphically:\n");

        // generically process each element in array payableObjects
        foreach (var currentPayable in payableObjects)
        {
            // output currentPayable and its appropriate payment amount
            Console.WriteLine("{0}\npayment due: {1:C}\n", currentPayable, currentPayable.GetPaymentAmount());
        } // end foreach
    }
예제 #18
0
      public static void Main()
      {
         /* Create a 4-elt IPayable Array */
         IPayable[] payableObjects = new IPayable[4];

         /* Populate array with objects that implement IPayable */
         payableObjects[0] = new Invoice("01234", "seat", 2, 375.00M) ;
         payableObjects[1] = new Invoice("56789", "tire", 4, 79.95M);
         payableObjects[2] = new SalariedEmployee("Nordine", "Sebkhi", "111-11-1111", 800.00M);
         payableObjects[3] = new SalariedEmployee("Marwan", "Chawqi", "222-22-2222", 1200.00M);

         Console.WriteLine("Invoices and Employees processed polymorphically:\n");

         /* Generically process each element in array payableObjects */
         foreach (IPayable currentPayable in payableObjects)
         {
            Console.WriteLine("{0} \n{1}: {2:C}\n", currentPayable, "payment due", currentPayable.GetPaymentAmount());
         }//end foreach

         Console.ReadLine();

      }//end method Main
예제 #19
0
        /// <summary>
        /// Main method of Tester class used to start the application and test whether employee information
        /// </summary>
        /// <param name="args">command line arguments</param>
        public static void Main(string[] args)
        {
            IPayable[] payableObjects = new IPayable[8];
            payableObjects[0] = new SalariedEmployee("John", "Smith", "111-11-1111", 700M);
            payableObjects[1] = new SalariedEmployee("Antonio", "Smith", "555-55-5555", 800M);
            payableObjects[2] = new SalariedEmployee("Victor", "Smith", "444-44-4444", 600M);
            payableObjects[3] = new HourlyEmployee("Karen", "Price", "222-22-2222", 16.75M, 40M);
            payableObjects[4] = new HourlyEmployee("Ruben", "Zamora", "666-66-6666", 20.00M, 40M);
            payableObjects[5] = new CommissionEmployee("Sue", "Jones", "333-33-3333", 10000M, .06M);
            payableObjects[6] = new BasePlusCommissionEmployee("Bob", "Lewis", "777-77-7777", 5000M, .04M, 300M);
            payableObjects[7] = new BasePlusCommissionEmployee("Lee", "Duarte", "888-88-888", 5000M, .04M, 300M);

            for (int i = 0; i <= 7; i++)
            {
                Console.WriteLine(payableObjects[i].ToString());
                Console.WriteLine();
            }

            Menu(payableObjects);

            Console.ReadKey(true);
        } // end Main
예제 #20
0
        /// <summary>
        /// Method that contains the algorith that aids in sorting employee list with SSN using the Selection sort algorithm
        /// </summary>
        /// <param name="arr">list that contains Employee list</param>
        /// <param name="compSSN">delegate of Class</param>
        public static void SelectionSort(IPayable[] empl, CompareDelegateSSN compSSN)
        {
            int n = empl.Length;

            for (int i = 0; i < n - 1; i++)
            {
                int ind = i;
                for (int j = i + 1; j < n; j++)
                {
                    Employee emp1 = (Employee)empl[j];
                    Employee emp2 = (Employee)empl[ind];

                    if (compSSN(empl[j], empl[ind]) < 0)
                    {
                        ind = j;
                    }
                }

                IPayable temp = empl[ind];
                empl[ind] = empl[i];
                empl[i]   = temp;
            }
        }
예제 #21
0
        public static AjaxCallResult DenyItem(string recordId, string reason)
        {
            AuthenticationData authData = GetAuthenticationDataAndCulture();
            IPayable           payable  = PayableFromRecordId(recordId);
            FinancialAccount   budget   = payable.Budget;

            if (budget.OrganizationId != authData.CurrentOrganization.Identity ||
                (budget.OwnerPersonId != authData.CurrentUser.Identity &&
                 budget.OwnerPersonId != Person.NobodyId))
            {
                throw new UnauthorizedAccessException();
            }

            if (String.IsNullOrEmpty(reason.Trim()))
            {
                reason = Resources.Global.Global_NoReasonGiven;
            }

            payable.DenyApproval(authData.CurrentUser, reason);

            return(new AjaxCallResult {
                Success = true
            });
        }
예제 #22
0
        static public async Task <FormerPaymentOrderDTO> RefreshPaymentOrder(IPayable payable)
        {
            FormerPaymentOrderDTO paymentOrderData = payable.TryGetFormerPaymentOrderData();

            Assertion.AssertObject(paymentOrderData,
                                   $"Transaction {payable.UID} doesn't have a registered payment order.");

            if (paymentOrderData.IsCompleted)
            {
                return(paymentOrderData);
            }

            IPaymentOrderProvider provider = ExternalProviders.GetPaymentOrderProvider();

            paymentOrderData = await provider.RefreshPaymentOrder(paymentOrderData)
                               .ConfigureAwait(false);

            if (paymentOrderData.IsCompleted)
            {
                payable.SetFormerPaymentOrderData(paymentOrderData);
            }

            return(paymentOrderData);
        }
예제 #23
0
        public static void Main(string[] args)
        {
            IPayable[] payableObjects = new IPayable[8];
            payableObjects[0] = new SalariedEmployee("John", "Smith", "111-11-1111", 700M);
            payableObjects[1] = new SalariedEmployee("Antonio", "Smith", "555-55-5555", 800M);
            payableObjects[2] = new SalariedEmployee("Victor", "Smith", "444-44-4444", 600M);
            payableObjects[3] = new HourlyEmployee("Karen", "Price", "222-22-2222", 16.75M, 40M);
            payableObjects[4] = new HourlyEmployee("Ruben", "Zamora", "666-66-6666", 20.00M, 40M);
            payableObjects[5] = new CommissionEmployee("Sue", "Jones", "333-33-3333", 10000M, .06M);
            payableObjects[6] = new BasePlusCommissionEmployee("Bob", "Lewis", "777-77-7777", 5000M, .04M, 300M);
            payableObjects[7] = new BasePlusCommissionEmployee("Lee", "Duarte", "888-88-888", 5000M, .04M, 300M);

            /*
             * Console.WriteLine("Not sorted in any way yet \n");
             *
             * for (int j = 0; j < payableObjects.Length; j++) {
             * Console.WriteLine("Employee new {0} is a {1}", j,
             *    payableObjects[j]);
             * }
             */
            foreach (IPayable p in payableObjects)
            {
                Console.WriteLine(p + "\n");
            }
            string menuOption;
            bool   menuLogic = true;

            while (menuLogic)
            {
                Console.WriteLine("1: Sort last name in ascending order using IComparable");
                Console.WriteLine("2: Sort pay amount in descending order using IComparer");
                Console.WriteLine("3: Sort by social security number in ascending order using a selection sort and delegate");
                Console.WriteLine("4: Exit");
                menuOption = Console.ReadLine();
                switch (menuOption)
                {
                case "1":
                    Array.Sort(payableObjects);
                    foreach (IPayable p in payableObjects)
                    {
                        Console.WriteLine(p + "\n");
                    }
                    Console.WriteLine();
                    break;

                case "2":
                    Array.Sort(payableObjects, Employee.payAmountSorter());

                    foreach (IPayable p in payableObjects)
                    {
                        Console.WriteLine(p + "\n");
                    }
                    Console.WriteLine();
                    break;

                case "3":
                    PayrollSystemTest payRoll = new PayrollSystemTest();

                    ComparerSSN ssnSort = new ComparerSSN(Employee.SortAsSSN);
                    payRoll.SelectionSort(payableObjects, ssnSort);

                    break;

                case "4":
                    Console.WriteLine("Option 4 ");
                    menuLogic = false;
                    break;
                }
            }

            Console.ReadKey();
        } // end Main
예제 #24
0
        public static void Main(string[] args)
        {
            IPayable[] payableObjects = new IPayable[8];
             payableObjects[0] = new SalariedEmployee("John", "Smith", "111-11-1111", 700M);
             payableObjects[1] = new SalariedEmployee("Antonio", "Smith", "555-55-5555", 800M);
             payableObjects[2] = new SalariedEmployee("Victor", "Smith", "444-44-4444", 600M);
             payableObjects[3] = new HourlyEmployee("Karen", "Price", "222-22-2222", 16.75M, 40M);
             payableObjects[4] = new HourlyEmployee("Ruben", "Zamora", "666-66-6666", 20.00M, 40M);
             payableObjects[5] = new CommissionEmployee("Sue", "Jones", "333-33-3333", 10000M, .06M);
             payableObjects[6] = new BasePlusCommissionEmployee("Bob", "Lewis", "777-77-7777", 5000M, .04M, 300M);
             payableObjects[7] = new BasePlusCommissionEmployee("Lee", "Duarte", "888-88-888", 5000M, .04M, 300M);
             /*
             Console.WriteLine("Not sorted in any way yet \n");

             for (int j = 0; j < payableObjects.Length; j++) {
            Console.WriteLine("Employee new {0} is a {1}", j,
               payableObjects[j]);
             }
             */
             foreach (IPayable p in payableObjects) {
            Console.WriteLine(p + "\n");
             }
             string menuOption;
             bool menuLogic = true;

             while (menuLogic) {
            Console.WriteLine("1: Sort last name in ascending order using IComparable");
            Console.WriteLine("2: Sort pay amount in descending order using IComparer");
            Console.WriteLine("3: Sort by social security number in ascending order using a selection sort and delegate");
            Console.WriteLine("4: Exit");
            menuOption = Console.ReadLine();
            switch (menuOption) {
               case "1":
                  Array.Sort(payableObjects);
                  foreach (IPayable p in payableObjects) {
                     Console.WriteLine(p + "\n");
                  }
                  Console.WriteLine();
                  break;

               case "2":
                  Array.Sort(payableObjects, Employee.payAmountSorter());

                  foreach (IPayable p in payableObjects) {
                     Console.WriteLine(p + "\n");
                  }
                  Console.WriteLine();
                  break;

               case "3":
                  PayrollSystemTest payRoll = new PayrollSystemTest();

                  ComparerSSN ssnSort = new ComparerSSN(Employee.SortAsSSN);
                  payRoll.SelectionSort(payableObjects, ssnSort);

                  break;

               case "4":
                  Console.WriteLine("Option 4 ");
                  menuLogic = false;
                  break;
            }
             }

             Console.ReadKey();
        }
예제 #25
0
        //Selection sort logic for SSN's
        public void SelectionSort(IPayable[] items, ComparerSSN comparer)
        {
            int i, j, min;
             IPayable temp;
             for (i = 0; i < items.Length - 1; i++) {
            min = i;
            for (j = i + 1; j < items.Length; j++) {
               Employee emp1 = (Employee)items[j];
               Employee emp2 = (Employee)items[min];

               if (comparer(items[j],items[min]) < 0) {
                  min = j;
               }
            }
            temp = items[i];
            items[i] = items[min];
            items[min] = temp;

             }
             foreach (IPayable p in items) {
            Console.WriteLine(p + "\n");
             }
        }
예제 #26
0
파일: PayLog.cs 프로젝트: danni95/Core
 public void TracePostingStarted(IPayable payItem, DirectionType direction,
     Amount amount, GamingPostingContext postingContext)
 {
     if (postingContext != null)
     {
         Add(LogLevel.Info, payItem.GetType().Name,
             string.Format("{0} posting: ID={1}, PayItemID={2}, amount={3} started",
                 Util.Convertion.EnumValueToName<DirectionType>(direction), postingContext.PostingID,
                 payItem.ID, amount),
             postingContext.PreTransID, postingContext.PostingID);
     }
 }
예제 #27
0
파일: PayLog.cs 프로젝트: danni95/Core
 public void TracePostingCompleted(IPayable payItem, DirectionType direction,
     Amount amount, PostingContext postingContext)
 {
     if (postingContext != null)
     {
         Add(LogLevel.Info, payItem.GetType().Name,
             string.Format("{0} posting: ID={1}, PayItemID={2}, amount={3} finished, ref={4}",
                 Util.Convertion.EnumValueToName<DirectionType>(direction), postingContext.PostingID,
                 payItem.ID, amount, postingContext.ExternalReference),
             postingContext.PreTransID, postingContext.PostingID);
     }
 }
예제 #28
0
        public static void Main(string[] args)
        {
            int userInput = -1;                          //used to keep track of user input
            int counter   = 1;                           //used to print out the designated order number in the array.

            IPayable[] payableObjects = new IPayable[8]; //declare array of IPayable objects

            //fill in array with data
            payableObjects[0] = new SalariedEmployee("John", "Smith", "111-11-1111", 700M);
            payableObjects[1] = new SalariedEmployee("Antonio", "Smith", "555-55-5555", 800M);
            payableObjects[2] = new SalariedEmployee("Victor", "Smith", "444-44-4444", 600M);
            payableObjects[3] = new HourlyEmployee("Karen", "Price", "222-22-2222", 16.75M, 40M);
            payableObjects[4] = new HourlyEmployee("Ruben", "Zamora", "666-66-6666", 20.00M, 40M);
            payableObjects[5] = new CommissionEmployee("Sue", "Jones", "333-33-3333", 10000M,
                                                       .06M);
            payableObjects[6] = new BasePlusCommissionEmployee("Bob", "Lewis", "777-77-7777",
                                                               5000M, .04M, 300M);
            payableObjects[7] = new BasePlusCommissionEmployee("Lee", "Duarte", "888-88-888",
                                                               5000M, .04M, 300M);

            //Inform user that employees are going to be processed polymorphically
            Console.WriteLine("Employees processed polymorphically:\n");

            //Display each Employee's information
            foreach (Employee currentEmployee in payableObjects)
            {
                Console.WriteLine(currentEmployee); // invokes ToString
                // determine whether element is a BasePlusCommissionEmployee
                if (currentEmployee is BasePlusCommissionEmployee)
                {
                    // downcast Employee reference to
                    // BasePlusCommissionEmployee reference
                    BasePlusCommissionEmployee employee =
                        (BasePlusCommissionEmployee)currentEmployee;
                    employee.BaseSalary *= 1.10M;           //increase their BaseSalary.
                    Console.WriteLine("new base salary with 10% increase is: {0:C}",
                                      employee.BaseSalary); //inform user of increase.
                } // end if
                //Display pay amount
                Console.WriteLine("earned {0:C}\n", currentEmployee.GetPaymentAmount());
            } // end foreach

            while (userInput != 4)
            {
                try {
                    //display commands and prompt user to enter a valid command
                    Console.WriteLine("\nUser Menu: \n 1. Sort last name in ascending order "
                                      + "using IComparable.\n 2. Sort pay amount in descending order using "
                                      + "IComparer.\n 3. Sort by social security number in ascending order "
                                      + "using a\n    selection sort and delegate.\n 4. Exit program ");
                    Console.WriteLine("\nPlease enter the number of the command you wish to "
                                      + "execute:\n(1 <= command number =< 4): ");
                    //attempt to convert the user input into an integer
                    userInput = Convert.ToInt32(Console.ReadLine());
                    //if the conversion was correct but the number is not within the valid
                    //range of 1 <= input =< 4, then re-prompt the user to enter a valid value
                    if (userInput > 4 || userInput < 1)
                    {
                        Console.WriteLine("The number provided was not within the appropriate"
                                          + " range of permissible \nvalues. Please enter an integer value "
                                          + "between 1 and 4...");
                    }
                    else
                    {
                        switch (userInput)
                        {
                        case 1:
                            Console.WriteLine("You chose command #1: Sort by last name "
                                              + "in ascending order\nusing IComparable.\n\nSorted Result:");
                            //Demo IComparable by sorting array with "default" sort ordr.
                            Array.Sort(payableObjects);

                            //display the names of the employees
                            counter = 1;
                            foreach (Employee emp in payableObjects)
                            {
                                Console.WriteLine("   {0}. {1, -10} {2, -10}", counter++,
                                                  emp.FirstName, emp.LastName);
                            }
                            break;

                        case 2:
                            Console.WriteLine("You chose command #2: Sort by pay amount "
                                              + "in descending order\nusing IComparer.\n\nSorted Result:");
                            //sort data using IComparer
                            Array.Sort(payableObjects, Employee.SortPayAmountDescending());

                            //display the names of the employees and payment amont
                            counter = 1;
                            foreach (Employee emp in payableObjects)
                            {
                                Console.WriteLine("   {0}. {1, -10} {2, -10} -     "
                                                  + "Payment Amount: {3:C}", counter++, emp.FirstName,
                                                  emp.LastName, emp.GetPaymentAmount());
                            }
                            break;

                        case 3:
                            Console.WriteLine("You chose command #3: Sort by social "
                                              + "security number in\nascending order using a selection "
                                              + "sort and delegate\n\nSorted Result:");
                            SelectionSort(payableObjects, Employee.SSNIsGreaterThan);

                            //display the names of the employees and payment amont
                            counter = 1;
                            foreach (Employee emp in payableObjects)
                            {
                                Console.WriteLine("   {0}. {1, -10} {2, -10} -    "
                                                  + "SSN: {3}", counter++, emp.FirstName, emp.LastName,
                                                  emp.SocialSecurityNumber);
                            }
                            break;

                        case 4:
                            Console.WriteLine("You chose command #4:\n"
                                              + "You will now exit the program...");
                            break;

                        default:
                            Console.WriteLine("You have reached the default case...");
                            break;
                        } //end switch
                    }     //end else
                }         //end try
                catch (FormatException) {
                    //inform the user that they did not enter an integer value and re-prompt
                    //the command value input.
                    Console.WriteLine("Invalid user input. Please enter an INTEGER value "
                                      + "between 1 and 4...");
                } //end catch
            }     //end while loop
            Console.WriteLine("Your session has been terminated. Thank you for using this "
                              + "program.\nClick any key to close this window..");
            Console.ReadKey();
        } // close Main(...)
 //Function pointer to Sort function
 public static int SSNAscending(IPayable e1, IPayable e2)
 {
     return(((Employee)e1).SocialSecurityNumber.CompareTo(
                ((Employee)e2).SocialSecurityNumber));
 }//end function
예제 #30
0
 public PaymentMethod(IPayable method)
 {
     _payableBehavior = method ?? new NoPayNow();
 }
    public static void Main(string[] args)
    {
        // create derived class objects
        SalariedEmployee salariedEmployee =
           new SalariedEmployee("John", "Smith", "111-11-1111", 800.00M);
        HourlyEmployee hourlyEmployee =
           new HourlyEmployee("Karen", "Price",
           "222-22-2222", 16.75M, 40.0M);
        CommissionEmployee commissionEmployee =
           new CommissionEmployee("Sue", "Jones",
           "333-33-3333", 10000.00M, .06M);
        BasePlusCommissionEmployee basePlusCommissionEmployee =
           new BasePlusCommissionEmployee("Bob", "Lewis",
           "444-44-4444", 5000.00M, .04M, 300.00M);

        Console.WriteLine("Employees processed individually:\n");

        Console.WriteLine("{0}\nearned: {1:C}\n",
           salariedEmployee, salariedEmployee.Earnings());
        Console.WriteLine("{0}\nearned: {1:C}\n",
           hourlyEmployee, hourlyEmployee.Earnings());
        Console.WriteLine("{0}\nearned: {1:C}\n",
           commissionEmployee, commissionEmployee.Earnings());
        Console.WriteLine("{0}\nearned: {1:C}\n",
           basePlusCommissionEmployee,
           basePlusCommissionEmployee.Earnings());

        // create four-element Employee array
        Employee[] employees = new Employee[4];

        // initialize array with Employees of derived types
        employees[0] = salariedEmployee;
        employees[1] = hourlyEmployee;
        employees[2] = commissionEmployee;
        employees[3] = basePlusCommissionEmployee;

        Console.WriteLine("Employees processed polymorphically:\n");

        // generically process each element in array employees
        processEmployees(employees);

        // get type name of each object in employees array
        for (int j = 0; j < employees.Length; j++)
            Console.WriteLine("Employee {0} is a {1}", j,
               employees[j].GetType());

        Console.WriteLine("\nEMPLOYEES PROCESSED BY IPAYABLE\n");

        //Create IPayable array
        IPayable[] payableObjects = new IPayable[8];
        payableObjects[0] = new SalariedEmployee(
                "John", "Smith", "111-11-1111", 700M);
        payableObjects[1] = new SalariedEmployee(
                "Antonio", "Smith", "555-55-5555", 800M);
        payableObjects[2] = new SalariedEmployee(
                "Victor", "Smith", "444-44-4444", 600M);
        payableObjects[3] = new HourlyEmployee(
                "Karen", "Price", "222-22-2222", 16.75M, 40M);
        payableObjects[4] = new HourlyEmployee(
                "Ruben", "Zamora", "666-66-6666", 20.00M, 40M);
        payableObjects[5] = new CommissionEmployee(
                "Sue", "Jones", "333-33-3333", 10000M, .06M);
        payableObjects[6] = new BasePlusCommissionEmployee(
                "Bob", "Lewis", "777-77-7777", 5000M, .04M, 300M);
        payableObjects[7] = new BasePlusCommissionEmployee(
                "Lee", "Duarte", "888-88-888", 5000M, .04M, 300M);

        // generically process each element in array employees
        processEmployees(payableObjects);

        //bubble sort and pointer
        Console.WriteLine("\nIPAYABLES SORTED BY SSN:\n");
        BubbleSort(payableObjects, SSNAscending);
        foreach (Employee currentEmployee in payableObjects)
        {
            Console.WriteLine(currentEmployee); // invokes ToString
            Console.WriteLine(
               "earned {0:C}\n", currentEmployee.Earnings());
        } // end foreach

        //IComparer
        Console.WriteLine("\nIPAYABLES SORTED BY LAST NAME ASCENDING\n");
        ArrayList comparerSample = new ArrayList();
        //populate ArrayList for IComparer and IComprable
        foreach (IPayable currentPayable in payableObjects)
        {
            comparerSample.Add(currentPayable);
        }//end foreach
        IComparer lastAscend = new SortLastNAscending();
        comparerSample.Sort(lastAscend);
        foreach (Employee currentEmployee in comparerSample)
        {
            Console.WriteLine(currentEmployee); // invokes ToString
            Console.WriteLine(
               "earned {0:C}\n", currentEmployee.Earnings());
        } // end foreach

        //IComparable implementation
        Console.WriteLine("\nIPAYABLES SORTED BY SALARY DESCEDNING\n");
        comparerSample.Sort();
        foreach (Employee currentEmployee in comparerSample)
        {
            Console.WriteLine(currentEmployee); // invokes ToString
            Console.WriteLine(
               "earned {0:C}\n", currentEmployee.Earnings());
        } // end foreach
    }
    // generically process each element in array employees
    public static void processEmployees(IPayable[] employees)
    {
        foreach (IPayable currentEmployee in employees)
        {
            Console.WriteLine(currentEmployee); // invokes ToString
            // determine whether element is a BasePlusCommissionEmployee
            if (currentEmployee is BasePlusCommissionEmployee)
            {
                // downcast Employee reference to
                // BasePlusCommissionEmployee reference
                BasePlusCommissionEmployee employee =
                   (BasePlusCommissionEmployee)currentEmployee;

                employee.BaseSalary *= 1.10M;
                Console.WriteLine(
                   "new base salary with 10% increase is: {0:C}",
                   employee.BaseSalary);
            } // end if
            Console.WriteLine(
               "earned {0:C}\n", currentEmployee.GetPaymentAmount());
        } // end foreach
    }
 //Function pointer to Sort function
 public static int SSNAscending(IPayable e1, IPayable e2)
 {
     return ((Employee)e1).SocialSecurityNumber.CompareTo(
             ((Employee)e2).SocialSecurityNumber);
 }
예제 #34
0
    public static void Main(string[] args)
    {
        SalariedEmployee salariedEmployee =
            new SalariedEmployee("John", "Smith", "111-11-1111", 800.00M);
        HourlyEmployee hourlyEmployee =
            new HourlyEmployee("Karen", "Price",
                               "222-22-2222", 16.75M, 40.0M);
        CommissionEmployee commissionEmployee =
            new CommissionEmployee("Sue", "Jones",
                                   "333-33-3333", 10000.00M, .06M);
        BasePlusCommissionEmployee basePlusCommissionEmployee =
            new BasePlusCommissionEmployee("Bob", "Lewis",
                                           "444-44-4444", 5000.00M, .04M, 300.00M);

        Console.WriteLine("Employees processed individually:\n");

        Console.WriteLine("{0}\nearned: {1:C}\n",
                          salariedEmployee, salariedEmployee.GetPaymentAmount());
        Console.WriteLine("{0}\nearned: {1:C}\n",
                          hourlyEmployee, hourlyEmployee.GetPaymentAmount());
        Console.WriteLine("{0}\nearned: {1:C}\n",
                          commissionEmployee, commissionEmployee.GetPaymentAmount());
        Console.WriteLine("{0}\nearned: {1:C}\n",
                          basePlusCommissionEmployee,
                          basePlusCommissionEmployee.GetPaymentAmount());

        // create four-element Employee array
        Employee[] employees = new Employee[4];

        // initialize array with Employees of derived types
        employees[0] = salariedEmployee;
        employees[1] = hourlyEmployee;
        employees[2] = commissionEmployee;
        employees[3] = basePlusCommissionEmployee;

        Console.WriteLine("Employees processed polymorphically:\n");

        // generically process each element in array employees
        foreach (Employee currentEmployee in employees)
        {
            Console.WriteLine(currentEmployee); // invokes ToString

            // determine whether element is a BasePlusCommissionEmployee
            if (currentEmployee is BasePlusCommissionEmployee)
            {
                // downcast Employee reference to
                // BasePlusCommissionEmployee reference
                BasePlusCommissionEmployee employee =
                    (BasePlusCommissionEmployee)currentEmployee;

                employee.BaseSalary *= 1.10M;
                Console.WriteLine(
                    "new base salary with 10% increase is: {0:C}",
                    employee.BaseSalary);
            } // end if

            Console.WriteLine(
                "earned {0:C}\n", currentEmployee.GetPaymentAmount());
        } // end foreach

        //get type name of each object in employees array
        for (int j = 0; j < employees.Length; j++)
        {
            Console.WriteLine("Employee {0} is a {1}", j,
                              employees[j].GetType());
        }

        Console.WriteLine("-------------------------------------------------");

        // create derived class objects
        IPayable[] payableObjects = new IPayable[8];
        payableObjects[0] = new SalariedEmployee("John", "Smith", "111-11-1111", 700M);
        payableObjects[1] = new SalariedEmployee("Antonio", "Smith", "555-55-5555", 800M);
        payableObjects[2] = new SalariedEmployee("Victor", "Smith", "444-44-4444", 600M);
        payableObjects[3] = new HourlyEmployee("Karen", "Price", "222-22-2222", 16.75M, 40M);
        payableObjects[4] = new HourlyEmployee("Ruben", "Zamora", "666-66-6666", 20.00M, 40M);
        payableObjects[5] = new CommissionEmployee("Sue", "Jones", "333-33-3333", 10000M, .06M);
        payableObjects[6] = new BasePlusCommissionEmployee("Bob", "Lewis", "777-77-7777", 5000M, .04M, 300M);
        payableObjects[7] = new BasePlusCommissionEmployee("Lee", "Duarte", "888-88-888", 5000M, .04M, 300M);

        SortSSNDelegate sortDelegate = new SortSSNDelegate(Employee.CompareSSN);  //delegate points to method.
        bool            key          = true;

        while (key)
        {
            Console.WriteLine(Environment.NewLine + "1.Sort last name in ascending order using IComparable");
            Console.WriteLine("2.Sort pay amount in descending order using IComparer");
            Console.WriteLine("3.Sort by social security number in asc order using selection sort & DELEGATE");
            Console.WriteLine("Press 4 anytime to Exit." + Environment.NewLine);
            int value = Int32.Parse(Console.ReadLine());
            switch (value)
            {
            case 1: Console.WriteLine("<Sorting Last Name using IComparABLE>");
                Array.Sort(payableObjects);
                PrintArrayElements(payableObjects);
                break;

            case 2: Console.WriteLine("\n\n<Sort payment amount in desc using ICompaRER>");
                Array.Sort(payableObjects, new PaymentAmountDesc());
                PrintArrayElements(payableObjects);
                break;

            case 3: Console.WriteLine("\n\n<Sort based on SSN in Ascending order>");
                SelectionSortMethod(payableObjects as object, sortDelegate, true);       // Call method. 'true' for ascending.
                PrintArrayElements(payableObjects);
                break;

            default: key = false;
                break;
            }
        } // end Main
    }
예제 #35
0
 // for dynamic set pay behavior
 public void SetPayBehavior(IPayable newPayBehavior)
 {
     _payableBehavior = newPayBehavior;
 }
예제 #36
0
 public void AddPayable(IPayable payable)
 {
     throw new NotImplementedException();
 }
예제 #37
0
 public void AddClient(IPayable client)
 {
     clients.Add(client);
 }
    public static void Main(string[] args)
    {
        // create derived class objects
        SalariedEmployee salariedEmployee =
            new SalariedEmployee("John", "Smith", "111-11-1111", 800.00M);
        HourlyEmployee hourlyEmployee =
            new HourlyEmployee("Karen", "Price",
                               "222-22-2222", 16.75M, 40.0M);
        CommissionEmployee commissionEmployee =
            new CommissionEmployee("Sue", "Jones",
                                   "333-33-3333", 10000.00M, .06M);
        BasePlusCommissionEmployee basePlusCommissionEmployee =
            new BasePlusCommissionEmployee("Bob", "Lewis",
                                           "444-44-4444", 5000.00M, .04M, 300.00M);

        Console.WriteLine("Employees processed individually:\n");

        Console.WriteLine("{0}\nearned: {1:C}\n",
                          salariedEmployee, salariedEmployee.Earnings());
        Console.WriteLine("{0}\nearned: {1:C}\n",
                          hourlyEmployee, hourlyEmployee.Earnings());
        Console.WriteLine("{0}\nearned: {1:C}\n",
                          commissionEmployee, commissionEmployee.Earnings());
        Console.WriteLine("{0}\nearned: {1:C}\n",
                          basePlusCommissionEmployee,
                          basePlusCommissionEmployee.Earnings());

        // create four-element Employee array
        Employee[] employees = new Employee[4];

        // initialize array with Employees of derived types
        employees[0] = salariedEmployee;
        employees[1] = hourlyEmployee;
        employees[2] = commissionEmployee;
        employees[3] = basePlusCommissionEmployee;

        Console.WriteLine("Employees processed polymorphically:\n");

        // generically process each element in array employees
        processEmployees(employees);

        // get type name of each object in employees array
        for (int j = 0; j < employees.Length; j++)
        {
            Console.WriteLine("Employee {0} is a {1}", j,
                              employees[j].GetType());
        }

        Console.WriteLine("\nEMPLOYEES PROCESSED BY IPAYABLE\n");

        //Create IPayable array
        IPayable[] payableObjects = new IPayable[8];
        payableObjects[0] = new SalariedEmployee(
            "John", "Smith", "111-11-1111", 700M);
        payableObjects[1] = new SalariedEmployee(
            "Antonio", "Smith", "555-55-5555", 800M);
        payableObjects[2] = new SalariedEmployee(
            "Victor", "Smith", "444-44-4444", 600M);
        payableObjects[3] = new HourlyEmployee(
            "Karen", "Price", "222-22-2222", 16.75M, 40M);
        payableObjects[4] = new HourlyEmployee(
            "Ruben", "Zamora", "666-66-6666", 20.00M, 40M);
        payableObjects[5] = new CommissionEmployee(
            "Sue", "Jones", "333-33-3333", 10000M, .06M);
        payableObjects[6] = new BasePlusCommissionEmployee(
            "Bob", "Lewis", "777-77-7777", 5000M, .04M, 300M);
        payableObjects[7] = new BasePlusCommissionEmployee(
            "Lee", "Duarte", "888-88-888", 5000M, .04M, 300M);

        // generically process each element in array employees
        processEmployees(payableObjects);

        //bubble sort and pointer
        Console.WriteLine("\nIPAYABLES SORTED BY SSN:\n");
        BubbleSort(payableObjects, SSNAscending);
        foreach (Employee currentEmployee in payableObjects)
        {
            Console.WriteLine(currentEmployee); // invokes ToString
            Console.WriteLine(
                "earned {0:C}\n", currentEmployee.Earnings());
        } // end foreach

        //IComparer
        Console.WriteLine("\nIPAYABLES SORTED BY LAST NAME ASCENDING\n");
        ArrayList comparerSample = new ArrayList();

        //populate ArrayList for IComparer and IComprable
        foreach (IPayable currentPayable in payableObjects)
        {
            comparerSample.Add(currentPayable);
        }//end foreach
        IComparer lastAscend = new SortLastNAscending();

        comparerSample.Sort(lastAscend);
        foreach (Employee currentEmployee in comparerSample)
        {
            Console.WriteLine(currentEmployee); // invokes ToString
            Console.WriteLine(
                "earned {0:C}\n", currentEmployee.Earnings());
        } // end foreach

        //IComparable implementation
        Console.WriteLine("\nIPAYABLES SORTED BY SALARY DESCEDNING\n");
        comparerSample.Sort();
        foreach (Employee currentEmployee in comparerSample)
        {
            Console.WriteLine(currentEmployee); // invokes ToString
            Console.WriteLine(
                "earned {0:C}\n", currentEmployee.Earnings());
        } // end foreach
    }     // end Main
예제 #39
0
        public void Pay(IPayable payable, decimal pay)
        {
            payable.Money += pay;

            Console.WriteLine(payable.Name + " paid " + pay);
        }
예제 #40
0
 public void AcceptPayment(IMoney payment, IPayable payer)
 {
     //throw new NotImplementedException();
 }
예제 #41
0
        public static AjaxCallResult AttestCorrectedItem(string recordId, string amountString)
        {
            AuthenticationData authData = GetAuthenticationDataAndCulture();
            Int64 amountCents           = 0;

            try
            {
                amountCents = Formatting.ParseDoubleStringAsCents(amountString);
            }
            catch (Exception)
            {
                return(new AjaxCallResult
                {
                    Success = false,
                    DisplayMessage = String.Format(Resources.Global.Error_CurrencyParsing, 1000.00)
                });
            }

            if (amountCents < 0)
            {
                return(new AjaxCallResult
                {
                    Success = false,
                    DisplayMessage = Resources.Pages.Financial.AttestCosts_CannotAttestNegative
                });
            }

            if (amountCents == 0)
            {
                return(new AjaxCallResult
                {
                    Success = false,
                    DisplayMessage = Resources.Pages.Financial.AttestCosts_CannotAttestZero
                });
            }

            IPayable         payable = PayableFromRecordId(recordId);
            FinancialAccount budget  = payable.Budget;

            if (budget.OrganizationId != authData.CurrentOrganization.Identity ||
                budget.OwnerPersonId != authData.CurrentUser.Identity)
            {
                throw new UnauthorizedAccessException();
            }

            Int64 centsRemaining = budget.GetBudgetCentsRemaining();

            if (centsRemaining < amountCents)
            {
                // TODO: Handle the special case where the IPayable is not on current year, so against another (last) year's budget

                string notEnoughFunds;

                if (centsRemaining > 0)
                {
                    notEnoughFunds = String.Format(Resources.Pages.Financial.AttestCosts_OutOfBudgetPrecise,
                                                   authData.CurrentOrganization.Currency.DisplayCode, centsRemaining / 100.0, DateTime.UtcNow.Year);
                }
                else
                {
                    notEnoughFunds = String.Format(Resources.Pages.Financial.AttestCosts_BudgetIsEmpty,
                                                   DateTime.UtcNow.Year);
                }

                return(new AjaxCallResult
                {
                    Success = false,
                    DisplayMessage = notEnoughFunds
                });
            }

            payable.SetAmountCents(amountCents, authData.CurrentUser);
            payable.Approve(authData.CurrentUser);

            return(new AjaxCallResult
            {
                Success = true
            });
        }
예제 #42
0
        public static void Main(string[] args)
        {
            bool programEnd = false;

            // create derived class objects
            IPayable[] payableObjects = new IPayable[8];
            payableObjects[0] = new SalariedEmployee("John", "Smith", "111-11-1111", 700M);
            payableObjects[1] = new SalariedEmployee("Antonio", "Smith", "555-55-5555", 800M);
            payableObjects[2] = new SalariedEmployee("Victor", "Smith", "444-44-4444", 600M);
            payableObjects[3] = new HourlyEmployee("Karen", "Price", "222-22-2222", 16.75M, 40M);
            payableObjects[4] = new HourlyEmployee("Ruben", "Zamora", "666-66-6666", 20.00M, 40M);
            payableObjects[5] = new CommissionEmployee("Sue", "Jones", "333-33-3333", 10000M, .06M);
            payableObjects[6] = new BasePlusCommissionEmployee("Bob", "Lewis", "777-77-7777", 5000M, .04M, 300M);
            payableObjects[7] = new BasePlusCommissionEmployee("Lee", "Duarte", "888-88-888", 5000M, .04M, 300M);

            while (!programEnd)
            {
                Console.WriteLine("1. Sort by last name");
                Console.WriteLine("2. Sort by pay");
                Console.WriteLine("3. Sort by social security number");
                Console.WriteLine("4. Exit the program");

                Console.Write("Please select an option from the Employee menu: ");
                int input = Convert.ToInt16(Console.ReadLine());
                Console.WriteLine();

                if (input == 1)
                {
                    Array.Sort(payableObjects);
                    Console.WriteLine("\nEmployees sorted by last name: ");
                    displayResult(payableObjects);
                }

                else if (input == 2)
                {
                    Array.Sort(payableObjects, Employee.sortByPay.sortPayAscending());
                    Console.WriteLine("\nEmployees sorted by pay: ");
                    displayResult(payableObjects);
                }

                else if (input == 3)
                {
                    selectionSort(payableObjects, SSN_Comparision);
                    Console.WriteLine("\nEmployees sorted by SSN: ");
                    displayResult(payableObjects);
                }

                else if (input == 4)
                {
                    Console.WriteLine("Thank you for using the program! Exiting.....");
                    programEnd = true;
                }

                else
                {
                    Console.WriteLine("Invalid input. Please enter a valid option from the menu.");
                }
            }

            Console.Read();
        } // end Main