Beispiel #1
0
        private void uiTxtSearch_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab)
            {
                if (uiTxtSearch.TextLength == 11)
                {
                    if (UtilValidar.validarCPF(uiTxtSearch.Text))
                    {
                        currentCustomerFisico = new CustomerFisico()
                        {
                            CPF = uiTxtSearch.Text
                        }.ObterPorCPF();

                        if (currentCustomerFisico != null)
                        {
                            UtilCreatePanel.CreateCustomerFPanel(currentCustomerFisico, uiFlowPanel, Customer_Click);
                            flowPanelCustomerF.Visible = false;
                        }
                        else
                        {
                            new Alert("Não possui cliente com o CPF inserido.", uiCSB.Toastr.Type.Warning);
                            uiTxtSearch.Text = string.Empty;
                        }
                    }
                    else
                    {
                        new Alert("O CPF inserido é inválido.", uiCSB.Toastr.Type.Warning);
                        uiTxtSearch.Text = string.Empty;
                    }
                }
                else if (uiTxtSearch.TextLength == 14)
                {
                    if (UtilValidar.validarCNPJ(uiTxtSearch.Text))
                    {
                        currentCustomerJuridico = new CustomerJuridico()
                        {
                            CNPJ = uiTxtSearch.Text
                        }.ObterPorCNPJ();

                        if (currentCustomerJuridico != null)
                        {
                        }
                        else
                        {
                            new Alert("Não possui cliente com o CNPJ inserido.", uiCSB.Toastr.Type.Warning);
                            uiTxtSearch.Text = string.Empty;
                        }
                    }
                    else
                    {
                        new Alert("O CNPJ inserido é inválido.", uiCSB.Toastr.Type.Warning);
                        uiTxtSearch.Text = string.Empty;
                    }
                }
            }
        }
Beispiel #2
0
        private void uiTxtSearch_TextChanged(object sender, EventArgs e)
        {
            uiFlowPanel.Controls.Clear();
            currentCustomerJuridico = null;
            currentCustomerFisico   = null;

            if (uiTxtSearch.TextLength == 11)
            {
                if (UtilValidar.validarCPF(uiTxtSearch.Text))
                {
                    currentCustomerFisico = new CustomerFisico()
                    {
                        CPF = uiTxtSearch.Text
                    }.ObterPorCPF();

                    if (currentCustomerFisico != null)
                    {
                        UtilCreatePanel.CreateCustomerFPanel(currentCustomerFisico, uiFlowPanel, Customer_Click);
                        flowPanelCustomerF.Visible = false;
                    }
                    else
                    {
                        new Alert("Não possui cliente com o CPF inserido.", uiCSB.Toastr.Type.Warning);
                    }
                }
            }
            else if (uiTxtSearch.TextLength == 14)
            {
                if (UtilValidar.validarCNPJ(uiTxtSearch.Text))
                {
                    currentCustomerJuridico = new CustomerJuridico()
                    {
                        CNPJ = uiTxtSearch.Text
                    }.ObterPorCNPJ();

                    if (currentCustomerJuridico != null)
                    {
                        UtilCreatePanel.CreateCustomerJPanel(currentCustomerJuridico, uiFlowPanel, Customer_Click);
                        flowPanelCustomerJ.Visible = false;
                    }
                    else
                    {
                        new Alert("Não possui cliente com o CNPJ inserido.", uiCSB.Toastr.Type.Warning);
                        uiTxtSearch.Text = string.Empty;
                    }
                }
                else
                {
                    new Alert("O CNPJ inserido é inválido.", uiCSB.Toastr.Type.Warning);
                    uiTxtSearch.Text = string.Empty;
                    uiTxtSearch.Focus();
                }
            }
        }