internal float GetCostEstimateByWeight(float weight, Carrier carrier, Parcel parcel, Invoice invoice)
        {
            float estimate = 0;
            int intPostcode = 0;
            int.TryParse(invoice.InvoiceCustomer.Postcode, out intPostcode);

            BlauModel _dbcontext = BlauModel.GetContext();
            DBCarrier _carrier = _dbcontext.Carrier.Where(x => x.carrierId == (int)carrier.CarrierId).FirstOrDefault();

            if (_carrier != default(DBCarrier))
            {
                /*PricingOption option = (from rate in _carrier.Rates
                                        where rate.Zones.Where(x => x.Postcode == invoice.InvoiceCustomer.Postcode).Count() > 0
                                            && rate.MinWeight < weight && rate.MaxWeight >= weight
                                        select new PricingOption(rate.Rate, rate.ExtraRate, rate.MinWeight, rate.MaxWeight, rate.SecondRate, rate.SecondRateExtra)
                                        ).FirstOrDefault();
                if (option != null)
                {
                    if (parcel.ParcelNumber == 1)
                        estimate = option.rate + option.extra_rate * weight;
                    else
                        estimate = option.second_parcel_rate + option.second_parcel_extra_rate * weight;
                }*/
            }
            return estimate;
        }
        internal void AddParcelToInvoice(Invoice invoice, Parcel parcel)
        {
            using (BlauModel _dbcontext = BlauModel.GetContext())
            {
                DBInvoice dbInvoice = _dbcontext.Invoice.Where(x => x.InvoiceNumber == invoice.InvoiceNo).FirstOrDefault();
                if (dbInvoice != default(DBInvoice))
                {
                    DBParcel dbParcel = _dbcontext.Parcel.Where(x => x.ParcelId == parcel.ParcelID).FirstOrDefault();
                    if (dbParcel == default(DBParcel))
                        dbParcel = new DBParcel();

                    dbParcel.ParcelNumber = parcel.ParcelNumber;
                    dbParcel.Length = parcel.Size.Length;
                    dbParcel.Height = parcel.Size.Height;
                    dbParcel.Width = parcel.Size.Width;
                    dbParcel.Weight = parcel.Weight;
                    dbParcel.ParcelStatus = (int)Enums.ParcelStatus.PACKED;
                    dbParcel.BarcodeText = parcel.BarcodeNumber;
                    dbParcel.ArticleId = parcel.ArticleID;

                    if (dbParcel.ParcelId == 0)
                    {
                        dbParcel.TimeCreated = DateTime.Now;
                    }
                    _dbcontext.Parcel.Add(dbParcel);

                    dbInvoice.Parcels.Add(dbParcel);
                    _dbcontext.SaveChanges();

                    parcel.ParcelID = dbParcel.ParcelId;
                    invoice.Parcels.Add(parcel);
                }
                else
                {
                    throw new InvoiceException(string.Format("Invoice {0} not found.", invoice.InvoiceNo));
                }
            }
        }
 internal int SaveInvoiceParcelReturnParcelID(Invoice invoice, Parcel parcel)
 {
     AddParcelToInvoice(invoice, parcel);
     return parcel.ParcelID;
 }
 private void printMaterial(Parcel parcel, PrintPageEventArgs e, Enums.CarrierDatabaseKey carrier)
 {
     LabelPrinter printer = null;
     switch (carrier)
     {
         case Enums.CarrierDatabaseKey.AUSTRALIA_POST:
             printer = new AustraliaPostPrinter(); break;
         case Enums.CarrierDatabaseKey.EPOST:
             printer = new EpostPrinter(); break;
         case Enums.CarrierDatabaseKey.TOLL:
             printer = new TollPrinter(); break;
         case Enums.CarrierDatabaseKey.HUNTER:
             printer = new HunterExpressPrinter(); break;
     }
     printer.PrintLabel(e.Graphics, currentInvoice, parcel);
 }
        private void GetCostEstimatesForInvoice(string invoiceNo)
        {
            double AP_total = 0.0;
            double EP_total = 0.0;
            double HE_total = 0.0;
            double TL_total = 0.0;
            double EP_size_total = 0.0;
            double TL_size_total = 0.0;

            InvalidateEstimateFormFields();

            //cost_estimates = new ArrayList(6) { "", "", "", "", "", "" };

            string new_temp_city = currentInvoice.InvoiceCustomer.City;
            int num_parcels = int.Parse(txtBox_input_parcelnum.Text);
            int parcel_number = 1;

            //int numSizeWeights = txtBox_input_dimensions.Text == "" ? 0 : txtBox_input_dimensions.Text.Split('/').Length;

            Dimensions dimensions = GetCurrentEnteredDimensions();

            string[] strWeights = txtBox_input_weight.Text.Split('/');
            float[] weights = new float[strWeights.Length];

            for (int i=0; i<strWeights.Length; i++)
            {
                float temp = 0.0f;
                float.TryParse(strWeights[i], out temp);
                weights[i] = temp;
            }

            // Split the weights and do separate checks for each
            foreach (string str_weight in txtBox_input_weight.Text.Split('/'))
            {
                float weight = float.Parse(str_weight);
                if (weight > 25.0)
                {
                    MessageBox.Show("Parcel weight is larger than 25KGs!");
                    return;
                }

                Parcel p = new Parcel(weight, parcel_number, 0.0d, num_parcels);
                API.InvoicesAPI.AddParcelToInvoice(currentInvoice, p);
                //temp_invoice.addParcel(p);

                //if (numSizeWeights > 0 && parcel_number <= numSizeWeights) {

                p.Size = dimensions;
                //}
                //}

                // Get Australia post estimate
                //IPricingMatrix matrix = GetMatrix(Enums.CarrierDatabaseKey.AP);
                //float rate = matrix.getCostEstimate(p, temp_invoice);
                float rate = API.PricingAPI.GetCostEstimate(AustraliaPost, p, currentInvoice);
                AP_total += rate;

                // Get Hunter Express estimate
                //matrix = GetMatrix(Enums.CarrierDatabaseKey.HE);
                //rate = matrix.getCostEstimate(p, temp_invoice);
                rate = API.PricingAPI.GetCostEstimate(HunterExpress, p, currentInvoice);
                HE_total += rate;

                // Get E-post estimate
                //matrix = GetMatrix(Enums.CarrierDatabaseKey.EP);
                //rate = matrix.getCostEstimate(p, temp_invoice);
                rate = API.PricingAPI.GetCostEstimate(EPost, p, currentInvoice);
                EP_total += rate;

                // Get E-post size estimate
                float sizeWeight = p.getSizeWeight() * EPost.DimensionWeightRate;
                //rate = matrix.getEstimateByWeight(sizeWeight, temp_invoice.InvoiceCustomer.Postcode, p.ParcelNumber);
                rate = API.PricingAPI.GetCostEstimateByWeight(sizeWeight, EPost, p, currentInvoice);
                EP_size_total += rate;
                if (parcel_number == 1)
                {
                    txtBox_sizeweight_EP.Text = sizeWeight.ToString("N2") + "kg";
                }
                else
                {
                    txtBox_sizeweight_EP.Text += "|" + sizeWeight.ToString("N2") + "kg";
                }

                // Get TOLL estimate
                //matrix = GetMatrix(Enums.CarrierDatabaseKey.TL);
                //rate = matrix.getCostEstimate(p, temp_invoice);
                rate = API.PricingAPI.GetCostEstimate(Toll, p, currentInvoice);
                TL_total += rate;

                // Get TOLL size estimate
                sizeWeight = p.getSizeWeight() * Toll.DimensionWeightRate;
                //rate = matrix.getEstimateByWeight(sizeWeight, temp_invoice.InvoiceCustomer.Postcode, p.ParcelNumber);
                rate = API.PricingAPI.GetCostEstimateByWeight(sizeWeight, Toll, p, currentInvoice);
                TL_size_total += rate;
                if (parcel_number == 1)
                {
                    txtBox_sizeweight_TL.Text = sizeWeight.ToString("N2") + "kg";
                }
                else
                {
                    txtBox_sizeweight_TL.Text += "|" + sizeWeight.ToString("N2") + "kg";
                }

                parcel_number++;
            }

            CostEstimate APEstimate = API.PricingAPI.GetCostEstimateFor(AustraliaPost, currentInvoice, dimensions, weights);
            CostEstimate EPEstimate = API.PricingAPI.GetCostEstimateFor(EPost, currentInvoice, dimensions, weights);
            CostEstimate HEEstimate = API.PricingAPI.GetCostEstimateFor(HunterExpress, currentInvoice, dimensions, weights);
            CostEstimate TLEstimate = API.PricingAPI.GetCostEstimateFor(Toll, currentInvoice, dimensions, weights);

            Dictionary<Carrier, CostEstimate> CurrentEstimates = new Dictionary<Carrier, CostEstimate>();
            CurrentEstimates.Add(AustraliaPost, APEstimate);
            CurrentEstimates.Add(EPost, EPEstimate);
            CurrentEstimates.Add(HunterExpress, HEEstimate);
            CurrentEstimates.Add(Toll, TLEstimate);

            txtBox_estimate_AP.Text = APEstimate.WeightEstimate.ToString("c2");
            txtBox_estimate_EP.Text = EPEstimate.WeightEstimate.ToString("c2");
            txtBox_estimate_HE.Text = HEEstimate.WeightEstimate.ToString("c2");
            if(API.CustomerAPI.HasPhoneNumberOrEmailAddress(currentInvoice.InvoiceCustomer))
            {
                txtBox_estimate_TL.Text = TLEstimate.WeightEstimate == PricingMatrix.MAX_VAL ? "N/A" : TL_total.ToString("c2");
            }
            else
            {
                txtBox_estimate_TL.Text = "N/A";
            }

            txtBox_sizeweight_AP.Text = "N/A";
            txtBox_sizeweight_HE.Text = "N/A";

            txtBox_size_estimate_EP.Text = EPEstimate.DimensionWeightEstimate.ToString("c2");
            txtBox_size_estimate_AP.Text = "N/A";
            txtBox_size_estimate_HE.Text = "N/A";
            txtBox_size_estimate_TL.Text = TLEstimate.DimensionWeightEstimate.ToString("c2");

            //update_all();

            txtTitle_estimate.Show();
            table_estimate.Show();

            currentInvoice.CurrentEstimates = CurrentEstimates;
        }
