private void CbxSelectedInvoice_SelectedValueChanged(object sender, EventArgs e)
        {
            DBInvoice tempInvoice = (cbxSelectedInvoice.SelectedItem as DBInvoice);

            this.txtSearchName.Text   = tempInvoice.Collector.FullName;
            this.mtxtPhoneNumber.Text = tempInvoice.Collector.PhoneNumber;
        }
コード例 #2
0
        /// <summary>
        /// Gets a list of all the invoices in the database
        /// </summary>
        /// <returns>A list of all the invoices in the database</returns>
        public static BindingList <DBInvoice> GetInvoices()
        {
            BindingList <DBInvoice> invoices = new BindingList <DBInvoice>();
            string query = "SELECT * FROM invoice";

            using (var conn = new SqlConnection(Properties.Settings.Default.Britannicus_DBConnectionString))
            {
                var command = new SqlCommand(query, conn);
                conn.Open();
                var reader = command.ExecuteReader();
                while (reader.Read())
                {
                    DBInvoice tempInvoice = new DBInvoice((int)reader["invoiceID"], (int)reader["customerID"], (DateTime)reader["invoiceDate"]);
                    invoices.Add(tempInvoice);
                }
            }
            return(invoices);
        }
        public ViewPurchasesByInvoiceScreen(Screen backScreen) : base("View Purchases by Invoice", backScreen, 1)
        {
            this.tlpSearchBar              = new System.Windows.Forms.TableLayoutPanel();
            this.lblName                   = new System.Windows.Forms.Label();
            this.lblSelectedInvoicePrompt  = new System.Windows.Forms.Label();
            this.lblSearchPrompt           = new System.Windows.Forms.Label();
            this.cbxSelectedInvoice        = new System.Windows.Forms.ComboBox();
            this.txtSearchName             = new System.Windows.Forms.TextBox();
            this.mtxtPhoneNumber           = new System.Windows.Forms.MaskedTextBox();
            this.lblPhoneNumPrompt         = new System.Windows.Forms.Label();
            this.btnViewCollectorPurchases = new System.Windows.Forms.Button();
            this.tlpDatePanel              = new System.Windows.Forms.TableLayoutPanel();
            this.dtpDateTo                 = new System.Windows.Forms.DateTimePicker();
            this.lblDateFromPrompt         = new System.Windows.Forms.Label();
            this.dtpDateFrom               = new System.Windows.Forms.DateTimePicker();
            this.lblDateToPrompt           = new System.Windows.Forms.Label();
            this.crvPurchasesByInvoice     = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
            cryRpt = new ViewPurchasesByInvoice();

            this.BackColor   = System.Drawing.Color.Transparent;
            this.ColumnCount = 1;
            this.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
            //this.Controls.Add(this.tlpSearchBar, 0, 0);
            //this.Controls.Add(this.tlpDatePanel, 0, 1);
            this.Controls.Add(this.crvPurchasesByInvoice, 0, 2);
            this.Dock     = System.Windows.Forms.DockStyle.Fill;
            this.RowCount = 1;
            //this.RowCount = 3;
            //this.RowStyles.Add(new System.Windows.Forms.RowStyle(SizeType.AutoSize));
            //this.RowStyles.Add(new System.Windows.Forms.RowStyle(SizeType.AutoSize));
            //this.RowStyles.Add(new System.Windows.Forms.RowStyle(SizeType.Percent, 100F));
            this.TabIndex       = 0;
            this.ParentChanged += ViewPurchasesByInvoiceScreen_ParentChanged;
            //
            // tlpSearchBar
            //
            //this.tlpSearchBar.AutoSize = true;
            this.tlpSearchBar.BackColor   = System.Drawing.Color.White;
            this.tlpSearchBar.ColumnCount = 6;
            this.tlpSearchBar.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.AutoSize));
            this.tlpSearchBar.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
            this.tlpSearchBar.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
            this.tlpSearchBar.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.AutoSize));
            this.tlpSearchBar.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tlpSearchBar.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.AutoSize));
            this.tlpSearchBar.Controls.Add(this.lblName, 1, 0);
            this.tlpSearchBar.Controls.Add(this.lblSelectedInvoicePrompt, 3, 0);
            this.tlpSearchBar.Controls.Add(this.lblSearchPrompt, 0, 0);
            this.tlpSearchBar.Controls.Add(this.cbxSelectedInvoice, 4, 0);
            this.tlpSearchBar.Controls.Add(this.txtSearchName, 1, 1);
            this.tlpSearchBar.Controls.Add(this.mtxtPhoneNumber, 2, 1);
            this.tlpSearchBar.Controls.Add(this.lblPhoneNumPrompt, 2, 0);
            this.tlpSearchBar.Controls.Add(this.btnViewCollectorPurchases, 5, 0);
            this.tlpSearchBar.Dock     = System.Windows.Forms.DockStyle.Fill;
            this.tlpSearchBar.Padding  = new System.Windows.Forms.Padding(10);
            this.tlpSearchBar.RowCount = 3;
            this.tlpSearchBar.RowStyles.Add(new System.Windows.Forms.RowStyle());
            this.tlpSearchBar.RowStyles.Add(new System.Windows.Forms.RowStyle());
            this.tlpSearchBar.RowStyles.Add(new System.Windows.Forms.RowStyle());
            this.tlpSearchBar.TabIndex = 0;
            //
            // lblName
            //
            this.lblName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
                                                                        | System.Windows.Forms.AnchorStyles.Right)));
            this.lblName.AutoSize  = true;
            this.lblName.TabIndex  = 7;
            this.lblName.Text      = "Name";
            this.lblName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            //
            // lblSelectedInvoicePrompt
            //
            this.lblSelectedInvoicePrompt.Anchor   = System.Windows.Forms.AnchorStyles.Right;
            this.lblSelectedInvoicePrompt.AutoSize = true;
            //this.lblSelectedInvoicePrompt.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.tlpSearchBar.SetRowSpan(this.lblSelectedInvoicePrompt, 2);
            this.lblSelectedInvoicePrompt.TabIndex = 3;
            this.lblSelectedInvoicePrompt.Text     = "Selected Invoice:";
            //
            // lblSearchPrompt
            //
            this.lblSearchPrompt.Anchor   = System.Windows.Forms.AnchorStyles.Right;
            this.lblSearchPrompt.AutoSize = true;
            //this.lblSearchPrompt.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.tlpSearchBar.SetRowSpan(this.lblSearchPrompt, 2);
            this.lblSearchPrompt.TabIndex = 0;
            this.lblSearchPrompt.Text     = "Search:";
            //
            // cbxSelectedCollector
            //
            this.cbxSelectedInvoice.Anchor            = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
            this.cbxSelectedInvoice.FormattingEnabled = true;
            this.cbxSelectedInvoice.Margin            = new System.Windows.Forms.Padding(10, 3, 10, 3);
            this.tlpSearchBar.SetRowSpan(this.cbxSelectedInvoice, 2);
            this.cbxSelectedInvoice.TabIndex              = 4;
            this.cbxSelectedInvoice.DataSource            = DBInvoice.GetInvoices();
            this.cbxSelectedInvoice.DisplayMember         = "ComboBoxDisplay";
            this.cbxSelectedInvoice.ValueMember           = "ID";
            this.cbxSelectedInvoice.DropDownStyle         = ComboBoxStyle.DropDownList;
            this.cbxSelectedInvoice.SelectedValueChanged += CbxSelectedInvoice_SelectedValueChanged;
            //
            // txtSearchInput
            //
            this.txtSearchName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                                                                              | System.Windows.Forms.AnchorStyles.Right)));
            this.txtSearchName.Margin    = new System.Windows.Forms.Padding(10, 3, 10, 3);
            this.txtSearchName.TabIndex  = 1;
            this.txtSearchName.MaxLength = DBControlHelper.MaximumFullNameLength;
            //
            // mtxtPhoneNumber
            //
            this.mtxtPhoneNumber.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                                                                                | System.Windows.Forms.AnchorStyles.Right)));
            this.mtxtPhoneNumber.Margin         = new System.Windows.Forms.Padding(10, 3, 10, 3);
            this.mtxtPhoneNumber.Mask           = "(000) 000-0000";
            this.mtxtPhoneNumber.TabIndex       = 5;
            this.mtxtPhoneNumber.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
            //
            // lblPhoneNumPrompt
            //
            this.lblPhoneNumPrompt.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
                                                                                  | System.Windows.Forms.AnchorStyles.Right)));
            this.lblPhoneNumPrompt.AutoSize  = true;
            this.lblPhoneNumPrompt.TabIndex  = 6;
            this.lblPhoneNumPrompt.Text      = "Phone Number";
            this.lblPhoneNumPrompt.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            //
            // btnViewDetails
            //
            this.btnViewCollectorPurchases.Anchor       = System.Windows.Forms.AnchorStyles.Left;
            this.btnViewCollectorPurchases.AutoSize     = true;
            this.btnViewCollectorPurchases.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
            this.btnViewCollectorPurchases.BackColor    = System.Drawing.SystemColors.Control;
            this.tlpSearchBar.SetRowSpan(this.btnViewCollectorPurchases, 2);
            this.btnViewCollectorPurchases.TabIndex = 8;
            this.btnViewCollectorPurchases.Text     = "View Collector Purchases";
            this.btnViewCollectorPurchases.UseVisualStyleBackColor = false;
            this.btnViewCollectorPurchases.Click += BtnViewDetails_Click;
            //
            // tlpDatePanel
            //
            this.tlpDatePanel.AutoSize    = true;
            this.tlpDatePanel.ColumnCount = 4;
            this.tlpDatePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
            this.tlpDatePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
            this.tlpDatePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
            this.tlpDatePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
            this.tlpDatePanel.Controls.Add(this.dtpDateTo, 3, 0);
            this.tlpDatePanel.Controls.Add(this.lblDateFromPrompt, 0, 0);
            this.tlpDatePanel.Controls.Add(this.dtpDateFrom, 1, 0);
            this.tlpDatePanel.Controls.Add(this.lblDateToPrompt, 2, 0);
            this.tlpDatePanel.Dock     = System.Windows.Forms.DockStyle.Fill;
            this.tlpDatePanel.RowCount = 1;
            this.tlpDatePanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
            this.tlpDatePanel.TabIndex  = 9;
            this.tlpDatePanel.BackColor = this.tlpSearchBar.BackColor;
            //
            // dtpDateTo
            //
            //this.dtpDateTo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
            this.dtpDateTo.TabIndex = 3;
            //
            // lblDateFromPrompt
            //
            this.lblDateFromPrompt.Anchor   = System.Windows.Forms.AnchorStyles.Right;
            this.lblDateFromPrompt.AutoSize = true;
            this.lblDateFromPrompt.TabIndex = 0;
            this.lblDateFromPrompt.Text     = "From";
            //
            // dtpDateFrom
            //
            //this.dtpDateFrom.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
            this.dtpDateFrom.TabIndex = 1;
            //
            // lblDateToPrompt
            //
            this.lblDateToPrompt.Anchor   = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
            this.lblDateToPrompt.AutoSize = true;
            this.lblDateToPrompt.TabIndex = 2;
            this.lblDateToPrompt.Text     = "to";
            //
            // crvPurchasesByInvoice
            //
            this.crvPurchasesByInvoice.ActiveViewIndex = -1;
            this.crvPurchasesByInvoice.BorderStyle     = System.Windows.Forms.BorderStyle.FixedSingle;
            this.crvPurchasesByInvoice.Cursor          = System.Windows.Forms.Cursors.Default;
            this.crvPurchasesByInvoice.Dock            = System.Windows.Forms.DockStyle.Fill;
            this.crvPurchasesByInvoice.TabIndex        = 1;
            this.crvPurchasesByInvoice.ReuseParameterValuesOnRefresh = true;
            this.crvPurchasesByInvoice.ReportRefresh += CrvPurchasesByInvoice_ReportRefresh;

            this.SetFontSizes(this.Controls);
        }