Exemplo n.º 1
0
        public static decimal GetTotal(int orderId)
        {
            POSDataContext     ctx          = new POSDataContext();
            var                orderdetails = from a in ctx.OrderDetails where a.OrderID == orderId select a;
            List <OrderDetail> orderDetails = new List <OrderDetail>(orderdetails.ToArray());

            decimal grandTotal      = 0;
            decimal orderTotal      = 0;
            decimal orderTotalDrink = 0;

            foreach (OrderDetail orderDetail in orderDetails)
            {
                if (orderDetail.CustomMenuPrice > 0)
                {
                    orderTotal += orderDetail.CustomMenuPrice * orderDetail.Quantity;
                }
                else
                {
                    orderTotal += orderDetail.MenuCard.Price * orderDetail.Quantity;
                }
            }

            grandTotal = orderTotalDrink + orderTotal;

            return(grandTotal);
        }
        public static bool TestDBConnection()
        {
            bool result = true;

            db = new POSDataContext(ConnectionString.connectionStringLinq);

            try
            {
                /// Hangs if connectionString is invalid rather than throw an exception
                db.Connection.Open();

                /// Initially, I was just trying to call DatabaseExists but, this hangs as well if the conn string is invalid
                if (!db.DatabaseExists())
                {
                    result = false;
                    throw new Exception("Database doesn't exist.");
                }
            }
            catch (Exception ex)
            {
                result = false;
                throw new Exception("Error:" + ex.Message + "\n\nDetailed Error: " + ex.StackTrace);
            }
            finally
            {
                DB.resetConnString();
            }

            return(result);
        }
Exemplo n.º 3
0
        private void txtQuantity_TextChanged(object sender, EventArgs e)
        {
            int quantity = 0;

            if (!string.IsNullOrEmpty(txtQuantity.Text))
            {
                quantity = Convert.ToInt32(this.txtQuantity.Text);
                SubTotal = quantity * Price;
            }
            else
            {
                SubTotal = 0;
            }
            using (POSDataContext ctx = new POSDataContext())
            {
                if (OrderDetailSelected != null)
                {
                    var item = from a in ctx.OrderDetails
                               where a.OrderDetailID == OrderDetailSelected.OrderDetailID
                               select a;
                    if (item != null)
                    {
                        if (item.Count() > 0)
                        {
                            var orderDetail = item.ToArray()[0];
                            orderDetail.Quantity = quantity;
                            ctx.SubmitChanges();
                        }
                    }
                }
            }
            OnRecalculateTotalHandler(e);
        }
