LAMPIRAN. 1. Source Code Data Buku. using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.

Similar documents
Lampiran. SetoransController

LAMPIRAN. 1. Source Code Data Jamah

MICRO SERVICES ARCHITECTURE

Repository Pattern and Unit of Work with Entity Framework

شروع کار با Entity Framework Core 2.0 ASP.NET Core 2.0

Bringing Together One ASP.NET

Description: This feature will enable user to send messages from website to phone number.

MVC CRUD. Tables: 1) Dinners (First Table)

MVC - Repository-And-Unit-Of-Work

HangFire Documentation

Enterprise Systems & Frameworks

Domain Driven Design, MVC & Entity Framework

CALCULATOR APPLICATION

Cursos técnicos gratuitos en línea

MVC :: Understanding Views, View Data, and HTML Helpers

Set Up a Two Factor Authentication with SMS.


Representing Recursive Relationships Using REP++ TreeView

The contents of this document are directly taken from the EPiServer SDK. Please see the SDK for further technical information about EPiServer.

MVC :: Preventing JavaScript Injection Attacks. What is a JavaScript Injection Attack?

Annex B: Prototype Draft Model Code. April 30 th, 2015 Siamak Khaledi, Ankit Shah, Matthew Shoaf

MVC :: Understanding Controllers, Controller Actions, and Action Results

ASP.NET MVC Music Store Tutorial

Action-packed controllers

CSIS 1624 CLASS TEST 6

Justin Jones 21 st February 2013 Version 1.1 Setting up an MVC4 Multi-Tenant Site

Design and Implementation of Real Time Bi-directional Traffic Management Support System with GPS and WebSocket

MVC :: Understanding Models, Views, and Controllers

Sub To Srt Converter. This is the source code of this program. It is made in C# with.net 2.0.

Main Game Code. //ok honestly im not sure, if i guess its a class ment for this page called methodtimer that //either uses the timer or set to timer..

SportsStore: Administration

COOKBOOK Sending an in Response to Actions

How to create a simple ASP.NET page to create/search data on baan using baan logic from the BOBS client sample.

Adapting a Grid to REP++

IBSDK Quick Start Tutorial for C# 2010

USER GUIDE Conversion and Validation of User Input

IN ACTION. Jeffrey Palermo Jimmy Bogard Eric Hexter Matthew Hinze Jeremy Skinner. Phil Haack. Third edition of ASP.NET MVC in Action FOREWORD BY

emkt Browserless Coding For C#.Net and Excel

