protected void gvPrices_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                var price = (ProductPriceOverviewModel)e.Row.DataItem;
                ProductPriceOverviewModel chosenPrice = null;

                if (ExistInChosenPrices(price))
                {
                    chosenPrice = ChosenPrices.Find(delegate(ProductPriceOverviewModel item)
                    {
                        return(item.Id == price.Id);
                    });
                }

                CheckBox cb = e.Row.FindControl("cbChosen") as CheckBox;

                if (chosenPrice != null)
                {
                    TextBox txtWeight  = e.Row.FindControl("txtWeight") as TextBox;
                    TextBox txtPrice   = e.Row.FindControl("txtPrice") as TextBox;
                    TextBox txtStock   = e.Row.FindControl("txtStock") as TextBox;
                    TextBox txtBarcode = e.Row.FindControl("txtBarcode") as TextBox;

                    cb.Checked = true;

                    txtWeight.Text  = chosenPrice.Weight.ToString();
                    txtPrice.Text   = AdminStoreUtility.GetFormattedPrice(chosenPrice.Price, CurrencySettings.PrimaryStoreCurrencyCode, CurrencyType.None);
                    txtStock.Text   = chosenPrice.Stock.ToString();
                    txtBarcode.Text = chosenPrice.Barcode;
                }
            }
        }
        protected string CheckIfDifferentFromRRP(string currencyCode, decimal exchangeRate, decimal rrp, decimal priceInclTax)
        {
            if (rrp > 0M && rrp != priceInclTax)
            {
                return(string.Format("was {0}, now {1}",
                                     AdminStoreUtility.GetFormattedPrice(rrp, currencyCode, CurrencyType.HtmlEntity, exchangeRate),
                                     AdminStoreUtility.GetFormattedPrice(priceInclTax, currencyCode, CurrencyType.HtmlEntity, exchangeRate)));
            }

            return(string.Empty);
        }
        protected void lbAuthorise_Click(object sender, EventArgs e)
        {
            int     orderId           = QueryOrderId;
            var     orderView         = OrderService.GetOrderOverviewModelById(orderId);
            decimal totalRefunded     = OrderService.CalculateTotalRefundedAmountByOrderId(orderId);
            decimal totalPaidPayments = OrderService.CalculateTotalPaidAmountByOrderId(orderId);
            decimal totalOrder        = OrderService.CalculateOrderTotalByOrderId(orderId);
            decimal totalPending      = totalOrder - totalRefunded - totalPaidPayments;

            OrderPayment payment = new OrderPayment
            {
                OrderId      = orderId,
                Amount       = totalPending / orderView.ExchangeRate,
                CurrencyCode = orderView.CurrencyCode,
                ExchangeRate = orderView.ExchangeRate,
                TimeStamp    = DateTime.Now
            };

            var output    = PaymentService.ProcessOrderCharging(payment);
            var profileId = Convert.ToInt32(HttpContext.Current.Profile.GetPropertyValue("ProfileId"));
            var fullName  = Convert.ToString(HttpContext.Current.Profile.GetPropertyValue("FullName"));

            if (output.Status)
            {
                var message = " Release amount: " + AdminStoreUtility.GetFormattedPrice(totalPending, payment.CurrencyCode.ToUpper(), CurrencyType.Code);

                OrderService.ProcessOrderCommentInsertion(orderId,
                                                          profileId,
                                                          fullName,
                                                          "Payment",
                                                          "Payment was authorised successfully. " + message,
                                                          string.Empty);

                // Display message and refresh
                InvokeNewMessage("Order was charged successfully.", true);
            }
            else
            {
                OrderService.ProcessOrderCommentInsertion(orderId,
                                                          profileId,
                                                          fullName,
                                                          "Payment",
                                                          "Payment was FAILED to authorise. " + output.Message,
                                                          string.Empty);

                OrderService.UpdateOrderStatusCodeByOrderId(orderId, OrderStatusCode.ON_HOLD);
                OrderService.UpdateOrderIssueCodeByOrderId(orderId, OrderIssueCode.FAILED_TO_CHARGE);

                InvokeNewMessage("Order was FAILED to charge. " + output.Message, true);
            }
        }
        private void LoadOrderSummary()
        {
            int profileId   = QueryUserId;
            int offerRuleId = QueryOfferRuleId;
            var orderTotals = CartService.CalculateOrderTotals(profileId, true, offerRuleId);

            var profile   = AccountService.GetProfileById(profileId);
            var promoCode = profile.GetAttribute <string>("Profile", SystemCustomerAttributeNames.DiscountCouponCode, UtilityService);

            litAppliedPromocode.Text = promoCode;
            litTotalsDiscount.Text   = AdminStoreUtility.GetFormattedPrice(orderTotals.Discount, orderTotals.CurrencyCode, CurrencyType.HtmlEntity);
            litTotalsSubTot.Text     = AdminStoreUtility.GetFormattedPrice(orderTotals.Subtotal, orderTotals.CurrencyCode, CurrencyType.HtmlEntity);
            litTotalsTotal.Text      = AdminStoreUtility.GetFormattedPrice(orderTotals.Total, orderTotals.CurrencyCode, CurrencyType.HtmlEntity);
        }
