Beispiel #1
0
        public static void Update(dtoProcessoPrazoResponsavel ProcessoPrazoResponsavel)
        {
            using (SqlConnection connection = new SqlConnection(DataAccess.Configuracao.getConnectionString()))
            {
                string stringSQL = @"UPDATE tbProcessoPrazoResponsavel SET 
                                        idProcessoPrazo = @idProcessoPrazo,
                                        idPessoa = @idPessoa
                                      WHERE idProcessoPrazoResponsavel = @idProcessoPrazoResponsavel";

                SqlCommand cmdProcessoPrazoResponsavel = new SqlCommand(stringSQL, connection);

                ValidaCampos(ref ProcessoPrazoResponsavel);

                cmdProcessoPrazoResponsavel.Parameters.Add("idProcessoPrazo", SqlDbType.Int).Value = ProcessoPrazoResponsavel.idProcessoPrazo;
                cmdProcessoPrazoResponsavel.Parameters.Add("idPessoa", SqlDbType.Int).Value        = ProcessoPrazoResponsavel.idPessoa;

                try
                {
                    connection.Open();
                    cmdProcessoPrazoResponsavel.ExecuteNonQuery();
                }
                catch
                {
                    throw new ApplicationException("Erro ao atualizar registro");
                }
                finally
                {
                    connection.Close();
                }
            }
        }
Beispiel #2
0
        public static void Delete(dtoProcessoPrazoResponsavel ProcessoPrazoResponsavel)
        {
            using (SqlConnection connection = new SqlConnection(DataAccess.Configuracao.getConnectionString()))
            {
                string stringSQL = @"DELETE tbProcessoPrazoResponsavel 
                                      WHERE idProcessoPrazoResponsavel = @idProcessoPrazoResponsavel";

                SqlCommand cmdMenu = new SqlCommand(stringSQL, connection);
                cmdMenu.Parameters.Add("idProcessoPrazoResponsavel", SqlDbType.Int).Value = ProcessoPrazoResponsavel.idProcessoPrazoResponsavel;

                try
                {
                    connection.Open();
                    cmdMenu.ExecuteNonQuery();
                }
                catch
                {
                    throw new ApplicationException("Erro ao excluir registro");
                }
                finally
                {
                    connection.Close();
                }
            }
        }
Beispiel #3
0
        public static int Insert(dtoProcessoPrazoResponsavel ProcessoPrazoResponsavel)
        {
            using (SqlConnection connection = new SqlConnection(DataAccess.Configuracao.getConnectionString()))
            {
                string stringSQL = @"INSERT INTO tbProcessoPrazoResponsavel(idProcessoPrazo, idPessoa)
                                            VALUES(@idProcessoPrazo, @idPessoa);
                                            SET @idProcessoPrazoResponsavel = SCOPE_IDENTITY()";

                SqlCommand cmdProcessoPrazoResponsavel = new SqlCommand(stringSQL, connection);

                ValidaCampos(ref ProcessoPrazoResponsavel);

                cmdProcessoPrazoResponsavel.Parameters.Add("idProcessoPrazoResponsavel", SqlDbType.Int);
                cmdProcessoPrazoResponsavel.Parameters["idProcessoPrazoResponsavel"].Direction = ParameterDirection.Output;

                cmdProcessoPrazoResponsavel.Parameters.Add("idProcessoPrazo", SqlDbType.Int).Value = ProcessoPrazoResponsavel.idProcessoPrazo;
                cmdProcessoPrazoResponsavel.Parameters.Add("idPessoa", SqlDbType.Int).Value        = ProcessoPrazoResponsavel.idPessoa;

                try
                {
                    connection.Open();
                    cmdProcessoPrazoResponsavel.ExecuteNonQuery();

                    return((int)cmdProcessoPrazoResponsavel.Parameters["idProcessoPrazoResponsavel"].Value);
                }
                catch
                {
                    throw new ApplicationException("Erro ao inserir registro");
                }
                finally
                {
                    connection.Close();
                }
            }
        }
        private void InserirNovoResponsavel(int idPessoa, int idProcessoPrazo)
        {
            if (!bllProcessoPrazoResponsavel.Exists(idProcessoPrazo, idPessoa))
            {
                dtoProcessoPrazoResponsavel processoPrazoResponsavel = new dtoProcessoPrazoResponsavel();

                processoPrazoResponsavel.idProcessoPrazo = idProcessoPrazo;
                processoPrazoResponsavel.idPessoa        = idPessoa;

                bllProcessoPrazoResponsavel.Insert(processoPrazoResponsavel);
            }
        }
Beispiel #5
0
        private static void PreencheCampos(SqlDataReader drProcessoPrazoResponsavel, ref dtoProcessoPrazoResponsavel ProcessoPrazoResponsavel)
        {
            if (drProcessoPrazoResponsavel["idProcessoPrazoResponsavel"] != DBNull.Value)
            {
                ProcessoPrazoResponsavel.idProcessoPrazoResponsavel = Convert.ToInt32(drProcessoPrazoResponsavel["idProcessoPrazoResponsavel"].ToString());
            }

            if (drProcessoPrazoResponsavel["idProcessoPrazo"] != DBNull.Value)
            {
                ProcessoPrazoResponsavel.idProcessoPrazo = Convert.ToInt32(drProcessoPrazoResponsavel["idProcessoPrazo"].ToString());
            }

            if (drProcessoPrazoResponsavel["idPessoa"] != DBNull.Value)
            {
                ProcessoPrazoResponsavel.idPessoa = Convert.ToInt32(drProcessoPrazoResponsavel["idPessoa"].ToString());
            }
        }
