Example #1
0
        public override void DataBind()
        {
            OrderGroup paymentPlanById;

            if (base.Request.QueryString["_v"].Equals("PaymentPlan-ObjectView"))
            {
                paymentPlanById = OrderHelper.GetPaymentPlanById(PrincipalInfo.CurrentPrincipal.GetContactId(), this.OrderGroupId);
            }
            else
            {
                paymentPlanById = OrderHelper.GetPurchaseOrderById(this.OrderGroupId);
            }
            OrderGroup             orderGroup             = paymentPlanById;
            Shipment               dataItem               = null;
            ObjectRepeaterDataItem objectRepeaterDataItem = this.DataItem as ObjectRepeaterDataItem;

            if (objectRepeaterDataItem != null && objectRepeaterDataItem.DataItem != null)
            {
                dataItem         = (Shipment)objectRepeaterDataItem.DataItem;
                this._shipmentId = dataItem.Id;
                this.btnShipmentStatus.ContainerId = dataItem.Id.ToString();
                this.btnShipmentStatus.DataBind();
                this.ReturnExchangeButtonsHolder.ContainerId = dataItem.Id.ToString();
                this.ReturnExchangeButtonsHolder.DataBind();
                this.CompletePickupButton.ContainerId = dataItem.Id.ToString();
                this.CompletePickupButton.DataBind();
            }
            if (dataItem != null)
            {
                OrderShipmentStatus orderShipmentStatus = OrderStatusManager.GetOrderShipmentStatus(dataItem);
                this.lblShipStatus.Text = (string)base.GetGlobalResourceObject("OrderStrings", string.Concat(typeof(OrderShipmentStatus).Name, "_", orderShipmentStatus.ToString()));
                Currency currency = new Currency(orderGroup.BillingCurrency);
                decimal  num      = ((IEnumerable <ILineItem>)dataItem.LineItems.ToArray <ILineItem>()).Sum <ILineItem>((ILineItem x) => x.TryGetDiscountValue((ILineItemDiscountAmount y) => y.OrderAmount));
                Label    str      = this.lblItemsSubTotal;
                Money    money    = new Money(dataItem.SubTotal + num, currency);
                //str.Text = money.ToString();
                Label label = this.lblOrderLevelDiscount;
                money = new Money(num, currency);
                //label.Text = money.ToString();
                Label str1 = this.lblOrderSubTotal;
                money = new Money(dataItem.SubTotal, currency);
                //str1.Text = money.ToString();
                Label label1 = this.lblShippingCost;
                money       = new Money(dataItem.ShippingSubTotal, currency);
                label1.Text = money.ToString();
                Label str2 = this.lblShippingDiscount;
                money     = new Money(dataItem.ShippingDiscountAmount, currency);
                str2.Text = money.ToString();
                Label label2 = this.lblShippingTax;
                money       = new Money(dataItem.ShippingTax, currency);
                label2.Text = money.ToString();
                Label str3 = this.lblShipTotal;
                money     = new Money(((dataItem.SubTotal + dataItem.ShippingSubTotal) + dataItem.ShippingTax) - dataItem.ShippingDiscountAmount, currency);
                str3.Text = money.ToString();
            }
        }
Example #2
0
        protected static OrderShipmentStatus GetShipmentStatus(Shipment shipment)
        {
            OrderShipmentStatus retVal = OrderShipmentStatus.InventoryAssigned;

            if (!string.IsNullOrEmpty(shipment.Status))
            {
                retVal = (OrderShipmentStatus)Enum.Parse(typeof(OrderShipmentStatus), shipment.Status);
            }
            return(retVal);
        }
        private OrderStatus CalculateOrderGroupStatus()
        {
            OrderStatus retVal    = base.OrderStatus;
            var         shipments = base.OrderGroup.OrderForms[0].Shipments.ToArray();
            //var purchaseOrder = base.OrderGroup as Mediachase.Commerce.Orders.PurchaseOrder;

            OrderShipmentStatus avtiveStates = OrderShipmentStatus.InventoryAssigned | OrderShipmentStatus.AwaitingInventory
                                               | OrderShipmentStatus.Released | OrderShipmentStatus.Packing;

            bool canceledFound  = shipments.Any(x => GetShipmentStatus(x) == OrderShipmentStatus.Cancelled);
            bool completedFound = shipments.Any(x => GetShipmentStatus(x) == OrderShipmentStatus.Shipped);
            bool activeFound    = shipments.Any(x => (GetShipmentStatus(x) & avtiveStates) == GetShipmentStatus(x));

            if (!canceledFound && !completedFound && !activeFound)
            {
                //Not found canceled,active,completed
            }
            else if (canceledFound && !completedFound && !activeFound)
            {
                //All canceled
                //retVal = OrderStatus.Cancelled;
            }
            else if (!canceledFound && completedFound && !activeFound)
            {
                //All completed
                retVal = OrderStatus.Completed;
            }
            else if (!canceledFound && !completedFound && activeFound)
            {
                //All active
            }
            else if (canceledFound && completedFound && !activeFound)
            {
                //Found  cancelled and completed
                retVal = OrderStatus.Completed;
            }
            else if (canceledFound && !completedFound && activeFound)
            {
                //Found cancelled and active
            }
            else if (!canceledFound && completedFound && activeFound)
            {
                //Found completted and active
                retVal = OrderStatus.PartiallyShipped;
            }
            else if (canceledFound && completedFound && activeFound)
            {
                //Found cancelled and active and completed
                retVal = OrderStatus.PartiallyShipped;
            }



            return(retVal);
        }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the OrderFilter class.
 /// </summary>
 public OrderFilter()
 {
     _OrderDateStart   = DateTime.MinValue;
     _OrderDateEnd     = DateTime.MaxValue;
     _OrderIdRange     = string.Empty;
     _OrderNumberRange = string.Empty;
     _PaymentStatus    = OrderPaymentStatus.Unspecified;
     _ShipmentStatus   = OrderShipmentStatus.Unspecified;
     _OrderStatus      = new IdList();
     _Keyword          = string.Empty;
     _KeywordField     = KeywordFieldType.All;
 }
