예제 #1
0
        static public ConfiguracaoMenu GetMenuConfig(int id)
        {
            SqlCommand command = new SqlCommand();

            command.Connection  = conex;
            command.CommandText = "select * from confUsu where Id = @id";
            command.Parameters.Add("@id", SqlDbType.Int).Value = id;
            conex.Open();
            SqlDataReader reader = command.ExecuteReader();

            if (reader.Read())
            {
                ConfiguracaoMenu configuracao = new ConfiguracaoMenu();
                configuracao.id            = id;
                configuracao.image         = reader.GetString(1);
                configuracao.corR          = reader.GetInt32(2);
                configuracao.corG          = reader.GetInt32(3);
                configuracao.corB          = reader.GetInt32(4);
                configuracao.tamanho_texto = float.Parse(reader.GetString(5));
                configuracao.nome_fonte    = reader.GetString(6);
                conex.Close();
                return(configuracao);
            }
            else
            {
                conex.Close();
                return(null);
            }
        }
예제 #2
0
        static public void InsertConfig(ConfiguracaoMenu config)
        {
            SqlCommand select = new SqlCommand("SELECT Id from ConfUsu where Id = @id", conex);

            select.Parameters.Add("@id", SqlDbType.Int).Value = config.id;
            conex.Open();
            object     resposta = select.ExecuteScalar();
            SqlCommand grava    = new SqlCommand();

            grava.Connection = conex;
            grava.Parameters.Add("@id", SqlDbType.Int).Value               = config.id;
            grava.Parameters.Add("@imagem", SqlDbType.VarChar).Value       = config.image;
            grava.Parameters.Add("@corR", SqlDbType.Int).Value             = config.corR;
            grava.Parameters.Add("@corG", SqlDbType.Int).Value             = config.corG;
            grava.Parameters.Add("@corB", SqlDbType.Int).Value             = config.corB;
            grava.Parameters.Add("@tamanhoFonte", SqlDbType.VarChar).Value = config.tamanho_texto;
            grava.Parameters.Add("@nomeFonte", SqlDbType.VarChar).Value    = config.nome_fonte;

            if (resposta == null)
            {
                grava.CommandText = "INSERT INTO confUsu VALUES (@id, @imagem, @corR, @corG, @corB, @tamanhoFonte, @nomeFonte)";
            }
            else
            {
                grava.CommandText = "UPDATE confUsu set imagem = @imagem, corR = @corR, corG = @corG, corB = @corB, tamanhoFonte = @tamanhoFonte, nomeFonte = @nomeFonte";
            }
            grava.ExecuteNonQuery();
            conex.Close();
        }
예제 #3
0
        public Configuracao(Usuario usuario, ConfiguracaoMenu confg)
        {
            InitializeComponent();
            this.usuario = usuario;
            this.config  = confg;

            if (!(config.image == ""))
            {
                pictureBox1.Image = Image.FromFile(config.image);

                openFileDialog1.FileName = config.image;

                label2.Font = new Font(config.nome_fonte, config.tamanho_texto);

                label2.ForeColor = Color.FromArgb(config.corR, config.corG, config.corB);

                fontDialog1.Font = label2.Font;

                fontDialog1.Color = label2.ForeColor;
            }
        }
예제 #4
0
 private void Carregaconf()
 {
     configuracaoMenu = Control.GetMenuConfig(usuario.Id);
     if (configuracaoMenu != null)
     {
         if (!(configuracaoMenu.image == ""))
         {
             this.BackgroundImage = Image.FromFile(configuracaoMenu.image);
             menuStrip1.ForeColor = Color.FromArgb(configuracaoMenu.corR, configuracaoMenu.corG, configuracaoMenu.corB);
             menuStrip1.Font      = new Font(configuracaoMenu.nome_fonte, configuracaoMenu.tamanho_texto);
         }
     }
     else
     {
         configuracaoMenu               = new ConfiguracaoMenu();
         configuracaoMenu.image         = "";
         configuracaoMenu.corR          = menuStrip1.ForeColor.R;
         configuracaoMenu.corG          = menuStrip1.ForeColor.G;
         configuracaoMenu.corB          = menuStrip1.ForeColor.B;
         configuracaoMenu.tamanho_texto = menuStrip1.Font.Size;
         configuracaoMenu.nome_fonte    = menuStrip1.Font.Name;
         configuracaoMenu.id            = usuario.Id;
     }
 }