예제 #1
0
        static void Main(string[] args)
        {
            try
            {
                Product[] ProductList = new Product[20];
                for (int i = 0; i < 15; i++)
                {
                    ProductList[0]  = new Product(1, "TRIMMER", 1000, 8, 1, "Electronics");
                    ProductList[1]  = new Product(2, "MIXER", 1000, 2, 1, "Electronics");
                    ProductList[2]  = new Product(3, "TELEVISION", 500, 10, 1, "Electronics");
                    ProductList[3]  = new Product(4, "PANTS", 100, 6, 3, "Clothing");
                    ProductList[4]  = new Product(5, "LAPTOP", 500, 4, 1, "Electronics");
                    ProductList[5]  = new Product(6, "SAREE", 500, 5, 3, "Clothing");
                    ProductList[6]  = new Product(7, "SHIRT", 500, 8, 3, "Clothing");
                    ProductList[7]  = new Product(8, "TRACKPANT", 500, 8, 3, "Clothing");
                    ProductList[8]  = new Product(9, "TSHIRT", 500, 10, 3, "Clothing");
                    ProductList[9]  = new Product(10, "EGGS", 50, 9, 2, "Grocery");
                    ProductList[10] = new Product(11, "MILK", 90, 5, 2, "Grocery");
                    ProductList[14] = new Product(15, "FRUITS", 50, 8, 2, "Grocery");
                    ProductList[11] = new Product(12, "LIPASTIC", 5000, 8, 4, "Cosmetics");
                    ProductList[12] = new Product(13, "KAJAL", 5000, 7, 4, "Cosmetics");
                    ProductList[13] = new Product(14, "BRUSHES", 500, 8, 4, "Cosmetics");

                    Program.ProductList.Add(ProductList[i]);
                }

                Category CategoryObj = new Category();
                Cart     CartObj     = new Cart();
                Program  programObj  = new Program();

                Order   OrderObj = new DemoKartBL.Order();
                Payment paymentObj = new Payment();
                int     num, num1, num2, num3, num4, id;
                double  TotalPrice = 0, TotalPrice1 = 0, TotalPrice2 = 0, TotalPrice3 = 0, TotalPrice4 = 0;
                double  GrandTotal1 = 0, GrandTotal2 = 0;
                User    UserObj = new User();
                Console.WriteLine("\t\t\t\t\t\t\tSHOPPING KART\n");
                Console.WriteLine("LOGIN TO PROCEED");
                Console.WriteLine("USERNAME");
                String UserName = Console.ReadLine();
                Console.WriteLine("PASSWORD");
                String Password = Console.ReadLine();
                int    value    = UserObj.Login(UserName, Password);

                if (value == 1)
                {
                    do
                    {
                        Console.WriteLine("CHOOSE THE CATEGORY YOU WANT TO SHOP");
                        Console.WriteLine("1.ELECTRONICS\t\n2.GROCERY\t\n3.CLOTHINGS\t\n4.COSMETICS");
                        int Choice = Convert.ToInt32(Console.ReadLine());
                        if (Choice == 1)
                        {
                            programObj.Display(Choice);
                            Console.WriteLine("1.Add To Cart\t2.Continue");
                            num1 = Convert.ToInt32(Console.ReadLine());
                            if (num1 == 1)
                            {
                                Console.WriteLine("\nENTER THE PRODUCT ID OF THE ITEM YOU WANT TO BUY : ");
                                id = Convert.ToInt32(Console.ReadLine());
                                Console.WriteLine("\nHOW MANY?");
                                int quantity = Convert.ToInt32(Console.ReadLine());
                                foreach (Product item in Program.ProductList)
                                {
                                    if (id == item.productId)
                                    {
                                        value = CartObj.AddToCart(quantity);
                                        if (value == 1)
                                        {
                                            Console.WriteLine("Quantity Size Exceeded The Limit\n");
                                            break;
                                        }
                                        else
                                        {
                                            double TotalPric = CategoryObj.CalculatePrice(Choice, item.price, quantity);
                                            TotalPrice1 = TotalPrice1 + TotalPric;
                                            Product cust_cart = new Product(item.productId, item.productName, item.price, quantity, item.CategoryObj.categoriesId, item.CategoryObj.categories);
                                            CartList.Add(cust_cart);
                                            Console.WriteLine("Add To cart Is Successfull\n");
                                        }
                                    }
                                }
                            }
                        }
                        if (Choice == 2)
                        {
                            programObj.Display(Choice);
                            Console.WriteLine("1.Add To Cart\t2.Continue");
                            num1 = Convert.ToInt32(Console.ReadLine());
                            if (num1 == 1)
                            {
                                Console.WriteLine("\nEnter the product ID of the product you want to Add to Cart : ");
                                id = Convert.ToInt32(Console.ReadLine());
                                Console.WriteLine("\nEnter the Quantity you want");
                                int quantity = Convert.ToInt32(Console.ReadLine());
                                foreach (Product item in Program.ProductList)
                                {
                                    if (id == item.productId)
                                    {
                                        value = CartObj.AddToCart(quantity);
                                        if (value == 1)
                                        {
                                            Console.WriteLine("Quantity Size Exceeded The Limit\n");
                                            break;
                                        }
                                        else
                                        {
                                            double TotalPric = CategoryObj.CalculatePrice(Choice, item.price, quantity);
                                            TotalPrice1 = TotalPrice1 + TotalPric;
                                            Product cust_cart = new Product(item.productId, item.productName, item.price, quantity, item.CategoryObj.categoriesId, item.CategoryObj.categories);
                                            CartList.Add(cust_cart);
                                            Console.WriteLine("Add To cart Is Successfull\n");
                                        }
                                    }
                                }
                            }
                        }
                        if (Choice == 3)
                        {
                            programObj.Display(Choice);
                            Console.WriteLine("1.Add To Cart\t2.Continue");
                            num1 = Convert.ToInt32(Console.ReadLine());
                            if (num1 == 1)
                            {
                                Console.WriteLine("\nEnter ID's of Product You Want Add to Cart : ");
                                id = Convert.ToInt32(Console.ReadLine());
                                Console.WriteLine("\nEnter How Many Quantity You Want");
                                int quantity = Convert.ToInt32(Console.ReadLine());
                                foreach (Product item in Program.ProductList)
                                {
                                    if (id == item.productId)
                                    {
                                        value = CartObj.AddToCart(quantity);
                                        if (value == 1)
                                        {
                                            Console.WriteLine("Quantity Size Exceed The Limit\n");
                                            break;
                                        }
                                        else
                                        {
                                            double TotalPric = CategoryObj.CalculatePrice(Choice, item.price, quantity);
                                            TotalPrice1 = TotalPrice1 + TotalPric;
                                            Product cust_cart = new Product(item.productId, item.productName, item.price, quantity, item.CategoryObj.categoriesId, item.CategoryObj.categories);
                                            CartList.Add(cust_cart);
                                            Console.WriteLine("Add To cart Is Successfull\n");
                                        }
                                    }
                                }
                            }
                        }
                        if (Choice == 4)
                        {
                            programObj.Display(Choice);
                            Console.WriteLine("1.Add To Cart\t2.Continue");
                            num1 = Convert.ToInt32(Console.ReadLine());
                            if (num1 == 1)
                            {
                                Console.WriteLine("\nEnter ID's of Product You Want Add to Cart : ");
                                id = Convert.ToInt32(Console.ReadLine());
                                Console.WriteLine("\nEnter How Many Quantity You Want");
                                int quantity = Convert.ToInt32(Console.ReadLine());
                                foreach (Product item in Program.ProductList)
                                {
                                    if (id == item.productId)
                                    {
                                        value = CartObj.AddToCart(quantity);
                                        if (value == 1)
                                        {
                                            Console.WriteLine("Quantity Exceeded\n");
                                            break;
                                        }
                                        else
                                        {
                                            double TotalPric = CategoryObj.CalculatePrice(Choice, item.price, quantity);
                                            TotalPrice1 = TotalPrice1 + TotalPric;
                                            Product cust_cart = new Product(item.productId, item.productName, item.price, quantity, item.CategoryObj.categoriesId, item.CategoryObj.categories);
                                            CartList.Add(cust_cart);
                                            Console.WriteLine("Added To cart\n");
                                        }
                                    }
                                }
                            }
                        }
                        Console.WriteLine("1.WANT TO ADD MORE?\t\n2.SHOW CART AND MAKE PAYMENT");
                        num = Convert.ToInt32(Console.ReadLine());
                    } while (num == 1);
                }
                else
                {
                    Console.WriteLine("ENTERED WRONG CREDENTIALS");
                }
                foreach (Product item in CartList)
                {
                    Console.WriteLine("Product id : " + item.productId);
                    Console.WriteLine("Product Name : " + item.productName);
                    Console.WriteLine("Product Price : " + item.price);
                    Console.WriteLine("Product Quantity : " + item.quantity);
                    Console.WriteLine("category id : " + item.CategoryObj.categoriesId);
                    Console.WriteLine("category type : " + item.CategoryObj.categories);
                    Console.WriteLine("\n______________");
                    Console.WriteLine("\n");
                }
                Console.WriteLine("1.DELETE A PRODUCT FROM CART?\t\n2.PLACE ORDER");
                num2 = Convert.ToInt32(Console.ReadLine());
                do
                {
                    if (num2 == 1)
                    {
                        Console.WriteLine("ENTER THE ID OF THE PRODUCT YOU WANT TO DELETE");
                        int PI = Convert.ToInt32(Console.ReadLine());
                        foreach (Product item in CartList)
                        {
                            if (PI == item.productId)
                            {
                                CartList.Remove(item);
                                Console.WriteLine("Cart item " + PI + " Deleted");
                                break;
                            }
                            else
                            {
                                Console.WriteLine("Item is not available in Cart");
                                break;
                            }
                        }
                    }
                    else
                    {
                        break;
                    }

                    Console.WriteLine("1.Remove Another Cart\t2.Order");
                    num3 = Convert.ToInt32(Console.ReadLine());
                } while (num3 == 1);

                foreach (Product item in CartList)
                {
                    Console.WriteLine("Updated Cart List");
                    Console.WriteLine("Product id : " + item.productId);
                    Console.WriteLine("Product Name : " + item.productName);
                    Console.WriteLine("Product Price : " + item.price);
                    Console.WriteLine("Product Quantity : " + item.quantity);
                    Console.WriteLine("Category ID : " + item.CategoryObj.categoriesId);
                    Console.WriteLine("Category type : " + item.CategoryObj.categories);
                    Console.WriteLine("\n______________");
                    Console.WriteLine("\n");
                }

                Console.WriteLine("Enter Details To Complete Order");
                Console.WriteLine("Enter The First Name : ");
                OrderObj.firstName = Console.ReadLine();
                Console.WriteLine("Enter  The Last Name : ");
                OrderObj.lastName = Console.ReadLine();
                Console.WriteLine("Enter The Mobile Number : ");
                OrderObj.mobileNo = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter The Delivery Address : ");
                OrderObj.deliveryAddress = Console.ReadLine();
                Console.WriteLine("Enter Pincode : ");
                OrderObj.pinCode = Convert.ToInt32(Console.ReadLine());

                TotalPrice = TotalPrice1 + TotalPrice2 + TotalPrice3 + TotalPrice4;

                Console.WriteLine("Choose The Payment Method");
                Console.WriteLine("1.ByCash\t\n2.ByCard");
                num4 = Convert.ToInt32(Console.ReadLine());


                Console.WriteLine("ORDER HAS BEEN PLACED");
                Console.WriteLine("First Name : " + OrderObj.firstName + "\nLast Name : " + OrderObj.lastName + "\nMobile Number : " + OrderObj.mobileNo + "\nDelivery Address : " + OrderObj.deliveryAddress + "\nPinCode : " + OrderObj.pinCode);
                if (num4 == 1)
                {
                    GrandTotal1 = paymentObj.CalculateCGST(num4, TotalPrice);
                    Console.WriteLine("Central GST is : " + GrandTotal1);
                    GrandTotal2 = paymentObj.CalculateSGST(num4, TotalPrice);
                    Console.WriteLine("AMOUNT TO BE PAIN INCLUDING GST : " + GrandTotal2);
                }
                else if (num4 == 2)
                {
                    double GrandTotal3 = paymentObj.CalculateCGST(num4, TotalPrice);
                    Console.WriteLine("C,S GST is : " + GrandTotal3);
                    double GrandTotal4 = paymentObj.CalculateSGST(num4, TotalPrice);
                    Console.WriteLine("AMOUNT TO BE PAIN INCLUDING GST: " + GrandTotal4);
                }
                else
                {
                    Console.WriteLine("Wrong Choice");
                }

                Console.WriteLine("\t\t\t\t\t\t\tTHANKYOU FOR SHOPPING VISIT AGAIN");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
예제 #2
0
         static void Main(string[] args)
        {
            Category CategoryObj = new Category();
            Cart CartObj = new Cart();
            Order OrderObj = new DemoKartBL.Order();
            Payment paymentObj = new Payment();
            User UserObj = new User();

            Console.Write("Enter the Username: "******"Enter the Password: "******"1.Electronics\t2.Grocery\t3.Clothing\t4.Cosmetics");
                    int Choice = Convert.ToInt32(Console.ReadLine());
                    if (Choice == 1)
                    {
                        programObj.Display(Choice);
                        Console.WriteLine("1.Add To Cart\t2.Continue");
                        num1 = Convert.ToInt32(Console.ReadLine());
                        if (num1 == 1)
                        {
                            Console.WriteLine("\nEnter ID's of Product You Want Add to Cart : ");
                            id = Convert.ToInt32(Console.ReadLine());
                            Console.WriteLine("\nEnter How Many Quantity You Want");
                            int quant = Convert.ToInt32(Console.ReadLine());
                            foreach (Product item in ProductList)
                            {
                                if (id == item.productId)
                                {
                                    value = CartObj.AddToCart(quant);
                                    if (value == 1)
                                    {
                                        Console.WriteLine("Quantity Size Exceed The Limit\n");
                                        break;
                                    }
                                    else
                                    {
                                        double TotalPric = CategoryObj.CalculatePrice(Choice, item.price, quant);
                                        TotalPrice1 = TotalPrice1 + TotalPric;
                                        Product cust_cart = new Product(item.Product_id, item.Product_name, item.Product_price, Product_qty, item.category.categoryid, item.category.categoryname);
                                        CartList.Add(cust_cart);
                                        Console.WriteLine("Add To cart Is Successfull\n");
                                    }

                                }
                            }

                        }
                    }
                     if (Choice == 2)
                    {
                        programObj.Display(Choice);
                        Console.WriteLine("1.Add To Cart\t2.Continue");
                        num1 = Convert.ToInt32(Console.ReadLine());
                        if (num1 == 1)
                        {
                            Console.WriteLine("\nEnter ID's of Product You Want Add to Cart : ");
                            id = Convert.ToInt32(Console.ReadLine());
                            Console.WriteLine("\nEnter How Many Quantity You Want");
                            int quant = Convert.ToInt32(Console.ReadLine());
                            foreach (Product item in ProductList)
                            {
                                if (id == item.productId)
                                {
                                    value = CartObj.AddToCart(quant);
                                    if (value == 1)
                                    {
                                        Console.WriteLine("Quantity Size Exceed The Limit\n");
                                        break;
                                    }
                                    else
                                    {
                                        double TotalPric = CategoryObj.CalculatePrice(Choice, item.price, quant);
                                        TotalPrice1 = TotalPrice1 + TotalPric;
                                        Product cust_cart = new Product(item.Product_id, item.Product_name, item.Product_price, Product_qty, item.category.categoryid, item.category.categoryname));
                                        CartList.Add(cust_cart);
                                        Console.WriteLine("Add To cart Is Successfull\n");
                                    }

                                }
                            }

                        }
                    }
                    if (Choice == 3)
                    {
                        programObj.Display(Choice);
                        Console.WriteLine("1.Add To Cart\t2.Continue");
                        num1 = Convert.ToInt32(Console.ReadLine());
                        if (num1 == 1)
                        {
                            Console.WriteLine("\nEnter ID's of Product You Want Add to Cart : ");
                            id = Convert.ToInt32(Console.ReadLine());
                            Console.WriteLine("\nEnter How Many Quantity You Want");
                            int quant = Convert.ToInt32(Console.ReadLine());
                            foreach (Product item in ProductList)
                            {
                                if (id == item.productId)
                                {
                                    value = CartObj.AddToCart(quant);
                                    if (value == 1)
                                    {
                                        Console.WriteLine("Quantity Size Exceed The Limit\n");
                                        break;
                                    }
                                    else
                                    {
                                        double TotalPric = CategoryObj.CalculatePrice(Choice, item.price, quant);
                                        TotalPrice1 = TotalPrice1 + TotalPric;
                                        Product cust_cart = new Product(item.Product_id, item.Product_name, item.Product_price, Product_qty, item.category.categoryid, item.category.categoryname));
                                        CartList.Add(cust_cart);
                                        Console.WriteLine("Add To cart Is Successfull\n");
                                    }

                                }
                            }

                        }
                    }
                    if (Choice == 4)
                    {
                        programObj.Display(Choice);
                        Console.WriteLine("1.Add To Cart\t2.Continue");
                        num1 = Convert.ToInt32(Console.ReadLine());
                        if (num1 == 1)
                        {
                            Console.WriteLine("\nEnter ID's of Product You Want Add to Cart : ");
                            id = Convert.ToInt32(Console.ReadLine());
                            Console.WriteLine("\nEnter How Many Quantity You Want");
                            int quant = Convert.ToInt32(Console.ReadLine());
                            foreach (Product item in ProductList)
                            {
                                if (id == item.productId)
                                {
                                    value = CartObj.AddToCart(quant);
                                    if (value == 1)
                                    {
                                        Console.WriteLine("Quantity Size Exceed The Limit\n");
                                        break;
                                    }
                                    else
                                    {
                                        double TotalPric = CategoryObj.CalculatePrice(Choice, item.price, quant);
                                        TotalPrice1 = TotalPrice1 + TotalPric;
                                        Product cust_cart = new Product(item.Product_id, item.Product_name, item.Product_price, Product_qty, item.category.categoryid, item.category.categoryname));
                                        CartList.Add(cust_cart);
                                        Console.WriteLine("Add To cart Is Successfull\n");
                                    }

                                }
                            }

                        }
                    }
                    Console.WriteLine("1.Revisit\t2.Display Cart And Payment");
                    num = Convert.ToInt32(Console.ReadLine());
                } while (num == 1);
            }
            foreach (Product item in CartList)
            {
                Console.WriteLine("Product id : " + item.Product_id);
                Console.WriteLine("Product Name : " + item.Product_name);
                Console.WriteLine("Product Price : " + item.Product_price);
                Console.WriteLine("Product Quantity : " + item.Product_qty);
                Console.WriteLine("Product Quantity : " + item.category.categoryid);
                Console.WriteLine("Product Quantity : " + item.category.categoryname);
                Console.WriteLine("\n");
            }
            Console.WriteLine("1.Delete cart List\t2.Order");
            num2 = Convert.ToInt32(Console.ReadLine());
            do
            {

                if (num2 == 1)
                {
                    Console.WriteLine("Enter Product Id To Delete");
                    int PI = Convert.ToInt32(Console.ReadLine());
                    foreach (Product item in CartList)
                    {
                        if (PI == item.Product_id)
                        {
                            CartList.Remove(item);
                            Console.WriteLine("Cart item " + PI + " Deleted");
                            break;
                        }
                        else
                        {
                            Console.WriteLine("Item is not in the Cart");
                            break;
                        }


                    }
                }
                else
                {
                    break;
                }

                Console.WriteLine("1.Remove Another Cart\t2.Order");
                num3 = Convert.ToInt32(Console.ReadLine());
            } while (num3 == 1);

            foreach (Product item in CartList)
            {
                Console.WriteLine("Updated Cart List");
                Console.WriteLine("Product id : " + item.Product_id);
                Console.WriteLine("Product Name : " + item.Product_name);
                Console.WriteLine("Product Price : " + item.Product_price);
                Console.WriteLine("Product Quantity : " + item.Product_quantity);
                Console.WriteLine("Product Quantity : " + item.category.categoryid);
                Console.WriteLine("Product Quantity : " + item.category.categoryname);
                Console.WriteLine("\n");
            }

            Console.WriteLine("Enter Details To Complete Order");
            Console.WriteLine("Enter First Name : ");
            OrderObj.firstName = Console.ReadLine();
            Console.WriteLine("Enter Last Name : ");
            OrderObj.lastName = Console.ReadLine();
            Console.WriteLine("Enter Mobile Number : ");
            OrderObj.mobileNo = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter Delivery Address : ");
            OrderObj.deliveryAddress = Console.ReadLine();
            Console.WriteLine("Enter Pincode : ");
            OrderObj.pinCode = Convert.ToInt32(Console.ReadLine());

            TotalPrice = TotalPrice1 + TotalPrice2 + TotalPrice3 + TotalPrice4;

            Console.WriteLine("Enter Payment method");
            Console.WriteLine("1.ByCash\t2.ByCard");
            num4 = Convert.ToInt32(Console.ReadLine());


            Console.WriteLine("Order Successfully Placed..................");
            Console.WriteLine("First Name : " + OrderObj.firstName + "\nLast Name : " + OrderObj.lastName + "\nMobile Number : " + OrderObj.mobileNo + "\nDelivery Address : " + OrderObj.deliveryAddress + "\nPinCode : " + OrderObj.pinCode);
            if (num4 == 1)
            {
                GrandTotal1 = paymentObj.CalculateCGST(num4, TotalPrice);
                Console.WriteLine("Central GST is : " + GrandTotal1);
                GrandTotal2 = paymentObj.CalculateSGST(num4, TotalPrice);
                Console.WriteLine("State GST is : " + GrandTotal2);
            }
            else if (num4 == 2)
            {
                double GrandTotal3 = paymentObj.CalculateCGST(num4, TotalPrice);
                Console.WriteLine("Central GST is : " + GrandTotal3);
                double GrandTotal4 = paymentObj.CalculateSGST(num4, TotalPrice);
                Console.WriteLine("State GST is : " + GrandTotal4);
            }
            else
            {
                Console.WriteLine("Wrong Choice");
            }

            Console.WriteLine("Thank You For Visiting.....................................");

        }
