Beispiel #1
0
        private static SqlDataReader EmployeeRelatedReporting(TelephoneBillSystemChoices userChoice)
        {
            SqlDataReader queryResult = null;

            switch (userChoice)
            {
            case TelephoneBillSystemChoices.DisplayAllEmployees:
                queryResult = UserInterfaceToDbAccessFunctions.DisplayAllEmployees();
                break;

            case TelephoneBillSystemChoices.DisplayEmployeeByID:
                queryResult = UserInterfaceToDbAccessFunctions.DisplayEmployeeByID();
                break;

            case TelephoneBillSystemChoices.DisplayCustomersOfEmployee:
                queryResult = UserInterfaceToDbAccessFunctions.DisplayEmployeesCustomers();
                break;

            case TelephoneBillSystemChoices.DisplayTransactionSummaryforEmployees:
                queryResult = UserInterfaceToDbAccessFunctions.DisplayTransactionSummaryForEmployees();
                break;

            case TelephoneBillSystemChoices.CalculateEmployeeBonus:
                queryResult = UserInterfaceToDbAccessFunctions.DisplayBonusForEmployee();
                break;
            }
            return(queryResult);
        }
        public static void UserDataModificationFunction(TelephoneBillSystemChoices userChoice)
        {
            try
            {
                switch (userChoice)
                {
                case TelephoneBillSystemChoices.AddCustomer:
                    UserInterfaceToDbAccessFunctions.AddCustomer();
                    break;

                case TelephoneBillSystemChoices.UpdateCustomer:
                    UserInterfaceToDbAccessFunctions.UpdateCustomer();
                    break;

                case TelephoneBillSystemChoices.GenerateCustomerBill:
                case TelephoneBillSystemChoices.RecordPayment:
                    UserInterfaceToDbAccessFunctions.RecordBillPayment();
                    break;
                }
            }
            catch (SqlException ex)
            {
                Console.WriteLine("Exception Occured" + ex.Message);
            }
        }
        /// <summary>
        /// This method calls the appropriate methods based on the UsersChoice of activity
        /// </summary>
        /// <param name="userChoice">This is the UsersChoice which has been inputted by User.</param>
        public static void ProcessUsersChoice(TelephoneBillSystemChoices userChoice)
        {
            switch (userChoice)
            {
            case TelephoneBillSystemChoices.DisplayAllCustomers:
            case TelephoneBillSystemChoices.DisplayCustomerByID:
            case TelephoneBillSystemChoices.DisplayCustomerBillingHistory:
            case TelephoneBillSystemChoices.DisplayAllEmployees:
            case TelephoneBillSystemChoices.DisplayEmployeeByID:
            case TelephoneBillSystemChoices.CalculateEmployeeBonus:
            case TelephoneBillSystemChoices.DisplayCustomersOfEmployee:
            case TelephoneBillSystemChoices.DisplayTransactionSummaryforEmployees:
                UserInterfaceReportingFunctions.UserReportingFunction(userChoice);
                break;

            case TelephoneBillSystemChoices.AddCustomer:
            case TelephoneBillSystemChoices.UpdateCustomer:
            case TelephoneBillSystemChoices.GenerateCustomerBill:
            case TelephoneBillSystemChoices.RecordPayment:
                UserInterfaceModificationFunctions.UserDataModificationFunction(userChoice);
                break;

            case TelephoneBillSystemChoices.EndApplication:
                Console.WriteLine("\nThanks for Using Telephone Billing System Application!!\n");
                return;
            }
        }
        public static void UserReportingFunction(TelephoneBillSystemChoices userChoice)
        {
            try
            {
                SqlDataReader queryResult = null;
                switch (userChoice)
                {
                    case TelephoneBillSystemChoices.DisplayAllCustomers:
                    case TelephoneBillSystemChoices.DisplayCustomerByID:
                    case TelephoneBillSystemChoices.DisplayCustomerBillingHistory:
                        queryResult = CustomerRelatedReporting(userChoice);
                        break;
                    case TelephoneBillSystemChoices.DisplayAllEmployees:
                    case TelephoneBillSystemChoices.DisplayEmployeeByID:
                    case TelephoneBillSystemChoices.DisplayCustomersOfEmployee:
                    case TelephoneBillSystemChoices.DisplayTransactionSummaryforEmployees:
                    case TelephoneBillSystemChoices.CalculateEmployeeBonus:
                        queryResult = EmployeeRelatedReporting(userChoice);
                        break;
                }

                UserInterfaceDisplayFunctions.DisplayQueryResult(queryResult);
            }
            catch (SqlException ex)
            {
                Console.WriteLine("Exception Occured" + ex.Message);
            }
        }
        /// <summary>
        /// This method calls the appropriate methods based on the UsersChoice of activity
        /// </summary>
        /// <param name="userChoice">This is the UsersChoice which has been inputted by User.</param>
        public static void ProcessUsersChoice(TelephoneBillSystemChoices userChoice)
        {
            switch (userChoice)
            {
                case TelephoneBillSystemChoices.DisplayAllCustomers:
                case TelephoneBillSystemChoices.DisplayCustomerByID:
                case TelephoneBillSystemChoices.DisplayCustomerBillingHistory:
                case TelephoneBillSystemChoices.DisplayAllEmployees:
                case TelephoneBillSystemChoices.DisplayEmployeeByID:
                case TelephoneBillSystemChoices.CalculateEmployeeBonus:
                case TelephoneBillSystemChoices.DisplayCustomersOfEmployee:
                case TelephoneBillSystemChoices.DisplayTransactionSummaryforEmployees:
                    UserInterfaceReportingFunctions.UserReportingFunction(userChoice);
                    break;
                case TelephoneBillSystemChoices.AddCustomer:
                case TelephoneBillSystemChoices.UpdateCustomer:
                case TelephoneBillSystemChoices.GenerateCustomerBill:
                case TelephoneBillSystemChoices.RecordPayment:
                    UserInterfaceModificationFunctions.UserDataModificationFunction(userChoice);
                    break;
                case TelephoneBillSystemChoices.EndApplication:
                    Console.WriteLine("\nThanks for Using Telephone Billing System Application!!\n");
                    return;

            }
        }
        /// <summary>
        /// This method prompts for User-Choices and returns a false if user decides to end application
        /// </summary>
        /// <returns></returns>
        private static bool PromptForUserOptions()
        {
            var runApplicationFlag = true;

            try
            {
                TelephoneBillSystemChoices userChoice = UserInteractionFunctions.GetUserActionChoice();
                UserInteractionFunctions.ProcessUsersChoice(userChoice);

                if (userChoice == TelephoneBillSystemChoices.EndApplication)
                {
                    runApplicationFlag = false;
                }
            }

            catch (FormatException ex)
            {
                Console.WriteLine("Bad Input !!!" + ex.Message);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error!!" + ex.Message + ex.GetType());
            }

            return(runApplicationFlag);
        }
