Exemplo n.º 1
0
        /// <summary>
        /// print the ship's current cargo
        /// </summary>
        /// <param name="preview"></param>
        public void printManifest(bool detailed)
        {
            StringBuilder sb = new StringBuilder();

            int col1 = 24;
            int col2 = 29;
            int col3 = 12;
            int col4 = 8;

            // create two column headers, can have max of 4
            string ch1 = "Cargo Code".PadRight(col1) +
              "Description".PadRight(col2) +
              "Cost".PadLeft(col3) +
              "dTons".PadLeft(col4);
            int total = 5;

            // generate the detail lines (Dummy Data)
            int totalTons = 0;
            int totalCreds = 0;
            foreach (Traveller.Starship.cargoDesc lot in this.manifest)
            {
                string desc = lot.desc;
                if (desc.Length > 24)
                    desc = desc.Substring(0, 24);
                string origCode = lot.origCode;
                if (origCode.Length > 24)
                    origCode = origCode.Substring(0, 24);

                sb.Append(String.Format("{0,-24} {1,-30} {2,8} {3,8}",
                    origCode, desc, lot.purchasePrice, lot.dtons) +
                    Environment.NewLine);
                total += 5;
                totalTons += lot.dtons;
                totalCreds += lot.purchasePrice;

                // and if detailed, add the origin & other info
                if (detailed)
                {
                    sb.Append(String.Format("  origination: {0}", lot.origSEC) +
                        Environment.NewLine);
                    sb.Append(String.Format("  destination: {0}", lot.destSEC) +
                        Environment.NewLine);
                    sb.Append(String.Format("  purch date : {0}", lot.purchaseDate) +
                        Environment.NewLine);
                    sb.Append(String.Format("  notes      : {0}", lot.notes) +
                        Environment.NewLine + Environment.NewLine);
                    total += 25;
                }
            }

            // now we will pretend to have had a total break and change the
            // subtitle, after forcing a page change
            sb.Append(Environment.NewLine + " ".PadLeft(45) +
              "Total Cr" + totalCreds.ToString().PadLeft(11) +
              totalTons.ToString().PadLeft(9) + Environment.NewLine);

            // finally, set up & print the report
            // instantiate the object
            CPrintReportStringDemo.CPrintReportString cprs = new CPrintReportStringDemo.CPrintReportString();

            // set the title font points size and style
            cprs.TitleFontSize = 14;
            cprs.TitleFontStyle = TitleStyle.BoldItalic;

            // get margin extenders if any
            cprs.LeftMarginExtender = MarginExtender.OneHalfInch;
            cprs.RightMarginExtender = MarginExtender.OneHalfInch;
            cprs.TopMarginExtender = MarginExtender.OneHalfInch;
            cprs.BottomMarginExtender = MarginExtender.OneHalfInch;

            cprs.Footer = String.Format("Cargo Lading for {0} as of {1}", this.name, this.Date);

            // call the print or preview method
            string title = String.Format("Current Manifest for {0} on {1}", this.name, this.Date);
            string subTitle = String.Format("current location: {0}", this.sec);
            cprs.SubTitle2 = " ";
            cprs.SubTitle3 = "";
            cprs.SubTitle4 = "";
            cprs.PrintOrPreview(CharsPerLine.CPL80,
              sb.ToString(), title, subTitle, PrintPreview.Preview,
              PrintOrientation.Portrait, ch1);
        }
Exemplo n.º 2
0
        /// <summary>
        /// print the ship's cargo history
        /// </summary>
        public void printHistory()
        {
            StringBuilder sb = new StringBuilder();

            int col1 = 25;
            int col2 = 25;
            int col3 = 9;
            int col4 = 8;
            int col5 = 8;

            // create two column headers, can have max of 4
            string ch1 = "Cargo Code".PadRight(col1) +
              "Description".PadRight(col2) +
              "Purchase".PadRight(col3) +
              "Sold".PadLeft(col4) +
              "Profit".PadLeft(col5);
            string ch2 = "   " +
                "sold at";
            int total = 5;

            // generate the detail lines (Dummy Data)
            int totalCreds = 0;
            int profit = 0;
            Traveller.World w = new World();
            foreach (Traveller.Starship.cargoDesc lot in this.sold)
            {
                Match worldMatch = w.worldRegex.Match(lot.origSEC);
                string origName = worldMatch.Groups["name"].Value;
                worldMatch = w.worldRegex.Match(lot.destSEC);
                string destName = worldMatch.Groups["name"].Value;
                profit = lot.sellingPrice - lot.purchasePrice;

                string desc = lot.desc;
                if (desc.Length > 24)
                    desc = desc.Substring(0, 24);
                string origCode = lot.origCode;
                if (origCode.Length > 24)
                    origCode = origCode.Substring(0, 24);

                sb.Append(String.Format("{0,-24} {1,-25} {2,8} {3,8} {4,8}",
                    lot.origCode, desc, lot.purchasePrice, lot.sellingPrice, profit) +
                    Environment.NewLine);
                sb.Append(String.Format("  purch date: {0} at {1} sold date: {2} at {3}", lot.purchaseDate, origName, lot.sellingDate, destName) +
                    Environment.NewLine + Environment.NewLine);
                total += 15;
                totalCreds += profit;
            }

            // now we will pretend to have had a total break and change the
            // subtitle, after forcing a page change
            sb.Append(Environment.NewLine + " ".PadLeft(45) +
              "Profit Cr" + totalCreds.ToString().PadLeft(12) + Environment.NewLine);

            // finally, set up & print the report
            // instantiate the object
            CPrintReportStringDemo.CPrintReportString cprs = new CPrintReportStringDemo.CPrintReportString();

            // set the title font points size and style
            cprs.TitleFontSize = 14;
            cprs.TitleFontStyle = TitleStyle.BoldItalic;
            cprs.Footer = String.Format("Confidential: Cargo History for {0}", this.name);

            // get margin extenders if any
            cprs.LeftMarginExtender = MarginExtender.OneHalfInch;
            cprs.RightMarginExtender = MarginExtender.OneHalfInch;
            cprs.TopMarginExtender = MarginExtender.OneHalfInch;
            cprs.BottomMarginExtender = MarginExtender.OneHalfInch;

            // call the print or preview method
            string title = String.Format("Cargo History for {0}", this.name);
            string subTitle = " ";
            cprs.SubTitle2 = " ";
            cprs.SubTitle3 = "";
            cprs.SubTitle4 = "";
            cprs.PrintOrPreview(CharsPerLine.CPL80,
              sb.ToString(), title, subTitle, PrintPreview.Preview,
              PrintOrientation.Portrait, ch1, ch2);
        }