TIENDA DE COSMETICO1.docx
-
Upload
fabiola-torres-hernandez -
Category
Documents
-
view
7 -
download
0
Transcript of TIENDA DE COSMETICO1.docx
TIENDA DE COSMETICOS
Objetivo:
Crear un programa que sea capaz de almacenar registros de información de una tienda de cosméticos sobre sus producto y sus clientes que esté disponible cuando se requiera.
Metodologia a emplear :
Materiales:
En este proyecto el material que se utilizo fue c#.
Desarrollo:
Primero diseñe 7 formularios lo cuales se describen acontinuacion:
El primer formulario es donde utilice un menustrip en el cual se unen los demás formularios.
using System;using System.Collections.Generic;using System.Drawing;using System.Windows.Forms;
namespace cosmetricos{ public partial class MainForm : Form { public MainForm() { InitializeComponent(); }
void AgregarToolStripMenuItem1Click(object sender, EventArgs e) { Form1 a= new Form1(); a.Show(); } void ConsultarToolStripMenuItem1Click(object sender, EventArgs e) { Form2 b=new Form2(); b.Show(); } void LeerToolStripMenuItem1Click(object sender, EventArgs e) { Form3 c= new Form3(); c.Show(); } void AgregarToolStripMenuItemClick(object sender, EventArgs e) { Form4 d=new Form4(); d.Show(); } void ConsultarToolStripMenuItemClick(object sender, EventArgs e) { Form5 wzz=new Form5(); wzz.Show(); } void LeerToolStripMenuItemClick(object sender, EventArgs e) { Form6 hi=new Form6(); hi.Show(); } }}
El segundo diseño es de agregar un registro del cliente:
using System;using System.Drawing;using System.Windows.Forms;using System.IO;namespace cosmetricos{ public partial class Form1 : Form { public Form1() { InitializeComponent(); }
void BtnguardarClick(object sender, EventArgs e) { FileStream c=new FileStream("c:\\osq\\clie.txt", FileMode.Append, FileAccess.Write); BinaryWriter cli=new BinaryWriter(c); cli.Write(txtnombre.Text); cli.Write(txtdireccion.Text); cli.Write(txttelefono.Text); c.Close(); cli.Close(); MessageBox.Show("datos almacenados"); txtnombre.Text=""; txtdireccion.Text=""; txttelefono.Text=""; c.Close(); cli.Close(); } void BtnregresarClick(object sender, EventArgs e) { this.Close(); } }}
En el tercer diseño se buscan los datos almacenados
using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
namespace cosmetricos
{
public partial class Form3 : Form
{
public Form3()
{ InitializeComponent();
}
void BtnobtenerClick(object sender, EventArgs e)
{
FileStream fer=new FileStream("c://osq//clie.txt",FileMode.
Open,FileAccess.Read);
BinaryReader fer1=new BinaryReader( fer);
lbinformacion.Items.Clear();
while(fer1.PeekChar() > - 1)
{
string nombre = fer1.ReadString();
string direccion=fer1.ReadString();
string telefono=fer1.ReadString();
lbinformacion.Items.Add(nombre +"-" + direccion + "-" + telefono );
}
fer.Close();
fer1.Close();
}
void BtnregresarClick(object sender, EventArgs e)
{
this.Close();
}
}
}
En el cuarto diseño se almacenan los datos del cuarto formulario que es el de
producto.
using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
namespace cosmetricos
{public partial class Form4 : Form
{
public Form4()
{
InitializeComponent();
}
void BtnguardarClick(object sender, EventArgs e)
{
FileStream ed=new FileStream("c:\\osq\\pro.txt", FileMode.Append,
FileAccess.Write);
BinaryWriter ed1=new BinaryWriter(ed);
ed1.Write(txtnombre.Text);
ed1.Write(txtmarca.Text);
ed1.Write(txtprecio.Text);
ed.Close();
ed1.Close();
MessageBox.Show("datos almacenados");
txtnombre.Text="";
txtmarca.Text="";
txtprecio.Text="";
ed.Close();
ed1.Close();
}
void BtnregresarClick(object sender, EventArgs e)
{
this.Close();
}
}
}
En el quinto diseño se busca o consulta los datos almacenados del producto.
using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
namespace cosmetricos
{ public partial class Form5 : Form
{
public Form5()
{
InitializeComponent();
}
void BtnbuscarClick(object sender, EventArgs e)
{
FileStream bus=new FileStream("c:\\osq\\
pro.txt",FileMode.Open,FileAccess.Read);
BinaryReader bus1=new BinaryReader (bus);
bool encont=false ;
while(bus1.PeekChar()> -1)
{
string nombre = bus1.ReadString();
string marca=bus1.ReadString();
string precio=bus1.ReadString();
if (txtmarca.Text.Trim() == marca.Trim())
{
MessageBox.Show(nombre +"\n" + marca + "\n" + precio );
encont=true;
break;
}
}
if(encont==false)
{
MessageBox.Show("No ha sido encontrado");
}
bus.Close();
bus1.Close();
}
void BtnregresarClick(object sender, EventArgs e)
{
this.Close();
}
}
En el sexto diseño se muestran los datos almacenados del producto.
using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
namespace cosmetricos
{ public partial class Form6 : Form
{
public Form6()
{
InitializeComponent();
}
void BtnobtenerClick(object sender, EventArgs e)
{
FileStream leo=new FileStream("c://osq//pro.txt",FileMode.Open,FileAccess.Read);
BinaryReader gabi=new BinaryReader( leo);
susdatos.Items.Clear();
while(gabi.PeekChar() > - 1)
{
string nombre = gabi.ReadString();
string marca=gabi.ReadString();
string precio=gabi.ReadString();
susdatos.Items.Add(nombre +"-" + marca + "-" + precio );
}
leo.Close();
gabi.Close();
}
void BtnregresarClick(object sender, EventArgs e)
{
this.Close();
}
}
}