コード例 #1
0
        private void AddTotalBoxes(int customerID)
        {
            Customer    cust        = CustomerDatabase.SearchCustomersByID(customerID);
            ProvinceTax provinceTax = ProvinceTaxDatabase.GetProvinceByName(cust.Province);

            Label subtotalLabel = new Label();

            subtotalLabel.Text     = "Subtotal";
            subtotalLabel.Location = new Point(562, 500);
            subtotalLabel.AutoSize = true;
            this.Controls.Add(subtotalLabel);

            TextBox subtotalAmount = new TextBox();

            subtotalAmount.Location       = new Point(610, 500);
            subtotalAmount.Size           = new Size(50, 25);
            subtotalAmount.Text           = invoice.SubTotal.ToString("0.00");
            subtotalAmount.ReadOnly       = true;
            subtotalAmount.Name           = "subtotalAmount";
            subtotalAmount.AccessibleName = "subtotalAmount";
            subtotalAmount.TextChanged   += SubtotalAmount_TextChanged;
            this.Controls.Add(subtotalAmount);

            Label feightLabel = new Label();

            feightLabel.Text      = "Freight";
            feightLabel.Location  = new Point(570, 530);
            feightLabel.AutoSize  = true;
            feightLabel.TextAlign = ContentAlignment.TopRight;
            this.Controls.Add(feightLabel);

            TextBox freight = new TextBox();

            freight.Location       = new Point(610, 530);
            freight.Size           = new Size(50, 25);
            freight.Name           = "freight";
            freight.AccessibleName = "freight";
            freight.TextChanged   += Freight_TextChanged;
            freight.KeyPress      += Freight_KeyPress;
            this.Controls.Add(freight);

            Label subtotalWithFreightLabel = new Label();

            subtotalWithFreightLabel.Text      = "Subtotal w/ Freight";
            subtotalWithFreightLabel.Location  = new Point(510, 560);
            subtotalWithFreightLabel.AutoSize  = true;
            subtotalWithFreightLabel.TextAlign = ContentAlignment.TopRight;
            this.Controls.Add(subtotalWithFreightLabel);

            TextBox subtotalWithFreight = new TextBox();

            subtotalWithFreight.Location       = new Point(610, 560);
            subtotalWithFreight.Size           = new Size(50, 25);
            subtotalWithFreight.Name           = "subtotalWithFreight";
            subtotalWithFreight.AccessibleName = "subtotalWithFreight";
            subtotalWithFreight.TextChanged   += SubtotalWithFreight_TextChanged;
            subtotalWithFreight.ReadOnly       = true;
            this.Controls.Add(subtotalWithFreight);

            Label gstLabel = new Label();

            gstLabel.Text      = "GST " + provinceTax.gst + "%";
            gstLabel.Location  = new Point(560, 590);
            gstLabel.Size      = new Size(50, 25);
            gstLabel.TextAlign = ContentAlignment.TopRight;
            this.Controls.Add(gstLabel);

            TextBox gst = new TextBox();

            gst.Location       = new Point(610, 590);
            gst.Size           = new Size(50, 25);
            gst.Text           = invoice.Gst.ToString("0.00");
            gst.ReadOnly       = true;
            gst.Name           = "gst";
            gst.AccessibleName = "gst";
            this.Controls.Add(gst);

            if (PST)
            {
                Label pstLabel = new Label();
                pstLabel.Text      = "PST " + provinceTax.pst + "%";
                pstLabel.Location  = new Point(560, 620);
                pstLabel.Size      = new Size(50, 25);
                pstLabel.TextAlign = ContentAlignment.TopRight;
                this.Controls.Add(pstLabel);

                TextBox pst = new TextBox();
                pst.Location       = new Point(610, 620);
                pst.Size           = new Size(50, 25);
                pst.Text           = invoice.Pst.ToString("0.00");
                pst.ReadOnly       = true;
                pst.Name           = "pst";
                pst.AccessibleName = "pst";
                this.Controls.Add(pst);


                Label invoiceTotalLabel = new Label();
                invoiceTotalLabel.Text     = "Invoice Total";
                invoiceTotalLabel.Location = new Point(540, 650);
                invoiceTotalLabel.AutoSize = true;
                this.Controls.Add(invoiceTotalLabel);

                TextBox invoiceTotal = new TextBox();
                invoiceTotal.Location       = new Point(610, 650);
                invoiceTotal.Size           = new Size(50, 25);
                invoiceTotal.Text           = invoice.NetTotal.ToString("0.00");
                invoiceTotal.ReadOnly       = true;
                invoiceTotal.Name           = "invoiceTotal";
                invoiceTotal.AccessibleName = "invoiceTotal";
                this.Controls.Add(invoiceTotal);
            }
            else //no pst
            {
                Label invoiceTotalLabel = new Label();
                invoiceTotalLabel.Text     = "Invoice Total";
                invoiceTotalLabel.Location = new Point(540, 620);
                invoiceTotalLabel.AutoSize = true;
                this.Controls.Add(invoiceTotalLabel);

                TextBox invoiceTotal = new TextBox();
                invoiceTotal.Location       = new Point(610, 620);
                invoiceTotal.Size           = new Size(50, 25);
                invoiceTotal.Text           = invoice.NetTotal.ToString("0.00");
                invoiceTotal.ReadOnly       = true;
                invoiceTotal.Name           = "invoiceTotal";
                invoiceTotal.AccessibleName = "invoiceTotal";
                this.Controls.Add(invoiceTotal);
            }
        }
