private void GetParentPath(decimal resourceId, ref string path) { for (int i = 0; i < resourceTable.Rows.Count; i++) { GTSDB.TA_SecurityResourceRow resourceRow = (GTSDB.TA_SecurityResourceRow)resourceTable.Rows[i]; if (resourceRow.resource_ID == resourceId) { if ((resourceTable.Rows[i][ParentFiledName] == DBNull.Value ? 0 : resourceRow.resource_ParentID) > 0) { path += "," + resourceRow.resource_ParentID.ToString(); this.GetParentPath(resourceRow.resource_ParentID, ref path); } } } }
private void button1_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; for (int i = 0; i < resourceTable.Rows.Count; i++) { GTSDB.TA_SecurityResourceRow resourceRow = (GTSDB.TA_SecurityResourceRow)resourceTable.Rows[i]; if ((resourceTable.Rows[i][ParentFiledName] == DBNull.Value ? 0 : resourceRow.resource_ParentID) > 0) { string path = ""; this.GetParentPath(resourceRow.resource_ID, ref path); resource.UpdateParentPath(path + ",", resourceRow.resource_ID); } } Cursor = Cursors.Default; MessageBox.Show("با موفقیت به پایان رسید"); }