private void OpenConfig(ExcelFile Workbook, DataSet ds, TreeNode[] FormatCellNode) { TreeNode UserDefined = tvFields.Nodes.Add(FldMessages.GetString(FldMsg.strUserDefined)); UserDefined.ImageIndex = imgUserDefined; UserDefined.SelectedImageIndex = UserDefined.ImageIndex; TreeNode ReportVarList = tvFields.Nodes.Add(FldMessages.GetString(FldMsg.strReportVars)); ReportVarList.ImageIndex = imgReportVarList; ReportVarList.SelectedImageIndex = ReportVarList.ImageIndex; TreeNode ReportExpList = tvFields.Nodes.Add(FldMessages.GetString(FldMsg.strReportExpressions)); ReportExpList.ImageIndex = imgReportExpList; ReportExpList.SelectedImageIndex = ReportExpList.ImageIndex; TreeNode ReportFormatList = tvFields.Nodes.Add(FldMessages.GetString(FldMsg.strFormats)); ReportFormatList.ImageIndex = imgReportFormatList; ReportFormatList.SelectedImageIndex = ReportFormatList.ImageIndex; for (int i = FirstConfigRow; i <= Workbook.RowCount; i++) { string TableName = Convert.ToString(Workbook.GetCellValue(i, ConfigColTableName)); if (TableName.Length > 0) { string SourceName = Workbook.GetCellValue(i, ConfigColSourceName).ToString(); DataTable dt = ds.Tables[SourceName]; if (dt != null) { AddTable(UserDefined, dt, TableName, imgUserDefinedTable, imgUserDefinedColumn); } } string VarName = Convert.ToString(Workbook.GetCellValue(i, ConfigColVarName)); if (VarName.Length > 0) { TreeNode ReportVar = ReportVarList.Nodes.Add(VarName); ReportVar.ImageIndex = imgReportVar; ReportVar.SelectedImageIndex = ReportVar.ImageIndex; string[] st = { VarName }; ReportVar.Tag = st; } string ExpName = Convert.ToString(Workbook.GetCellValue(i, ConfigColExpName)); if (ExpName.Length > 0) { TreeNode ReportExp = ReportExpList.Nodes.Add(ExpName); ReportExp.ImageIndex = imgReportExp; ReportExp.SelectedImageIndex = ReportExp.ImageIndex; string[] st = { ExpName }; ReportExp.Tag = st; } string FormatName = Convert.ToString(Workbook.GetCellValue(i, ConfigColFormatName)); if (FormatName.Length > 0) { TreeNode ReportFormat = ReportFormatList.Nodes.Add(FormatName); ReportFormat.ImageIndex = imgReportFormat; ReportFormat.SelectedImageIndex = ReportFormat.ImageIndex; string[] st = { FormatName }; ReportFormat.Tag = st; if (FormatCellNode != null && FormatCellNode[0] != null) { ReportFormat = FormatCellNode[0].Nodes.Add(ReportFormat.Text); ReportFormat.Tag = new string[] { ReportTag.StrOpen + ((string[])FormatCellNode[0].Tag)[1] + ReportTag.StrOpenParen + FormatName + ReportTag.StrCloseParen + ReportTag.StrClose }; ReportFormat.ImageIndex = imgReportFormat; ReportFormat.SelectedImageIndex = ReportFormat.ImageIndex; } } } }
private void FillBasicListView(TreeNode[] FormatCellNode) { string opentag = ReportTag.StrOpen; string closetag = ReportTag.StrClose; string septag = ReportTag.DbSeparator; string strOpenParen = ReportTag.StrOpenParen.ToString(); string strSepArg = ReportTag.ParamDelim.ToString(); string strCloseParen = ReportTag.StrCloseParen.ToString(); tvFields.Nodes.Clear(); #region SysTag TreeNode Config = tvFields.Nodes.Add(FldMessages.GetString(FldMsg.strConfig)); Config.ImageIndex = imgConfig; Config.SelectedImageIndex = Config.ImageIndex; TreeNode ConfigSheet = Config.Nodes.Add(FldMessages.GetString(FldMsg.strConfig)); ConfigSheet.ImageIndex = imgFullConfig; ConfigSheet.SelectedImageIndex = ConfigSheet.ImageIndex; foreach (ConfigTagEnum tag in Enum.GetValues(typeof(ConfigTagEnum))) { string s = ReportTag.ConfigTag(tag); TreeNode n = Config.Nodes.Add(s.ToUpper()); string ParamList = ReportTag.ConfigTagParams(tag); string[] sc = { n.Text + ParamList, n.Text }; n.ImageIndex = imgConfigTag; n.SelectedImageIndex = n.ImageIndex; n.Tag = sc; } TreeNode Extras = tvFields.Nodes.Add(FldMessages.GetString(FldMsg.strExtras)); Extras.ImageIndex = imgExtras; Extras.SelectedImageIndex = Extras.ImageIndex; foreach (string s in ReportTag.TagTableKeys) { TreeNode n = Extras.Nodes.Add(s.ToLower()); string ParamList = string.Empty; int ParamCount; if (ReportTag.TryGetTagParams(s, out ParamCount)) { if (ParamCount > 0) { ParamList = strOpenParen.PadRight(strOpenParen.Length + ParamCount - 1, strSepArg[0]) + strCloseParen; } } string[] sc = { opentag + n.Text + ParamList + closetag, n.Text }; n.ImageIndex = imgOneExtra; n.SelectedImageIndex = n.ImageIndex; n.Tag = sc; TValueType TagDef; if (ReportTag.TryGetTag(s, out TagDef)) { if (TagDef == TValueType.IF) { FillIfListView(n); } if (TagDef == TValueType.FormatCell && FormatCellNode != null) { FormatCellNode[0] = n; } } } #endregion #region My Tags //DataSet TreeNode root = tvFields.Nodes.Add("DataSet"); root.ImageIndex = imgDataset; root.SelectedImageIndex = root.ImageIndex; foreach (dData dt in _xlsConfig.Data) { TreeNode rdt = root.Nodes.Add(dt.TableName); rdt.ImageIndex = imgTable; rdt.SelectedImageIndex = rdt.ImageIndex; foreach (dField f in dt.Fields) { TreeNode temp = rdt.Nodes.Add(f.Name); temp.Text = f.Name; temp.ImageIndex = imgColumn; temp.SelectedImageIndex = temp.ImageIndex; string[] sc = { f.TableName, f.Name, temp.Text }; temp.Tag = sc; } TreeNode tempcount = rdt.Nodes.Add("ROWCOUNT"); tempcount.Text = "ROWCOUNT"; tempcount.ImageIndex = imgColumn; tempcount.SelectedImageIndex = tempcount.ImageIndex; string[] scx = new string[] { dt.TableName, "#ROWCOUNT", "#ROWCOUNT" }; tempcount.Tag = scx; TreeNode temppos = rdt.Nodes.Add("ROWPOS"); temppos.Text = "ROWPOS"; temppos.ImageIndex = imgColumn; temppos.SelectedImageIndex = temppos.ImageIndex; scx = new string[] { dt.TableName, "#ROWPOS", "#ROWPOS" }; temppos.Tag = scx; } //Expression TreeNode rootExp = tvFields.Nodes.Add("Expressions"); rootExp.ImageIndex = imgReportExpList; rootExp.SelectedImageIndex = rootExp.ImageIndex; foreach (dExpressions dt in _xlsConfig.Expression) { TreeNode rdt = rootExp.Nodes.Add(dt.Name); rdt.ImageIndex = imgReportExp; rdt.SelectedImageIndex = rdt.ImageIndex; string[] sc = { dt.Name }; rdt.Tag = sc; } //Variables TreeNode rootVal = tvFields.Nodes.Add("Variables"); rootVal.ImageIndex = imgReportVarList; rootVal.SelectedImageIndex = rootVal.ImageIndex; foreach (dReportVariables dt in _xlsConfig.ReportVariable) { TreeNode rdt = rootVal.Nodes.Add(dt.Name); rdt.ImageIndex = imgReportVar; rdt.SelectedImageIndex = rdt.ImageIndex; string[] sc = { dt.Name }; rdt.Tag = sc; } //Format TreeNode rootFor = tvFields.Nodes.Add("Formats"); rootFor.ImageIndex = imgReportFormatList; rootFor.SelectedImageIndex = rootFor.ImageIndex; foreach (dFormat dt in _xlsConfig.Format) { TreeNode rdt = rootFor.Nodes.Add(dt.Name); rdt.ImageIndex = imgReportFormat; rdt.SelectedImageIndex = rdt.ImageIndex; string[] sc = { dt.Value }; rdt.Tag = sc; } /* #region DataField * TreeNode root = tvFields.Nodes.Add("DataField"); * root.ImageIndex = imgDataset; * root.SelectedImageIndex = root.ImageIndex; * * if (dt_list != null) * { * foreach (DataRow row in dt_list.Rows) * { * TreeNode temp = root.Nodes.Add(row["Code"].ToString()); * temp.Text = row["Name"].ToString(); * temp.ImageIndex = imgColumn; * temp.SelectedImageIndex = temp.ImageIndex; * string[] sc = { dt_list.TableName, row["Code"].ToString(), temp.Text }; * temp.Tag = sc; * } * TreeNode tmp = root.Nodes.Add("#ROWPOS"); * tmp.Text = "#ROWPOS"; * tmp.ImageIndex = imgColumn; * tmp.SelectedImageIndex = tmp.ImageIndex; * string[] src = new string[] { dt_list.TableName, tmp.Text, tmp.Text }; * tmp.Tag = src; * * tmp = root.Nodes.Add("#ROWCOUNT"); * tmp.Text = "#ROWCOUNT"; * tmp.ImageIndex = imgColumn; * tmp.SelectedImageIndex = tmp.ImageIndex; * src = new string[] { dt_list.TableName, tmp.Text, tmp.Text }; * tmp.Tag = src; * } * * #endregion DataField * #region Params * TreeNode rootParams = tvFields.Nodes.Add("DataParams"); * rootParams.ImageIndex = imgDataset; * rootParams.SelectedImageIndex = rootParams.ImageIndex; * * if (dt_Params != null) * { * foreach (DataRow row in dt_Params.Rows) * { * TreeNode temp = rootParams.Nodes.Add(row["Code"].ToString()); * temp.Text = row["Name"].ToString(); * temp.ImageIndex = imgColumn; * temp.SelectedImageIndex = temp.ImageIndex; * string[] sc = { dt_Params.TableName, row["Code"].ToString(), temp.Text }; * temp.Tag = sc; * } * * TreeNode tmp = rootParams.Nodes.Add("#ROWPOS"); * tmp.Text = "#ROWPOS"; * tmp.ImageIndex = imgColumn; * tmp.SelectedImageIndex = tmp.ImageIndex; * string[] src = new string[] { dt_Params.TableName, tmp.Text, tmp.Text }; * tmp.Tag = src; * * tmp = rootParams.Nodes.Add("#ROWCOUNT"); * tmp.Text = "#ROWCOUNT"; * tmp.ImageIndex = imgColumn; * tmp.SelectedImageIndex = tmp.ImageIndex; * src = new string[] { dt_Params.TableName, tmp.Text, tmp.Text }; * tmp.Tag = src; * } #endregion */ #region Function TreeNode root1 = tvFields.Nodes.Add("Functions"); root1.ImageIndex = imgUserDefined; root1.SelectedImageIndex = root1.ImageIndex; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(Properties.Resources.MyFunc); XmlElement element = xmlDoc.DocumentElement; foreach (XmlElement node in element.ChildNodes) { string code = node.GetAttribute("Code"); TreeNode tmp = root1.Nodes.Add(code); tmp.ImageIndex = imgUserDefinedColumn; tmp.SelectedImageIndex = tmp.ImageIndex; tmp.Text = node.GetAttribute("Code"); string[] src = new string[] { "", node.GetAttribute("Value"), tmp.Text }; tmp.Tag = src; } #endregion Function /* #region Parameter * TreeNode rootfilter = tvFields.Nodes.Add("Parameter"); * rootfilter.ImageIndex = imgReportExpList; * rootfilter.SelectedImageIndex = rootfilter.ImageIndex; * if (dt_Filter != null) * { * foreach (DataRow row in dt_Filter.Rows) * { * TreeNode tmp = rootfilter.Nodes.Add(row["Code"].ToString()); * tmp.ImageIndex = imgReportExp; * tmp.SelectedImageIndex = tmp.ImageIndex; * tmp.Text = row["Name"].ToString(); * string[] src = new string[] { row["Code"].ToString() }; * tmp.Tag = src; * } * } * #endregion Parameter */ #endregion My Tags }