C# Windows Forms Library Management System Source Code

Classified in Technology

Written on in English with a size of 4.29 KB

C# Windows Forms Library Management System Source Code

Below is the complete C# source code for a Windows Forms application designed to manage library loans, book returns, and student or teacher transactions.

Form1 Implementation

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Examen_1_Objetos_Denys_Garnier
{
    public partial class Form1 : Form
    {
        Biblioteca[] mibiblioteca = new Biblioteca[1];
        byte cont = 0;
        string nom;
        string lec;
        string tipl;
        string fc1;
        string fc2;
        int dia;
        string ttp;
        string tp;
        string tp1;
        string tp2;
        string tp3;
        byte cl = 0;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
        }

        private void button1_Click(object sender, EventArgs e)
        {
            tp = "";
            tp1 = "";
            tp2 = "";
            tp3 = "";
            tipl = "";
            nom = textBox1.Text;
            
            if (radioButton3.Checked)
                ttp = "Prestamo";
            else if (radioButton4.Checked)
            {
                ttp = "Devolucion";
            }
            
            if (radioButton1.Checked)
                lec = "Docente";
            else if (radioButton2.Checked)
                lec = "Estudiante";

            if (checkBox1.Checked == true)
            {
                tp = "Matematica";
                cl++;
            }
            if (checkBox2.Checked == true)
            {
                tp1 = "Fisica";
                cl++;
            }
            if (checkBox3.Checked == true)
            {
                tp2 = "Computacion";
                cl++;
            }
            if (checkBox4.Checked == true)
            {
                tp3 = "Dibujo";
                cl++;
            }
            tipl = tp + tp1 + tp2 + tp3;
     
            dia = Convert.ToByte(textBox2.Text);
            int mes = Convert.ToByte(textBox3.Text);
            int año = Convert.ToByte(textBox4.Text);
            int dia2 = dia + 5;
            fc1 = dia + "/" + mes + "/" + año;
            fc2 = dia2 + "/" + mes + "/" + año;

            Array.Resize(ref mibiblioteca, cont + 1);
            mibiblioteca[cont] = new Biblioteca();
            mibiblioteca[cont].agregrar(nom, lec, tipl, fc1, fc2, ttp, cl);
            listBox1.Items.Add("Nombre: " + nom + "   T. Lector: " + lec + "   T. Libro: " + tipl + "   F. de Prestamo: " + fc1 + "F. de Vencimiento: " + fc2 + "   Condicion:   " + ttp);
            cont++;
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";
            textBox1.Focus();
            checkBox1.Checked = false;
            checkBox2.Checked = false;
            checkBox3.Checked = false;
            checkBox4.Checked = false;
            radioButton1.Checked = false;
            radioButton2.Checked = false;
            radioButton3.Checked = false;
            radioButton4.Checked = false;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            int resul = 0;
            Biblioteca cal = new Biblioteca();

            if (radioButton5.Checked)
            {
                resul = cal.cantidad_lp(mibiblioteca);
                MessageBox.Show("Cantidad de libros prestados:  " + resul, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (radioButton6.Checked)
            {
                resul = cal.cantl_presA(mibiblioteca);
                MessageBox.Show("Cantidad de libros prestados a alumnos:  " + resul, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (radioButton7.Checked)
            {
                resul = cal.cant_lce(mibiblioteca);
                MessageBox.Show("Cantidad de libros prestados de computacion:  " + resul, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}

Related entries: