//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; } }
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); } } }
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"; }