Пример #1
0
        private void FrmCliente_Load(object sender, EventArgs e)
        {
            model get = new model();
            List <DtoCidadeMap> ListCidades = get.getAllCidades();

            comboBox1.DataSource    = null;
            comboBox1.ValueMember   = "id";
            comboBox1.DisplayMember = "nome";
            comboBox1.DataSource    = ListCidades;
        }
Пример #2
0
        private void listBoxDestinos_DoubleClick(object sender, EventArgs e)
        {
            model      get    = new model();
            DtoLatLong latlgn = get.getLatLngId(listBoxDestinos.Text);

            //center map
            gMapControl1.Position = new PointLatLng(Convert.ToDouble(latlgn.latitude, CultureInfo.InvariantCulture), Convert.ToDouble(latlgn.longitude, CultureInfo.InvariantCulture));
            //set zoom
            gMapControl1.Zoom = 15;
        }
Пример #3
0
        private void FrmCidade_Load(object sender, EventArgs e)
        {
            model            get        = new model();
            List <DtoEstado> ListEstado = get.getAllEstados();

            comboBox1.DataSource    = null;
            comboBox1.ValueMember   = "id";
            comboBox1.DisplayMember = "uf";
            comboBox1.DataSource    = ListEstado;
        }
Пример #4
0
        private void CarregaDestinos()
        {
            model             get = new model();
            List <DtoDestino> d   = get.getListDestino();

            dataGridView1.DataSource    = null;
            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dataGridView1.MultiSelect   = false;
            dataGridView1.DataSource    = d;
            dataGridView1.Refresh();
        }
Пример #5
0
        private void CarregarGrid()
        {
            model get = new model();
            List <DtoLancamento2> d = get.getLancamentosLimited();

            dataGridView1.DataSource    = null;
            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dataGridView1.MultiSelect   = false;
            dataGridView1.DataSource    = d;
            dataGridView1.Refresh();
        }
Пример #6
0
        private void CarregarDestinos()
        {
            listBoxDestinos.Items.Clear();

            model             get   = new model();
            List <DtoDestino> lista = get.getListaDestinos();

            foreach (var l in lista)
            {
                AddMarkerMap(l.latitude, l.longitude, l.documento + "\n" + l.nome + "\n" + l.endereco);
                this.listBoxDestinos.Items.Add(l.id + "-" + l.documento + "-" + l.nome + "-" + l.bairro);
            }
        }
Пример #7
0
 private void btnExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         model delete = new model();
         delete.DeleteCliente(textBoxID.Text);
         this.Close();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #8
0
        public void ArquivoTXT(string[] theLines)
        {
            progressBar1.Maximum = theLines.Count();
            progressBar1.Minimum = 0;
            for (int i = 0; i < theLines.Count(); i++)
            {
                progressBar1.Value = i;
                DtoDestino destino = new DtoDestino();
                destino.transportadora = theLines[0];
                if (theLines[i].Contains("NF:"))
                {
                    if (theLines[i].Substring(3).Length > 30)
                    {
                        destino.documento = theLines[i].Substring(3, 30);
                    }
                    else
                    {
                        destino.documento = theLines[i].Substring(3);
                    }
                    destino.nome = theLines[i + 1];
                    model   get             = new model();
                    Boolean existeDocumento = get.getDestinoDocumento(destino.documento, destino.transportadora);
                    if (!existeDocumento)
                    {
                        int    posicao      = theLines[i + 2].IndexOf("-");
                        string bairro       = theLines[i + 2].Substring(posicao + 2);
                        int    posicaofinal = bairro.IndexOf("-");
                        destino.bairro   = bairro.Substring(0, 7);
                        destino.endereco = theLines[i + 2].Replace('-', ',');

                        model      m       = new model();
                        DtoLatLong latlong = m.GetLatLongGoogle(destino.endereco);

                        try
                        {
                            destino.latitude  = double.Parse(latlong.latitude, CultureInfo.InvariantCulture);
                            destino.longitude = double.Parse(latlong.longitude, CultureInfo.InvariantCulture);
                            destino.distancia = Convert.ToDouble(latlong.distancia, CultureInfo.InvariantCulture);
                            destino.duracao   = latlong.duracao;
                        }
                        catch (Exception)
                        {
                            destino.status = "E";
                        }
                        destino.status = "I";
                        model post = new model();
                        post.set(destino);
                    }
                }
            }
        }
