PROY
ECTO
Integrantes
Andres Figueroa
Jose Alfredo Medina
Alvaro Mojica
IMÁGENES DEL PROYECTO CORRIENDO
CÓDIGO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Farmacia.Datos;
namespace Farmacia
{
public partial class GestionProducto : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
refreshdata();
CargarCategoria();
}
else
{
refreshdata();
CargarCategoria();
}
}
private void refreshdata()
{
using (FarmaciaEntities db = new FarmaciaEntities())
{
var lst = from p in db.producto
join c1 in db.categoria on p.IdCategoria equals c1.id
orderby (p.id) descending
select new
{p.id,p.nombre,NCategoria =
c1.nombre,p.pcosto,p.pventa,p.stock,
p.FechaElaboracion,p.FechaVencimineto};
this.GridView1.DataSource = lst.ToList();
this.GridView1.DataBind();
}
}
public void CargarCategoria()
{
using (FarmaciaEntities db = new FarmaciaEntities())
{
var lst = from d in db.categoria
orderby (d.nombre) descending
select new { d.id, d.nombre }; //SELECT * FROM
CATEGORIA
this.DropDownList1.DataSource = lst.ToList();
this.DropDownList1.DataTextField = "Nombre";
this.DropDownList1.DataValueField = "Id";
this.DropDownList1.DataBind();
}
}
private void Insertar()
{
string idcategoria = this.DropDownList1.SelectedValue;
using (FarmaciaEntities db = new FarmaciaEntities())
{
producto oProducto = new producto();
oProducto.id = int.Parse(this.TextBox3.Text);
oProducto.nombre = this.TextBox4.Text;
oProducto.IdCategoria = int.Parse(idcategoria);
oProducto.pcosto = decimal.Parse(this.TextBox5.Text);
oProducto.pventa = decimal.Parse(this.TextBox6.Text);
oProducto.stock = decimal.Parse(this.TextBox7.Text);
oProducto.FechaElaboracion = DateTime.Parse(this.TextBox8.Text);
oProducto.FechaVencimineto = DateTime.Parse(this.TextBox9.Text);
db.producto.Add(oProducto);
db.SaveChanges();//GRABANDO BD
}
}
public void BuscarNombre()
{
string t = this.TextBox1.Text;
using (FarmaciaEntities db = new FarmaciaEntities())
{
var lst = from p in db.producto
join c1 in db.categoria on p.IdCategoria equals c1.id
where p.nombre == t
orderby (p.nombre) descending
select new {
p.id,
p.nombre,
NCategoria = c1.nombre,
p.pcosto,
p.pventa,
p.stock,
p.FechaElaboracion,
p.FechaVencimineto
};
this.GridView1.DataSource = lst.ToList();
this.GridView1.DataBind();
}
}
public void BuscarCategoria()
{
string t = this.TextBox2.Text;
using (FarmaciaEntities db = new FarmaciaEntities())
{
var lst = from p in db.producto
join c1 in db.categoria on p.IdCategoria equals c1.id
where c1.nombre == t
orderby (p.nombre) descending
select new {
p.id,
p.nombre,
NCategoria = c1.nombre,
p.pcosto,
p.pventa,
p.stock,
p.FechaElaboracion,
p.FechaVencimineto
};
this.GridView1.DataSource = lst.ToList();
this.GridView1.DataBind();
}
}
protected void RadioButtonList1_SelectedIndexChanged(object sender,
EventArgs e)
{
if (this.RadioButtonList1.Items[0].Selected == true)
{
this.Label1.Visible = true;
this.TextBox1.Visible = true;
this.TextBox1.Text = "";
this.Label2.Visible = false;
this.TextBox2.Visible = false;
}
else
{
this.Label2.Visible = true;
this.TextBox2.Visible = true;
this.TextBox2.Text = "";
this.Label1.Visible = false;
this.TextBox1.Visible = false;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (this.RadioButtonList1.Items[0].Selected == true)
{
if (this.TextBox1.Text == "")
Response.Write("Error introduzca Nombre");
else
{
//cadena = "select Venta.Id,fecha,nombre as NCliente from
venta inner join cliente on (venta.idcliente=cliente.id) where Venta.id=" +
this.TextBox1.Text;
this.BuscarNombre();
}
}
else
{
if (this.TextBox2.Text == "")
Response.Write("Error introduzca Categoria");
else
{
//cadena = "select Venta.Id,fecha,nombre as NCliente from
venta inner join cliente on (venta.idcliente=cliente.id) where fecha>='" +
this.TextBox2.Text + "' and fecha<='" + this.TextBox3.Text + "'";
this.BuscarCategoria();
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{
this.refreshdata();
CargarCategoria();
}
protected void Button3_Click(object sender, EventArgs e)
{
this.Insertar();
Response.Redirect("GestionProducto.aspx");
}
protected void GridView1_RowDeleting(object sender,
GridViewDeleteEventArgs e)
{
string id;
id = this.GridView1.Rows[e.RowIndex].Cells[1].Text;
using (FarmaciaEntities db = new FarmaciaEntities())
{
Datos.producto c = new Datos.producto();
c = db.producto.Find(int.Parse(id));
if (c == null)
Response.Write("Error no Existe");
else
{
db.producto.Remove(c);
db.SaveChanges();
refreshdata();
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Farmacia.Datos;
namespace Farmacia
{
public partial class GestionCategoria : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
refreshdata();
}
else
{
refreshdata();
}
}
private void refreshdata()
{
using (FarmaciaEntities db = new FarmaciaEntities())
{
var lst = from d in db.categoria
orderby (d.nombre)
select d;
this.GridView1.DataSource = lst.ToList();
this.GridView1.DataBind();
}
}
private void Insertar()
{
using (FarmaciaEntities db = new FarmaciaEntities())
{
categoria ocategoria = new categoria();
ocategoria.id = int.Parse(this.TextBox1.Text);
ocategoria.nombre = this.TextBox2.Text;
db.categoria.Add(ocategoria);
db.SaveChanges();//GRABANDO BD
}
}
protected void Button2_Click(object sender, EventArgs e)
{
this.Insertar();
Response.Redirect("GestionCategoria.aspx");
refreshdata();
}
protected void Button1_Click(object sender, EventArgs e)
{
if (this.TextBox3.Text != "")
{
using (FarmaciaEntities db = new FarmaciaEntities())
{
var lst = from d in db.categoria
where d.nombre.Contains(this.TextBox3.Text)
orderby (d.nombre)
select d;
this.GridView1.DataSource = lst.ToList();
this.GridView1.DataBind();
}
}
}
protected void Button3_Click(object sender, EventArgs e)
{
Response.Redirect("GestionCategoria.aspx");
refreshdata();
}
protected void GridView1_RowDeleting(object sender,
GridViewDeleteEventArgs e)
{
string id;
id = this.GridView1.Rows[e.RowIndex].Cells[1].Text;
using (FarmaciaEntities db = new FarmaciaEntities())
{
Datos.categoria c = new Datos.categoria();
c = db.categoria.Find(int.Parse(id));
if (c == null)
Response.Write("Error no Existe");
else
{
db.categoria.Remove(c);
db.SaveChanges();
refreshdata();
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Farmacia.Datos;
namespace Farmacia
{
public partial class GestionProducto : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
refreshdata();
CargarCategoria();
}
else
{
refreshdata();
CargarCategoria();
}
}
private void refreshdata()
{
using (FarmaciaEntities db = new FarmaciaEntities())
{
var lst = from p in db.producto
join c1 in db.categoria on p.IdCategoria equals c1.id
orderby (p.id) descending
select new
{p.id,p.nombre,NCategoria =
c1.nombre,p.pcosto,p.pventa,p.stock,
p.FechaElaboracion,p.FechaVencimineto};
this.GridView1.DataSource = lst.ToList();
this.GridView1.DataBind();
}
}
public void CargarCategoria()
{
using (FarmaciaEntities db = new FarmaciaEntities())
{
var lst = from d in db.categoria
orderby (d.nombre) descending
select new { d.id, d.nombre }; //SELECT * FROM
CATEGORIA
this.DropDownList1.DataSource = lst.ToList();
this.DropDownList1.DataTextField = "Nombre";
this.DropDownList1.DataValueField = "Id";
this.DropDownList1.DataBind();
}
}
private void Insertar()
{
string idcategoria = this.DropDownList1.SelectedValue;
using (FarmaciaEntities db = new FarmaciaEntities())
{
producto oProducto = new producto();
oProducto.id = int.Parse(this.TextBox3.Text);
oProducto.nombre = this.TextBox4.Text;
oProducto.IdCategoria = int.Parse(idcategoria);
oProducto.pcosto = decimal.Parse(this.TextBox5.Text);
oProducto.pventa = decimal.Parse(this.TextBox6.Text);
oProducto.stock = decimal.Parse(this.TextBox7.Text);
oProducto.FechaElaboracion = DateTime.Parse(this.TextBox8.Text);
oProducto.FechaVencimineto = DateTime.Parse(this.TextBox9.Text);
db.producto.Add(oProducto);
db.SaveChanges();//GRABANDO BD
}
}
public void BuscarNombre()
{
string t = this.TextBox1.Text;
using (FarmaciaEntities db = new FarmaciaEntities())
{
var lst = from p in db.producto
join c1 in db.categoria on p.IdCategoria equals c1.id
where p.nombre == t
orderby (p.nombre) descending
select new {
p.id,
p.nombre,
NCategoria = c1.nombre,
p.pcosto,
p.pventa,
p.stock,
p.FechaElaboracion,
p.FechaVencimineto
};
this.GridView1.DataSource = lst.ToList();
this.GridView1.DataBind();
}
}
public void BuscarCategoria()
{
string t = this.TextBox2.Text;
using (FarmaciaEntities db = new FarmaciaEntities())
{
var lst = from p in db.producto
join c1 in db.categoria on p.IdCategoria equals c1.id
where c1.nombre == t
orderby (p.nombre) descending
select new {
p.id,
p.nombre,
NCategoria = c1.nombre,
p.pcosto,
p.pventa,
p.stock,
p.FechaElaboracion,
p.FechaVencimineto
};
this.GridView1.DataSource = lst.ToList();
this.GridView1.DataBind();
}
}
protected void RadioButtonList1_SelectedIndexChanged(object sender,
EventArgs e)
{
if (this.RadioButtonList1.Items[0].Selected == true)
{
this.Label1.Visible = true;
this.TextBox1.Visible = true;
this.TextBox1.Text = "";
this.Label2.Visible = false;
this.TextBox2.Visible = false;
}
else
{
this.Label2.Visible = true;
this.TextBox2.Visible = true;
this.TextBox2.Text = "";
this.Label1.Visible = false;
this.TextBox1.Visible = false;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (this.RadioButtonList1.Items[0].Selected == true)
{
if (this.TextBox1.Text == "")
Response.Write("Error introduzca Nombre");
else
{
//cadena = "select Venta.Id,fecha,nombre as NCliente from
venta inner join cliente on (venta.idcliente=cliente.id) where Venta.id=" +
this.TextBox1.Text;
this.BuscarNombre();
}
}
else
{
if (this.TextBox2.Text == "")
Response.Write("Error introduzca Categoria");
else
{
//cadena = "select Venta.Id,fecha,nombre as NCliente from
venta inner join cliente on (venta.idcliente=cliente.id) where fecha>='" +
this.TextBox2.Text + "' and fecha<='" + this.TextBox3.Text + "'";
this.BuscarCategoria();
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{
this.refreshdata();
CargarCategoria();
}
protected void Button3_Click(object sender, EventArgs e)
{
this.Insertar();
Response.Redirect("GestionProducto.aspx");
}
protected void GridView1_RowDeleting(object sender,
GridViewDeleteEventArgs e)
{
string id;
id = this.GridView1.Rows[e.RowIndex].Cells[1].Text;
using (FarmaciaEntities db = new FarmaciaEntities())
{
Datos.producto c = new Datos.producto();
c = db.producto.Find(int.Parse(id));
if (c == null)
Response.Write("Error no Existe");
else
{
db.producto.Remove(c);
db.SaveChanges();
refreshdata();
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Farmacia.Datos;
namespace Farmacia
{
public partial class BusVentas : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
refreshdata();
}
else
{
refreshdata();
}
}
private void refreshdata()
{
using (FarmaciaEntities db = new FarmaciaEntities())
{
var lst = from p in db.venta
join c1 in db.cliente on p.idCliente equals c1.id
orderby (p.id) descending
select new{p.id, p.fecha, NCliente = c1.nombre};
this.GridView1.DataSource = lst.ToList();
this.GridView1.DataBind();
}
}
public void BuscarFechas()
{
DateTime t1 = DateTime.Parse(this.TextBox2.Text);
DateTime t2 = DateTime.Parse(this.TextBox3.Text);
using (FarmaciaEntities db = new FarmaciaEntities())
{
var lst = from d in db.venta
join c1 in db.cliente on d.idCliente equals c1.id
where d.fecha >= t1 && d.fecha <= t2
orderby (d.id) descending
select new { d.id, d.fecha, NCliente = c1.nombre };
this.GridView1.DataSource = lst.ToList();
this.GridView1.DataBind();
public void BuscarNombre()
{
string t = this.TextBox1.Text;
using (FarmaciaEntities db = new FarmaciaEntities())
{
var lst = from d in db.venta
join c1 in db.cliente on d.idCliente equals c1.id
where c1.nombre == t
orderby (d.id) descending
select new { d.id, d.fecha, NCliente = c1.nombre };
this.GridView1.DataSource = lst.ToList();
this.GridView1.DataBind();
protected void RadioButtonList1_SelectedIndexChanged(object sender,
EventArgs e)
{
if (this.RadioButtonList1.Items[0].Selected == true)
{
this.Label4.Visible = true;
this.TextBox1.Visible = true;
this.TextBox1.Text = "";
this.Label2.Visible = false;
this.Label3.Visible = false;
this.TextBox2.Visible = false;
this.TextBox3.Visible = false;
}
else
{
this.Label2.Visible = true;
this.Label3.Visible = true;
this.TextBox2.Visible = true;
this.TextBox3.Visible = true;
this.TextBox2.Text = "";
this.TextBox3.Text = "";
this.Label4.Visible = false;
this.TextBox1.Visible = false;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (this.RadioButtonList1.Items[0].Selected == true)
{
if (this.TextBox1.Text == "")
Response.Write("Error introduzca nombre");
else
{
//cadena = "select Venta.Id,fecha,nombre as NCliente from
venta inner join cliente on (venta.idcliente=cliente.id) where Venta.id=" +
this.TextBox1.Text;
this.BuscarNombre();
}
}
else
{
if (this.TextBox2.Text == "" || this.TextBox3.Text == "")
Response.Write("Error introduzca la fecha inicial o la fecha
final");
else
{
//cadena = "select Venta.Id,fecha,nombre as NCliente from
venta inner join cliente on (venta.idcliente=cliente.id) where fecha>='" +
this.TextBox2.Text + "' and fecha<='" + this.TextBox3.Text + "'";
this.BuscarFechas();
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{
refreshdata();
}
protected void GridView1_RowDeleting(object sender,
GridViewDeleteEventArgs e)
{
string id;
id = this.GridView1.Rows[e.RowIndex].Cells[1].Text;
using (FarmaciaEntities db = new FarmaciaEntities())
{
Datos.venta c = new Datos.venta();
c = db.venta.Find(int.Parse(id));
if (c == null)
Response.Write("Error no Existe");
else
{
db.venta.Remove(c);
db.SaveChanges();
refreshdata();
}
}
}
protected void Button3_Click(object sender, EventArgs e)
{
Session["IdCompra"] = null;
Session["Fecha"] = null;
Session["IdProveedor"] = null;
Session["Glosa"] = null;
Response.Redirect("AgregarVenta.aspx");
}
}