public EditInvoiceViewModel(Invoice invoice) : base(invoice)
        {
            EditEnabled = true;
            Validator   = new Validation.InvoiceValidator(this);

            if (Model.IsNew)
            {
                DisplayName = "Uusi lasku";
                if (Model.Titles.Count < 1)
                {
                    NewTitle.Execute();
                }
            }
            else
            {
                DisplayName = "Lasku " + (InvoiceID == null ? Status : InvoiceID.ToString()) + (Customer == null ? null : " - " + Customer.Name);
            }

            if (Paid != null)
            {
                IsEnabled = false;
            }

            CustomerList = new CustomerListViewModel(Resources.GetModels <Customer>());
            if (Model.Customer != null)
            {
                CustomerList.SelectedItem = CustomerList.FindByID(Model.Customer.ID) as CustomerViewModel;
            }

            CustomerList.SelectionChanged += CustomerListSelectionChanged;

            Send      = new CommandViewModel("Laskuta", OnSend, CanSend);
            Pay       = new CommandViewModel("Merkitse maksupäivä", OnPay, CanPay);
            SavePay   = new CommandViewModel("Aseta päiväys", OnSavePay);
            CancelPay = new CommandViewModel("Peruuta", OnCancelPay);
        }
Exemplo n.º 2
0
        void rcpt_PrintPage(object sender, PrintPageEventArgs e)
        {
            // Initialize printing stuff
            Graphics g = e.Graphics;

            Font  font  = new Font("Arial", 12);
            Brush brush = Brushes.Black;

            StringFormat leftAlign = new StringFormat()
            {
                Alignment = StringAlignment.Near
            };
            StringFormat rightAlign = new StringFormat()
            {
                Alignment = StringAlignment.Far
            };
            StringFormat centerAlign = new StringFormat()
            {
                Alignment = StringAlignment.Center
            };

            RectangleF cursor = new RectangleF(e.PageBounds.X, e.PageBounds.Y, e.PageBounds.Width, font.Height);

            // Print Logo
            g.DrawImage(logo, cursor.Width / 2 - logo.Width / 2, cursor.Top);
            cursor.Y += logo.Height;

            // Print InvoiceID Barcode
            g.DrawString(InvoiceID.ToString(), font, brush, cursor, leftAlign);
            cursor.Y += font.Height;

            // Print Header
            g.DrawString(header, font, brush, cursor, centerAlign);
            cursor.Y += font.Height; //TODO: Will nee to handle multiline headers well

            // Print InvoiceID
            g.DrawString("Invoice #: " + InvoiceID.ToString(), font, brush, cursor, leftAlign);


            // Print Location
            g.DrawString("Location" + Location, font, brush, cursor, rightAlign);
            cursor.Y += font.Height;

            // Date and time
            g.DrawString("Date and time: " + TransactionDateTime.ToString(), font, brush, cursor, leftAlign);
            cursor.Y += font.Height;

            // Print Items
            g.DrawString("---------------------------------", font, brush, cursor, leftAlign);
            cursor.Y += font.Height;

            foreach (Item item in Items)
            {
                g.DrawString(item.NumSold + " " + item.Name, font, brush, cursor, leftAlign);
                g.DrawString("$ " + item.Price.ToString(), font, brush, cursor, rightAlign);
                cursor.Y += font.Height;
            }

            g.DrawString("---------------------------------", font, brush, cursor, leftAlign);
            cursor.Y += font.Height;

            // Print subtotal
            g.DrawString("SubTotal:", font, brush, cursor, leftAlign);
            g.DrawString("$ " + Subtotal.ToString(), font, brush, cursor, rightAlign);
            cursor.Y += font.Height;

            // Print tax
            g.DrawString("Tax:", font, brush, cursor, leftAlign);
            g.DrawString("$ " + Tax.ToString(), font, brush, cursor, rightAlign);
            cursor.Y += font.Height;

            // Print total
            g.DrawString("TOTAL:", font, brush, cursor, leftAlign);
            g.DrawString("$ " + Total.ToString(), font, brush, cursor, rightAlign);
            cursor.Y += font.Height;

            g.DrawString("---------------------------------", font, brush, cursor, leftAlign);
            cursor.Y += font.Height;

            // Print # of items
            g.DrawString("# of Items: " + Items.Count.ToString(), font, brush, cursor, leftAlign);
            cursor.Y += font.Height;

            // Print Payment Method
            // Print # of items
            g.DrawString("Payment Method: " + PayMethod + ": " + PayNum, font, brush, cursor, leftAlign);
            cursor.Y += font.Height;

            //Print footer
            // Print # of items
            g.DrawString(footer, font, brush, cursor, centerAlign);
            cursor.Y += font.Height; //TODO: Will nee to handle multiline footers well
        }