Пример #9
0
        private void FrmMotorista_Load(object sender, EventArgs e)
        {
            model get = new model();
            List <DtoCidadeMap> ListCidades = get.getAllCidades();

            comboBox1.DataSource    = null;
            comboBox1.ValueMember   = "id";
            comboBox1.DisplayMember = "nome";
            comboBox1.DataSource    = ListCidades;

            List <DtoMotorista> d = get.getMotoristasAll();

            CarregarGrid(d);
        }
Пример #10
0
        public FrmDestino(string valor)
        {
            InitializeComponent();
            model      get = new model();
            DtoDestino d   = get.getDestinoDocumento(valor);

            textBoxID.Text             = d.id.ToString();
            textBoxNome.Text           = d.nome;
            textBoxDocumento.Text      = d.documento;
            textBoxEndereco.Text       = d.endereco;
            textBoxLatitude.Text       = d.latitude.ToString();
            textBoxLongitude.Text      = d.longitude.ToString();
            textBoxTransportadora.Text = d.transportadora;
            textBoxBairro.Text         = d.bairro;
        }
Пример #11
0
        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            int ID = (Int32)dataGridView1.CurrentRow.Cells[0].Value;

            model          get = new model();
            DtoLancamento2 d   = get.getLancamentosId(ID);

            textBoxID.Text                  = d.id.ToString();
            textBoxData.Text                = d.dt_lancamento.ToString();
            textBoxControle.Text            = d.nr_controle.ToString();
            textBoxValor.Text               = d.valor.ToString();
            textBoxObservacao.Text          = d.observacao.ToString();
            comboBoxCliente.SelectedValue   = d.id_cliente.Value;
            comboBoxMotorista.SelectedValue = d.id_motorista.Value;
        }
Пример #12
0
        public FrmEmpresa()
        {
            InitializeComponent();
            model      get = new model();
            DtoEmpresa e   = get.getEndEmpresa();

            if (e != null)
            {
                textBoxID.Text        = e.id.ToString();
                textBoxNome.Text      = e.nome.ToString();
                textBoxLatitude.Text  = e.latitude.ToString();
                textBoxLongitude.Text = e.longitude.ToString();
                textBoxEndereco.Text  = e.endereco.ToString();
            }
        }
Пример #13
0
        private void btnConsultar_Click(object sender, EventArgs e)
        {
            model      get     = new model();
            DtoLatLong latlong = get.GetLatLongGoogle(textBoxEndereco.Text);

            try
            {
                textBoxLatitude.Text  = latlong.latitude;
                textBoxLongitude.Text = latlong.longitude;
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #14
0
        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            int ID = (Int32)dataGridView1.CurrentRow.Cells[0].Value;

            model      get = new model();
            DtoDestino d   = get.getDestinoId(ID);

            textBoxID.Text             = d.id.ToString();
            textBoxNome.Text           = d.nome;
            textBoxDocumento.Text      = d.documento;
            textBoxEndereco.Text       = d.endereco;
            textBoxLatitude.Text       = d.latitude.ToString();
            textBoxLongitude.Text      = d.longitude.ToString();
            textBoxTransportadora.Text = d.transportadora;
            textBoxBairro.Text         = d.bairro;
        }
Пример #15
0
        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            int ID = (Int32)dataGridView1.CurrentRow.Cells[0].Value;

            model        get = new model();
            DtoMotorista d   = get.getMotoristaId(ID);

            textBoxID.Text          = d.id.ToString();
            textBoxNome.Text        = d.nome;
            textBoxEndereco.Text    = d.endereco;
            textBoxTelefone.Text    = d.telefone;
            textBoxEmail.Text       = d.email;
            textBoxCPF.Text         = d.cpfcnpj;
            textBoxRG.Text          = d.ierg;
            comboBox1.SelectedValue = d.id_cidade;
            textBoxObservacao.Text  = d.observacoes;
            textBoxComplemento.Text = d.complemento;
            textBoxComissao.Text    = d.comissao.ToString();
        }
