コード例 #1
0
        public ActionResult Create(int?Id, string pageToken = null)
        {
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }

            if (Id == null)
            {
                int id             = 0;
                var accountaddress = _accountServices.GetAllValidAccountContactsByAccountId(id, CurrentTenantId);
                ViewBag.AccountContactes = new SelectList(accountaddress, "AccountContactId", "ContactEmail", accountaddress.Select(x => x.AccountID).FirstOrDefault());
                var directsales = _salesServices.GetDirectSaleOrders(null);
                ViewBag.DirectOrderList = new SelectList(directsales, "OrderID", "OrderNumber");
                Order NewOrder = new Order();
                NewOrder.OrderNumber = GeneratePO((int)InventoryTransactionTypeEnum.PurchaseOrder);
                NewOrder.IssueDate   = DateTime.Today;
                SetViewBagItems(null, EnumAccountType.Supplier);
                ViewBag.OrderDetails   = new List <OrderDetail>();
                ViewBag.OrderProcesses = new List <OrderProcess>();
                //ViewBag.IsCollectionFromCustomerSide = true;
                ViewBag.AllowAccountAddress = caCurrent.CurrentWarehouse().AllowShipToAccountAddress;
                if (string.IsNullOrEmpty(pageToken))
                {
                    ViewBag.ForceRegeneratePageToken  = "True";
                    ViewBag.ForceRegeneratedPageToken = Guid.NewGuid().ToString();
                }
                NewOrder.InventoryTransactionTypeId = (int)InventoryTransactionTypeEnum.PurchaseOrder;
                GaneOrderDetailsSessionHelper.SetOrderDetailSessions(ViewBag.ForceRegeneratedPageToken, new List <OrderDetailSessionViewModel>());
                GaneOrderNotesSessionHelper.SetOrderNotesSessions(ViewBag.ForceRegeneratedPageToken, new List <OrderNotes>());
                return(View(NewOrder));
            }

            return(View());
        }