Now find the button component in the tool box. [if toolbox isn't present click VIEW on the top and click toolbox]

What property of a C# array indicates its allocated size? What keyword in the base class allows a method to be polymorphic?

Activating AspxCodeGen 4.0

Objectives. Introduce static keyword examine syntax describe common uses

Universitas Sumatera Utara

NerdDinner Step 1: File->New Project

Equality in.net. Gregory Adam 07/12/2008. This article describes how equality works in.net

You can call the project anything you like I will be calling this one project slide show.

Creating SDK plugins

// Specify SEF file to load. oschema = (edischema) oedidoc.loadschema(spath + sseffilename, SchemaTypeIDConstants. Schema_Standard_Exchange_Format);

Reflection in C# Case studies in metaprogramming. torsdag 6 mars 14

if (say==0) { k.commandtext = "Insert into kullanici(k_adi,sifre) values('" + textbox3.text + "','" + textbox4.text + "')"; k.

20 Recipes for Programming MVC 3

KWizCom Corporation. imush. Information Management Utilities for SharePoint. Printing Feature. Application Programming Interface (API)

SMITE API Developer Guide TABLE OF CONTENTS

Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK.

Professional ASP.NET Web Services : Asynchronous Programming

Working with Controllers

Start Visual Studio and create a new windows form application under C# programming language. Call this project YouTube Alarm Clock.

Using Visual Studio 2017

ASP.NET Web API 2 Recipes ASP.NET Web API 2 Recipes will show you how to: SOURCE CODE ONLINE

Mainly three tables namely Teacher, Student and Class for small database of a school. are used. The snapshots of all three tables are shown below.

To start we will be using visual studio Start a new C# windows form application project and name it motivational quotes viewer

API Guide MSS-8 and MVS-16

INTRO TO ASP.NET MVC JAY HARRIS.NET DEVELOPER

C# COMO VOCÊ (TALVEZ) NUNCA VIU

Visual Basic/C# Programming (330)

Integrate WebScheduler to Microsoft SharePoint 2007

FatModel Quick Start Guide

LISTING PROGRAM. //Find the maximum and minimum values in the array int maxvalue = integers[0]; //start with first element int minvalue = integers[0];

The Open Core Interface SDK has to be installed on your development computer. The SDK can be downloaded at:

// Specify SEF file to load. edischema oschema = oedidoc.loadschema(spath + sseffilename, SchemaTypeIDConstants. Schema_Standard_Exchange_Format);

Advance Level Questions. 1) Evaluate the following postfix expression : / / +

RegEx - Numbers matching. Below is a sample code to find the existence of integers within a string.

APÉNDICE J. CÓDIGO DEL ARCHIVO FORM1.CS EN LENGUAJE C# Comprende:

GEARMOTORS AF MOTORS FOR INVERTER C-1

Object oriented lab /second year / review/lecturer: yasmin maki

Getting Started with ExcelMVC

RegEx-validate IP address. Defined below is the pattern for checking an IP address with value: String Pattern Explanation

Writing Your First Autodesk Revit Model Review Plug-In

Module 4 Microsoft Azure Messaging Services

Click on the empty form and apply the following options to the properties Windows.

Developing and deploying MVC4/HTML5 SDK application to IIS DigitalOfficePro Inc.

Web Services in.net (6)

We are going to use some graphics and found a nice little batman running GIF, off course you can use any image you want for the project.

This is the empty form we will be working with in this game. Look under the properties window and find the following and change them.

Tutorial 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and Arithmetic

GSU Alumni Portal. OPUS Open Portal to University Scholarship. Governors State University. Vemuri Vinusha Chowdary Governors State University

Blackbird Books and Supplies

C:\homeworks\PenAttention_v13_src\PenAttention_v13_src\PenAttention4\PenAttention\PenAttention.cs 1 using System; 2 using System.Diagnostics; 3 using

string spath; string sedifile = "277_005010X228.X12"; string sseffile = "277_005010X228.SemRef.EVAL0.SEF";

Your Company Name. Tel: Fax: Microsoft Visual Studio C# Project Source Code Output

Start Visual Studio, create a new project called Helicopter Game and press OK

Pentatonic Labs Final Documentation

Advanced Developer. Kentico 9 Solution Book

GENESIS64 Using IRepository to Access Configuration Databases

First start a new Windows Form Application from C# and name it Interest Calculator. We need 3 text boxes. 4 labels. 1 button

COOKBOOK Creating an Order Form

A Summoner's Tale MonoGame Tutorial Series. Chapter 10. Creating Avatars

Hands-On Lab. Lab: Client Object Model. Lab version: Last updated: 2/23/2011

LAMPIRAN A : LISTING PROGRAM

Visual C# 2012 How to Program by Pe ars on Ed uc ati on, Inc. All Ri ght s Re ser ve d.

Transcription:

81 LAMPIRAN 1. Source Code Data Buku using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Linq; using System.Net; using System.Web; using System.Web.Mvc; using Perpustakaan.Models; namespace Perpustakaan.Controllers public class BukuController : Controller private perpusentities1 db = new perpusentities1(); // GET: Buku public ActionResult Index()

82 var buku = db.buku.include(b => b.buku_bahasa1).include(b => b.buku_kategori1).include(b => b.buku_penerbit1).include(b => b.buku_penulis1).include(b => b.buku_rak1); return View(buku.ToList()); public ActionResult loaddata() using (perpusentities1 dc = new perpusentities1()) // dc.configuration.lazyloadingenabled = false; // if your table is relational, contain foreign key var data = dc.buku.orderby(a => a.buku_judul).tolist(); return Json(new data = data, JsonRequestBehavior.AllowGet); // GET: Buku/Details/5 public ActionResult Details(int? id) if (id == null) return new HttpStatusCodeResult(HttpStatusCode.BadRequest); Buku buku = db.buku.find(id); if (buku == null)

83 return HttpNotFound(); return View(buku); // GET: Buku/Create public ActionResult Create() ViewBag.Buku_Bahasa = new SelectList(db.Buku_Bahasa, "Bahasa_Id", "Bahasa_Nama"); ViewBag.Buku_Kategori = new SelectList(db.Buku_Kategori, "Katrgori_Id", "Kategori_Nama"); ViewBag.Buku_Penerbit = new SelectList(db.Buku_Penerbit, "Penerbit_Id", "Penerbit_Nama"); ViewBag.Buku_Penulis = new SelectList(db.Buku_Penulis, "Penulis_Id", "Penulis_Nama"); ViewBag.Buku_Rak = new SelectList(db.Buku_Rak, "Rak_Id", "Rak_Nama"); return View(); // POST: Buku/Create // To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see http://go.microsoft.com/fwlink/?linkid=317598. [HttpPost] [ValidateAntiForgeryToken]

84 public ActionResult Create([Bind(Include = "Buku_Id,Buku_Bcd,Buku_Judul,Buku_Kategori,Buku_Penulis,Buku_Penerbit,Buku_Ra k,buku_bahasa,buku_jumlah,buku_tahun_terbit")] Buku buku) if (ModelState.IsValid) db.buku.add(buku); db.savechanges(); return RedirectToAction("Index"); ViewBag.Buku_Bahasa = new SelectList(db.Buku_Bahasa, "Bahasa_Id", "Bahasa_Nama", buku.buku_bahasa); ViewBag.Buku_Kategori = new SelectList(db.Buku_Kategori, "Katrgori_Id", "Kategori_Nama", buku.buku_kategori); ViewBag.Buku_Penerbit = new SelectList(db.Buku_Penerbit, "Penerbit_Id", "Penerbit_Nama", buku.buku_penerbit); ViewBag.Buku_Penulis = new SelectList(db.Buku_Penulis, "Penulis_Id", "Penulis_Nama", buku.buku_penulis); ViewBag.Buku_Rak = new SelectList(db.Buku_Rak, "Rak_Id", "Rak_Nama", buku.buku_rak); return View(buku); // GET: Buku/Edit/5 public ActionResult Edit(int? id) if (id == null)

85 return new HttpStatusCodeResult(HttpStatusCode.BadRequest); Buku buku = db.buku.find(id); if (buku == null) return HttpNotFound(); ViewBag.Buku_Bahasa = new SelectList(db.Buku_Bahasa, "Bahasa_Id", "Bahasa_Nama", buku.buku_bahasa); ViewBag.Buku_Kategori = new SelectList(db.Buku_Kategori, "Katrgori_Id", "Kategori_Nama", buku.buku_kategori); ViewBag.Buku_Penerbit = new SelectList(db.Buku_Penerbit, "Penerbit_Id", "Penerbit_Nama", buku.buku_penerbit); ViewBag.Buku_Penulis = new SelectList(db.Buku_Penulis, "Penulis_Id", "Penulis_Nama", buku.buku_penulis); ViewBag.Buku_Rak = new SelectList(db.Buku_Rak, "Rak_Id", "Rak_Nama", buku.buku_rak); return View(buku); // POST: Buku/Edit/5 // To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see http://go.microsoft.com/fwlink/?linkid=317598. [HttpPost] [ValidateAntiForgeryToken]

86 public ActionResult Edit([Bind(Include = "Buku_Id,Buku_Bcd,Buku_Judul,Buku_Kategori,Buku_Penulis,Buku_Penerbit,Buku_Ra k,buku_bahasa,buku_jumlah,buku_tahun_terbit")] Buku buku) if (ModelState.IsValid) db.entry(buku).state = EntityState.Modified; db.savechanges(); return RedirectToAction("Index"); ViewBag.Buku_Bahasa = new SelectList(db.Buku_Bahasa, "Bahasa_Id", "Bahasa_Nama", buku.buku_bahasa); ViewBag.Buku_Kategori = new SelectList(db.Buku_Kategori, "Katrgori_Id", "Kategori_Nama", buku.buku_kategori); ViewBag.Buku_Penerbit = new SelectList(db.Buku_Penerbit, "Penerbit_Id", "Penerbit_Nama", buku.buku_penerbit); ViewBag.Buku_Penulis = new SelectList(db.Buku_Penulis, "Penulis_Id", "Penulis_Nama", buku.buku_penulis); ViewBag.Buku_Rak = new SelectList(db.Buku_Rak, "Rak_Id", "Rak_Nama", buku.buku_rak); return View(buku); // GET: Buku/Delete/5 public ActionResult Delete(int? id) if (id == null)

87 return new HttpStatusCodeResult(HttpStatusCode.BadRequest); Buku buku = db.buku.find(id); if (buku == null) return HttpNotFound(); return View(buku); // POST: Buku/Delete/5 [HttpPost, ActionName("Delete")] [ValidateAntiForgeryToken] public ActionResult DeleteConfirmed(int id) Buku buku = db.buku.find(id); db.buku.remove(buku); db.savechanges(); return RedirectToAction("Index"); protected override void Dispose(bool disposing) if (disposing)

88 db.dispose(); base.dispose(disposing); 2. Source Code Data Anggota using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Linq; using System.Net; using System.Web; using System.Web.Mvc; using Perpustakaan.Models; namespace Perpustakaan.Controllers public class AnggotaController : Controller

89 private perpusentities1 db = new perpusentities1(); // GET: Anggota public ActionResult Index() var anggota = db.anggota.include(a => a.jenis_kelamin); return View(anggota.ToList()); // GET: Anggota/Details/5 public ActionResult Details(int? id) if (id == null) return new HttpStatusCodeResult(HttpStatusCode.BadRequest); Anggota anggota = db.anggota.find(id); if (anggota == null) return HttpNotFound(); return View(anggota);

90 // GET: Anggota/Create public ActionResult Create() ViewBag.Anggota_Jk = new SelectList(db.Jenis_Kelamin, "JK_Id", "JK_Nama"); return View(); // POST: Anggota/Create // To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see http://go.microsoft.com/fwlink/?linkid=317598. [HttpPost] [ValidateAntiForgeryToken] public ActionResult Create([Bind(Include = "Anggota_Id,Anggota_Bcd,Anggota_Nim,Anggota_Nama,Anggota_TTL,Anggota_Tgl,A nggota_jk,anggota_alamat,anggota_email")] Anggota anggota) if (ModelState.IsValid) db.anggota.add(anggota); db.savechanges(); return RedirectToAction("Index");

91 ViewBag.Anggota_Jk = new SelectList(db.Jenis_Kelamin, "JK_Id", "JK_Nama", anggota.anggota_jk); return View(anggota); // GET: Anggota/Edit/5 public ActionResult Edit(int? id) if (id == null) return new HttpStatusCodeResult(HttpStatusCode.BadRequest); Anggota anggota = db.anggota.find(id); if (anggota == null) return HttpNotFound(); ViewBag.Anggota_Jk = new SelectList(db.Jenis_Kelamin, "JK_Id", "JK_Nama", anggota.anggota_jk); return View(anggota); // POST: Anggota/Edit/5

92 // To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see http://go.microsoft.com/fwlink/?linkid=317598. [HttpPost] [ValidateAntiForgeryToken] public ActionResult Edit([Bind(Include = "Anggota_Id,Anggota_Bcd,Anggota_Nim,Anggota_Nama,Anggota_TTL,Anggota_Tgl,A nggota_jk,anggota_alamat,anggota_email")] Anggota anggota) if (ModelState.IsValid) db.entry(anggota).state = EntityState.Modified; db.savechanges(); return RedirectToAction("Index"); ViewBag.Anggota_Jk = new SelectList(db.Jenis_Kelamin, "JK_Id", "JK_Nama", anggota.anggota_jk); return View(anggota); // GET: Anggota/Delete/5 public ActionResult Delete(int? id) if (id == null)

93 return new HttpStatusCodeResult(HttpStatusCode.BadRequest); Anggota anggota = db.anggota.find(id); if (anggota == null) return HttpNotFound(); return View(anggota); // POST: Anggota/Delete/5 [HttpPost, ActionName("Delete")] [ValidateAntiForgeryToken] public ActionResult DeleteConfirmed(int id) Anggota anggota = db.anggota.find(id); db.anggota.remove(anggota); db.savechanges(); return RedirectToAction("Index"); protected override void Dispose(bool disposing)

94 if (disposing) db.dispose(); base.dispose(disposing); 2. Source Code Peminjaman Buku using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Linq; using System.Net; using System.Web; using System.Web.Mvc; using Perpustakaan.Models; namespace Perpustakaan.Controllers

95 public class PeminjamanController : Controller private perpusentities1 db = new perpusentities1(); // GET: Peminjaman public ActionResult Index() var peminjaman = db.peminjaman.include(p => p.anggota).include(p => p.batas_hari).include(p => p.denda); return View(peminjaman.ToList()); // GET: Peminjaman/Details/5 public ActionResult Details(int? id) if (id == null) return new HttpStatusCodeResult(HttpStatusCode.BadRequest); Peminjaman peminjaman = db.peminjaman.find(id); if (peminjaman == null) return HttpNotFound();

96 return View(peminjaman); // GET: Peminjaman/Create public ActionResult Create(int id_pinjaman) Peminjaman pem = db.peminjaman.find(id_pinjaman); ViewBag.ID_Peminjaman = pem.peminjaman_id; ViewData["DaftarPinjaman"] = db.peminjaman_detail.where(e => e.peminjaman_id == id_pinjaman).tolist(); return View(); public ActionResult PeminjamanBuku(int id_pinjaman, string barcodebuku) int idbuku = db.buku.where(e => e.buku_bcd.contains(barcodebuku)).first().buku_id; Peminjaman_Detail pem = new Peminjaman_Detail(); pem.peminjaman_id = id_pinjaman;

97 pem.buku_id = idbuku; pem.tgl_kembali = DateTime.Now; db.peminjaman_detail.add(pem); db.savechanges(); return RedirectToAction("Create", new id_pinjaman = pem.peminjaman_id ); public ActionResult Pinjam(string id_anggota) int idanggota = db.anggota.where(e => e.anggota_bcd.contains(id_anggota)).first().anggota_id; Peminjaman baru = new Peminjaman(); baru.anggota_id = idanggota; baru.peminjaman_tanggal = DateTime.Now; baru.denda_id = 1; baru.batas_hari_id = 1; db.peminjaman.add(baru); db.savechanges(); return RedirectToAction("Create", new id_pinjaman = baru.peminjaman_id );

98 // GET: Peminjaman/Edit/5 public ActionResult Edit(int? id) if (id == null) return new HttpStatusCodeResult(HttpStatusCode.BadRequest); Peminjaman peminjaman = db.peminjaman.find(id); if (peminjaman == null) return HttpNotFound(); ViewBag.Anggota_Id = new SelectList(db.Anggota, "Anggota_Id", "Anggota_Bcd", peminjaman.anggota_id); ViewBag.Batas_Hari_Id = new SelectList(db.Batas_Hari, "Batas_Hari_Id", "Hari", peminjaman.batas_hari_id); ViewBag.Denda_Id = new SelectList(db.Denda, "Denda_Id", "Nominal", peminjaman.denda_id); return View(peminjaman); // POST: Peminjaman/Edit/5

99 // To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see http://go.microsoft.com/fwlink/?linkid=317598. [HttpPost] [ValidateAntiForgeryToken] public ActionResult Edit([Bind(Include = "Peminjaman_Id,Anggota_Id,Peminjaman_Tanggal,Denda_Id,Batas_Hari_Id")] Peminjaman peminjaman) if (ModelState.IsValid) db.entry(peminjaman).state = EntityState.Modified; db.savechanges(); return RedirectToAction("Index"); ViewBag.Anggota_Id = new SelectList(db.Anggota, "Anggota_Id", "Anggota_Bcd", peminjaman.anggota_id); ViewBag.Batas_Hari_Id = new SelectList(db.Batas_Hari, "Batas_Hari_Id", "Hari", peminjaman.batas_hari_id); ViewBag.Denda_Id = new SelectList(db.Denda, "Denda_Id", "Nominal", peminjaman.denda_id); return View(peminjaman); // GET: Peminjaman/Delete/5

100 public ActionResult Delete(int? id) if (id == null) return new HttpStatusCodeResult(HttpStatusCode.BadRequest); Peminjaman peminjaman = db.peminjaman.find(id); if (peminjaman == null) return HttpNotFound(); return View(peminjaman); // POST: Peminjaman/Delete/5 [HttpPost, ActionName("Delete")] [ValidateAntiForgeryToken] public ActionResult DeleteConfirmed(int id) Peminjaman peminjaman = db.peminjaman.find(id); db.peminjaman.remove(peminjaman); db.savechanges(); return RedirectToAction("Index");

101