Exemplo n.º 6
0
 public static float GetCostEstimate(Carrier carrier, Parcel parcel, Invoice invoice)
 {
     return Actions.GetCostEstimate(carrier, parcel, invoice);
 }
 public virtual float getCostEstimate(Parcel p, Invoice i)
 {
     return getEstimateByWeight(p.Weight, i.InvoiceCustomer.Postcode, p.ParcelNumber);
 }
        public override void PrintLabel(Graphics g, Invoice temp_invoice, Parcel p)
        {
            g.Clear(Color.Transparent);

            string defaultFont = "Arial";

            // List all fonts
            /*FontFamily ff = null;
            InstalledFontCollection fontsCollection = new InstalledFontCollection();
            FontFamily[] fontFamilies = fontsCollection.Families;
            foreach (FontFamily font in fontFamilies) {
                Console.Write(font.Name);
                if (font.IsStyleAvailable(FontStyle.Regular))
                    Console.WriteLine(" (regular available)");
                else
                    Console.WriteLine(" (regular not available)");

                if (font.Name.Equals("Code 128")) {
                    ff = font;
                    Console.WriteLine("128 set");
                }
            }*/
            FontFamily code128 = pfc.Families[0];
            Font f_barcode = new Font(code128, 32, FontStyle.Regular);
            Font font8 = new Font(defaultFont, 7, FontStyle.Regular);
            Font font10 = new Font(defaultFont, 8, FontStyle.Regular);
            Font font10b = new Font(defaultFont, 8, FontStyle.Bold);
            Font font12 = new Font(defaultFont, 10, FontStyle.Regular);
            Font font12b = new Font(defaultFont, 10, FontStyle.Bold);
            Font font14 = new Font(defaultFont, 12, FontStyle.Regular);
            Font font14b = new Font(defaultFont, 12, FontStyle.Bold);
            Font font16b = new Font(defaultFont, 14, FontStyle.Bold);
            Font font18b = new Font(defaultFont, 16, FontStyle.Bold);

            Pen pen1 = new Pen(Brushes.Black);
            pen1.Width = 2.0F;
            Pen pen2 = new Pen(Brushes.Black);
            pen2.Width = 1.0F;
            Pen pen3 = new Pen(Brushes.Black);
            pen3.Width = 25.0F;
            Pen pen4 = new Pen(Brushes.Black);
            pen4.Width = 38.0F;
            Pen pen5 = new Pen(Brushes.Black);
            pen5.Width = 30.0F;

            string serviceName = "ECONOMY EXPRESS";
            IDepotService service = API.CarrierAPI.GetDepotServiceForCarrier(Enums.CarrierDatabaseKey.TOLL);
            string depot_code = service.findDepotForCustomer(temp_invoice.InvoiceCustomer);

            int x = 0, y = 0;
            int box_v_spacing = 6;
            int x_margin = convertSize(35), y_margin = convertSize(10);
            int line_height = convertSize(25);
            int line_height2 = convertSize(14);
            int line_height3 = convertSize(20);
            int width = convertSize(400), height = convertSize(600);
            int box_width = convertSize(50);

            StringFormat centerformat = new StringFormat();
            centerformat.Alignment = StringAlignment.Center;

            // Draw lines and right side items
            Point a = new Point(0, 0);
            Point b = new Point(0, 0);
            a.X = convertSize(3);
            a.Y = convertSize(41);
            b.X = convertSize(300);
            b.Y = a.Y;
            g.DrawLine(pen3, a, b); // Top black bar

            // Depot code
            a.X = b.X + convertSize(5);
            a.Y -= 12;
            b.Y = a.Y + convertSize(42);
            b.X = convertSize(370);
            g.DrawRectangle(pen2, new Rectangle(a.X, a.Y, b.X - a.X, b.Y - a.Y));
            g.DrawString(depot_code, font18b, Brushes.Black, 370 - box_width - 12, 35);

            y += convertSize(90);
            a.X = 370 - box_width;
            a.Y = convertSize(94) + 20 + box_v_spacing;
            b.Y += 90;
            g.DrawRectangle(pen2, new Rectangle(a.X, a.Y, b.X - a.X, b.Y - a.Y));
            g.DrawString("DGs:", font12b, Brushes.Black, 370 - box_width +6, a.Y + 4);
            g.DrawString("NO", font12b, Brushes.Black, 370 - box_width +9, a.Y + 22);

            a.Y = b.Y + box_v_spacing;
            b.Y = a.Y + 40;
            g.DrawRectangle(pen2, new Rectangle(a.X, a.Y, b.X - a.X, b.Y - a.Y));
            g.DrawString("ITEM#", font8, Brushes.Black, 370 - box_width + 6, a.Y + 4);
            g.DrawString("1 of 1", font8, Brushes.Black, 370 - box_width + 8, a.Y + 22);

            a.Y = b.Y + box_v_spacing;
            b.Y = a.Y + 40;
            g.DrawRectangle(pen2, new Rectangle(a.X, a.Y, b.X - a.X, b.Y - a.Y));
            g.DrawString("DATE", font8, Brushes.Black, 370 - box_width + 6, a.Y + 4);
            g.DrawString(DateTime.Now.ToString("dd/MM/yy"), font8, Brushes.Black, 370 - box_width + 1, a.Y + 22);

            a.Y = b.Y + box_v_spacing;
            b.Y = a.Y + 110;
            //RectangleF text
            g.DrawRectangle(pen2, new Rectangle(a.X, a.Y, b.X - a.X, b.Y - a.Y));
            g.DrawString("CON", font8, Brushes.Black, new RectangleF(370 - box_width, a.Y + 4, b.X - a.X, b.Y - a.Y), centerformat);
            g.DrawString("WEIGHT", font8, Brushes.Black, new RectangleF(370 - box_width, a.Y + 22, b.X - a.X, b.Y - a.Y), centerformat);
            string wString = p.Weight.ToString();
            g.DrawString(string.Format("{0}kg", wString.Substring(0, Math.Min(5, wString.Length))), font10, Brushes.Black, new RectangleF(370 - box_width + 2, a.Y + 40, b.X - a.X, b.Y - a.Y), centerformat);

            g.DrawString("CON", font8, Brushes.Black, new RectangleF(370 - box_width, a.Y + 58, b.X - a.X, b.Y - a.Y), centerformat);
            g.DrawString("CUBIC", font8, Brushes.Black, new RectangleF(370 - box_width, a.Y + 76, b.X - a.X, b.Y - a.Y), centerformat);
            wString = getDimensionalWeight(temp_invoice, p).ToString();
            g.DrawString(string.Format("{0}kg", wString.Substring(0, Math.Min(5, wString.Length))), font10, Brushes.Black, new RectangleF(370 - box_width, a.Y + 94, b.X - a.X, b.Y - a.Y), centerformat);

            a.X = x_margin;
            a.Y = convertSize(470);
            b.X = convertSize(370);
            b.Y = a.Y;
            g.DrawLine(pen5, a, b); // Bottom black bar
            g.DrawString("NSR-NO SIGNATURE REQUIRED", font16b, Brushes.White, new RectangleF(0, a.Y-10, g.VisibleClipBounds.Width, 20), centerformat);

            g.DrawString(string.Format("FOR ORDER: {0}", temp_invoice.InvoiceNo), font10b, Brushes.Black, a.X, a.Y-30);

            // Draw Barcode
            string barcode_number = GenerateBarcode(temp_invoice, p);
            string temp = Code128.Encode(barcode_number);
            g.DrawString(temp, f_barcode, Brushes.Black, new RectangleF(0, a.Y + 15, g.VisibleClipBounds.Width, 60), centerformat);
            g.DrawString(temp, f_barcode, Brushes.Black, new RectangleF(0, a.Y + 54, g.VisibleClipBounds.Width, 60), centerformat);

            // Draw text of barcode
            g.DrawString(barcode_number, font8, Brushes.Black, new RectangleF(0, a.Y + 98, g.VisibleClipBounds.Width, a.Y + 108), centerformat);

            string declaration = "DECLARATION BY: " + SIGNER;
            g.DrawString(declaration, font8, Brushes.Black, new RectangleF(0, g.VisibleClipBounds.Height - 16, g.VisibleClipBounds.Width, g.VisibleClipBounds.Height), centerformat);

            a.X = b.X - box_width;
            a.Y = convertSize(94);
            b.X = a.X + box_width;
            b.Y = a.Y;
            g.DrawLine(pen4, a, b); // Right black box
            g.DrawString("ADP", font14, Brushes.White, 370 - box_width + 4, convertSize(94) - 10);

            x = x_margin;
            y = y_margin;

            // Carrier line
            g.DrawString("CARRIER:", font10b, Brushes.Black, x, y);
            g.DrawString("TOLL PRIORITY", font10, Brushes.Black, x + 80, y);
            y += line_height;

            // Service line
            g.DrawString(string.Format("SERVICE: {0}", serviceName), font10b, Brushes.White, x, y);
            y += line_height;

            // Connote line
            g.DrawString(string.Format("CONNOTE #: {0}", GetConnoteNumber(temp_invoice)), font10b, Brushes.Black, x, y);
            y += line_height2;

            // Sender details
            g.DrawString("FROM:", font10b, Brushes.Black, x, y);
            y += line_height2;
            g.DrawString("Bright Life Australia", font10, Brushes.Black, x, y);
            g.DrawString(string.Format("ACCT# {0}", ACCOUNT_NUMBER), font10, Brushes.Black, x + 120, y);
            y += line_height2;
            g.DrawString("3/7 Jubilee Ave", font10, Brushes.Black, x, y);
            y += line_height2;
            g.DrawString("WARRIEWOOD NSW 2102", font10, Brushes.Black, x, y);
            y += line_height2 * 2;

            g.DrawString("FOR ANY ISSUES PLEASE CONTACT:", font10, Brushes.Black, x, y);
            y += line_height2;
            g.DrawString("CUSTOMER SUPPORT ON (02) 9979 0283", font10, Brushes.Black, x, y);
            y += line_height2 * 2;

            // Customer details
            g.DrawString("TO:", font12b, Brushes.Black, x, y);
            y += line_height3;
            g.DrawString(temp_invoice.InvoiceCustomer.FullName, font12, Brushes.Black, x, y);
            y += line_height3;
            g.DrawString(temp_invoice.InvoiceCustomer.Address1, font12, Brushes.Black, x, y);
            y += line_height3;
            if(!string.IsNullOrEmpty(temp_invoice.InvoiceCustomer.Address2)) {
                g.DrawString(temp_invoice.InvoiceCustomer.Address2, font12, Brushes.Black, x, y);
            }

            y += line_height3;
            if (API.CustomerAPI.IsMobile(temp_invoice.InvoiceCustomer.PhoneNumber)) {
                string mobile = API.CustomerAPI.GetNormalisedMobileNumber(temp_invoice.InvoiceCustomer.PhoneNumber);
                g.DrawString("Consumer Mobile No: " + mobile, font10, Brushes.Black, x, y);
            }
            y += line_height2;
            //g.DrawString("Consumer Email: " + temp_invoice.InvoiceCustomer.EmailAddress, font10, Brushes.Black, x, y);
            y += line_height2;

            y += line_height3;

            g.DrawString(temp_invoice.InvoiceCustomer.City, font14b, Brushes.Black, x, y);
            y += line_height;
            g.DrawString(string.Format("{0}, {1}", temp_invoice.InvoiceCustomer.State, temp_invoice.InvoiceCustomer.Postcode), font14b, Brushes.Black, x, y);
            y += line_height * 2;

            // Special instructions
            g.DrawString("Special instructions: Authorised to leave in safe, protective location", font10, Brushes.Black, x, y);
            y += line_height2;

            // Description of goods
            g.DrawString("Description of goods: Non-Hazardous Cargo", font10, Brushes.Black, x, y);
            y += line_height;

            // Rotated text on left
            SizeF sz = g.VisibleClipBounds.Size;
            g.TranslateTransform(0, sz.Height);
            g.RotateTransform(270);
            g.DrawString("THIS ITEM WILL BE SUBJECT TO SECURITY SCREENING AND CLEARING", font10, Brushes.Black, new RectangleF(100, 10, sz.Height, sz.Width), new StringFormat());
            g.ResetTransform();

            // Rotated text on right
            g.TranslateTransform(sz.Width, 0);
            g.RotateTransform(90);
            g.DrawString("CARRIERS TERMS AND CONDITIONS APPLY. DANGEROUS GOODS NOT CONSIGNED WITHIN", font10, Brushes.Black, new RectangleF(0, 10, sz.Height, sz.Width), centerformat);
            g.ResetTransform();

            API.InvoicesAPI.SaveInvoiceParcelReturnParcelID(temp_invoice, p);

            // Also update the invoice database table with the barcode data
            /*if (connection != null) {
                if (connection.State != System.Data.ConnectionState.Open)
                    connection.open();
                if (connection.State == System.Data.ConnectionState.Open) {
                    API.Invoices.SaveInvoiceParcelReturnParcelID(temp_invoice, p);
                    string query = String.Format("UPDATE ps_invoice_info SET barcode_text='{0}', article_id='{2}' WHERE id={1}", p.BarcodeNumber, p.ParcelID, p.ArticleID);
                    //MySqlCommand cmd_update = new MySqlCommand(query, SQLConnection);
                    //cmd_update.ExecuteNonQuery();
                    connection.runNonQuery(query);
                }
                connection.close();
            }*/
        }
 public abstract void PrintLabel(Graphics g, Invoice temp_invoice, Parcel p);
        public override void PrintLabel(System.Drawing.Graphics g, Invoice temp_invoice, Parcel p)
        {
            g.Clear(Color.Transparent);

            // List all fonts
            /*FontFamily ff = null;
            InstalledFontCollection fontsCollection = new InstalledFontCollection();
            FontFamily[] fontFamilies = fontsCollection.Families;
            foreach (FontFamily font in fontFamilies) {
                Console.Write(font.Name);
                if (font.IsStyleAvailable(FontStyle.Regular))
                    Console.WriteLine(" (regular available)");
                else
                    Console.WriteLine(" (regular not available)");

                if (font.Name.Equals("Code 128")) {
                    ff = font;
                    Console.WriteLine("128 set");
                }
            }*/
            FontFamily code128 = pfc.Families[0];
            FontFamily zurich = pfc.Families[1];
            Font f_eparcel = new Font(zurich, convertSize(36), FontStyle.Regular);
            Font f_titles = new Font(zurich, convertSize(10), FontStyle.Bold);
            Font f_smaller_titles = new Font(zurich, convertSize(8), FontStyle.Bold);
            Font f_address = new Font(zurich, convertSize(10), FontStyle.Regular);
            Font f_sender = new Font(zurich, convertSize(8), FontStyle.Regular);
            Font f_barcode = new Font(code128, 42, FontStyle.Regular);
            //Font f_barcodea = new Font("Code128", convertSize(36), FontStyle.Regular);
            Font f_disclaimer = new Font(zurich, convertSize(6), FontStyle.Regular);
            Font f_disclaimer_b = new Font(zurich, convertSize(6), FontStyle.Bold);

            Pen pen1 = new Pen(Brushes.Black);
            pen1.Width = 2.0F;
            Pen pen2 = new Pen(Brushes.Black);
            pen2.Width = 1.0F;

            // Generate barcode
            string code = "4DY"; // Marchant Location ID
            code += temp_invoice.InvoiceNo.Remove(0, 2); // Remove the SI from the invoice number
            string consign_number = code;
            //code += "01"; // First parcel in group
            code += p.ParcelNumber.ToString("D2");
            // NOTE: Bean may ask to change this to no signature required for under 500g
            code += "02"; // Service Code; Signature needed
            if (p.ParcelNumber == p.TotalParcels) {
                code += "2"; // Single item or last in a multi-parcel consignment
            } else {
                code += "1"; // More parcels after this one
            }
            code += Tools.get_checksum_bit(code); // Check digit

            string full_code = "997" + "00160" + code + "1" + temp_invoice.InvoiceCustomer.Postcode;
            //full_code += get_symbol_check(full_code);
            p.BarcodeNumber = full_code;
            p.ArticleID = code;

            //int b_width = 242, b_height = 92;
            int b_width = 466, b_height = convertSize(92);
            string temp = BarcodeTools.encode128barcode(full_code);
            char[] charray = temp.ToCharArray();

            //Barcode barcode = new Barcode();
            //barcode.Alignment = BarcodeLib.AlignmentPositions.CENTER;
            //Image barcode_img = barcode.Encode(TYPE.CODE128, full_code, Color.Black, Color.White, b_width, b_height);
            //Bitmap b_img = Tools.ResizeImage(barcode_img, 345, 92);

            // Also need to update the invoice table with the barcode text
            API.InvoicesAPI.SaveInvoiceParcelReturnParcelID(temp_invoice, p);

            int x = 0, y = 0;
            int x_margin = convertSize(13), y_margin = convertSize(10);
            int width = convertSize(400), height = convertSize(600);
            int disclaimer_y = 0;

            x = convertSize(15);
            y = convertSize(20);
            // Add AP image
            try {
                Stream img_stream = System.Reflection.Assembly.GetEntryAssembly().GetManifestResourceStream("LabelPrintingSystem_Manifest.Images.105mm Black Header.jpg");

                //Stream file = System.Reflection.GetManifestResourceStream("105mm Black Header.jpg");
                //Image img = Image.FromFile("105mm Black Header.jpg");
                Image img = Image.FromStream(img_stream);
                img = Tools.ResizeImage(img, convertSize(img.Width), convertSize(img.Height));
                g.DrawImage(img, 0, y-10);
                //Image img = Image.From
            } catch (Exception exc) {
                Log.LogException(exc);
                //
            }

            y += convertSize(55);
            //customer name
            g.DrawString("DELIVER TO", f_titles, Brushes.Black, x, y);
            g.DrawString("PHONE: 0391060000", f_smaller_titles, Brushes.Black, x + convertSize(243), y);
            y += convertSize(30);
            g.DrawString(temp_invoice.InvoiceCustomer.Title + " " + temp_invoice.InvoiceCustomer.Firstname + " " + temp_invoice.InvoiceCustomer.Middlename + " " + temp_invoice.InvoiceCustomer.Lastname, f_address, Brushes.Black, x, y);

            //customer address
            y += convertSize(20);
            g.DrawString(temp_invoice.InvoiceCustomer.Address1 + " ", f_address, Brushes.Black, x, y);
            y += convertSize(20);
            g.DrawString(temp_invoice.InvoiceCustomer.Address2 + " ", f_address, Brushes.Black, x, y);
            y += convertSize(21);
            g.DrawString(temp_invoice.InvoiceCustomer.City + " ", f_address, Brushes.Black, x, y);
            g.DrawString(temp_invoice.InvoiceCustomer.State + " ", f_address, Brushes.Black, x + convertSize(195), y);
            g.DrawString(temp_invoice.InvoiceCustomer.Postcode + " ", f_address, Brushes.Black, x + convertSize(250), y);

            y += convertSize(26);
            g.DrawLine(pen2, x_margin, y + convertSize(18), width - x_margin, y + convertSize(18));

            y += convertSize(28);
            g.DrawString("DELIVERY INSTRUCTIONS", f_smaller_titles, Brushes.Black, x, y);
            g.DrawString(String.Format("{0} kg", Tools.get_weight_string(p.Weight.ToString())), f_titles, Brushes.Black, x + convertSize(300), y - convertSize(5));

            y += convertSize(20);
            g.DrawString("DELIVERY SIGNATURE ALWAYS REQUIRED", f_address, Brushes.Black, x, y);
            y += convertSize(15);
            g.DrawString("DO NOT leave parcel", f_address, Brushes.Black, x, y);

            y += convertSize(25);
            //g.DrawString("AUTHORITY TO LEAVE IF UNATTENDED", f_smaller_titles, Brushes.Black, x, y);
            g.DrawString(String.Format("CON NO {0}", consign_number), f_address, Brushes.Black, x + convertSize(225), y);
            y += convertSize(15);
            g.DrawString(String.Format("Parcel {0} of {1}", p.ParcelNumber, p.TotalParcels), f_smaller_titles, Brushes.Black, x + convertSize(225), y);

            y += convertSize(3);
            g.DrawLine(pen2, x_margin, y + convertSize(18), width - x_margin, y + convertSize(18));

            y += convertSize(20);
            g.DrawString("AP Article Id: " + code, f_address, Brushes.Black, x + convertSize(100), y);
            y += convertSize(20);

            //g.DrawImage(barcode_img, x + 16, y);
            g.DrawString(Code128.Encode(full_code), f_barcode, Brushes.Black, x, y);
            g.DrawString(Code128.Encode(full_code), f_barcode, Brushes.Black, x, y+35);
            //g.DrawString("1384213010224", f_barcode, Brushes.Black, x + 90, y);
            y += convertSize(98);
            g.DrawString("AP Article Id: " + code, f_address, Brushes.Black, x + convertSize(100), y);

            y += convertSize(30);
            disclaimer_y = y;
            g.DrawString("SENDER", f_smaller_titles, Brushes.Black, x, y);
            g.DrawLine(pen2, convertSize(150), y, convertSize(150), height - y_margin);

            y += convertSize(15);
            g.DrawString("Bright Life Australia", f_sender, Brushes.Black, x, y);
            y += convertSize(15);
            g.DrawString("PO Box 6521", f_sender, Brushes.Black, x, y);
            y += convertSize(15);
            g.DrawString("Brookvale", f_sender, Brushes.Black, x, y);
            y += convertSize(15);
            g.DrawString("NSW 2100", f_sender, Brushes.Black, x, y);
            y += convertSize(30);
            g.DrawString("Tel: 02 9979 0283", f_sender, Brushes.Black, x, y);

            y = disclaimer_y;
            int tx = x + convertSize(155);
            g.DrawString("Aviation Security and Dangerous Goods Declaration", f_disclaimer_b, Brushes.Black, tx, y);
            y += convertSize(15);
            g.DrawString("The sender acknowledges that this article may be carried by air", f_disclaimer, Brushes.Black, tx, y);
            y += convertSize(10);
            g.DrawString("and will be subject to aviation security and clearing procedures;", f_disclaimer, Brushes.Black, tx, y);
            y += convertSize(10);
            g.DrawString("and the sender and will be subject to aviation security and", f_disclaimer, Brushes.Black, tx, y);
            y += convertSize(10);
            g.DrawString("clearing procedures; and the sender declares that the article does", f_disclaimer, Brushes.Black, tx, y);
            y += convertSize(10);
            g.DrawString("not contain any dangerous or prohibited goods, explosive or", f_disclaimer, Brushes.Black, tx, y);
            y += convertSize(10);
            g.DrawString("incendiary devices. A false declaration is a criminal offence.", f_disclaimer, Brushes.Black, tx, y);
        }
        internal int SaveInvoiceParcelReturnParcelID(Invoice invoice, Parcel parcel)
        {
            int result = 0;

            IDataConnection connection = DatabaseAPI.GetConnection();
            connection.open();

            if (API.InvoicesAPI.DoesInvoiceExist(parcel.ParcelID.ToString()))
            {
                string query = String.Format("UPDATE ps_invoice_info SET invoiceNo='{0}', parcel_weight={1}*1000, custNo='{2}',address1='{3}', address2='{4}', title='{5}',surName='{6}', firstName='{7}', middleName='{8}', city='{9}', postcode='{10}', state='{11}', countryCode='{12}', companyName='{13}', companyABN='{14}', companyAddress='{15}', carrier_id={16}, charge={17}, parcel_num='{18}', ipv4='127.0.0.1', status={19}, dimL={20}, dimW={21}, dimH={22}, phoneNumber='{23}', emailAddress='{24}', barcode_text='{25}', article_id='{26}' WHERE id={27}",
                    Tools.replace_quote(invoice.InvoiceNo),
                    parcel.Weight,
                    Tools.replace_quote(invoice.InvoiceCustomer.CustomerNumber),
                    Tools.replace_quote(invoice.InvoiceCustomer.Address1),
                    Tools.replace_quote(invoice.InvoiceCustomer.Address2),
                    Tools.replace_quote(invoice.InvoiceCustomer.Title),
                    Tools.replace_quote(invoice.InvoiceCustomer.Lastname),
                    Tools.replace_quote(invoice.InvoiceCustomer.Firstname),
                    Tools.replace_quote(invoice.InvoiceCustomer.Middlename),
                    Tools.replace_quote(invoice.InvoiceCustomer.City),
                    Tools.replace_quote(invoice.InvoiceCustomer.Postcode),
                    Tools.replace_quote(invoice.InvoiceCustomer.State),
                    Tools.replace_quote(invoice.InvoiceCustomer.Country),
                    Tools.replace_quote(invoice.CompanyName),
                    Tools.replace_quote(invoice.CompanyABN),
                    Tools.replace_quote(invoice.CompanyAddress),
                    invoice.Provider.CarrierId,
                    parcel.CostEstimate,
                    parcel.ParcelNumber,
                    (int)invoice.Status,
                    parcel.Size.Length,
                    parcel.Size.Width,
                    parcel.Size.Height,
                    invoice.InvoiceCustomer.PhoneNumber,
                    invoice.InvoiceCustomer.EmailAddress,
                    parcel.BarcodeNumber,
                    parcel.ArticleID,
                    parcel.ParcelID
                );

                try
                {
                    connection.runNonQuery(query);
                    result = parcel.ParcelID;
                }
                catch (Exception exc)
                {
                    throw exc;
                }
                finally
                {
                    if (connection != null && connection.State == ConnectionState.Open)
                        connection.close();
                }
            }
            else
            {

                string query = String.Format("INSERT INTO ps_invoice_info SET invoiceNo='{0}', parcel_weight={1}*1000, custNo='{2}',address1='{3}', address2='{4}', title='{5}',surName='{6}', firstName='{7}', middleName='{8}', city='{9}', postcode='{10}', state='{11}', countryCode='{12}', companyName='{13}', companyABN='{14}', companyAddress='{15}', carrier_id={16}, charge={17}, parcel_num='{18}', ipv4='127.0.0.1', status={19}, dimL={20}, dimW={21}, dimH={22}, phoneNumber='{23}', emailAddress='{24}', barcode_text='{25}', article_id='{26}'; select last_insert_id();",
                    Tools.replace_quote(invoice.InvoiceNo),
                    parcel.Weight,
                    Tools.replace_quote(invoice.InvoiceCustomer.CustomerNumber),
                    Tools.replace_quote(invoice.InvoiceCustomer.Address1),
                    Tools.replace_quote(invoice.InvoiceCustomer.Address2),
                    Tools.replace_quote(invoice.InvoiceCustomer.Title),
                    Tools.replace_quote(invoice.InvoiceCustomer.Lastname),
                    Tools.replace_quote(invoice.InvoiceCustomer.Firstname),
                    Tools.replace_quote(invoice.InvoiceCustomer.Middlename),
                    Tools.replace_quote(invoice.InvoiceCustomer.City),
                    Tools.replace_quote(invoice.InvoiceCustomer.Postcode),
                    Tools.replace_quote(invoice.InvoiceCustomer.State),
                    Tools.replace_quote(invoice.InvoiceCustomer.Country),
                    Tools.replace_quote(invoice.CompanyName),
                    Tools.replace_quote(invoice.CompanyABN),
                    Tools.replace_quote(invoice.CompanyAddress),
                    invoice.Provider.CarrierId,
                    parcel.CostEstimate,
                    parcel.ParcelNumber,
                    (int)invoice.Status,
                    parcel.Size.Length,
                    parcel.Size.Width,
                    parcel.Size.Height,
                    invoice.InvoiceCustomer.PhoneNumber,
                    invoice.InvoiceCustomer.EmailAddress,
                    parcel.BarcodeNumber,
                    parcel.ArticleID);

                try
                {
                    int.TryParse(connection.runScalar(query).ToString(), out result);
                }
                catch (FormatException)
                {
                    result = 0;
                }
                finally
                {
                    if (connection != null && connection.State == ConnectionState.Open)
                        connection.close();
                }
            }
            return result;
        }
        internal CostEstimate GetCostEstimateFor(Carrier carrier, Invoice invoice, Dimensions dimensions, float[] parcelWeights)
        {
            int numParcels = parcelWeights.Length;
            CostEstimate estimate = new CostEstimate();

            double weightTotal = 0.0f, sizeTotal = 0.0f;

            string new_temp_city = invoice.InvoiceCustomer.City;
            int parcelNumber = 1;

            //int numSizeWeights = txtBox_input_dimensions.Text == "" ? 0 : txtBox_input_dimensions.Text.Split('/').Length;

            // Split the weights and do separate checks for each
            foreach (float weight in parcelWeights)
            {
                if (weight > MAXIMUM_WEIGHT)
                {
                    throw new PricingException($"Parcel weight is larger than {MAXIMUM_WEIGHT}KGs!");
                }

                Parcel p = new Parcel(weight, parcelNumber, 0.0d, numParcels);
                p.Size = dimensions;

                API.InvoicesAPI.AddParcelToInvoice(invoice, p);

                float sizeWeight = p.getSizeWeight() * carrier.DimensionWeightRate;

                weightTotal += GetCostEstimate(carrier, p, invoice);
                sizeTotal += sizeWeight == 0 ? 0.0f : GetCostEstimateByWeight(sizeWeight, carrier, p, invoice);

                parcelNumber++;
            }

            return estimate;
        }
 internal float GetCostEstimate(Carrier carrier, Parcel parcel, Invoice invoice)
 {
     return GetCostEstimateByWeight(parcel.Weight, carrier, parcel, invoice);
 }
