コード例 #1
0
ファイル: CalcDemo.cs プロジェクト: sureshk5/.Net
        private static void addOperation()
        {
            double v1  = MyConsole.GetDouble("Enter the first value");
            double v2  = MyConsole.GetDouble("Enter the Second value");
            double res = CalcComponent.Sum(v1, v2);

            Console.WriteLine("The Added value is " + res);
        }
コード例 #2
0
ファイル: CalcDemo.cs プロジェクト: sureshk5/.Net
 static void Main(string[] args)
 {
     do
     {
         string choice = MyConsole.GetString(strMenu);
         processing = processMenu(choice);
     } while (processing);
 }
コード例 #3
0
        static void Main(string[] args)
        {
            InitializeComponent();
            bool @continue = true;

            do
            {
                string choice = MyConsole.getString(menu);
                @continue = processing(choice);
            } while (@continue);
        }
コード例 #4
0
        private static void deletingCustomer()
        {
            int id = MyConsole.getNumber("Enter the ID of the customer to remove");

            if (mgr.DeleteCustomer(id))
            {
                Console.WriteLine("Customer Deleted successfully");
            }
            else
            {
                Console.WriteLine("Could not find the Customer to delete");
            }
        }
コード例 #5
0
        private static void deletingFeature()
        {
            int id = MyConsole.getNumber("Enter the ID of the book to remove");

            if (mgr.DeleteBook(id))
            {
                Console.WriteLine("Book Deleted successfully");
            }
            else
            {
                Console.WriteLine("Could not find the book to delete");
            }
        }
コード例 #6
0
        private static void serializingXml()
        {
            Student stud = new Student();

            stud.Name    = MyConsole.getString("Enter the name");
            stud.Address = MyConsole.getString("Enter the address");
            stud.Phone   = MyConsole.getNumber("Enter the landline Phone no");
            FileStream    fs = new FileStream("Xmlfile.xml", FileMode.OpenOrCreate, FileAccess.ReadWrite);
            XmlSerializer sl = new XmlSerializer(typeof(Student));

            sl.Serialize(fs, stud);
            fs.Flush();//Clears the buffer into the destination so that no unused stream is left over before U close the Stream...
            fs.Close();
        }
コード例 #7
0
        private static void readingCustomerData()
        {
            string name = MyConsole.getString("Enter the name of the customer");

            Customer[] customer = mgr.GetAllCustomer(name);
            foreach (var cus in customer)
            {
                if (cus != null)
                {
                    Console.WriteLine(cus.Name);
                }
                Console.WriteLine(cus.CustomerID);
                Console.WriteLine(cus.Address);
            }
        }
コード例 #8
0
        private static void readingFeature()
        {
            string title = MyConsole.getString("Enter the title or part of the title to search");

            Book[] books = mgr.GetAllBooks(title);
            foreach (var bk in books)
            {
                if (bk != null)
                {
                    Console.WriteLine(bk.Title);
                }
                Console.WriteLine(bk.BookID);
                Console.WriteLine(bk.Author);
                Console.WriteLine(bk.Price);
            }
        }
コード例 #9
0
        private static void addingCustomerData()
        {
            Customer cus = new Customer();

            cus.CustomerID = MyConsole.getNumber("Enter the ID of the Customer");
            cus.Name       = MyConsole.getString("Enter the Name of Customer");
            cus.Address    = MyConsole.getString("Enter the Address of Customer");

            try
            {
                bool result = mgr.AddNewCustomer(cus);
                Console.WriteLine($"Customer by name {cus.Name} is added successfully to the database");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #10
0
        private static void updatingCustomerData()
        {
            Customer cus = new Customer();

            cus.CustomerID = MyConsole.getNumber("Enter the ID  of the Customer U wish to update");
            cus.Name       = MyConsole.getString("Enter the new name of this customer");
            cus.Address    = MyConsole.getString("Enter the new Address of this customer");

            bool result = mgr.UpdateCustomer(cus);

            if (!result)
            {
                Console.WriteLine($"No Customer by this id {cus.CustomerID} found to update");
            }
            else
            {
                Console.WriteLine($"Customer by ID {cus.CustomerID} is updated successfully to the database");
            }
        }
コード例 #11
0
        private static void updatingBookFeature()
        {
            Book bk = new Book();

            bk.BookID = MyConsole.getNumber("Enter the ISBN no of the book U wish to update");
            bk.Title  = MyConsole.getString("Enter the new title of this book");
            bk.Author = MyConsole.getString("Enter the new Author of this book");
            bk.Price  = MyConsole.getDouble("Enter the new Price of this book");
            bool result = mgr.UpdateBook(bk);

            if (!result)
            {
                Console.WriteLine($"No book by this id {bk.BookID} found to update");
            }
            else
            {
                Console.WriteLine($"Book by ID {bk.BookID} is updated successfully to the database");
            }
        }
コード例 #12
0
        private static void dynamicArrayExample()
        {
            //requirements: type, size, values, iteration...
            Console.WriteLine("What Type of Array U want to create\nPS: Enter the CTS typename");
            string input    = Console.ReadLine();  //ReadLine is the only method to take inputs from the console.
            Type   dataType = Type.GetType(input); //Similar to ClassName for...
            int    size     = MyConsole.GetNumber("Enter the size of the array");
            Array  array    = Array.CreateInstance(dataType, size);

            for (int i = 0; i < size; i++)
            {
                Console.WriteLine("Enter the value for the location {0} of the data type {1}", i, dataType.Name);
                input = Console.ReadLine();
                object inputValue = Convert.ChangeType(input, dataType);
                array.SetValue(inputValue, i);
            }
            Console.WriteLine("All the values are set\nReading the values");
            foreach (object value in array)
            {
                Console.WriteLine(value);
            }
        }
コード例 #13
0
        private static void twoDArrayExample()
        {
            //Length vs. GetLength vs. Rank of the Array class.
            //GetLength method is used to get the length of the specified dimension in a multi dimensional array. dimension index starts with 0...
            int[,] rooms = new int[3, 2];
            Console.WriteLine("The no of dimensions:" + rooms.Rank);
            for (int i = 0; i < rooms.GetLength(0); i++)
            {
                for (int j = 0; j < rooms.GetLength(1); j++)
                {
                    rooms[i, j] = MyConsole.GetNumber($"Enter the value for {i},{j} location");
                }
            }

            for (int i = 0; i < rooms.GetLength(0); i++)
            {
                for (int j = 0; j < rooms.GetLength(1); j++)
                {
                    Console.Write(rooms[i, j] + "\t");//Difference b/w Write vs WriteLine
                }
                Console.WriteLine();
            }
        }