コード例 #1
0
ファイル: Program.cs プロジェクト: swarnayuroy/Warehouse
        public static void TestRemoveProduct()
        {
c1:
            Console.Write("Enter product id to be removed: ");
            string prodId = Console.ReadLine();

            if (string.IsNullOrEmpty(prodId))
            {
                Console.Clear();
                Console.WriteLine("Please enter a product id!");
                goto c1;
            }
            WarehouseDataAccessLayer dal = new WarehouseDataAccessLayer();
            int status = dal.RemoveProduct(prodId);

            if (status == 1)
            {
                Console.Clear();
                Console.WriteLine("Product has been removed.\n");
            }
            else if (status == -1)
            {
                Console.Clear();
                Console.WriteLine("Product with the entered id doesn't exists!\n");
            }
            else
            {
                Console.Clear();
                Console.WriteLine("Some error occured while removing!\n");
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: swarnayuroy/Warehouse
        public static void TestProcessOrder()
        {
            Console.Write("\nEnter order id: ");
            string oId = Console.ReadLine();

            Console.Write("Enter status: ");
            string o_status = Console.ReadLine();

            WarehouseDataAccessLayer dal = new WarehouseDataAccessLayer();
            int retVal = dal.ProcessOrder(oId, o_status);

            if (retVal == 1)
            {
                Console.Clear();
                Console.WriteLine("Status has been changed to " + "[" + o_status + "]" + " for the order, " + oId + "\n");
            }
            else if (retVal == 0)
            {
                Console.Clear();
                Console.WriteLine("Some error had occurred. Please try again later.\n");
            }
            else
            {
                Console.Clear();
                Console.WriteLine("The order id you entered doesn't exsit.\n");
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: swarnayuroy/Warehouse
        public static void TestAddCategory()
        {
c1:
            Console.Write("Enter category name: ");
            string catName = Console.ReadLine();

            if (string.IsNullOrEmpty(catName))
            {
                Console.Clear();
                Console.WriteLine("Please enter a new category!");
                goto c1;
            }
            WarehouseDataAccessLayer dal = new WarehouseDataAccessLayer();
            int status = dal.AddCategory(catName);

            if (status == 1)
            {
                Console.Clear();
                Console.WriteLine("A new category, " + catName + " has been added.\n");
            }
            else if (status == -1)
            {
                Console.Clear();
                Console.WriteLine("Category already exists!\n");
            }
            else
            {
                Console.Clear();
                Console.WriteLine("Some error occured while insertion!\n");
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: swarnayuroy/Warehouse
        public static void TestRemoveCategory()
        {
c1:
            Console.Write("Enter category id to be removed: ");
            int catId = Convert.ToInt32(Console.ReadLine());

            if (catId == 0)
            {
                Console.Clear();
                Console.WriteLine("Please enter a valid category id!");
                goto c1;
            }
            WarehouseDataAccessLayer dal = new WarehouseDataAccessLayer();
            int status = dal.RemoveCategory(catId);

            if (status == 1)
            {
                Console.Clear();
                Console.WriteLine("Category has been removed.\n");
            }
            else if (status == -1)
            {
                Console.Clear();
                Console.WriteLine("Category doesn't exists!\n");
            }
            else
            {
                Console.Clear();
                Console.WriteLine("Some error occured while removing!\n");
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: swarnayuroy/Warehouse
        public static void TestValidateUser()
        {
c1:
            Console.WriteLine("Please Login to continue...");
            Console.Write("Enter email: ");
            string email = Console.ReadLine();

            Console.Write("Enter password: "******"Enter your credentials..!\n");
                goto c1;
            }

            WarehouseDataAccessLayer dal = new WarehouseDataAccessLayer();
            int status = dal.ValidateUser(email, pass);

            if (status == -1)
            {
                Console.Clear();
                Console.WriteLine("Incorrect email or password!\n");
                goto c1;
            }
            else
            {
                Console.Clear();
                Console.WriteLine("Login Successful...");
            }
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: swarnayuroy/Warehouse
        public static void TestGetCategories()
        {
            WarehouseDataAccessLayer dal = new WarehouseDataAccessLayer();
            var catList = dal.GetCategoryList();

            Console.WriteLine("\n\n***********Categories************");
            foreach (var item in catList)
            {
                Console.WriteLine("\t" + item.CategoryId + " " + item.CategoryName);
            }
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: swarnayuroy/Warehouse
        public static void TestGetProducts()
        {
            WarehouseDataAccessLayer dal = new WarehouseDataAccessLayer();
            var productList = dal.GetProductList();

            Console.WriteLine("************Product List*************");
            Console.WriteLine("Product Id" + "\t\tProduct" + "\tStock");
            foreach (var item in productList)
            {
                Console.WriteLine(item.ProductId + "\t\t" + item.Product1 + "\t" + item.Quantity);
            }
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: swarnayuroy/Warehouse
        public static void TestGetOrderList()
        {
            WarehouseDataAccessLayer dal = new WarehouseDataAccessLayer();
            var orderList = dal.GetOrderList();

            foreach (var item in orderList)
            {
                Console.WriteLine("ORDER ID: " + item.OrderId);
                Console.WriteLine("CUSTOMER ID: " + item.Customer_Id);
                Console.WriteLine("CUSTOMER NAME: " + item.Customer_Name);
                Console.WriteLine("PRODUCT ID: " + item.ProductId);
                Console.WriteLine("PRODUCT: " + item.ProductName);
                Console.WriteLine("PRICE(Rs): " + item.Price);
                Console.WriteLine("QUANTITY ORDERED: " + item.Quantity_Ordered);
                Console.WriteLine("DATE: " + item.Date);
                Console.WriteLine("STATUS: " + item.Status);
                Console.WriteLine("-----------------------------------------------\n");
            }
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: swarnayuroy/Warehouse
        public static void TestUpdateCategory()
        {
c1:
            Console.Write("Enter category id you want to edit: ");
            int catId = Convert.ToInt32(Console.ReadLine());

            if (catId == 0)
            {
                Console.Clear();
                Console.WriteLine("Please enter a valid category id!\n");
                goto c1;
            }
c2:
            Console.Write("Enter the new category: ");
            string catName = Console.ReadLine();

            if (string.IsNullOrEmpty(catName))
            {
                Console.Clear();
                Console.WriteLine("Please enter a new category!\n");
                goto c2;
            }

            WarehouseDataAccessLayer dal = new WarehouseDataAccessLayer();
            int status = dal.UpdateCategory(catId, catName);

            if (status == 1)
            {
                Console.Clear();
                Console.WriteLine("Category has been upadated.\n");
            }
            else if (status == -1)
            {
                Console.Clear();
                Console.WriteLine("Category doesn't exists!\n");
            }
            else
            {
                Console.Clear();
                Console.WriteLine("Some error occured while updating!\n");
            }
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: swarnayuroy/Warehouse
        public static void TestFetchProducts()
        {
            Console.Write("Enter category id: ");
            int catId = Convert.ToInt32(Console.ReadLine());
            WarehouseDataAccessLayer dal      = new WarehouseDataAccessLayer();
            List <Product>           products = dal.FetchProducts(catId);

            if (products.Any())
            {
                Console.WriteLine("\n************Product List*************");
                Console.WriteLine("Product Id" + "\t\tProduct" + "\t\tPrice" + "\tStock");
                foreach (var item in products)
                {
                    Console.WriteLine(item.ProductId + "\t\t" + item.Product1 + "\t\t" + item.Price + "\t" + item.Quantity);
                }
            }
            else
            {
                Console.WriteLine("No products are available to this category!");
            }
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: swarnayuroy/Warehouse
        public static void TestAddProduct()
        {
            Console.WriteLine("\n");
            Console.Write("Enter product name: ");
            string prodName = Console.ReadLine();

            Console.Write("Enter category id: ");
            decimal catId = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter price: ");
            decimal price = Convert.ToDecimal(Console.ReadLine());

            Console.Write("Enter stock: ");
            decimal stock  = Convert.ToInt32(Console.ReadLine());
            string  prodId = " ";

            WarehouseDataAccessLayer dal = new WarehouseDataAccessLayer();
            int retVal = dal.AddProduct(prodName, catId, price, stock, out prodId);

            if (retVal == -1)
            {
                Console.Clear();
                Console.WriteLine("This product already exists!\n");
            }
            else if (retVal == -2)
            {
                Console.Clear();
                Console.WriteLine("This category doesn't exists!\n");
            }
            else if (retVal == -99 || retVal == 0)
            {
                Console.Clear();
                Console.WriteLine("Some error occurred while adding a product!\n");
            }
            else
            {
                Console.Clear();
                Console.WriteLine("\nA new product of id " + prodId + " has been added.\n");
            }
        }