Пример #1
0
        /// <summary>
        ///     Allows you to generate an HTML representation of the current Address object.
        /// </summary>
        /// <returns>An HTML representation of the current Address object.</returns>
        public string ToHtmlString()
        {
            var sb = new StringBuilder();

            if (NickName.Trim().Length > 0)
            {
                sb.Append("<em>" + NickName + "</em><br />");
            }
            if (LastName.Length > 0 || FirstName.Length > 0)
            {
                sb.Append(FirstName);
                if (MiddleInitial.Trim().Length > 0)
                {
                    sb.Append(" " + MiddleInitial);
                }
                sb.Append(" " + LastName + "<br />");
                if (Company.Trim().Length > 0)
                {
                    sb.Append(Company + "<br />");
                }
            }

            sb.Append(GetLinesHtml());

            return(sb.ToString());
        }
Пример #2
0
        /// <summary>
        ///     Returns a List-based representation of the address, including all of the common addres properties, as specified in
        ///     the parameters.
        /// </summary>
        /// <param name="appendNameAndCompany">It true, the full name and company name will be included in the list.</param>
        /// <param name="appendPhones">If true, the phone, fax, and website URL will be included in the list.</param>
        /// <returns>List - an array of the address information in the current object.</returns>
        public List <string> GetLines(bool appendNameAndCompany = true, bool appendPhones = true)
        {
            var lines = new List <string>();

            if (appendNameAndCompany)
            {
                lines.Add(
                    LastName +
                    (string.IsNullOrWhiteSpace(MiddleInitial) ? "" : " " + MiddleInitial.Trim()) +
                    (string.IsNullOrWhiteSpace(FirstName) ? "" : " " + FirstName.Trim())
                    );
                lines.Add(Company);
            }

            lines.Add(Line1);
            lines.Add(Line2);
            lines.Add(Line3);

            if (RegionData != null)
            {
                lines.Add(City + ", " + RegionData.Abbreviation + " " + _postalCode);
            }
            else
            {
                lines.Add(City + ", " + _postalCode);
            }

            if (CountryData != null && !string.IsNullOrEmpty(CountryData.DisplayName))
            {
                lines.Add(CountryData.DisplayName);
            }
            if (appendPhones)
            {
                lines.Add(Phone);

                if (!string.IsNullOrWhiteSpace(Fax))
                {
                    lines.Add("Fax: " + Fax);
                }

                lines.Add(WebSiteUrl);
            }

            // Remove emtpy lines
            var i = 0;

            while (i < lines.Count)
            {
                if (string.IsNullOrWhiteSpace(lines[i]))
                {
                    lines.RemoveAt(i);
                }
                else
                {
                    i++;
                }
            }

            return(lines);
        }
Пример #3
0
        public Transaction CreateTransaction(CMSDataContext Db, decimal?amount = null)
        {
            if (!amount.HasValue)
            {
                amount = AmtToPay;
            }

            decimal?amtdue = null;

            if (Amtdue > 0)
            {
                amtdue = Amtdue - (amount ?? 0);
            }

            // var ss = m.ProcessType;

            var ti = new Transaction
            {
                First              = First,
                MiddleInitial      = MiddleInitial.Truncate(1) ?? "",
                Last               = Last,
                Suffix             = Suffix,
                Donate             = Donate,
                Regfees            = AmtToPay,
                Amt                = amount,
                Amtdue             = Math.Max((amtdue ?? 0), 0),
                Emails             = Email,
                Testing            = testing,
                Description        = Description,
                OrgId              = OrgId,
                Url                = URL,
                TransactionGateway = OnlineRegModel.GetTransactionGateway(ProcessType)?.GatewayAccountName,
                Address            = Address.Truncate(50),
                Address2           = Address2.Truncate(50),
                City               = City,
                State              = State,
                Country            = Country,
                Zip                = Zip,
                DatumId            = DatumId,
                Phone              = Phone.Truncate(20),
                OriginalId         = OriginalId,
                Financeonly        = FinanceOnly,
                TransactionDate    = Util.Now,
                PaymentType        = Type,
                LastFourCC         = Type == PaymentType.CreditCard ? CreditCard.Last(4) : null,
                LastFourACH        = Type == PaymentType.Ach ? Account.Last(4) : null
            };

            CurrentDatabase.Transactions.InsertOnSubmit(ti);
            CurrentDatabase.SubmitChanges();
            if (OriginalId == null) // first transaction
            {
                ti.OriginalId = ti.Id;
            }

            return(ti);
        }
