Showing posts with label library management system web application. Show all posts
Showing posts with label library management system web application. Show all posts

Friday, July 27, 2018

Library management system in asp.net Ms Visual Studio, Sql Server | Sradha Webcreations

Library management system in Visual Studio, Sql Server 

 http://www.sradhawebcreations.com



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

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
 protected void TextBoxRETURN_TextChanged(object sender, EventArgs e)
    {
        string sCardNumber = TextBoxCARDNUMBER.Text;
        string sBookNmae = TextBoxBOOKNAME.Text;
        string sStudentName = TextBoxSTUDENTNAME.Text;
       
        string sIssuedDate = TextBoxISSUED.Text;
        DateTime d1 = Convert.ToDateTime(sIssuedDate);

        string sReturnDate = TextBoxRETURN.Text;
        DateTime d2 = Convert.ToDateTime(sReturnDate);

        int iNumberOfDay;
        double dFine;

        iNumberOfDay = ((TimeSpan)(d2 - d1)).Days;
        TextBoxNUMBEROFDAY.Text = Convert.ToString(iNumberOfDay);

        if (iNumberOfDay <= 30)
        {
            dFine = 0;
        }
        else
        {
            dFine = iNumberOfDay * 10.00;
        }
        TextBoxFINE.Text = Convert.ToString(dFine);
    }

    protected void ButtonSAVE_Click(object sender, EventArgs e)
    {
        string connectionstring= ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
        string insertsql = "insert into libraryfine(cardnumber,bookname,issueddate,returneddate,noofdate,fine)values(@cardnumber,@bookname,@issueddate,@returneddate,@noofdate,@fine)";

        using (SqlConnection myconnection = new SqlConnection(connectionstring))
        {
            myconnection.Open();
        SqlCommand mycommand = new SqlCommand(insertsql,myconnection);
         mycommand.Parameters.AddWithValue("cardnumber",TextBoxCARDNUMBER.Text);
     mycommand.Parameters.AddWithValue("booknumber",TextBoxBOOKNAME.Text);
            mycommand.Parameters.AddWithValue("name",TextBoxSTUDENTNAME.Text);
            mycommand.Parameters.AddWithValue("issueddate",TextBoxISSUED.Text);
            mycommand.Parameters.AddWithValue("returneddate",TextBoxRETURN.Text);
            mycommand.Parameters.AddWithValue("noofday",TextBoxNUMBEROFDAY.Text);
            mycommand.Parameters.AddWithValue("fine",TextBoxFINE.Text);
            mycommand.ExecuteNonQuery();
            myconnection.Close();
        }
        TextBoxCARDNUMBER.Text = string.Empty;
        TextBoxBOOKNAME.Text = string.Empty;
        TextBoxSTUDENTNAME.Text = string.Empty;
        TextBoxISSUED.Text = string.Empty;
        TextBoxRETURN.Text = string.Empty;
        textbox
    }
}