Ejemplo n.º 1
0
        public PromoCode PromocodeGetObj(string pc_name)
        {
            PromoCode p  = new PromoCode();
            DataTable dt = new DataTable();
            int       r  = new PromoCodes().P...(pc_name, ref dt);

            if (r >= 0 && dt.Rows.Count > 0)
            {
                DataRow row = dt.Rows[0];
                p.Name          = pc_name;
                p.DiscountValue = Utils.Str2Decimal(row[".."].ToString());
            }
            return(p);
        }
Ejemplo n.º 2
0
        public PromocodeResponse PromocodeGet(string pc_name)
        {
            PromocodeResponse pr = new PromocodeResponse();
            PromoCode         p  = PromocodeGetObj(pc_name);
            int errorCode        = 0;

            if (string.IsNullOrWhiteSpace(p.Name))
            {
                errorCode = -1; // not available
            }
            if (p.UsageCurrent >= p.UsageLimit && p.UsageLimit >= 0)
            {
                errorCode = -2;//'promotion run out
            }
            if (errorCode == 0 && p.UserRestriction == 1 && ClientCompletedJobs() < 1)
            {
                if (p.DateEnd > 0)
                {
                    errorCode = -5;//' end date is exceeded
                }
                else
                {
                    errorCode = -3;//' only for existing customers
                }
            }
            if (errorCode == 0 && DateStart < 0)
            {
                errorCode = -4;//' start date is later
            }
            if (errorCode == 0 && DateEnd > 0)
            {
                errorCode = -5;//' end date is exceeded
            }
            pr.name = p.Name;
            if (errorCode == 0)
            {
                pr.type      = p.DiscountType;
                pr.value     = p.DiscountValue;
                pr.appliesTo = p.AppliesTo;
            }
            else
            {
                pr.type = errorCode;
            }

            return(pr);
        }
Ejemplo n.º 3
0
        public static decimal AmountTotal(bool getLists, ref List <Service> services, ref Package pack, ref decimal promoCodeAmount)
        {
            decimal retV = 0;
            Package p    = new Package().Get();

            retV = p.Price;
            Job j = Job.Session();

            decimal servicesPrice = 0;

            if (j.ServicesId != null && p.ServiceListAll != null)
            {
                foreach (int s in j.ServicesId)
                {
                    foreach (var sx in p.ServiceListAll)
                    {
                        if (s == sx.Id)
                        {
                            if (!sx.IncludedInPackage)
                            {
                                servicesPrice += sx.Price;
                                if (getLists)
                                {
                                    services.Add(sx);
                                }
                            }
                            break;
                        }
                    }
                }
            }
            retV += servicesPrice;

            if (getLists)
            {
                pack = p;
            }
            promoCodeAmount = PromoCode.PromoDiscount(j, retV, servicesPrice);

            return(retV - promoCodeAmount);//.ToString("0.00");//"C 0.00"
        }