Пример #4
0
 public void Authenticate(string Username, string Password)
 {
     try
     {
         this.DE = new DirectoryEntry(null, Username, Password, AuthenticationTypes.Secure);
         var sss = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
         DirectorySearcher deSearch = new DirectorySearcher(DE);
         deSearch.Filter = "(&(objectClass=user)(sAMAccountName=" + Username + "))";
         SearchResult result = deSearch.FindOne();
         if (result != null)
         {
             this.DE           = new DirectoryEntry(result.Path, Username, Password, AuthenticationTypes.Secure);
             IsAuthenticated   = true;
             FirstName         = GetProperty("givenName");
             MiddleInitial     = GetProperty("initials");
             LastName          = GetProperty("sn");
             UserPrincipalName = GetProperty("UserPrincipalName");
             EmployeeID        = int.Parse(GetProperty("employeeID"));
             //PostalAddress = GetProperty("PostalAddress");
             //MailingAddress = GetProperty("StreetAddress");
             //ResidentialAddress = GetProperty("HomePostalAddress");
             Title = GetProperty("Title");
             //HomePhone = GetProperty("HomePhone");
             //OfficePhone = GetProperty("TelephoneNumber");
             //Mobile = GetProperty("Mobile");
             //Fax = GetProperty("FacsimileTelephoneNumber");
             Email             = GetProperty("mail");
             Url               = GetProperty("Url");
             this.Username     = GetProperty("sAMAccountName");
             DistinguishedName = GetProperty("DistinguishedName");
             //Company = GetProperty("Company");
             Department  = GetProperty("Department");
             DisplayName = FirstName + ((MiddleInitial.Trim() != string.Empty) ? " " + MiddleInitial.Trim() + "." : string.Empty) + " " + LastName;
             Groups.Clear();
             for (int i = 0; i <= DE.Properties["memberOf"].Count - 1; i++)
             {
                 string s = GetProperty("memberOf", i);
                 if (s.IndexOf("OU=CPL Systems") != 0)
                 {
                     string[] x = s.Split(',')[0].Split('=');
                     Groups.Add(x[1]);
                 }
             }
             OU = DistinguishedName.Split(',')[1].Replace("OU=", "");
         }
     }
     catch
     {
         //Exception = ex;
         Clear();
     }
 }
Пример #5
0
        public string FullName()
        {
            string n;

            n = MiddleInitial.HasValue()
                ? $"{First} {MiddleInitial} {Last}"
                : $"{First} {Last}";
            if (Suffix.HasValue())
            {
                n = n + " " + Suffix;
            }
            return(n);
        }
Пример #6
0
 /// <summary>
 ///    Serves as a hash function for a particular type.
 /// </summary>
 /// <returns>
 ///    A hash code for the current <see cref="T:System.Object" />.
 /// </returns>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (FirstName != null ? FirstName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (MiddleInitial != null ? MiddleInitial.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (LastName != null ? LastName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ BirthDate.GetHashCode();
         hashCode = (hashCode * 397) ^ (Father != null ? Father.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Mother != null ? Mother.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Children != null ? Children.GetHashCode() : 0);
         return(hashCode);
     }
 }
Пример #7
0
        public Transaction CreateTransaction(CMSDataContext Db, decimal?amount = null)
        {
            if (!amount.HasValue)
            {
                amount = AmtToPay;
            }
            decimal?amtdue = null;

            if (Amtdue > 0)
            {
                amtdue = Amtdue - (amount ?? 0);
            }
            var ti = new Transaction
            {
                First              = First,
                MiddleInitial      = MiddleInitial.Truncate(1) ?? "",
                Last               = Last,
                Suffix             = Suffix,
                Donate             = Donate,
                Regfees            = AmtToPay,
                Amt                = amount,
                Amtdue             = amtdue,
                Emails             = Email,
                Testing            = testing,
                Description        = Description,
                OrgId              = OrgId,
                Url                = Url,
                TransactionGateway = OnlineRegModel.GetTransactionGateway(),
                Address            = Address.Truncate(50),
                City               = City,
                State              = State,
                Zip                = Zip,
                DatumId            = DatumId,
                Phone              = Phone.Truncate(20),
                OriginalId         = OriginalId,
                Financeonly        = FinanceOnly,
                TransactionDate    = DateTime.Now
            };

            Db.Transactions.InsertOnSubmit(ti);
            Db.SubmitChanges();
            if (OriginalId == null) // first transaction
            {
                ti.OriginalId = ti.Id;
            }
            return(ti);
        }
