DataSet.Relations一例

DataSet.Relations一例 DataSet ds = Database.ExecuteDataSet(CommandType.Text, "SELECT * FROM SR_RegulationReclassify WHERE SchemeID='" + this.ID + "' order by pid,sid desc"); DataTable dt = scheme.RegulationReclassifyTable; if (dt != null && dt.Rows.Count > 0) { //有重分类信息 this.SystemALLRegColl = scheme.GetAllRegulation(); int subErrorCount = 0; dt.DataSet.Relations.Add("ReClassRelation", dt.Columns["id"], dt.Columns["pid"]); string id = ""; string pid = ""; string Caption = ""; int type = -1; DataRow[] drArray=dt.Select("id=pid", "sid"); foreach (DataRow dbRow in drArray) { subErrorCount = 0; id = dbRow["id"].ToString(); pid = dbRow["pid"].ToString(); Caption = dbRow["Caption"].ToString(); type = CommonClass.TInt(dbRow["type"]); if (id == pid && type != 1) { TreeListViewItem rgTN = new TreeListViewItem(Caption, SrImageList.Instance.GetImageIndex("Namespace")); rgTN.Tag = dbRow; this.LoopRegGroup_ReClass(dbRow, rgTN, ref subErrorCount); if (rgTN.Items.Count > 0) { this.RegTree.Items.Add(rgTN); } rgTN.Text = rgTN.Text + "(" + subErrorCount.ToString() + ")"; Application.DoEvents(); } } } //递归函数 重分类式 OK private void LoopRegGroup_ReClass(DataRow dbRow, TreeListViewItem rgTN, ref int subErrorCount) { int RegErrorCount = 0; string id = ""; string pid = ""; string Caption = ""; int type = -1; IRegulation tmpReg = null; foreach (DataRow childRow in dbRow.GetChildRows("ReClassRelation")) { RegErrorCount = 0; id = childRow["id"].ToString(); pid = childRow["pid"].ToString(); Caption = childRow["Caption"].ToString(); type = CommonClass.TInt(childRow["type"]); if (id != pid) { if (type == 1) { //叶子节点 //TreeListViewItem SubRgTN = new TreeListViewItem(Caption, SrImageList.Instance.GetImageIndex("TopologyRule")); //SubRgTN.Tag = childRow; tmpReg = this.SystemALLRegColl.IndexOf(id); if (tmpReg != null) { tmpReg = ExplainFactory.GetRegulationByFactParam(tmpReg); if (tmpReg != null && tmpReg.Template != null && tmpReg.Template.ResultSaveToDB != null) { RegErrorCount = tmpReg.Template.ResultSaveToDB.GetErrorCount(); } } //SubRgTN.Tag = tmpReg; //rgTN.Items.Add(SubRgTN); //SubRgTN.Text = SubRgTN.Text + "(" + RegErrorCount.ToString() + ")"; subErrorCount += RegErrorCount; } else { //重分组 TreeListViewItem SubRgTN = new TreeListViewItem(Caption, SrImageList.Instance.GetImageIndex("Namespace")); SubRgTN.Tag = childRow; this.LoopRegGroup_ReClass(childRow, SubRgTN, ref RegErrorCount); rgTN.Items.Add(SubRgTN); SubRgTN.Text = SubRgTN.Text + "(" + RegErrorCount.ToString() + ")"; subErrorCount += RegErrorCount; } } Application.DoEvents(); } } 

转载于:https://www.cnblogs.com/sqlite3/archive/2010/03/08/2566956.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值