Esempio n. 1
0
        public static void ConexionUsuario(UsuarioInfo user)
        {
            try
            {
                SqlConnection sql = new SqlConnection(@"Data Source=(local)\SQLEXPRESS;Initial Catalog=TinderForWorkDB;Integrated Security=True");
                sql.Open();

                SqlCommand cmd = sql.CreateCommand();
                cmd.CommandText = "InsertUser";
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@Matricula", user.Matricula);
                cmd.Parameters.AddWithValue("@Nombre", user.Nombre);
                cmd.Parameters.AddWithValue("@ApellidoP", user.ApellidoP);
                cmd.Parameters.AddWithValue("@ApellidoM", user.ApellidoM);
                cmd.Parameters.AddWithValue("@Contrasena", user.Contrasena);
                cmd.Parameters.AddWithValue("@Correo", user.Correo);
                cmd.Parameters.AddWithValue("@Carrera", user.Carrera);
                cmd.Parameters.AddWithValue("@Campus", user.Campus);
                cmd.Parameters.AddWithValue("@StatusOcupado", user.StatusOcupado);
                cmd.Parameters.AddWithValue("@Telefono", user.Telefono);
                cmd.ExecuteNonQuery();
                sql.Close();
            }
            catch (SqlException ex)
            {
                Console.WriteLine("SQL Error" + ex.Message.ToString());
            }
        }
Esempio n. 2
0
        public static List <UsuarioInfo> NextUser(int index, int ProjectID)
        {
            List <UsuarioInfo> list       = new List <UsuarioInfo>();
            SqlConnection      connection = new SqlConnection(@"Data Source=(local)\SQLEXPRESS;Initial Catalog=TinderForWorkDB;Integrated Security=True");

            connection.Open();
            {
                SqlCommand cmd  = connection.CreateCommand();
                DataTable  Data = new DataTable();
                cmd.CommandText = "ViewPossibleUsers";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@ProjectID", ProjectID);


                cmd.ExecuteNonQuery();

                SqlDataReader dataReader = cmd.ExecuteReader();


                while (dataReader.Read())
                {
                    UsuarioInfo temp = new UsuarioInfo();
                    // dataReader.Read();
                    temp.Nombre        = dataReader["Nombre"].ToString();
                    temp.ApellidoM     = dataReader["ApellidoM"].ToString();
                    temp.ApellidoP     = dataReader["ApellidoP"].ToString();
                    temp.Carrera       = Convert.ToInt32(dataReader["Carrera"].ToString());
                    temp.Campus        = dataReader["Campus"].ToString();
                    temp.StatusOcupado = Convert.ToBoolean(dataReader["StatusOcupado"]);
                    list.Add(temp);
                    //dataReader.NextResult();
                }

                /*else
                 * {
                 *  index = 0;
                 * }*/
                dataReader.Close();
                connection.Close();
                return(list);
            }
        }