Example #1
0
        private void ExecutaPesquisaCliente()
        {
            frmPesquisaClientes pesquisa = new frmPesquisaClientes();

            if (pesquisa.ExibeDialogo(txtCodCliIntegracao.Text) == DialogResult.OK)
            {
                if (pesquisa.Id != null)
                {
                    clienteBLL = new ClienteBLL();
                    Cliente cliente = clienteBLL.Localizar(pesquisa.Id);
                    if (cliente != null)
                    {
                        txtCodCliIntegracao.Text = cliente.codigo_cliente_integracao;
                        txtClienteNome.Text      = cliente.nome_fantasia;
                        txtIdCliente.Text        = cliente.Id.ToString();
                        if (cliente.cliente_vendedor.Count > 0)
                        {
                            Id         = cliente.cliente_vendedor.FirstOrDefault().Id;
                            txtId.Text = Convert.ToString(Id);
                            cbVendedor.SelectedValue = cliente.cliente_vendedor.FirstOrDefault().Id_Vendedor;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Cliente não localizado.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtCodCliIntegracao.Text = String.Empty;
                }
            }
            else
            {
                txtCodCliIntegracao.Focus();
            }
        }
Example #2
0
        private void ExecutaPesquisaCliente(TextBox txtId, TextBox txtCod, TextBox txtDesc = null)
        {
            frmPesquisaClientes pesquisa = new frmPesquisaClientes();

            if (pesquisa.ExibeDialogo(txtCod.Text) == DialogResult.OK)
            {
                if (pesquisa.Id != null)
                {
                    LoadDadosCliente(pesquisa.Id, string.Empty, txtId, txtCod, txtDesc);
                }
            }
        }
Example #3
0
        private void ExecutaPesquisaCliente()
        {
            frmPesquisaClientes pesquisa = new frmPesquisaClientes();

            if (pesquisa.ExibeDialogo(txtCodCliIntegracao.Text) == DialogResult.OK)
            {
                if (pesquisa.Id != null)
                {
                    clienteBLL = new ClienteBLL();
                    Cliente cliente = clienteBLL.Localizar(pesquisa.Id);
                    if (cliente != null)
                    {
                        txtCodCliIntegracao.Text = cliente.codigo_cliente_integracao;
                        txtClienteNome.Text      = cliente.nome_fantasia;
                        txtIdCliente.Text        = cliente.Id.ToString();

                        Cliente_Parcela cliente_Parcela = cliente.cliente_parcela.FirstOrDefault();
                        if (cliente_Parcela != null)
                        {
                            cbCondPagamento.SelectedValue = cliente_Parcela.Id_parcela;
                        }
                        if (Id == null)
                        {
                            txtDtEmissao.Text = DateTime.Now.ToShortDateString();
                        }

                        if (cliente.cliente_transportadora.Count() > 0)
                        {
                            Cliente_Transportadora cliente_Transportadora = cliente.cliente_transportadora.First();
                            if (cliente_Transportadora != null)
                            {
                                cbTransportadora.SelectedValue = cliente_Transportadora.Id_transportadora;
                            }
                        }
                        else
                        {
                            //Vamos sugerir a transportadora pela localidade do cliente.
                            RotaBLL      rotaBLL  = new RotaBLL();
                            IList <Rota> RotaList = rotaBLL.getRota(p => p.cidade.cCod == cliente.cidade);
                            if (RotaList.Count > 0)
                            {
                                cbTransportadora.SelectedValue = RotaList.First().id_transportadora;
                            }
                        }

                        if (cliente.cliente_vendedor.Count() > 0)
                        {
                            Cliente_Vendedor cliente_Vendedor = cliente.cliente_vendedor.First();
                            if (cliente_Vendedor != null)
                            {
                                cbVendedor.SelectedValue = cliente_Vendedor.Id_Vendedor;
                            }
                        }
                        else
                        {
                            //Vamos sugerir a transportadora pela localidade do cliente.
                            vendedor_LocalidadeBLL = new Vendedor_LocalidadeBLL();
                            IList <Vendedor_Localidade> vendlocList = vendedor_LocalidadeBLL.getVendedor_Localidade(p => p.cidade.cCod == cliente.cidade);

                            if (vendlocList.Count > 0)
                            {
                                cbVendedor.SelectedValue = vendlocList.First().Id_vendedor;
                            }
                        }


                        txtDtFechamento.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("Cliente não localizado.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtCodCliIntegracao.Text = String.Empty;
                }
            }
            else
            {
                txtCodCliIntegracao.Focus();
            }
        }