예제 #3
0
        static void Main(string[] args)
        {
            try
            {
                Product[] ProductObj = new Product[20];
                for (int i = 0; i < 13; i++)
                {
                    ProductObj[0]  = new Product(1, "Iphone", 1000, 5, 1, "Electronics");
                    ProductObj[1]  = new Product(2, "mi 10", 1000, 2, 1, "Electronics");
                    ProductObj[2]  = new Product(3, "TV", 500, 10, 1, "Electronics");
                    ProductObj[3]  = new Product(4, "Shoe", 100, 4, 3, "Clothing");
                    ProductObj[4]  = new Product(5, "Fan", 500, 4, 1, "Electronics");
                    ProductObj[5]  = new Product(6, "Saree", 500, 4, 3, "Clothing");
                    ProductObj[6]  = new Product(7, "Shirt", 500, 4, 3, "Clothing");
                    ProductObj[7]  = new Product(8, "Pant", 500, 4, 3, "Clothing");
                    ProductObj[8]  = new Product(9, "Skirt", 500, 4, 3, "Clothing");
                    ProductObj[9]  = new Product(10, "Eggs", 50, 4, 2, "Grocery");
                    ProductObj[10] = new Product(11, "Milk", 90, 4, 2, "Grocery");
                    ProductObj[11] = new Product(12, "Lipstick", 5000, 4, 4, "Cosmetics");
                    ProductObj[12] = new Product(13, "eyeliner", 5000, 4, 4, "Cosmetics");

                    ProductList.Add(ProductObj[i]);
                }



                Category CategoryObj = new Category();
                Cart     CartObj     = new Cart();
                Program  programObj  = new Program();
                Order    OrderObj    = new DemoKartBL.Order();
                Payment  paymentObj  = new Payment();
                Console.WriteLine("**************Sign Up**********************");

                Console.WriteLine("Enter User Name for Sign Up");
                String userName = Console.ReadLine();
                Console.WriteLine("Enter Password for Sign Up");
                String password = Console.ReadLine();
                Console.WriteLine("Enter Date of Birth ");
                DateTime dob = Convert.ToDateTime(Console.ReadLine());
                Console.WriteLine("Enter Mobile Number ");
                long mNo = Convert.ToInt64(Console.ReadLine());

                User UserObj = new User(userName, password, dob, mNo);
                UserList.Add(UserObj);

                Console.WriteLine("1.Display Sign Up Details\t 2.Login");
                int choice2 = Convert.ToInt32(Console.ReadLine());
                if (choice2 == 1)
                {
                    foreach (User item in UserList)
                    {
                        Console.WriteLine("User Name : " + item.UserName);
                        Console.WriteLine("Password : "******"Date Of Birth : " + item.Dob);
                        Console.WriteLine("Mobile Number : " + item.mobileNo);
                    }
                }
                Console.WriteLine("*************Singup Successfull******************");

                int    num, num1, num2, num3, num4, id, value;
                double TotalPrice = 0, TotalPrice1 = 0, TotalPrice2 = 0, TotalPrice3 = 0, TotalPrice4 = 0;
                double GrandTotal1 = 0, GrandTotal2 = 0;
                do
                {
                    Console.WriteLine("\n**********Welcome to our World**********");
                    Console.WriteLine("Enter The User Name for Login");
                    String UserName = Console.ReadLine();
                    Console.WriteLine("Enter The Password for Login");
                    String Password = Console.ReadLine();
                    value = UserObj.Login(UserName, Password);


                    if (value == 1)
                    {
                        Console.WriteLine("************Login Successfull****************");
                        do
                        {
                            Console.WriteLine("\nSelect Category");
                            Console.WriteLine("1.Electronics\t2.Grocery\t3.Clothing\t4.Cosmetics");
                            int Choice = Convert.ToInt32(Console.ReadLine());
                            if (Choice == 1)
                            {
                                programObj.Display(Choice);
                                Console.WriteLine("\n1.Add To Cart\t2.Continue");
                                num1 = Convert.ToInt32(Console.ReadLine());
                                if (num1 == 1)
                                {
                                    Console.WriteLine("\nEnter the product ID of the product  you want to add  : ");
                                    id = Convert.ToInt32(Console.ReadLine());
                                    Console.WriteLine("\nEnter The Quantity You Want");
                                    int quant = Convert.ToInt32(Console.ReadLine());
                                    foreach (Product item in ProductList)
                                    {
                                        if (id == item.productId)
                                        {
                                            value = CartObj.AddToCart(quant);
                                            if (value == 1)
                                            {
                                                double TotalPric = CategoryObj.CalculatePrice(Choice, item.price, quant);
                                                TotalPrice1 = TotalPrice1 + TotalPric;
                                                Product cust_cart = new Product(item.productId, item.productName, item.price, quant, item.CategoryObj.categoriesId, item.CategoryObj.categories);
                                                CartList.Add(cust_cart);
                                                Console.WriteLine("Add To cart Is Successfull\n");
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                            if (Choice == 2)
                            {
                                programObj.Display(Choice);
                                Console.WriteLine("1.Add To Cart\t2.Continue");
                                num1 = Convert.ToInt32(Console.ReadLine());
                                if (num1 == 1)
                                {
                                    Console.WriteLine("\nEnter the product ID of the product you want to Add to Cart : ");
                                    id = Convert.ToInt32(Console.ReadLine());
                                    Console.WriteLine("\nEnter the Quantity you want");
                                    int quant = Convert.ToInt32(Console.ReadLine());
                                    foreach (Product item in ProductList)
                                    {
                                        if (id == item.productId)
                                        {
                                            value = CartObj.AddToCart(quant);
                                            if (value == 1)
                                            {
                                                double TotalPric = CategoryObj.CalculatePrice(Choice, item.price, quant);
                                                TotalPrice1 = TotalPrice1 + TotalPric;
                                                Product cust_cart = new Product(item.productId, item.productName, item.price, quant, item.CategoryObj.categoriesId, item.CategoryObj.categories);
                                                CartList.Add(cust_cart);
                                                Console.WriteLine("Add To cart Is Successfull\n");
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                            if (Choice == 3)
                            {
                                programObj.Display(Choice);
                                Console.WriteLine("1.Add To Cart\t2.Continue");
                                num1 = Convert.ToInt32(Console.ReadLine());
                                if (num1 == 1)
                                {
                                    Console.WriteLine("\nEnter ID of Product You Want Add to Cart : ");
                                    id = Convert.ToInt32(Console.ReadLine());
                                    Console.WriteLine("\nEnter How Many Quantity You Want");
                                    int quant = Convert.ToInt32(Console.ReadLine());
                                    foreach (Product item in ProductList)
                                    {
                                        if (id == item.productId)
                                        {
                                            value = CartObj.AddToCart(quant);
                                            if (value == 1)
                                            {
                                                double TotalPric = CategoryObj.CalculatePrice(Choice, item.price, quant);
                                                TotalPrice1 = TotalPrice1 + TotalPric;
                                                Product cust_cart = new Product(item.productId, item.productName, item.price, quant, item.CategoryObj.categoriesId, item.CategoryObj.categories);
                                                CartList.Add(cust_cart);
                                                Console.WriteLine("Add To cart Is Successfull\n");
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                            if (Choice == 4)
                            {
                                programObj.Display(Choice);
                                Console.WriteLine("1.Add To Cart\t2.Continue");
                                num1 = Convert.ToInt32(Console.ReadLine());
                                if (num1 == 1)
                                {
                                    Console.WriteLine("\nEnter ID of Product You Want Add to Cart : ");
                                    id = Convert.ToInt32(Console.ReadLine());
                                    Console.WriteLine("\nEnter How Many Quantity You Want");
                                    int quant = Convert.ToInt32(Console.ReadLine());
                                    foreach (Product item in ProductList)
                                    {
                                        if (id == item.productId)
                                        {
                                            value = CartObj.AddToCart(quant);
                                            if (value == 1)
                                            {
                                                double TotalPric = CategoryObj.CalculatePrice(Choice, item.price, quant);
                                                TotalPrice1 = TotalPrice1 + TotalPric;
                                                Product cust_cart = new Product(item.productId, item.productName, item.price, quant, item.CategoryObj.categoriesId, item.CategoryObj.categories);
                                                CartList.Add(cust_cart);
                                                Console.WriteLine("Add To cart Is Successfull\n");
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                            Console.WriteLine("1.Revisit\t2.Display Cart And Payment");
                            num = Convert.ToInt32(Console.ReadLine());
                        } while (num == 1);
                    }
                    else
                    {
                        Console.WriteLine("User Name and Password Does Not Match");
                        continue;
                    }
                } while (value != 1);
                foreach (Product item in CartList)
                {
                    Console.WriteLine("Product id : " + item.productId);
                    Console.WriteLine("Product Name : " + item.productName);
                    Console.WriteLine("Product Price : " + item.price);
                    Console.WriteLine("Product Quantity : " + item.quantity);
                    Console.WriteLine("Category Id : " + item.CategoryObj.categoriesId);
                    Console.WriteLine("Type of Product : " + item.CategoryObj.categories);
                    Console.WriteLine("\n");
                }
                Console.WriteLine("1.Delete the cart List\t2.Order");
                num2 = Convert.ToInt32(Console.ReadLine());
                do
                {
                    if (num2 == 1)
                    {
                        Console.WriteLine("Enter The Product Id of the product You Want To Delete");
                        int PI = Convert.ToInt32(Console.ReadLine());
                        foreach (Product item in CartList)
                        {
                            if (PI == item.productId)
                            {
                                CartList.Remove(item);
                                Console.WriteLine("Cart item " + PI + " Deleted");
                                break;
                            }
                            else
                            {
                                Console.WriteLine("Item is not available in Cart");
                                break;
                            }
                        }
                    }
                    else
                    {
                        break;
                    }

                    Console.WriteLine("1.Remove Another Cart\t2.Order");
                    num3 = Convert.ToInt32(Console.ReadLine());
                } while (num3 == 1);

                foreach (Product item in CartList)
                {
                    Console.WriteLine("Updated Cart List");
                    Console.WriteLine("Product id : " + item.productId);
                    Console.WriteLine("Product Name : " + item.productName);
                    Console.WriteLine("Product Price : " + item.price);
                    Console.WriteLine("Product Quantity : " + item.quantity);
                    Console.WriteLine("Category Id : " + item.CategoryObj.categoriesId);
                    Console.WriteLine("Type of Product : " + item.CategoryObj.categories);
                    Console.WriteLine("\n");
                }

                Console.WriteLine("Enter Details To Complete Order");
                Console.WriteLine("Enter The First Name : ");
                OrderObj.firstName = Console.ReadLine();
                Console.WriteLine("Enter the Last Name : ");
                OrderObj.lastName = Console.ReadLine();
                Console.WriteLine("Enter The Mobile Number : ");
                OrderObj.mobileNo = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter The Delivery Address : ");
                OrderObj.deliveryAddress = Console.ReadLine();
                Console.WriteLine("Enter Pincode : ");
                OrderObj.pinCode = Convert.ToInt32(Console.ReadLine());

                TotalPrice = TotalPrice1 + TotalPrice2 + TotalPrice3 + TotalPrice4;

                Console.WriteLine("Choose The Payment Method");
                Console.WriteLine("1.ByCash\t2.ByCard");
                num4 = Convert.ToInt32(Console.ReadLine());


                Console.WriteLine("****************Order  Placed*****************");
                Console.WriteLine("First Name : " + OrderObj.firstName + "\nLast Name : " + OrderObj.lastName + "\nMobile Number : " + OrderObj.mobileNo + "\nDelivery Address : " + OrderObj.deliveryAddress + "\nPinCode : " + OrderObj.pinCode);
                if (num4 == 1)
                {
                    GrandTotal1 = paymentObj.CalculateCGST(num4, TotalPrice);
                    Console.WriteLine("Total Price with Central GST : " + GrandTotal1);
                    GrandTotal2 = paymentObj.CalculateSGST(num4, TotalPrice);
                    Console.WriteLine("Total Price with State GST : " + GrandTotal2);
                }
                else if (num4 == 2)
                {
                    double GrandTotal3 = paymentObj.CalculateCGST(num4, TotalPrice);
                    Console.WriteLine("Total Price with Central GST : " + GrandTotal3);
                    double GrandTotal4 = paymentObj.CalculateSGST(num4, TotalPrice);
                    Console.WriteLine("Total Price with State GST : " + GrandTotal4);
                }
                else
                {
                    Console.WriteLine("Wrong Choice");
                }

                Console.WriteLine("*****************Thank You For Visiting**************************");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);;
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            try
            {
                Product[] ProductObj = new Product[20];
                for (int i = 0; i < 20; i++)
                {
                    ProductObj[0] = new Product(1, "TV", 7000, 5, 1, "Electronics");
                    ProductObj[1] = new Product(2, "MOBILE", 8000, 2, 1, "Electronics");
                    ProductObj[2] = new Product(3, "JUICER", 5000, 3, 1, "Electronics");
                    ProductObj[3] = new Product(4, "TOASTER", 5000, 4, 1, "Electronics");
                    ProductObj[4] = new Product(5, "LAPTOPS", 5000, 4, 1, "Electronics");

                    ProductObj[5] = new Product(11, "EGGS", 50, 14, 2, "Grocery");
                    ProductObj[6] = new Product(12, "MILK", 90, 4, 2, "Grocery");
                    ProductObj[7] = new Product(13, "OATS", 90, 4, 2, "Grocery");
                    ProductObj[8] = new Product(14, "BREAD", 130, 4, 2, "Grocery");
                    ProductObj[9] = new Product(15, "JAM", 190, 4, 2, "Grocery");

                    ProductObj[10] = new Product(6, "MUFFLER", 100, 4, 3, "Clothing");
                    ProductObj[11] = new Product(7, "CAP", 500, 4, 3, "Clothing");
                    ProductObj[12] = new Product(8, "SHIRT", 500, 4, 3, "Clothing");
                    ProductObj[13] = new Product(9, "PANT", 500, 4, 3, "Clothing");
                    ProductObj[14] = new Product(10, "SKIRT", 500, 4, 3, "Clothing");

                    ProductObj[15] = new Product(16, "LIPSTICK", 150, 4, 4, "Cosmetics");
                    ProductObj[16] = new Product(17, "EYELINER", 100, 3, 4, "Cosmetics");
                    ProductObj[17] = new Product(18, "FOUNDATION", 500, 2, 4, "Cosmetics");
                    ProductObj[18] = new Product(19, "FACE WIPES", 300, 4, 4, "Cosmetics");
                    ProductObj[19] = new Product(20, "FACE CREAM", 500, 3, 4, "Cosmetics");

                    ProductList.Add(ProductObj[i]);
                }

                Category CategoryObj = new Category();
                Cart     CartObj     = new Cart();
                Program  programObj  = new Program();

                Order   OrderObj = new DemoKartBL.Order();
                Payment paymentObj = new Payment();
                int     num, num1, num2, num3, num4, id;
                double  TotalPrice = 0, totalPrice1 = 0, TotalPrice2 = 0, TotalPrice3 = 0, TotalPrice4 = 0;
                double  GrandTotal1 = 0, GrandTotal2 = 0;
                User    UserObj = new User();
                Console.WriteLine("*********************Welcome************************");
                Console.WriteLine("Enter User Name");
                String UserName = Console.ReadLine();
                Console.WriteLine("Enter Password");
                String Password = Console.ReadLine();
                int    value    = UserObj.Login(UserName, Password);

                if (value == 1)
                {
                    do
                    {
                        Console.WriteLine("1.Electronics\t2.Grocery\t3.Clothing\t4.Cosmetics");
                        int Choice = Convert.ToInt32(Console.ReadLine());
                        if (Choice == 1)
                        {
                            programObj.Display(Choice);
                            Console.WriteLine("1.Add To Cart\n2.Continue");
                            num1 = Convert.ToInt32(Console.ReadLine());
                            if (num1 == 1)
                            {
                                Console.WriteLine("\nEnter product ID you want to add  : ");
                                id = Convert.ToInt32(Console.ReadLine());
                                Console.WriteLine("\nEnter The Quantity You Want");
                                int quant = Convert.ToInt32(Console.ReadLine());
                                foreach (Product item in ProductList)
                                {
                                    if (id == item.productId)
                                    {
                                        value = CartObj.AddToCart(quant);
                                        if (value == 1)
                                        {
                                            Console.WriteLine("Please Enter valid Quantity of the Product\n");
                                            break;
                                        }
                                        else
                                        {
                                            double TotalPric = CategoryObj.CalculatePrice(Choice, item.price, quant);
                                            totalPrice1 = totalPrice1 + TotalPric;
                                            Product userCart = new Product(item.productId, item.productName, item.price, quant, item.CategoryObj.categoriesId, item.CategoryObj.categories);
                                            CartList.Add(userCart);
                                            Console.WriteLine("Product Added To cart Is Successfully\n");
                                        }
                                    }
                                }
                            }
                        }
                        if (Choice == 2)
                        {
                            programObj.Display(Choice);
                            Console.WriteLine("1.Add To Cart\n2.Continue\n");
                            num1 = Convert.ToInt32(Console.ReadLine());
                            if (num1 == 1)
                            {
                                Console.WriteLine("\nEnter ID of the product you want to Add to Cart : ");
                                id = Convert.ToInt32(Console.ReadLine());
                                Console.WriteLine("\nEnter the Quantity of the Product");
                                int quant = Convert.ToInt32(Console.ReadLine());
                                foreach (Product item in ProductList)
                                {
                                    if (id == item.productId)
                                    {
                                        value = CartObj.AddToCart(quant);
                                        if (value == 1)
                                        {
                                            Console.WriteLine("Please Enter valid Quantity of the Product\n");
                                            break;
                                        }
                                        else
                                        {
                                            double TotalPric = CategoryObj.CalculatePrice(Choice, item.price, quant);
                                            totalPrice1 = totalPrice1 + TotalPric;
                                            Product userCart = new Product(item.productId, item.productName, item.price, quant, item.CategoryObj.categoriesId, item.CategoryObj.categories);
                                            CartList.Add(userCart);
                                            Console.WriteLine("Product Added To cart Is Successfull\n");
                                        }
                                    }
                                }
                            }
                        }
                        if (Choice == 3)
                        {
                            programObj.Display(Choice);
                            Console.WriteLine("1.Add To Cart\t2.Continue");
                            num1 = Convert.ToInt32(Console.ReadLine());
                            if (num1 == 1)
                            {
                                Console.WriteLine("\nEnter ID's of Product You Want Add to Cart : ");
                                id = Convert.ToInt32(Console.ReadLine());
                                Console.WriteLine("\nEnter Product Quantity You Want to add");
                                int quant = Convert.ToInt32(Console.ReadLine());
                                foreach (Product item in ProductList)
                                {
                                    if (id == item.productId)
                                    {
                                        value = CartObj.AddToCart(quant);
                                        if (value == 1)
                                        {
                                            Console.WriteLine("Please Enter valid Quantity of the Product\n");
                                            break;
                                        }
                                        else
                                        {
                                            double TotalPric = CategoryObj.CalculatePrice(Choice, item.price, quant);
                                            totalPrice1 = totalPrice1 + TotalPric;
                                            Product userCart = new Product(item.productId, item.productName, item.price, quant, item.CategoryObj.categoriesId, item.CategoryObj.categories);
                                            CartList.Add(userCart);
                                            Console.WriteLine("Product Added To cart Is Successfully\n");
                                        }
                                    }
                                }
                            }
                        }
                        if (Choice == 4)
                        {
                            programObj.Display(Choice);
                            Console.WriteLine("1.Add To Cart\t2.Continue");
                            num1 = Convert.ToInt32(Console.ReadLine());
                            if (num1 == 1)
                            {
                                Console.WriteLine("\nEnter ID's of Product You Want Add to Cart : ");
                                id = Convert.ToInt32(Console.ReadLine());
                                Console.WriteLine("\nEnter the no of Products You Want to add");
                                int quant = Convert.ToInt32(Console.ReadLine());
                                foreach (Product item in ProductList)
                                {
                                    if (id == item.productId)
                                    {
                                        value = CartObj.AddToCart(quant);
                                        if (value == 1)
                                        {
                                            Console.WriteLine("Please Enter valid Quantity of the Product\n");
                                            break;
                                        }
                                        else
                                        {
                                            double totalPrice = CategoryObj.CalculatePrice(Choice, item.price, quant);
                                            totalPrice1 = totalPrice1 + totalPrice;
                                            Product userCart = new Product(item.productId, item.productName, item.price, quant, item.CategoryObj.categoriesId, item.CategoryObj.categories);
                                            CartList.Add(userCart);
                                            Console.WriteLine("Add To cart Is Successfull\n");
                                        }
                                    }
                                }
                            }
                        }
                        Console.WriteLine("1.Revisit\t2.Display Cart And Payment");
                        num = Convert.ToInt32(Console.ReadLine());
                    } while (num == 1);
                }
                foreach (Product item in CartList)
                {
                    Console.WriteLine("Product id : " + item.productId);
                    Console.WriteLine("Product Name : " + item.productName);
                    Console.WriteLine("Product Price : " + item.price);
                    Console.WriteLine("Product Quantity : " + item.quantity);
                    Console.WriteLine("Product Quantity : " + item.CategoryObj.categoriesId);
                    Console.WriteLine("Product Quantity : " + item.CategoryObj.categories);
                    Console.WriteLine("\n");
                }
                Console.WriteLine("1.Delete the Product List\t2.Order");
                num2 = Convert.ToInt32(Console.ReadLine());
                do
                {
                    if (num2 == 1)
                    {
                        Console.WriteLine("Enter The Product Id You Want To Delete");
                        int PI = Convert.ToInt32(Console.ReadLine());
                        foreach (Product item in CartList)
                        {
                            if (PI == item.productId)
                            {
                                CartList.Remove(item);
                                Console.WriteLine("Cart item" + PI + "Deleted");
                                break;
                            }
                            else
                            {
                                Console.WriteLine("Item is not available in Cart");
                                break;
                            }
                        }
                    }
                    else
                    {
                        break;
                    }

                    Console.WriteLine("1.Remove Another Cart\t2.Order");
                    num3 = Convert.ToInt32(Console.ReadLine());
                } while (num3 == 1);

                foreach (Product item in CartList)
                {
                    Console.WriteLine("Updated Cart List");
                    Console.WriteLine("Product id : " + item.productId);
                    Console.WriteLine("Product Name : " + item.productName);
                    Console.WriteLine("Product Price : " + item.price);
                    Console.WriteLine("Product Quantity : " + item.quantity);
                    Console.WriteLine("Product Quantity : " + item.CategoryObj.categoriesId);
                    Console.WriteLine("Product Quantity : " + item.CategoryObj.categories);
                    Console.WriteLine("\n");
                }

                Console.WriteLine("Enter User Details To Complete Order");
                Console.WriteLine("Enter Your First Name : ");
                OrderObj.firstName = Console.ReadLine();
                Console.WriteLine("Enter  Your Last Name : ");
                OrderObj.lastName = Console.ReadLine();
                Console.WriteLine("Enter Phone No : ");
                OrderObj.mobileNo = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter The Delivery Address : ");
                OrderObj.deliveryAddress = Console.ReadLine();


                TotalPrice = totalPrice1 + TotalPrice2 + TotalPrice3 + TotalPrice4;

                Console.WriteLine("Choose The Payment Method");
                Console.WriteLine("1.ByCash\t2.ByCard");
                num4 = Convert.ToInt32(Console.ReadLine());


                Console.WriteLine("Order  Placed ..................");
                Console.WriteLine("First Name : " + OrderObj.firstName + "\nLast Name : " + OrderObj.lastName + "\nMobile Number : " + OrderObj.mobileNo + "\nDelivery Address : " + OrderObj.deliveryAddress);
                if (num4 == 1)
                {
                    GrandTotal1 = paymentObj.CalcCGST(num4, TotalPrice);
                    Console.WriteLine("Central GST is : " + GrandTotal1);
                    GrandTotal2 = paymentObj.CalcSGST(num4, TotalPrice);
                    Console.WriteLine("State GST is : " + GrandTotal2);
                }
                else if (num4 == 2)
                {
                    double GrandTotal3 = paymentObj.CalcCGST(num4, TotalPrice);
                    Console.WriteLine("Central GST is : " + GrandTotal3);
                    double GrandTotal4 = paymentObj.CalcSGST(num4, TotalPrice);
                    Console.WriteLine("State GST is : " + GrandTotal4);
                }
                else
                {
                    Console.WriteLine("Enter Correct Choice");
                }

                Console.WriteLine("Thank You");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }