public async Task <IActionResult> Create([Bind("Voucherno,InputDate,StudentId,Headname,Amount")] Fee fee) { try { if (ModelState.IsValid) { _context.Add(fee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["StudentId"] = new SelectList(_context.Student, "Id", "Id", fee.StudentId); return(View(fee)); } catch (DbUpdateException dbx) { ViewData["err"] = "Inserted Voucher No. is already exists"; return(View()); } catch (Exception ex) { ViewData["err"] = ex.Message.ToString(); return(View()); } }
public async Task <IActionResult> Create([Bind("Itemcode,Itemname,Picture")] Items items) { try { if (ModelState.IsValid) { _context.Add(items); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(items)); } catch (DbUpdateException dbx) { ViewData["err"] = "Inserted Item Code No. Is Already Exists"; return(View()); } catch (Exception ex) { ViewData["err"] = ex.Message.ToString(); return(View()); } }
public async Task <IActionResult> Create([Bind("Examsl,Studentid,Examname,Institution,Board,Result")] Examresult examresult) { try { if (ModelState.IsValid) { _context.Add(examresult); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Studentid"] = new SelectList(_context.Student, "Id", "Id", examresult.Studentid); return(View(examresult)); } catch (DbUpdateException dbx) { ViewData["err"] = "Inserted Exam Serial No. is already exists"; return(View()); } catch (Exception ex) { ViewData["err"] = ex.Message.ToString(); return(View()); } }
public async Task <IActionResult> Create([Bind("Id,Name")] Student student) { if (ModelState.IsValid) { _context.Add(student); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(student)); }
public async Task <IActionResult> Create([Bind("Id,Name,Fee,Picture")] Student student) { try { if (ModelState.IsValid) { _context.Add(student); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(student)); } catch (DbUpdateException dbx) { ViewData["err"] = "Inserted Student Id is already exists"; return(View()); } catch (Exception ex) { ViewData["err"] = ex.Message.ToString(); return(View()); } }