Пример #16
0
 private void btnExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         model delete = new model();
         if (textBoxID.Text != string.Empty)
         {
             delete.DeleteLancamento(textBoxID.Text);
         }
         else
         {
             MessageBox.Show("Selecione um registro");
         }
         this.Close();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #17
0
        private void Lançamento_Load(object sender, EventArgs e)
        {
            textBoxData.Text = DateTime.Now.ToShortDateString();
            model             get          = new model();
            List <DtoCliente> ListClientes = get.getAllClientes();

            comboBoxCliente.DataSource    = null;
            comboBoxCliente.ValueMember   = "id";
            comboBoxCliente.DisplayMember = "nome";
            comboBoxCliente.DataSource    = ListClientes;

            List <DtoMotorista> ListMotorista = get.getAllMotorista();

            comboBoxMotorista.DataSource    = null;
            comboBoxMotorista.ValueMember   = "id";
            comboBoxMotorista.DisplayMember = "nome";
            comboBoxMotorista.DataSource    = ListMotorista;

            CarregarGrid();
        }
Пример #18
0
        private void CarregarMapa()
        {
            //use google provider
            //gMapControl1.MapProvider = BingMapProvider.Instance;
            gMapControl1.MapProvider = GoogleMapProvider.Instance;
            //get tiles from server only
            gMapControl1.Manager.Mode = AccessMode.ServerOnly;
            //not use proxy
            GMapProvider.WebProxy = null;
            //center map on toledo
            model      get    = new model();
            DtoLatLong latlgn = get.getLatlgnEmpresa();

            gMapControl1.Position = new PointLatLng(Convert.ToDouble(latlgn.latitude, CultureInfo.InvariantCulture), Convert.ToDouble(latlgn.longitude, CultureInfo.InvariantCulture));

            //zoom min/max; default both = 2
            gMapControl1.MinZoom = 1;
            gMapControl1.MaxZoom = 100;
            //set zoom
            gMapControl1.Zoom = 13;
        }
Пример #19
0
        private void textBoxPesquisa_TextChanged(object sender, EventArgs e)
        {
            model get = new model();

            string verifica         = "^[0-9]";
            List <DtoLancamento2> d = new List <DtoLancamento2>();

            if (Regex.IsMatch(textBoxPesquisa.Text, verifica))
            {
                d = get.getLancamentoControle(textBoxPesquisa.Text);
            }
            else
            {
                d = get.getLancamentoNomeCliente(textBoxPesquisa.Text);
            }

            dataGridView1.DataSource    = null;
            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dataGridView1.MultiSelect   = false;
            dataGridView1.DataSource    = d;
            dataGridView1.Refresh();
        }
