Beispiel #1
0
        public bool DeleteRecord(Situacao_Fields oSituacao)
        {
            //**************
            //* Declarações
            //**************
            DBManager oDBManager = new DBManager(ConnectionString);
            string    SQL        = string.Empty;

            //*********************************
            //* O código da situação é válido?
            //*********************************
            if (oSituacao.PK_SitCli != 0)
            {
                //******************
                //* Exclui registro
                //******************
                SQL = "DELETE FROM situacao WHERE SitCli = " + oSituacao.PK_SitCli;
                oDBManager.ExecuteCommand(SQL);

                //*****************************
                //* Retorna estado de execução
                //*****************************
                if (!oDBManager.Error)
                {
                    //*************
                    //* Retorna OK
                    //*************
                    _ErrorText = string.Empty;
                    _Error     = false;
                    return(true);
                }
                else
                {
                    //***************
                    //* Retorna erro
                    //***************
                    _ErrorText = oDBManager.ErrorMessage;
                    _Error     = oDBManager.Error;
                    return(false);
                }
            }
            else
            {
                //***************
                //* Retorna erro
                //***************
                _ErrorText = "Informe o código da profissão.";
                _Error     = true;
                return(false);
            }
        }
Beispiel #2
0
        public Int32 ApplyRecord(Situacao_Fields oSituacao, bool Import = false)
        {
            //**************
            //* Declarações
            //**************
            DBManager oDBManager = new DBManager(ConnectionString);
            string    SQL        = string.Empty;

            //****************
            //* Cria registro
            //****************
            SQL  = "REPLACE INTO situacao (";
            SQL += "SitCli,";
            SQL += "DescSitCli";
            SQL += ") VALUES (";
            SQL += oSituacao.PK_SitCli + ",";
            SQL += "'" + oSituacao.DescSitCli.SQLFilter() + "')";

            //****************************
            //* Controla erro de execução
            //****************************
            try
            {
                //**************************
                //* Executa comando formado
                //**************************
                oSituacao.PK_SitCli = oDBManager.ExecuteCommand(SQL, Import);

                //************************************
                //* Devolve status e mensagem de erro
                //************************************
                _ErrorText = oDBManager.ErrorMessage;
                _Error     = oDBManager.Error;
            }
            catch (Exception oException)
            {
                //************************************
                //* Devolve status e mensagem de erro
                //************************************
                _ErrorText = oException.Message;
                _Error     = true;
            }

            //*************************
            //* Retorna chave primária
            //*************************
            return(oSituacao.PK_SitCli);
        }
Beispiel #3
0
        public Situacao_Fields GetRecord(Int32 SitCli)
        {
            //**************
            //* Declarações
            //**************
            Situacao_Fields oSituacao  = new Situacao_Fields();
            DBManager       oDBManager = new DBManager(ConnectionString);
            DataTable       oTable     = new DataTable();
            string          SQL        = string.Empty;

            //****************************
            //* Controla erro de execução
            //****************************
            try
            {
                //*****************
                //* Obtem registro
                //*****************
                SQL    = "SELECT * FROM situacao WHERE SitCli = " + SitCli;
                oTable = oDBManager.ExecuteQuery(SQL);

                //************************************
                //* Devolve status e mensagem de erro
                //************************************
                _ErrorText = oDBManager.ErrorMessage;
                _Error     = oDBManager.Error;
            }
            catch (Exception oException)
            {
                //************************************
                //* Devolve status e mensagem de erro
                //************************************
                _ErrorText = oException.Message;
                _Error     = true;
            }

            //*********************************
            //* A pesquisa retornou registros?
            //*********************************
            if (oTable != null)
            {
                //***********************************
                //* A pesquisa localizou o registro?
                //***********************************
                if (oTable.Rows.Count == 1)
                {
                    //*******************************
                    //* Copia dados para a estrutura
                    //*******************************
                    DataRow oRow = oTable.Rows[0];
                    oSituacao.PK_SitCli  = !DBNull.Value.Equals(oRow["SitCli"]) ? Convert.ToInt32("0" + oRow["SitCli"]) : 0;
                    oSituacao.DescSitCli = !DBNull.Value.Equals(oRow["DescSitCli"]) ? oRow["DescSitCli"].ToString() : string.Empty;
                }
            }
            else
            {
                //************************************
                //* Devolve status e mensagem de erro
                //************************************
                _ErrorText = "O resultado da pesquisa retornou nulo";
                _Error     = true;
            }

            //****************
            //* Retorna dados
            //****************
            return(oSituacao);
        }