Beispiel #1
0
        public ActionResult UpdateInline(OrderTypeModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    bool validate = true;
                    if (model.DateFrom > model.DateTo)
                    {
                        validate = false;
                        ViewData["EditError"] = "From Date cannot be less than To Date.";
                    }

                    model.CompanyId = AuthenticationHelper.CompanyId.Value;

                    if (validate)
                    {
                        OrderTypeHelper.Save(model);
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("_List", OrderTypeHelper.GetOrderTypes()));
        }
Beispiel #2
0
        private TransactionError CanBeCanceled(Transaction tran)
        {
            if (tran == null)
            {
                return(TransactionError.TransactionNotExists);
            }
            if (!tran.CancelService.CanCancel)
            {
                return(TransactionError.TransactionCannotBeCanceled);
            }
            var baseTime = MarketManager.Now;

            if (!tran.PlacedByRiskMonitor)
            {
                if (!tran.SettingInstrument.CanPlace(baseTime, OrderTypeHelper.IsPendingType(tran.OrderType)))
                {
                    return(TransactionError.PriceIsDisabled);
                }
                if (!tran.CancelService.CanBeCanceledByCustomer())
                {
                    return(TransactionError.TransactionCannotBeCanceled);
                }
                if (!tran.CancelService.ShouldAutoCancel())
                {
                    return(TransactionError.Action_NeedDealerConfirmCanceling);
                }
            }
            return(TransactionError.OK);
        }
        public ActionResult Create()
        {
            OrderModel order = SessionHelper.Order;

            if (order == null)
            {
                order = new OrderModel
                {
                    CompanyId   = AuthenticationHelper.CompanyId.Value,
                    OrderDate   = DateTime.Now,
                    OrderDetail = new List <OrderDetailModel>(),
                    OrderNo     = "New",
                    Status      = "Booked"
                };
                SessionHelper.Order = order;
            }

            order.Customers = CustomerHelper.GetActiveCustomersCombo(order.OrderDate);
            if (order.Customers != null && order.Customers.Count() > 0)
            {
                order.CustomerId    = order.CustomerId > 0 ? order.CustomerId : Convert.ToInt64(order.Customers.FirstOrDefault().Value);
                order.CustomerSites = CustomerHelper.GetCustomerSitesCombo(order.CustomerId);
            }

            order.OrderTypes = OrderTypeHelper.GetOrderTypesCombo(order.OrderDate);
            if (order.OrderTypes != null && order.OrderTypes.Count() > 0)
            {
                order.OrderTypeId = order.OrderTypeId > 0 ? order.OrderTypeId : Convert.ToInt64(order.OrderTypes.FirstOrDefault().Value);
            }

            return(View("Edit", order));
        }
Beispiel #4
0
        public ActionResult DeleteInline(OrderTypeModel model)
        {
            try
            {
                model.CompanyId = AuthenticationHelper.CompanyId.Value;
                OrderTypeHelper.Delete(model.Id.ToString());
                return(PartialView("_List", OrderTypeHelper.GetOrderTypes()));
            }
            catch (Exception e)
            {
                ViewData["EditError"] = e.Message;
            }

            return(PartialView("_List", OrderTypeHelper.GetOrderTypes()));
        }
        public ActionResult Edit(string id)
        {
            OrderModel order = OrderHelper.GetOrder(id);

            order.OrderDetail   = OrderHelper.GetOrderDetail(id);
            SessionHelper.Order = order;

            order.Customers = CustomerHelper.GetCustomersCombo(order.OrderDate, order.OrderDate);
            if (order.Customers != null && order.Customers.Count() > 0)
            {
                order.CustomerSites = CustomerHelper.GetCustomerSitesCombo(order.CustomerId);
            }

            order.OrderTypes = OrderTypeHelper.GetOrderTypesCombo(order.OrderDate);
            if (order.OrderTypes != null && order.OrderTypes.Count() > 0)
            {
                order.OrderTypeId = order.OrderTypeId > 0 ? order.OrderTypeId : Convert.ToInt64(order.OrderTypes.FirstOrDefault().Value);
            }

            return(View("Edit", order));
        }
        public ActionResult ChangeCombos(DateTime orderDate)
        {
            if (orderDate < DateTime.Now.Date)
            {
                return(Json("Order date cannot be the past date!."));
            }

            OrderModel order = new OrderModel();

            order.Customers = CustomerHelper.GetActiveCustomersCombo(orderDate);
            if (order.Customers != null && order.Customers.Count() > 0)
            {
                order.CustomerId    = order.CustomerId > 0 ? order.CustomerId : Convert.ToInt64(order.Customers.FirstOrDefault().Value);
                order.CustomerSites = CustomerHelper.GetCustomerSitesCombo(order.CustomerId);
            }

            order.OrderTypes = OrderTypeHelper.GetOrderTypesCombo(orderDate);
            if (order.OrderTypes != null && order.OrderTypes.Count() > 0)
            {
                order.OrderTypeId = order.OrderTypeId > 0 ? order.OrderTypeId : Convert.ToInt64(order.OrderTypes.FirstOrDefault().Value);
            }

            return(Json(order));
        }
Beispiel #7
0
        public ActionResult CreatePartial()
        {
            IEnumerable <OrderTypeModel> model = OrderTypeHelper.GetOrderTypes();

            return(PartialView("_List", model));
        }