Пример #20
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                model         set  = new model();
                DtoLancamento lanc = new DtoLancamento();
                lanc.dt_lancamento = Convert.ToDateTime(textBoxData.Text);
                lanc.dt_record     = DateTime.Now;
                lanc.id_cliente    = Convert.ToInt16(comboBoxCliente.SelectedValue);
                lanc.id_motorista  = Convert.ToInt16(comboBoxMotorista.SelectedValue);
                lanc.observacao    = textBoxObservacao.Text;
                if (textBoxValor.Text != string.Empty)
                {
                    lanc.valor = float.Parse(textBoxValor.Text);
                }
                if (textBoxControle.Text != string.Empty)
                {
                    lanc.nr_controle = int.Parse(textBoxControle.Text);
                }

                if (textBoxID.Text != string.Empty)
                {
                    lanc.id = int.Parse(textBoxID.Text);
                    set.alterLancamento(lanc);
                }
                else
                {
                    set.setLancamento(lanc);
                }
                MessageBox.Show("Registro salvo com sucesso");
                limpaCampos();
                CarregarGrid();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #21
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            model model  = new model();
            int   idRota = model.getIdRota();

            idRota++;
            List <DtoBairro> listBairros = new List <DtoBairro>();

            foreach (string l in checkedListBox1.CheckedItems)
            {
                DtoBairro b = new DtoBairro();
                b.bairro = l;
                listBairros.Add(b);
            }
            //RotaCoordenadas(listBairros);
            model             get   = new model();
            List <DtoDestino> lista = get.getListaDestinosBairro(listBairros);

            foreach (var l in lista)
            {
                model.addRota(l.id, idRota, "F");
            }
        }
