Beispiel #1
0
        private bool ExecutarQuery(string Sql, OqueFazer oQueFazer)
        {
            try
            {
                if (!ValidarDados(oQueFazer))
                {
                    MessageBox.Show("Todos os campos são obrigatórios, por favor, preencha todos os campos.", Application.ProductName, MessageBoxButtons.OK); return(false);
                }
                AdicionarParametros(oQueFazer);
                string sData = "Data source = ";
                using (SqlCeConnection cn = new SqlCeConnection(sData + CaminhoDoBancoDeDados))
                {
                    cn.Open();
                    SqlCeCommand cm = new SqlCeCommand(Sql, cn);

                    foreach (SqlCeParameter p in parametros)
                    {
                        cm.Parameters.Add(p);
                    }

                    cm.ExecuteNonQuery();
                }
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }
Beispiel #2
0
        private void AdicionarParametros(OqueFazer oqueFazer)
        {
            parametros.Clear();
            SqlCeParameter novoPar = new SqlCeParameter("@Id_Repositorio", this.Id_Repositorio);

            parametros.Add(novoPar);
            if (oqueFazer == OqueFazer.cadastrar)
            {
                parametros.Clear();
            }
            novoPar = new SqlCeParameter("@Usuario", this.Usuario);
            parametros.Add(novoPar);
            novoPar = new SqlCeParameter("@Senha", this.Senha);
            parametros.Add(novoPar);
            novoPar = new SqlCeParameter("@Email_Referencia", this.Email_Referencia);
            parametros.Add(novoPar);
            novoPar = new SqlCeParameter("@Email_Recuperaca", this.Email_Recuperaca);
            parametros.Add(novoPar);
            novoPar = new SqlCeParameter("@Celular", this.Celular);
            parametros.Add(novoPar);
            novoPar = new SqlCeParameter("@PerguntaDeSeguranca", this.PerguntaDeSeguranca);
            parametros.Add(novoPar);
            novoPar = new SqlCeParameter("@RespostaDaPergunta", this.RespostaDaPergunta);
            parametros.Add(novoPar);
            novoPar = new SqlCeParameter("@DataCadastro", this.DataCadastro);
            parametros.Add(novoPar);
        }
Beispiel #3
0
 private bool ValidarDados(OqueFazer oQueFazer)
 {
     if (this.TxtIdRepositorio.Text == string.Empty & oQueFazer != OqueFazer.excluir)
     {
         MessageBox.Show("Selecione um registro para excluir.", Application.ProductName, MessageBoxButtons.OK); return(false);
     }
     if (this.txtUsuario.Text == string.Empty | this.txtSenha.Text == string.Empty | this.txtEmailDeRecuperacao.Text == string.Empty | this.txtEmailDeReferencia.Text == string.Empty | this.MskCelular.Text == string.Empty | this.txtPerguntaDeSeguranca.Text == string.Empty | this.txtRespostaDaPergunta.Text == string.Empty)
     {
         return(false);
     }
     this.Id_Repositorio      = this.TxtIdRepositorio.Text.Trim();
     this.Usuario             = this.txtUsuario.Text.Trim();
     this.Senha               = this.txtSenha.Text.Trim();
     this.Email_Recuperaca    = this.txtEmailDeRecuperacao.Text.Trim();
     this.Email_Referencia    = this.txtEmailDeReferencia.Text.Trim();
     this.Celular             = this.MskCelular.Text.Replace("(", "").Replace(")", "").Replace("-", "").Trim();
     this.PerguntaDeSeguranca = this.txtPerguntaDeSeguranca.Text.Trim();
     this.RespostaDaPergunta  = this.txtRespostaDaPergunta.Text.Trim();
     this.DataCadastro        = DateTime.Now;
     return(true);
 }