public ActionResult Borrar(int pro_id)
        {
            if (Session["user"] == null)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                Usuario user = (Usuario)Session["user"];
                if (user.tipo == 0)
                {
                    var service = new WebService.WebServiceSoapClient();
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    var datos = js.Deserialize<Producto>(service.product_cargarProducto(pro_id));
                    Producto product = new Producto();
                    product.pro_nombre = datos.pro_nombre;
                    product.pro_precio = datos.pro_precio;
                    product.pro_estado = product.pro_estado;
                    product.pro_id = datos.pro_id;
                    return View(product);
                }
                else
                {
                    return RedirectToAction("Index", "Home");

                }
            }
        }
        public ActionResult Cargar(int conv_id)
        {
            if (Session["user"] == null)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                Usuario user = (Usuario)Session["user"];
                if (user.tipo == 0 || user.tipo == 1)
                {
                    var service = new WebService.WebServiceSoapClient();
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    var datos = js.Deserialize<List<Conv_Message>>(service.mes_cargarMensajes(conv_id));
                    MensajeFinal data = new MensajeFinal();
                    data.messages = datos;
                    data.user = user;
                    return View(data);
                }
                else
                {
                    return RedirectToAction("Index", "Home");

                }
            }
        }
        public ActionResult Cargar(int cita_id)
        {
            if (Session["user"] == null)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                Usuario user = (Usuario)Session["user"];
                if (user.tipo == 0)
                {
                    var service = new WebService.WebServiceSoapClient();
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    var datos = js.Deserialize<Cita_Usuario>(service.cita_cargarCita(cita_id));
                    Cita_Usuario cita = new Cita_Usuario();
                    cita.username = datos.username;
                    cita.user_info = datos.user_info;
                    cita.cita_id = datos.cita_id;
                    cita.cita_estado = datos.cita_id;
                    cita.cita_fecha = datos.cita_fecha;
                    return View(cita);
                }
                else
                {
                    return RedirectToAction("Index", "Home");

                }
            }
        }
 public ActionResult Borrar(string username)
 {
     if (Session["user"] == null)
     {
         return RedirectToAction("Index", "Home");
     }
     else
     {
         Usuario user = (Usuario)Session["user"];
         if (user.tipo == 0)
         {
             var service = new WebService.WebServiceSoapClient();
             JavaScriptSerializer js = new JavaScriptSerializer();
             var datos = js.Deserialize<Usuario>(service.user_CargarUsuario(username));
             Usuario usuario = new Usuario();
             usuario.username = datos.username;
             usuario.nombre = datos.nombre;
             usuario.apellidos = datos.apellidos;
             usuario.tipo = datos.tipo;
             return View(user);
         }
         else
         {
             return RedirectToAction("Index", "Home");
         }
     }
 }
        // GET: Conversaciones
        public ActionResult Index()
        {
            if (Session["user"] == null)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                Usuario user = (Usuario)Session["user"];
                if (user.tipo == 0 || user.tipo==1)
                {
                    var service = new WebService.WebServiceSoapClient();
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    var datos = js.Deserialize<List<Conversaciones>>(service.conv_CargarConversacionesUsuario(user.username));
                    List<Conversaciones> finalList = new List<Conversaciones>();
                    foreach(var item in datos){
                        Conversaciones conv = item;
                        if (item.username2 == user.username)
                        {
                            var aux = item.username1;
                            conv.username1 = conv.username2;
                            conv.username2 = aux;
                        }
                        finalList.Add(conv);
                    }
                    return View(finalList);
                }
                else
                {
                    return RedirectToAction("Index", "Home");

                }
            }
        }
 public ActionResult BorradoConfirmed(string username)
 {
     if (ModelState.IsValid)
     {
         var service = new WebService.WebServiceSoapClient();
         JavaScriptSerializer js = new JavaScriptSerializer();
         var datos = js.Deserialize<Respuesta>(service.user_delete(username));
         ViewBag.Message = datos.response;
     }
     return RedirectToAction("Index");
 }
 public ActionResult BorradoConfirmed(int pro_id)
 {
     if (ModelState.IsValid)
     {
         var service = new WebService.WebServiceSoapClient();
         JavaScriptSerializer js = new JavaScriptSerializer();
         var datos = js.Deserialize<Respuesta>(service.product_eliminarCliente(pro_id));
         ViewBag.Message = datos.response;
     }
     return RedirectToAction("Index");
 }
 public ActionResult Conversar(string search)
 {
     Usuario user = (Usuario)Session["user"];
     var service = new WebService.WebServiceSoapClient();
     JavaScriptSerializer js=new JavaScriptSerializer();
     var conv = js.Deserialize<Conversaciones>(service.conv_verificarConversacion(user.username, search));
     if (conv.conv_id == 0)
     {
         service.conv_crearConversacion(user.username, search,"");
     }
     js.Deserialize<Conversaciones>(service.conv_verificarConversacion(user.username, search));
     return RedirectToAction("Cargar?conv_id="+conv.conv_id, "Conversaciones");
 }