Beispiel #6
0
        public static List <dtoProcessoPrazoResponsavel> GetByProcessoPrazo(int idProcessoPrazo)
        {
            List <dtoProcessoPrazoResponsavel> ProcessoPrazoResponsavels = new List <dtoProcessoPrazoResponsavel>();

            if (idProcessoPrazo > 0)
            {
                using (SqlConnection connection = new SqlConnection(DataAccess.Configuracao.getConnectionString()))
                {
                    StringBuilder sbCondicao = new StringBuilder();

                    sbCondicao.AppendFormat(@" WHERE (tbProcessoPrazoResponsavel.idProcessoPrazo = {0})", idProcessoPrazo.ToString());

                    string stringSQL = String.Format("SELECT * FROM tbProcessoPrazoResponsavel {0} ORDER BY idProcessoPrazoResponsavel", sbCondicao.ToString());

                    SqlCommand cmdProcessoPrazoResponsavel = new SqlCommand(stringSQL, connection);

                    try
                    {
                        connection.Open();
                        SqlDataReader drProcessoPrazoResponsavel = cmdProcessoPrazoResponsavel.ExecuteReader();

                        while (drProcessoPrazoResponsavel.Read())
                        {
                            dtoProcessoPrazoResponsavel ProcessoPrazoResponsavel = new dtoProcessoPrazoResponsavel();

                            PreencheCampos(drProcessoPrazoResponsavel, ref ProcessoPrazoResponsavel);

                            ProcessoPrazoResponsavels.Add(ProcessoPrazoResponsavel);
                        }
                    }
                    catch
                    {
                        throw new ApplicationException("Erro ao capturar todos os registros");
                    }
                    finally
                    {
                        connection.Close();
                    }
                }
            }

            return(ProcessoPrazoResponsavels);
        }
Beispiel #7
0
        public static List <dtoProcessoPrazoResponsavel> GetAll(string SortExpression)
        {
            List <dtoProcessoPrazoResponsavel> ProcessoPrazoResponsavels = new List <dtoProcessoPrazoResponsavel>();

            using (SqlConnection connection = new SqlConnection(DataAccess.Configuracao.getConnectionString()))
            {
                string stringSQL = String.Format("SELECT * FROM tbProcessoPrazoResponsavel ORDER BY {0}", (SortExpression.Trim() != String.Empty ? SortExpression.Trim() : "idProcessoPrazoResponsavel"));

                SqlCommand cmdProcessoPrazoResponsavel = new SqlCommand(stringSQL, connection);

                try
                {
                    connection.Open();
                    SqlDataReader drProcessoPrazoResponsavel = cmdProcessoPrazoResponsavel.ExecuteReader();

                    while (drProcessoPrazoResponsavel.Read())
                    {
                        dtoProcessoPrazoResponsavel ProcessoPrazoResponsavel = new dtoProcessoPrazoResponsavel();

                        PreencheCampos(drProcessoPrazoResponsavel, ref ProcessoPrazoResponsavel);

                        ProcessoPrazoResponsavels.Add(ProcessoPrazoResponsavel);
                    }
                }
                catch
                {
                    throw new ApplicationException("Erro ao capturar todos os registros");
                }
                finally
                {
                    connection.Close();
                }
            }

            return(ProcessoPrazoResponsavels);
        }
Beispiel #8
0
        public static dtoProcessoPrazoResponsavel Get(int idProcessoPrazoResponsavel)
        {
            dtoProcessoPrazoResponsavel ProcessoPrazoResponsavel = new dtoProcessoPrazoResponsavel();

            using (SqlConnection connection = new SqlConnection(DataAccess.Configuracao.getConnectionString()))
            {
                string stringSQL = @"SELECT *
                                    FROM tbProcessoPrazoResponsavel
                                    WHERE idProcessoPrazoResponsavel = @idProcessoPrazoResponsavel";

                SqlCommand cmdMenu = new SqlCommand(stringSQL, connection);

                cmdMenu.Parameters.Add("idProcessoPrazoResponsavel", SqlDbType.Int).Value = idProcessoPrazoResponsavel;

                try
                {
                    connection.Open();
                    SqlDataReader drProcessoPrazoResponsavel = cmdMenu.ExecuteReader();

                    if (drProcessoPrazoResponsavel.Read())
                    {
                        PreencheCampos(drProcessoPrazoResponsavel, ref ProcessoPrazoResponsavel);
                    }
                }
                catch
                {
                    throw new ApplicationException("Erro ao capturar registro");
                }
                finally
                {
                    connection.Close();
                }
            }

            return(ProcessoPrazoResponsavel);
        }
Beispiel #9
0
 private static void ValidaCampos(ref dtoProcessoPrazoResponsavel ProcessoPrazoResponsavel)
 {
 }