public bool ValidaUsuario() { try { using (RestauranteBaseContext db = new RestauranteBaseContext(RestauranteBaseContext.ConnectionString)) { if (!db.DatabaseExists()) { db.CreateDatabase(); } EMPLEADO emp = db.EMPLEADO.FirstOrDefault(); if (emp != null) { tbMozo.Text = "mozo: " + emp.EMP_LOGIN; return(true); } return(false); } } catch { return(false); } }
private void servicio_MesasDisponiblesCompleted(object sender, ServiceReference1.MesasDisponiblesCompletedEventArgs e) { try { XDocument xmlD = new XDocument(e.Result); xmlDocSocios = xmlD; using (RestauranteBaseContext ctx = new RestauranteBaseContext(RestauranteBaseContext.ConnectionString)) { if (!ctx.DatabaseExists()) { ctx.CreateDatabase(); } List <BaseLocal.MESA> ListaMesas = (from c in xmlDocSocios.Descendants("Table") select new BaseLocal.MESA { MESA_NUM = (Int16)c.Element("MESA_NUM"), MESA_CANTSILLAS = (Int16)c.Element("MESA_CANTSILLAS"), MESA_ESTADO = (String)c.Element("MESA_ESTADO"), REST_ID = (int)c.Element("REST_ID") }).ToList <BaseLocal.MESA>(); borrar_mesas(); foreach (BaseLocal.MESA mesa in ListaMesas) { ctx.MESA.InsertOnSubmit(mesa); } ctx.SubmitChanges(); ctx.Dispose(); } var qry = (from c in db.MESA where c.MESA_ESTADO == "OCUPADO" select c.MESA_NUM + " - " + c.MESA_ESTADO).ToList(); lbMesas.ItemsSource = qry; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void servicio_RecetasCompleted(object sender, ServiceReference1.RecetasCompletedEventArgs e) { XDocument xmlD = new XDocument(e.Result); xmlDocSocios = xmlD; using (RestauranteBaseContext ctx = new RestauranteBaseContext(RestauranteBaseContext.ConnectionString)) { if (!ctx.DatabaseExists()) { ctx.CreateDatabase(); } List <BaseLocal.PLATO> ListaPlato = (from c in xmlDocSocios.Descendants("Table") select new BaseLocal.PLATO { PLATO_ID = (Int16)c.Element("RECETA_ID"), PLATO_NOMBRE = (String)c.Element("RECETA_NOMBRE"), PLATO_PRECIO = (double)c.Element("RECETA_PRECIO"), }).ToList <BaseLocal.PLATO>(); borrar_platos(); foreach (PLATO plato in ListaPlato) { int length = plato.PLATO_NOMBRE.Length; if (length > 20) { plato.PLATO_NOMBRE = plato.PLATO_NOMBRE.Substring(0, 19); } } foreach (BaseLocal.PLATO plato in ListaPlato) { ctx.PLATO.InsertOnSubmit(plato); ctx.SubmitChanges(); } ctx.Dispose(); } }