Ejemplo n.º 1
0
        public static bool Delete(UploadsType uploadtype)
        {
            // 1) Create the connection
            SqlConnection connection = new SqlConnection();

            connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["SqlConnection"].ConnectionString;

            // 2) Open the connection
            connection.Open();

            // 3) Execute query
            SqlCommand command = new SqlCommand();

            command.Connection  = connection;
            command.CommandText = string.Format("delete from uploadstype where id='{0}'", uploadtype.Id);

            int rowsAffected = command.ExecuteNonQuery();

            // 4) Close the connection
            connection.Close();

            if (rowsAffected == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 2
0
        public static List <UploadsType> GetAll()
        {
            List <UploadsType> uploadtypes = new List <UploadsType>();
            // 1) Create the connection
            SqlConnection connection = new SqlConnection();

            connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["SqlConnection"].ConnectionString;

            // 2) Open the connection
            connection.Open();

            // 3) Execute query
            SqlCommand command = new SqlCommand();

            command.Connection  = connection;
            command.CommandText = string.Format("select * from UploadsType");

            SqlDataReader dataReader = command.ExecuteReader();

            while (dataReader.Read())
            {
                UploadsType uploadtype = new UploadsType();

                uploadtype.Id   = Convert.ToInt32(dataReader["Id"]);
                uploadtype.Name = Convert.ToString(dataReader["Name"]);

                uploadtypes.Add(uploadtype);
            }
            // 4) Close the connection
            connection.Close();


            return(uploadtypes);
        }
Ejemplo n.º 3
0
        public static UploadsType GetSingle(int Id)
        {
            UploadsType uploadtype = null;
            // 1) Create the connection
            SqlConnection connection = new SqlConnection();

            connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["SqlConnection"].ConnectionString;

            // 2) Open the connection
            connection.Open();

            // 3) Execute query
            SqlCommand command = new SqlCommand();

            command.Connection  = connection;
            command.CommandText = string.Format("select * from UploadsType where id = '{0}'", Id);

            SqlDataReader dataReader = command.ExecuteReader();

            if (dataReader.Read())
            {
                uploadtype = new UploadsType();

                uploadtype.Id   = Convert.ToInt32(dataReader["Id"]);
                uploadtype.Name = Convert.ToString(dataReader["Name"]);
            }

            // 4) Close the connection
            connection.Close();

            return(uploadtype);
        }
Ejemplo n.º 4
0
        public static bool Add(UploadsType uploadtype)
        {
            // 1) Create the connection
            SqlConnection connection = new SqlConnection();

            connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["SqlConnection"].ConnectionString;

            // 2) Open the connection
            connection.Open();

            // 3) Execute query
            SqlCommand command = new SqlCommand();

            command.Connection  = connection;
            command.CommandText = string.Format("insert into uploadstype(name) values('{0}')", uploadtype.Name);

            int rowsAffected = command.ExecuteNonQuery();

            // 4) Close the connection
            connection.Close();

            if (rowsAffected == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 5
0
 public static bool Delete(UploadsType updatetype)
 {
     return(DataAccess.UploadsTypeDA.Delete(updatetype));
 }
Ejemplo n.º 6
0
 public static bool Add(UploadsType updatetype)
 {
     return(DataAccess.UploadsTypeDA.Add(updatetype));
 }