Professional Documents
Culture Documents
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PrestamoLibros
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace PrestamoLibros
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void CargarDatos()
{
StreamReader Leer = File.OpenText("D:\\Libros.txt");
txtLista.Text = Leer.ReadToEnd();
Leer.Close();
}
public void LimpiarCajas()
{
txtCodigo.Clear();
txtTitulo.Clear();
txtEditorial.Clear();
cmbEstado.Text = "";
txtCodigo.Focus();
}
private void btnAdicionar_Click(object sender, EventArgs e)
{
string Codigo, Titulo, Editorial, Estado;
try
{
Codigo = txtCodigo.Text;
Titulo = txtTitulo.Text;
Editorial = txtEditorial.Text;
Estado = cmbEstado.Text;
StreamWriter Escribir = File.AppendText("D:\\Libros.txt");
Escribir.Write(Codigo + "\t" + Titulo + "\t" + Editorial + "\t" +
Estado + Environment.NewLine);
Escribir.Close();
MessageBox.Show("Archivo Guardado ");
//Lista los datos
CargarDatos();
LimpiarCajas();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
namespace PrestamoLibros
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void CargarDatos()
{
StreamReader Leer = File.OpenText("D:\\Lectores.txt");
txtLista.Text = Leer.ReadToEnd();
Leer.Close();
}
public void LimpiarCajas()
{
txtCi.Clear();
txtNombre.Clear();
txtPaterno.Clear();
txtTelefono.Text = "";
txtCi.Focus();
}
private void btnSalir_Click(object sender, EventArgs e)
{
Form1 Inicio = new Form1();
Inicio.Show();
this.Hide();
}
namespace PrestamoLibros
{
public partial class Form4 : Form
{
string estado;
public Form4()
{
InitializeComponent();
}
}
Leer.Close();
}
catch (Exception ex)
{ MessageBox.Show(ex.Message); }
}
private void txtCodigo_Leave(object sender, EventArgs e)
{
string Datos, CILector;
int sw = 0;
char[] Caracteres = { '\t' };
try
{
StreamReader Leer = File.OpenText("D:\\Lectores.txt");
Datos = Leer.ReadLine(); Datos = Leer.ReadLine();
while (Leer.EndOfStream == false)
{
Datos = Leer.ReadLine();
string[] MisDatos = Datos.Split(Caracteres);
CILector = MisDatos[0];
if (CILector == txtCI.Text)
{
txtNombreCompleto.Text = MisDatos[1] + " " +
MisDatos[2];
sw = 1;
}
}
Leer.Close();
}
catch (Exception ex)
{ MessageBox.Show(ex.Message); }
if (sw == 0)
{
MessageBox.Show("DEbe registrar al Lector", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
txtCI.Clear(); txtCI.Focus();
}
}
}
}
}