Esempio n. 1
0
        private static List <MarketingCenterBL> BuildFromTable(DataTable dtTable)
        {
            List <MarketingCenterBL> list = new List <MarketingCenterBL>();

            if (dtTable != null)
            {
                foreach (DataRow dr in dtTable.Rows)
                {
                    MarketingCenterBL thisMember = new MarketingCenterBL(dr);
                    list.Add(thisMember);
                }
            }
            return(list);
        }
Esempio n. 2
0
        public int CompareTo(MarketingCenterBL au2, String comparisonType)
        {
            String baseComparisonType = comparisonType;
            Int32  compareResult      = 0;
            Int32  descFlag           = 1; //-1 for descending, + 1 for ascending, multiply by compare result

            if (comparisonType.Contains("DESC"))
            {
                descFlag = -1;
                string[] compArr = comparisonType.Split(new Char[] { ' ' });
                if (compArr.Length > 0)
                {
                    baseComparisonType = compArr[0];
                }
            }

            switch (comparisonType)
            {
            case "PhoneASC":
                descFlag = 1;
                if (null != phone && null != au2.phone)
                {
                    compareResult = phone.CompareTo(au2.phone);
                }
                break;

            case "PhoneDESC":
                descFlag = -1;
                if (null != phone && null != au2.phone)
                {
                    compareResult = phone.CompareTo(au2.phone);
                }
                break;

            case "DateASC":
                descFlag = 1;
                if (null != updatedEntryTime && null != au2.updatedEntryTime)
                {
                    compareResult = updatedEntryTime.Value.CompareTo(au2.updatedEntryTime.Value);
                }
                break;

            case "DateDESC":
                descFlag = -1;
                if (null != updatedEntryTime && null != au2.updatedEntryTime)
                {
                    compareResult = updatedEntryTime.Value.CompareTo(au2.updatedEntryTime.Value);
                }
                break;

            case "TimeASC":
                descFlag = 1;
                if (null != updatedEntryTime && null != au2.updatedEntryTime)
                {
                    compareResult = updatedEntryTime.Value.ToShortTimeString().CompareTo(au2.updatedEntryTime.Value.ToShortTimeString());
                }
                break;

            case "TimeDESC":
                descFlag = -1;
                if (null != updatedEntryTime && null != au2.updatedEntryTime)
                {
                    compareResult = updatedEntryTime.Value.ToShortTimeString().CompareTo(au2.updatedEntryTime.Value.ToShortTimeString());
                }
                break;

            case "NameASC":
                descFlag = 1;
                if (null != userName && null != au2.userName)
                {
                    compareResult = userName.CompareTo(au2.userName);
                }
                break;

            case "NameDESC":
                descFlag = -1;
                if (null != userName && null != au2.userName)
                {
                    compareResult = userName.CompareTo(au2.userName);
                }
                break;

            case "ZipASC":
                descFlag = 1;
                if (null != zip && null != au2.zip)
                {
                    compareResult = zip.CompareTo(au2.zip);
                }
                break;

            case "ZipDESC":
                descFlag = -1;
                if (null != zip && null != au2.zip)
                {
                    compareResult = zip.CompareTo(au2.zip);
                }
                break;

            case "EmailASC":
                descFlag = 1;
                if (null != email && null != au2.email)
                {
                    compareResult = email.CompareTo(au2.email);
                }
                break;

            case "EmailDESC":
                descFlag = -1;
                if (null != email && null != au2.email)
                {
                    compareResult = email.CompareTo(au2.email);
                }
                break;

            case "DeliveryDateASC":
                descFlag = 1;
                if (DeliveryDate != null && au2.DeliveryDate != null)
                {
                    compareResult = DeliveryDate.Value.CompareTo(au2.DeliveryDate.Value);
                }
                else if (DeliveryDate.HasValue && !au2.DeliveryDate.HasValue)
                {
                    compareResult = -1;
                }
                break;

            case "DeliveryDateDESC":
                descFlag = -1;
                if (DeliveryDate.HasValue && au2.DeliveryDate.HasValue)
                {
                    compareResult = DeliveryDate.Value.CompareTo(au2.DeliveryDate.Value);
                }
                else if (DeliveryDate.HasValue && !au2.DeliveryDate.HasValue)
                {
                    compareResult = 1;
                }
                break;

            case "VehicleInfoASC":
                descFlag = 1;
                String vehicleInfo  = (year != null ? year : String.Empty) + "," + (make != null ? make : String.Empty) + "," + (model != null ? model : String.Empty);
                String vehicleInfo2 = (au2.year != null ? au2.year : String.Empty) + "," + (au2.make != null ? au2.make : String.Empty) + "," + (au2.model != null ? au2.model : String.Empty);
                if (!String.IsNullOrEmpty(vehicleInfo) && !String.IsNullOrEmpty(vehicleInfo2))
                {
                    compareResult = vehicleInfo.CompareTo(vehicleInfo2);
                }
                break;

            case "VehicleInfoDESC":
                descFlag = -1;
                String _vehicleInfo  = (year != null ? year : String.Empty) + "," + (make != null ? make : String.Empty) + "," + (model != null ? model : String.Empty);
                String _vehicleInfo2 = (au2.year != null ? au2.year : String.Empty) + "," + (au2.make != null ? au2.make : String.Empty) + "," + (au2.model != null ? au2.model : String.Empty);
                if (!String.IsNullOrEmpty(_vehicleInfo) && !String.IsNullOrEmpty(_vehicleInfo2))
                {
                    compareResult = _vehicleInfo.CompareTo(_vehicleInfo2);
                }
                break;

            default:
                descFlag = 1;
                if (null != userName && null != au2.userName)
                {
                    compareResult = userName.CompareTo(au2.userName);
                }
                break;
            }
            return(compareResult * descFlag); //desc flag of -1 returns negative result for descending sort
        }