private void 设定求和公式ToolStripMenuItem_Click(object sender, EventArgs e) { foreach (Row row in c1FlexGrid1.Rows) { if (c1FlexGrid1.Selection.ContainsRow(row.SafeIndex)) { CalTag tag = row.DataSource as CalTag; List <CalTag> subTags = tag.GetChildTags(); if (subTags.Count > 0) { string forma = ""; foreach (var item in subTags) { if (forma == "") { forma = item.TagFullName; } else { forma += " + " + item.TagFullName; } } tag.Forma = forma; } } } }
private void 设定分摊公式ToolStripMenuItem_Click(object sender, EventArgs e) { NameDialog dialog = new NameDialog(); if (dialog.ShowDialog() == DialogResult.OK) { foreach (Row row in c1FlexGrid1.Rows) { if (c1FlexGrid1.Selection.ContainsRow(row.SafeIndex)) { CalTag tag = row.DataSource as CalTag; CalTag fenTanTag = tag.GetBrotherTag(dialog.Result); if (fenTanTag != null) { List <CalTag> subTags = tag.GetChildTags(); if (subTags.Count > 1) { string lastFormua = ""; for (int i = 0; i < subTags.Count - 1; i++) { CalTag item = subTags[i]; lastFormua += "-" + item.TagFullName; CalTag subFenTag = item.GetBrotherTag(dialog.Result); if (subFenTag != null) { item.Forma = string.Format("{0}*{1}/{2}", tag.TagFullName, subFenTag.TagFullName, fenTanTag.TagFullName); } } subTags[subTags.Count - 1].Forma = tag.TagFullName + lastFormua; } else if (subTags.Count == 1) { subTags[0].Forma = tag.TagFullName; } } } } } }