Пример #8
0
        //public string Name { get; set; }
        public string FullName()
        {
            string n;

            if (MiddleInitial.HasValue())
            {
                n = "{0} {1} {2}".Fmt(First, MiddleInitial, Last);
            }
            else
            {
                n = "{0} {1}".Fmt(First, Last);
            }
            if (Suffix.HasValue())
            {
                n = n + " " + Suffix;
            }
            return(n);
        }
Пример #9
0
        /// <summary>
        /// Provide validation for the segment by overriding this method.
        /// </summary>
        protected override void ValidationMethod(object sender, EventArgs e)
        {
            Trace.WriteLine("ValidationMethod entered.", Name);

            if (FirstName.Length > 40)
            {
                FirstName = FirstName.Substring(0, 40);
            }

            if (LastName.Length > 80)
            {
                LastName = LastName.Substring(0, 80);
            }

            if (MiddleInitial.Length > 1)
            {
                MiddleInitial = MiddleInitial.Substring(0, 1);
            }
        }
Пример #10
0
        /// <summary>
        ///     Allows you to compare another address object to determine if the two addresses are the same.
        /// </summary>
        /// <param name="a2">Another address object.</param>
        /// <returns>If true, the current address matches the address in the parameter.</returns>
        public bool IsEqualTo(Address a2)
        {
            if (a2 == null)
            {
                return(false);
            }

            var result = true;

            if (string.Compare(NickName.Trim(), a2.NickName.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(FirstName.Trim(), a2.FirstName.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(MiddleInitial.Trim(), a2.MiddleInitial.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(LastName.Trim(), a2.LastName.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(Company.Trim(), a2.Company.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(Line1.Trim(), a2.Line1.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(Line2.Trim(), a2.Line2.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(Line3.Trim(), a2.Line3.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(RegionBvin.Trim(), a2.RegionBvin.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(City.Trim(), a2.City.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(PostalCode.Trim(), a2.PostalCode.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(CountryBvin.Trim(), a2.CountryBvin.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(Phone.Trim(), a2.Phone.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(Fax.Trim(), a2.Fax.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            if (string.Compare(WebSiteUrl.Trim(), a2.WebSiteUrl.Trim(), true, CultureInfo.InvariantCulture) != 0)
            {
                result = false;
            }
            //if (this.Residential != a2.Residential) {
            //    result = false;
            //}

            return(result);
        }
Пример #11
0
        public string ToHtmlString()
        {
            StringBuilder sb = new StringBuilder();

            if (NickName.Trim().Length > 0)
            {
                sb.Append("<em>" + NickName + "</em><br />");
            }
            if (LastName.Length > 0 || FirstName.Length > 0)
            {
                sb.Append(FirstName);
                if (MiddleInitial.Trim().Length > 0)
                {
                    sb.Append(" " + MiddleInitial);
                }
                sb.Append(" " + LastName + "<br />");
                if (Company.Trim().Length > 0)
                {
                    sb.Append(Company + "<br />");
                }
            }
            if (Line1.Length > 0)
            {
                sb.Append(Line1 + "<br />");
            }
            if (Line2.Trim().Length > 0)
            {
                sb.Append(Line2 + "<br />");
            }
            if (Line3.Trim().Length > 0)
            {
                sb.Append(Line3 + "<br />");
            }

            MerchantTribe.Web.Geography.Country c = MerchantTribe.Web.Geography.Country.FindByBvin(CountryBvin);
            MerchantTribe.Web.Geography.Region  r = c.Regions.Where(y => y.Abbreviation == RegionBvin).FirstOrDefault();

            if (r != null)
            {
                sb.Append(City + ", " + r.Abbreviation + " " + _PostalCode + "<br />");
            }
            else
            {
                if (RegionName.Trim().Length > 0)
                {
                    sb.Append(City + ", " + RegionName + " " + _PostalCode + "<br />");
                }
                else
                {
                    sb.Append(City + ", " + _PostalCode + "<br />");
                }
            }
            if (c != null)
            {
                sb.Append(c.DisplayName + "<br />");
            }

            if (Phone.Trim().Length > 0)
            {
                sb.Append(Phone + "<br />");
            }
            if (Fax.Trim().Length > 0)
            {
                sb.Append("Fax: " + Fax + "<br />");
            }
            if (WebSiteUrl.Trim().Length > 0)
            {
                sb.Append(WebSiteUrl + "<br />");
            }
            return(sb.ToString());
        }