private void tvInven_AfterSelect(object sender, TreeViewEventArgs e) { commUse.DataGridViewReset(dgvStructInfo); //清空DataGridView if (tvInven.SelectedNode != null) { if (tvInven.SelectedNode.Tag != null) { BindDataGridView(tvInven.SelectedNode.Tag.ToString()); } } }
private void tvCustomer_AfterSelect(object sender, TreeViewEventArgs e) { commUse.DataGridViewReset(dgvSell); //清空dgvSell commUse.DataGridViewReset(dgvRel); //清空dgvRel commUse.DataGridViewReset(dgvAfter); //清空dgvAfter if (tvCustomer.SelectedNode != null) { if (tvCustomer.SelectedNode.Tag != null) { BindDataGridView(tvCustomer.SelectedNode.Tag.ToString(), "CUSellChance", dgvSell); BindDataGridView(tvCustomer.SelectedNode.Tag.ToString(), "CURelRecord", dgvRel); BindDataGridView(tvCustomer.SelectedNode.Tag.ToString(), "CUAfterService", dgvAfter); } } }
private void tvModule_AfterSelect(object sender, TreeViewEventArgs e) { commUse.DataGridViewReset(dgvINRightInfo);//清空DataGridView if (tvOperator.SelectedNode != null) { if (tvOperator.SelectedNode.Tag != null) { if (tvModule.SelectedNode != null) { if (tvModule.SelectedNode.Tag != null) { //string strSql = "Select OperatorCode,ModuleTag,RightTag,IsRight From SYAssignRight "; //strSql += "Where OperatorCode = '" + tvOperator.SelectedNode.Tag.ToString() + "' and ModuleTag = '" + tvModule.SelectedNode.Tag.ToString() + "'"; string strSql = " SELECT UserID, Moduleid, RightTag, IsRight " + " FROM dbo.SYAssignRight WHERE UserID=" + tvOperator.SelectedNode.Tag.ToString() + " and Moduleid=" + tvModule.SelectedNode.Tag.ToString(); try { sda = new SqlDataAdapter(strSql, db.Conn); SqlCommandBuilder scb = new SqlCommandBuilder(sda); dt = new DataTable(); sda.Fill(dt); bsINRight.DataSource = dt; //BindingSource绑定数据源 dgvINRightInfo.DataSource = bsINRight; //DataGridView控件绑定数据源 //if (dgvINRightInfo.RowCount == 0) //{ // InsertOperation(tvModule.SelectedNode.Tag.ToString());//插入模块的操作权限 //} } catch (Exception ex) { MessageBox.Show(ex.Message, "软件提示"); throw ex; } } } } } }
private void tvModule_AfterSelect(object sender, TreeViewEventArgs e) { commUse.DataGridViewReset(dgvINRightInfo); //清空DataGridView控件 if (tvOperator.SelectedNode != null) //若操作员节点不为空 { if (tvOperator.SelectedNode.Tag != null) //若操作员节点为非根节点 { if (tvModule.SelectedNode != null) //若模块节点为非空 { if (tvModule.SelectedNode.Tag != null) //若模块节点为非根节点 { //查询某个操作员的某个模块的操作权限信息 string strSql = "Select OperatorCode,ModuleTag,RightTag,IsRight From SYAssignRight "; strSql += "Where OperatorCode = '" + tvOperator.SelectedNode.Tag.ToString() + "' and ModuleTag = '" + tvModule.SelectedNode.Tag.ToString() + "'"; try { sda = new SqlDataAdapter(strSql, db.Conn); //实例化SqlDataAdapter //实例化SqlCommandBuilder,用于将数据源所做的更改与关联的SQL Server数据库的更改相协调 SqlCommandBuilder scb = new SqlCommandBuilder(sda); dt = new DataTable(); //实例化DataTable sda.Fill(dt); //将得到的数据源填充到dt中 bsINRight.DataSource = dt; //BindingSource组件绑定到数据源 //DataGridView控件绑定到BindingSource组件 dgvINRightInfo.DataSource = bsINRight; //若无数据行,则插入该模块具有的操作功能及授权信息 if (dgvINRightInfo.RowCount == 0) { InsertOperation(tvModule.SelectedNode.Tag.ToString()); } } catch (Exception ex) //捕获异常信息 { MessageBox.Show(ex.Message, "软件提示"); //异常信息提示 throw ex; } } } } } }