示例#1
0
        static void CreateAccount()
        {
            Console.WriteLine("----------------- Creating user account -----------------------");

            Console.Write("\nEnter user name:");
            string name = Console.ReadLine();

            Console.Write("\nEnter amount:");
            decimal balance = decimal.Parse(Console.ReadLine());
            
            Account newAccount = new Account(accounts.Count + 1, name, balance);
            accounts.Add(newAccount);
        }
示例#2
0
文件: Program.cs 项目: jaspreet93/lab
        public void TransferFunds(Account destinatin, decimal amount)
        {

        }
示例#3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Создайте пароль");
            string NewPass =  Console.ReadLine();
            User Client = new User();
            Client.CreatePassword(NewPass);

            int selection = 0;
            do
            {
                Console.WriteLine("Меню:");
                Console.WriteLine("1-Выйти");
                Console.WriteLine("2-Сменить пароль");
                Console.WriteLine("3-Запрос баланса");
                Console.WriteLine("4-Добавить транзакцию");
                Console.WriteLine("5-Создайте счёт");

                selection = Int32.Parse(Console.ReadLine());

                switch (selection)
                {

                    case 1:
                        Console.WriteLine("Вы вышли");
                        break;
                    case 2:
                        Console.WriteLine("Введите новый пароль:");
                        string changedPass = Console.ReadLine();
                        Client.ChangePassword(changedPass);
                        Console.WriteLine("Вы успешно сменили пароль");

                        break;
                    case 3:
                        if (Client.Acc != null)
                        {
                            Console.WriteLine(Account.getBalance(Client.Acc.Details));
                            break;
                        }
                        else
                        {
                            Console.WriteLine("Создайте для начала счёт!");
                            break;
                        }
                    case 4:
                        if (Client.Acc != null && Client.Acc.Details != null)
                        {
                            Console.WriteLine("Введите вид транзакции (расход/приход)");
                            string Transaction = Console.ReadLine();
                            Console.WriteLine("Введите категорию:");
                            string Category = Console.ReadLine();
                            Console.WriteLine("Введите сумму:");
                            double Amount = Convert.ToDouble(Console.ReadLine());
                           Client.Acc.Details.Add(Detail.NewDatail(Amount,Category,DateTime.Now, Transaction));
                            Console.WriteLine("Успешно!");
                            break;
                        }
                        if (Client.Acc == null)
                        {
                            Console.WriteLine("Создайте для начала счёт!");
                            break;
                        }

                            Console.WriteLine("Введите вид транзакции (расход/приход)");
                            string MYTransaction = Console.ReadLine();
                            Console.WriteLine("Введите категорию:");
                            string MYCategory = Console.ReadLine();
                            Console.WriteLine("Введите сумму:");
                            double MYAmount = Convert.ToDouble(Console.ReadLine());
                            List<Detail> myNewDetail = new List<Detail>();

                            myNewDetail.Add(Detail.NewDatail(Convert.ToDouble(MYAmount), MYCategory, DateTime.Now,
                                MYTransaction));
                            Client.Acc.Details = myNewDetail;
                            Console.WriteLine("Успешно!");
                            break;

                    case 5:
                        Console.WriteLine("Название счёта:");
                        string newAcc = Console.ReadLine();
                        Account myNewAccount = new Account();

                        myNewAccount.name = newAcc;
                        Client.Acc = myNewAccount;
                        Console.WriteLine("Вы успешно создали счёт");

                        break;

                    default:
                        Console.WriteLine("Некоректный ввод");
                        break;

                }
            } while (selection != 6);
        }
示例#4
0
        /// <summary>
        /// Creates any entity records that this sample requires.
        /// </summary>
        public void CreateRequiredRecords()
        {
            #region Create Accounts to query over

            Console.WriteLine("  Creating some sample accounts");

            Account account = new Account()
            {
                Name = "Coho Vineyard"
            };
            account.Id = _serviceProxy.Create(account);
            _accounts.Add(account);
            Console.WriteLine("    Created Account {0}", account.Name);

            account = new Account()
            {
                Name = "Coho Winery"
            };
            account.Id = _serviceProxy.Create(account);
            _accounts.Add(account);
            Console.WriteLine("    Created Account {0}", account.Name);

            account = new Account()
            {
                Name = "Coho Vineyard & Winery"
            };
            account.Id = _serviceProxy.Create(account);
            _accounts.Add(account);
            Console.WriteLine("    Created Account {0}", account.Name);

            #endregion

            #region Create a Saved Query

            Console.WriteLine("  Creating a Saved Query that retrieves all Account ids");

            _savedQuery = new SavedQuery()
            {
                Name = "Fetch all Account ids",
                ReturnedTypeCode = Account.EntityLogicalName,
                FetchXml = @"
                    <fetch mapping='logical'>
                        <entity name='account'>
                            <attribute name='name' />
                        </entity>
                    </fetch>",
                QueryType = 0,

            };
            _savedQuery.Id = _serviceProxy.Create(_savedQuery);

            #endregion

            #region Create a User Query

            Console.WriteLine(
                "  Creating a User Query that retrieves all Account ids for Accounts with name 'Coho Winery'");

            _userQuery = new UserQuery()
            {
                Name = "Fetch Coho Winery",
                ReturnedTypeCode = Account.EntityLogicalName,
                FetchXml = @"
                    <fetch mapping='logical'>
                        <entity name='account'>
                            <attribute name='name' />
                            <filter>
                                <condition attribute='name' operator='eq' value='Coho Winery' />
                            </filter>
                        </entity>
                    </fetch>",
                QueryType = 0
            };
            _userQuery.Id = _serviceProxy.Create(_userQuery);

            #endregion
        }