using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using BLL; using DAL; namespace IBRCAD { public partial class frm_consultasubcategoria : Form { public int codigo = 0; public frm_consultasubcategoria() { InitializeComponent(); } private void Frm_consultasubcategoria_Load(object sender, EventArgs e) { this.Btn_localizar_Click(sender, e); this.OrgCampos(dgv_dados); }//load private void Btn_localizar_Click(object sender, EventArgs e) { DALLconexao cx = new DALLconexao(DadosDaConexao.StringDeConexao); BLLSubCategoria bll = new BLLSubCategoria(cx); dgv_dados.DataSource = bll.Localizar(txt_pesquisa.Text); }//botão localizar private void Dgv_dados_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { this.codigo = Convert.ToInt32(dgv_dados.Rows[e.RowIndex].Cells[0].Value); this.Close(); } } private void OrgCampos(DataGridView grid) { grid.Columns[0].Width = 60; grid.Columns[0].HeaderText = "Código"; grid.Columns[1].Width = 300; grid.Columns[1].HeaderText = "Nome da subCategoria"; grid.Columns[2].Width = 150; grid.Columns[2].HeaderText = "Código da categoria"; grid.Columns[3].Width = 190; grid.Columns[3].HeaderText = "Nome da categoria"; }//organiza melhor o datagridview private void pb_exit_Click(object sender, EventArgs e) { this.Close(); }//end exit } }