Beispiel #7
0
        public static void UserReportingFunction(TelephoneBillSystemChoices userChoice)
        {
            try
            {
                SqlDataReader queryResult = null;
                switch (userChoice)
                {
                case TelephoneBillSystemChoices.DisplayAllCustomers:
                case TelephoneBillSystemChoices.DisplayCustomerByID:
                case TelephoneBillSystemChoices.DisplayCustomerBillingHistory:
                    queryResult = CustomerRelatedReporting(userChoice);
                    break;

                case TelephoneBillSystemChoices.DisplayAllEmployees:
                case TelephoneBillSystemChoices.DisplayEmployeeByID:
                case TelephoneBillSystemChoices.DisplayCustomersOfEmployee:
                case TelephoneBillSystemChoices.DisplayTransactionSummaryforEmployees:
                case TelephoneBillSystemChoices.CalculateEmployeeBonus:
                    queryResult = EmployeeRelatedReporting(userChoice);
                    break;
                }

                UserInterfaceDisplayFunctions.DisplayQueryResult(queryResult);
            }
            catch (SqlException ex)
            {
                Console.WriteLine("Exception Occured" + ex.Message);
            }
        }
        /// <summary>
        /// This method prompts the user options and takes a UserFunctionChoice input from user
        /// </summary>
        /// <returns>Returns the Users Choice of Action </returns>
        private static TelephoneBillSystemChoices PromptUsersChoice()
        {
            Console.Write(ConfigurationManager.AppSettings.Get("UserDisplayOptions"));

            TelephoneBillSystemChoices userChoice = UserInputGathering.GetUsersChoice();

            return(userChoice);
        }
        public static TelephoneBillSystemChoices GetUserActionChoice()
        {
            TelephoneBillSystemChoices usersFunctionChoice = PromptUsersChoice();

            if (!ValidateUsersChoice(usersFunctionChoice))
            {
                throw new InvalidOperationException("\nBad Option Choice!! Please Try Again with a Valid Choice\n");
            }

            return(usersFunctionChoice);
        }
Beispiel #10
0
        /// <summary>
        /// This method checks if the Input User Choice is Valid
        /// </summary>
        /// <param name="userChoice">The UsersChoice inputted by the user</param>
        /// <returns>Returns a boolean flag to indicate if input UserChoice is valid</returns>
        public static bool IsValidUserChoice(TelephoneBillSystemChoices userChoice)
        {
            var isValidUserChoiceFlag = false;

            if (Enum.IsDefined(typeof(TelephoneBillSystemChoices), userChoice))
            {
                isValidUserChoiceFlag = true;
            }

            return(isValidUserChoiceFlag);
        }
 private static SqlDataReader CustomerRelatedReporting(TelephoneBillSystemChoices userChoice)
 {
     SqlDataReader queryResult = null;
     switch (userChoice)
     {
         case TelephoneBillSystemChoices.DisplayAllCustomers:
             queryResult = UserInterfaceToDbAccessFunctions.DisplayAllCustomers();
             break;
         case TelephoneBillSystemChoices.DisplayCustomerByID:
             queryResult = UserInterfaceToDbAccessFunctions.DisplayCustomerByID();
             break;
         case TelephoneBillSystemChoices.DisplayCustomerBillingHistory:
             queryResult = UserInterfaceToDbAccessFunctions.DisplayCustomerBillHistory();
             break;
     }
     return queryResult;
 }