Exemple #5
0
 protected string GetFormattedPrice(decimal value)
 {
     return(AdminStoreUtility.GetFormattedPrice(value, CurrencySettings.PrimaryStoreCurrencyCode, CurrencyType.HtmlEntity));
 }
        void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
        {
            string[] args = eventArgument.Split(splitter);

            int hourFlag    = 0;
            int dayFlag     = 0;
            int weekFlag    = 0;
            int monthFlag   = 0;
            int quarterFlag = 0;
            int yearFlag    = 0;
            int hour;
            int day;
            int week;
            int month;
            int quarter;
            int year;

            hour    = Convert.ToInt32(args[1]);
            day     = Convert.ToInt32(args[2]);
            week    = Convert.ToInt32(args[3]);
            month   = Convert.ToInt32(args[4]);
            quarter = Convert.ToInt32(args[5]);
            year    = Convert.ToInt32(args[6]);

            string typeFlag = args[8];

            switch (typeFlag)
            {
            case "hour":
                weekFlag    = 1;
                quarterFlag = 1;
                break;

            case "day":
                hourFlag    = 1;
                weekFlag    = 1;
                quarterFlag = 1;
                break;

            case "week":
                hourFlag    = 1;
                dayFlag     = 1;
                monthFlag   = 1;
                quarterFlag = 1;
                break;

            case "month":
                hourFlag    = 1;
                dayFlag     = 1;
                weekFlag    = 1;
                quarterFlag = 1;
                break;

            case "quarter":
                hourFlag  = 1;
                dayFlag   = 1;
                weekFlag  = 1;
                monthFlag = 1;
                break;

            case "year":
                hourFlag    = 1;
                dayFlag     = 1;
                weekFlag    = 1;
                monthFlag   = 1;
                quarterFlag = 1;
                break;
            }

            bool noneu = Convert.ToBoolean(args[7]);
            int  count = 0;

            switch (args[0])
            {
            case "noOrders":
                count = ReportService.GetOrderCountSumByDate(AdminStoreUtility.BuildXmlString("status", ValidOrderStatus.VALID_STATUSES),
                                                             noneu,
                                                             hourFlag,
                                                             dayFlag,
                                                             weekFlag,
                                                             monthFlag,
                                                             quarterFlag,
                                                             yearFlag,
                                                             hour,
                                                             day,
                                                             week,
                                                             month,
                                                             quarter,
                                                             year);
                message = count.ToString();

                break;

            case "promoDiscount":
                decimal promoDiscount = ReportService.GetOrderDiscountSumByDate(
                    AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES),
                    noneu,
                    hourFlag,
                    dayFlag,
                    weekFlag,
                    monthFlag,
                    quarterFlag,
                    yearFlag,
                    hour,
                    day,
                    week,
                    month,
                    quarter,
                    year);
                message = AdminStoreUtility.GetFormattedPrice(promoDiscount,
                                                              CurrencySettings.PrimaryStoreCurrencyCode,
                                                              CurrencyType.HtmlEntity);
                break;

            case "loyaltyDiscount":
                decimal loyaltyDiscount = ReportService.GetOrderLoyaltyDiscountSumByDate(AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES),
                                                                                         noneu,
                                                                                         hourFlag,
                                                                                         dayFlag,
                                                                                         weekFlag,
                                                                                         monthFlag,
                                                                                         quarterFlag,
                                                                                         yearFlag,
                                                                                         hour,
                                                                                         day,
                                                                                         week,
                                                                                         month,
                                                                                         quarter,
                                                                                         year);
                message = AdminStoreUtility.GetFormattedPrice(loyaltyDiscount,
                                                              CurrencySettings.PrimaryStoreCurrencyCode,
                                                              CurrencyType.HtmlEntity);
                break;

            case "lineCostPrice":
                decimal lineCostPrice = ReportService.GetLineCostSumByDate(AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES),
                                                                           AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidLineStatus.VALID_LINE_STATUSES),
                                                                           noneu,
                                                                           hourFlag,
                                                                           dayFlag,
                                                                           weekFlag,
                                                                           monthFlag,
                                                                           quarterFlag,
                                                                           yearFlag,
                                                                           hour,
                                                                           day,
                                                                           week,
                                                                           month,
                                                                           quarter,
                                                                           year);
                message = AdminStoreUtility.GetFormattedPrice(lineCostPrice,
                                                              CurrencySettings.PrimaryStoreCurrencyCode,
                                                              CurrencyType.HtmlEntity);
                break;

            case "margin":
                decimal margin = ReportService.GetMarginValueSumByDate(AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES),
                                                                       AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidLineStatus.VALID_LINE_STATUSES),
                                                                       noneu,
                                                                       20,
                                                                       hourFlag,
                                                                       dayFlag,
                                                                       weekFlag,
                                                                       monthFlag,
                                                                       quarterFlag,
                                                                       yearFlag,
                                                                       hour,
                                                                       day,
                                                                       week,
                                                                       month,
                                                                       quarter,
                                                                       year);
                message = margin.ToString() + "%";
                break;

            case "shipping":
                decimal shipping = ReportService.GetShippingValueSumByDate(
                    AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES),
                    AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidLineStatus.VALID_LINE_STATUSES),
                    noneu,
                    20,
                    hourFlag,
                    dayFlag,
                    weekFlag,
                    monthFlag,
                    quarterFlag,
                    yearFlag,
                    hour,
                    day,
                    week,
                    month,
                    quarter,
                    year);
                message = AdminStoreUtility.GetFormattedPrice(shipping,
                                                              CurrencySettings.PrimaryStoreCurrencyCode,
                                                              CurrencyType.HtmlEntity);
                break;

            case "orderValue":
                decimal orderValue = ReportService.GetOrderValueSumByDate(AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES),
                                                                          AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidLineStatus.VALID_LINE_STATUSES),
                                                                          noneu,
                                                                          20,
                                                                          hourFlag,
                                                                          dayFlag,
                                                                          weekFlag,
                                                                          monthFlag,
                                                                          quarterFlag,
                                                                          yearFlag,
                                                                          hour,
                                                                          day,
                                                                          week,
                                                                          month,
                                                                          quarter,
                                                                          year);

                message = AdminStoreUtility.GetFormattedPrice(orderValue, CurrencySettings.PrimaryStoreCurrencyCode, CurrencyType.HtmlEntity);

                decimal nonTaxableOrderValue = ReportService.GetNonTaxableOrderValueSumByDate(AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES),
                                                                                              AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidLineStatus.VALID_LINE_STATUSES),
                                                                                              noneu,
                                                                                              20,
                                                                                              hourFlag,
                                                                                              dayFlag,
                                                                                              weekFlag,
                                                                                              monthFlag,
                                                                                              quarterFlag,
                                                                                              yearFlag,
                                                                                              hour,
                                                                                              day,
                                                                                              week,
                                                                                              month,
                                                                                              quarter,
                                                                                              year);

                decimal vatDiscount = nonTaxableOrderValue / (120M) * 20M;

                decimal netOrderValue = AdminStoreUtility.RoundPrice(orderValue) - AdminStoreUtility.RoundPrice(vatDiscount);

                message = AdminStoreUtility.GetFormattedPrice(netOrderValue, CurrencySettings.PrimaryStoreCurrencyCode, CurrencyType.HtmlEntity);

                break;

            case "productDiscount":
                decimal productDiscount = ReportService.GetProductDiscountSumByDate(
                    AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES),
                    AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidLineStatus.VALID_LINE_STATUSES),
                    noneu,
                    hourFlag,
                    dayFlag,
                    weekFlag,
                    monthFlag,
                    quarterFlag,
                    yearFlag,
                    hour,
                    day,
                    week,
                    month,
                    quarter,
                    year);
                message = AdminStoreUtility.GetFormattedPrice(productDiscount,
                                                              CurrencySettings.PrimaryStoreCurrencyCode,
                                                              CurrencyType.HtmlEntity);
                break;

            case "orderAverageValue":
                decimal totalOrderValue = ReportService.GetOrderValueSumByDate(AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES),
                                                                               AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidLineStatus.VALID_LINE_STATUSES),
                                                                               noneu,
                                                                               20,
                                                                               hourFlag,
                                                                               dayFlag,
                                                                               weekFlag,
                                                                               monthFlag,
                                                                               quarterFlag,
                                                                               yearFlag,
                                                                               hour,
                                                                               day,
                                                                               week,
                                                                               month,
                                                                               quarter,
                                                                               year);

                decimal totalNonTaxableOrderValue = ReportService.GetNonTaxableOrderValueSumByDate(AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES),
                                                                                                   AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidLineStatus.VALID_LINE_STATUSES),
                                                                                                   noneu,
                                                                                                   20,
                                                                                                   hourFlag,
                                                                                                   dayFlag,
                                                                                                   weekFlag,
                                                                                                   monthFlag,
                                                                                                   quarterFlag,
                                                                                                   yearFlag,
                                                                                                   hour,
                                                                                                   day,
                                                                                                   week,
                                                                                                   month,
                                                                                                   quarter,
                                                                                                   year);

                decimal totalVatDiscount = totalNonTaxableOrderValue / (120M) * 20M;

                decimal totalNetOrderValue = AdminStoreUtility.RoundPrice(totalOrderValue) - AdminStoreUtility.RoundPrice(totalVatDiscount);

                int totalOrder = ReportService.GetOrderCountSumByDate(AdminStoreUtility.BuildXmlString("status", ValidOrderStatus.VALID_STATUSES),
                                                                      noneu,
                                                                      hourFlag,
                                                                      dayFlag,
                                                                      weekFlag,
                                                                      monthFlag,
                                                                      quarterFlag,
                                                                      yearFlag,
                                                                      hour,
                                                                      day,
                                                                      week,
                                                                      month,
                                                                      quarter,
                                                                      year);

                if (totalNetOrderValue != 0M && totalOrder != 0)
                {
                    message = AdminStoreUtility.GetFormattedPrice(totalNetOrderValue / totalOrder, CurrencySettings.PrimaryStoreCurrencyCode, CurrencyType.HtmlEntity);
                }
                else
                {
                    message = AdminStoreUtility.GetFormattedPrice(0M, CurrencySettings.PrimaryStoreCurrencyCode, CurrencyType.HtmlEntity);
                }

                break;
            }
        }