Example #5
0
        /// <summary>
        /// Helper to convert enum to a valid string sent/received in from the API
        /// <returns>String</returns>
        /// </summary>
        public static String OrderShipmentStatusToString(OrderShipmentStatus value)
        {
            switch (value)
            {
            case OrderShipmentStatus.Pending: return("0");

            case OrderShipmentStatus.Picking: return("100");

            case OrderShipmentStatus.Shipped: return("200");
            }
            return("");
        }
Example #6
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public OrderSearchCriteria()
 {
     _OrderDateStart   = DateTime.MinValue;
     _OrderDateEnd     = DateTime.MaxValue;
     _OrderIdRange     = string.Empty;
     _OrderIdStart     = 0;
     _OrderIdEnd       = 0;
     _OrderNumberRange = string.Empty;
     _OrderNumberStart = 0;
     _OrderNumberEnd   = 0;
     _PaymentStatus    = OrderPaymentStatus.Unspecified;
     _ShipmentStatus   = OrderShipmentStatus.Unspecified;
     _OrderStatus      = new IdList();
     _Filter           = new Collection <MatchCriteria>();
 }
Example #7
0
        internal static void UpdateShipmentStatus(Order order, OrderShipmentStatus ShipmentStatus)
        {
            bool saveDirty = order.IsDirty;

            order.ShipmentStatus = ShipmentStatus;
            string   updateQuery = "UPDATE ac_Orders SET ShipmentStatusId = @ShipmentStatus WHERE OrderId = @orderId";
            Database database    = Token.Instance.Database;

            using (System.Data.Common.DbCommand updateCommand = database.GetSqlStringCommand(updateQuery))
            {
                database.AddInParameter(updateCommand, "@ShipmentStatus", System.Data.DbType.Byte, (byte)ShipmentStatus);
                database.AddInParameter(updateCommand, "@orderId", System.Data.DbType.Int32, order.OrderId);
                if (database.ExecuteNonQuery(updateCommand) > 0)
                {
                    order.IsDirty = saveDirty;
                }
            }
        }
Example #8
0
        /// <summary>
        /// Counts the number of orders for given search criteria
        /// </summary>
        /// <param name="orderStatusId">order status Id of the orders to search</param>
        /// <param name="paymentStatus">payment status of the orders to search</param>
        /// <param name="shipmentStatus">shipment status of the orders to search</param>
        /// <param name="startDate">starting date for search</param>
        /// <param name="endDate">ending date for search</param>
        /// <returns>The number of orders for given search criteria</returns>
        public static int SearchCount(int orderStatusId, OrderPaymentStatus paymentStatus, OrderShipmentStatus shipmentStatus, DateTime startDate, DateTime endDate)
        {
            //COUNT ORDER IDS THAT FIT THE CRITERIA
            StringBuilder countQuery = new StringBuilder();

            countQuery.Append("SELECT COUNT(*) AS SearchCount");
            countQuery.Append(" FROM ac_Orders");
            countQuery.Append(" WHERE StoreId = @storeId");
            if (orderStatusId != 0)
            {
                countQuery.Append(" AND OrderStatusId = @orderStatusId");
            }
            if (paymentStatus != OrderPaymentStatus.Unspecified)
            {
                countQuery.Append(" AND PaymentStatusId = @paymentStatusId");
            }
            if (shipmentStatus != OrderShipmentStatus.Unspecified)
            {
                countQuery.Append(" AND ShipmentStatusId = @shipmentStatusId");
            }
            if (startDate > DateTime.MinValue)
            {
                countQuery.Append(" AND OrderDate >= @startDate");
            }
            if (endDate > DateTime.MinValue)
            {
                countQuery.Append(" AND OrderDate <= @endDate");
            }
            Database  database     = Token.Instance.Database;
            DbCommand countCommand = database.GetSqlStringCommand(countQuery.ToString());

            database.AddInParameter(countCommand, "@storeId", System.Data.DbType.Int32, Token.Instance.StoreId);
            if (orderStatusId != 0)
            {
                database.AddInParameter(countCommand, "@orderStatusId", System.Data.DbType.Int32, orderStatusId);
            }
            if (startDate > DateTime.MinValue)
            {
                database.AddInParameter(countCommand, "@startDate", System.Data.DbType.DateTime, startDate);
            }
            if (endDate > DateTime.MinValue)
            {
                database.AddInParameter(countCommand, "@endDate", System.Data.DbType.DateTime, endDate);
            }
            if (paymentStatus != OrderPaymentStatus.Unspecified)
            {
                database.AddInParameter(countCommand, "@paymentStatus", System.Data.DbType.Byte, paymentStatus);
            }
            if (shipmentStatus != OrderShipmentStatus.Unspecified)
            {
                database.AddInParameter(countCommand, "@shipmentStatus", System.Data.DbType.Byte, shipmentStatus);
            }
            return(AlwaysConvert.ToInt(database.ExecuteScalar(countCommand)));
        }
