Beispiel #1
0
        private void btnRegistraAlteracao_Click(object sender, RoutedEventArgs e)
        {
            Dictionary <int, string> listaIndicesValores = new Dictionary <int, string>();

            foreach (DataRowView dv in dtgDetalhes.Items.SourceCollection)
            {
                listaIndicesValores.Add(Convert.ToInt32(dv.Row[0]), dv.Row[3].ToString());
            }

            StringBuilder sb = new StringBuilder();

            foreach (int i in listaIndicesValores.Keys)
            {
                CampoArquivoCompe campo = _detalhe.CAMPOS.Find(x => x.NUMERO == i);

                if (listaIndicesValores[i].Length > campo.TAMANHO)
                {
                    campo.CONTEUDO = listaIndicesValores[i].Substring(0, campo.TAMANHO);
                }
                else
                {
                    campo.CONTEUDO = listaIndicesValores[i];
                }

                if (campo.CONTEUDO != _detalhe.CAMPOS.Find(x => x.NUMERO == i).CONTEUDO)
                {
                    _detalhe.CAMPOS.Remove(campo);
                    _detalhe.CAMPOS.Insert(i - 1, campo);
                }
            }

            _detalhe.RegeraLinha();

            this.DialogResult = true;
        }
 public CampoArquivoCompe(CampoArquivoCompe campo)
 {
     NUMERO    = campo.NUMERO;
     POSICAO   = campo.POSICAO;
     TIPO      = campo.TIPO;
     TAMANHO   = campo.TAMANHO;
     DESCRICAO = campo.DESCRICAO;
     CONTEUDO  = campo.CONTEUDO;
     PERMITE_EDICAO_INDIVIDUAL = campo.PERMITE_EDICAO_INDIVIDUAL;
 }
