示例#1
0
        private void butCommitChanges_Click(object sender, EventArgs e)
        {
            // Validation
            if (trophyEditor1.TrophyName.Length == 0)
            {
                MessageBox.Show(this, "The trophy name is required.",
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (trophyEditor1.Donor.Length == 0)
            {
                MessageBox.Show(this, "The donor is required.",
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (trophyEditor1.YearDonated.Length == 0)
            {
                MessageBox.Show(this, "The donation year is required.",
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            TrophyDataSet.tblTrophiesRow row = ((tblTrophiesBindingSource.Current as DataRowView).Row as TrophyDataSet.tblTrophiesRow);
            this.tblTrophiesBindingSource.CurrencyManager.EndCurrentEdit();

            bool isNew = (row.RowState == DataRowState.Added);

            if (!isNew)
            {
                row.fldModified = DateTime.Now;
            }

            this.tblTrophiesTableAdapter.Update(this.trophyDataSet.tblTrophies);

            if (isNew)
            {
                row.fldTrophyID = GetLastAutoIncrementID("tblTrophies", "fldTrophyID");
                row.AcceptChanges();

                int i = 0;
                foreach (DataRowView r in tblTrophiesBindingSource.List)
                {
                    if ((r.Row as TrophyDataSet.tblTrophiesRow).fldTrophyID == row.fldTrophyID)
                    {
                        tblTrophiesBindingSource.Position = i;
                        break;
                    }
                    i++;
                }
            }

            OnTrophyPositionChanged();
        }
示例#2
0
        private void butAddTrophy_Click(object sender, EventArgs e)
        {
            // Filter needs to be removed so that the new trophy is sure to be displayed
            txtFilterTrophies.Clear();

            // Defaults need to be set as they may stay null if not changed in the editor
            TrophyDataSet.tblTrophiesRow row = ((tblTrophiesBindingSource.AddNew() as DataRowView).Row as TrophyDataSet.tblTrophiesRow);
            row.fldConditions     = string.Empty;
            row.fldCreated        = DateTime.Now;
            row.fldCurrentClassID = 1;
            row.fldDetails        = string.Empty;
            row.fldDonor          = string.Empty;
            row.fldName           = string.Empty;
            row.fldRedBookPage    = 0;
            row.fldYearDonated    = (short)DateTime.Now.Year;

            trophyEditor1.IsDirty = true;
        }
示例#3
0
        private void AddTrophyPage(Document doc, TrophyDataSet.tblTrophiesRow trophy, ref int pageNumber)
        {
            // Create a new A4 portrait page and add to the document
            pageNumber++;
            Page page = new Page(A4Portrait.Width, A4Portrait.Height);

            doc.Pages.Content.Add(page);

            // Add a bookmark
            doc.Outlines.Content.Add(new Outline(trophy.fldName,
                                                 new Siberix.PDF.Atoms.XYZDestination(page, page.Graphics.TranslateY(0)), true));

            Siberix.PDF.Layout.Table.Table table;

            table = CreateDetailsTable(page, trophy);
            table.Measure(page.Graphics);
            table.Draw(page.Graphics);

            // Winners table, 2mm below details table
            table = CreateWinnersTable(page, trophy, table.Top + table.Height + Px(2));

            TrophyDataSet.tblWinnersRow[] rows = (TrophyDataSet.tblWinnersRow[])Winners.Select(
                string.Format("[fldTrophyID] = {0}", trophy.fldTrophyID),
                "[fldYear] ASC");
            int rowIndex = 0;

            foreach (TrophyDataSet.tblWinnersRow winner in rows)
            {
                AddWinnerRow(table, winner);

                /* Table needs to be measured, if it's too tall, then we need to remove this row,
                 * draw it on the current page, add a new page, create a new table, and the row to it
                 */
                table.Measure(page.Graphics);
                if ((table.Top + table.Height + Px(5)) > (page.Height - Margin))
                {
                    table.Rows.Remove(rowIndex, 0);

                    // Draw the winners, and the footer, increment the page number
                    table.Measure(page.Graphics);
                    table.Draw(page.Graphics);
                    DrawFooter(page, pageNumber);
                    page.Graphics.Flush();
                    pageNumber++;

                    // New page
                    page = new Page(A4Portrait.Width, A4Portrait.Height);
                    doc.Pages.Content.Add(page);

                    table = CreateWinnersTable(page, trophy, Margin);
                    AddWinnerRow(table, winner);
                    rowIndex = 0;
                }

                rowIndex++;
            }

            table.Measure(page.Graphics);
            table.Draw(page.Graphics);
            DrawFooter(page, pageNumber);

            page.Graphics.Flush();
        }
示例#4
0
        private Siberix.PDF.Layout.Table.Table CreateWinnersTable(Page page, TrophyDataSet.tblTrophiesRow trophy, float top)
        {
            Siberix.PDF.Layout.Table.Table table;
            Siberix.PDF.Layout.Table.Row   row;
            Siberix.PDF.Layout.Table.Cell  cell;
            Siberix.PDF.Layout.Text.Text   text;

            Siberix.PDF.Layout.Text.Style regular = new Siberix.PDF.Layout.Text.Style(WinnerFont, Brushes.Black);

            table = new Siberix.PDF.Layout.Table.Table()
            {
                Left  = Margin,
                Top   = top,
                Width = page.Width - (2 * Margin)
            };

            // Title
            row                  = table.AddRow();
            cell                 = row.AddCell();
            cell.TopPadding      = (top == Margin ? Px(5) : Px(2));
            cell.BottomPadding   = Px(1);
            cell.TopBorder.Width = 1;
            cell.TopBorder.Color = Color.LightGray;
            text                 = cell.AddText();
            text.Style           = new Siberix.PDF.Layout.Text.Style(CaptionFont, Brushes.Black);
            text.Alignment       = TextAlignment.Center;
            text.AddContent(trophy.fldName + " Winners");

            // Column titles
            row = table.AddRow();
            // Year
            cell = row.AddCell();
            cell.BottomPadding = Px(1);
            cell.Width         = Px(15);
            cell.WidthIsFixed  = true;
            text       = cell.AddText();
            text.Style = regular;
            text.AddContent("Year");
            // Sail #
            cell = row.AddCell();
            cell.BottomPadding = Px(1);
            cell.Width         = Px(30);
            cell.WidthIsFixed  = true;
            text       = cell.AddText();
            text.Style = regular;
            text.AddContent("Sail # / Name");
            // Helm
            cell = row.AddCell();
            cell.BottomPadding = Px(1);
            text       = cell.AddText();
            text.Style = regular;
            text.AddContent("Helm");
            // Owner
            cell = row.AddCell();
            cell.BottomPadding = Px(1);
            text       = cell.AddText();
            text.Style = regular;
            text.AddContent("Owner");

            return(table);
        }
示例#5
0
        private Siberix.PDF.Layout.Table.Table CreateDetailsTable(Page page, TrophyDataSet.tblTrophiesRow trophy)
        {
            Siberix.PDF.Layout.Table.Table table;
            Siberix.PDF.Layout.Table.Row   row;
            Siberix.PDF.Layout.Table.Cell  cell;
            Siberix.PDF.Layout.Text.Text   text;

            Siberix.PDF.Layout.Text.Style regular = new Siberix.PDF.Layout.Text.Style(WinnerFont, Brushes.Black);

            // Details table
            table = new Siberix.PDF.Layout.Table.Table()
            {
                Left  = Margin,
                Top   = Margin,
                Width = page.Width - (2 * Margin)
            };

            // Header row
            row                  = table.AddRow();
            cell                 = row.AddCell();
            cell.TopPadding      = cell.BottomPadding = Px(5);
            cell.TopBorder.Width = 1;
            cell.TopBorder.Color = Color.LightGray;
            text                 = cell.AddText();
            text.Alignment       = TextAlignment.Center;
            text.Style           = new Siberix.PDF.Layout.Text.Style(TitleFont, Brushes.Black);
            text.AddContent(trophy.fldName);

            // Donated
            row  = table.AddRow();
            cell = row.AddCell();
            cell.BottomPadding = Px(2);
            text       = cell.AddText();
            text.Style = regular;
            text.AddContent(string.Format("Donated by {0} in {1}", trophy.fldDonor, trophy.fldYearDonated));

            // Conditions
            row  = table.AddRow();
            cell = row.AddCell();
            cell.WidthIsFixed  = true;
            cell.Width         = Px(25);
            cell.BottomPadding = Px(2);
            text       = cell.AddText();
            text.Style = regular;
            text.AddContent("Conditions:");
            cell = row.AddCell();
            cell.BottomPadding = Px(2);
            text       = cell.AddText();
            text.Style = regular;
            text.AddContent(trophy.fldConditions);

            // Details
            row  = table.AddRow();
            cell = row.AddCell();
            cell.WidthIsFixed  = true;
            cell.Width         = Px(25);
            cell.BottomPadding = Px(2);
            text       = cell.AddText();
            text.Style = regular;
            text.AddContent("Details:");
            cell = row.AddCell();
            cell.BottomPadding = Px(2);
            text       = cell.AddText();
            text.Style = regular;
            text.AddContent(trophy.fldDetails);

            // Red book page
            if (trophy.fldRedBookPage != 0)
            {
                row  = table.AddRow();
                cell = row.AddCell();
                cell.BottomPadding = Px(2);
                text       = cell.AddText();
                text.Style = regular;
                text.AddContent(string.Format("Red book page #{0}", trophy.fldRedBookPage));
            }

            return(table);
        }