PROJECT : Create Book Inventory Project for Beginners


Download Previous Project with Source Code :

  1. Stock Management System Project With Source Code
  2. Library Management System Project With Source Code
  3. Reminder Application Project With Source Code
  4. Book Inventory Project With Source Code
  5. School Management System Project With Source Code

Create Book Inventory

Create Book Inventory is very simple and easy project to understand by seeing UI of this project in above image. Book Inventory is used to store Book Information to Database and Retrieve the data from the Database and show in Gridview( i.e Tabular Format).

Allow to do :

  1. Create Book Info.
  2. Edit Book Info.
  3. Update Book Info.
  4. Delete Book Info.

CREATE DATABASE : Book Inventory

USE [master]
GO
/****** Object:  Table [dbo].[Book]    Script Date: 03/30/2015 22:44:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Book]undefined
 [Book_Id] [nvarchar]undefined5) NULL,
 [Book_name] [nvarchar]undefined50) NULL,
 [Book_author] [nvarchar]undefined30) NULL,
 [Book_Publisher_name] [nvarchar]undefined50) NULL,
 [Book_Published_date] [nvarchar]undefined30) NULL
) ON [PRIMARY]
GO

HTML CODE For User Interface :

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="BookForm.aspx.cs" Inherits="BookForm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>    
    <link href="CSS/StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">    
    <div>
    <div id="display_success" class="display_success" visible="false" runat="server"></div>
    <div id="display_warning" class="display_warning" runat="server"></div>
    <div id="display_info" class="display_info" runat="server"></div>
    <div id="displau_error" class="display_error" runat="server"></div>
     <div>      
     </div>
     <table class="table">
      <tr>
      <th colspan="2">Create Book Inventory</th>
      </tr>      
      <tr>
       <td>Book ID : </td><td><asp:TextBox ID="txtBookId" CssClass="textbox" runat="server" MaxLength="5"></asp:TextBox>&nbsp;<asp:Button 
              ID="BtnGet" runat="server" 
              Text="Get" Visible="false" onclick="BtnGet_Click" /></td></tr><tr>
       <td>Book Name : </td><td><asp:TextBox ID="txtBookName" CssClass="textbox" runat="server"></asp:TextBox></td></tr><tr>
       <td>Book Author : </td><td><asp:TextBox ID="txtBookAuthor" CssClass="textbox" runat="server"></asp:TextBox></td></tr><tr>
       <td>Book Publisher Name : </td><td><asp:TextBox ID="txtBookPublisherName" CssClass="textbox" runat="server"></asp:TextBox></td>
      </tr>
      <tr>
      <td colspan="2" align="center">
          <asp:Button CssClass="button" ID="BtnCreateBookInvSubmit" runat="server" 
              Text="Submit" onclick="BtnCreateBookInvSubmit_Click" />&nbsp;
          <asp:Button CssClass="button" ID="BtnCreateBookInvUpdate" runat="server" 
              Text="Update" Visible="false" onclick="BtnCreateBookInvUpdate_Click" />&nbsp;
               <asp:Button CssClass="button" ID="BtnCreateBookInvDelet" runat="server" 
              Text="Delete" Visible="false" onclick="BtnCreateBookInvDelet_Click" />&nbsp;
              <asp:Button CssClass="button" ID="BtnCreateBookInvEdit" runat="server" 
              Text="Edit" onclick="BtnCreateBookInvEdit_Click" />&nbsp;
          <asp:Button CssClass="button" ID="BtnCreateBookInvCancel" runat="server" 
              Text="Cancel" onclick="BtnCreateBookInvCancel_Click" />
      </td>
      </tr>
     </table>
    </div>
    <div style="margin:20px -250px 0px -90px;">
    <asp:GridView ID="gridview_book" runat="server" AutoGenerateColumns="False" 
        BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" 
        CellPadding="3" CellSpacing="2">
        <Columns>
            <asp:BoundField DataField="Book_id" HeaderText="Book ID" />
            <asp:BoundField DataField="Book_name" HeaderText="Book Name" />
            <asp:BoundField DataField="Book_author" HeaderText="Book Author">            
            </asp:BoundField>
            <asp:BoundField DataField="Book_Publisher_name" 
                HeaderText="Book Publisher Name">
            </asp:BoundField>
            <asp:BoundField DataField="Book_Published_date" 
                HeaderText="Book Published Date">
            </asp:BoundField>

        </Columns>
        <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
        <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
        <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
        <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
        <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
        <SortedAscendingCellStyle BackColor="#FFF1D4" />
        <SortedAscendingHeaderStyle BackColor="#B95C30" />
        <SortedDescendingCellStyle BackColor="#F1E5CE" />
        <SortedDescendingHeaderStyle BackColor="#93451F" />
    </asp:GridView>
    </div> 
    
    </form>
</body>
</html>

CSS Book Inventory

.body
{
    margin:50px 250px 0px 500px;
}
.table
    {   
        border-collapse:collapse;
        padding:10px 10px 10px 10px;
    }
    .table th, td
    {        
        border:1px solid #ccc;
    }
    .table th
    { 
        background-color:#0066cc;
        color:#fff;
        padding:5px 5px 5px 5px;
    }
    .table td
    {
       padding:2px 5px 2px 5px;
    }
    .textbox
    {
        background:#9999FF;
        width:190px;
        border:1px solid #0066cc;
        padding:3px 3px 3px 3px;
    }
    .textbox:hover
    {
        background:#0066cc;
        width:190px;
        border:1px solid #ff0000;
        padding:3px 3px 3px 3px;
        color:#fff;
    }
    .button
    {
        background:#000000;
        color:#fff;
        padding:10px 15px 10px 15px;
        border-collapse:collapse;        
        border:1px solid #000000;
    }
    .button:hover
    {
        background:#0066cc;
        color:#fff;
        padding:10px 15px 10px 15px;
        border-collapse:collapse;      
        border:1px solid #0066cc;
    }
    .display_success, dispaly_warning, display_error, display_info{
        border:1px solid;
        margin: 10px 0px;
        padding:15px 10px 15px 50px;
        background-repeat: no-repeat;
        background-position: 10px center;
    }
    .display_info {
        color: #00529B;
        background-color: #BDE5F8;
        background-image: url('info.png');
    }
    .display_success {
        color: #4F8A10;
        background-color: #DFF2BF;
        background-image:url('~/Images/success-lg.gif');
        width:310px;
    }
    .display_warning {
        color: #9F6000;
        background-color: #FEEFB3;
        background-image: url('warning.png');
    }
    .display_error {
        color: #D8000C;
        background-color: #FFBABA;
        background-image: url('error.png');
    }

C# Coding :Namespaces

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

Web.Config : Database Connection

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
 <system.web>
  <compilation debug="true" targetFramework="4.0"/>    
 </system.web>
  <connectionStrings>
    <add name="RCCon" connectionString="Server=.; Database = master; Trusted_Connection = Yes;"/>
  </connectionStrings>
</configuration>

C# Coding : Retrieve Data from the Database and display in Gridview

void Get_Book_Detailsundefined)
    {       
        sqlquery = "Select * from Book";
        cmd=new SqlCommandundefinedsqlquery, con);
        con.Openundefined);
        gridview_book.DataSource = cmd.ExecuteReaderundefined);
        gridview_book.DataBindundefined);
        con.Closeundefined);
    }

C# Coding : Submit Button Code

 protected void BtnCreateBookInvSubmit_Clickundefinedobject sender, EventArgs e)
    {
        sqlquery = "Insert into BookundefinedBook_id, Book_name, Book_author, Book_Publisher_name, Book_Published_date) Valuesundefined'" + txtBookId.Text + "', '" + txtBookName.Text + "', '" + txtBookAuthor.Text + "', '" + txtBookPublisherName.Text + "', '" + datetime + "')";
        cmd = new SqlCommandundefinedsqlquery, con);
        con.Openundefined);
        cmd.ExecuteNonQueryundefined);
        con.Closeundefined);
        display_success.Visible = true;
        display_success.InnerHtml = "Insert Successfully...";
        Get_Book_Detailsundefined);
        
    }

C# Coding : Edit Button Code

protected void BtnCreateBookInvEdit_Clickundefinedobject sender, EventArgs e)
    {
        display_success.Visible = false;
        display_success.InnerHtml = string.Empty;
        txtBookId.Text = string.Empty;
        txtBookId.Attributes["placeholder"] = "Please Enter Book ID";
        txtBookName.Visible = false;
        txtBookAuthor.Visible = false;
        txtBookPublisherName.Visible = false;
        BtnCreateBookInvSubmit.Visible = false;
        BtnGet.Visible = true;
        BtnCreateBookInvEdit.Visible = false;
        BtnCreateBookInvUpdate.Visible = true;
        BtnCreateBookInvDelet.Visible = true;
    }

C# Coding : Cancel Button Code

 protected void BtnCreateBookInvCancel_Clickundefinedobject sender, EventArgs e)
    {
        display_success.Visible = false;
        display_success.InnerHtml = string.Empty;
        txtBookId.Attributes["placeholder"] = string.Empty;
        txtBookId.Text = string.Empty;
        txtBookAuthor.Text = string.Empty;
        txtBookAuthor.Visible = true;
        txtBookName.Text = string.Empty;
        txtBookName.Visible = true;
        txtBookPublisherName.Text = string.Empty;
        txtBookPublisherName.Visible = true;
        BtnGet.Visible = false;
        BtnCreateBookInvSubmit.Visible = true;
        BtnCreateBookInvEdit.Visible = true;
        BtnCreateBookInvUpdate.Visible = false;
        BtnCreateBookInvDelet.Visible = false;
    }

C# Coding : Update Button Code

protected void BtnCreateBookInvUpdate_Clickundefinedobject sender, EventArgs e)
    {
        sqlquery = "Update Book set Book_name='" + txtBookName.Text + "', Book_author='" + txtBookAuthor.Text + "', Book_Publisher_name='" + txtBookPublisherName.Text + "', Book_Published_date='" + System.DateTime.Today.ToStringundefined) + "' where book_id='" + txtBookId.Text + "'";
        cmd = new SqlCommandundefinedsqlquery, con);
        con.Openundefined);
        cmd.ExecuteNonQueryundefined);
        con.Closeundefined);
        display_success.Visible = true;
        display_success.InnerHtml = "Update Successfully...";
        Get_Book_Detailsundefined);
    }

C# Coding : Delete Button Code

protected void BtnCreateBookInvDelet_Clickundefinedobject sender, EventArgs e)
    {
        sqlquery = "delete Book where book_id='" + txtBookId.Text + "'";
        cmd = new SqlCommandundefinedsqlquery, con);
        con.Openundefined);
        cmd.ExecuteNonQueryundefined);
        con.Closeundefined);
        Get_Book_Detailsundefined);
    }  
void enableundefined)
    {
        txtBookAuthor.Visible = true;
        txtBookName.Visible = true;
        txtBookPublisherName.Visible = true;
    }  

Download Project Source Code


0 Komentar untuk "PROJECT : Create Book Inventory Project for Beginners"

Back To Top