예제 #1
0
파일: Program.cs 프로젝트: radtek/Gradual
        private void CarregarSoliciacaoAlteracao(int pIdCliente, string pCPF, int pIdLoginAlteracao)
        {
            ///TODO tratar login realização, pois foi criado posteriormente

            BindingList <EAlteracao> lAlteracaoAntiga = new NAlteracao().Listar(pCPF);
            ClienteAlteracaoInfo     lAlteracao;
            SalvarObjetoRequest <ClienteAlteracaoInfo> lEntradaAlteracao;
            DbConnection  conn;
            DbTransaction trans;

            foreach (EAlteracao item in lAlteracaoAntiga)
            {
                lAlteracao           = new ImportacaoDuc().GetAlteracao(item, pIdLoginAlteracao);
                lAlteracao.IdCliente = pIdCliente;

                if (null != lAlteracao.IdLoginRealizacao)
                {
                    lAlteracao.IdLoginRealizacao = pIdLoginAlteracao;
                }

                //TODO adicionar ALteração
                lEntradaAlteracao        = new SalvarObjetoRequest <ClienteAlteracaoInfo>();
                lEntradaAlteracao.Objeto = lAlteracao;


                Conexao._ConnectionStringName = "Cadastro";
                conn = Conexao.CreateIConnection();
                conn.Open();
                trans = conn.BeginTransaction();
                try
                {
                    ClienteDbLib.SalvarClienteAlteracaoImportacao(trans, lEntradaAlteracao);
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw ex;
                }
                finally
                {
                    trans.Dispose();
                    trans = null;
                    if (!ConnectionState.Closed.Equals(conn.State))
                    {
                        conn.Close();
                    }
                    conn.Dispose();
                    conn = null;
                }
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: radtek/Gradual
        public void ImportarClientesPasso123()
        {
            //****************************************************************************************************************************
            //****************************************************************************************************************************
            //****************************************************************************************************************************
            //****************************************************************************************************************************
            ///TODO OBS. Pegar o login do Administrador do cadastro
            int IdLoginAlteracao = 65859;
            //****************************************************************************************************************************
            //****************************************************************************************************************************

            //carregar antigo
            //converter para novo
            //salvar com transação
            //pegar próximo


            string ok    = "";
            string erro  = "";
            int    iok   = 0;
            int    ierro = 0;

            ImportacaoDuc lImportar      = new ImportacaoDuc();
            List <int>    lIdClientesDuc = lImportar.GetIdClientes();
            ClienteAntigo lClienteDuc;
            ClienteNovo   lClienteNovo;

            foreach (int lIdCliente in lIdClientesDuc)
            {
                try
                {
                    lClienteDuc  = lImportar.GetClienteDuc(lIdCliente);
                    lClienteNovo = lImportar.Conversao(lClienteDuc, IdLoginAlteracao);
                    lImportar.ImportarCliente(lClienteNovo);
                    ok += lIdCliente + Environment.NewLine;
                    iok++;
                }
                catch (Exception ex)
                {
                    erro += lIdCliente + ": " + ex.Message + Environment.NewLine;
                    ierro++;
                }
            }

            string xerro  = erro;
            string xok    = ok;
            int    iiok   = iok;
            int    iierro = ierro;
        }