Take the data searchFornecedor and put in the form of product registration

Asked

Viewed 981 times

0

I cannot take the data from the Pesqvendor form and put it in the formCadastroProdu

My project is in C# Windows Forms in 4 layers.

did so

Tela Cadastro de Peças

frmCasters

    private void pctLocalizaFornecedor_Click(object sender, EventArgs e)
    {
        frmPesquisarFornecedor pesqFornec = new frmPesquisarFornecedor();

        pesqFornec.Show(this);


    }

Pesquisar Fornecedor

frmPesquisarFornecedor

    public partial class frmPesquisarFornecedor : Form
{
    private Form codFornec;
    public frmPesquisarFornecedor()
    {
        InitializeComponent();
    }

    public frmPesquisarFornecedor(Form codFornec)
    {
        InitializeComponent();

        this.codFornec = codFornec;


    }


    private void frmPesquisarFornecedor_Load(object sender, EventArgs e)
    {
        CarregaGrid();

    }

    private void CarregaGrid()
    {
        try
        {
            IList<FornecedorDTO> listaFornecDTO = new List<FornecedorDTO>();

            listaFornecDTO = new FornecedorModel().CargaFornecedor();// Cria uma estancia do Objeto UsuarioModel
            dgvFornecedor.AutoGenerateColumns = false;// Não vai gerar colunas automaticamente
            dgvFornecedor.DataSource = listaFornecDTO;// carrega o meu grid DataSource ListaUsuarioDTO



        }
        catch (Exception ex)
        {

            MessageBox.Show(ex.Message);
        }
    }

    #endregion

    private void frmPesquisarFornecedor_FormClosed(object sender, FormClosedEventArgs e)
    {
        // Não sei o que colocar AQUI ??????
    }



}

}

needed to load the selected vendor into frmCadastroPecas

I’m not able to get him to press frmCadastroPecas it shows supplier Cod 0 someone would have some solution

thank you

  • has yes face. You have two cool ways of doing: 1: You can create a new form (aspx) that when the guy clicks on the search button, open that popup. You’ll be chatting with the bottom screen by Session, for example. 2: Another way, which I think is best, to create a usercontrol. This can be opened by modal (it would be nice for you to use bootstrap). If you didn’t understand anything I said, unfortunately you will need to look for an example on the internet to know how to do it...

  • This is simple, creates screen with gridView, in the event form_load you load all suppliers, in the event of the click of the grid you take the data of the provider and click on the previous screen, that is the basic explanation. Be it case go trying to do and posting the doubts of each step.

  • If the answer helped you, please mark it

1 answer

1

come on:

in the search form, create a Provider property to return it:

public FornecedorDTO Retorno {get;set;}

and I imagine the ok button will select the correct supplier ? in his code, do it like this:

private void buttonOk_Click(object sender, EventArgs e)
{
      Retorno = (Aqui você atribui o objeto selecionado)
      this.DialogResult = System.Windows.Forms.DialogResult.OK;
}

now in the registration form:

 private void pctLocalizaFornecedor_Click(object sender, EventArgs e)
 {
     frmPesquisarFornecedor pesqFornec = new frmPesquisarFornecedor();
     if (pesqFornec.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
        "seucampoFornecedor".Text = pesqFornec.Retorno.Codigo;
        //Carrega os outros campos
     }
     //se não entrar no if, não faz nada porque a pesquisa foi cancelada.
 }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.