예제 #1
0
        /// <summary>
        /// Carga informacion a la mascarilla por Location
        /// </summary>
        private Boolean ExistAndLoadLocationInformation()
        {
            string send     = "*PDK";
            string res      = string.Empty;
            string location = string.Empty;

            using (CommandsAPI objCommand = new CommandsAPI())
            {
                res = objCommand.SendReceive(send);
            }
            if (res.Trim() != "‡NO PSGR DATA‡")
            {
                location = res.Substring(18, 6);
            }
            WsMyCTS wsServ = new WsMyCTS();

            MyCTS.Services.ValidateDKsAndCreditCards.Cat1stStarInfoByLocation star1InfoByLocation = null;

            try
            {
                star1InfoByLocation = wsServ.GetProfileInfo(location);
            }
            catch { }

            if (star1InfoByLocation != null)
            {
                if (!string.IsNullOrEmpty(star1InfoByLocation.CustomerName))
                {
                    string customer = star1InfoByLocation.CustomerName.ToString();
                    customer             = customer.Replace("(", "");
                    customer             = customer.Replace(")", "");
                    txtSocialReason.Text = customer.Replace(',', ' ');
                }

                if (!string.IsNullOrEmpty(star1InfoByLocation.Address1))
                {
                    txtStreet.Text = star1InfoByLocation.Address1.Replace(',', ' ');
                }
                ;

                if (!string.IsNullOrEmpty(star1InfoByLocation.Address2))
                {
                    star1InfoByLocation.Address2 = star1InfoByLocation.Address2.Replace("#", "");
                    star1InfoByLocation.Address2 = star1InfoByLocation.Address2.TrimStart().Replace(',', ' ');;

                    txtNumberExt.Text = star1InfoByLocation.Address2;
                }
                if (!string.IsNullOrEmpty(star1InfoByLocation.Address3))
                {
                    star1InfoByLocation.Address3 = star1InfoByLocation.Address3.Replace("#", "");
                    star1InfoByLocation.Address3 = star1InfoByLocation.Address3.TrimStart().Replace(',', ' ');
                    txtNumberInt.Text            = star1InfoByLocation.Address3;
                }
                if (!string.IsNullOrEmpty(star1InfoByLocation.Address4))
                {
                    txtColony.Text = star1InfoByLocation.Address4;
                }

                if (star1InfoByLocation.Address4 == "")
                {
                    txtColony.Enabled = true;
                }


                if (!string.IsNullOrEmpty(star1InfoByLocation.Municipality))
                {
                    txtDelegation.Text = star1InfoByLocation.Municipality.Replace(',', ' ');
                }


                if (!string.IsNullOrEmpty(star1InfoByLocation.PostalCode))
                {
                    txtCP.Text = star1InfoByLocation.PostalCode;
                }

                if (!string.IsNullOrEmpty(star1InfoByLocation.City))
                {
                    txtCity.Text = star1InfoByLocation.City.Replace(',', ' ');
                }


                if (!string.IsNullOrEmpty(star1InfoByLocation.State))
                {
                    txtState.Text = star1InfoByLocation.State.Replace(',', ' ');
                }


                if (!string.IsNullOrEmpty(star1InfoByLocation.RFC))
                {
                    bool IsRFC = ValidateRegularExpression.ValidateRFCFormat(star1InfoByLocation.RFC);
                    if (IsRFC)
                    {
                        if (star1InfoByLocation.RFC.Length.Equals(13))
                        {
                            txtRFC1.Text = star1InfoByLocation.RFC.Substring(0, 4);
                            txtRFC2.Text = star1InfoByLocation.RFC.Substring(4, 6);
                            txtRFC3.Text = star1InfoByLocation.RFC.Substring(10, 3);
                        }


                        else if (star1InfoByLocation.RFC.Length.Equals(12))
                        {
                            txtRFC1.Text = star1InfoByLocation.RFC.Substring(0, 3);
                            txtRFC2.Text = star1InfoByLocation.RFC.Substring(3, 6);
                            txtRFC3.Text = star1InfoByLocation.RFC.Substring(9, 3);
                        }
                    }
                }
                return(true);
            }

            return(true);
        }