Example #1
0
 public FormConsultaCadastroResult(RetConsCad vConsCad)
 {
     InitializeComponent();
     this.vConsCad = vConsCad;
 }
Example #2
0
        private void metroButton1_Click(object sender, EventArgs e)
        {
            FocusF();

            this.textResultado.Text = "Consultando o servidor. Aguarde....";
            this.Refresh();

            RetConsCad vConsCad = null;

            try
            {
                if (string.IsNullOrEmpty(this.textConteudo.Text))
                {
                    throw new Exception("Conteúdo para pesquisa deve ser informado");
                }

                object vvConsCad = null;

                if (rbCNPJ.Checked)
                {
                    vvConsCad = ConsultaCadastro((string)this.comboUf.SelectedValue, this.textConteudo.Text, string.Empty, string.Empty);
                }
                else
                if (rbCPF.Checked)
                {
                    vvConsCad = ConsultaCadastro((string)this.comboUf.SelectedValue, string.Empty, string.Empty, this.textConteudo.Text);
                }
                else
                {
                    vvConsCad = ConsultaCadastro((string)this.comboUf.SelectedValue, string.Empty, this.textConteudo.Text, string.Empty);
                }

                if (vvConsCad is RetConsCad)
                {
                    vConsCad = (vvConsCad as RetConsCad);
                    if (vConsCad == null)
                    {
                        this.textResultado.Text = "Não pode obter a resposta do Sefaz";
                    }
                }
                else
                {
                    throw new Exception((string)vvConsCad);
                }
            }
            catch (Exception ex)
            {
                this.textResultado.Text = ex.Message;
                vConsCad = null;
            }
            finally
            {
                if (vConsCad != null)
                {
                    this.textResultado.Text = "";

                    if (vConsCad.infCad.Count > 0)
                    {
                        this.Visible = false;

                        Form parent = (Form)this.Parent;

                        var icc = rst == null ? -1 : parent.Controls.IndexOf(rst);
                        if (icc >= 0)
                        {
                            (parent.Controls[icc] as UserControl1).UpdateControles();
                            parent.Controls[icc].Visible = true;
                        }
                        else
                        {
                            rst          = new userCadastroResult();
                            rst.vConsCad = vConsCad;
                            rst.UpdateControles();

                            rst.back_button.Click += delegate
                            {
                                rst.Visible = false;
                                icc         = parent.Controls.IndexOf(rst);
                                parent.Controls.RemoveAt(icc);
                                rst.Dispose();

                                this.Visible = true;
                                this.FocusF();
                            };
                            parent.Controls.Add(rst);
                            rst.Visible = true;
                        }
                    }
                    else
                    {
                        this.textResultado.Text = vConsCad.xMotivo;
                    }
                }
            }
        }
Example #3
0
        private void buttonPesquisaCNPJ_Click(object sender, EventArgs e)
        {
            this.textConteudo.Focus();
            this.toolStripStatusLabel1.Text = _wait;
            this.textResultado.Text         = "";
            this.Refresh();

            this.Cursor = Cursors.WaitCursor;

            RetConsCad vConsCad = null;

            try
            {
                object vvConsCad = null;

                if (rbCNPJ.Checked)
                {
                    vvConsCad = ConsultaCadastro((string)this.comboUf.SelectedValue, this.textConteudo.Text, string.Empty, string.Empty);
                }
                else
                if (rbCPF.Checked)
                {
                    vvConsCad = ConsultaCadastro((string)this.comboUf.SelectedValue, string.Empty, string.Empty, this.textConteudo.Text);
                }
                else
                {
                    vvConsCad = ConsultaCadastro((string)this.comboUf.SelectedValue, string.Empty, this.textConteudo.Text, string.Empty);
                }

                if (vvConsCad is RetConsCad)
                {
                    vConsCad = (vvConsCad as RetConsCad);
                    if (vConsCad == null)
                    {
                        this.textResultado.Text = "Não pode obter a resposta do Sefaz";
                    }
                }
                else
                {
                    throw new Exception((string)vvConsCad);
                }
            }
            catch (Exception ex)
            {
                this.textResultado.Text = ex.Message;
                vConsCad = null;
            }
            finally
            {
                this.Cursor = Cursors.Default;
                this.toolStripStatusLabel1.Text = "";
                if (vConsCad != null)
                {
                    if (vConsCad.infCad.Count > 0)
                    {
                        using (FormConsultaCadastroResult fResult = new FormConsultaCadastroResult(vConsCad))
                        {
                            fResult.ShowDialog();
                        }
                    }
                    else
                    {
                        this.textResultado.Text = vConsCad.xMotivo;
                    }
                }
            }
        }