Exemplo n.º 1
0
        private void edtDirEntrada_Leave(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(edtDirEntrada.Text))
            {
                ParametrosController parametrosController = new ParametrosController();
                if (parametrosController.GetIdParametro("Sugerir_Mapeamento_Do_Arquivo") == 0)
                {
                    parametrosController.GravaNovoParametro("Sugerir_Mapeamento_Do_Arquivo", "SIM");
                }
                if (parametrosController.GetValorParametro("Sugerir_Mapeamento_Do_Arquivo") == "SIM")
                {
                    if (cbTpArquivo.Text == "EXCEL" ||
                        cbTpArquivo.Text == "DBF" && (operacao == Operacao.oInsert && dgvMapeamentos.Rows.Count == 1 && Global.IsNullOrEmpty(dgvMapeamentos.Rows[0].Cells[1].Value)))
                    {
                        ArquivosController arquivosController = new ArquivosController();
                        edtDirEntrada.Text = Global.LastCaracterDifereDeBarra(edtDirEntrada.Text);

                        lblNameFileShort.Text = GetShortPathName(edtDirEntrada.Text + edtMascaraArquivo.Text);

                        bool NomeArqRenomeado = RenomeiaSeNomeMaiorOitoDig(edtDirEntrada.Text + edtMascaraArquivo.Text);

                        List <MapeamentosModel> LstMapeamentos = arquivosController.GetEstruturaFile(edtDirEntrada.Text + NomePadrao, edtNomePlanilha.Text);
                        for (int i = 0; i <= LstMapeamentos.Count - 1; i++)
                        {
                            dgvMapeamentos.Rows.Add();
                            dgvMapeamentos.Rows[i].Cells[0].Value = LstMapeamentos[i].id_arquivo;
                            dgvMapeamentos.Rows[i].Cells[1].Value = LstMapeamentos[i].nm_coluna;
                            dgvMapeamentos.Rows[i].Cells[2].Value = LstMapeamentos[i].ordem;
                            dgvMapeamentos.Rows[i].Cells[3].Value = LstMapeamentos[i].fixo_inicio;
                            dgvMapeamentos.Rows[i].Cells[4].Value = LstMapeamentos[i].fixo_tamanho;
                            dgvMapeamentos.Rows[i].Cells[5].Value = LstMapeamentos[i].tp_coluna;
                            dgvMapeamentos.Rows[i].Cells[6].Value = LstMapeamentos[i].tm_coluna;
                            dgvMapeamentos.Rows[i].Cells[7].Value = LstMapeamentos[i].pr_coluna;
                            dgvMapeamentos.Rows[i].Cells[8].Value = LstMapeamentos[i].MASK_CAMPO;
                            dgvMapeamentos.Rows[i].Cells[9].Value = LstMapeamentos[i].ExpressaoSql;
                        }
                        //if (NomeArqRenomeado)
                        //{
                        //    File.Move(PathDoArqPadrao, NomeORG);
                        //}
                    }
                }
            }
        }