private void Delete(int i) { dbtblNumberInfo num = new dbtblNumberInfo(); int t_sex = num.GetPersonSex(i); num.CarryOutSqlSentence("delete from [Family].[dbo].[tblNumberInfo] where NiId=" + i); num.CarryOutSqlSentence("delete from [Family].[dbo].[tblNumberInfo] where NiSpouseId = " + i); if (t_sex == 1) //女族人 { DataTable db = num.MotherGetChilDataTable(i); for (int j = 0; j < db.Rows.Count; j++) { if (num.GetChildCount(j, t_sex) != 0) { Delete(Convert.ToInt32(db.Rows[j]["NiId"])); } num.CarryOutSqlSentence("delete from [Family].[dbo].[tblNumberInfo] where NiId=" + db.Rows[j]["NiId"].ToString()); num.CarryOutSqlSentence("delete from [Family].[dbo].[tblNumberInfo] where NiSpouseId = " + db.Rows[j]["NiId"].ToString()); } } else { DataTable db = num.FatherGetChilDataTable(i); for (int j = 0; j < db.Rows.Count; j++) { if (num.GetChildCount(j, t_sex) != 0) { Delete(Convert.ToInt32(db.Rows[j]["NiId"])); } num.CarryOutSqlSentence("delete from [Family].[dbo].[tblNumberInfo] where NiId=" + db.Rows[j]["NiId"].ToString()); num.CarryOutSqlSentence("delete from [Family].[dbo].[tblNumberInfo] where NiSpouseId = " + db.Rows[j]["NiId"].ToString()); } } }
private void BindChildNode(TreeNode tnTop) { dbvwNumberInfo vw = new dbvwNumberInfo(); dbtblNumberInfo num = new dbtblNumberInfo(); int i = Convert.ToInt32(tnTop.Tag.ToString()); int t_sex = num.GetPersonSex(i); if (t_sex == 1)//女族人 { DataTable db = num.MotherGetChilDataTable(i); for (int j = 0; j < db.Rows.Count; j++) { TreeNode node = new TreeNode(); node.Tag = db.Rows[j]["NiId"]; if (num.GetPersonSex(Convert.ToInt32(db.Rows[j]["NiId"])) == 1) { node.Text = "女:" + db.Rows[j]["NiName"].ToString(); } else { node.Text = "男:" + db.Rows[j]["NiName"].ToString(); } tnTop.Nodes.Add(node); if (num.GetChildCount(i) != 0) { BindChildNode(node); } } } else if (t_sex == 0)//女族人 { DataTable db = num.FatherGetChilDataTable(i); for (int j = 0; j < db.Rows.Count; j++) { TreeNode node = new TreeNode(); node.Tag = db.Rows[j]["NiId"]; if (num.GetPersonSex(Convert.ToInt32(db.Rows[j]["NiId"])) == 1) { node.Text = "女:" + db.Rows[j]["NiName"].ToString(); } else { node.Text = "男:" + db.Rows[j]["NiName"].ToString(); } tnTop.Nodes.Add(node); if (num.GetChildCount(i) != 0) { BindChildNode(node); } } } }