示例#1
0
        public ActionResult EnviarMP()
        {
            Session["UserIDG"] = Session["UserIDG"];
            Session["UserID"] = Session["UserID"];
            Session["User"] = Session["User"];
            ViewBag.Message = "Mensaje Privado";
            User user = new User();
            Inbox inbox = new Inbox();
            int retorno = 0;
            string message = (string)Request["Mensaje"];
            string title = (string)Request["title"];
            string destiny = (string)Request["Destinatario"];
            int origen = (int)Session["UserID"];
            if (!user.Checkuser(destiny))
            {
                MessageBox.Show("No Existe Usuario Destino", "Invalido", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return Redirect("MP");
            }
            user = user.getUser(destiny);
            inbox = inbox.getInbox(user.id);
            DateTime thisDay = DateTime.Now;
            string date = thisDay.ToString();

            String sql = "Insert into mp (id_userfrom,id_inbox,title,check_read,messages,date_send)"
             + "values ('{0}','{1}','{2}','{3}','{4}','{5}')";

            using (SqlConnection connection = BD.getConnection())
            {
                SqlCommand Comando = new SqlCommand(string.Format(sql, origen, inbox.id, title, 0, message, date), connection);

                retorno = Comando.ExecuteNonQuery();
                connection.Close();

            }
            if (retorno > 0)
            {

                MessageBox.Show("Mensaje Enviado Con Exito!!", "Enviado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return Redirect("UserIn");
            }
            else
            {
                MessageBox.Show("No se pudo enviar el Mensaje", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

            }
            return Redirect("MP"); ;
        }
示例#2
0
 public ActionResult UserIn2()
 {
     ViewBag.Message = "Mi cuenta";
     string name = (string)Request["UserName"];
     string pass = (string)Request["PassUser"];
     User user = new User();
     user = user.getUser(name);
     Session["User"] = name;
     Session["UserID"] = user.id;
     Session["UserIDG"] = user.id_group;
     //MessageBox.Show("Bienvenido " + user.name,"Wellcome" ,MessageBoxButtons.OK);
     //return Redirect("UserIn");
     return Redirect("Categorias");
 }
示例#3
0
        public ActionResult VerMP(int id)
        {
            ViewBag.Message = "Inbox";
            Session["UserIDG"] = Session["UserIDG"];
            Session["UserID"] = Session["UserID"];
            Session["User"] = Session["User"];
            MP mp = new MP();
            mp = mp.getMPByID(id);
            User user = new User();
            user = user.getUserID(mp.id_from);
            List<string> items = new List<string>();
            items.Add(mp.title);
            items.Add(mp.date_send);
            items.Add(mp.msg);
            items.Add(user.name);
            ViewBag.Items = items;
            if (mp.check.Equals(1))
            {
                return View();
            }
            String sql = "Update  MP set check_read = '1' where id_message = '" + id + "'";
            int retorno = 0;
            using (SqlConnection connection = BD.getConnection())
            {
                SqlCommand Comando = new SqlCommand(string.Format(sql), connection);
                retorno = Comando.ExecuteNonQuery();
                connection.Close();

            }
            return View();
        }
示例#4
0
        public ActionResult Registracion2()
        {
            //G_User gu = new G_User();

            Session["UserIDG"] = Session["UserIDG"];
            Session["UserID"] = Session["UserID"];
            Session["User"] = Session["User"];
            int retorno = 0;
            ViewBag.Message = "Formulario de Registro";
            string user = (string)Request["UserName"];
            //int id_group = int.Parse(Request["UserType"]);
            string pass = (string)Request["PassUser"];
            string rpass = (string)Request["RPass"];
            string born = (string)Request["UserBorn"];
            string sex = (string)Request["UserSex"];
            string url = (string)Request["UserAvatar-Url"];
            DateTime thisDay = DateTime.Now;
            string date = thisDay.ToString();
            //int id_group = gu.getIDGUser(type);
            String sql = "Insert into Users (id_group,name,pass,n_comment,a_url,born,sex,date_r) "
            + "values  ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')";
            String sql2 = "Insert into inbox (id_user,messages_in,messages_out)"
                + "values ('{0}','{1}','{2}')";

            User u = new User();

            using (SqlConnection connection = BD.getConnection())
            {
                SqlCommand Comando = new SqlCommand(string.Format(sql,3,user,pass,0,url,born,sex,date), connection);

                retorno = Comando.ExecuteNonQuery();
                connection.Close();

            }
            if (retorno > 0)
            {
                u = u.getUser(user);

                using (SqlConnection connection = BD.getConnection())
                {
                    SqlCommand Comando = new SqlCommand(string.Format(sql2, u.id, 0, 0), connection);
                    retorno = Comando.ExecuteNonQuery();
                    connection.Close();
                }
                MessageBox.Show("Cliente Guardado Con Exito!!", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return Redirect("Login");
            }
            else
            {
                MessageBox.Show("No se pudo guardar el cliente", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

            }

            return Redirect("Registracion");
        }
示例#5
0
 public ActionResult Registracion()
 {
     Session["UserIDG"] = Session["UserIDG"];
     Session["UserID"] = Session["UserID"];
     Session["User"] = Session["User"];
     ViewBag.Message = "Formulario de Registro";
     User users = new User();
     List<string> names = users.getAllUsersNames();
     ViewBag.Items = names;
     ViewBag.Serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
     return View();
 }
示例#6
0
 public ActionResult MP(string name, string title)
 {
     ViewBag.Message = "Mensaje Privado";
     Session["UserIDG"] = Session["UserIDG"];
     Session["UserID"] = Session["UserID"];
     Session["User"] = Session["User"];
     ViewBag.name = name;
     ViewBag.Asunto = title;
     User users = new User();
     List<string> names = users.getAllUsersNames();
     ViewBag.Items = names;
     ViewBag.Serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
     return View();
 }
示例#7
0
 public ActionResult Login()
 {
     ViewBag.Message = "Login";
     Session["UserIDG"] = Session["UserIDG"];
     Session["UserID"] = Session["UserID"];
     Session["User"] = Session["User"];
     User users = new User();
     List<string> names = users.getAllUsersNamesNormal();
     List<string> passes = users.getAllUsersPass();
     ViewBag.Items = names;
     ViewBag.items2 = passes;
     ViewBag.Serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
     ViewBag.Serializer2 = new System.Web.Script.Serialization.JavaScriptSerializer();
     return View();
 }
示例#8
0
文件: User.cs 项目: TareasJM/Tarea2BD
        public User getUserID(int id)
        {
            String sql = "Select *From Users where id_user = '******'";
            User user = new User();
            using (SqlConnection connection = BD.getConnection())
            {
                SqlCommand Comando = new SqlCommand(string.Format(sql), connection);

                SqlDataReader reader = Comando.ExecuteReader();
                while (reader.Read())
                {

                    user.id = reader.GetInt32(0);
                    user.id_group = reader.GetInt32(1);
                    user.name = reader.GetString(2);
                    user.pass = reader.GetString(3);
                    user.comments = reader.GetInt32(4);
                    user.a_url = reader.GetString(5);
                    user.born = reader.GetString(6);
                    user.sex = reader.GetString(7);
                    user.date_r = reader.GetString(8);
                }
            }
            return user;
        }