private void dgvljjl_CellClick(object sender, DataGridViewCellEventArgs e) { //MessageBox.Show(e.ColumnIndex.ToString()); this.tabControl_main.SelectedIndex = 1; if (e.RowIndex >= 0 && e.RowIndex < dgvljjl.Rows.Count && e.ColumnIndex >= 0 && e.ColumnIndex < dgvljjl.Columns.Count) { // MessageBox.Show(dgvljjl.Columns.Count.ToString() + " "+ e.ColumnIndex); if (dgvljjl.Columns[e.ColumnIndex].HeaderText == "零件类型基础管理") { addparts addp = new addparts(); string ljh = dgvljjl.Rows[e.RowIndex].Cells["PN"].Value.ToString(); string Barcode = dgvljjl.Rows[e.RowIndex].Cells["Barcode"].Value.ToString(); addp.setenableSetValue(ljh, Barcode); addp.ShowDialog(); return; MessageBox.Show("设置位置"); } string id = dgvljjl.Rows[e.RowIndex].Cells["component"].Value.ToString(); this.textBox_query.Text = id; string where_str = ""; // 通过零件的id或者零件的名字 where_str += string.Format(" componentId= '{0}' ", this.textBox_query.Text); Maticsoft.BLL.component com_bll = new Maticsoft.BLL.component(); DataSet ds = com_bll.GetListByPage2(where_str, "", cur_step, cur_step + cur_page_lenb); DataTable dt = ds.Tables[0]; this.dataGridView1.DataSource = dt; } else { // MessageBox.Show("选中了无效的行"); } }
private void init_dgv() { del_list_for_part.Clear(); #region 获得查询语句 string where_str = " 1=1 "; if (this.textBox_query.Text != "") { // 通过零件的id或者零件的名字 where_str += string.Format(" and ( componentId like '%{0}%' or name like '%{1}%') ", this.textBox_query.Text, this.textBox_query.Text); } Maticsoft.BLL.component com_bll = new Maticsoft.BLL.component(); DataSet ds = com_bll.GetListByPage2(where_str, "", cur_page_lenb * cur_page_num, cur_page_lenb * (1 + cur_page_num)); DataTable dt = ds.Tables[0]; this.dataGridView1.DataSource = dt; #endregion }