In my college project, I'm doing the product registration. All right. My problem is loading the supplier in the product register. I created a form frmCadastroProduct and a Form frmCadastroEntry in the product register when I click on search the supplier opens a search screen and I can not bring back the supplier that I selected someone could give me a force. Windows Form 4 Layers
follow below
Product Registration
code
privatevoidpctLocalizaFornecedor_Click(objectsender,EventArgse){frmPesquisarFornecedorpesqFornec=newfrmPesquisarFornecedor(this);pesqFornec.Show();}
SearchProvider
This code is what I tried the most 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);
}
}
}
DTO Provider Class
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 that's right
onthepartscreenisnotworkinginIFif(return==DialogResult.OK)
pq. will it?