Beispiel #12
0
        private static SqlDataReader CustomerRelatedReporting(TelephoneBillSystemChoices userChoice)
        {
            SqlDataReader queryResult = null;

            switch (userChoice)
            {
            case TelephoneBillSystemChoices.DisplayAllCustomers:
                queryResult = UserInterfaceToDbAccessFunctions.DisplayAllCustomers();
                break;

            case TelephoneBillSystemChoices.DisplayCustomerByID:
                queryResult = UserInterfaceToDbAccessFunctions.DisplayCustomerByID();
                break;

            case TelephoneBillSystemChoices.DisplayCustomerBillingHistory:
                queryResult = UserInterfaceToDbAccessFunctions.DisplayCustomerBillHistory();
                break;
            }
            return(queryResult);
        }
 private static SqlDataReader EmployeeRelatedReporting(TelephoneBillSystemChoices userChoice)
 {
     SqlDataReader queryResult = null;
     switch (userChoice)
     {
         case TelephoneBillSystemChoices.DisplayAllEmployees:
             queryResult = UserInterfaceToDbAccessFunctions.DisplayAllEmployees();
             break;
         case TelephoneBillSystemChoices.DisplayEmployeeByID:
             queryResult = UserInterfaceToDbAccessFunctions.DisplayEmployeeByID();
             break;
         case TelephoneBillSystemChoices.DisplayCustomersOfEmployee:
             queryResult = UserInterfaceToDbAccessFunctions.DisplayEmployeesCustomers();
             break;
         case TelephoneBillSystemChoices.DisplayTransactionSummaryforEmployees:
             queryResult = UserInterfaceToDbAccessFunctions.DisplayTransactionSummaryForEmployees();
             break;
         case TelephoneBillSystemChoices.CalculateEmployeeBonus:
             queryResult = UserInterfaceToDbAccessFunctions.DisplayBonusForEmployee();
             break;
     }
     return queryResult;
 }
        public static void UserDataModificationFunction(TelephoneBillSystemChoices userChoice)
        {
            try
            {
                switch (userChoice)
                {
                    case TelephoneBillSystemChoices.AddCustomer:
                        UserInterfaceToDbAccessFunctions.AddCustomer();
                        break;
                    case TelephoneBillSystemChoices.UpdateCustomer:
                        UserInterfaceToDbAccessFunctions.UpdateCustomer();
                        break;
                    case TelephoneBillSystemChoices.GenerateCustomerBill:
                    case TelephoneBillSystemChoices.RecordPayment:
                        UserInterfaceToDbAccessFunctions.RecordBillPayment();
                        break;
                }

            }
            catch (SqlException ex)
            {
                Console.WriteLine("Exception Occured" + ex.Message);
            }
        }
 /// <summary>
 /// This method performs validation to check that the userchoice is valid
 /// </summary>
 /// <param name="userChoice"> Users Choice inputted for action</param>
 /// <returns>Flag indicating the users choice is valid or not</returns>
 private static bool ValidateUsersChoice(TelephoneBillSystemChoices userChoice)
 {
     bool isValidUserChoiceFlag = UserInputValidation.IsValidUserChoice(userChoice);
     return isValidUserChoiceFlag;
 }
        /// <summary>
        /// This method performs validation to check that the userchoice is valid
        /// </summary>
        /// <param name="userChoice"> Users Choice inputted for action</param>
        /// <returns>Flag indicating the users choice is valid or not</returns>
        private static bool ValidateUsersChoice(TelephoneBillSystemChoices userChoice)
        {
            bool isValidUserChoiceFlag = UserInputValidation.IsValidUserChoice(userChoice);

            return(isValidUserChoiceFlag);
        }
        /// <summary>
        /// This method checks if the Input User Choice is Valid
        /// </summary>
        /// <param name="userChoice">The UsersChoice inputted by the user</param>
        /// <returns>Returns a boolean flag to indicate if input UserChoice is valid</returns>
        public static bool IsValidUserChoice(TelephoneBillSystemChoices userChoice)
        {
            var isValidUserChoiceFlag = false;

            if (Enum.IsDefined(typeof(TelephoneBillSystemChoices),userChoice))
                isValidUserChoiceFlag = true;

            return isValidUserChoiceFlag;
        }