Exemplo n.º 4
0
        private void btnClose_Click(object sender, EventArgs e)
        {
            POSDataContext db = new POSDataContext();
            //close table
            var ret = MessageBox.Show("Are you sure you want to close this table?",
                                      "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

            if (ret != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            int tableId = SelectedTable.TableID;
            var order   = from a in db.OrderKassas
                          where a.OrderID == _currentOrderId && a.TableID == tableId
                          select a;

            if (order.Count() > 0)
            {
                OrderKassa itemOrder = order.ToArray()[0];
                var        tab       = db.TableSeats.First(m => m.TableID == tableId);
                tab.TableStatus = "Free";

                var     details = from a in db.OrderDetails where a.OrderID == itemOrder.OrderID select a;
                decimal total   = 0;

                if (details.Count() > 0)
                {
                    foreach (var detail in details)
                    {
                        if (detail.CustomMenuPrice > 0)
                        {
                            total = total + detail.Quantity * detail.CustomMenuPrice;
                        }
                        else
                        {
                            total = total + detail.Quantity * detail.MenuCard.Price;
                        }
                    }
                    itemOrder.OrderTotal    = total;
                    itemOrder.IsComplete    = false;
                    itemOrder.CompletedDate = DateTime.Now;
                }
                else
                {
                    db.OrderKassas.DeleteOnSubmit(itemOrder);
                }

                db.SubmitChanges();
                this.OnBackToTablesHandler(e);
            }
            else
            {
                MessageBox.Show("Order was not found for this table");
            }
        }
Exemplo n.º 5
0
        public static string GetOrderName(POSDataContext ctx, int tableId)
        {
            var order = ctx.OrderKassas.Where(x => x.TableID == tableId && x.TableSeat.TableStatus.ToLower() == "occupied").OrderByDescending(x => x.OrderID).FirstOrDefault();

            if (order != null)
            {
                return(order.Name);
            }
            return(string.Empty);
        }
Exemplo n.º 6
0
        public static MenuCard UpdateMenuStock(int menuId, int updateValue)
        {
            POSDataContext db = new POSDataContext();

            var menuToUpdate = db.MenuCards.FirstOrDefault(x => x.id == menuId);

            menuToUpdate.Stock = updateValue;

            db.SubmitChanges();

            return(menuToUpdate);
        }
Exemplo n.º 7
0
        private void OrderDetailPopulate(int orderId)
        {
            POSDataContext db = new POSDataContext();

            panelRightContent.Controls.Clear();
            int index   = 0;
            var details = from a in db.OrderDetails
                          where a.OrderID == orderId
                          select a;

            decimal totalAll = 0;

            foreach (var detail in details)
            {
                ItemRowUserControl row = new ItemRowUserControl();
                row.Name = detail.MenuCardID.ToString();

                if (!string.IsNullOrEmpty(detail.CustomMenuName))
                {
                    row.ItemTitle = detail.CustomMenuName;
                    row.SubTotal  = detail.CustomMenuPrice * detail.Quantity;
                }
                else
                {
                    row.SubTotal  = detail.MenuCard.Price * detail.Quantity;
                    row.ItemTitle = detail.MenuCard.MenuName;
                }


                if (detail.CustomMenuPrice > 0)
                {
                    row.Price = detail.CustomMenuPrice;
                }
                else
                {
                    row.Price = detail.MenuCard.Price;
                }

                totalAll = totalAll + (row.SubTotal);
                row.OrderDetailSelected = detail;
                row.Quantity            = detail.Quantity.ToString();

                row.DeleteItemHandler       += new EventHandler <SelectedItemEventArgs>(row_DeleteItemHandler);
                row.RecalculateTotalHandler += new EventHandler <EventArgs>(row_RecalculateTotalHandler);
                panelRightContent.Controls.Add(row);

                row.Top  = 2 + index * 64;
                row.Left = 5;
                index++;
            }
            lbTotal.Text = "Rp. " + totalAll.ToString("N0");
        }
Exemplo n.º 8
0
        private void btnSaveName_Click(object sender, EventArgs e)
        {
            POSDataContext db           = new POSDataContext();
            var            currentOrder = db.OrderKassas.SingleOrDefault(x => x.OrderID == _currentOrderId);

            if (currentOrder != null)
            {
                currentOrder.Name = txtNamaPemesan.Text;
                db.SubmitChanges();
                MessageBox.Show("Nama Pemesan Telah Tersimpan.");
            }
            else
            {
                MessageBox.Show("Order tidak ditemukan, coba kembali.");
            }
        }
Exemplo n.º 9
0
        private void Initialize()
        {
            //PopulateMenus();
            POSDataContext db = new POSDataContext();

            panelRightContent.Controls.Clear();
            TableSeat seat = SelectedTable;

            //ctx.DetectChanges();
            ctx.SubmitChanges();
            if (seat.TableStatus.ToLower() == "occupied")
            {
                int id    = seat.TableID;
                var order = (from a in db.OrderKassas
                             where (a.TableID == id && a.IsComplete == false && a.OrderTotal == 0)
                             select a).ToList <OrderKassa>().LastOrDefault();
                if (order != null)
                {
                    _currentOrderId = order.OrderID;
                    OrderDetailPopulate(order.OrderID);
                    _currentOrder       = order;
                    txtNamaPemesan.Text = order.Name;
                }
            }
            else
            {
                int id    = seat.TableID;
                var table = from a in ctx.TableSeats where a.TableID == id select a;
                if (table.Count() > 0)
                {
                    var item = table.ToArray()[0];
                    item.TableStatus = "Occupied";

                    OrderKassa order = new OrderKassa();
                    order.OrderDate     = DateTime.Now;
                    order.IsComplete    = false;
                    order.Remarks       = string.Empty;
                    order.TableID       = id;
                    order.CompletedDate = DateTime.Now.AddDays(-1);

                    ctx.OrderKassas.InsertOnSubmit(order);
                    ctx.SubmitChanges();
                    _currentOrderId = order.OrderID;
                    _currentOrder   = order;
                }
            }
        }
Exemplo n.º 10
0
        private void btnDiskon_Click(object sender, EventArgs e)
        {
            int inputDiskon;

            if (!int.TryParse(txtDiskon.Text, out inputDiskon))
            {
                MessageBox.Show("Angka diskon salah!!!");
                return;
            }

            POSDataContext db           = new POSDataContext();
            var            currentOrder = db.OrderKassas.SingleOrDefault(x => x.OrderID == _currentOrderId);

            if (currentOrder != null)
            {
                currentOrder.Discount = inputDiskon;
                db.SubmitChanges();
                MessageBox.Show("Diskon Telah Tersimpan.");
            }
            else
            {
                MessageBox.Show("Order tidak ditemukan, coba kembali.");
            }
        }
Exemplo n.º 11
0
 public CategoryDAL(POSDataContext context)
 {
     _context = context;
 }
Exemplo n.º 12
0
 public CategoriesController(POSDataContext context)
 {
     _context = context;
 }
Exemplo n.º 13
0
        private void PopulateMenuCard()
        {
            POSDataContext posDb = new POSDataContext();

            panelLeft.Controls.Clear();
            this.lbTableTitle.Text = SelectedTable.TableName;
            int length      = this.Width - 560;
            int totalPerRow = 5;

            if (length <= 1024)
            {
                totalPerRow = 4;
            }

            var menus = posDb.MenuCards.Where(x => x.id != 1124).OrderBy(m => m.MenuGroupId);
            Dictionary <int, Color> colorKey = new Dictionary <int, Color>();

            Color[] colors = new Color[] { Color.Blue, Color.Green,
                                           Color.Yellow, Color.Pink, Color.BlueViolet, Color.DarkRed,
                                           Color.Aqua, Color.GreenYellow, Color.Cyan };
            int index    = 0;
            int row      = 0;
            int indexCol = 0;

            foreach (var menu in menus)
            {
                MenuUserControl uc = new MenuUserControl();
                uc.LabelControl.MouseClick += new MouseEventHandler(LabelControl_MouseClick);

                if (!colorKey.ContainsKey(menu.MenuGroupId))
                {
                    if (indexCol <= 8)
                    {
                        colorKey.Add(menu.MenuGroupId, colors[indexCol]);
                        indexCol++;
                    }
                }

                if (indexCol <= 8)
                {
                    uc.BackColor = colorKey[menu.MenuGroupId];
                }
                else
                {
                    uc.BackColor = Color.DarkSalmon;
                }

                var menuLabel = menu.MenuName + (menu.Stock.HasValue ? "(" + menu.Stock.Value.ToString() + ")" : " (0)");

                uc.TableControlTitle = menuLabel;
                uc.LabelControl.Tag  = menu;
                uc.Name = "Menu" + menu.id.ToString();
                panelLeft.Controls.Add(uc);
                if (index == 0)
                {
                    uc.Left = 5;
                }
                else
                {
                    uc.Left = 5 + (index * 160);
                }

                uc.Top = 10 + (row * 110);
                index++;
                if ((index + 1) > totalPerRow)
                {
                    index = 0;
                    row++;
                }
            }
        }
 public static void resetConnString()
 {
     db.Dispose();
     db = new POSDataContext(ConnectionString.connectionStringLinq);
 }
Exemplo n.º 15
0
        public static MenuCard GetMenuCard(int menuId)
        {
            POSDataContext db = new POSDataContext();

            return(db.MenuCards.FirstOrDefault(x => x.id == menuId));
        }
Exemplo n.º 16
0
        public void PopulateTables()
        {
            POSDataContext db = new POSDataContext();

            panelKassa.Controls.Clear();
            var tables = from a in db.TableSeats where a.IsDelete == false select a;

            if (tables.Count() > 0)
            {
                int length        = panelKassa.Width;
                int totalRowTable = (length - 5) / 210;
                int index         = 0;
                int row           = 0;
                foreach (var table in tables)
                {
                    TableUserControl uc = new TableUserControl();

                    uc.LabelControl.MouseClick += new MouseEventHandler(LabelControl_MouseClick);

                    var orderName = Helper.GetOrderName(db, table.TableID);

                    if (!string.IsNullOrEmpty(orderName))
                    {
                        uc.TableControlTitle = string.Format("{0}: {1}", table.TableName, orderName);
                    }

                    else
                    {
                        uc.TableControlTitle = table.TableName;
                    }

                    uc.LabelControl.Tag = table;

                    panelKassa.Controls.Add(uc);

                    if (index == 0)
                    {
                        uc.Left = 5;
                    }
                    else
                    {
                        uc.Left = 5 + (index * 210);
                    }

                    uc.ConfigureBackground(table.TableStatus);

                    uc.Top = 10 + (row * 90);

                    index++;

                    if ((index + 1) > totalRowTable)
                    {
                        index = 0;
                        row++;
                    }
                }

                dataGridTables.DataSource = ctx.TableSeats.ToArray();
                cboTables.DataSource      = ctx.TableSeats.ToArray();
                //dataGridMenus.DataSource = ctx.MenuCard;
                List <MenuGroup> list = new List <MenuGroup>(ctx.MenuGroups.ToArray());

                MenuGroup g = new MenuGroup();
                g.id        = 0;
                g.GroupName = "ALL";
                list.Add(g);
                cboFilter.DataSource    = list;
                cboFilter.SelectedValue = 0;
            }
        }
Exemplo n.º 17
0
        private void LabelControl_MouseClick(object sender, MouseEventArgs e)
        {
            POSDataContext posDb = new POSDataContext();
            MenuCard       menu  = Helper.GetMenuCard(((MenuCard)((Label)sender).Tag).id);

            if (menu.Stock.HasValue)
            {
                if (menu.Stock.Value <= 0)
                {
                    MessageBox.Show("Stok Habis!!!");
                    return;
                }
            }
            else
            {
                MessageBox.Show("Stok Habis!!!");
                return;
            }

            if (!panelRightContent.Controls.ContainsKey(menu.id.ToString()))
            {
                OrderDetail orderDetail = new OrderDetail();
                orderDetail.OrderID         = _currentOrderId;
                orderDetail.MenuCardID      = menu.id;
                orderDetail.Quantity        = 1;
                orderDetail.Remarks         = string.Empty;
                orderDetail.CustomMenuName  = string.Empty;
                orderDetail.CustomMenuPrice = 0;

                posDb.OrderDetails.InsertOnSubmit(orderDetail);
                posDb.SubmitChanges();

                ItemRowUserControl row = new ItemRowUserControl();
                row.Name      = menu.id.ToString();
                row.ItemTitle = menu.MenuName;
                row.Price     = menu.Price;
                row.SubTotal  = menu.Price;
                row.Quantity  = "1";
                decimal currentTotal = 0;
                if (lbTotal.Text.Trim().Length > 2)
                {
                    currentTotal = Convert.ToDecimal(lbTotal.Text.Replace("Rp.", ""));
                }
                decimal totalAll = currentTotal + row.SubTotal;
                row.OrderDetailSelected = orderDetail;
                //row.OrderDetailId = orderDetail.OrderDetailID;

                row.DeleteItemHandler       += new EventHandler <SelectedItemEventArgs>(row_DeleteItemHandler);
                row.RecalculateTotalHandler += new EventHandler <EventArgs>(row_RecalculateTotalHandler);
                panelRightContent.Controls.Add(row);

                row.Top  = 2 + (panelRightContent.Controls.Count - 1) * 64;
                row.Left = 5;

                lbTotal.Text = "Rp. " + totalAll.ToString("N0");
            }
            else
            {
                var item = from a in posDb.OrderDetails
                           where a.MenuCardID == menu.id && a.OrderID == _currentOrderId
                           select a;
                if (item.Count() > 0)
                {
                    var orderDetail = item.ToArray()[0];
                    orderDetail.Quantity = orderDetail.Quantity + 1;
                    posDb.SubmitChanges();

                    ((ItemRowUserControl)panelRightContent.Controls[menu.id.ToString()]).Quantity            = orderDetail.Quantity.ToString();
                    ((ItemRowUserControl)panelRightContent.Controls[menu.id.ToString()]).OrderDetailSelected = orderDetail;
                }
            }

            var stock = menu.Stock.HasValue ? (menu.Stock.Value - 1) : 0;

            UpdateMenuCard(menu.id, stock);
        }
Exemplo n.º 18
0
        public static void PrintOrder(POSDataContext ctx, OrderKassa order, bool btw, bool isKitchen, bool bni = false)
        {
            var orderdetails = from a in ctx.OrderDetails where a.OrderID == order.OrderID select a;
            List <OrderDetail> orderDetails = new List <OrderDetail>(orderdetails.ToArray());

            float fontSize = Convert.ToSingle(ConfigurationManager.AppSettings["FontSize"]);

            Font          printFont = new Font("Arial", fontSize);
            PrintDocument pd        = new PrintDocument();

            pd.PrinterSettings.PrinterName = ConfigurationManager.AppSettings["PrinterName"];

            if (isKitchen)
            {
                pd.PrinterSettings.PrinterName = ConfigurationManager.AppSettings["PrinterNameKitchen"];
            }

            string tableNameHeader = order.TableSeat.TableName + ": " + order.Name;
            string dateHeader      = "\nTanggal : " + order.OrderDate.ToLongDateString();

            decimal grandTotal            = 0;
            string  strBillSubtotal       = "";
            string  strBillSubtotalAmount = "";
            string  strBillBTW            = "";
            string  strBillBTWAmount      = "";
            string  strBillDrink          = "";
            string  strBillDrinkAmount    = "";
            string  strBillBTWDrink       = "";
            string  strBillBTWDrinkAmount = "";
            string  strBillTotal          = "";
            string  strBillTotalAmount    = "";
            string  strBillFooter         = "Terima kasih dan sampai jumpa";
            string  strBillDiskon         = "";
            string  strBillDiskonAmount   = "";

            pd.PrintPage += (s, ev) =>
            {
                float linesPerPage = 0;
                //not using
                //float yPos = 0;
                //int count = 0;
                float  leftMargin    = 10;
                float  topMargin     = 10;
                string currentLine   = null;
                Pen    p             = new Pen(Color.White, 1);
                float  lineHeight    = printFont.GetHeight(ev.Graphics);
                int    intLineHeight = (int)lineHeight;

                // Calculate the number of lines per page.
                linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics);

                StringFormat sfHeader = new StringFormat();
                sfHeader.Alignment = StringAlignment.Center;

                StringFormat sf = new StringFormat();
                sf.Alignment = StringAlignment.Near;

                StringFormat sfFar = new StringFormat();
                sfFar.Alignment = StringAlignment.Far;

                // header
                Rectangle rectHeader  = new Rectangle((int)leftMargin, (int)topMargin, 260, 50);
                Rectangle rectHeader2 = new Rectangle((int)leftMargin, rectHeader.Height + 20, 260, 35);
                ev.Graphics.DrawString("Meat Compiler", printFont, Brushes.Black, rectHeader, sfHeader);
                ev.Graphics.DrawString("\nTel: 0817-6328-000", printFont, Brushes.Black, rectHeader, sfHeader);
                ev.Graphics.DrawString("\n\nwww.meatcompiler.id", printFont, Brushes.Black, rectHeader, sfHeader);
                ev.Graphics.DrawString(tableNameHeader, printFont, Brushes.Black, rectHeader2, sf);
                ev.Graphics.DrawString(dateHeader, printFont, Brushes.Black, rectHeader2, sf);
                ev.Graphics.DrawRectangle(p, rectHeader);
                ev.Graphics.DrawRectangle(p, rectHeader2);

                int topMarginBody1 = 100;

                ev.Graphics.DrawLine(Pens.Black, (int)leftMargin, topMarginBody1, (int)leftMargin + 260, topMarginBody1);

                decimal orderTotal      = 0;
                decimal orderTotalDrink = 0;

                int topMarginBody = topMarginBody1 + 10;

                foreach (OrderDetail orderDetail in orderDetails)
                {
                    Rectangle rectBodyLeft  = new Rectangle((int)leftMargin, topMarginBody, 200, intLineHeight);
                    Rectangle rectBodyright = new Rectangle(rectBodyLeft.Width + 5 - 40, topMarginBody, 100, intLineHeight);

                    string menuNameBill   = "";
                    string menuAmountBill = "";

                    if (orderDetail.CustomMenuPrice > 0)
                    {
                        orderTotal    += orderDetail.CustomMenuPrice * orderDetail.Quantity;
                        menuNameBill   = orderDetail.Quantity + "x " + orderDetail.CustomMenuName;
                        menuAmountBill = Helper.FormatPrice(orderDetail.CustomMenuPrice * orderDetail.Quantity);
                    }
                    else
                    {
                        orderTotal    += orderDetail.MenuCard.Price * orderDetail.Quantity;
                        menuNameBill   = orderDetail.Quantity + "x " + orderDetail.MenuCard.MenuName;
                        menuAmountBill = Helper.FormatPrice(orderDetail.MenuCard.Price * orderDetail.Quantity);
                    }

                    ev.Graphics.DrawString(menuNameBill, printFont, Brushes.Black, rectBodyLeft, sf);
                    ev.Graphics.DrawString(menuAmountBill, printFont, Brushes.Black, rectBodyright, sfFar);

                    ev.Graphics.DrawRectangle(p, rectBodyLeft);
                    ev.Graphics.DrawRectangle(p, rectBodyright);

                    topMarginBody = topMarginBody + intLineHeight + 5;
                }


                grandTotal         = orderTotalDrink + orderTotal;
                strBillTotal       = "Total ";
                strBillTotalAmount = Helper.FormatPrice(grandTotal);

                int topMarginFooter1     = topMarginBody + 15; // bodyHeight + 5;
                int topMarginFooter      = topMarginFooter1 + 15;
                int topMarginFooterFinal = topMarginFooter;

                ev.Graphics.DrawLine(Pens.Black, (int)leftMargin, topMarginFooter1, (int)leftMargin + 260, topMarginFooter1);

                POSDataContext db       = new POSDataContext();
                var            theOrder = db.OrderKassas.FirstOrDefault(x => x.OrderID == order.OrderID);
                if (theOrder.Discount > 0)
                {
                    strBillSubtotal       = "Subtotal: ";
                    strBillSubtotalAmount = Helper.FormatPrice(grandTotal);
                    int subTotalTopMargin = topMarginFooter + intLineHeight + 5;

                    Rectangle rectFooterSubtotal       = new Rectangle((int)leftMargin, subTotalTopMargin, 200, intLineHeight);
                    Rectangle rectFooterSubtotalAmount = new Rectangle(rectFooterSubtotal.Width + 5 - 40, topMarginFooter, 100, intLineHeight);

                    ev.Graphics.DrawString(strBillSubtotal, printFont, Brushes.Black, rectFooterSubtotal, sf);
                    ev.Graphics.DrawString(strBillSubtotalAmount, printFont, Brushes.Black, rectFooterSubtotalAmount, sfFar);

                    strBillDiskon       = "Diskon: ";
                    strBillDiskonAmount = (grandTotal * (order.Discount / 100)).ToString("N0");
                    int diskonTopMargin = subTotalTopMargin + intLineHeight + 5;

                    grandTotal         = grandTotal - (grandTotal * (order.Discount / 100));
                    strBillTotalAmount = Helper.FormatPrice(grandTotal);

                    Rectangle rectFooterDiskon       = new Rectangle((int)leftMargin, diskonTopMargin, 200, intLineHeight);
                    Rectangle rectFooterDiskonAmount = new Rectangle(rectFooterDiskon.Width + 5 - 40, diskonTopMargin, 100, intLineHeight);

                    ev.Graphics.DrawString(strBillDiskon, printFont, Brushes.Black, rectFooterDiskon, sf);
                    ev.Graphics.DrawString(strBillDiskonAmount, printFont, Brushes.Black, rectFooterDiskonAmount, sfFar);
                }

                if (bni)
                {
                    decimal cardChargeAmount = grandTotal * (decimal)(0.02);
                    decimal subTotal         = grandTotal;

                    strBillSubtotal       = "Subtotal: ";
                    strBillSubtotalAmount = Helper.FormatPrice(subTotal);

                    strBillBTW       = "Card Charge 2%: ";
                    strBillBTWAmount = Helper.FormatPrice(cardChargeAmount);

                    Rectangle rectFooterSubtotal       = new Rectangle((int)leftMargin, topMarginFooter, 200, intLineHeight);
                    Rectangle rectFooterSubtotalAmount = new Rectangle(rectFooterSubtotal.Width + 5 - 40, topMarginFooter, 100, intLineHeight);
                    int       btwTopMargin             = topMarginFooter + intLineHeight + 5;

                    Rectangle rectFooterBTW       = new Rectangle((int)leftMargin, btwTopMargin, 200, intLineHeight);
                    Rectangle rectFooterBTWAmount = new Rectangle(rectFooterBTW.Width + 5 - 40, btwTopMargin, 100, intLineHeight);

                    ev.Graphics.DrawString(strBillSubtotal, printFont, Brushes.Black, rectFooterSubtotal, sf);
                    ev.Graphics.DrawString(strBillSubtotalAmount, printFont, Brushes.Black, rectFooterSubtotalAmount, sfFar);
                    ev.Graphics.DrawString(strBillBTW, printFont, Brushes.Black, rectFooterBTW, sf);
                    ev.Graphics.DrawString(strBillBTWAmount, printFont, Brushes.Black, rectFooterBTWAmount, sfFar);

                    ev.Graphics.DrawRectangle(p, rectFooterSubtotal);
                    ev.Graphics.DrawRectangle(p, rectFooterSubtotalAmount);
                    ev.Graphics.DrawRectangle(p, rectFooterBTW);
                    ev.Graphics.DrawRectangle(p, rectFooterBTWAmount);

                    topMarginFooterFinal = btwTopMargin + intLineHeight + 5;

                    grandTotal         = subTotal + cardChargeAmount;
                    strBillTotalAmount = Helper.FormatPrice(grandTotal);
                }

                if (btw)
                {
                    decimal btwAmount = orderTotal * (decimal)((decimal)6 / (decimal)106);
                    decimal subTotal  = orderTotal - btwAmount;

                    strBillSubtotal       = "Subtotal: ";
                    strBillSubtotalAmount = Helper.FormatPrice(subTotal);

                    strBillBTW       = "BTW 6%: ";
                    strBillBTWAmount = Helper.FormatPrice(btwAmount);

                    Rectangle rectFooterSubtotal       = new Rectangle((int)leftMargin, topMarginFooter, 200, intLineHeight);
                    Rectangle rectFooterSubtotalAmount = new Rectangle(rectFooterSubtotal.Width + 5, topMarginFooter, 60, intLineHeight);
                    int       btwTopMargin             = topMarginFooter + intLineHeight + 5;

                    Rectangle rectFooterBTW       = new Rectangle((int)leftMargin, btwTopMargin, 200, intLineHeight);
                    Rectangle rectFooterBTWAmount = new Rectangle(rectFooterBTW.Width + 5, btwTopMargin, 60, intLineHeight);

                    ev.Graphics.DrawString(strBillSubtotal, printFont, Brushes.Black, rectFooterSubtotal, sf);
                    ev.Graphics.DrawString(strBillSubtotalAmount, printFont, Brushes.Black, rectFooterSubtotalAmount, sfFar);
                    ev.Graphics.DrawString(strBillBTW, printFont, Brushes.Black, rectFooterBTW, sf);
                    ev.Graphics.DrawString(strBillBTWAmount, printFont, Brushes.Black, rectFooterBTWAmount, sfFar);

                    ev.Graphics.DrawRectangle(p, rectFooterSubtotal);
                    ev.Graphics.DrawRectangle(p, rectFooterSubtotalAmount);
                    ev.Graphics.DrawRectangle(p, rectFooterBTW);
                    ev.Graphics.DrawRectangle(p, rectFooterBTWAmount);

                    topMarginFooterFinal = btwTopMargin + intLineHeight + 5;

                    if (orderTotalDrink > 0)
                    {
                        decimal btwAmountDrink = orderTotalDrink * (decimal)((decimal)19 / (decimal)119);
                        decimal subTotalDrink  = orderTotalDrink - btwAmountDrink;
                        strBillDrink          = "Alcoholic Drink: ";
                        strBillDrinkAmount    = Helper.FormatPrice(subTotalDrink);
                        strBillBTWDrink       = "BTW 19%: ";
                        strBillBTWDrinkAmount = Helper.FormatPrice(btwAmountDrink);

                        Rectangle rectFooterDrink       = new Rectangle((int)leftMargin, topMarginFooterFinal, 200, intLineHeight);
                        Rectangle rectFooterDrinkAmount = new Rectangle(rectFooterDrink.Width + 5, topMarginFooterFinal, 60, intLineHeight);

                        topMarginFooterFinal = topMarginFooterFinal + intLineHeight + 5;
                        Rectangle rectFooterBTWDrink       = new Rectangle((int)leftMargin, topMarginFooterFinal, 200, intLineHeight);
                        Rectangle rectFooterBTWDrinkAmount = new Rectangle(rectFooterBTW.Width + 5, topMarginFooterFinal, 60, intLineHeight);

                        ev.Graphics.DrawString(strBillDrink, printFont, Brushes.Black, rectFooterDrink, sf);
                        ev.Graphics.DrawString(strBillDrinkAmount, printFont, Brushes.Black, rectFooterDrinkAmount, sfFar);
                        ev.Graphics.DrawString(strBillBTWDrink, printFont, Brushes.Black, rectFooterBTWDrink, sf);
                        ev.Graphics.DrawString(strBillBTWDrinkAmount, printFont, Brushes.Black, rectFooterBTWDrinkAmount, sfFar);

                        ev.Graphics.DrawRectangle(p, rectFooterDrink);
                        ev.Graphics.DrawRectangle(p, rectFooterDrinkAmount);
                        ev.Graphics.DrawRectangle(p, rectFooterBTWDrink);
                        ev.Graphics.DrawRectangle(p, rectFooterBTWDrinkAmount);

                        topMarginFooterFinal = topMarginFooterFinal + intLineHeight + 5;
                    }
                }

                Rectangle rectFooterTotal       = new Rectangle((int)leftMargin, topMarginFooterFinal, 200, intLineHeight);
                Rectangle rectFooterTotalAmount = new Rectangle(rectFooterTotal.Width + 5 - 40, topMarginFooterFinal, 100, intLineHeight);
                Rectangle rectFooterClose       = new Rectangle((int)leftMargin, topMarginFooterFinal + intLineHeight + 30, 260, intLineHeight);

                ev.Graphics.DrawString(strBillTotal, printFont, Brushes.Black, rectFooterTotal, sf);
                ev.Graphics.DrawString(strBillTotalAmount, printFont, Brushes.Black, rectFooterTotalAmount, sfFar);
                ev.Graphics.DrawString(strBillFooter, printFont, Brushes.Black, rectFooterClose, sfHeader);

                ev.Graphics.DrawRectangle(p, rectFooterTotal);
                ev.Graphics.DrawRectangle(p, rectFooterTotalAmount);
                ev.Graphics.DrawRectangle(p, rectFooterClose);

                // If more lines exist, print another page.
                if (currentLine != null)
                {
                    ev.HasMorePages = true;
                    currentLine     = null;
                }
                else
                {
                    ev.HasMorePages = false;
                }
            };

            pd.EndPrint += (s, ev) =>
            {
            };

            pd.Print();
        }