4
in my college project I am doing the product registration ta all right my problem is to load the supplier in the product registration. I created a form frmCartiroProduct and a form frmCadastroFornrcedor in the product registration when I click on search the supplier opens a search screen and I can’t bring back the vendor I selected someone could give me a strength. Windows Form 4 layers
goes down
Product Registration
code
private void pctLocalizaFornecedor_Click(object sender, EventArgs e)
{
frmPesquisarFornecedor pesqFornec = new frmPesquisarFornecedor(this);
pesqFornec.Show();
}
Search Supplier
Code what this commented was what I tried more did not work
public partial class frmPesquisarFornecedor : Form
{
// private int CodFornec;
//private Form codFornecedor;
frmCadastroPecas codFornecedor;
public frmPesquisarFornecedor()
{
InitializeComponent();
}
public frmPesquisarFornecedor(frmCadastroPecas fm1)
{
InitializeComponent();
codFornecedor = fm1;
//tbxTextBoxFormB.Text = instanciaDoForm1.tbxTextBoxFormA.Text.ToString();
}
//public frmPesquisarFornecedor(int codFornec)
//{
// InitializeComponent();
// CodFornec = codFornec;
//}
private void frmPesquisarFornecedor_Load(object sender, EventArgs e)
{
CarregaGrid();
}
#region Carregar o Grid Fornecedor
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)
{
frmCadastroPecas obj = new frmCadastroPecas();
// obj.codForn = Convert.ToInt32(txtCodigoFornec.Text);
}
private void dgvFornecedor_CellClick(object sender, DataGridViewCellEventArgs e)
{
int sel = dgvFornecedor.CurrentRow.Index;
txtCodigoFornec.Text = Convert.ToString(dgvFornecedor["Codigo", sel].Value);
txtRazaoSocial.Text = Convert.ToString(dgvFornecedor["NomeRazao", sel].Value);
txtNomeFantasia.Text = Convert.ToString(dgvFornecedor["NomeFantasia", sel].Value);
}
private void btnOk_Click(object sender, EventArgs e)
{
//PesqFornecDTO objFornec = new PesqFornecDTO();
//objFornec.Codigo = Convert.ToInt32(txtCodigoFornec.Text);
//frmCadastroPecas obj = new frmCadastroPecas();
//obj.codForn = Convert.ToInt32(txtCodigoFornec.Text);
frmCadastroPecas obj = new frmCadastroPecas();
// obj.codForn = Convert.ToInt32(txtCodigoFornec.Text);
}
}
}
Class of Supplier
public class FornecedorDTO:PessoaDTO
{
private int codigo;
private Double vlMinCompra;
private String telefone2;
private String contato;
private int ramal;
private String userConectado;
#region Getters e Setters
public int Codigo
{
get { return codigo; }
set { codigo = value; }
}
public String Telefone2
{
get { return telefone2; }
set { telefone2 = value; }
}
public String Contato
{
get { return contato; }
set { contato = value; }
}
public Double VlMinCompra
{
get { return vlMinCompra; }
set { vlMinCompra = value; }
}
public int Ramal
{
get { return ramal; }
set { ramal = value; }
}
public String UserConectado
{
get { return userConectado; }
set { userConectado = value; }
}
on the search screen this right
in the tile screen this entry is not in the if (return == Dialogresult.OK)
pq. will be ?
It did not work following the error in the question thanks for helping me
– Denilson Carlos
How strange I’ll check!
– Fernando Vellozo
if I do so it works that if Loko thing (return == Dialogresult.Cancel)
– Denilson Carlos
I already ran the code, I forgot Dialogresult.OK, sorry!
– Fernando Vellozo
You are the very Thanks Guy will save my life, by the end of the year I’ll have a lot of doubt. I am programming alone in the group and nobody knows and do not even want to learn more I know that I am already learning a lot from this and in the future I can be here helping people as well as you. Thank you very much
– Denilson Carlos
only one more thing what makes this line using (var form = new frmPesquisarFornecedor())
– Denilson Carlos
That’s aew fera I’m very happy to have helped, with continue firm in your studies you will go far, thanks!
– Fernando Vellozo
The code inside the Using serves to ensure that the objects are deleted from the memory once the execution of the same, for more information visit this link: https://msdn.microsoft.com/pt-br/library/yh598w02.aspx
– Fernando Vellozo