private void button1_Click(object sender, EventArgs e)
        {
            limpiar();

            TransDepotProxy proxy = new TransDepotProxy();

            try
            {
                var response = proxy.ConsultarRuc(txtRuc.Text);
                lblRuc.Text      = response.ruc;
                txtRazonSoc.Text = response.razon_social;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "Mensaje");
            }
        }
        bool EnviarPreAdvice()
        {
            TransDepotProxy  proxy   = new TransDepotProxy();
            RequestPreAdvice request = new RequestPreAdvice();

            request.YardCode   = ConfigurationManager.AppSettings["DepSanAgustin"].ToString();
            request.ActionType = "P";
            request.OperationTypeMovementCode = "";
            request.VoyageStopExternalCode    = txtOrdenServicio.Text.Trim();
            request.VesselIMO    = "";
            request.VoyageNumber = "";
            request.OceanCarrier = OceanCarrier;

            if (OperationType != null)
            {
                if (OperationType.Equals("E"))
                {
                    request.ReferenceType = ConfigurationManager.AppSettings["ReferenceTypeBK"].ToString();
                }
                else
                {
                    request.ReferenceType = ConfigurationManager.AppSettings["ReferenceTypeBL"].ToString();
                }
            }

            request.OperationType   = OperationType;
            request.ReferenceNumber = ReferenceNumber;
            request.PlaceOfReceipt  = PlaceOfReceipt;
            request.PortOfLoading   = PortOfLoading;
            request.PortOfDischarge = PortOfDischarge;
            request.PlaceOfDelivery = PlaceOfDelivery;
            request.CustomerERPCode = CustomerERPCode;
            request.ShipmentType    = "";

            request.Equipments.Add(new PreAdviceEquipment()
            {
                EquipmentNumber          = EquipmentNumber,
                EquipmentTypeSizeISOCode = EquipmentTypeSizeISOCode,
                IsEmpty               = (IsEmpty.Equals("S")) ? true : false,
                IsHazardous           = (IsHazardous.Equals("S")) ? true : false,
                RequiresReview        = false,
                SetPoint              = (SetPoint.Trim() != "") ? Convert.ToDouble(SetPoint) : 0.0,
                SetPointUnitOfMeasure = SetPointUnitOfMeasure,
                Ventilation           = 0.0,
                RelativeHumidityLevel = 0.0,
                O2Level               = 0.0,
                CO2Level              = 0.0,
                RequiresPlug          = (RequiresPlug.Equals("S")) ? true : false,
                Technology            = ""
            });

            ResponsePreAdvice resp = new ResponsePreAdvice();

            resp = proxy.PreAdvice(request);

            if (!resp.isValid)
            {
                List <string> listaDestinatarios = new List <string>();
                List <string> listaCopia         = new List <string>();
                List <string> listaCopiaOculta   = new List <string>();

                string destinatarios = ConfigurationManager.AppSettings["Destinatarios"].ToString();
                if (destinatarios != "" && destinatarios.Contains(";"))
                {
                    var correosDestino = destinatarios.Split(';');
                    foreach (string item in correosDestino)
                    {
                        listaDestinatarios.Add(item);
                    }
                }
                else
                {
                    listaDestinatarios.Add(destinatarios);
                }

                string copia = ConfigurationManager.AppSettings["ConCopia"].ToString();
                if (copia != "" && copia.Contains(";"))
                {
                    var correosCopia = copia.Split(';');
                    foreach (string item in correosCopia)
                    {
                        listaCopia.Add(item);
                    }
                }
                else
                {
                    listaCopia.Add(copia);
                }

                string copiaOculta = ConfigurationManager.AppSettings["CopiaOculta"].ToString();
                if (copiaOculta != "" && copiaOculta.Contains(";"))
                {
                    var correosCopiaOculta = copiaOculta.Split(';');
                    foreach (string item in correosCopiaOculta)
                    {
                        listaCopiaOculta.Add(item);
                    }
                }
                else
                {
                    listaCopiaOculta.Add(copiaOculta);
                }

                new ManejadorCorreos().EnviarCorreo(ConfigurationManager.AppSettings["AsuntoCorreoError"].ToString(), resp.messages[0].message, listaDestinatarios, listaCopia, listaCopiaOculta);
            }

            return(true);
        }
        void InvocarServicio()
        {
            TransDepotProxy           proxy   = new TransDepotProxy();
            RequestEquipmentOperation request = new RequestEquipmentOperation();

            request.OceanCarrier = OceanCarrier;

            if (OperationType != null)
            {
                if (OperationType.Equals("E"))
                {
                    request.ReferenceType = ConfigurationManager.AppSettings["ReferenceTypeBK"].ToString();
                }
                else
                {
                    request.ReferenceType = ConfigurationManager.AppSettings["ReferenceTypeBL"].ToString();
                }
            }

            request.ReferenceNumber           = ReferenceNumber;
            request.YardCode                  = ConfigurationManager.AppSettings["DepSanAgustin"].ToString();
            request.ActionType                = ActionType;
            request.ActivityCode              = ActivityCode;
            request.OperationTypeMovementCode = "";
            request.OperationType             = OperationType;
            request.VehiclePlate              = VehiclePlate;
            request.ExecutionDate             = ExecutionDate;
            request.direction                 = Direction;
            request.Status      = Status;
            request.truckerCode = "";
            request.driverCode  = "";

            request.Equipments.Add(new YardOperationEquipment()
            {
                EquipmentNumber          = EquipmentNumber,
                EquipmentTypeSizeISOCode = EquipmentTypeSizeISOCode,
                IsEmpty        = (IsEmpty.Equals("S")) ? true : false,
                IsHazardous    = (IsHazardous.Equals("S")) ? true : false,
                RequiresReview = false
            });

            ResponseEquipmentOperation resp = new ResponseEquipmentOperation();

            try
            {
                resp = proxy.EquipmentOperation(request);
            }catch (Exception ex)
            {
                resp.isValid = false;
                Message msg = new Message();
                msg.message = ex.Message.ToString();
                resp.messages.Add(msg);
                MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }

            if (!resp.isValid)
            {
                List <string> listaDestinatarios = new List <string>();
                List <string> listaCopia         = new List <string>();
                List <string> listaCopiaOculta   = new List <string>();

                string destinatarios = ConfigurationManager.AppSettings["Destinatarios"].ToString();
                if (destinatarios != "" && destinatarios.Contains(";"))
                {
                    var correosDestino = destinatarios.Split(';');
                    foreach (string item in correosDestino)
                    {
                        listaDestinatarios.Add(item);
                    }
                }
                else
                {
                    listaDestinatarios.Add(destinatarios);
                }

                string copia = ConfigurationManager.AppSettings["ConCopia"].ToString();
                if (copia != "" && copia.Contains(";"))
                {
                    var correosCopia = copia.Split(';');
                    foreach (string item in correosCopia)
                    {
                        listaCopia.Add(item);
                    }
                }
                else
                {
                    listaCopia.Add(copia);
                }

                string copiaOculta = ConfigurationManager.AppSettings["CopiaOculta"].ToString();
                if (copiaOculta != "" && copiaOculta.Contains(";"))
                {
                    var correosCopiaOculta = copiaOculta.Split(';');
                    foreach (string item in correosCopiaOculta)
                    {
                        listaCopiaOculta.Add(item);
                    }
                }
                else
                {
                    listaCopiaOculta.Add(copiaOculta);
                }

                new ManejadorCorreos().EnviarCorreo(ConfigurationManager.AppSettings["AsuntoCorreoError"].ToString(), resp.messages[0].message, listaDestinatarios, listaCopia, listaCopiaOculta);
            }
            else
            {
                MessageBox.Show("Se procesó correctamente", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        void invocarServicio()
        {
            TransDepotProxy proxy = new TransDepotProxy();
            RequestBusinessPartnerRegister request = new RequestBusinessPartnerRegister();

            request.OrganizationCode = "TRA";

            if (ParentBusinessPartner != null && ParentBusinessPartner.Trim() != "")
            {
                request.ParentBusinessPartner = ParentBusinessPartner;
            }

            request.ERPCode = ERPCode;
            request.Name    = NameBusinessPartner;

            if (RowStatus != null && RowStatus.Equals("S"))
            {
                request.RowStatus = true;
            }
            else
            {
                request.RowStatus = false;
            }

            if (ShortName != null && ShortName.Trim() != "")
            {
                request.ShortName = ShortName;
            }

            if (EmailAddress != null && EmailAddress.Trim() != "")
            {
                request.EmailAddress = EmailAddress;
            }

            request.IsCustomer = true;
            request.IsVendor   = false;

            if (IsCustomer != null && IsCustomer.Equals("S"))
            {
                request.Roles.Add(new Roles()
                {
                    Code = "CUS", Name = "CLIENTE"
                });
                request.Roles.Add(new Roles()
                {
                    Code = "SHI", Name = "EXPORTADOR"
                });
                request.Roles.Add(new Roles()
                {
                    Code = "CON", Name = "CONSIGNATARIO"
                });
                request.Roles.Add(new Roles()
                {
                    Code = "NOT", Name = "NOTIFICADO"
                });
                request.Roles.Add(new Roles()
                {
                    Code = "3PL", Name = "OPERADOR LOGÍSTICO"
                });
            }

            request.Documents.Add(new Documents()
            {
                DocumentType = DocumentType, DocumentNumber = DocumentNumber
            });

            ResponseBusinessPartnerRegister resp = new ResponseBusinessPartnerRegister();

            resp = proxy.RegistrarCliente(request);

            if (!resp.isValid)
            {
                List <string> listaDestinatarios = new List <string>();
                List <string> listaCopia         = new List <string>();
                List <string> listaCopiaOculta   = new List <string>();

                string destinatarios = ConfigurationManager.AppSettings["Destinatarios"].ToString();
                if (destinatarios != "" && destinatarios.Contains(";"))
                {
                    var correosDestino = destinatarios.Split(';');
                    foreach (string item in correosDestino)
                    {
                        listaDestinatarios.Add(item);
                    }
                }
                else
                {
                    listaDestinatarios.Add(destinatarios);
                }

                string copia = ConfigurationManager.AppSettings["ConCopia"].ToString();
                if (copia != "" && copia.Contains(";"))
                {
                    var correosCopia = copia.Split(';');
                    foreach (string item in correosCopia)
                    {
                        listaCopia.Add(item);
                    }
                }
                else
                {
                    listaCopia.Add(copia);
                }

                string copiaOculta = ConfigurationManager.AppSettings["CopiaOculta"].ToString();
                if (copiaOculta != "" && copiaOculta.Contains(";"))
                {
                    var correosCopiaOculta = copiaOculta.Split(';');
                    foreach (string item in correosCopiaOculta)
                    {
                        listaCopiaOculta.Add(item);
                    }
                }
                else
                {
                    listaCopiaOculta.Add(copiaOculta);
                }

                new ManejadorCorreos().EnviarCorreo(ConfigurationManager.AppSettings["AsuntoCorreoError"].ToString(), resp.messages[0].message, listaDestinatarios, listaCopia, listaCopiaOculta);

                MessageBox.Show("Error al registrar cliente", "Mensaje");
            }
            //else
            //{
            //    MessageBox.Show("Cliente registrado con éxito", "Mensaje");
            //}
        }