Esempio n. 1
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");
 }
Esempio n. 2
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"); ;
        }
Esempio n. 3
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");
        }