Exemple #1
0
        public static void Updatepro()
        {
            try
            {
                Console.WriteLine("Enter product's id to update:");
                int id = int.Parse(Console.ReadLine());
                if (Allproducts.Products.ContainsKey(id))
                {
                    Console.WriteLine("Enter new name: ");
                    string name = Console.ReadLine();
                    Console.WriteLine("Enter new price:");
                    int     price = (int)uint.Parse(Console.ReadLine());
                    Product pro   = new Product(id, name, price);
                    Allproducts.Products[id] = pro;
                    string fulllink = $@"{path}{filename}";
                    ReadWriteFile <Dictionary <int, Product> > .WriteData(fulllink, Products);

                    Console.WriteLine("Successfully!!");
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine("Not found!!");
                    Updatepro();
                }
            }
            catch (Exception e)
            {
                Console.Clear();
                Console.WriteLine($"Type:{e.GetType()}, Message : {e.Message} ");
                Updatepro();
            }
        }
Exemple #2
0
        public static void Removepro()
        {
            try
            {
                Console.WriteLine("Enter product's id to remove:");
                int id = int.Parse(Console.ReadLine());
                if (Allproducts.Products.ContainsKey(id))
                {
                    Allproducts.Products.Remove(id);
                    string fulllink = $@"{path}{filename}";
                    ReadWriteFile <Dictionary <int, Product> > .WriteData(fulllink, Products);

                    Console.WriteLine("Successfully!!");
                }
                else
                {
                    Console.WriteLine("Not found!!");
                    Removepro();
                }
            }
            catch (Exception e)
            {
                Console.Clear();
                Console.WriteLine($"Type:{e.GetType()}, Message : {e.Message} ");
                Removepro();
            }
        }
Exemple #3
0
        public static void Addpro()
        {
            ReadData();
            try
            {
                Console.WriteLine("Enter product's id:");
                int id = int.Parse(Console.ReadLine());
                if (Allproducts.Products.ContainsKey(id) == false)
                {
                    Console.WriteLine("Enter product's name: ");
                    string name = Console.ReadLine();
                    Console.WriteLine("Enter price:");
                    int     price = (int)uint.Parse(Console.ReadLine());
                    Product pro   = new Product(id, name, price);
                    Allproducts.Products.Add(id, pro);
                    string fulllink = $@"{path}{filename}";
                    ReadWriteFile <Dictionary <int, Product> > .WriteData(fulllink, Products);

                    Console.WriteLine("Successfully!!");
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine("This ID is already exists!");
                    Addpro();
                }
            }
            catch (Exception e)
            {
                Console.Clear();
                Console.WriteLine($"Type:{e.GetType()}, Message : {e.Message} ");
                Addpro();
            }
        }
Exemple #4
0
        /* Xử lý trên order*/
        // Cập nhật đơn hàng
        public static void UpdateOrder(Order order)
        {
            if (order.Status == 1)
            {
                do
                {
                    Allproducts.ShowAllproduct();

                    Console.WriteLine("Enter id of product that you want:");
                    int id = int.Parse(Console.ReadLine());

                    order.ProductsList.Add(Allproducts.Products[id]);
                    int index = shop.listorder.ListOrder.IndexOf(order);
                    shop.listorder.ListOrder[index].ProductsList = order.ProductsList;

                    string fulllink = $"{path}{nameFile}";
                    ReadWriteFile<Listorder>.WriteData(fulllink, shop.listorder);

                    Console.Clear();
                    Console.WriteLine(order.ToString());
                    Console.WriteLine("Successfully!");
                    Console.Write("Do you want to add more? y(Yes)/n(No):  ");
                }
                while (Console.ReadLine().ToLower() == "y");
            }
            else
            {
                Console.WriteLine(order.ToString());
                Console.WriteLine(" This order has been paid or has been canceled before!!");
            }
        }
Exemple #5
0
        //{
        //    { 1, new Product (1, "Ao khoac nam", 150000) },
        //    { 2, new Product (2, "Ao khoac kaki", 350000) },
        //    { 3, new Product (3, "Ao khoac du", 250000) },
        //    { 4, new Product (4, "Dam xoe nu", 500000) },
        //    { 5, new Product (5, "Ao thun nu", 450000) },
        //    { 6, new Product (6, "Hoodie nam", 320000) },
        //    { 7, new Product (7, "Ao chong nang", 630000)}
        //};
        public static Dictionary <int, Product> ReadData()
        {
            string fulllink = $@"{path}{filename}";

            ReadWriteFile <Dictionary <int, Product> > .ReadData(fulllink, ref Products);

            return(Products);
        }
Exemple #6
0
        //Thêm đơn hàng
        public void Add(Order oder)
        {
            orderid++;
            oder.OrderId = orderid;
            listorder.ListOrder.Add(oder);
            string fulllink = $"{path}{nameFileData}";

            ReadWriteFile <Listorder> .WriteData(fulllink, listorder);
        }
Exemple #7
0
        // Thêm user
        public void Adduser()
        {
            listuser.Listuser.Add(newuser());
            string fulllink = $"{path}{nameFileData}";

            ReadWriteFile <ListUser> .WriteData(fulllink, listuser);

            Console.WriteLine("Successfully!");
        }
Exemple #8
0
        public void PrintBill(Order od)
        {
            string billname = $"{DateTime.Now.ToString("ddMMyyyy")}_order_{od.OrderId}";

            ReadWriteFile <Order> .WriteData($@"{path}{billname}", od);

            string fulllink = $"{path}{nameFileData}";

            ReadWriteFile <Listorder> .WriteData(fulllink, listorder);
        }
Exemple #9
0
        // Update Order's Status
                                    public static void UpdateStatus(Order order)
        {
            try
            {
                Console.Write("1.Waiting\n2.Paid\n3.Cancel\nChoice: ");
                int stt   = int.Parse(Console.ReadLine());
                int index = shop.listorder.ListOrder.IndexOf(order);
                order.Status = (stt == 1) ? 1 : (stt == 2) ? 2 : 3;
                shop.listorder.ListOrder[index].Status = order.Status;
                string fulllink = $"{path}{nameFile}";
                ReadWriteFile <Listorder> .WriteData(fulllink, shop.listorder);

                Console.Clear();
                Console.WriteLine(order.ToString());
                Console.WriteLine("Update successfully");
            }
            catch (Exception)
            {
                Console.WriteLine("Enter a number of Interger, please!!");
                Console.WriteLine(order.ToString());
                UpdateStatus(order);
            }
        }
Exemple #10
0
        // Đổi mật khẩu
        public void ChangePass()
        {
            Console.WriteLine("Enter username:"******"Enter current password:"******"Enter new password");
                    string newpass = Console.ReadLine();
                    Console.WriteLine("Enter new password again:");
                    string newpass2 = Console.ReadLine();
                    if (newpass == newpass2)
                    {
                        user.password = newpass;
                        string fulllink = $"{path}{nameFileData}";
                        ReadWriteFile <ListUser> .WriteData(fulllink, listuser);

                        Console.WriteLine("Successfully!");
                    }
                }
                else
                {
                    Console.WriteLine("Wrong password! Enter again, please!");
                    ChangePass();
                }
            }
            else
            {
                Console.WriteLine("Username does not exist !!");
                ChangePass();
            }
        }
Exemple #11
0
        public void ReadData()
        {
            string fulllink = $@"{path}{nameFileData}";

            ReadWriteFile <Listorder> .ReadData(fulllink, ref listorder);
        }