コード例 #2
0
        private void AddLabels(int customerID)
        {
            int x = 30;
            int y = 150;

            Customer    cust        = CustomerDatabase.SearchCustomersByID(customerID);
            ProvinceTax provinceTax = ProvinceTaxDatabase.GetProvinceByName(cust.Province);

            //customer labels
            Label storeNameLabel = new Label();

            if (cust.StoreDetails.Length != 0)
            {
                storeNameLabel.Text = "Store name: " + cust.StoreName + " - " + cust.StoreDetails;
            }
            else
            {
                storeNameLabel.Text = "Store name: " + cust.StoreName;
            }
            storeNameLabel.Location = new Point(30, 10);
            storeNameLabel.AutoSize = true;
            this.Controls.Add(storeNameLabel);

            Label officeLabel = new Label();

            officeLabel.Text     = "Billing Address: " + cust.BillingAddress;
            officeLabel.Location = new Point(30, 25);
            officeLabel.AutoSize = true;
            this.Controls.Add(officeLabel);

            Label shippingLabel = new Label();

            shippingLabel.Text     = "Shipping Address: " + cust.ShippingAddress;
            shippingLabel.Location = new Point(30, 40);
            shippingLabel.AutoSize = true;
            this.Controls.Add(shippingLabel);

            Label contactLabel = new Label();

            contactLabel.Text     = "Store Contact: " + cust.StoreContact;
            contactLabel.Location = new Point(30, 55);
            contactLabel.AutoSize = true;
            this.Controls.Add(contactLabel);

            Label emailLabel = new Label();

            emailLabel.Text     = "Email: " + cust.Email;
            emailLabel.Location = new Point(30, 70);
            emailLabel.AutoSize = true;
            this.Controls.Add(emailLabel);

            Label phoneLabel = new Label();

            phoneLabel.Text     = "Phone: " + cust.PhoneNumber;
            phoneLabel.Location = new Point(emailLabel.Location.X + emailLabel.Size.Width + 20, 70);
            phoneLabel.AutoSize = true;
            this.Controls.Add(phoneLabel);


            Label invoiceIDLabel = new Label();

            invoiceIDLabel.Text     = "Local Invoice ID: " + invoice.InvoiceID;
            invoiceIDLabel.Location = new Point(500, 10);
            invoiceIDLabel.AutoSize = true;
            this.Controls.Add(invoiceIDLabel);

            Label invoiceNumberLabel = new Label();

            invoiceNumberLabel.Text     = "Invoice #: ";
            invoiceNumberLabel.Location = new Point(500, 25);
            invoiceNumberLabel.AutoSize = true;
            this.Controls.Add(invoiceNumberLabel);

            TextBox invoiceNumber = new TextBox();

            invoiceNumber.Location       = new Point(560, 25);
            invoiceNumber.Size           = new Size(75, 25);
            invoiceNumber.Name           = "invoiceNumber";
            invoiceNumber.AccessibleName = "invoiceNumber";
            invoiceNumber.KeyPress      += textBoxOnlyNumb_KeyPress;
            this.Controls.Add(invoiceNumber);

            Label paymentLabel = new Label();

            paymentLabel.Text     = "Payment Terms: " + cust.PaymentTerms;
            paymentLabel.Location = new Point(500, 45);
            paymentLabel.AutoSize = true;
            this.Controls.Add(paymentLabel);

            Label shippingInstructionsLabel = new Label();

            shippingInstructionsLabel.Text     = "Shipping Instructions: " + cust.ShippingInstructions;
            shippingInstructionsLabel.Location = new Point(500, 60);
            shippingInstructionsLabel.AutoSize = true;
            this.Controls.Add(shippingInstructionsLabel);


            Label purchaseOrderLabel = new Label();

            purchaseOrderLabel.Text     = "PO#:" + invoice.PurchaseOrder;
            purchaseOrderLabel.Location = new Point(500, 75);
            purchaseOrderLabel.AutoSize = true;
            this.Controls.Add(purchaseOrderLabel);

            Label invoiceSpecialNotesLabel = new Label();

            invoiceSpecialNotesLabel.Text     = "Special Notes: ";
            invoiceSpecialNotesLabel.Location = new Point(30, 90);
            invoiceSpecialNotesLabel.AutoSize = true;
            this.Controls.Add(invoiceSpecialNotesLabel);

            TextBox invoiceSpecialNotes = new TextBox();

            invoiceSpecialNotes.Location       = new Point(110, 90);
            invoiceSpecialNotes.Size           = new Size(500, 25);
            invoiceSpecialNotes.Text           = invoice.SpecialNotes;
            invoiceSpecialNotes.Name           = "invoiceSpecialNotes";
            invoiceSpecialNotes.AccessibleName = "invoiceSpecialNotes";
            this.Controls.Add(invoiceSpecialNotes);


            Label backorderInvoiceNotesLabel = new Label();

            backorderInvoiceNotesLabel.Text     = "Backorder Invoice Notes: ";
            backorderInvoiceNotesLabel.Location = new Point(30, 115);
            backorderInvoiceNotesLabel.AutoSize = true;
            this.Controls.Add(backorderInvoiceNotesLabel);

            TextBox backorderInvoiceNotes = new TextBox();

            backorderInvoiceNotes.Location       = new Point(165, 115);
            backorderInvoiceNotes.Size           = new Size(700, 25);
            backorderInvoiceNotes.Text           = "ITEMS ON BACKORDER " + cust.StoreName + ". PO#: " + invoice.PurchaseOrder + " ";
            backorderInvoiceNotes.Name           = "backorderInvoiceNotes";
            backorderInvoiceNotes.AccessibleName = "backorderInvoiceNotes";
            this.Controls.Add(backorderInvoiceNotes);

            //Invoice column headers
            Label qtyLabel = new Label();

            qtyLabel.Text      = "Qty";
            qtyLabel.Location  = new Point(x, y);
            qtyLabel.AutoSize  = true;
            qtyLabel.BackColor = System.Drawing.Color.LightGray;
            this.Controls.Add(qtyLabel);

            Label itemNoLabel = new Label();

            itemNoLabel.Text      = "Item Number";
            itemNoLabel.Location  = new Point(x + 50, y);
            itemNoLabel.AutoSize  = true;
            itemNoLabel.BackColor = System.Drawing.Color.LightGray;
            this.Controls.Add(itemNoLabel);

            Label locLabel = new Label();

            locLabel.Text      = "Location";
            locLabel.Location  = new Point(x + 170, y);
            locLabel.AutoSize  = true;
            locLabel.BackColor = System.Drawing.Color.LightGray;
            this.Controls.Add(locLabel);

            Label descLabel = new Label();

            descLabel.Text      = "Description";
            descLabel.Location  = new Point(x + 240, y);
            descLabel.AutoSize  = true;
            descLabel.BackColor = System.Drawing.Color.LightGray;
            this.Controls.Add(descLabel);

            Label cartonLabel = new Label();

            cartonLabel.Text      = "Pack";
            cartonLabel.Location  = new Point(x + 460, y);
            cartonLabel.AutoSize  = true;
            cartonLabel.BackColor = System.Drawing.Color.LightGray;
            this.Controls.Add(cartonLabel);

            Label costLabel = new Label();

            costLabel.Text      = "Cost";
            costLabel.Location  = new Point(x + 510, y);
            costLabel.AutoSize  = true;
            costLabel.BackColor = System.Drawing.Color.LightGray;
            this.Controls.Add(costLabel);

            Label amountLabel = new Label();

            amountLabel.Text      = "Amount";
            amountLabel.Location  = new Point(x + 580, y);
            amountLabel.AutoSize  = true;
            amountLabel.BackColor = System.Drawing.Color.LightGray;
            this.Controls.Add(amountLabel);

            Label specialNotesLabel = new Label();

            specialNotesLabel.Text      = "Special Notes";
            specialNotesLabel.Location  = new Point(x + 640, y);
            specialNotesLabel.AutoSize  = true;
            specialNotesLabel.BackColor = System.Drawing.Color.LightGray;
            this.Controls.Add(specialNotesLabel);

            Label backorderLabel = new Label();

            backorderLabel.Text      = "B.O.";
            backorderLabel.Location  = new Point(x + 790, y);
            backorderLabel.AutoSize  = true;
            backorderLabel.BackColor = System.Drawing.Color.LightGray;
            this.Controls.Add(backorderLabel);

            Label backorderNotesLabel = new Label();

            backorderNotesLabel.Text      = "B.O. Note";
            backorderNotesLabel.Location  = new Point(x + 830, y);
            backorderNotesLabel.AutoSize  = true;
            backorderNotesLabel.BackColor = System.Drawing.Color.LightGray;
            this.Controls.Add(backorderNotesLabel);

            Button cancelButton = new Button();

            cancelButton.Location = new Point(720, 620);
            cancelButton.Size     = new Size(50, 25);
            cancelButton.Text     = "Cancel";
            cancelButton.Click   += CancelButton_Click;
            this.Controls.Add(cancelButton);

            Button okButton = new Button();

            okButton.Location = new Point(780, 620);
            okButton.Size     = new Size(50, 25);
            okButton.Text     = "OK";
            okButton.Click   += OkButton_Click;
            this.Controls.Add(okButton);

            Button printButton = new Button();

            printButton.Location = new Point(665, 620);
            printButton.Size     = new Size(50, 25);
            printButton.Text     = "Print";
            printButton.Click   += PrintButton_Click;
            this.Controls.Add(printButton);
        }
