private void button4_Click(object sender, EventArgs e) { Form prompt = new Form(); prompt.Width = 500; prompt.Height = 150; prompt.FormBorderStyle = FormBorderStyle.FixedDialog; prompt.Text = "Cancel an order"; prompt.StartPosition = FormStartPosition.CenterScreen; Label textLabel = new Label() { Left = 50, Top = 20, Width = 400, Text = "Enter tracking number to cancel:" }; TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 }; Button confirmation = new Button() { Text = "Ok", Left = 350, Width = 100, Top = 70 }; Button cancel = new Button() { Text = "Cancel", Left = 250, Width = 100, Top = 70 }; confirmation.DialogResult = DialogResult.OK; confirmation.Click += (sndr, evnt) => { prompt.Close(); }; cancel.Click += (sndr, evnt) => { prompt.Close(); }; prompt.Controls.Add(textBox); prompt.Controls.Add(confirmation); prompt.Controls.Add(cancel); prompt.Controls.Add(textLabel); prompt.CancelButton = cancel; prompt.AcceptButton = confirmation; DialogResult result = prompt.ShowDialog(); if (result != System.Windows.Forms.DialogResult.OK || textBox.Text.Length == 0) return; DeleteShipmentRequest req = new DeleteShipmentRequest(); req.WebAuthenticationDetail = plugin.auth; req.ClientDetail = plugin.clientDetail; req.Version = new VersionId(); req.TransactionDetail = new TransactionDetail(); req.TransactionDetail.CustomerTransactionId = textBox.Text; req.TrackingId = new TrackingId(); req.TrackingId.TrackingNumber = textBox.Text; req.TrackingId.TrackingIdType = TrackingIdType.EXPRESS; req.TrackingId.TrackingIdTypeSpecified = true; req.DeletionControl = DeletionControlType.DELETE_ALL_PACKAGES; var reply = plugin.svc.deleteShipment(req); if (reply.HighestSeverity == NotificationSeverityType.SUCCESS) { MessageBox.Show("Success"); } else { var output = ""; for (int i = 0; i < reply.Notifications.Length; i++) { Notification notification = reply.Notifications[i]; output += string.Format("Notification no. {0}\n", i); output += string.Format(" Severity: {0}\n", notification.Severity); output += string.Format(" Code: {0}\n", notification.Code); output += string.Format(" Message: {0}\n", notification.Message); output += string.Format(" Source: {0}\n", notification.Source); } MessageBox.Show("Failed!\n\n" + output); } }
/// <remarks/> public void deleteShipmentAsync(DeleteShipmentRequest DeleteShipmentRequest, object userState) { if ((this.deleteShipmentOperationCompleted == null)) { this.deleteShipmentOperationCompleted = new System.Threading.SendOrPostCallback(this.OndeleteShipmentOperationCompleted); } this.InvokeAsync("deleteShipment", new object[] { DeleteShipmentRequest}, this.deleteShipmentOperationCompleted, userState); }
/// <remarks/> public void deleteShipmentAsync(DeleteShipmentRequest DeleteShipmentRequest) { this.deleteShipmentAsync(DeleteShipmentRequest, null); }
/// <remarks/> public System.IAsyncResult BegindeleteShipment(DeleteShipmentRequest DeleteShipmentRequest, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("deleteShipment", new object[] { DeleteShipmentRequest}, callback, asyncState); }