Exemple #1
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 #2
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 #3
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 #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
        //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 #6
0
        // Thêm user
        public void Adduser()
        {
            listuser.Listuser.Add(newuser());
            string fulllink = $"{path}{nameFileData}";

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

            Console.WriteLine("Successfully!");
        }
Exemple #7
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 #8
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 #9
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();
            }
        }