Exemplo n.º 14
0
 public static float GetCostEstimateByWeight(float weight, Carrier carrier, Parcel parcel, Invoice invoice)
 {
     return Actions.GetCostEstimateByWeight(weight, carrier, parcel, invoice);
 }
        private string GenerateBarcode(Invoice invoice, Parcel p)
        {
            string item_number = GetConnoteNumber(invoice) + string.Format("{0}", p.ParcelNumber).PadLeft(3, '0');
            string barcode_number = string.Format("T{0}{1}{2}0", invoice.InvoiceCustomer.Postcode.PadLeft(4, '0'), SERVICE_CODE, item_number);
            barcode_number = GetCheckDigit(barcode_number);

            // Generate barcode

            p.BarcodeNumber = barcode_number;
            p.ArticleID = item_number;

            //int b_width = 242, b_height = 92;
            //int b_width = 466, b_height = convertSize(92);
            string temp = BarcodeTools.encode128barcode(barcode_number);
            return barcode_number;
        }
        public override void PrintLabel(System.Drawing.Graphics g, Invoice temp_invoice, Parcel p)
        {
            Font font1 = new Font("Verdana", 18, FontStyle.Bold);
            Font font2 = new Font("Verdana", 10, FontStyle.Regular);
            Font font3 = new Font("3 of 9 Barcode", 22, FontStyle.Regular);
            Font font4 = new Font("Verdana", 8, FontStyle.Regular);
            Pen pen1 = new Pen(Brushes.Black);

            int x = 55;//10
            int y = -350;//-290
            int x1;
            int x2;
            int y1;
            int y2;

            g.RotateTransform(90);

            //company name
            g.DrawString(temp_invoice.CompanyName, font1, Brushes.Black, x, y);

            //company information
            x = x + 5;//15
            g.DrawString("ABN   " + temp_invoice.CompanyABN, font4, Brushes.Black, x, y + 30);
            g.DrawString("Return Address:", font4, Brushes.Black, x, y + 45);
            g.DrawString(temp_invoice.CompanyAddress, font4, Brushes.Black, x, y + 60);

            //order information
            g.DrawString("Inv. No.: " + temp_invoice.InvoiceNo, font2, Brushes.Black, x, y + 80);
            //g.DrawString("Run: " + temp_state + " " + "", font2, Brushes.Black, x + 220, y + 80);

            //order barcode
            g.DrawString("*" + temp_invoice.InvoiceNo + "*", font3, Brushes.Black, x, y + 100);

            //draw box of customer information
            g.DrawString("DELIVERED TO:", font2, Brushes.Black, x, y + 140);
            x = x + 10;//25
            x1 = x - 5;
            x2 = x1 + 460;//315
            y1 = y + 165;
            y2 = y1 + 110;
            //top
            g.DrawLine(pen1, x1, y1, x2, y1);
            //left
            g.DrawLine(pen1, x1, y1, x1, y2);
            //right
            g.DrawLine(pen1, x2, y1, x2, y2);
            //buttom
            g.DrawLine(pen1, x1, y2, x2, y2);
            //customer name
            g.DrawString(temp_invoice.InvoiceCustomer.Greeting, font2, Brushes.Black, x, y + 170);
            //customer address
            g.DrawString(temp_invoice.InvoiceCustomer.Address1, font2, Brushes.Black, x, y + 195);//190
            g.DrawString(temp_invoice.InvoiceCustomer.Address2, font2, Brushes.Black, x, y + 220);//210
            //g.DrawString(temp_address3, font2, Brushes.Black, x, y + 230);//230
            g.DrawString(temp_invoice.InvoiceCustomer.City, font2, Brushes.Black, x, y + 250);

            x = x + 210;//235
            x = x + 135;//430
            //state symbol
            g.DrawString("", font2, Brushes.Black, x + 5, y + 220);
            g.DrawString(temp_invoice.InvoiceCustomer.State, font2, Brushes.Black, x, y + 245);

            x = x + 50;//285 ->430
            //postcode
            g.DrawString(temp_invoice.InvoiceCustomer.Postcode, font2, Brushes.Black, x, y + 245);
            x = x - 135;

            x = x + 70;//355
            //barcode of postcode
            g.DrawString("*" + temp_invoice.InvoiceCustomer.Postcode + "*", font3, Brushes.Black, x + 5, y + 5);

            //draw POSTAGE PAID AUSTRALIA
            //g.DrawImage(global::BL_AU_PrintingLabelSystem.Properties.Resources.postage_paid_australia, x, 60);
            x1 = x + 13;
            x2 = x1 + 100;
            y1 = y + 40;//70
            y2 = y1 + 100;
            //top
            g.DrawLine(pen1, x1, y1, x2, y1);
            //left
            g.DrawLine(pen1, x1, y1, x1, y2);
            //right
            g.DrawLine(pen1, x2, y1, x2, y2);
            //buttom
            g.DrawLine(pen1, x1, y2, x2, y2);
            g.DrawString("POSTAGE", font2, Brushes.Black, x + 25, y + 55);//y85
            g.DrawString("PAID", font2, Brushes.Black, x + 43, y + 80);//y110
            g.DrawString("AUSTRALIA", font2, Brushes.Black, x + 20, y + 105);//y135
        }
 private float getDimensionalWeight(Invoice i, Parcel p)
 {
     return p.getSizeWeight() * i.Provider.DimensionWeightRate;
 }
        public override void PrintLabel(Graphics g, Invoice temp_invoice, Parcel p)
        {
            Font font1 = new Font("Arial", 14, FontStyle.Bold);
            Font font2 = new Font("Arial", 12, FontStyle.Bold);
            Font font3 = new Font("Arial", 10, FontStyle.Bold);
            Font font4 = new Font("Arial", 8, FontStyle.Bold);
            Font font5 = new Font("Arial", 26, FontStyle.Bold);
            Font fontBarcode = new Font("3 of 9 Barcode", 30, FontStyle.Regular);
            Pen pen1 = new Pen(Brushes.Black);
            pen1.Width = 2.0F;
            Pen pen2 = new Pen(Brushes.Black);
            pen2.Width = 1.5F;

            int x_org = 15;//10//5
            int y_org = -385;//20//-395
            int x = x_org;
            int y = y_org;
            int x1, x2, y1, y2;

            g.RotateTransform(90);

            //customer name
            g.DrawString("To: " + temp_invoice.InvoiceCustomer.Greeting, font1, Brushes.Black, x, y);

            //customer address
            y = y + 25;
            g.DrawString(temp_invoice.InvoiceCustomer.Address1 + " ", font2, Brushes.Black, x + 5, y);
            y = y + 20;
            g.DrawString(temp_invoice.InvoiceCustomer.Address2 + " ", font2, Brushes.Black, x + 5, y);
            y = y + 20;
            g.DrawString(temp_invoice.InvoiceCustomer.City + " ", font2, Brushes.Black, x + 5, y);
            g.DrawString(temp_invoice.InvoiceCustomer.Postcode + " ", font2, Brushes.Black, x + 155, y + 20);

            //reference
            y = y + 80;
            //g.DrawString("Ref", font3, Brushes.Black, x + 10, y);
            //g.DrawString("123456789123456789", font3, Brushes.Black, x + 50, y);

            //consignment
            y = y + 20;
            g.DrawString("CONSIGNMENT", font2, Brushes.Black, x + 5, y);
            g.DrawString("XS" + temp_invoice.InvoiceNo.Substring(3), font2, Brushes.Black, x + 175, y);
            g.DrawString("ROAD FREIGHT", font2, Brushes.Black, x + 305, y);

            //barcode
            y = y + 45;
            //g.DrawString("*XS" + temp_invoice.InvoiceNo.Substring(3) + Tools.digit_3("1") + Tools.digit_3("1") + temp_invoice.InvoiceCustomer.Postcode + "*", fontBarcode, Brushes.Black, x + 0, y);
            g.DrawString("*XS" + temp_invoice.InvoiceNo.Substring(3) + p.ParcelNumber.ToString("D3") + temp_invoice.Parcels.Count.ToString("D3") + temp_invoice.InvoiceCustomer.Postcode + "*", fontBarcode, Brushes.Black, x + 0, y);

            //company name
            y = y + 65;
            g.DrawString("From: " + temp_invoice.CompanyName, font4, Brushes.Black, x + 5, y);
            //company address
            g.DrawString(temp_invoice.CompanyAddress, font4, Brushes.Black, x + 5, y + 15);
            //company tel
            g.DrawString("9979 0283", font4, Brushes.Black, x + 5, y + 30);
            //date
            g.DrawString(Tools.date_now_print(), font4, Brushes.Black, x + 5, y + 45);

            //customer name
            g.DrawString("To: " + temp_invoice.InvoiceCustomer.Greeting, font4, Brushes.Black, x + 225, y);
            //customer address 1
            g.DrawString(temp_invoice.InvoiceCustomer.Address1, font4, Brushes.Black, x + 225, y + 15);
            //customer address 2
            g.DrawString(temp_invoice.InvoiceCustomer.Address2, font4, Brushes.Black, x + 225, y + 30);
            //customer city
            g.DrawString(temp_invoice.InvoiceCustomer.City, font4, Brushes.Black, x + 225, y + 45);
            //customer postcode
            g.DrawString(temp_invoice.InvoiceCustomer.Postcode, font4, Brushes.Black, x + 325, y + 60);
            //consignment
            g.DrawString("CONSIGNMENT " + "XS" + temp_invoice.InvoiceNo.Substring(3), font4, Brushes.Black, x + 225, y + 75);

            //instruction
            g.DrawString("Instructions:", font4, Brushes.Black, x + 410, y);//425
            //instruction line 1
            g.DrawString("IF NO ONE HOME", font4, Brushes.Black, x + 410, y + 15);
            //instruction line 2
            g.DrawString("SECURE DROP", font4, Brushes.Black, x + 410, y + 30);
            //instruction line 3
            g.DrawString("    (for HOUSE Address Only)", font4, Brushes.Black, x + 410, y + 45);
            //instruction line 4
            g.DrawString("DO NOT leave parcel", font4, Brushes.Black, x + 410, y + 60);
            //instruction line 5
            g.DrawString("    (for APARTMENT address)", font4, Brushes.Black, x + 410, y + 75);

            //headport
            x = x_org + 325;
            y = y_org;
            string txt_headport = "";
            if (temp_invoice.HeadPort.Length == 3) {
                txt_headport = temp_invoice.HeadPort.Substring(0, 1) + "  " + temp_invoice.HeadPort.Substring(1, 1) + "  " + temp_invoice.HeadPort.Substring(2, 1);
                // call head port
                g.DrawString(txt_headport, font5, Brushes.Black, x + 15, y + 10);
            } else if (temp_invoice.HeadPort.Length == 2) {
                txt_headport = " " + temp_invoice.HeadPort.Substring(0, 1) + "   " + temp_invoice.HeadPort.Substring(1, 1);
                // call head port
                g.DrawString(txt_headport, font5, Brushes.Black, x + 25, y + 10);
            }

            //logo box
            x1 = x;
            x2 = x1 + 168;
            y1 = y + 5;
            y2 = y1 + 50;
            g.DrawLine(pen1, x1, y1, x2, y1);
            g.DrawLine(pen1, x1, y1, x1, y2);
            g.DrawLine(pen1, x1, y2, x2, y2);
            g.DrawLine(pen1, x2, y1, x2, y2);

            //print
            y = y + 60;
            g.DrawString("Print", font2, Brushes.Black, x, y);
            g.DrawLine(pen2, x, y + 18, x + 230, y + 18);

            //signature
            y = y + 20;
            g.DrawString("Signature", font2, Brushes.Black, x, y);
            g.DrawLine(pen2, x, y + 18, x + 230, y + 18);

            //date/time
            y = y + 20;
            g.DrawString("Date/Time", font2, Brushes.Black, x, y);
            g.DrawLine(pen2, x, y + 18, x + 230, y + 18);

            //account
            y = y + 20;
            g.DrawString("Account: BLIFE", font2, Brushes.Black, x, y);

            //no of parcel
            y = y + 25;
            g.DrawString("Items: " + p.ParcelNumber + "/" + temp_invoice.Parcels.Count, font2, Brushes.Black, x + 150, y);
        }
