public static string getOrderStateByLang(OrderStates s) { if (CultureInfo.CurrentCulture.CompareInfo.Name == "ar-SA") { switch (s) { case OrderStates.pending: return("معلق"); case OrderStates.paid: return("مدفوع"); case OrderStates.pendingShipping: return("بانتظار الشحن"); case OrderStates.shipped: return("مشحون"); case OrderStates.complete: return("مكتمل"); case OrderStates.canceled: return("ملغي"); default: return(""); } } else { return(s.ToString()); } }
/// <summary> /// Upon clicking the submit button, the order state gets updated /// If there is a single item that is not in stock OR there is less than 1 item, then the order gets automatically rejected /// If all items are in stock the order becomes "Pending" and then (after clicking the button again) gets submitted /// </summary> private void Btn_Submit_Click(object sender, RoutedEventArgs e) { OrderStates comparison = (OrderStates)currentOrderHeader.State; //check whether there is a single item that is not in stock bool allItemsAreInStock = true; for (int i = 0; i < currentOrders.Count; i++) { switch (currentOrders[i].Description) { case "Not_in_stock": allItemsAreInStock = false; break; } } //if there is a single item that is not in stock OR there is less than 1 item, then the order gets automatically rejected if ((allItemsAreInStock == false || currentOrders.Count < 1) && comparison.ToString() != "New") { currentOrderHeader.State = (int)Enum.Parse(typeof(OrderStates), "Rejected"); } else { switch (comparison.ToString()) { case "New": case "Rejected": currentOrderHeader.State = (int)Enum.Parse(typeof(OrderStates), "Pending"); break; default: currentOrderHeader.State = (int)Enum.Parse(typeof(OrderStates), "Complete"); break; } } //submitting the state after it has been determined. layer.SubmitOrder(currentOrderHeader.Id, currentOrderHeader.State); UpdateInfo(); }