private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e) { TreeNode node = this.treeView1.SelectedNode; if (node != null) { string clipTags = Clipboard.GetData(DataFormats.UnicodeText).ToString(); System.IO.StringReader strReader = new System.IO.StringReader(clipTags); string tagName = null; while ((tagName = strReader.ReadLine()) != null) { if (node.Tag.GetType() == typeof(CalModel)) { CalModel model = node.Tag as CalModel; if (model != null) { CalTag nTag = model.AddTag(tagName); } } else if (node.Tag.GetType() == typeof(CalOrg)) { CalOrg org = node.Tag as CalOrg; if (org != null) { CalTag nTag = org.AddTag(tagName); } } } strReader.Close(); bindingSource1.ResetBindings(false); } }
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) { foreach (Row row in c1FlexGrid1.Rows) { if (c1FlexGrid1.Selection.ContainsRow(row.SafeIndex)) { CalTag tag = row.DataSource as CalTag; if (tag.TagFullName.StartsWith("累计")) { tag.Forma = tag.TagFullName.Replace("累计", "昨日累计") + "+" + tag.TagFullName.Replace("累计", "本日"); } } } }
private void 制ToolStripMenuItem_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); for (int rowIdx = c1FlexGrid1.Selection.TopRow; rowIdx <= c1FlexGrid1.Selection.BottomRow; rowIdx++) { Row row = c1FlexGrid1.Rows[rowIdx]; CalTag tag = row.DataSource as CalTag; if (tag != null) { sb.AppendLine(tag.TagName); } } Clipboard.SetData(DataFormats.UnicodeText, sb.ToString()); }
private void 移ToolStripMenuItem_Click(object sender, EventArgs e) { if (c1FlexGrid1.RowSel >= 0) { Row row = c1FlexGrid1.Rows[c1FlexGrid1.RowSel]; CalTag tag = row.DataSource as CalTag; if (tag != null) { CalOrg parent = tag.MyCalOrg; if (parent != null) { parent.DownIdx(tag); } } c1FlexGrid1.Refresh(); } }
public void SetValue(string tagName, double val) { if (myModel != null) { CalTag tag = myModel.GetTag(tagName); if (tag == null) { string err = "找不到标签:" + tagName; if (!_errs.Contains(err)) { _errs.Add(err); } } else { tag.TagValue = val; } } }
private void 除标签ToolStripMenuItem1_Click(object sender, EventArgs e) { for (int rowIdx = c1FlexGrid1.Selection.TopRow; rowIdx <= c1FlexGrid1.Selection.BottomRow; rowIdx++) { Row row = c1FlexGrid1.Rows[rowIdx]; CalTag tag = row.DataSource as CalTag; if (tag != null) { if (tag.MyCalOrg != null) { tag.MyCalOrg.RemoveTag(tag); } else { tag.MyModel.RemoveTag(tag); } } } bindingSource1.ResetBindings(false); }
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; } } } } } }
private int SortCalTag(CalTag a1, CalTag a2) { return(a1.TagFullName.CompareTo(a2.TagFullName)); }
public CalModel GetModel(string modelName) { CalModel model = null; Dictionary <string, CalOrg> allOrgs = new Dictionary <string, CalOrg>(); conn.Open(); OracleCommand selectModelCmd = new OracleCommand(); selectModelCmd.Connection = conn; selectModelCmd.CommandText = "Select EID,MODELNAME From CALF_CALMODEL Where MODELNAME='" + modelName + "'"; OracleDataReader drModel = selectModelCmd.ExecuteReader(); if (drModel.Read()) { model = new CalModel(); model.EID = drModel.GetString(0); model.ModelName = drModel.IsDBNull(1) ? "" : drModel.GetString(1); model.ReSet(); } drModel.Close(); if (model != null) { OracleCommand selectOrgCmd = new OracleCommand(); selectOrgCmd.Connection = conn; selectOrgCmd.CommandText = "Select EID,CALMODELID,PARENTID,ORGNAME From CALF_CALORG Where CALMODELID='" + model.EID + "' ORDER By ORGNAME"; OracleDataReader drOrg = selectOrgCmd.ExecuteReader(); while (drOrg.Read()) { CalOrg org = new CalOrg(); org.EID = drOrg.GetString(0); if (allOrgs.ContainsKey(org.EID)) { org = allOrgs[org.EID]; } else { allOrgs.Add(org.EID, org); } org.MyModel = model; model.AllCalOrgs.Add(org); if (!drOrg.IsDBNull(2)) { string parentOrgID = drOrg.GetString(2); if (allOrgs.ContainsKey(parentOrgID)) { org.ParentCalOrg = allOrgs[parentOrgID]; org.ParentCalOrg.ChildCalOrgs.Add(org); } else { CalOrg parentOrg = new CalOrg(); parentOrg.EID = parentOrgID; org.ParentCalOrg = parentOrg; parentOrg.ChildCalOrgs.Add(org); allOrgs.Add(parentOrgID, parentOrg); } } else { model.RootOrgs.Add(org); } org.OrgName = drOrg.IsDBNull(3) ? "" : drOrg.GetString(3); org.ReSet(); } drOrg.Close(); OracleCommand selectTagCmd = new OracleCommand(); selectTagCmd.Connection = conn; selectTagCmd.CommandText = "Select EID,CALMODELID,CALORGID,TAGNAME,FORMA,DEC From CALF_CALTAG Where CALMODELID='" + model.EID + "' order by IDX"; OracleDataReader drTag = selectTagCmd.ExecuteReader(); while (drTag.Read()) { CalTag tag = new CalTag(); tag.EID = drTag.GetString(0); model.AllCalTags.Add(tag); tag.MyModel = model; if (!drTag.IsDBNull(2) && allOrgs.ContainsKey(drTag.GetString(2))) { string parentOrgID = drTag.GetString(2); allOrgs[parentOrgID].CalTags.Add(tag); tag.MyCalOrg = allOrgs[parentOrgID]; } else { model.RootTags.Add(tag); } tag.TagName = drTag.IsDBNull(3) ? "" : drTag.GetString(3); tag.Forma = drTag.IsDBNull(4) ? "" : drTag.GetString(4); if (!drTag.IsDBNull(5)) { tag.Dec = drTag.GetInt32(5); } tag.ReSet(); } drTag.Close(); } conn.Close(); return(model); }
public List <CalModel> GetAllModels() { Dictionary <string, CalModel> allModels = new Dictionary <string, CalModel>(); Dictionary <string, CalOrg> allOrgs = new Dictionary <string, CalOrg>(); conn.Open(); OracleCommand selectModelCmd = new OracleCommand(); selectModelCmd.Connection = conn; selectModelCmd.CommandText = "Select EID,MODELNAME From CALF_CALMODEL order by MODELNAME"; OracleDataReader drModel = selectModelCmd.ExecuteReader(); while (drModel.Read()) { CalModel model = new CalModel(); model.EID = drModel.GetString(0); model.ModelName = drModel.IsDBNull(1) ? "" : drModel.GetString(1); allModels.Add(model.EID, model); model.ReSet(); } drModel.Close(); OracleCommand selectOrgCmd = new OracleCommand(); selectOrgCmd.Connection = conn; selectOrgCmd.CommandText = "Select EID,CALMODELID,PARENTID,ORGNAME From CALF_CALORG order by orgname"; OracleDataReader drOrg = selectOrgCmd.ExecuteReader(); while (drOrg.Read()) { CalOrg org = new CalOrg(); org.EID = drOrg.GetString(0); if (allOrgs.ContainsKey(org.EID)) { org = allOrgs[org.EID]; } else { allOrgs.Add(org.EID, org); } CalModel myModel = allModels[drOrg.GetString(1)]; org.MyModel = myModel; myModel.AllCalOrgs.Add(org); if (!drOrg.IsDBNull(2)) { string parentOrgID = drOrg.GetString(2); if (allOrgs.ContainsKey(parentOrgID)) { org.ParentCalOrg = allOrgs[parentOrgID]; org.ParentCalOrg.ChildCalOrgs.Add(org); } else { CalOrg parentOrg = new CalOrg(); parentOrg.EID = parentOrgID; org.ParentCalOrg = parentOrg; parentOrg.ChildCalOrgs.Add(org); allOrgs.Add(parentOrgID, parentOrg); } } else { myModel.RootOrgs.Add(org); } org.OrgName = drOrg.IsDBNull(3) ? "" : drOrg.GetString(3); org.ReSet(); } drOrg.Close(); OracleCommand selectTagCmd = new OracleCommand(); selectTagCmd.Connection = conn; selectTagCmd.CommandText = "Select EID,CALMODELID,CALORGID,TAGNAME,FORMA,DEC From CALF_CALTAG order by CALMODELID,CALORGID,IDX"; OracleDataReader drTag = selectTagCmd.ExecuteReader(); while (drTag.Read()) { CalTag tag = new CalTag(); tag.EID = drTag.GetString(0); CalModel myModel = allModels[drTag.GetString(1)]; myModel.AllCalTags.Add(tag); tag.MyModel = myModel; if (!drTag.IsDBNull(2)) { string parentOrgID = drTag.GetString(2); allOrgs[parentOrgID].CalTags.Add(tag); tag.MyCalOrg = allOrgs[parentOrgID]; } else { myModel.RootTags.Add(tag); } tag.TagName = drTag.IsDBNull(3) ? "" : drTag.GetString(3); tag.Forma = drTag.IsDBNull(4) ? "" : drTag.GetString(4); if (!drTag.IsDBNull(5)) { tag.Dec = drTag.GetInt32(5); } tag.ReSet(); } drTag.Close(); conn.Close(); List <CalModel> result = new List <CalModel>(); result.AddRange(allModels.Values); return(result); }