Exemplo n.º 19
0
 public void addParcel(Parcel p)
 {
     parcels.Add(p);
 }
        private void act_print(Enums.CarrierDatabaseKey carrier, Parcel p)
        {
            int page_width = 0, page_height = 0;
            pDoc = new PrintDocument();

            pSDlg.Document = pDoc;
            pDlg.Document = pDoc;

            //MessageBox.Show(digit_3(temp_parcel_num_page) + "/" + digit_3(temp_parcel_num));
            if (carrier == Enums.CarrierDatabaseKey.AUSTRALIA_POST)
            {
                pDoc.PrintPage += (sender, args) => printMaterial(p, args, Enums.CarrierDatabaseKey.AUSTRALIA_POST);
                if (String.Equals(AP_PRINTER, "Dialog"))
                {
                    pDlg.ShowDialog();
                }
                else if (!String.Equals(AP_PRINTER, "Default"))
                {
                    pDlg.PrinterSettings.PrinterName = AP_PRINTER;
                }
                page_width = 400;
                page_height = 600;
            }
            else if (carrier == Enums.CarrierDatabaseKey.HUNTER)
            {
                //pDoc.PrintPage += new PrintPageEventHandler(print_material_hunterexpress);
                pDoc.PrintPage += (sender, args) => printMaterial(p, args, Enums.CarrierDatabaseKey.HUNTER);
                if (String.Equals(HE_PRINTER, "Dialog"))
                {
                    pDlg.ShowDialog();
                }
                else if (!String.Equals(HE_PRINTER, "Default"))
                {
                    pDlg.PrinterSettings.PrinterName = HE_PRINTER;
                }
                page_width = 400;
                page_height = 600;
            }
            else if (carrier == Enums.CarrierDatabaseKey.EPOST)
            {
                //pDoc.PrintPage += new PrintPageEventHandler(print_material_epost);
                pDoc.PrintPage += (sender, args) => printMaterial(p, args, Enums.CarrierDatabaseKey.EPOST);
                if (String.Equals(EP_PRINTER, "Dialog"))
                {
                    pDlg.ShowDialog();
                }
                else if (!String.Equals(EP_PRINTER, "Default"))
                {
                    pDlg.PrinterSettings.PrinterName = EP_PRINTER;
                }
                page_width = EpostPrinter.convertSize(400);
                page_height = EpostPrinter.convertSize(600);
            }
            else if (carrier == Enums.CarrierDatabaseKey.TOLL)
            {
                //pDoc.PrintPage += new PrintPageEventHandler(print_material_hunterexpress);
                pDoc.PrintPage += (sender, args) => printMaterial(p, args, Enums.CarrierDatabaseKey.TOLL);
                if (String.Equals(TL_PRINTER, "Dialog"))
                {
                    pDlg.ShowDialog();
                }
                else if (!String.Equals(TL_PRINTER, "Default"))
                {
                    pDlg.PrinterSettings.PrinterName = TL_PRINTER;
                }
                page_width = 400;
                page_height = 600;
            }

            //set the paper size
            //1 mm = 0.0393700787 inch
            //75 mm -> 295 - the width of the paper, in hundredths of an inch
            //130 mm -> 511 - the height of the paper, in hundredths of an inch
            //testing label = 4" x 6"
            pSDlg.PageSettings.PaperSize = new PaperSize("Custom Paper Size", page_width, page_height);
            //production label = 3" x 5"
            //pSDlg.PageSettings.PaperSize = new PaperSize("Custom Paper Size", 300, 500);
            //set margins
            pSDlg.PageSettings.Margins = new Margins(0, 0, 0, 0);
            //set landscape
            //pSDlg.PageSettings.Landscape = true;
            //set portrait
            pSDlg.PageSettings.Landscape = false;
            pDoc.Print();
        }
Exemplo n.º 21
0
 public static int SaveInvoiceParcelReturnParcelID(Invoice invoice, Parcel parcel)
 {
     return Actions.SaveInvoiceParcelReturnParcelID(invoice, parcel);
 }
Exemplo n.º 22
0
 public static void AddParcelToInvoice(Invoice invoice, Parcel parcel)
 {
     Actions.AddParcelToInvoice(invoice, parcel);
 }