Beispiel #9
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            EQ_DomainContext context = new EQ_DomainContext();

            this.busyIndicator1.IsBusy = true;
            EntityQuery<tblUser> q = (from n in context.GetTblUserQuery() where n.UserID == txtUserID.Text && n.Password == txtPassword.Password select n);

            LoadOperation<tblUser> lo = context.Load<tblUser>(q);
            lo.Completed += (s, a) =>
            {
                if (lo.Error != null)
                {
                    MessageBox.Show(lo.Error.Message);
                    this.busyIndicator1.IsBusy = false;
                    return;
                }

                tblUser user = lo.Entities.FirstOrDefault<tblUser>();
                if (user == null)
                {
                    MessageBox.Show("帳號密碼錯誤 !");
                    this.busyIndicator1.IsBusy = false;
                    return;
                };

               // slDBManager.WebContext client = new WebContext();

                WebService.WebServiceSoapClient client = new WebService.WebServiceSoapClient();

                client.RegisterSessionCompleted += (ss, aa) =>
                {
                    if (aa.Error != null)
                    {
                        MessageBox.Show(aa.Error.Message);
                        this.busyIndicator1.IsBusy = false;
                        return;
                    }
                    this.busyIndicator1.IsBusy = true;
                    this.NavigationService.Navigate(new Uri("/EqManager.xaml?userid="+user.UserID+"&username="+user.UserName,UriKind.Relative));

                };

                client.RegisterSessionAsync(user.UserID);

            };
        }
 public ActionResult Index([Bind(Include = "username,password")] Usuario usuario)
 {
     var service = new WebService.WebServiceSoapClient();
     JavaScriptSerializer js = new JavaScriptSerializer();
     var response = js.Deserialize<Respuesta_Usuario>(service.user_Login(usuario.username, usuario.password));
     if (response.response.Equals("yes"))
     {
         Session["user"] = response.user;
         if (response.user.tipo == 0)
         {
             return RedirectToAction("Menu");
         }
         else
         {
             return RedirectToAction("Cliente");
         }
     }
     else
     {
         return RedirectToAction("Index");
     }
 }
        public ActionResult Aprobadas()
        {
            if (Session["user"] == null)
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                Usuario user = (Usuario)Session["user"];
                if (user.tipo == 0)
                {
                    var service = new WebService.WebServiceSoapClient();
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    var datos = js.Deserialize<List<Cita_Usuario>>(service.cita_cargarCitasAprobadas());

                    return View(datos);
                }
                else
                {
                    return RedirectToAction("Index", "Home");

                }
            }
        }
 public JsonResult Aprobar(int cita_id)
 {
     var service = new WebService.WebServiceSoapClient();
     return Json(service.cita_aprobarCita(cita_id));
 }
 public ActionResult Send(int conv_id,string message,string username)
 {
     var service = new WebService.WebServiceSoapClient();
     return Json(service.mes_enviarmensaje(conv_id,message,username));
 }
 public ActionResult Pull(int conv_id)
 {
     var service = new WebService.WebServiceSoapClient();
     return Json(service.mes_cargarMensajes(conv_id));
 }
 public ActionResult NoSpam(string username, int conv_id)
 {
     var service = new WebService.WebServiceSoapClient();
     return Json(service.conv_quitarSpam(username,conv_id));
 }
 public ActionResult Index(int tipo)
 {
     if (ModelState.IsValid)
     {
         if (tipo == null)
         {
             return RedirectToAction("Index");
         }
         else
         {
             var service = new WebService.WebServiceSoapClient();
             JavaScriptSerializer js = new JavaScriptSerializer();
             var datos = js.Deserialize<List<Usuario>>(service.user_CargarUsuarios(tipo));
             return View(datos);
         }
     }
     return View();
 }
        public ActionResult Create([Bind(Include = "pro_nombre,pro_precio,pro_estado")] Producto product)
        {
            if (ModelState.IsValid)
            {
                var service = new WebService.WebServiceSoapClient();
                JavaScriptSerializer js = new JavaScriptSerializer();
                var datos = js.Deserialize<Respuesta>(service.product_guardarProducto(product.pro_nombre, product.pro_precio, product.pro_estado, product.pro_foto));
                ViewBag.Message = datos.response;

            }
            else
            {
                ViewBag.Message = "Llena los datos correctamente";
            }
            return View();
        }
 public JsonResult Ajax(string user)
 {
     var service = new WebService.WebServiceSoapClient();
     return Json(service.user_Ajax(user));
 }
 public ActionResult PasswordConfirmed(string username, string password)
 {
     if (ModelState.IsValid)
     {
         var service = new WebService.WebServiceSoapClient();
         JavaScriptSerializer js = new JavaScriptSerializer();
         var datos = js.Deserialize<Respuesta>(service.user_CambiarContraseña(username, password));
         ViewBag.Message = datos.response;
         return RedirectToAction("Index");
     }
     return View();
 }
 public JsonResult EditProduct(int pro_id,string pro_nombre,int pro_precio,int pro_estado)
 {
     var service = new WebService.WebServiceSoapClient();
     return Json(service.product_editarProducto(pro_id,pro_nombre,pro_precio,pro_estado,null));
 }
        public ActionResult SolicitarConfirmada(string fecha,string hora)
        {
            if (ModelState.IsValid)
            {
                var service = new WebService.WebServiceSoapClient();
                JavaScriptSerializer js = new JavaScriptSerializer();

                Usuario user = (Usuario)Session["user"];
                var data = js.Deserialize<Respuesta>(service.cita_solicitarCita(user.username, fecha,hora));
                ViewBag.Message = data.response;
            }
            else
            {
                ViewBag.Message = "Llena los datos correctamente";
            }
            return View();
        }
        public ActionResult Create([Bind(Include = "username,password,nombre,apellidos,tipo")] Usuario user)
        {
            if (ModelState.IsValid)
            {
                var service = new WebService.WebServiceSoapClient();
                JavaScriptSerializer js = new JavaScriptSerializer();
                var datos = js.Deserialize<Respuesta>(service.user_Save(user.username, user.password, user.nombre, user.apellidos, user.tipo));
                ViewBag.Message = datos.response;

            }
            return View();
        }