Good morning, I need some help from you in my college project. I'm doing an inventory system with 4 layers, I have a form that is a company record where I register the user company that the user wants to work, when I enter the system, I choose the company that the user wants to work in the moment, how do I make the data to be from that company, for example company I will have the stock movements of company A, when I choose company B I will have the company moves B made the screen
code
Form
publicfrmSelEmpUsuaria(){InitializeComponent();}privatevoidfrmSelEmpUsuaria_Load(objectsender,EventArgse){CarregaEmpresaUsuaria();}privatevoidCarregaEmpresaUsuaria(){try{IList<EmpresaUsuariaDTO>listaEmpresaUsuaria=newList<EmpresaUsuariaDTO>();listaEmpresaUsuaria=newEmpresaUsuariaModel().ListaEmpresa();dgvEmpresaUsuaria.AutoGenerateColumns=false;dgvEmpresaUsuaria.DataSource=listaEmpresaUsuaria;}catch(Exceptionerro){MessageBox.Show(erro.Message);}}privatevoidbtnConfirmar_Click(objectsender,EventArgse){//Nãoseiocodigoquevainobotão}privatevoidbtnCancelar_Click(objectsender,EventArgse){this.Close();}}
DAOlayer
publicIList<EmpresaUsuariaDTO>ListaEmpresa(){try{SqlConnectionCON=newSqlConnection();CON.ConnectionString=Properties.Settings.Default.csSistemaEstoque;SqlCommandCM=newSqlCommand();CM.CommandType=System.Data.CommandType.Text;CM.CommandText="SELECT * FROM tbEmpresaUsuaria";
CM.Connection = CON;
SqlDataReader ER;
IList<EmpresaUsuariaDTO> ListaEmpresa = new List<EmpresaUsuariaDTO>();
CON.Open();
ER = CM.ExecuteReader();
if (ER.HasRows)
{
while (ER.Read())
{
EmpresaUsuariaDTO empresaUsu = new EmpresaUsuariaDTO();
empresaUsu.Codigo = Convert.ToInt32(ER["cod_emp"]);
empresaUsu.DataCadastro = Convert.ToDateTime(ER["dtInclusao_emp"]);
empresaUsu.NomeRazao = Convert.ToString(ER["razao_emp"]);
empresaUsu.NomeFantasia = Convert.ToString(ER["nomeFant_emp"]);
empresaUsu.CpfCnpj = Convert.ToString(ER["cnpj_emp"]);
empresaUsu.RgInscricao = Convert.ToString(ER["inscEst_emp"]);
empresaUsu.Endereco = Convert.ToString(ER["endereco_emp"]);
empresaUsu.Numero = Convert.ToString(ER["numero_emp"]);
empresaUsu.Complemento = Convert.ToString(ER["compl_emp"]);
empresaUsu.Bairro = Convert.ToString(ER["bairro_emp"]);
empresaUsu.Cidade = Convert.ToString(ER["cidade_emp"]);
empresaUsu.Uf = Convert.ToString(ER["uf_emp"]);
empresaUsu.Cep = Convert.ToString(ER["cep_emp"]);
empresaUsu.Telefone = Convert.ToString(ER["tel_emp"]);
empresaUsu.Tel2 = Convert.ToString(ER["tel2_emp"]);
empresaUsu.Email = Convert.ToString(ER["email_emp"]);
empresaUsu.Site = Convert.ToString(ER["site_emp"]);
empresaUsu.EndLogo = Convert.ToString(ER["endLogo_emp"]);
ListaEmpresa.Add(empresaUsu);
}
}
return ListaEmpresa;
}
catch (Exception ex)
{
throw ex;
}
}
Could someone give me strength?