protected void lbSave_Click(object sender, EventArgs e) { string urlKey = txtUrlKey.Text.Trim(); // If urlKey is empty, regenerate with given name if (urlKey == string.Empty) { urlKey = AdminStoreUtility.GetFriendlyUrlKey(txtRuleAlias.Text.Trim()); txtUrlKey.Text = urlKey; } // Make sure urlKey is unique if (((OfferService.GetOfferRuleByUrlKey(urlKey) != null) && (OfferService.GetOfferRuleByUrlKey(urlKey).Id != QueryOfferRuleId))) { enbNotice.Message = "Offer was failed to save. URL key is not unique."; } else { string htmlMsg; if (ftbDesc.Visible) { htmlMsg = AdminStoreUtility.CleanFtbOutput(ftbDesc.Text); } else { htmlMsg = txtDescription.Text.Trim(); } // Retrieve rule from database var rule = OfferService.GetOfferRuleById(QueryOfferRuleId); rule.Name = txtRuleName.Text.Trim(); rule.ProceedForNext = Convert.ToBoolean(rblProceed.SelectedValue); rule.IsActive = Convert.ToBoolean(rblStatus.SelectedValue); rule.PromoCode = txtPromoCode.Text.Trim(); rule.UsesPerCustomer = Convert.ToInt32(txtUsesPerCust.Text.Trim()); rule.Priority = Convert.ToInt32(txtPriority.Text.Trim()); rule.HtmlMessage = htmlMsg; rule.OfferedItemIncluded = cbOfferedItemIncluded.Checked; rule.Alias = txtRuleAlias.Text.Trim(); rule.PointSpendable = chkPointSpendable.Checked; rule.UrlRewrite = urlKey; rule.UseInitialPrice = cbUseInitialPrice.Checked; rule.NewCustomerOnly = cbNewCustomerOnly.Checked; rule.ShowCountDown = cbShowCountDownTimer.Checked; rule.DisplayOnProductPage = cbDisplayOnProductPage.Checked; rule.OfferTypeId = Convert.ToInt32(ddlOfferTypes.SelectedValue); if (ddlRelatedTypes.SelectedValue != string.Empty) { switch (ddlRelatedTypes.SelectedValue) { case "products": rule.RelatedProducts = txtRelatedItems.Text.ToString(); break; case "brands": rule.RelatedBrands = txtRelatedItems.Text.ToString(); break; case "category": rule.RelatedCategory = txtRelatedItems.Text.ToString(); break; } } else { rule.RelatedProducts = string.Empty; rule.RelatedBrands = string.Empty; rule.RelatedCategory = string.Empty; } if (!string.IsNullOrEmpty(txtDateFrom.Text.Trim())) { rule.StartDate = DateTime.ParseExact(txtDateFrom.Text, AppConstant.DATE_FORM1, CultureInfo.InvariantCulture); } else { rule.StartDate = null; } if (!string.IsNullOrEmpty(txtDateTo.Text.Trim())) { rule.EndDate = DateTime.ParseExact(txtDateTo.Text, AppConstant.DATE_FORM1, CultureInfo.InvariantCulture); } else { rule.EndDate = null; } rule.ShortDescription = txtShortDescription.Text; string longDesc; if (!ftbLongDesc.Visible && txtLongDesc.Visible) { if (txtLongDesc.Text != string.Empty) { longDesc = txtLongDesc.Text.Trim(); } else { longDesc = txtShortDescription.Text.Trim(); } } else if (ftbLongDesc.Visible) { longDesc = AdminStoreUtility.CleanFtbOutput(ftbLongDesc.Text); } else { longDesc = txtShortDescription.Text.Trim(); } rule.LongDescription = longDesc; rule.ShowInOfferPage = chkShowOnOfferPage.Checked; rule.DisplayOnHeaderStrip = chkDisplayOnHeaderStrip.Checked; rule.OfferLabel = txtOfferLabel.Text.Trim(); rule.DisableOfferLabel = cbDisableOfferLabel.Checked; rule.OfferUrl = txtViewOfferURL.Text.Trim(); if (fuSmallImage.HasFile) { string filename = rule.Id.ToString() + "_small" + Path.GetExtension(fuSmallImage.FileName).ToLower(); fuSmallImage.SaveAs(MediaSettings.OfferMediaLocalPath + filename); rule.SmallImage = filename; } if (fuLargeImage.HasFile) { string filename = rule.Id.ToString() + "_large" + Path.GetExtension(fuLargeImage.FileName).ToLower(); fuLargeImage.SaveAs(MediaSettings.OfferMediaLocalPath + filename); rule.LargeImage = filename; } object freeProductItself = DBNull.Value; object freeProductId = DBNull.Value; object freeProductPriceId = DBNull.Value; object freeProductQty = DBNull.Value; // Determine if there is any free item settings if (rbFreeItself.Checked || rbFreeItem.Checked) { freeProductItself = rbFreeItself.Checked; if (rbFreeItem.Checked) { freeProductId = txtFreeProductId.Text.Trim(); freeProductPriceId = txtFreeProductPriceId.Text.Trim(); freeProductQty = txtFreeQuantity.Text.Trim(); } } object discountQtyStep = DBNull.Value; object minimumAmount = DBNull.Value; object discountAmount = DBNull.Value; int rewardPoint = 0; if (txtDiscountQtyStep.Text.Trim() != string.Empty) { discountQtyStep = txtDiscountQtyStep.Text.Trim(); } if (txtMinimumAmount.Text.Trim() != string.Empty) { minimumAmount = txtMinimumAmount.Text.Trim(); } if (txtDiscountAmount.Text.Trim() != string.Empty) { discountAmount = txtDiscountAmount.Text.Trim(); } if (txtRewardPoint.Text.Trim() != string.Empty) { rewardPoint = Convert.ToInt32(txtRewardPoint.Text.Trim()); } // Retrieve size target if any object optionOperatorId = DBNull.Value; object optionOperator = DBNull.Value; object optionOperand = DBNull.Value; if (txtOption.Text.Trim() != string.Empty) { optionOperand = txtOption.Text.Trim(); optionOperatorId = ddlOptionOperator.SelectedValue; optionOperator = OfferService.GetOfferOperator(Convert.ToInt32(optionOperatorId)).Operator; } int offerActionId = OfferService.GetOfferRuleById(QueryOfferRuleId).Action.Id; // Assign action to this rule object's action var newAction = new OfferAction { Id = offerActionId, OfferRuleId = QueryOfferRuleId }; if (discountAmount != DBNull.Value) { newAction.DiscountAmount = Convert.ToDecimal(discountAmount); } if (freeProductItself != DBNull.Value) { newAction.FreeProductItself = Convert.ToBoolean(freeProductItself); } if (freeProductId != DBNull.Value) { newAction.FreeProductId = Convert.ToInt32(freeProductId); } if (freeProductPriceId != DBNull.Value) { newAction.FreeProductPriceId = Convert.ToInt32(freeProductPriceId); } if (freeProductQty != DBNull.Value) { newAction.FreeProductQty = Convert.ToInt32(freeProductQty); } newAction.OfferActionAttributeId = Convert.ToInt32(ddlAction.SelectedValue); newAction.Name = ddlAction.SelectedItem.Text; newAction.IsCart = true; if (discountQtyStep != DBNull.Value) { newAction.DiscountQtyStep = Convert.ToInt32(discountQtyStep); } if (minimumAmount != DBNull.Value) { newAction.MinimumAmount = Convert.ToDecimal(minimumAmount); } newAction.RewardPoint = rewardPoint; if (optionOperatorId != DBNull.Value) { newAction.OptionOperatorId = Convert.ToInt32(optionOperatorId); } if (optionOperand != DBNull.Value) { newAction.OptionOperand = Convert.ToString(optionOperand); } if ((optionOperator != DBNull.Value) && (optionOperatorId != DBNull.Value)) { newAction.OptionOperator = new OfferOperator { Id = Convert.ToInt32(optionOperatorId), Operator = Convert.ToString(optionOperator) } } ; newAction.XValue = Convert.ToInt32(txtXValue.Text.Trim()); newAction.YValue = Convert.ToDecimal(txtYValue.Text.Trim()); rule.Action = newAction; var proceed = true; // Assign root condition to this rule object's condition rule.Condition = OfferUtility.OfferRuleConditions[rule.Id]; if (rule.Condition == null) { enbNotice.Message = "Offer was failed to update. There is no condition setup for this offer. It could be due to session lost. Please try to create again."; proceed = false; } // Assign root condition to this action object's condition rule.Action.Condition = OfferUtility.OfferActionConditions[rule.Id]; if (rule.Action.Condition == null) { enbNotice.Message = "Offer was failed to update. There is no <u>action</u> condition setup for this offer. It could be due to session lost. Please try to create again."; proceed = false; } if (proceed) { // Update database var success = OfferService.ProcessOfferUpdation(rule); if (success) { enbNotice.Message = "Offer was updated successfully."; } else { enbNotice.Message = "Offer was failed to update."; } } LoadCartOfferInfo(); } }
protected void ddlDelivery_Init(object sender, EventArgs e) { DropDownList ddl = (DropDownList)sender; ddl = AdminStoreUtility.GenerateDeliveryList(ddl); }
public void RaiseCallbackEvent(string eventArgument) { string type = eventArgument; string param = string.Empty; if (type.Split('|').Length > 1) { param = type.Split('|')[1]; type = type.Split('|')[0]; } switch (type) { case "charge_failed": int failedChargeCount = OrderService.GetOrderCountByOrderStatusAndIssueCode( OrderStatusCode.ON_HOLD, OrderIssueCode.FAILED_TO_CHARGE); message = failedChargeCount.ToString(); break; case "otc_order_system_check": int otcOrderSystemCheckCount = OrderService.GetOrderCountByOrderStatusAndIssueCode( OrderStatusCode.ON_HOLD, OrderIssueCode.OTC_ORDER_AND_SYSTEM_CHECK_FAILED); message = otcOrderSystemCheckCount.ToString(); break; case "otc_order": int otcOrderCount = OrderService.GetOrderCountByOrderStatusAndIssueCode( OrderStatusCode.ON_HOLD, OrderIssueCode.OTC_ORDER); message = otcOrderCount.ToString(); break; case "system_check": int systemCheckCount = OrderService.GetOrderCountByOrderStatusAndIssueCode( OrderStatusCode.ON_HOLD, OrderIssueCode.SYSTEM_CHECK_FAILED); message = systemCheckCount.ToString(); break; case "order_placed": int orderPlacedCount = OrderService.GetOrderCountByOrderStatus(OrderStatusCode.ORDER_PLACED); message = orderPlacedCount.ToString(); break; case "cancel": int cancelCount = OrderService.GetRefundCountByTypeAndStatus(true, true); message = cancelCount.ToString(); break; case "refund": int refundCount = OrderService.GetRefundCountByTypeAndStatus(false, true); message = refundCount.ToString(); break; case "line_items": int lineItemcount = 0; string inLineStatusXml = AdminStoreUtility.BuildXmlString("status", new string[] { LineStatusCode.ORDERED, LineStatusCode.PENDING }); string inOrderStatusXml = AdminStoreUtility.BuildXmlString("status", new string[] { OrderStatusCode.ORDER_PLACED, OrderStatusCode.PARTIAL_SHIPPING }); DataTable pendingOrderTable = OrderService.GetOrderCountGroupByDate(inLineStatusXml, inOrderStatusXml); for (int i = 0; i < pendingOrderTable.Rows.Count; i++) { lineItemcount += Convert.ToInt32(pendingOrderTable.Rows[i][1]); } message = lineItemcount.ToString(); break; case "picking": int pickingItemCount = 0; message = pickingItemCount.ToString(); break; case "packing": int packingCount = OrderService.GetOrderCountForPacking(); message = packingCount.ToString(); break; case "despatch": int despatchCount = OrderService.GetOrderCountByOrderStatus(OrderStatusCode.SHIPPING); message = despatchCount.ToString(); break; case "complete": int completeCount = OrderService.GetOrderCountByOrderStatus(OrderStatusCode.INVOICED); message = completeCount.ToString(); break; case "awaiting_reply": int awaitingReplyCount = OrderService.GetOrderCountByOrderStatus(OrderStatusCode.AWAITING_REPLY); message = awaitingReplyCount.ToString(); break; case "cancel_value_chart": DateTime chosenCancelDate = ParseDate(param); string inOrderStatusXmlForCancelValueChart = AdminStoreUtility.BuildXmlString("status", new string[] { OrderStatusCode.CANCELLED, OrderStatusCode.SCHEDULED_FOR_CANCEL }); int count1 = ReportService.GetOrderCountSumByDate(inOrderStatusXmlForCancelValueChart, false, 1, 0, 1, 0, 1, 0, 0, chosenCancelDate.Day, 0, chosenCancelDate.Month, 0, chosenCancelDate.Year); message = count1.ToString(); break; case "cancel_other_value_chart": DateTime chosenCancelOtherDate = ParseDate(param); string inOrderStatusXmlForCancelOtherValueChart = AdminStoreUtility.BuildXmlString("status", new string[] { OrderStatusCode.ORDER_PLACED, OrderStatusCode.PARTIAL_SHIPPING, OrderStatusCode.SHIPPING, OrderStatusCode.STOCK_WARNING, OrderStatusCode.INVOICED, OrderStatusCode.ON_HOLD }); int count2 = ReportService.GetOrderCountSumByDate(inOrderStatusXmlForCancelOtherValueChart, false, 1, 0, 1, 0, 1, 0, 0, chosenCancelOtherDate.Day, 0, chosenCancelOtherDate.Month, 0, chosenCancelOtherDate.Year); message = count2.ToString(); break; case "refund_value_chart": int refundValueChartCount = OrderService.GetRefundCountByTypeAndStatus(false, true, param, param); message = refundValueChartCount.ToString(); break; case "refund_other_value_chart": DateTime chosenRefundOtherDate = ParseDate(param); string inOrderStatusXmlForRefundOtherValueChart = AdminStoreUtility.BuildXmlString("status", new string[] { OrderStatusCode.ORDER_PLACED, OrderStatusCode.PARTIAL_SHIPPING, OrderStatusCode.SHIPPING, OrderStatusCode.STOCK_WARNING, OrderStatusCode.INVOICED, OrderStatusCode.ON_HOLD }); int count3 = ReportService.GetOrderCountSumByDate(inOrderStatusXmlForRefundOtherValueChart, false, 1, 0, 1, 0, 1, 0, 0, chosenRefundOtherDate.Day, 0, chosenRefundOtherDate.Month, 0, chosenRefundOtherDate.Year); message = count3.ToString(); break; case "as_value_chart": var asList = OrderService.GetLineItemListByStatusCodeAndDate(DateTime.Now.AddYears(-3), DateTime.MaxValue, new string[] { LineStatusCode.AWAITING_STOCK }, new string[] { OrderStatusCode.ORDER_PLACED, OrderStatusCode.PARTIAL_SHIPPING }); message = asList.Count.ToString(); break; case "sw_value_chart": var swList = OrderService.GetLineItemListByStatusCodeAndDate(DateTime.Now.AddYears(-3), DateTime.MaxValue, new string[] { LineStatusCode.GOODS_ALLOCATED }, new string[] { OrderStatusCode.ORDER_PLACED, OrderStatusCode.PARTIAL_SHIPPING }); message = swList.Count.ToString(); break; case "ga_value_chart": var gaList = OrderService.GetLineItemListByStatusCodeAndDate(DateTime.Now.AddYears(-3), DateTime.MaxValue, new string[] { LineStatusCode.GOODS_ALLOCATED }, new string[] { OrderStatusCode.ORDER_PLACED, OrderStatusCode.PARTIAL_SHIPPING }); message = gaList.Count.ToString(); break; case "pp_value_chart": var ppList = OrderService.GetLineItemListByStatusCodeAndDate(DateTime.Now.AddYears(-3), DateTime.MaxValue, new string[] { LineStatusCode.PICK_IN_PROGRESS }, new string[] { OrderStatusCode.ORDER_PLACED, OrderStatusCode.PARTIAL_SHIPPING }); message = ppList.Count.ToString(); break; case "o_value_chart": var oList = OrderService.GetLineItemListByStatusCodeAndDate(DateTime.Now.AddYears(-3), DateTime.MaxValue, new string[] { LineStatusCode.ORDERED }, new string[] { OrderStatusCode.ORDER_PLACED, OrderStatusCode.PARTIAL_SHIPPING }); message = oList.Count.ToString(); break; case "shipment_value_chart": DateTime chosenDate = new DateTime(); DateTime.TryParseExact(param, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out chosenDate); StringBuilder sb = new StringBuilder(); // Loop each day for (int i = -3; i < 4; i++) { DateTime loopDate = chosenDate.AddDays(i); string dateInString = loopDate.ToString("dd/MM/yyyy"); sb.Append(dateInString).Append(","); // Get rate for same day sb.Append(OrderService.GetShipmentRate(dateInString, 0, 3)).Append(","); // Get rate for > 3 days sb.Append(OrderService.GetShipmentRate(dateInString, 3, 7)).Append(","); // Get rate for > 1 week sb.Append(OrderService.GetShipmentRate(dateInString, 7, 14)).Append(","); // Get rate for > 2 weeks sb.Append(OrderService.GetShipmentRate(dateInString, 14, 999)).Append(","); } sb = sb.Remove(sb.Length - 1, 1); message = sb.ToString(); break; } }
protected void lbSave_Click(object sender, EventArgs e) { string urlKey = txtUrlKey.Text.Trim(); // If urlKey is empty, regenerate with given name if (urlKey == string.Empty) { urlKey = AdminStoreUtility.GetFriendlyUrlKey(txtRuleAlias.Text.Trim()); txtUrlKey.Text = urlKey; } // Make sure urlKey is unique if (((OfferService.GetOfferRuleByUrlKey(urlKey) != null) && (OfferService.GetOfferRuleByUrlKey(urlKey).Id != QueryOfferRuleId))) { enbNotice.Message = "Offer was failed to save. URL key is not unique."; } else { var rule = OfferService.GetOfferRuleById(QueryOfferRuleId); rule.UrlRewrite = urlKey; rule.Name = txtRuleName.Text.Trim(); rule.ProceedForNext = Convert.ToBoolean(rblProceed.SelectedValue); rule.IsActive = Convert.ToBoolean(rblStatus.SelectedValue); rule.Priority = Convert.ToInt32(txtPriority.Text.Trim()); rule.Alias = txtRuleAlias.Text.Trim(); rule.ShowOfferTag = chkShowOfferTag.Checked; rule.ShowRRP = chkShowRRP.Checked; rule.OfferUrl = txtViewOfferURL.Text.Trim(); rule.PointSpendable = chkPointSpendable.Checked; rule.ShowCountDown = cbShowCountDownTimer.Checked; if (!string.IsNullOrEmpty(txtDateFrom.Text.Trim())) { rule.StartDate = DateTime.ParseExact(txtDateFrom.Text, AppConstant.DATE_FORM1, CultureInfo.InvariantCulture); } else { rule.StartDate = null; } if (!string.IsNullOrEmpty(txtDateTo.Text.Trim())) { rule.EndDate = DateTime.ParseExact(txtDateTo.Text, AppConstant.DATE_FORM1, CultureInfo.InvariantCulture); } else { rule.EndDate = null; } rule.ShortDescription = txtShortDescription.Text; string htmlMsg; if (ftbLongDesc.Visible) { htmlMsg = AdminStoreUtility.CleanFtbOutput(ftbLongDesc.Text); } else { htmlMsg = txtShortDescription.Text.Trim(); } rule.LongDescription = htmlMsg; rule.ShowInOfferPage = chkShowOnOfferPage.Checked; rule.DisplayOnHeaderStrip = chkDisplayOnHeaderStrip.Checked; rule.OfferLabel = txtOfferLabel.Text.Trim(); rule.DisableOfferLabel = cbDisableOfferLabel.Checked; rule.DisplayOnProductPage = cbDisplayOnProductPage.Checked; rule.OfferTypeId = Convert.ToInt32(ddlOfferTypes.SelectedValue); if (ddlRelatedTypes.SelectedValue != string.Empty) { switch (ddlRelatedTypes.SelectedValue) { case "products": rule.RelatedProducts = txtRelatedItems.Text.ToString(); break; case "brands": rule.RelatedBrands = txtRelatedItems.Text.ToString(); break; case "category": rule.RelatedCategory = txtRelatedItems.Text.ToString(); break; } } else { rule.RelatedProducts = string.Empty; rule.RelatedBrands = string.Empty; rule.RelatedCategory = string.Empty; } if (fuSmallImage.HasFile) { string filename = rule.Id.ToString() + "_small" + Path.GetExtension(fuSmallImage.FileName).ToLower(); fuSmallImage.SaveAs(MediaSettings.OfferMediaLocalPath + filename); rule.SmallImage = filename; } if (fuLargeImage.HasFile) { string filename = rule.Id.ToString() + "_large" + Path.GetExtension(fuLargeImage.FileName).ToLower(); fuLargeImage.SaveAs(MediaSettings.OfferMediaLocalPath + filename); rule.LargeImage = filename; } var newAction = new OfferAction { Id = rule.Action.Id, OfferRuleId = rule.Action.OfferRuleId, DiscountAmount = Convert.ToDecimal(txtDiscountAmount.Text), OfferActionAttributeId = Convert.ToInt32(ddlAction.SelectedValue), Name = ddlAction.SelectedItem.Text, IsCatalog = true }; // Retrieve size target if any string optionOperatorId = null; string optionOperator = null; string optionOperand = null; if (txtOption.Text.Trim() != string.Empty) { optionOperand = txtOption.Text.Trim(); optionOperatorId = ddlOptionOperator.SelectedValue; optionOperator = OfferService.GetOfferOperator(Convert.ToInt32(optionOperatorId)).Operator; } if (!string.IsNullOrEmpty(optionOperatorId)) { newAction.OptionOperatorId = Convert.ToInt32(optionOperatorId); } if (!string.IsNullOrEmpty(optionOperand)) { newAction.OptionOperand = Convert.ToString(optionOperand); } if ((!string.IsNullOrEmpty(optionOperator)) && (!string.IsNullOrEmpty(optionOperatorId))) { newAction.OptionOperator = new OfferOperator { Id = Convert.ToInt32(optionOperatorId), Operator = Convert.ToString(optionOperator) } } ; rule.Action = newAction; var proceed = true; // Assign root condition to this rule object's condition rule.Condition = OfferUtility.OfferRuleConditions[rule.Id]; if (rule.Condition == null) { enbNotice.Message = "Offer was failed to update. There is no condition setup for this offer. It could be due to session lost. Please try to create again."; proceed = false; } if (proceed) { // Update database var success = OfferService.ProcessOfferUpdation(rule); if (success) { enbNotice.Message = "Offer was updated successfully."; } else { enbNotice.Message = "Offer was failed to update."; } LoadCatalogInfo(); } } }
protected string GetFormattedPrice(decimal value) { return(AdminStoreUtility.GetFormattedPrice(value, CurrencySettings.PrimaryStoreCurrencyCode, CurrencyType.HtmlEntity)); }
private void LoadInfo(bool charged) { int orderId = QueryOrderId; var shippingAddress = OrderService.GetShippingAddressViewModelByOrderId(orderId); ltlHeaderAddress.Text = "Ship To:" + HtmlElement.BR; if (string.IsNullOrEmpty(shippingAddress.Name) == false) { ltlHeaderAddress.Text += shippingAddress.Name + HtmlElement.BR; } if (string.IsNullOrEmpty(shippingAddress.AddressLine1) == false) { ltlHeaderAddress.Text += shippingAddress.AddressLine1 + HtmlElement.BR; } if (string.IsNullOrEmpty(shippingAddress.AddressLine2) == false) { ltlHeaderAddress.Text += shippingAddress.AddressLine2 + HtmlElement.BR; } if (string.IsNullOrEmpty(shippingAddress.City) == false) { ltlHeaderAddress.Text += shippingAddress.City + HtmlElement.BR; } if (string.IsNullOrEmpty(shippingAddress.PostCode) == false) { ltlHeaderAddress.Text += shippingAddress.PostCode + HtmlElement.BR; } if (string.IsNullOrEmpty(shippingAddress.USStateName) == false) { ltlHeaderAddress.Text += shippingAddress.USStateName + HtmlElement.BR; } if (string.IsNullOrEmpty(shippingAddress.CountryName) == false) { ltlHeaderAddress.Text += shippingAddress.CountryName + HtmlElement.BR; } ltlDeliveryAddr.Text = ltlHeaderAddress.Text; eohHeader.OrderId = orderId; eavShipping.OrderId = orderId; var orderView = OrderService.GetOrderOverviewModelById(orderId); esnShipping.OrderOverviewModel = orderView; // Exclude anonymous order if (orderView.ProfileId > 0) { var account = AccountService.GetAccountByProfileId(orderView.ProfileId); if (account != null) { eavShipping.Email = string.IsNullOrEmpty(account.Email) ? string.Empty : account.Email; eavShipping.Phone = string.IsNullOrEmpty(account.ContactNumber) ? string.Empty : account.ContactNumber; eavShipping.DisplayPhone = account.DisplayContactNumberInDespatch; ltContactNumber.Text = string.Empty; if (account.DisplayContactNumberInDespatch) { ltContactNumber.Text = string.Format("<i class='fa fa-phone' aria-hidden='true'></i> {0}", account.ContactNumber); } } } if (orderView.PointValue > 0) { phEarnPoint.Visible = true; ltlPointValue.Text = orderView.PointValue.ToString(); } else { phEarnPoint.Visible = false; } var items = OrderService.GetLineItemOverviewModelListByOrderId(orderId); rptItems.DataSource = items; rptItems.DataBind(); rptDnoteItems.DataSource = items; rptDnoteItems.DataBind(); rptComments.DataSource = OrderService.GetOrderCommentOverviewModelListByOrderId(orderId, AppConstant.SHOW_MAX_COMMENT); rptComments.DataBind(); if (orderView.StatusCode == OrderStatusCode.SHIPPING || orderView.StatusCode == OrderStatusCode.INVOICED || orderView.StatusCode == OrderStatusCode.CANCELLED || orderView.StatusCode == OrderStatusCode.DISCARDED || orderView.StatusCode == OrderStatusCode.PENDING || orderView.StatusCode == OrderStatusCode.SCHEDULED_FOR_CANCEL || orderView.StatusCode == OrderStatusCode.STOCK_WARNING) { phItems.Visible = false; esnShipping.Visible = false; } else { phItems.Visible = true; esnShipping.Visible = true; } var GAItems = items.Where(i => i.StatusCode == LineStatusCode.GOODS_ALLOCATED).ToList(); int weight = 0; decimal netValue = 0M; int quantityGA = GAItems.Select(i => i.Quantity).Sum(); int quantityOrder = items.Select(i => i.Quantity).Sum(); GAItems.ForEach(delegate(LineItemOverviewModel item) { weight += item.Weight * item.Quantity; netValue += (item.PriceExclTax * item.Quantity); }); // Discount only if quantities match if (quantityOrder == quantityGA) { decimal result = netValue - orderView.DiscountValue; if (result > 0M) { netValue = result; } } ltlWeightGrams.Text = "<input id=\"cn22Weight\" class=\"form-control\" type=\"text\" value=\"" + weight + "\" onkeyup=\"getWeightInput(event)\" />"; ltlNetValue.Text = "<input id=\"cn22Value\" class=\"form-control\" type=\"text\" value=\"" + orderView.CurrencyCode + " " + AdminStoreUtility.RoundPrice(netValue) + "\" onkeyup=\"getValueInput(event)\" />"; if (GAItems.Count == 0) { lbSubmitTop.Visible = false; lbSubmitBottom.Visible = false; } if (charged) { lbProcessPaymentTop.Visible = false; phAfterPaymentTop.Visible = true; lbProcessPaymentBottom.Visible = false; phAfterPaymentBottom.Visible = true; } else { lbProcessPaymentTop.Visible = true; phAfterPaymentTop.Visible = false; lbProcessPaymentBottom.Visible = true; phAfterPaymentBottom.Visible = false; enbInfo.Message = "This order was not fully paid. Please process payment first before proceed to packing."; } // Shipping Option ID // Next Day Shipping Option ID = 2 // Local Standard Shipping Option ID = 1 if (shippingAddress.CountryId == ShippingSettings.PrimaryStoreCountryId) { ltlFirstClass.Text = "<input type=\"radio\" name=\"stampType\" value=\"firstClass\" checked=\"checked\" /> 1st class"; ltlInternational.Text = "<input type=\"radio\" name=\"stampType\" value=\"international\" /> International"; } else { ltlFirstClass.Text = "<input type=\"radio\" name=\"stampType\" value=\"firstClass\" /> 1st class"; ltlInternational.Text = "<input type=\"radio\" name=\"stampType\" value=\"international\" checked=\"checked\" /> International"; } ltlCN22Date.Text = DateTime.Now.ToString(AppConstant.DATE_FORM1); ltlSignature.Text = "<img src=\"/img/diana-sig.jpg\" alt=\"diana\" width=\"50\" />"; // Default var country = ShippingService.GetCountryById(shippingAddress.CountryId); ltlDeminimis.Text = country.DeminimisValue; ltOrderNumber.Text = string.Format("Order # {0}", orderId); ltOrderNumberReturn.Text = ltOrderNumber.Text; int profileId = Convert.ToInt32(HttpContext.Current.Profile.GetPropertyValue("ProfileId")); string email = AccountService.GetEmailByProfileId(profileId); if (email.ToLower() == "*****@*****.**") { ltlSignature.Text = "<img src=\"/img/flory-sig.jpg\" alt=\"flory\" width=\"50\" />"; } }
protected void lbSaveBrandCategory_Click(object sender, EventArgs e) { string urlKey = txtUrlKey.Text.Trim(); txtUrlKey.BackColor = Color.Empty; // If url key is empty, regenerate with given category name if (urlKey == string.Empty) { urlKey = AdminStoreUtility.GetFriendlyUrlKey(txtName.Text.Trim()); txtUrlKey.Text = urlKey; } // Make sure url key is unique if (((GetStringState(MODE) == NEW) && (BrandService.GetBrandCategoryByUrlKey(urlKey) != null)) || ((GetStringState(MODE) == EDIT) && (BrandService.GetBrandCategoryByUrlKey(urlKey) != null) && (BrandService.GetBrandCategoryByUrlKey(urlKey).Id != GetIntState(BRAND_CATEGORY_ID)))) { enbNotice.Message = "Url key is not unique."; } else { string thumbnailFilename = string.Empty; if (fuThumbnail.HasFile) { thumbnailFilename = txtUrlKey.Text.Trim() + Path.GetExtension(fuThumbnail.FileName).ToLower(); fuThumbnail.SaveAs(MediaSettings.BrandMediaLocalPath + thumbnailFilename); } else { if (!cbRemoveThumb.Checked) { BrandCategory category = BrandService.GetBrandCategoryByUrlKey(urlKey); if (category != null) { thumbnailFilename = category.ImageUrl; } } } BrandCategory brandCategory = new BrandCategory(); brandCategory.Name = Server.HtmlEncode(txtName.Text.Trim()); brandCategory.BrandId = QueryBrandId; brandCategory.Description = Server.HtmlEncode(txtDesc.Text.Trim()); brandCategory.ImageUrl = thumbnailFilename; brandCategory.UrlRewrite = txtUrlKey.Text.Trim(); brandCategory.Visible = cbVisible.Checked; if (!string.IsNullOrEmpty(hfParent.Value)) { brandCategory.ParentId = Convert.ToInt32(hfParent.Value); } if (GetStringState(MODE) == NEW) { if (string.IsNullOrEmpty(hfParent.Value)) { brandCategory.ParentId = AppConstant.DEFAULT_BRAND_CATEGORY; } brandCategory.Id = BrandService.InsertBrandCategory(brandCategory); } else // Edit mode { brandCategory.Id = GetIntState(LAST_CHOSEN_BRAND_CATEGORY); BrandService.UpdateBrandCategory(brandCategory); } ectBrandCategory.Repopulate(); var treeList = BrandService.GetBrandCategoryTreeList(brandCategory.Id); ectBrandCategory.FindSelectedNode(AppConstant.DEFAULT_BRAND_CATEGORY, treeList); PopulateBrandCategoryInfo(brandCategory.Id); enbNotice.Message = "Brand category was saved successfully."; } cbRemoveThumb.Checked = false; ChosenProducts.Clear(); NotChosenProducts.Clear(); LoadProducts(); }
protected void LoadOrderReport() { gvOrdersByHour.Visible = false; gvOrdersByDay.Visible = false; gvOrdersByWeek.Visible = false; gvOrdersByMonth.Visible = false; gvOrdersByQuarter.Visible = false; gvOrdersByYear.Visible = false; string sorting = ddlShowBy.SelectedValue; // Calculate days DateTime dtFrom; DateTime dtTo; if (txtDateFrom.Text.Trim().Length != 0 && txtDateTo.Text.Trim().Length != 0) { dtFrom = DateTime.ParseExact(txtDateFrom.Text, AppConstant.DATE_FORM1, CultureInfo.InvariantCulture); dtTo = DateTime.ParseExact(txtDateTo.Text, AppConstant.DATE_FORM1, CultureInfo.InvariantCulture); } else { txtDateTo.Text = DateTime.Today.ToString(AppConstant.DATE_FORM1); txtDateFrom.Text = DateTime.Today.AddDays(-6).ToString(AppConstant.DATE_FORM1); dtFrom = DateTime.ParseExact(txtDateFrom.Text, AppConstant.DATE_FORM1, CultureInfo.InvariantCulture); dtTo = DateTime.ParseExact(txtDateTo.Text, AppConstant.DATE_FORM1, CultureInfo.InvariantCulture); } DataTable dt; int beginMonth; int endMonth; int pointerMonth; int pointerYear; int beginWeek; int endWeek; int beginYear; int endYear; int pointerWeek; TimeSpan span; int totalDays; switch (sorting) { case "hour": dt = new DataTable(); dt.Columns.Add("Hour"); dt.Columns.Add("Day"); dt.Columns.Add("Month"); dt.Columns.Add("Year"); span = dtTo - dtFrom; totalDays = span.Days; for (int i = totalDays; i >= 0; i--) { for (int j = 0; j < 24; j++) { DataRow dr = dt.NewRow(); dr["Hour"] = j; DateTime temp = dtFrom.AddDays((double)(i)); dr["Day"] = temp.Day; dr["Month"] = temp.Month; dr["Year"] = temp.Year; dt.Rows.Add(dr); } } gvOrdersByHour.Visible = true; gvOrdersByHour.DataSource = dt; gvOrdersByHour.DataBind(); break; case "day": List <DateTime> dates = new List <DateTime>(); span = dtTo - dtFrom; totalDays = span.Days; for (int i = totalDays; i >= 0; i--) { dates.Add(dtFrom.AddDays((double)(i))); } gvOrdersByDay.Visible = true; gvOrdersByDay.DataSource = dates; gvOrdersByDay.DataBind(); break; case "week": CultureInfo culture = CultureInfo.CurrentCulture; dt = new DataTable(); dt.Columns.Add("Week"); dt.Columns.Add("Year"); beginWeek = culture.Calendar.GetWeekOfYear(dtFrom, CalendarWeekRule.FirstDay, DayOfWeek.Monday); endWeek = culture.Calendar.GetWeekOfYear(dtTo, CalendarWeekRule.FirstDay, DayOfWeek.Monday); beginMonth = dtFrom.Month; endMonth = dtTo.Month; beginYear = dtFrom.Year; endYear = dtTo.Year; pointerWeek = beginWeek; pointerMonth = beginMonth; pointerYear = dtFrom.Year; int endWeekTemp = endYear > beginYear ? 52 : endWeek; for (int i = pointerYear; i <= endYear; i++) { for (int j = pointerWeek; j <= endWeekTemp; j++) { DataRow dr = dt.NewRow(); dr["Week"] = j; dr["Year"] = i; dt.Rows.Add(dr); } endWeekTemp = (i + 1) < endYear ? 52 : endWeek; pointerWeek = 1; } gvOrdersByWeek.Visible = true; gvOrdersByWeek.RowDataBound += new GridViewRowEventHandler(gvOrdersByWeek_RowDataBound); gvOrdersByWeek.DataSource = dt; gvOrdersByWeek.DataBind(); break; case "month": dt = new DataTable(); dt.Columns.Add("Month"); dt.Columns.Add("Year"); beginMonth = dtFrom.Month; endMonth = dtTo.Month; endYear = dtTo.Year; pointerMonth = beginMonth; pointerYear = dtFrom.Year; while (pointerYear <= endYear) { if (pointerMonth <= 12) { DataRow dr = dt.NewRow(); dr["Month"] = pointerMonth; dr["Year"] = pointerYear; dt.Rows.Add(dr); pointerMonth++; } else { pointerYear++; pointerMonth = 1; } if (pointerMonth > endMonth && pointerYear == endYear) { break; } } gvOrdersByMonth.Visible = true; gvOrdersByMonth.DataSource = dt; gvOrdersByMonth.DataBind(); break; case "quarter": dt = new DataTable(); dt.Columns.Add("Quarter"); dt.Columns.Add("Year"); int beginQuarter = AdminStoreUtility.GetQuarter(dtFrom); int endQuarter = AdminStoreUtility.GetQuarter(dtTo); endYear = dtTo.Year; int pointerQuarter = beginQuarter; pointerYear = dtFrom.Year; while (pointerYear <= endYear) { if (pointerQuarter <= 4) { DataRow dr = dt.NewRow(); dr["Quarter"] = pointerQuarter; dr["Year"] = pointerYear; dt.Rows.Add(dr); pointerQuarter++; } else { pointerYear++; pointerQuarter = 1; } if (pointerQuarter > endQuarter && pointerYear == endYear) { break; } } gvOrdersByQuarter.Visible = true; gvOrdersByQuarter.DataSource = dt; gvOrdersByQuarter.DataBind(); break; case "year": dt = new DataTable(); dt.Columns.Add("Year"); beginYear = dtFrom.Year; endYear = dtTo.Year; pointerYear = beginYear; while (pointerYear <= endYear) { DataRow dr = dt.NewRow(); dr["Year"] = pointerYear; dt.Rows.Add(dr); pointerYear++; if (pointerYear > endYear) { break; } } gvOrdersByYear.Visible = true; gvOrdersByYear.DataSource = dt; gvOrdersByYear.DataBind(); break; } }
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; } }