示例#1
0
        public async Task <IActionResult> Create([Bind("MaterialId,Code,Name")] Material source)
        {
            if (ModelState.IsValid)
            {
                context.Add(source);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(source));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("UnitId,Description")] Unit source)
        {
            if (ModelState.IsValid)
            {
                context.Add(source);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(source));
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("RecordId,ComponentId,Income,Expense")] IncomeExpenseBook source)
        {
            if (ModelState.IsValid)
            {
                context.Add(source);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            //ViewData["ComponentId"] = new SelectList(context.Components.Include(c => c.Detail).Include(c => c.Material), "ComponentId", "Material.Name", source.RecordId);
            ViewData["ComponentId"] = new SelectList(context.Components, "ComponentId", "ComponentId", source.RecordId);
            return(View(source));
        }
示例#4
0
        public async Task <IActionResult> Create([Bind("ComponentId,DetailId,MaterialId,UnitId")] Component source)
        {
            if (ModelState.IsValid)
            {
                context.Add(source);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            ViewData["DetailId"]   = new SelectList(context.Details, "DetailId", "Code", source.DetailId);
            ViewData["MaterialId"] = new SelectList(context.Materials, "MaterialId", "Name", source.MaterialId);
            ViewData["UnitId"]     = new SelectList(context.Units, "UnitId", "Description", source.UnitId);
            return(View(source));
        }