public MailSend(Invoice invoice, Enums.MessageType type) { ID = 0; this.Invoice = invoice; MessageType = type; Status = Enums.MailStatus.WAITING; }
public Invoice(Invoice copyFrom) { id = 0; InvoiceCustomer = copyFrom.InvoiceCustomer; HeadPort = copyFrom.HeadPort; Packed = copyFrom.Packed; Provider = copyFrom.Provider; Status = copyFrom.Status; CompanyABN = copyFrom.CompanyABN; CompanyAddress = copyFrom.CompanyAddress; CompanyName = copyFrom.CompanyName; }
public bool CanAddInvoiceToManfest(Invoice invoice) { bool result = true; if (CarrierType == Enums.CarrierType.EPOST) { foreach (Parcel p in invoice.Parcels) { if (string.IsNullOrEmpty(p.ArticleID)) return false; else if (string.IsNullOrEmpty(p.BarcodeNumber)) return false; else if (string.IsNullOrEmpty(invoice.InvoiceCustomer.Address1)) return false; else if (p.Weight <= 0) return false; } } return result; }
private void load_data() { try { using (IDataReader reader = API.EmailingAPI.GetMailJobById(ID.ToString())) { if (reader.Read()) { Status = (Enums.MailStatus)int.Parse(reader["status"].ToString()); MessageType = (Enums.MessageType)int.Parse(reader["message_type"].ToString()); Invoice = new Invoice(reader["invoice_number"].ToString()); Invoice.loadInvoiceDetails(); } } } catch(Exception exc) { // Trouble connecting to database Console.WriteLine("Problem connecting: {0}", exc.Message); } }
void sendParcelSentEmailNotification(Invoice invoice) { IMailSender email = new MailSend(invoice, Enums.MessageType.PARCEL_SENT_NOTIFICATION); email.SaveJob(); }
internal void SaveInvoice(Invoice invoice) { IDataConnection connection = DatabaseAPI.GetConnection(); connection.open(); string query = string.Empty; if (invoice.Id > 0) { query = String.Format("UPDATE ps_invoice_info SET invoiceNo='{0}', parcel_weight=0, custNo='{1}', address1='{2}', address2='{3}', title='{4}', surName='{5}', firstName='{6}', middleName='{7}', city='{8}', postcode='{9}', state='{10}', countryCode='{11}', companyName='{12}', companyABN='{13}', companyAddress='{14}', carrier_id={17}, charge=0, ipv4='127.0.0.1', time_created='{15}', status={16}, dimL=0, dimW=0, dimH=0, WHERE id={18}", Tools.replace_quote(invoice.InvoiceNo), 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), Tools.datetime_now(), (int)invoice.Status, (int)invoice.Provider.CarrierId, invoice.Id); } else { query = String.Format("INSERT INTO ps_invoice_info SET invoiceNo='{0}', parcel_weight=0, custNo='{1}', address1='{2}', address2='{3}', title='{4}', surName='{5}', firstName='{6}', middleName='{7}', city='{8}', postcode='{9}', state='{10}', countryCode='{11}', companyName='{12}', companyABN='{13}', companyAddress='{14}', carrier_id={17}, charge=0, ipv4='127.0.0.1', time_created='{15}', status={16}, dimL=0, dimW=0, dimH=0", Tools.replace_quote(invoice.InvoiceNo), 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), Tools.datetime_now(), (int)invoice.Status, (int)invoice.Provider.CarrierId); } connection.runNonQuery(query); connection.close(); }
public static void SaveInvoice(Invoice invoice) { Actions.SaveInvoice(invoice); }
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); }
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 }
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; }
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; }
private void update_last_inserted() { lastInvoice = API.InvoicesAPI.GetLastInserted(); if (lastInvoice == null) { lastInvoice = API.InvoicesAPI.GetLastInserted(); if (lastInvoice != null) { if (lastInvoice.Parcels != null) { foreach (Parcel p in lastInvoice.Parcels) { p.Status = Enums.ParcelStatus.PACKED; p.Save(); } } txtBox_last_carrier.Text = lastInvoice.Provider.CarrierName; } } else { Parcel par = lastInvoice.Parcels.Count > 0 ? (Parcel)lastInvoice.Parcels[0] : new Parcel(); //txtBox_last_carrier.Text = String.Format("{0}", last_invoiced.Provider); txtBox_last_cost.Text = String.Format("{0:C}", par.CostEstimate); txtBox_last_invoiceNo.Text = lastInvoice.InvoiceNo; txtBox_last_packpick.Text = lastInvoice.Packed ? "Yes" : "No"; txtBox_last_parcelnum.Text = par.ParcelNumber.ToString(); txtBox_last_postcode.Text = lastInvoice.InvoiceCustomer.Postcode; txtBox_last_receiptient.Text = lastInvoice.InvoiceCustomer.FullName; txtBox_last_weight.Text = par.Weight.ToString(); txtBox_last_time.Text = lastInvoice.InvoiceDate.ToString("dd/MM/yyyy"); txtBox_last_carrier.Text = lastInvoice.Provider.CarrierName; } }
private string GetConnoteNumber(Invoice invoice) { int startIndex = invoice.InvoiceNo.Length-6; return CONNOTE_CUST_NUMBER + invoice.InvoiceNo.Substring(startIndex, 6); }
/// <summary> /// Determines which provider should be used, depending on the mitigating factors /// </summary> /// <returns>The indicated provider</returns> private Enums.CarrierDatabaseKey figure_out_suggestion(Invoice invoice) { bool use_hunter = true, use_toll = true; Enums.CarrierDatabaseKey provider = Enums.CarrierDatabaseKey.NONE; double cost_AP = 0.0; if (txtBox_estimate_AP.Text != "Invalid") { //cost_AP = Convert.ToDouble(txtBox_estimate_AP.Text); cost_AP = invoice.CurrentEstimates.ContainsKey(AustraliaPost) ? invoice.CurrentEstimates[AustraliaPost].WeightEstimate : 0.0; } double cost_HE = 0.0; if (txtBox_estimate_HE.Text != "Invalid") { //cost_HE = Convert.ToDouble(txtBox_estimate_HE.Text); cost_HE = invoice.CurrentEstimates.ContainsKey(HunterExpress) ? invoice.CurrentEstimates[HunterExpress].WeightEstimate : 0.0; } double cost_EP = 0.0; if (txtBox_estimate_EP.Text != "Invalid") { //cost_HE = Convert.ToDouble(txtBox_estimate_HE.Text); cost_EP = invoice.CurrentEstimates.ContainsKey(EPost) ? invoice.CurrentEstimates[EPost].WeightEstimate : 0.0; } double cost_TL = 0.0; if (txtBox_estimate_TL.Text != "Invalid") { //cost_HE = Convert.ToDouble(txtBox_estimate_HE.Text); cost_TL = invoice.CurrentEstimates.ContainsKey(Toll) ? invoice.CurrentEstimates[Toll].WeightEstimate : 0.0; } // Don't use Hunter Express or TOLL if it is a post box if(API.CustomerAPI.AddressIsPostBox(invoice.InvoiceCustomer)) { use_toll = false; use_hunter = false; // Set their estimate boxes to 'N/A' txtBox_estimate_HE.Text = "N/A"; txtBox_estimate_TL.Text = "N/A"; txtBox_size_estimate_TL.Text = "N/A"; } // Don't use Hunter Express if it is an apartment if (API.CustomerAPI.AddressIsApartment(invoice.InvoiceCustomer)) { use_hunter = false; txtBox_estimate_HE.Text = "N/A"; } // Don't use TOLL unless customer has a mobile or an email address, or if the address // is a parcel centre if (!API.CustomerAPI.HasPhoneNumberOrEmailAddress(invoice.InvoiceCustomer) || API.CustomerAPI.AddressIsParcelCentre(invoice.InvoiceCustomer)) { use_toll = false; txtBox_estimate_TL.Text = "N/A"; txtBox_size_estimate_TL.Text = "N/A"; } List<double> factors = new List<double>(); factors.Add(invoice.CurrentEstimates[EPost].HighestEstimate); factors.Add(invoice.CurrentEstimates[AustraliaPost].HighestEstimate); if (use_hunter) factors.Add(invoice.CurrentEstimates[HunterExpress].HighestEstimate); if (use_toll) factors.Add(invoice.CurrentEstimates[Toll].HighestEstimate); double factor = double.MaxValue; foreach (double val in factors) { if (val < factor) factor = val; } if (factor == invoice.CurrentEstimates[AustraliaPost].HighestEstimate) { provider = Enums.CarrierDatabaseKey.AUSTRALIA_POST; } else if (factor == invoice.CurrentEstimates[HunterExpress].HighestEstimate) { provider = Enums.CarrierDatabaseKey.HUNTER; } else if (factor == invoice.CurrentEstimates[Toll].HighestEstimate) { provider = Enums.CarrierDatabaseKey.TOLL; } else if (factor == invoice.CurrentEstimates[EPost].HighestEstimate) { provider = Enums.CarrierDatabaseKey.EPOST; } return provider; }
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(); }*/ }
//Form_insert_parcel_manually form2; public FulfilmentForm() { currentInvoice = new Invoice(); InitializeComponent(); setupProviders(); txtBox_input_invoiceNo.SelectAll(); txtBox_input_invoiceNo.Focus(); if (!UpdateForm()) { MessageBox.Show("Cannot connect to server. Please contact IT team."); } temp_parcel_num_page = "1"; }
public virtual float getCostEstimate(Parcel p, Invoice i) { return getEstimateByWeight(p.Weight, i.InvoiceCustomer.Postcode, p.ParcelNumber); }
private void ResetForm() { lastInvoice = null; // Force a re-read from the DB currentInvoice = new Invoice(); temp_parcel_num = ""; temp_parcel_num_page = "1"; hide_estimate(); hide_suggestion(); //hide_receiptient(); UpdateForm(); txtBox_input_invoiceNo.Text = ""; txtBox_input_invoiceNo.ReadOnly = false; txtBox_input_weight.Text = ""; txtBox_input_weight.ReadOnly = false; txtBox_input_parcelnum.Text = "1"; txtBox_input_parcelnum.ReadOnly = false; txtBox_input_L.ReadOnly = false; txtBox_input_L.Text = ""; txtBox_input_W.ReadOnly = false; txtBox_input_W.Text = ""; txtBox_input_H.ReadOnly = false; txtBox_input_H.Text = ""; txtBox_input_valid.Text = ""; txtBox_suggestion_carrier.Text = ""; btn_input_calculate.Show(); txtBox_input_invoiceNo.SelectAll(); txtBox_input_invoiceNo.Focus(); printHunterExpressLabelToolStripMenuItem.Enabled = false; }
public static int SaveInvoiceParcelReturnParcelID(Invoice invoice, Parcel parcel) { return Actions.SaveInvoiceParcelReturnParcelID(invoice, parcel); }
public void TestCalculateDimensionWeightForToll() { Invoice invoice = new Invoice(); }