Esempio n. 1
0
        private void eventClickBan(object sender, EventArgs e)
        {
            Ban          ban    = (Ban)(sender as IconButton).Tag;
            DialogResult result = new DialogResult();

            if (ban.Trangthai.Contains("empty")) // bàn trống gọi món
            {
                result = MessageBox.Show(String.Format("Bạn muốn gọi món cho {0} ?", ban.Tenban), "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    myParent.btnChonban.PerformClick();
                    myParent.btnthongtinban.Text = "Thông tin bàn " + ban.Tenban + "-" + ban.Makhuvuc;
                    myParent.btntrangthai.Text   = "Đang thực hiện gọi món";
                    myParent.btnthongtinban.Tag  = ban;
                }
            }
            else // bàn bận chỉ chỉnh sửa hoặc thanh toán.
            {
                result = MessageBox.Show(String.Format("Bạn muốn thanh toán hoặc chỉnh sửa {0} ?", ban.Tenban), "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    myParent.btnChonban.PerformClick();
                    myParent.ClearThanhToanInfo();
                    myParent.btnthongtinban.Text = "Thông tin bàn " + ban.Tenban + "-" + ban.Makhuvuc;
                    myParent.btntrangthai.Text   = "Đang thực hiện thanh toán / cập nhật";
                    myParent.btnthongtinban.Tag  = ban;
                    long tongtien = 0;
                    // lấy chi tiết hóa đơn đổ lên dgvhoadon.
                    String mahoadondanghoatdong = new BanDangHoatDong().getMaHoaDonFromMaBan(ban.Soban);
                    myParent.dgvhoadon.Rows.Clear();
                    List <ChiTietHoaDon> cthds = new ChiTietHoaDon().chiTietHoaDons(mahoadondanghoatdong);
                    foreach (ChiTietHoaDon item in cthds)
                    {
                        DataGridViewRow row = (DataGridViewRow)myParent.dgvhoadon.Rows[0].Clone();
                        row.Cells[0].Value = item.Mamon;
                        row.Cells[1].Value = item.Tenmon;
                        row.Cells[2].Value = item.Dvt;
                        row.Cells[3].Value = item.Dongia;
                        row.Cells[4].Value = item.Soluong;
                        row.Cells[5].Value = item.Dongia * item.Soluong;
                        tongtien          += Convert.ToInt64(row.Cells[5].Value);
                        DataGridViewCellStyle style = new DataGridViewCellStyle();
                        style.BackColor = Color.Blue;
                        row.Tag         = cthds.Count;
                        myParent.dgvhoadon.Rows.Add(row);
                    }
                    //thông số hóa đơn
                    myParent.btnthanhtien.ButtonText = tongtien.ToString("C0");
                    myParent.btnthanhtien.Tag        = tongtien;
                    myParent.btnvat.ButtonText       = ((double)tongtien * 0.1).ToString("C0");
                    myParent.btnvat.Tag = ((double)tongtien * 0.1);
                    myParent.txbtienkhachdua.Enabled = true;
                }
            }
        }