Example #1
0
        public async Task <IActionResult> Create([Bind("ItemName,ItemValue,ItemNote")] ItemModel itemModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(itemModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(itemModel));
        }
Example #2
0
        public async Task <IActionResult> Edit(int id, [Bind("BorrowOrderID,TranName,AccountName,StartTime,TranTime,FinishTime,IsCanceled,IsCompleted,IsTraned,OrderMoney,BorrowNote,ItemNum1,ItemNum2,ItemNum3,ItemNum4,ItemNum5,ItemNum6,ItemNum7,ItemNum8,ItemNum9,ItemNum10,ItemNum11,ItemNum12,ItemNum13,ItemNum14,ItemNum15,ItemNum16,ItemNum17,ItemNum18,ItemNum19,ItemNum20,ItemNum21,ItemNum22,ItemNum23,ItemNum24,ItemNum25,ItemNum26,ItemNum27,ItemNum28,ItemNum29,ItemNum30,ItemNum31,ItemNum32,ItemNum33,ItemNum34,ItemNum35,ItemNum36,ItemNum37,ItemNum38,ItemNum39,ItemNum40")] BorrowModel borrowModel)
        {
            if (id != borrowModel.BorrowOrderID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(borrowModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BorrowModelExists(borrowModel.BorrowOrderID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("OrderPool", "Home"));
            }
            ViewData["AccountName"] = new SelectList(_context.AccountModels.Where(x => x.Type == Models.EnumClass.EnumAccountType.配送专员), "AccountName", "AccountName", borrowModel.AccountName);
            return(View(borrowModel));
        }
        public async Task <IActionResult> Create([Bind("DiscountID,DiscountValue,AccountName,DiscountNote")] DiscountModel discountModel)
        {
            if (ModelState.IsValid)
            {
                if (await _context.DiscountModels.AnyAsync(x => x.AccountName == discountModel.AccountName))
                {
                    ModelState.AddModelError("AccountName", "该用户已经填写过折扣");
                }
                else
                {
                    _context.Add(discountModel);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            ViewData["AccountName"] = new SelectList(_context.AccountModels.Where(x => x.Type == Models.EnumClass.EnumAccountType.客户), "AccountName", "AccountName", discountModel.AccountName);
            return(View(discountModel));
        }