예제 #1
0
        public PriceCalculator(string[] inputData)
        {
            this.pricePerDay      = decimal.Parse(inputData[0]);
            this.numberOfDays     = int.Parse(inputData[1]);
            this.seasonMultiplier = Enum.Parse <SeasonMultiplier>(inputData[2]);

            if (inputData.Length > 3)
            {
                string discountPercentageAsString = inputData[3];
                this.discountPercentage = Enum.Parse <DiscountPercentage>(discountPercentageAsString);
            }
        }
예제 #2
0
        public PriceCalculator(string[] commandArgs)
        {
            pricePerNight      = decimal.Parse(commandArgs[0]);
            nights             = int.Parse(commandArgs[1]);
            seasonMultiplier   = Enum.Parse <SeasonMultiplier>(commandArgs[2]);
            discountPercentage = DiscountPercentage.None;

            if (commandArgs.Length == 4)
            {
                discountPercentage = Enum.Parse <DiscountPercentage>(commandArgs[3]);
            }
        }
예제 #3
0
        /// <summary>
        /// Add an entity.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public DiscountPercentageViewModel Add(DiscountPercentageViewModel model)
        {
            this.ThrowExceptionIfExist(model);

            var entity = model.ToEntity();

            try
            {
                entity.Percentage = int.Parse(model.Name.Replace("%", ""));
            }
            catch
            {
            }
            finally
            {
                entity.Name = null;
            }

            entity = this._DiscountPercentagesRepository.Add(entity);

            var entityAr = new DiscountPercentage
            {
                Name        = model.Name,
                Description = model.DescriptionAr,
                Language    = Framework.Common.Enums.Language.Arabic,
                ParentKeyDiscountPercentage = entity
            };

            entity.ChildTranslatedDiscountPercentages.Add(entityAr);
            this._DiscountPercentagesRepository.Add(entityAr);

            var entityEn = new DiscountPercentage
            {
                Name        = model.Name,
                Description = model.DescriptionEn,
                Language    = Framework.Common.Enums.Language.English,
                ParentKeyDiscountPercentage = entity
            };

            entity.ChildTranslatedDiscountPercentages.Add(entityEn);
            this._DiscountPercentagesRepository.Add(entityEn);


            #region Commit Changes
            this._unitOfWork.Commit();
            #endregion

            model = entity.ToModel();
            return(model);
        }
예제 #4
0
        void ToggleDiscountType()
        {
            BunifuElipse DiscountTypeImgElipse = new BunifuElipse {
                ElipseRadius = 5
            };
            Image ColoredImgCashDiscountType = ImageUtil.ColorImage(imgbtnCashDiscountType.Image, SoftColor);
            Image ColoredImgPtgDiscountType  = ImageUtil.ColorImage(imgbtnPtgDiscountType.Image, SoftColor);
            Image ImgCashDiscountType        = ImageUtil.ColorImage(imgbtnCashDiscountType.Image, Color.White);
            Image ImgPtgDiscountType         = ImageUtil.ColorImage(imgbtnPtgDiscountType.Image, Color.White);

            txtDiscountValue.Text = "";

            if (IsCashDiscount)
            {
                //Cash
                lblDiscountType.Text      = StringAmount;
                txtDiscountValue.HintText = (DiscountAmount == 0) ? "00,00" : DiscountAmount.ToString();
                lblUnit.Text          = Currency;
                txtDiscountValue.Text = DiscountAmount.ToString();

                // Change Both Control Color, Image Oppositely
                imgbtnCashDiscountType.BackColor = SoftColor;
                imgbtnCashDiscountType.Image     = ImgCashDiscountType;

                imgbtnPtgDiscountType.BackColor = Color.White;
                imgbtnPtgDiscountType.Image     = ColoredImgPtgDiscountType;

                DiscountTypeImgElipse.TargetControl = imgbtnCashDiscountType;
            }
            else
            {
                // Percentage
                lblDiscountType.Text      = stringPercentage;
                txtDiscountValue.HintText = DiscountPercentage.ToString();
                txtDiscountValue.Text     = DiscountPercentage.ToString();
                lblUnit.Text = "%";

                //Refresh UI  : Change Both Control Color, Image Oppositely
                imgbtnCashDiscountType.BackColor = Color.White;
                imgbtnCashDiscountType.Image     = ColoredImgCashDiscountType;

                imgbtnPtgDiscountType.BackColor = SoftColor;
                imgbtnPtgDiscountType.Image     = ImgPtgDiscountType;

                DiscountTypeImgElipse.TargetControl = imgbtnPtgDiscountType;
            }
            txtDiscountName.Text = DiscountName;
        }
예제 #5
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Product != null ? Product.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Quantity.GetHashCode();
         hashCode = (hashCode * 397) ^ Rate.GetHashCode();
         hashCode = (hashCode * 397) ^ TaxPercentage.GetHashCode();
         hashCode = (hashCode * 397) ^ DiscountPercentage.GetHashCode();
         hashCode = (hashCode * 397) ^ Total.GetHashCode();
         hashCode = (hashCode * 397) ^ Subtotal.GetHashCode();
         hashCode = (hashCode * 397) ^ Tax.GetHashCode();
         hashCode = (hashCode * 397) ^ LineIdx;
         return(hashCode);
     }
 }
예제 #6
0
 private bool Equals(IInvoiceLineItem other)
 {
     return(Product == other.Product && Description == other.Description && Quantity.Equals(other.Quantity) && Rate.Equals(other.Rate) && TaxPercentage.Equals(other.TaxPercentage) &&
            DiscountPercentage.Equals(other.DiscountPercentage) && Total.Equals(other.Total) && Subtotal.Equals(other.Subtotal) && Tax.Equals(other.Tax) && LineIdx == other.LineIdx);
 }
예제 #7
0
 public void clearNow()
 {
     DiscountPercentage.Clear();
     DiscountTitle.Clear();
     newDiscount();
 }