Example #9
0
        public static OrderCollection Search(int orderStatusId, OrderPaymentStatus paymentStatus, OrderShipmentStatus shipmentStatus, DateTime startDate, DateTime endDate, int maximumRows, int startRowIndex, string sortExpression)
        {
            //SET DEFAULT SORT
            if (string.IsNullOrEmpty(sortExpression))
            {
                sortExpression = "OrderDate DESC";
            }
            //CREATE THE DYNAMIC SQL TO LOAD OBJECT
            StringBuilder selectQuery = new StringBuilder();

            selectQuery.Append("SELECT");
            if (maximumRows > 0)
            {
                selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString());
            }
            selectQuery.Append(" " + Order.GetColumnNames(string.Empty));
            selectQuery.Append(" FROM ac_Orders");
            selectQuery.Append(" WHERE StoreId = @storeId");
            if (orderStatusId != 0)
            {
                selectQuery.Append(" AND OrderStatusId = @orderStatusId");
            }
            if (paymentStatus != OrderPaymentStatus.Unspecified)
            {
                selectQuery.Append(" AND PaymentStatusId = @paymentStatus");
            }
            if (shipmentStatus != OrderShipmentStatus.Unspecified)
            {
                selectQuery.Append(" AND ShipmentStatusId = @shipmentStatus");
            }
            if (startDate > DateTime.MinValue)
            {
                selectQuery.Append(" AND OrderDate >= @startDate");
            }
            if (endDate > DateTime.MinValue)
            {
                selectQuery.Append(" AND OrderDate <= @endDate");
            }
            selectQuery.Append(" ORDER BY " + sortExpression);
            //BUILD THE COMMAND
            Database  database      = Token.Instance.Database;
            DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString());

            database.AddInParameter(selectCommand, "@storeId", System.Data.DbType.Int32, Token.Instance.StoreId);
            if (orderStatusId != 0)
            {
                database.AddInParameter(selectCommand, "@orderStatusId", System.Data.DbType.Int32, orderStatusId);
            }
            if (startDate > DateTime.MinValue)
            {
                database.AddInParameter(selectCommand, "@startDate", System.Data.DbType.DateTime, startDate);
            }
            if (endDate > DateTime.MinValue)
            {
                database.AddInParameter(selectCommand, "@endDate", System.Data.DbType.DateTime, endDate);
            }
            if (paymentStatus != OrderPaymentStatus.Unspecified)
            {
                database.AddInParameter(selectCommand, "@paymentStatus", System.Data.DbType.Byte, paymentStatus);
            }
            if (shipmentStatus != OrderShipmentStatus.Unspecified)
            {
                database.AddInParameter(selectCommand, "@shipmentStatus", System.Data.DbType.Byte, shipmentStatus);
            }
            //EXECUTE THE COMMAND
            OrderCollection results   = new OrderCollection();
            int             thisIndex = 0;
            int             rowCount  = 0;

            using (IDataReader dr = database.ExecuteReader(selectCommand))
            {
                while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows)))
                {
                    if (thisIndex >= startRowIndex)
                    {
                        Order order = new Order();
                        Order.LoadDataReader(order, dr);
                        results.Add(order);
                        rowCount++;
                    }
                    thisIndex++;
                }
                dr.Close();
            }
            return(results);
        }
Example #10
0
 public static OrderCollection Search(int orderStatusId, OrderPaymentStatus paymentStatus, OrderShipmentStatus shipmentStatus, DateTime startDate, DateTime endDate, string sortExpression)
 {
     return(OrderDataSource.Search(orderStatusId, paymentStatus, shipmentStatus, startDate, endDate, 0, 0, sortExpression));
 }