Exemplo n.º 1
0
        private static void addingBookFeature()
        {
            Book bk = new Book();

            bk.BookID = MyConsole.getNumber("Enter the ISBN no of this book");
            bk.Title  = MyConsole.getString("Enter the title of this book");
            bk.Author = MyConsole.getString("Enter the Author of this book");
            bk.Price  = MyConsole.getDouble("Enter the Price of this book");
            try
            {
                bool result = mgr.AddNewBook(bk);
                if (!result)
                {
                    Console.WriteLine("No more books could be added");
                }
                else
                {
                    Console.WriteLine($"Book by title {bk.Title} is added successfully to the database");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            InitializeComponent();
            bool @continue = true;

            do
            {
                string choice = MyConsole.getString(menu);
                @continue = processing(choice);
            } while (@continue);
        }
        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();
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
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);
            }
        }
Exemplo n.º 7
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");
            }
        }
Exemplo n.º 8
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");
            }
        }