Пример #22
0
        private void CarregarMapa()
        {
            try
            {
                Provider();
                //get tiles from server only
                gMapControl1.Manager.Mode = AccessMode.ServerOnly;
                //center map on toledo
                model      get    = new model();
                DtoLatLong latlgn = get.getLatlgnEmpresa();
                gMapControl1.Position = new PointLatLng(Convert.ToDouble(latlgn.latitude, CultureInfo.InvariantCulture), Convert.ToDouble(latlgn.longitude, CultureInfo.InvariantCulture));

                //zoom min/max; default both = 2
                gMapControl1.MinZoom = 1;
                gMapControl1.MaxZoom = 100;
                //set zoom
                gMapControl1.Zoom = 13;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #23
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                model        set = new model();
                DtoMotorista c   = new DtoMotorista();
                c.nome        = textBoxNome.Text;
                c.endereco    = textBoxEndereco.Text;
                c.telefone    = textBoxTelefone.Text;
                c.email       = textBoxEmail.Text;
                c.cpfcnpj     = textBoxCPF.Text;
                c.ierg        = textBoxRG.Text;
                c.id_cidade   = Convert.ToInt16(comboBox1.SelectedValue);
                c.observacoes = textBoxObservacao.Text;
                c.complemento = textBoxComplemento.Text;
                if (textBoxComissao.Text != string.Empty)
                {
                    c.comissao = float.Parse(textBoxComissao.Text);
                }

                if (textBoxID.Text == string.Empty)
                {
                    set.setMotorista(c);
                }
                else
                {
                    c.id = int.Parse(textBoxID.Text);
                    set.AlteraMotorista(c);
                }
                MessageBox.Show("Registro salvo com sucesso");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #24
0
        private void DIALOGO(string[] theLines)
        {
            try
            {
                progressBar1.Maximum = theLines.Count();
                progressBar1.Minimum = 0;
                for (int i = 0; i < theLines.Count(); i++)
                {
                    progressBar1.Value = i;
                    if (i >= 19)
                    {
                        DtoDestino destino = new DtoDestino();
                        destino.transportadora = "DIALOGO";
                        destino.documento      = Regex.Match(theLines[i].Substring(11, 9), @"\d+").Value;

                        if (theLines[i + 1].Contains("CENTRO"))
                        {
                            destino.bairro = "CENTRO";
                        }
                        else
                        if (theLines[i + 1].Contains("VILA INDUSTRIAL"))
                        {
                            destino.bairro = "VILA INDUSTRIAL";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM PORTO ALEGRE"))
                        {
                            destino.bairro = "JARDIM PORTO ALEGRE";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM POR"))
                        {
                            destino.bairro = "JARDIM PORTO ALEGRE";
                        }
                        else
                        if (theLines[i + 1].Contains("JD PTO ALEGRE"))
                        {
                            destino.bairro = "JARDIM PORTO ALEGRE";
                        }
                        else
                        if (theLines[i + 1].Contains("JD PORTO ALEGRE"))
                        {
                            destino.bairro = "JARDIM PORTO ALEGRE";
                        }
                        else
                        if (theLines[i + 1].Contains("SANTA CLARA 4"))
                        {
                            destino.bairro = "SANTA CLARA IV";
                        }
                        else
                        if (theLines[i + 1].Contains("SANTA CLARA IV"))
                        {
                            destino.bairro = "SANTA CLARA IV";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM EUR"))
                        {
                            destino.bairro = "JARDIM EUROPA";
                        }
                        else
                        if (theLines[i + 1].Contains("JD EUROPA"))
                        {
                            destino.bairro = "JARDIM EUROPA";
                        }
                        else
                        if (theLines[i + 1].Contains("VILA PIONEIRO"))
                        {
                            destino.bairro = "VILA PIONEIRO";
                        }
                        else
                        if (theLines[i + 1].Contains("Vila Pioneiro"))
                        {
                            destino.bairro = "VILA PIONEIRO";
                        }
                        else
                        if (theLines[i + 1].Contains("VILA PIONE"))
                        {
                            destino.bairro = "VILA PIONEIRO";
                        }
                        else
                        if (theLines[i + 1].Contains("VL PIONEIRO"))
                        {
                            destino.bairro = "VILA PIONEIRO";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM PAULISTA"))
                        {
                            destino.bairro = "JARDIM PAULISTA";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM PAU"))
                        {
                            destino.bairro = "JARDIM PAULISTA";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM PANORAMA"))
                        {
                            destino.bairro = "JARDIM PANORAMA";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM PAN"))
                        {
                            destino.bairro = "JARDIM PANORAMA";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM BRESSAN"))
                        {
                            destino.bairro = "JARDIM BRESSAN";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM BRE"))
                        {
                            destino.bairro = "JARDIM BRESSAN";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM PARIZZOTTO"))
                        {
                            destino.bairro = "JARDIM PARIZZOTTO";
                        }
                        else
                        if (theLines[i + 1].Contains("SAO FRANCISCO"))
                        {
                            destino.bairro = "SAO FRANCISCO";
                        }
                        else
                        if (theLines[i + 1].Contains("SAO FRANCI"))
                        {
                            destino.bairro = "SAO FRANCISCO";
                        }
                        else
                        if (theLines[i + 1].Contains("BOA ESPERANCA"))
                        {
                            destino.bairro = "BOA ESPERANCA";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM CONCORDIA"))
                        {
                            destino.bairro = "JARDIM CONCORDIA";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM CON"))
                        {
                            destino.bairro = "JARDIM CONCORDIA";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM COOPAGRO"))
                        {
                            destino.bairro = "JARDIM COOPAGRO";
                        }
                        else
                        if (theLines[i + 1].Contains("MARACANA"))
                        {
                            destino.bairro = "MARACANA";
                        }
                        else
                        if (theLines[i + 1].Contains("INDEPENDENCIA"))
                        {
                            destino.bairro = "INDEPENDENCIA";
                        }
                        else
                        if (theLines[i + 1].Contains("VILA OPERARIA"))
                        {
                            destino.bairro = "VILA OPERARIA";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM GISELA"))
                        {
                            destino.bairro = "JARDIM GISELA";
                        }
                        else
                        if (theLines[i + 1].Contains("VILA NOVA"))
                        {
                            destino.bairro = "VILA NOVA";
                        }
                        else
                        {
                            destino.bairro = "Não encontrado";
                        }

                        model   get             = new model();
                        Boolean existeDocumento = get.getDestinoDocumento(destino.documento, destino.transportadora);

                        if (!existeDocumento)
                        {
                            if (theLines[i + 1].Contains("-"))
                            {
                                int posicao = theLines[i + 1].IndexOf("-") + 3;
                                destino.nome = theLines[i + 1].Substring(posicao, 25);
                            }
                            else
                            {
                                destino.nome = theLines[i + 1].Substring(0, 30);
                            }
                            int posicaoDacte = theLines[i + 2].IndexOf("DACTE") - 5;
                            destino.endereco = theLines[i + 2].Substring(3, posicaoDacte).Replace('/', ',') + ",Toledo, PR";

                            try
                            {
                                model      m       = new model();
                                DtoLatLong latlong = m.GetLatLongGoogle(destino.endereco);
                                destino.latitude  = Convert.ToDouble(latlong.latitude, CultureInfo.InvariantCulture);
                                destino.longitude = Convert.ToDouble(latlong.longitude, CultureInfo.InvariantCulture);
                                destino.distancia = Convert.ToDouble(latlong.distancia, CultureInfo.InvariantCulture);
                                destino.duracao   = latlong.duracao;
                            }
                            catch (Exception)
                            {
                                destino.status = "E";
                            }
                            destino.status = "I";
                            model post = new model();
                            post.set(destino);
                            i++;
                        }
                        i++;
                    }
                }
                CarregarDestinos();
                progressBar1.Visible = false;
            }
            catch (Exception ex)
            { }
        }
Пример #25
0
        private void TotalExpress(string[] theLines)
        {
            try
            {
                progressBar1.Maximum = theLines.Count();
                progressBar1.Minimum = 0;
                int linha = 0;
                foreach (var l in theLines)
                {
                    linha++;
                    progressBar1.Value = linha;
                    if (linha >= 15 && linha < 48)
                    {
                        string     theLine = l.ToLower();
                        DtoDestino destino = new DtoDestino();
                        destino.transportadora = "TotalExpress";

                        string nrLinha = theLine.Substring(0, 2);
                        if (nrLinha.Trim().Length == 1)
                        {
                            destino.documento = theLine.Substring(20, 9);
                            destino.nome      = theLine.Substring(35);
                            int posicao = theLine.IndexOf("/") + 2;
                            if (theLine.Substring(posicao).Length > 30)
                            {
                                destino.bairro = theLine.Substring(posicao, 30).ToUpper();
                            }
                            else
                            {
                                destino.bairro = theLine.Substring(posicao).ToUpper();
                            }

                            model   get             = new model();
                            Boolean existeDocumento = get.getDestinoDocumento(destino.documento, destino.transportadora);

                            if (!existeDocumento)
                            {
                                if (theLine.Contains("avenida"))
                                {
                                    int posicaoAvenia = theLine.IndexOf("avenida");
                                    destino.endereco = theLine.Substring(posicaoAvenia).Replace('/', ',') + ",Toledo, PR";
                                }
                                else
                                if (theLine.Contains("rua"))
                                {
                                    int posicaoRua = theLine.IndexOf("rua");
                                    destino.endereco = theLine.Substring(posicaoRua).Replace('/', ',') + ",Toledo, PR";
                                }
                                else
                                {
                                    destino.endereco = theLine.Substring(61).Replace('/', ',') + ",Toledo, PR";
                                }
                                try
                                {
                                    model      getlatlng = new model();
                                    DtoLatLong latlong   = getlatlng.GetLatLongGoogle(destino.endereco);
                                    destino.latitude  = Convert.ToDouble(latlong.latitude, CultureInfo.InvariantCulture);
                                    destino.longitude = Convert.ToDouble(latlong.longitude, CultureInfo.InvariantCulture);
                                    destino.distancia = Convert.ToDouble(latlong.distancia, CultureInfo.InvariantCulture);
                                    destino.duracao   = latlong.duracao;
                                }
                                catch (Exception ex)
                                {
                                    destino.status = "E";
                                }
                            }
                        }
                        else
                        {
                            destino.documento = theLine.Substring(20, 9);
                            destino.nome      = theLine.Substring(36);
                            int posicao = theLine.IndexOf("/") + 2;
                            if (theLine.Substring(posicao).Length > 30)
                            {
                                destino.bairro = theLine.Substring(posicao, 30).ToUpper();
                            }

                            destino.documento = theLine.Substring(20, 9);
                            model   get             = new model();
                            Boolean existeDocumento = get.getDestinoDocumento(destino.documento, destino.transportadora);

                            if (!existeDocumento)
                            {
                                if (theLine.Contains("avenida"))
                                {
                                    int posicaoAvenia = theLine.IndexOf("avenida");
                                    destino.endereco = theLine.Substring(posicaoAvenia).Replace('/', ',') + ",Toledo, PR";
                                }
                                else
                                if (theLine.Contains("rua"))
                                {
                                    int posicaoRua = theLine.IndexOf("rua");
                                    destino.endereco = theLine.Substring(posicaoRua).Replace('/', ',') + ",Toledo, PR";
                                }
                                else if (theLine.Contains("rodovia"))
                                {
                                    int posicaoRua = theLine.IndexOf("rodovia");
                                    destino.endereco = theLine.Substring(posicaoRua).Replace('/', ',') + ",Toledo, PR";
                                }
                                else
                                {
                                    destino.endereco = theLine.Substring(61).Replace('/', ',') + ",Toledo, PR";
                                }
                                try
                                {
                                    model      getlatlng = new model();
                                    DtoLatLong latlong   = getlatlng.GetLatLongGoogle(destino.endereco);
                                    destino.latitude  = Convert.ToDouble(latlong.latitude, CultureInfo.InvariantCulture);
                                    destino.longitude = Convert.ToDouble(latlong.longitude, CultureInfo.InvariantCulture);
                                    destino.distancia = Convert.ToDouble(latlong.distancia, CultureInfo.InvariantCulture);
                                    destino.duracao   = latlong.duracao;
                                }
                                catch (Exception)
                                {
                                    destino.status = "E";
                                }
                            }
                        }

                        destino.status = "I";
                        model post = new model();
                        post.set(destino);
                    }
                }
                CarregarDestinos();
                progressBar1.Visible = false;
            }
            catch (Exception ex)
            {
                throw ex;;
            }
        }
Пример #26
0
        private void Jadlog(string[] theLines)
        {
            try
            {
                progressBar1.Maximum = theLines.Count();
                progressBar1.Minimum = 0;

                for (int i = 0; i < theLines.Count(); i++)
                {
                    progressBar1.Value = i;
                    if (theLines[i].Contains("Nome") && theLines[i].Contains("Cep"))
                    {
                        DtoDestino destino = new DtoDestino();
                        destino.transportadora = "JADLOG";
                        if (theLines[i].Contains("NomeNome"))
                        {
                            destino.documento = theLines[i].Substring(9, 14);
                        }
                        else
                        {
                            destino.documento = theLines[i].Substring(5, 14);
                        }
                        model   get             = new model();
                        Boolean existeDocumento = get.getDestinoDocumento(destino.documento, destino.transportadora);

                        if (!existeDocumento)
                        {
                            destino.nome = theLines[i + 1].Substring(0, 29);
                            int posicao       = theLines[i + 1].IndexOf("-");
                            int posicaobairro = (theLines[i - 1].IndexOf("-")) + 1;

                            string bairro = theLines[i - 1].Substring(posicaobairro);
                            destino.bairro   = bairro;
                            destino.endereco = theLines[i + 1].Substring(posicao + 1).Replace('/', ',') + "," + bairro + ",Toledo, PR";

                            model      m       = new model();
                            DtoLatLong latlong = m.GetLatLongGoogle(destino.endereco);

                            try
                            {
                                destino.latitude  = double.Parse(latlong.latitude, CultureInfo.InvariantCulture);
                                destino.longitude = double.Parse(latlong.longitude, CultureInfo.InvariantCulture);
                                destino.distancia = Convert.ToDouble(latlong.distancia, CultureInfo.InvariantCulture);
                                destino.duracao   = latlong.duracao;
                            }
                            catch (Exception)
                            {
                                destino.status = "E";
                            }
                            destino.status = "I";
                            model post = new model();
                            post.set(destino);
                        }
                    }
                }
                CarregarDestinos();
                progressBar1.Visible = false;
            }
            catch (Exception ex)
            {
            }
        }