예제 #1
0
 public static void Insert(Modelo.Icone icone)
 {
     Modelo.Icone icon = icone;
     try
     {
         if (Select(icon.id) == null)
         {
             using (connection = new SqlConnection(connectionString))
             {
                 connection.Open();
                 string     sqlUsuario = "INSERT INTO Icone(IconeUrl) VALUES (@iconeUrl)";
                 SqlCommand cmdUsuario = new SqlCommand(sqlUsuario, connection);
                 cmdUsuario.Parameters.AddWithValue("@iconeUrl", icone.iconeUrl);
                 cmdUsuario.ExecuteNonQuery();
             }
         }
         else
         {
             Update(icone);
         }
     }
     catch (SystemException)
     {
         throw;
     }
 }
예제 #2
0
 public static Modelo.Icone Select(int icone_id)
 {
     //instancia um novo usuario
     Modelo.Icone icone = null;
     try
     {
         using (connection = new SqlConnection(connectionString))
         {
             //abre a conexão
             connection.Open();
             string     sqlIcone = "SELECT * FROM Icone WHERE id = @id";
             SqlCommand cmdIcone = new SqlCommand(sqlIcone, connection);
             cmdIcone.Parameters.AddWithValue("@id", icone_id);
             SqlDataReader drIcones;
             using (drIcones = cmdIcone.ExecuteReader())
             {
                 if (drIcones.HasRows)
                 {
                     //lê os resultados
                     while (drIcones.Read())
                     {
                         int    idIcone  = (int)drIcones["id"];
                         string iconeUrl = (string)drIcones["IconeUrl"];
                         icone = new Modelo.Icone(idIcone, iconeUrl);
                     }
                 }
             }
         }
     }
     catch (SystemException)
     {
         throw;
     }
     return(icone);
 }
예제 #3
0
 protected void AddIcone_Click(object sender, EventArgs e)
 {
     uploadImage();
     Modelo.Icone jog = new Modelo.Icone("../Icone/" + UploadImage.FileName);
     DAL.DALIcons.Insert(jog);
     Response.Redirect("~/Administrador/Icone.aspx");
 }
예제 #4
0
 protected void getIcon()
 {
     if (!Page.IsPostBack)
     {
         this.dalicon = new DAL.DALIcons();
         this.icon    = DAL.DALIcons.Select(this.user.Icone_id);
     }
 }
예제 #5
0
 protected void setIcon()
 {
     if (Request.QueryString["icone"] != null)
     {
         this.dalicone = new DAL.DALIcons();
         this.icone    = DAL.DALIcons.Select(int.Parse(Request.QueryString["icone"]));
     }
 }
예제 #6
0
 protected void initPage()
 {
     if (Session["id"] != null)
     {
         if (Metodos.hasUser(Session["id"].ToString() ?? ""))
         {
             this.user = Metodos.getUser(Session["id"].ToString());
             this.icon = Metodos.getIcone(this.user.Icone_id);
         }
     }
     else
     {
         Response.Redirect("~/Public/Login.aspx");
     }
 }
예제 #7
0
 public static void Delete(Modelo.Icone icone)
 {
     try
     {
         using (connection = new SqlConnection(connectionString))
         {
             connection.Open();
             string     sqlIcone = "DELETE FROM Icone WHERE id = @id";
             SqlCommand cmdIcone = new SqlCommand(sqlIcone, connection);
             cmdIcone.Parameters.AddWithValue("@id", icone.id);
             cmdIcone.ExecuteNonQuery();
         }
     }
     catch (SystemException)
     {
         throw;
     }
 }
예제 #8
0
 public static void Update(Modelo.Icone icone)
 {
     try
     {
         using (connection = new SqlConnection(connectionString))
         {
             connection.Open();
             if (Select(icone.id) != icone)
             {
                 string     sqlUsuario = "UPDATE Icone SET IconeUrl = @iconeUrl WHERE id = @id";
                 SqlCommand cmdUsuario = new SqlCommand(sqlUsuario, connection);
                 cmdUsuario.Parameters.AddWithValue("@iconeUrl", icone.iconeUrl);
                 cmdUsuario.Parameters.AddWithValue("@id", icone.id);
                 cmdUsuario.ExecuteNonQuery();
             }
         }
     }
     catch (SystemException)
     {
         throw;
     }
 }
예제 #9
0
        public static List <Modelo.Icone> SelectAll()
        {
            Modelo.Icone        icone;
            List <Modelo.Icone> icones = new List <Modelo.Icone>();

            try
            {
                using (connection = new SqlConnection(connectionString))
                {
                    connection.Open();
                    string        sqlIcones = "SELECT * FROM Icone";
                    SqlCommand    cmdIcones = new SqlCommand(sqlIcones, connection);
                    SqlDataReader drIcones;

                    using (drIcones = cmdIcones.ExecuteReader())
                    {
                        if (drIcones.HasRows)
                        {
                            while (drIcones.Read())
                            {
                                int    idIcone  = (int)drIcones["id"];
                                string iconeUrl = (string)drIcones["IconeUrl"];
                                icone = new Modelo.Icone(idIcone, iconeUrl);
                                icones.Add(icone);
                            }
                        }
                    }
                }
            }
            catch (SystemException)
            {
                throw;
            }

            return(icones);
        }