/// <summary> /// Gets all records with the ID of the selected order, which is kept in the txt file. /// Adds them to the list. /// </summary> /// <returns></returns> public List <tblRecord> GetRecords() { string id = ""; using (StreamReader sr = new StreamReader("../../Order.txt")) { string line; while ((line = sr.ReadLine()) != null) { id = line; } } try { using (RestaurantEntities context = new RestaurantEntities()) { int i = Convert.ToInt32(id); List <tblRecord> list = new List <tblRecord>(); list = (from x in context.tblRecords where x.OrderID == i select x).ToList(); return(list); } } catch (Exception ex) { System.Diagnostics.Debug.Write("Exception" + ex.Message.ToString()); return(null); } }
public override OperationResult execute(RestaurantEntities entiteti) { entiteti.MenadzerUpdate(this.menadzer.Id, this.menadzer.Ime, this.menadzer.Prezime, this.menadzer.Iskustvo); return(new OperationResult { Success = true }); }
void btnBuscar_Click(object sender, EventArgs e) { db = new RestaurantEntities(); Lista = FactoryPlatos.getItems(db, this.txtBuscar.Text); this.bs.DataSource = Lista; this.bs.ResetBindings(true); }
public static OrderModel GetOrderToCancel(Siparis s) { using (RestaurantEntities db = new RestaurantEntities()) { return(db.Siparis.Find(s.SiparisID).ConvertToOrderModel()); } }
public tblOrder LoadOrder(int id) { using (var conn = new RestaurantEntities()) { return(conn.tblOrders.FirstOrDefault(o => o.OrderID == id)); } }
public static string GetMaxDiario(string Variable) { try { string Fecha = DateTime.Today.ToShortDateString(); using (var oEntidades = new RestaurantEntities()) { Contadore Contador = oEntidades.Contadores.FirstOrDefault(x => x.Variable == Variable + Fecha); if (Contador == null) { Contador = new Contadore(); Contador.Variable = Variable + Fecha; Contador.Valor = 1; oEntidades.Contadores.AddObject(Contador); } else { Contador.Valor++; } oEntidades.SaveChanges(); return(((int)Contador.Valor).ToString("000000")); } } catch (Exception ex) { Basicas.ManejarError(ex); } return(""); }
private void Busqueda() { db = new RestaurantEntities(); Lista = FactoryMesas.getItems(db, this.txtBuscar.Text); this.bs.DataSource = Lista; this.bs.ResetBindings(true); }
public List <T> GetAll() { using (RestaurantEntities context = new RestaurantEntities()) { return(context.Set <T>().ToList()); } }
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 RestaurantEntities()) { 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 static Calisan GetEmployeeByID(int ID) { using (RestaurantEntities db = new RestaurantEntities()) { return(db.Calisan.Find(ID)); } }
public override OperationResult execute(RestaurantEntities restoran) { IEnumerable <PozicijeItem> pozicije = null; if (this.Id == 0) { pozicije = from poz in restoran.Pozicijes select new PozicijeItem { idPozicije = poz.Id_pozicija, NazivPozicije = poz.naziv }; } else { pozicije = from poz in restoran.Pozicijes where poz.Id_pozicija == this.Id select new PozicijeItem { idPozicije = poz.Id_pozicija, NazivPozicije = poz.naziv }; } PozicijeResult rez = new PozicijeResult(); rez.pozicije = pozicije.ToList(); rez.Success = true; return(rez); }
public List <ProductoVariante> GetLista(TipoProducto tipo) { List <ProductoVariante> lista = null; try { using (RestaurantEntities context = new RestaurantEntities()) { context.Configuration.LazyLoadingEnabled = true; // context.Database.Log = s => Log.Write(s); context.Configuration.LazyLoadingEnabled = false; if (tipo == null) { lista = context.ProductoVariante.ToList(); } else { lista = context.ProductoVariante.Where(pr => pr.id_tipo_producto == tipo.id_tipo_producto).OrderBy(p => p.nombre_variante).ToList(); return(lista); } } return(lista); } catch (Exception e) { Log.Write("Error " + e.Message); return(lista); } }
public override OperationResult execute(RestaurantEntities restoran) { IEnumerable <BrojLjudiItem> brojLJudi = null; if (this.Id == 0) { brojLJudi = from ljudi in restoran.brojLjudis select new BrojLjudiItem { IdBroj = ljudi.IdBrojLjudi, Broj = ljudi.brojLjudi1 }; } else { brojLJudi = from ljudi in restoran.brojLjudis where ljudi.IdBrojLjudi == this.Id select new BrojLjudiItem { IdBroj = ljudi.IdBrojLjudi, Broj = ljudi.brojLjudi1 }; } BrojLjudiResult rez = new BrojLjudiResult(); rez.brojLjudi = brojLJudi.ToList(); rez.Success = true; return(rez); }
public List <RegistroProducto> GetLista(DateTime date, DateTime date2) { List <RegistroProducto> lista = null; try { using (RestaurantEntities db = new RestaurantEntities()) { var query = (from c in db.RegistroProducto group c by c.id_producto into g select new { id_producto = g.Key, Sum = g.Sum(oi => oi.cantidad * oi.precio_tipo), }).OrderBy(m => m.Sum).ToList(); //return query; lista = db.RegistroProducto.Where(m => m.fecha >= date && m.fecha <= date2).OrderBy(m => m.nombre_producto).ToList(); return(lista); } } catch (Exception e) { Log.Write("Error " + e.Message); return(null); } }
public override OperationResult execute(RestaurantEntities restoran) { IEnumerable <SastojciItem> sastojci = null; if (this.Id == 0) { sastojci = from sastojak in restoran.Sastojcis select new SastojciItem { IdSastojka = sastojak.Id_sastojka, NazivSastojka = sastojak.naziv }; } else { sastojci = from sastojak in restoran.Sastojcis where sastojak.Id_sastojka == this.Id select new SastojciItem { IdSastojka = sastojak.Id_sastojka, NazivSastojka = sastojak.naziv }; } SastojciResult rez = new SastojciResult(); rez.sastojci = sastojci.ToList(); rez.Success = true; return(rez); }
public override OperationResult execute(RestaurantEntities restoran) { IEnumerable <KuvariPozicijaItem> kuvariPozicije = null; if (this.Id == 0) { kuvariPozicije = from kuvariP in restoran.Kuvaris join pozicije in restoran.Pozicijes on kuvariP.id_pozicija equals pozicije.Id_pozicija select new KuvariPozicijaItem { IdKuvar = kuvariP.Id_kuvara, Ime = kuvariP.ime, Slika = kuvariP.slika, idPozicije = kuvariP.id_pozicija, NazivPozicije = pozicije.naziv }; } else { kuvariPozicije = from kuvariP in restoran.Kuvaris join pozicije in restoran.Pozicijes on kuvariP.id_pozicija equals pozicije.Id_pozicija where kuvariP.Id_kuvara == this.id select new KuvariPozicijaItem { IdKuvar = kuvariP.Id_kuvara, Ime = kuvariP.ime, Slika = kuvariP.slika, idPozicije = kuvariP.id_pozicija, NazivPozicije = pozicije.naziv }; } KuvariPozicijeResult rez = new KuvariPozicijeResult(); rez.kuvariPoz = kuvariPozicije.ToList(); rez.Success = true; return(rez); }
public static string GetMax(string Variable) { try { using (var oEntidades = new RestaurantEntities()) { 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 void LibroDeVentas() { FrmMesyAño f = new FrmMesyAño(); f.Text = "Libro de Ventas"; f.ShowDialog(); if (f.DialogResult != System.Windows.Forms.DialogResult.OK) { return; } using (var db = new RestaurantEntities()) { int Mes = f.Mes; int Año = f.Año; var consulta = from q in db.Facturas where (q.Fecha.Value.Month == Mes && q.Fecha.Value.Year == f.Año) && q.Tipo == "FACTURA" orderby q.Numero select q; reportViewer1.ProcessingMode = ProcessingMode.Local; this.reportViewer1.LocalReport.ReportPath = Application.StartupPath + "\\Reportes\\LibroDeVentas.rdlc"; this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("LibroVentas", consulta.ToList())); this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Parametros", new Parametro[] { Basicas.parametros() })); this.reportViewer1.LocalReport.SetParameters(new ReportParameter("Periodo", string.Format("Mes {0} Año {1}", Mes, Año))); this.reportViewer1.RefreshReport(); this.ShowDialog(); } }
public static int GetContador(string Variable) { try { using (var oEntidades = new RestaurantEntities()) { 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 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 RestaurantEntities()) { int Mes = f.Mes; int Año = f.Año; var consulta = from q in db.LibroCompras where (q.Fecha.Value.Month == Mes && q.Fecha.Value.Year == f.Año) 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 OrderModel GetOrderByID(int siparisID) { using (RestaurantEntities db = new RestaurantEntities()) { return(db.Siparis.Find(siparisID).ConvertToOrderModel()); } }
//System.Data.Objects.ObjectParameter idJelaParametar = new System.Data.Objects.ObjectParameter("idJela", System.Type.GetType("System.Int32")); public override OperationResult execute(RestaurantEntities entiteti) { entiteti.JelaInsert(this.jelo.NazivJela, this.jelo.Slika, this.jelo.Cena, this.jelo.Akcija); return(new OperationResult { Success = true }); }
public static bool UpdateOrderBill(int masaID) { using (RestaurantEntities db = new RestaurantEntities()) { var f = GetLastAddedOrder(masaID).Item1; var liste = FoodNavigateBLL.GetLastOrderFoods(f.SiparisID); decimal bill = 0; foreach (var item in liste) { bill += item.yemek.YemekFiyati; } f.Tutari = bill; if (CRUD(f.ConvertToSiparis(), EntityState.Modified).Item1) { return(true); } else { return(false); } } }
public override OperationResult execute(RestaurantEntities entiteti) { entiteti.Jela_SastojciInsert(this.jelosastojak.IdJela, this.jelosastojak.IdSastojka); return(new OperationResult { Success = true }); }
public tblMeal LoadMeal(int id) { using (var conn = new RestaurantEntities()) { return(conn.tblMeals.FirstOrDefault(m => m.MealID == id)); } }
public override OperationResult execute(RestaurantEntities restoran) { IEnumerable <JelaSastojciItem> jelaSastojci = null; if (this.jelosastojak.IdJela == 0) { jelaSastojci = from jelasastojci1 in restoran.Jela_Sastojci join jela in restoran.Jelas on jelasastojci1.Id_jela equals jela.Id_jela join sastojci in restoran.Sastojcis on jelasastojci1.Id_sastojka equals sastojci.Id_sastojka select new JelaSastojciItem { IdJela = jela.Id_jela, Naziv = jela.naziv, Slika = jela.slika, Cena = jela.cena, akcija = jela.akcija, IdSastojka = sastojci.Id_sastojka, NazivSastojka = sastojci.naziv }; } if (this.jelosastojak.IdJela != 0) { jelaSastojci = from jelasastojci1 in restoran.Jela_Sastojci join jela in restoran.Jelas on jelasastojci1.Id_jela equals jela.Id_jela join sastojci in restoran.Sastojcis on jelasastojci1.Id_sastojka equals sastojci.Id_sastojka where jela.Id_jela == this.jelosastojak.IdJela select new JelaSastojciItem { IdJela = jela.Id_jela, Naziv = jela.naziv, Slika = jela.slika, Cena = jela.cena, akcija = jela.akcija, IdSastojka = sastojci.Id_sastojka, NazivSastojka = sastojci.naziv }; } return(new JelaSastojciResult { Success = true, JelaSastojci = jelaSastojci.ToList() }); }
public async Task EditAsync(int id, Product updateItem) { using (var db = new RestaurantEntities()) { var product = await GetByIdAsync(id); if (product == null) { throw new KeyNotFoundException("A product withthe id of " + id + "does not exisst in the data store"); } product.Name = updateItem.Name; product.CategoryId = updateItem.CategoryId; product.Price = updateItem.Price; product.ImageUrl = updateItem.ImageUrl; product.SKU = updateItem.SKU; product.Count = updateItem.Count; product.Discount = updateItem.Discount; product.Content = updateItem.Content; product.FromDateDiscount = updateItem.FromDateDiscount; product.ToDateDiscount = updateItem.ToDateDiscount; product.AuthorId = updateItem.AuthorId; db.SaveChanges(); } }
public bool Eliminar(Producto producto) { if (producto.id_producto <= 0) { return(false); } try { using (RestaurantEntities db = new RestaurantEntities()) { // TODO agregar un log a todo esto // context.Database.Log = s => Log.Write(s); // context.Entry(producto).State = EntityState.Deleted; // TODO antes de eliminar verificar que no se encuentre en nimguna orden producto = db.Producto.Find(producto.id_producto); db.Producto.Remove(producto); db.SaveChanges(); } return(true); } catch (Exception e) { Log.Write("Error " + e.Message); return(false); } }
private void Login() { Person loggedUser; if (Email == "" || Email == null) { MessageBox.Show("Please enter an email"); return; } if (password == "" || password == null) { MessageBox.Show("Please enter a password"); return; } using (var tables = new RestaurantEntities()) { var users = tables.SpFindUserByEmailPassword(Email, Password).ToList(); if (users.Count == 0) { MessageBox.Show("Nonexistent user"); return; } loggedUser = users[0]; } Application.Current.Windows[Application.Current.Windows.Count - 1].Close(); ProductsView view = new ProductsView(); view.DataContext = new ProductsViewModel(loggedUser); view.Show(); }
/// <summary> /// Adds new order to the DataBase. /// </summary> /// <param name="price"></param> /// <returns></returns> public tblOrder AddOrder(int price) { tblOrder order = new tblOrder(); try { using (RestaurantEntities context = new RestaurantEntities()) { order.JMBG = GetJmbg(); order.DateAndTime = DateTime.ParseExact(DateTime.Now.ToString("yyyy-MM-dd-hh-mm"), "yyyy-MM-dd-hh-mm", System.Globalization.CultureInfo.InvariantCulture); order.StatusID = 1; order.Price = price; context.tblOrders.Add(order); context.SaveChanges(); int id = order.OrderID; order.OrderID = id; } } catch (Exception ex) { System.Diagnostics.Debug.Write("Exception" + ex.Message.ToString()); return(null); } return(order); }