public void Index() { int choice; char input; bool flag; do { Console.WriteLine("_____________________________ Login To Commercial data processing ____________________________"); Console.WriteLine("1 Create Acoount if you Have already an Account, Ignore"); Console.WriteLine("2 Login"); Console.WriteLine("______________________________________________________________________________________________"); choice = Utility.switchinputvalidation(); switch (choice) { case 1: CommercialDataProcessingUtility createAccount = new CommercialDataProcessingUtility(); createAccount.CreateAccount(); break; case 2: CommercialDataProcessingUtility LoginUser = new CommercialDataProcessingUtility(); LoginUser.Login(); break; default: Console.WriteLine("You Enter The Wrong Option"); break; } do { Console.WriteLine("Do You Want Continue Y/N ?"); flag = char.TryParse(Console.ReadLine(), out input); if (flag) { break; } Console.WriteLine("Please Enter the proper Input"); } while (!flag); } while (input.Equals('Y') || input.Equals('y')); }
public void StockReport() { try { int serial = 1; char input; bool flag; string Portfolio = @"C:\Users\User\source\repos\ObjectOrientedProgramming\ObjectOrientedProgramming\StockMngt\JsonFiles\Portfolio.json"; string Stocks = File.ReadAllText(Portfolio); var jsonStcoksdata = JsonConvert.DeserializeObject <Portfolio>(Stocks); int TotalStockPrice = 0; List <getStockInfromation> TotalStockDetails; getStockInfromation stocks; Console.WriteLine("Do You Want To Add The Stocks Press Y/y and For View The List of Stocks press S/s else other ?"); do { flag = char.TryParse(Console.ReadLine(), out input); if (flag) { break; } Console.WriteLine("Enter the Proper input"); } while (!flag); if (input.Equals('Y') || input.Equals('y')) { Console.WriteLine("___________________________\tEnter The Number of Stock\t___________________________"); int size = Utility.switchinputvalidation(); for (int i = 0; i < size; i++) { Console.WriteLine("_____________________________ Enter The stock Details of " + (i + 1) + " __________________________________"); if (Portfolio == "") { TotalStockDetails = new List <getStockInfromation>(); stocks = CommercialDataProcessingUtility.AddStocksInformation(); TotalStockDetails.Add(stocks); } else { TotalStockDetails = jsonStcoksdata.TotalStocks; stocks = CommercialDataProcessingUtility.AddStocksInformation(); TotalStockDetails.Add(stocks); } } } if (input.Equals('S') || input.Equals('s')) { Console.WriteLine("The Total Stocks Is ---"); var table = new ConsoleTable("seq", "StockName", "NumberofShare", "SharePrice", "TotalValueofTheStock"); foreach (var stockData in jsonStcoksdata.TotalStocks) { TotalStockPrice = TotalStockPrice + stockData.Numberofshare * stockData.shareprice; table.AddRow(serial, stockData.StockName, stockData.Numberofshare, stockData.shareprice, stockData.Numberofshare * stockData.shareprice); serial++; } table.Write(); Console.WriteLine(); Console.Write("Value Of Total Stocks\t "); Console.WriteLine(TotalStockPrice); string TotalStocks = JsonConvert.SerializeObject(jsonStcoksdata); File.WriteAllText(Portfolio, TotalStocks); } } catch (Exception e) { Console.WriteLine(e.Message); } }
/// <summary> /// Validation of Login User Method /// </summary> public void Login() { bool flag = false; int choice; char input; AddressBookUtility validation = new AddressBookUtility(); string AccountHoldersPath = @"C:\Users\User\source\repos\ObjectOrientedProgramming\ObjectOrientedProgramming\StockMngt\JsonFiles\AccountHolders.json"; string AccountHolders = File.ReadAllText(AccountHoldersPath); var jsonAccountHolder = JsonConvert.DeserializeObject <AccountHolderLists>(AccountHolders); Console.WriteLine("Enter Your User Name"); UserName = validation.CustomName(); foreach (var checkUser in jsonAccountHolder.TotalUsers) { if (checkUser.userName.Contains(UserName)) { do { Console.WriteLine("_____________________________ Welcome To Commercial data processing ____________________________"); Console.WriteLine("1 Buy Share"); Console.WriteLine("2 Sell Share"); Console.WriteLine("3 Total value"); Console.WriteLine("4 Print Report"); Console.WriteLine("_____________________________ ************************************* ____________________________"); Console.WriteLine("Enter Your Choice"); choice = Utility.switchinputvalidation(); switch (choice) { case 1: CommercialDataProcessingUtility Buy = new CommercialDataProcessingUtility(); Buy.BuyShare(); break; case 2: CommercialDataProcessingUtility Shell = new CommercialDataProcessingUtility(); Shell.shellShare(); break; case 3: CommercialDataProcessingUtility Totalvalue = new CommercialDataProcessingUtility(); Totalvalue.TotalAmount(); break; case 4: CommercialDataProcessingUtility PrintReport = new CommercialDataProcessingUtility(); PrintReport.PrintReport(); break; default: Console.WriteLine("You Enterd The Wrong Option"); break; } do { Console.WriteLine("Do You Want Continue Y/N ?"); flag = char.TryParse(Console.ReadLine(), out input); if (flag) { break; } Console.WriteLine("Please Enter the proper Input"); } while (!flag); } while (input.Equals('y') || input.Equals('Y')); flag = true; } } if (flag == false) { Console.WriteLine("No User Name Found"); } }