Beispiel #3
0
        private void btnRegistraAlteracao_Click(object sender, RoutedEventArgs e)
        {
            Dictionary <int, string> listaIndicesValores = new Dictionary <int, string>();

            foreach (DataRowView dv in dtgDetalhes.Items.SourceCollection)
            {
                listaIndicesValores.Add(Convert.ToInt32(dv.Row[0]), dv.Row[3].ToString());
            }

            StringBuilder sb = new StringBuilder();

            foreach (int i in listaIndicesValores.Keys)
            {
                CampoArquivoCompe campo = _detalhe.CAMPOS.Find(x => x.NUMERO == i);

                if (listaIndicesValores[i].Length > campo.TAMANHO)
                {
                    listaIndicesValores[i].Substring(0, campo.TAMANHO);
                }

                if (campo.TIPO == 1)
                {
                    campo.CONTEUDO = listaIndicesValores[i].PadLeft(campo.TAMANHO, '0');
                }
                else if (campo.TIPO == 0)
                {
                    campo.CONTEUDO = listaIndicesValores[i].PadRight(campo.TAMANHO, ' ');
                }

                if (campo.CONTEUDO != _detalhe.CAMPOS.Find(x => x.NUMERO == i).CONTEUDO)
                {
                    _detalhe.CAMPOS.Remove(campo);
                    _detalhe.CAMPOS.Insert(i - 1, campo);
                }
            }

            foreach (CampoArquivoCompe c in _detalhe.CAMPOS)
            {
                sb.Append(c.CONTEUDO);
            }

            _detalhe.Text = sb.ToString().Substring(0, _detalhe.QUEBRA);
        }
        private void btnRegistraAlteracao_Click(object sender, RoutedEventArgs e)
        {
            if (_imagemFrente != null)
            {
                _cheque.IMAGEM_FRENTE = new byte[_imagemFrente.Length];
                Array.Copy(_imagemFrente, _cheque.IMAGEM_FRENTE, _imagemFrente.Length);
            }

            if (_assinaturaFrente != null)
            {
                _cheque.ASSINATURA_FRENTE = new byte[_assinaturaFrente.Length];
                Array.Copy(_assinaturaFrente, _cheque.ASSINATURA_FRENTE, _assinaturaFrente.Length);
            }

            if (_imagemVerso != null)
            {
                _cheque.IMAGEM_VERSO = new byte[_imagemVerso.Length];
                Array.Copy(_imagemVerso, _cheque.IMAGEM_VERSO, _imagemVerso.Length);

                if (_cheque.DADOS_VERSO == null)
                {
                    _cheque.DADOS_VERSO = new List <DetalheArquivoCompe>();
                    _detalheV           = _detalheF;
                    _cheque.DADOS_VERSO.Add(_detalheV);
                }
            }

            if (_assinaturaVerso != null)
            {
                _cheque.ASSINATURA_VERSO = new byte[_assinaturaVerso.Length];
                Array.Copy(_assinaturaVerso, _cheque.ASSINATURA_VERSO, _assinaturaVerso.Length);
            }

            if (_cheque.IMAGEM_FRENTE == null)
            {
                _cheque.ASSINATURA_FRENTE = null;
                _cheque.IMAGEM_VERSO      = null;
                _cheque.ASSINATURA_VERSO  = null;
            }
            else
            {
                if (_cheque.ASSINATURA_FRENTE == null)
                {
                    MessageBox.Show("Não tem assinatura da frente");
                    return;
                }
                if (_cheque.IMAGEM_VERSO == null)
                {
                    MessageBox.Show("Não tem imagem do verso");
                    return;
                }
                if (_cheque.ASSINATURA_VERSO == null)
                {
                    MessageBox.Show("Não tem assinatura do verso");
                    return;
                }
            }

            Dictionary <int, string> listaIndicesValores = new Dictionary <int, string>();

            foreach (DataRowView dv in dtgDetalhes.Items.SourceCollection)
            {
                listaIndicesValores.Add(Convert.ToInt32(dv.Row[0]), dv.Row[3].ToString());
            }

            foreach (int i in listaIndicesValores.Keys)
            {
                CampoArquivoCompe campo = _detalheF.CAMPOS.Find(x => x.NUMERO == i);

                if (listaIndicesValores[i].Length > campo.TAMANHO)
                {
                    campo.CONTEUDO = listaIndicesValores[i].Substring(0, campo.TAMANHO);
                }
                else
                {
                    campo.CONTEUDO = listaIndicesValores[i];
                }

                if (campo.CONTEUDO != _detalheF.CAMPOS.Find(x => x.NUMERO == i).CONTEUDO)
                {
                    _detalheF.CAMPOS.Remove(campo);
                    _detalheF.CAMPOS.Insert(i - 1, campo);
                }
            }

            _detalheF.RegeraLinha();

            if (_cheque.DADOS_VERSO != null)
            {
                foreach (int i in listaIndicesValores.Keys)
                {
                    CampoArquivoCompe campo = _detalheV.CAMPOS.Find(x => x.NUMERO == i);

                    if (listaIndicesValores[i].Length > campo.TAMANHO)
                    {
                        campo.CONTEUDO = listaIndicesValores[i].Substring(0, campo.TAMANHO);
                    }
                    else
                    {
                        campo.CONTEUDO = listaIndicesValores[i];
                    }

                    if (campo.CONTEUDO != _detalheV.CAMPOS.Find(x => x.NUMERO == i).CONTEUDO)
                    {
                        _detalheV.CAMPOS.Remove(campo);
                        _detalheV.CAMPOS.Insert(i - 1, campo);
                    }
                }

                _detalheV.RegeraLinha();
            }

            _cheque.DADOS_FRENTE.Clear();

            byte totalRegistroImagem = 0;
            long tamanhoTotal        = 0;
            int  restoLinha          = 0;

            if (_cheque.IMAGEM_FRENTE != null)
            {
                tamanhoTotal = _cheque.IMAGEM_FRENTE.Length + _cheque.ASSINATURA_FRENTE.Length;
                restoLinha   = _detalheF.TAMANHO_TOTAL_LINHA - _detalheF.QUEBRA;

                while (tamanhoTotal > 0)
                {
                    totalRegistroImagem++;
                    tamanhoTotal = tamanhoTotal - restoLinha;
                }

                _cheque.TOTAL_REGISTROS_IMAGEM_FRENTE = totalRegistroImagem;

                DetalheArquivoCompe detalhe;

                for (int i = 0; i < totalRegistroImagem; i++)
                {
                    detalhe        = new DetalheArquivoCompe();
                    detalhe.CAMPOS = new List <CampoArquivoCompe>(_detalheF.CAMPOS.Count);

                    detalhe.VERSO         = false;
                    detalhe.INDICE_LOTE   = _detalheF.INDICE_LOTE;
                    detalhe.INDICE_CHEQUE = _detalheF.INDICE_CHEQUE;
                    detalhe.NOME_REGISTRO = _detalheF.NOME_REGISTRO;
                    detalhe.Text          = _detalheF.Text;
                    detalhe.Foreground    = _detalheF.Foreground;

                    _detalheF.CAMPOS.ForEach((item) =>
                    {
                        detalhe.CAMPOS.Add(new CampoArquivoCompe(item));
                    });

                    _cheque.DADOS_FRENTE.Add(detalhe);
                }

                if (_cheque.DADOS_VERSO != null)
                {
                    _cheque.DADOS_VERSO.Clear();

                    totalRegistroImagem = 0;
                    tamanhoTotal        = _cheque.IMAGEM_VERSO.Length + _cheque.ASSINATURA_VERSO.Length;

                    while (tamanhoTotal > 0)
                    {
                        totalRegistroImagem++;
                        tamanhoTotal = tamanhoTotal - restoLinha;
                    }

                    _cheque.TOTAL_REGISTROS_IMAGEM_VERSO = totalRegistroImagem;

                    for (int i = 0; i < totalRegistroImagem; i++)
                    {
                        detalhe        = new DetalheArquivoCompe();
                        detalhe.CAMPOS = new List <CampoArquivoCompe>(_detalheV.CAMPOS.Count);

                        detalhe.VERSO         = true;
                        detalhe.INDICE_LOTE   = _detalheV.INDICE_LOTE;
                        detalhe.INDICE_CHEQUE = _detalheV.INDICE_CHEQUE;
                        detalhe.NOME_REGISTRO = _detalheV.NOME_REGISTRO;
                        detalhe.Text          = _detalheV.Text;
                        detalhe.Foreground    = _detalheV.Foreground;

                        _detalheV.CAMPOS.ForEach((item) =>
                        {
                            detalhe.CAMPOS.Add(new CampoArquivoCompe(item));
                        });

                        _cheque.DADOS_VERSO.Add(detalhe);
                    }
                }
            }
            else
            {
                _cheque.DADOS_FRENTE.Add(_detalheF);
                _cheque.DADOS_VERSO = null;
            }

            this.DialogResult = true;
        }