예제 #1
0
        private void ClearInputData()
        {
            foreach (Control x in this.Controls)
            {
                if (x is TextBox)
                {
                    ((TextBox)x).Text = String.Empty;
                }
            }

            foreach (Control x in groupBox1.Controls)
            {
                if (x is TextBox)
                {
                    ((TextBox)x).Text = String.Empty;
                }
            }
            listView1.Items.Clear();
            TotalParcels = 0;
            txtOrderNumber.Focus();
            OrderObject = null;
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtOrderNumber.Text.Trim().Length != 13)
                {
                    MessageBox.Show("Please enter a valid Order Number!", "Order Details Collector", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    ClearInputData();
                    return;
                }
                if (txtOrderNumber.Text.Trim() != string.Empty)
                {
                    SqlConnection sqlCon = new SqlConnection();
                    sqlCon.ConnectionString =
                        "Data Source=greenmagic_data.fnf.co.za;" +
                        "Initial Catalog=LogisticsSuite;" +
                        "User id=svc_fnfhqsv036;" +
                        "Password=fnf.001$;";
                    sqlCon.Open();
                    string result = string.Empty;
                    using (SqlCommand command = new SqlCommand())
                    {
                        command.Connection  = sqlCon;
                        command.CommandType = CommandType.Text;
                        command.CommandText = "select inbound_json from dbo.INBOUND_WAYBILL_DATA where inbound_waybillno = " + "'" + txtOrderNumber.Text.Trim() + "'";

                        SqlDataReader dr = command.ExecuteReader();
                        while (dr.Read())
                        {
                            result = dr["inbound_json"].ToString();
                        }
                    }
                    if (result == "")
                    {
                        MessageBox.Show("This order has not been processed yet!", "Order Details Collector", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        ClearInputData();
                        return;
                    }
                    else
                    {
                        DialogResult r1 = MessageBox.Show("Are you sure you would like reprint this waybill?", "Order Details Collector", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                        if (r1 == DialogResult.Yes)
                        {
                            WaybillObject reprint = JsonConvert.DeserializeObject <WaybillObject>(result);
                            PrintFNFLabel(reprint, LablePrinter);
                            ClearInputData();
                        }
                        else
                        {
                            MessageBox.Show("Waybill will not be printed", "Order Details Collector", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            ClearInputData();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Order Number Must Be Supllied!", "Order Details Collector", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception e2)
            {
                MessageBox.Show(e2.ToString());
            }
        }
예제 #3
0
        private void GetOrderDetails(string mv_OrderNumber)
        {
            try
            {
                if (OrderObject != null)
                {
                    OrderObject = null;
                }
                string check             = mv_OrderNumber.Substring(0, 3).ToUpper();
                string mv_OrderNumberVEA = mv_OrderNumber.Remove(0, 3);

                if (check == "VEA")
                {
                    HttpClient clientVEA = new HttpClient();
                    clientVEA.BaseAddress = new Uri(string.Format("https://everythinghair.co.za"));
                    clientVEA.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "71kwwfg1sqpul8gouikh13vv30ttn740");
                    clientVEA.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    HttpRequestMessage  requestVEA  = new HttpRequestMessage(HttpMethod.Get, string.Format("/rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=increment_id&searchCriteria[filter_groups][0][filters][0][value]=" + mv_OrderNumberVEA));
                    HttpResponseMessage responseVEA = clientVEA.SendAsync(requestVEA).Result;
                    if (responseVEA.ReasonPhrase == System.Net.HttpStatusCode.OK.ToString())
                    {
                        string jsonVEA = responseVEA.Content.ReadAsStringAsync().Result;
                        VeaudryWaybillDetails OrderObjectVEA = JsonConvert.DeserializeObject <VeaudryWaybillDetails>(jsonVEA);

                        //WaybillObject OrderObject = new WaybillObject();
                        ConsigneeAdress nca = new ConsigneeAdress();
                        WaybillObject   nwo = new WaybillObject();
                        SenderAdress    nsa = new SenderAdress();
                        Reference       nro = new Reference();
                        Contact         nco = new Contact();
                        try
                        {
                            txtConsignee.Text = string.Concat(OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.firstname).Trim().ToUpper() + " " + string.Concat(OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.lastname).Trim().ToUpper();

                            try
                            {
                                nca.StreetName  = string.Concat(OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.street[0]).Trim().ToUpper() + " " + string.Concat(OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.company).Trim().ToUpper();
                                txtAddress.Text = string.Concat(OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.street[0]).Trim().ToUpper() + " " + string.Concat(OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.company).Trim().ToUpper();
                            }
                            catch
                            {
                                nca.StreetName  = OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.street[0].Trim().ToUpper();
                                txtAddress.Text = OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.street[0].Trim().ToUpper();
                            }

                            try
                            {
                                txtSuburb.Text = OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.street[1].Trim().ToUpper();
                                nca.Suburb     = OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.street[1].Trim().ToUpper();
                            }
                            catch
                            {
                                txtSuburb.Text = OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.city.Trim().ToUpper();;
                                nca.Suburb     = OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.city.Trim().ToUpper();;
                            }

                            txtTown.Text     = OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.city.Trim().ToUpper();
                            txtPostCode.Text = OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.postcode.Trim().ToUpper();

                            comboBox1.Items.Clear();
                            comboBox1.SelectedItem = null;
                            comboBox1.Text         = "ECO";
                            comboBox1.Items.Add("ONX");
                            comboBox1.Items.Add("ROEX");

                            cmbxBoxSize.Items.Clear();
                            cmbxBoxSize.SelectedItem = null;
                            cmbxBoxSize.Text         = "";
                            cmbxBoxSize.Items.Add("S = 210 x 210 x 70");
                            cmbxBoxSize.Items.Add("M = 290 x 210 x 70");
                            cmbxBoxSize.Items.Add("L = 440 x 150 x 150");

                            nwo.WaybillNo   = CheckInvalidCharacters(string.Concat(mv_OrderNumber.ToString().Trim().ToUpper()));
                            nwo.Account     = "VEA001";
                            nwo.Service     = comboBox1.Text;
                            nwo.WaybillType = 2;
                            nwo.Department  = "";
                            nwo.Insurance   = 0.0;
                            nwo.Transporter = "FNF";

                            nsa.Consignor  = "THE GANTRY";
                            nsa.StreetNo   = "";
                            nsa.StreetName = "CNR WITKOPPEN AND THE STRAIGHT AVE";
                            nsa.Complex    = "";
                            nsa.UnitNo     = "";
                            nsa.Suburb     = "FOURWAYS";
                            nsa.Town       = "JOHANNESBURG";
                            nsa.PostCode   = "2062";
                            nsa.StoreCode  = "";
                            nsa.Latitude   = "0.000000";
                            nsa.Longitude  = "0.000000";
                            nwo.Sender     = nsa;

                            nca.Consignee  = CheckInvalidCharacters(string.Concat(OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.firstname).Trim().ToUpper() + " " + string.Concat(OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.lastname).Trim().ToUpper());
                            nca.StreetNo   = "";
                            nca.StreetName = CheckInvalidCharacters(string.Concat(OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.street[0]).Trim().ToUpper() + " " + string.Concat(OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.company).Trim().ToUpper());
                            nca.Complex    = "";
                            nca.UnitNo     = "";
                            nca.Town       = CheckInvalidCharacters(OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.city.Trim().ToUpper());
                            nca.PostCode   = CheckInvalidCharacters(OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.postcode.Trim().ToUpper());
                            nca.StoreCode  = "";
                            nca.Latitude   = "0.000000";
                            nca.Longitude  = "0.000000";
                            nwo.Consignee  = nca;

                            List <Reference> nrl = new List <Reference>();
                            nro.ReferenceNo   = CheckInvalidCharacters(mv_OrderNumber);
                            nro.ReferenceType = "CUSTOMER WAYBILL NO";
                            nro.Pages         = 0;
                            nro.Document      = "";
                            nrl.Add(nro);
                            nwo.References = nrl;

                            List <Contact> ncl = new List <Contact>();
                            nco.Firstname  = CheckInvalidCharacters(OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.firstname.Trim().ToUpper());
                            nco.Surname    = CheckInvalidCharacters(OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.lastname.Trim().ToUpper());
                            nco.Telephone  = CheckInvalidCharacters(OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.telephone.Trim().ToUpper());
                            nco.Mobile     = CheckInvalidCharacters(OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.telephone.Trim().ToUpper());
                            nco.Mail       = CheckInvalidCharacters(OrderObjectVEA.items[0].extension_attributes.shipping_assignments[0].shipping.address.email.Trim().ToUpper());
                            nco.NationalID = "";
                            ncl.Add(nco);
                            nwo.Contacts = ncl;

                            OrderObject = nwo;

                            string asdf = OrderObject.ToString();
                        }
                        catch (Exception getex)
                        {
                            MessageBox.Show("There was an issue collecting data for your requested Order Number", "Order Details Collector", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            ClearInputData();
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("There was an issue collecting data for your requested Order Number", "Order Details Collector", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        ClearInputData();
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("Incorrect prefix used!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an issue collecting data for your requested Order Number", "Order Details Collector", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                ClearInputData();
                return;
            }
        }
예제 #4
0
        public void PrintFNFLabel(WaybillObject mv_InboundWaybill, string mv_PrinterName)
        {
            List <string> PrintStrings = new List <string>();

            int TotalParcels = Convert.ToInt32(mv_InboundWaybill.Packets);

            for (int i = 0; i < TotalParcels; i++)
            {
                PrintStrings.Add("CT~~CD,~CC^~CT~");
                PrintStrings.Add("^XA~TA000~JSN^LT0^MNW^MTD^PON^PMN^LH0,0^JMA^PR4,4~SD15^JUS^LRN^CI0^XZ");
                PrintStrings.Add("^XA");
                PrintStrings.Add("^MMT");
                PrintStrings.Add("^PW730");
                PrintStrings.Add("^LL0790");
                PrintStrings.Add("^LS0");

                string VolumiseParcel = "VI";
                PrintStrings.Add(string.Format(@"^LRY
                                                 ^FO88,48^GB49,35,25^FS
                                                 ^FO90,50^CFD,36,18 ^FR^FD{0}^FS", VolumiseParcel));

                string CompanyName = "FAST + FURIOUS";
                PrintStrings.Add(string.Format("^FO225,50 ^CFD,36,18 ^FR^FD{0}^FS", CompanyName));

                string DateScanned = string.Concat("DATE PRINTED : ", DateTime.Now.ToString("yyy-MM-dd"));
                PrintStrings.Add(string.Format("^FO225,100 ^CFD,22,12 ^FD{0}^FS", DateScanned));

                string DeliverTo = "DELIVER TO : ";
                PrintStrings.Add(string.Format("^FO80,140 ^CFD,30,12 ^FD{0}^FS", DeliverTo));

                string Consignee = mv_InboundWaybill.Consignee.Consignee.Trim();
                PrintStrings.Add(string.Format("^FO240,140 ^CFD,30,12 ^FD{0}^FS", Consignee));

                string Address = string.Concat(mv_InboundWaybill.Consignee.Complex.Trim(), ' ', mv_InboundWaybill.Consignee.UnitNo.Trim(), ' ', mv_InboundWaybill.Consignee.StreetNo.Trim(), ' ', mv_InboundWaybill.Consignee.StreetName.Trim());
                PrintStrings.Add(string.Format("^FO80,180 ^CFD,30,12 ^FD{0}^FS", Address.Trim()));

                string Suburb = mv_InboundWaybill.Consignee.Suburb.Trim();
                PrintStrings.Add(string.Format("^FO80,220 ^CFD,30,12 ^FD{0}^FS", Suburb));

                string Town = mv_InboundWaybill.Consignee.Town.Trim();
                PrintStrings.Add(string.Format("^FO80,260 ^CFD,30,12 ^FD{0}^FS", Town));

                string PostCode = mv_InboundWaybill.Consignee.PostCode.Trim();
                PrintStrings.Add(string.Format("^FO80,300 ^CFD,30,12 ^FD{0}^FS", PostCode));

                string Reference;
                try
                {
                    Reference = string.Concat("REF : ", mv_InboundWaybill.References.ElementAt(0).ReferenceNo.ToString().Trim());
                }
                catch (Exception)
                {
                    Reference = string.Concat("REF : ", "");
                }
                PrintStrings.Add(string.Format("^FO400,260 ^CFD,30,12 ^FD{0}^FS", Reference));

                string Service = string.Concat("SRV TYPE : ", mv_InboundWaybill.Service);
                PrintStrings.Add(string.Format(@"^LRY
                                             ^FO78,338^GB180,35,25^FS
                                             ^FO80,340^FR^CFD,30,12^FD{0}^FS", Service));

                string Route = string.Concat("ROUTE : ", "UNDEFINED");
                PrintStrings.Add(string.Format(@"^LRY
                                             ^FO398,298 ^GB225,35,25^FS
                                             ^FO400,300 ^CFD,30,12 ^FD{0}^FS", Route));

                string Hub = string.Empty;
                if (string.IsNullOrEmpty(""))
                {
                    Hub = string.Concat("DEST HUB : ", "JHB");
                }
                else
                {
                    Hub = string.Concat("DEST HUB : ", "");
                }

                PrintStrings.Add(string.Format(@"^LRY
                                             ^FO398,338 ^GB190,35,25^FS
                                             ^FO400,340 ^CFD,30,12 ^FD{0}^FS", Hub));

                string WaybillNo = mv_InboundWaybill.WaybillNo.Trim();
                PrintStrings.Add(string.Format("^FO80,380 ^CFD,30,12 ^FD{0}^FS", WaybillNo));

                string Mobile;
                try
                {
                    Mobile = string.Concat("PHONE : ", mv_InboundWaybill.Contacts.ElementAt(0).Mobile.Trim());
                }
                catch (Exception)
                {
                    Mobile = string.Concat("PHONE : ", "");
                }
                PrintStrings.Add(string.Format("^FO400,380 ^CFD,30,12 ^FD{0}^FS", Mobile));

                string Pieces = string.Format("PIECES {0} OF {1}", i + 1, TotalParcels);
                PrintStrings.Add(string.Format("^FO80,420 ^CFD,30,12 ^FD{0}^FS", Pieces));

                string Weight = string.Concat("PARCEL WEIGHT : ", Convert.ToDouble(mv_InboundWaybill.Parcels.ElementAt(i).Weight));
                PrintStrings.Add(string.Format("^FO400,420 ^CFD,30,12 ^FD{0}^FS", Weight));

                string Barcode = mv_InboundWaybill.Parcels.ElementAt(i).Barcode.Trim();
                PrintStrings.Add(string.Format("^FO120,460 ^BY2^BCN,100,Y,N,N^FD{0}^FS", Barcode));
                //^ FO100,100 ^BY3^BCN,100,Y,N,N^FD{0}^FS
                PrintStrings.Add("^XZ");

                int    mv_PrintByteLength = 0;
                IntPtr PrintBytes         = ConvertPrintStringstoByetArra(PrintStrings, ref mv_PrintByteLength);
                RawPrinterHelper.RawPrinterHelper.SendBytesToPrinter(mv_PrinterName, PrintBytes, mv_PrintByteLength);
                PrintStrings.Clear();
            }
        }