Beispiel #1
0
        private void btnAddAfter_Click(object sender, EventArgs e)
        {
            Validation validation = new Validation();

            string content = "";

            content += validation.Check_Empty("ID", txtIDAdd);
            content += validation.Check_Empty("Name", txtNameAdd);
            content += validation.Check_Empty("Promotion", txtPromotionAdd);
            content += validation.Check_Empty("Price", txtPriceAdd);
            content += validation.Check_Empty("After ID", txtIDAfter);
            if (content != "")
            {
                MessageBox.Show(content, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                LinkedListHD <DoUong> .Node NodeDoUong = Form2.menu.pHead;
                while (NodeDoUong != null)
                {
                    if (NodeDoUong.data.ID.ToString() == txtIDAdd.Text)
                    {
                        MessageBox.Show("ID đã tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtIDAdd.Text = "";
                        return;
                    }
                    NodeDoUong = NodeDoUong.pNext;
                }
                DoUong douong = new DoUong();
                douong.ID        = int.Parse(txtIDAdd.Text);
                douong.Name      = txtNameAdd.Text;
                douong.Promotion = int.Parse(txtPromotionAdd.Text);
                douong.Price     = double.Parse(txtPriceAdd.Text);

                LinkedListHD <DoUong> .Node pSearch = Form2.menu.pHead;
                while (pSearch != null)
                {
                    if (pSearch.data.ID == int.Parse(txtIDAfter.Text))
                    {
                        Form2.menu.AddAfter(douong, pSearch);
                        MessageBox.Show("Đồ uống đã được thêm vào menu.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.None);
                        txtIDAdd.Text        = "";
                        txtNameAdd.Text      = "";
                        txtPromotionAdd.Text = "";
                        txtPriceAdd.Text     = "";
                        txtIDAfter.Text      = "";
                        return;
                    }
                    pSearch = pSearch.pNext;
                }
                MessageBox.Show("Không tìm thấy After ID. Đồ uống được thêm vào cuối menu.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Form2.menu.Add(douong);
            }
        }
Beispiel #2
0
        //public double Price_Min(LinkedListHD<DoUong> D)
        //{
        //    LinkedListHD<DoUong>.Node Node = D.pHead;
        //    double min = Node.data.Price;
        //    while (Node != null)
        //    {
        //        if (Node.data.Price < min)
        //        {
        //            min = Node.data.Price;
        //        }
        //        Node = Node.pNext;
        //    }
        //    return min;
        //}

        private void btnIncrease_Click(object sender, EventArgs e)
        {
            LinkedListHD <DoUong> increase = new LinkedListHD <DoUong>();


            double temp = 0;

            while (increase.count != Form2.menu.count)
            {
                double min = 10000000000;
                LinkedListHD <DoUong> .Node NodeDoUong = Form2.menu.pHead;

                while (NodeDoUong != null)
                {
                    if (NodeDoUong.data.Price <= min && NodeDoUong.data.Price > temp)
                    {
                        min = NodeDoUong.data.Price;
                    }
                    NodeDoUong = NodeDoUong.pNext;
                }

                LinkedListHD <DoUong> .Node Node = Form2.menu.pHead;

                while (Node != null)
                {
                    if (Node.data.Price == min)
                    {
                        DoUong douong = Node.data;
                        increase.Add(douong);
                    }
                    Node = Node.pNext;
                }
                temp = min;
            }


            txbMoney.Text = "";
            LinkedListHD <DoUong> .Node PrintNode = increase.pHead;
            while (PrintNode != null)
            {
                if (PrintNode.data.ID.ToString().Length < 2)
                {
                    txbMoney.Text += PrintNode.data.ID + "                   " + PrintNode.data.Price + "\r\n";
                }
                else
                {
                    txbMoney.Text += PrintNode.data.ID + "                 " + PrintNode.data.Price + "\r\n";
                }
                PrintNode = PrintNode.pNext;
            }
        }
Beispiel #3
0
        public void createDatabase()
        {
            string dsnuoc    = @"C:\Users\Admin\Desktop\New folder\DoAn1\Doan1\Doan1\bin\Debug\dsnuoc.txt";
            string giatien   = @"C:\Users\Admin\Desktop\New folder\DoAn1\Doan1\Doan1\bin\Debug\gia.txt";
            string khuyenmai = @"C:\Users\Admin\Desktop\New folder\DoAn1\Doan1\Doan1\bin\Debug\dskhuyenmai.txt";

            string[] arrnuoc;
            string[] arrgia;
            string[] arrkhuyenmai;

            if (System.IO.File.Exists(dsnuoc))
            {
                string n1, n2, t2, k2;
                arrnuoc      = System.IO.File.ReadAllLines(dsnuoc);
                arrgia       = System.IO.File.ReadAllLines(giatien);
                arrkhuyenmai = System.IO.File.ReadAllLines(khuyenmai);

                for (int i = 0; i < arrnuoc.Length; i++)
                {
                    DoUong douong = new DoUong();
                    string s      = arrnuoc[i];
                    string x      = arrgia[i];
                    string k      = arrkhuyenmai[i];

                    n1 = s.Substring(0, 3).Trim();
                    n2 = s.Substring(3).Trim();

                    t2 = x.Substring(3).Trim();

                    k2 = k.Substring(3).Trim();

                    douong.ID        = int.Parse(n1);
                    douong.Name      = n2;
                    douong.Promotion = int.Parse(k2);
                    douong.Price     = double.Parse(t2);

                    menu.Add(douong);
                }
            }
        }
Beispiel #4
0
        private void btnAddOrder_Click(object sender, EventArgs e)
        {
            Validation validation = new Validation();

            string content = "";

            content += validation.Check_Empty("Name Cus", txtNameCusOrder);
            content += validation.Check_Empty("ID", txtIDOrder);
            content += validation.Check_Empty("Amount", txtAmountOrder);

            if (content != "")
            {
                MessageBox.Show(content, "Validation", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                int test = 0;
                LinkedListHD <DoUong> .Node NodeDoUong = menu.pHead;

                while (NodeDoUong != null)
                {
                    if (NodeDoUong.data.ID.ToString() == txtIDOrder.Text)
                    {
                        test = 1;
                    }
                    NodeDoUong = NodeDoUong.pNext;
                }

                if (test == 0)
                {
                    MessageBox.Show("ID đồ uống không tồn tại trong menu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                Total += double.Parse(lblPriceOrder.Text);
                if (Total <= 0)
                {
                    lblTotalOrder.Text = "";
                }
                else
                {
                    lblTotalOrder.Text = Total + "";
                }

                LinkedListHD <DoUong> .Node Node = menu.pHead;

                while (Node != null)
                {
                    if (Node.data.ID.ToString() == txtIDOrder.Text)
                    {
                        DoUong douong = Node.data;
                        LinkedListHD <HoaDon> .Node NodeHoaDon = dsHoaDon.pHead;
                        while (NodeHoaDon != null)
                        {
                            if (NodeHoaDon.data.douong.ID.ToString() == txtIDOrder.Text)
                            {
                                NodeHoaDon.data.Count += int.Parse(txtAmountOrder.Text);
                                hoadon.Total          += double.Parse(lblPriceOrder.Text);
                                txtAmountOrder.Text    = "1";
                                if (NodeHoaDon.data.Count <= 0)
                                {
                                    dsHoaDon.Remove(NodeHoaDon);
                                }
                                return;
                            }
                            NodeHoaDon = NodeHoaDon.pNext;
                        }
                        hoadon              = new HoaDon();
                        hoadon.IdHD         = IDHoaDon;
                        hoadon.CustomerName = txtNameCusOrder.Text;
                        hoadon.Total       += double.Parse(lblPriceOrder.Text);
                        hoadon.douong       = douong;
                        hoadon.Count        = int.Parse(txtAmountOrder.Text);
                        dsHoaDon.Add(hoadon);
                    }
                    Node = Node.pNext;
                }
            }
            txtAmountOrder.Text = "1";
        }
Beispiel #5
0
 public HoaDon()
 {
     Count  = 0;
     douong = new DoUong();
 }