Exemplo n.º 3
0
        // Event handler for printing receipt
        void rcpt_PrintPage(object sender, PrintPageEventArgs e)
        {
            // Initialize printing stuff
            Graphics g = e.Graphics;

            Font font        = new Font("Arial", 10);
            Font barcodeFont = new Font("Free 3 of 9", 36); //Will default to Sans Serif if not installed

            float lSpacing = 5F;
            Brush brush    = Brushes.Black;
            Pen   pen      = new Pen(brush);

            StringFormat leftAlign = new StringFormat()
            {
                Alignment = StringAlignment.Near
            };
            StringFormat centerAlign = new StringFormat()
            {
                Alignment = StringAlignment.Center
            };
            StringFormat rightAlign = new StringFormat()
            {
                Alignment = StringAlignment.Far
            };

            RectangleF cursor = new RectangleF(e.PageBounds.X, e.PageBounds.Y, e.PageBounds.Width, font.Height);

            // Print Logo
            g.DrawImage(logo, cursor.Width / 2 - logo.Width / 2, cursor.Top);
            cursor.Y += logo.Height + lSpacing;

            // Print InvoiceID Barcode
            cursor = printText("*" + InvoiceID.ToString() + "*", true, g, barcodeFont, brush, cursor, centerAlign, lSpacing);

            // Print Header
            cursor = printHeaderFooter(header, g, font, brush, cursor, centerAlign, lSpacing);

            // Print InvoiceID
            cursor = printText("Invoice #: " + InvoiceID.ToString(), true, g, font, brush, cursor, leftAlign, lSpacing);

            // Print RegisterID
            cursor = printText("Register ID: " + RegisterID.ToString(), false, g, font, brush, cursor, leftAlign, lSpacing);

            // Print Location
            cursor = printText("Location: " + Location, true, g, font, brush, cursor, rightAlign, lSpacing);

            // Date and time
            cursor = printText("Date and time: " + TransactionDateTime.ToString(), true, g, font, brush, cursor, leftAlign, lSpacing);

            // Print Separator
            cursor = printHorizontalLine(g, font, pen, cursor, lSpacing);

            // Print Items
            foreach (Item item in Items)
            {
                cursor = printText(item.NumSold + " " + item.Name, false, g, font, brush, cursor, leftAlign, lSpacing);
                cursor = printText("$ " + item.Price.ToString(), true, g, font, brush, cursor, rightAlign, lSpacing);
            }

            // Print Separator
            cursor = printHorizontalLine(g, font, pen, cursor, lSpacing);

            // Print subtotal
            cursor = printText("SubTotal:", false, g, font, brush, cursor, leftAlign, lSpacing);
            cursor = printText("$ " + Subtotal.ToString(), true, g, font, brush, cursor, rightAlign, lSpacing);

            // Print tax
            cursor = printText("Tax:", false, g, font, brush, cursor, leftAlign, lSpacing);
            cursor = printText("$ " + Tax.ToString(), true, g, font, brush, cursor, rightAlign, lSpacing);

            // Print total
            cursor = printText("TOTAL:", false, g, font, brush, cursor, leftAlign, lSpacing);
            cursor = printText("$ " + Total.ToString(), true, g, font, brush, cursor, rightAlign, lSpacing);

            // Print Separator
            cursor = printHorizontalLine(g, font, pen, cursor, lSpacing);

            // Print # of items
            cursor = printText("# of Items: " + Items.Count.ToString(), true, g, font, brush, cursor, leftAlign, lSpacing);

            // Print Payment Method
            cursor = printText("Payment Method: " + PayMethod + ": " + PayNum, true, g, font, brush, cursor, leftAlign, lSpacing);

            //Print footer
            cursor = printHeaderFooter(footer, g, font, brush, cursor, centerAlign, lSpacing);
        }