コード例 #3
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            var confirmResult = MessageBox.Show("Are you sure this invoice is complete?",
                                                "Confirm Completion!!",
                                                MessageBoxButtons.YesNo);

            if (confirmResult == DialogResult.Yes)
            {
                if (this.Controls["invoiceNumber"].Text.Length == 0)
                {
                    this.Controls["invoiceNumber"].BackColor = Color.Red;
                    return;
                }
                Customer cust = CustomerDatabase.SearchCustomersByID(customerID);

                for (int i = 0; i < invoiceContentsList.Count; i++)
                {
                    int    numBO;
                    String itemNo  = this.panel1.Controls["itemNumber" + i].Text;
                    String notes   = this.panel1.Controls["specialNotes" + i].Text;
                    int    qty     = Int32.Parse(this.panel1.Controls["qty" + i].Text);
                    int    entryID = InvoiceContentsDatabase.GetEntryID(invoice.InvoiceID, itemNo);

                    if (invoiceContentsList[i].Backorder > 0)
                    {
                        numBO = Int32.Parse(this.panel1.Controls["backorder" + i].Text);
                        InvoiceContentsDatabase.EditInvoiceContent(entryID, invoice.InvoiceID, itemNo, qty, notes);
                        InvoiceContentsDatabase.UpdateBackorderSpecialNotes(entryID, this.panel1.Controls["backorderNotes" + i].Text);
                    }
                }
                int invoiceNumber;

                invoiceNumber = Int32.Parse(this.Controls["invoiceNumber"].Text);

                float freight = 0;
                if (this.Controls["freight"].Text.Length == 0)
                {
                    freight = 0;
                }
                else
                {
                    freight = Single.Parse(this.Controls["freight"].Text);
                }
                InvoiceDatabase.EditInvoice(invoice.InvoiceID, cust.StoreID, invoice.PurchaseOrder, invoice.SpecialNotes, invoiceNumber, Single.Parse(this.Controls["subTotalAmount"].Text), Single.Parse(this.Controls["gst"].Text), Single.Parse(this.Controls["pst"].Text), Single.Parse(this.Controls["invoiceTotal"].Text), 3);
                InvoiceDatabase.UpdateFreight(invoice.InvoiceID, freight);
                InvoiceDatabase.UpdateBackorderSpecialNotes(invoice.InvoiceID, this.Controls["backorderInvoiceNotes"].Text);

                bool hasBackorder = false;

                for (int i = 0; i < invoice.Items.Count; i++)
                {
                    if (invoice.Items[i].BackOrder > 0)
                    {
                        hasBackorder = true;
                        break;
                    }
                }

                if (hasBackorder)
                {
                    InvoiceDatabase.UpdateBackorderSpecialNotes(invoice.InvoiceID, this.Controls["backorderInvoiceNotes"].Text);
                }
                else
                {
                    InvoiceDatabase.UpdateBackorderSpecialNotes(invoice.InvoiceID, "");
                }

                // Query DB for updated results.
                Invoice printInvoice = new Invoice(invoice.InvoiceID);

                // Define & populate Object to define Table columns for datasource in .rdlc Report
                List <InvoiceItemDetail> invoiceItemDetails;
                invoiceItemDetails = new List <InvoiceItemDetail>();

                for (int i = 0; i < invoice.Items.Count; i++)
                {
                    invoiceItemDetails.Add(new InvoiceItemDetail());

                    // Invoice Order Data
                    invoiceItemDetails[i].InvoiceID = invoice.InvoiceID;
                    invoiceItemDetails[i].QTY       = printInvoice.Items[i].Quantity;
                    // Hide GrabCarton in Final Invoice Report
                    invoiceItemDetails[i].GrabCarton  = 0.0f;
                    invoiceItemDetails[i].ItemNo      = printInvoice.Items[i].ItemNo;
                    invoiceItemDetails[i].Description = printInvoice.Items[i].ItemDesc;
                    // Hide CartonTotal in Final Invoice Report
                    invoiceItemDetails[i].CartonTotal          = 0;
                    invoiceItemDetails[i].InvoiceItemSellPrice = printInvoice.Items[i].SellPrice;
                    invoiceItemDetails[i].InvoiceItemAmount    = printInvoice.Items[i].Quantity * printInvoice.Items[i].SellPrice;
                    invoiceItemDetails[i].InvoiceItemNote      = printInvoice.Items[i].SpecialNotes;

                    // Backorder Data
                    invoiceItemDetails[i].Backorder           = printInvoice.Items[i].BackOrder;
                    invoiceItemDetails[i].BackorderGrabCarton = 0.0f;
                    invoiceItemDetails[i].BackorderNote       = printInvoice.Items[i].BackOrderSpecialNotes;
                }

                Form PrintForm = new PrintInvoiceProgress(printInvoice, invoiceItemDetails);
                PrintForm.ShowDialog();

                this.Close();
            }
            else
            {
                // If 'No', do something here.
            }
        }