Пример #1
0
 protected void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         int valCola = ElegirCola();
         using (SolicitudesEntities contex = new SolicitudesEntities())
         {
             Usuario objUsuario = new Usuario();
             objUsuario.nombre   = txtNombre.Text.Trim();
             objUsuario.cola     = valCola;
             objUsuario.atendido = false;
             contex.Usuarios.Add(objUsuario);
             contex.SaveChanges();
             if (valCola == 1)
             {
                 micola1.Add(objUsuario);
             }
             else
             {
                 micola2.Add(objUsuario);
             }
             ObtenerSolicitudes();
             txtNombre.Text = string.Empty;
             upTexto.Update();
             upColas.Update();
             upCola2.Update();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #2
0
        private void ObtenerSolicitudes()
        {
            try
            {
                using (SolicitudesEntities contex = new SolicitudesEntities())
                {
                    if (contex.Usuarios.Count() > 0)
                    {
                        var cola1 = (from em in contex.Usuarios
                                     where em.atendido == false && em.cola == 1
                                     select em).ToList();

                        var cola2 = (from em in contex.Usuarios
                                     where em.atendido == false && em.cola == 2
                                     select em).ToList();

                        foreach (var item in cola1)
                        {
                            micola1.Add(item);
                        }
                        foreach (var item in cola2)
                        {
                            micola2.Add(item);
                        }
                        Session["cola1"] = cola1;
                        Session["cola2"] = cola2;

                        gdCola1.DataSource = cola1;
                        gdCola1.DataBind();

                        gdCola2.DataSource = cola2;
                        gdCola2.DataBind();

                        upColas.Update();
                        upCola2.Update();
                    }
                    else
                    {
                        gdCola1.DataSource = null;
                        gdCola2.DataSource = null;
                        gdCola1.DataBind();
                        gdCola2.DataBind();
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #3
0
 public void AtenderCola2()
 {
     if (micola2.Count() > 0)
     {
         Usuario objUsuario = new Usuario();
         objUsuario = micola2[0];
         using (SolicitudesEntities contex = new SolicitudesEntities())
         {
             var usu = contex.Usuarios.First(a => a.id == objUsuario.id);
             usu.atendido = true;
             contex.SaveChanges();
             micola2.Remove(objUsuario);
             gdCola2.DataSource = micola2;
             gdCola2.DataBind();
             upCola2.Update();
         }
     }
 }