private void Busqueda() { db = new FeriaEntities(); Lista = FactoryPlatos.getItems(db, this.txtBuscar.Text); this.bs.DataSource = Lista; this.bs.ResetBindings(true); }
void Cargar_Click(object sender, EventArgs e) { FrmBuscarEntidades f = new FrmBuscarEntidades(); f.BuscarFacturas(""); if (f.DialogResult == System.Windows.Forms.DialogResult.Abort) { using (var db = new FeriaEntities()) { var x = (from item in db.Facturas where item.IdFactura == ((Factura)(f.registro)).IdFactura select item).FirstOrDefault(); if (x != null) { db.Facturas.DeleteObject(x); db.SaveChanges(); return; } } } if (f.DialogResult == System.Windows.Forms.DialogResult.OK) { if (f.registro != null) { factura = FactoryFacturas.Item(db, ((Factura)f.registro).IdFactura); facturaBindingSource.DataSource = factura; facturaBindingSource.ResetBindings(true); facturaProductoBindingSource.DataSource = factura.FacturasPlatos; facturaProductoBindingSource.ResetBindings(true); esNuevo = false; factura.Tipo = "FACTURA"; } } }
public void LibroDeCompras() { FrmMesyAño f = new FrmMesyAño(); f.Text = "Libro de Compras"; f.ShowDialog(); if (f.DialogResult != System.Windows.Forms.DialogResult.OK) { return; } using (var db = new FeriaEntities()) { int Mes = f.Mes; int Año = f.Año; var consulta = from q in db.Compras where (q.Fecha.Value.Month == Mes && q.Fecha.Value.Year == f.Año) && q.LibroCompras == true orderby q.Fecha select q; reportViewer1.ProcessingMode = ProcessingMode.Local; this.reportViewer1.LocalReport.ReportPath = Application.StartupPath + "\\Reportes\\LibroDeCompras.rdlc"; this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Compras", consulta.ToList())); this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Parametros", new Parametro[] { Basicas.parametros() })); this.reportViewer1.RefreshReport(); this.ShowDialog(); } }
public static List <IngredientesConsumo> ConsumoPlatosxLapso(DateTime desde, DateTime hasta) { using (FeriaEntities db = new FeriaEntities()) { List <IngredientesConsumo> q = (from factura in db.Facturas join facturaplato in db.FacturasPlatos on factura.IdFactura equals facturaplato.IdFactura join productoIngrediente in db.PlatosIngredientes on facturaplato.Idplato equals productoIngrediente.IdPlato where factura.Fecha.Value >= desde && factura.Fecha.Value <= hasta && (factura.Tipo == "FACTURA" || factura.Tipo == "CONSUMO") select new IngredientesConsumo { IdIngrediente = productoIngrediente.IdIngrediente, Descripcion = productoIngrediente.Ingrediente, Cantidad = (double)facturaplato.Cantidad * (double)productoIngrediente.Cantidad }).ToList(); var ResumenxIngrediente = from p in q group p by p.Descripcion into ConsumoxProducto select new IngredientesConsumo { Descripcion = ConsumoxProducto.Key, Cantidad = ConsumoxProducto.Sum(x => x.Cantidad) }; var ordenado = from a in ResumenxIngrediente orderby a.Descripcion select a; return(ordenado.ToList()); } }
public static List <TotalxFormaPago> VentasxHoras(DateTime desde, DateTime hasta) { List <TotalxFormaPago> retorno = new List <TotalxFormaPago>(); using (var db = new FeriaEntities()) { var consulta = from q in db.Facturas where (q.Fecha.Value == DateTime.Today.Date && q.Hora.Value >= desde && q.Hora.Value <= hasta && q.Anulado == false) select q; TotalxFormaPago efectivo = new TotalxFormaPago(); double cambio = consulta.Sum(x => x.Cambio).GetValueOrDefault(0); efectivo.FormaPago = "EFECTIVO"; efectivo.Bolivares = consulta.Sum(x => x.Efectivo).GetValueOrDefault(0) - cambio; retorno.Add(efectivo); TotalxFormaPago cheque = new TotalxFormaPago(); cheque.FormaPago = "CHEQUE"; cheque.Bolivares = consulta.Sum(x => x.Cheque).GetValueOrDefault(0); retorno.Add(cheque); TotalxFormaPago tarjeta = new TotalxFormaPago(); tarjeta.FormaPago = "TARJETA"; tarjeta.Bolivares = consulta.Sum(x => x.Tarjeta).GetValueOrDefault(0); retorno.Add(tarjeta); TotalxFormaPago cestaTicket = new TotalxFormaPago(); cestaTicket.FormaPago = "CESTA TICKET"; cestaTicket.Bolivares = consulta.Sum(x => x.CestaTicket).GetValueOrDefault(0); retorno.Add(cestaTicket); TotalxFormaPago consumoInterno = new TotalxFormaPago(); consumoInterno.FormaPago = "CONSUMO INTERNO"; consumoInterno.Bolivares = consulta.Sum(x => x.ConsumoInterno).GetValueOrDefault(0); retorno.Add(consumoInterno); return(retorno); } }
void btnBuscar_Click(object sender, EventArgs e) { db = new FeriaEntities(); Lista = FactoryPlatos.getItems(db, this.txtBuscar.Text); this.bs.DataSource = Lista; this.bs.ResetBindings(true); }
public static List <VentasxPlato> VentasHorasxPlatos(DateTime desde, DateTime hasta) { using (FeriaEntities db = new FeriaEntities()) { var q = from factura in db.Facturas join facturaplato in db.FacturasPlatos on factura.IdFactura equals facturaplato.IdFactura where factura.Hora.Value >= desde && factura.Hora.Value <= hasta && factura.Fecha == DateTime.Today.Date && factura.Anulado == false && (factura.Tipo == "FACTURA" || factura.Tipo == "CONSUMO") select new VentasxPlato { Grupo = facturaplato.Grupo, Descripcion = facturaplato.Descripcion, PlatosVendidos = facturaplato.Cantidad.Value, MontoPlatosVendidos = facturaplato.Total.Value }; var ResumenxPlato = from p in q.ToList() group p by new { p.Grupo, p.Descripcion } into ventaxPlato select new VentasxPlato { Grupo = ventaxPlato.Key.Grupo, Descripcion = ventaxPlato.Key.Descripcion, PlatosVendidos = ventaxPlato.Sum(x => x.PlatosVendidos), MontoPlatosVendidos = ventaxPlato.Sum(x => x.MontoPlatosVendidos) }; return(ResumenxPlato.ToList()); } }
private void Busqueda() { db = new FeriaEntities(); Lista = FactoryUsuarios.getItems(db, this.txtBuscar.Text, "ADMINISTRADOR"); this.bs.DataSource = Lista; this.bs.ResetBindings(true); }
private void Busqueda() { db = new FeriaEntities(); Lista = FactoryLibroVentas.getItems(db, Convert.ToInt16(txtMes.Text), Convert.ToInt16(txtAño.Text)); this.bs.DataSource = Lista; this.bs.ResetBindings(true); }
private void Busqueda() { if (!DateTime.TryParse(txtBuscar.Text, out dia)) { txtBuscar.Text = DateTime.Today.ToString("d"); return; } db = new FeriaEntities(); IngredientesInventario InventarioSiguiente = (from item in db.IngredientesInventarios where item.Fecha > dia select item).FirstOrDefault(); if (InventarioSiguiente != null) { MessageBox.Show("Atencion hay movimientos posteriores a esta fecha"); } Lista = (from q in db.IngredientesInventarios orderby q.Ingrediente where q.Fecha == dia select q).ToList(); foreach (Ingrediente item in db.Ingredientes) { var esta = Lista.FirstOrDefault(x => x.IdIngrediente == item.IdIngrediente); if (esta == null) { IngredientesInventario nuevoItem = new IngredientesInventario(); var DiaAnterior = (from p in db.IngredientesInventarios where p.IdIngrediente == item.IdIngrediente && p.Fecha <= dia orderby p.Fecha descending select p).FirstOrDefault(); if (DiaAnterior != null) { nuevoItem.Inicio = DiaAnterior.InventarioFisico; nuevoItem.Salidas = 0; nuevoItem.Entradas = 0; nuevoItem.Final = DiaAnterior.InventarioFisico; } else { nuevoItem.Inicio = 0; nuevoItem.Salidas = 0; nuevoItem.Entradas = 0; nuevoItem.Final = 0; } nuevoItem.Fecha = dia; nuevoItem.IdIngrediente = item.IdIngrediente; nuevoItem.IdIngredienteInventario = FactoryContadores.GetMax("IdIngredienteInventario"); nuevoItem.Ingrediente = item.Descripcion; db.IngredientesInventarios.AddObject(nuevoItem); db.SaveChanges(); } } Lista = (from q in db.IngredientesInventarios orderby q.Ingrediente where q.Fecha == dia select q).ToList(); this.bs.DataSource = Lista; this.bs.ResetBindings(true); }
public static int GetContador(string Variable) { try { using (var oEntidades = new FeriaEntities()) { Contadore Contador = oEntidades.Contadores.FirstOrDefault(x => x.Variable == Variable); if (Contador == null) { Contador = new Contadore(); Contador.Variable = Variable; Contador.Valor = 1; oEntidades.Contadores.AddObject(Contador); } else { Contador.Valor++; if (Contador.Valor > 99) { Contador.Valor = 1; } } oEntidades.SaveChanges(); return(Contador.Valor.GetValueOrDefault(0)); } } catch (Exception ex) { string x = ex.Message; } return(1); }
public static string GetMax(string Variable) { try { using (var oEntidades = new FeriaEntities()) { Contadore Contador = oEntidades.Contadores.FirstOrDefault(x => x.Variable == Variable); if (Contador == null) { Contador = new Contadore(); Contador.Variable = Variable; Contador.Valor = 1; oEntidades.Contadores.AddObject(Contador); } else { Contador.Valor++; } oEntidades.SaveChanges(); return(((int)Contador.Valor).ToString("000000")); } } catch (Exception ex) { string x = ex.Message; } return(""); }
public static Factura Item(FeriaEntities db, string id) { var item = (from x in db.Facturas where (x.IdFactura == id) select x).FirstOrDefault(); return(item); }
public static Ingrediente Item(FeriaEntities db, string id) { var item = (from x in db.Ingredientes where (x.IdIngrediente == id) select x).FirstOrDefault(); return(item); }
public static MesasAbierta MesaAbiertaItem(FeriaEntities db, MesasAbierta mesasAbierta) { var q = from p in db.MesasAbiertas where p.IdMesaAbierta == mesasAbierta.IdMesaAbierta select p; return(q.FirstOrDefault()); }
public static Traslado Item(FeriaEntities db, string id) { var item = (from x in db.Traslados where (x.IdTraslado == id) select x).FirstOrDefault(); return(item); }
public static Plato ItemxCodgo(FeriaEntities db, string codigo) { var item = (from x in db.Platos where x.Codigo == codigo select x).FirstOrDefault(); return(item); }
public static LibroVenta Item(FeriaEntities db, string IdLibroVentas) { var q = from p in db.LibroVentas where p.IdLibroVentas == IdLibroVentas select p; return(q.FirstOrDefault()); }
public static Parametro parametros() { using (var db = new FeriaEntities()) { Parametro p = db.Parametros.FirstOrDefault(); return(p); } }
public static Proveedore Item(FeriaEntities db, string cedularif) { var q = from p in db.Proveedores orderby p.RazonSocial where p.CedulaRif == cedularif select p; return(q.FirstOrDefault()); }
public static List <Proveedore> getItems(FeriaEntities db, string texto) { var q = from p in db.Proveedores orderby p.RazonSocial where (p.CedulaRif.Contains(texto) || p.RazonSocial.Contains(texto) || texto.Length == 0) select p; return(q.ToList()); }
public static List <LibroVenta> getItems(FeriaEntities db, int mes, int año) { var q = from p in db.LibroVentas orderby p.Fecha where p.Mes == mes && p.Año == año select p; return(q.ToList()); }
public static List <Mesa> getItems(FeriaEntities db, string texto) { var q = from p in db.Mesas orderby p.Descripcion where (p.Descripcion.Contains(texto) || p.Ubicacion.Contains(texto) || texto.Length == 0) select p; return(q.ToList()); }
public static Mesa Item(FeriaEntities db, string ID) { var q = from p in db.Mesas orderby p.Descripcion where p.IdMesa == ID select p; return(q.FirstOrDefault()); }
public static List <Ingrediente> getItems(FeriaEntities db, string texto) { var mplatos = (from x in db.Ingredientes orderby x.Descripcion where (x.Descripcion.Contains(texto) || texto.Length == 0) && x.Activo == true select x).ToList(); return(mplatos); }
public static List <Factura> getFacturasPendientes(FeriaEntities db, string texto) { var mFacturas = (from x in db.Facturas orderby x.IdFactura where (x.Tipo == "PENDIENTE") select x).ToList(); return(mFacturas); }
public static List <Usuario> getItems(FeriaEntities db, string texto, string Tipo) { var q = from p in db.Usuarios orderby p.Nombre where (p.Cedula.Contains(texto) || p.Nombre.Contains(texto) || texto.Length == 0) && p.Activo == true && p.TipoUsuario == Tipo select p; return(q.ToList()); }
public static List <Plato> getItems(FeriaEntities db, string texto) { var mplatos = (from x in db.Platos orderby x.Codigo where (x.Codigo.Contains(texto) || x.Descripcion.Contains(texto) || x.Grupo.Contains(texto) || texto.Length == 0) select x).ToList(); return(mplatos); }
public static List <string> getProveedores() { using (var db = new FeriaEntities()) { var q = from p in db.Proveedores orderby p.RazonSocial select p.RazonSocial; return(q.ToList()); } }
public static Usuario Item(string Usuario, string Contraseña) { using (var db = new FeriaEntities()) { var q = from p in db.Usuarios where p.Nombre == Usuario && p.Clave == Contraseña && p.Activo == true select p; return(q.FirstOrDefault()); } }