private void ShowGraph() { if (plGraph.Tag == null) { return; } DataTable tbData = (DataTable)plGraph.Tag; TableColumn[] columns = new TableColumn[1]; columns[0].ColumnName = "人次"; columns[0].ColumnField = "NUM"; GraphControl gc; DataTableStruct datatablestruct = DataTableStruct.Rows; Color[] colors = new Color[] { Color.Blue, Color.Aqua, Color.Beige, Color.BlanchedAlmond, Color.Brown, Color.Chocolate, Color.DarkGray, Color.DodgerBlue }; if (rdHistogram.Checked) { gc = new HistogramGraphControl(this.plGraph, datatablestruct, columns, colors, tbData, "DATE"); } else { gc = new LineGraphControl(this.plGraph, datatablestruct, columns, colors, tbData, "DATE"); } object obj = tbData.Compute("Sum(Num)", ""); string title = "住院人次:" + (obj == null ? "0" : obj.ToString()) + "人"; gc.GraphTitle = title; gc.DrawGraph(); }
private void ShowGraph() { if (_managerDiary.HSFee == null) { return; } DataTable tbData = _managerDiary.HSFee; TableColumn[] columns = new TableColumn[1]; columns[0].ColumnName = "金额"; columns[0].ColumnField = "TOTALFEE"; GraphControl gc; DataTableStruct datatablestruct = DataTableStruct.Rows; Color[] colors = new Color[tbData.Rows.Count]; Random random = new Random(); for (int index = 0; index < tbData.Rows.Count; index++) { int red = random.Next(255); int blue = random.Next(255); int green = random.Next(255); colors[index] = Color.FromArgb(red, green, blue); } gc = new CakyGraphControl(this.pnlPictrue, datatablestruct, columns, colors, tbData, "ITEM_NAME", 0); string title = "医院收入示意图"; gc.GraphTitle = title; gc.DrawGraph(); }
/// <summary>新建字段</summary> /// <param name="sender"></param> /// <param name="e"></param> private void ToolStripMenuItem_fieldAdd_Click(object sender, EventArgs e) { TreeNode node = this.treeView1.SelectedNode; _number++; TreeNode fieldNode = new TreeNode("字段" + _number.ToString()); fieldNode.Name = "field" + _number.ToString(); node.Nodes.Add(fieldNode); fieldNode.ContextMenuStrip = contextMenuStrip_field; this.treeView1.SelectedNode = fieldNode; LibField field = new LibField(); field.Name = fieldNode.Name; field.DisplayName = ""; field.AliasName = string.Empty; DataTableStruct tableStruct = GetDTStruct(node.Name); if (tableStruct.Fields == null) { tableStruct.Fields = new LibCollection <LibField>(); } tableStruct.Fields.Add(field); TreeNodeSelected(fieldNode); }
/// <summary> /// 实例化线形图 /// </summary> /// <param name="GraphContainer">图形显示所需要的容器</param> /// <param name="XAxisScaleRefrence">X轴刻度参照类型</param> /// <param name="ShowValueColumns">需要显示的值的列,和传入的DataSource的列对应(仅数值列)</param> /// <param name="LineColors">每条线的颜色,数组</param> /// <param name="DataSource">数据源</param> /// <param name="CNNameColumn">数据源中的中文名称列的字段名</param> public LineGraphControl(System.Windows.Forms.Control GraphContainer, DataTableStruct XAxisScaleRefrence, TableColumn[] ShowValueColumns, Color[] LineColors, System.Data.DataTable DataSource, string CNNameColumn) { base.GraphContainer = GraphContainer; base.XAxisScaleRefrence = XAxisScaleRefrence; base.ShowValueColumns = ShowValueColumns; base.Colors = LineColors; base.DataSource = DataSource; base.CNNameColumn = CNNameColumn; }
/// <summary> /// 实例化饼状图 /// </summary> /// <param name="GraphContainer">图形显示所需的容器</param> /// <param name="XAxisScaleRefrence">饼组成部分的数据来源.当等于Row时,整个饼状图代表一个字段,Index参数指定DataSource的列,;当等于Column时.整个饼状图代表数据表内的一行数据,具体行由参数Index指定</param> /// <param name="ShowValueColumns">要显示的的值的列</param> /// <param name="PartyColors">每部分饼状颜色,数组</param> /// <param name="DataSource">数据源,至少要有一列名称列和值列</param> /// <param name="CNNameColumn">名称列的字段名</param> /// <param name="Index">指定要显示的列或行的索引(相对于DataSource对象)</param> public CakyGraphControl(System.Windows.Forms.Control GraphContainer, DataTableStruct XAxisScaleRefrence, TableColumn[] ShowValueColumns, Color[] PartyColors, System.Data.DataTable DataSource, string CNNameColumn, int Index) { base.GraphContainer = GraphContainer; base.Colors = PartyColors; base.DataSource = DataSource; base.CNNameColumn = CNNameColumn; base.XAxisScaleRefrence = XAxisScaleRefrence; base.ShowValueColumns = ShowValueColumns; index = Index; }
/// <summary> /// 实例化柱状图类 /// </summary> /// <param name="GraphContainer">图形显示所需的容器</param> /// <param name="XAxisScaleRefrence">X轴刻度参照类型</param> /// <param name="ShowValueColumns">需要显示的值的列,和传入的DataSource的列对应(仅数值列)</param> /// <param name="HistogramColors">每个刻度内的柱的颜色,数组长度取决于每个刻度内的柱数</param> /// <param name="DataSource">数据源</param> /// <param name="CNNameColumn">数据源中的名称列的字段名</param> /// <param name="GraphTitle">图形的标题,显示在图形的正上方</param> public HistogramGraphControl(System.Windows.Forms.Control GraphContainer, DataTableStruct XAxisScaleRefrence, TableColumn[] ShowValueColumns, Color[] HistogramColors, System.Data.DataTable DataSource, string CNNameColumn, string GraphTitle) { base.GraphContainer = GraphContainer; base.XAxisScaleRefrence = XAxisScaleRefrence; base.ShowValueColumns = ShowValueColumns; base.DataSource = DataSource; base.CNNameColumn = CNNameColumn; base.Colors = HistogramColors; base.GraphTitle = GraphTitle; }
public FrmShowGraphic(DataTable dataSource, string itemName, TableColumn[] columns, DataTableStruct selectStruct, string title) { _dataSource = dataSource; _itemName = itemName; _columns = columns; _selectStruct = selectStruct; _title = title; InitializeComponent(); this.FormTitle = title; this.Text = title; }
private void InitializeControl() { _currentDS = ModelDesignProject.GetDataSource(_dsId); if (_currentDS.DefTables != null) { foreach (DefineTable defTB in _currentDS.DefTables) { TreeNode nodeDefTable = new TreeNode(); SetDefineTableNode(defTB, nodeDefTable); TreeNode nodeDTStruct; TreeNode nodeField; foreach (DataTableStruct dtStruct in defTB.TableStruct) { nodeDTStruct = new TreeNode(); SetTableStructNode(dtStruct, nodeDTStruct); foreach (LibField field in dtStruct.Fields) { nodeField = new TreeNode(); SetFieldNode(field, nodeField); nodeDTStruct.Nodes.Add(nodeField); } nodeDefTable.Nodes.Add(nodeDTStruct); } this.treeView1.Nodes["defineTableCollection"].Nodes.Add(nodeDefTable); } } else { _currentDS.DefTables = new SDPCRL.CORE.LibCollection <DefineTable>(); TreeNode nodeDefTable = new TreeNode(); DefineTable defTable = new DefineTable(); defTable.ID = DataSourceInfoBLL.GetMaxDefTBID(_dsId) + 1; defTable.TableName = "defineTable1"; defTable.DisplayName = "自定义数据表"; SetDefineTableNode(defTable, nodeDefTable); _currentDS.DefTables.Add(defTable); defTable.TableStruct = new SDPCRL.CORE.LibCollection <DataTableStruct>(); TreeNode tableStruct = new TreeNode(); nodeDefTable.Nodes.Add(tableStruct); DataTableStruct dbStruct = new DataTableStruct(); dbStruct.Name = "dataTableStruct1"; dbStruct.DisplayName = "数据表结构"; SetTableStructNode(dbStruct, tableStruct); defTable.TableStruct.Add(dbStruct); this.treeView1.Nodes["defineTableCollection"].Nodes.Add(nodeDefTable); this.treeView1.SelectedNode = tableStruct;; nodeDefTable.Expand(); } ModelDesignProject.CreateDS(_currentDS); }
/// <summary> /// 绘制柱状图 /// </summary> /// <param name="table"></param> /// <returns></returns> private GraphControl CreateHistogramGraph(DataTable table) { TableColumn[] columns = new TableColumn[1]; columns[0].ColumnName = "金额"; columns[0].ColumnField = "money"; DataTableStruct datatableStruct = DataTableStruct.Rows; Color[] color = new Color[table.Columns.Count]; int num = Convert.ToInt32(256 / table.Rows.Count); for (int index = 0; index < table.Columns.Count; index++) { color[index] = System.Drawing.Color.FromArgb(((int)(((byte)(200 - index * num / 2)))), ((int)(((byte)(255 - index * num / 2)))), ((int)(((byte)(0 + index * num))))); } return(new HistogramGraphControl(plGraph, datatableStruct, columns, color, table, "item_name", "处方金额分类汇总", "分类名称", "金额")); }
/// <summary>获取字段实体对象</summary> /// <param name="tableStructName">表名</param> /// <param name="fieldName">字段名</param> /// <returns></returns> private LibField GetField(string tableStructName, string fieldName) { LibField field = null; DataTableStruct tableStruct = GetDTStruct(tableStructName); if (tableStruct != null) { foreach (LibField item in tableStruct.Fields) { if (string.Compare(item.Name, fieldName, true) == 0) { field = item; } } } #region //foreach (DefineTable deftb in _currentDS.DefTables) //{ // foreach (DataTableStruct tablestruct in deftb.TableStruct) // { // foreach (LibField item in tablestruct.Fields) // { // if (string.Compare(item.Name, fieldName, true) == 0) // { // field = item; // isFind = true; // break; // } // } // if (isFind) // break; // } // if (isFind) // break; //} #endregion return(field); }
private DataTableStruct GetDTStruct(string name) { DataTableStruct dtStruct = null; bool isFind = false; foreach (DefineTable deftb in _currentDS.DefTables) { foreach (DataTableStruct item in deftb.TableStruct) { if (string.Compare(item.Name, name, true) == 0) { dtStruct = item; isFind = true; break; } } if (isFind) { break; } } return(dtStruct); }
public Form1() { InitializeComponent(); //this.tabControl1.Appearance = TabAppearance.FlatButtons; #region DBModelOperation dbmodel = new DBModelOperation(); DataSource ds = new DataSource(); ds.DataSourceName = "datasourcename"; ds.DSID = 111111111; LibField field = new LibField(); field.Name = "字段名称1"; field.AliasName = "字段别名1"; field.DisplayName = "字段显示名称1"; LibField field2 = new LibField(); field2.Name = "字段名称2"; field2.AliasName = "字段别名2"; field2.DisplayName = "字段显示名称2"; DataTableStruct tablestruct = new DataTableStruct(); tablestruct.Name = "数据表结构"; tablestruct.Fields = new LibCollection <LibField>(); tablestruct.Fields.Add(field); tablestruct.Fields.Add(field2); DefineTable deftb = new DefineTable(); deftb.TableName = "zyy"; deftb.ID = 123456; deftb.TableStruct = new LibCollection <DataTableStruct>(); deftb.TableStruct.Add(tablestruct); //DefineTable deftb2 = new DefineTable(); //deftb2.TableName = "Ylr"; //deftb2.ID = "22222"; //PropertyInfo[] propertis = deftb.GetType().GetProperties(); //LibXmlAttributeAttribute attr = propertis[0].GetCustomAttributes(typeof(LibXmlAttributeAttribute), true)[0] as LibXmlAttributeAttribute; ds.DefTables = new LibCollection <DefineTable>(); ds.DefTables.Add(deftb); //ds.DefTables.Add(deftb2); ds.DefTables.Guid = "................"; SerializerUtils serial = new SerializerUtils(); string str = serial.XMLSerialize(ds); //SerializerUtils.xmlserialzaition(ds, string.Format(@"{0}\Models\DataSource\{1}", Environment.CurrentDirectory, "text.xml")); //XMLOperation xml = new XMLOperation(string.Format(@"{0}\Models\DataSource\{1}", Environment.CurrentDirectory, "text.xml")); //ILibXMLNodeRead noderead = xml.NodeRead("/DataSource/DefTables/DefineTable"); //while (!noderead.EOF) //{ // string test= noderead.InnerText; // string TableName = noderead.Attributions["TableName"]; // noderead.ReadNext(); //} //if (true) { // ExceptionManager.ThrowError("sdfsd"); //} //else { // int a = 0; // a = 88; //} #endregion //DAL.DBHelp.DataAccess.testsql(); //DAL.DBHelp.DataAccess.testsql(); }
/// <summary> /// 实例化线形图 /// </summary> /// <param name="GraphContainer">图形显示所需要的容器</param> /// <param name="XAxisScaleRefrence">X轴刻度参照类型</param> /// <param name="ShowValueColumns">需要显示的值的列,和传入的DataSource的列对应(仅数值列)</param> /// <param name="LineColors">每条线的颜色,数组</param> /// <param name="DataSource">数据源</param> /// <param name="CNNameColumn">数据源中的中文名称列的字段名</param> /// <param name="GraphTitle">图形的标题,位于整个图形的正上方</param> /// <param name="XAxisTitle">x轴的标题</param> /// <param name="YAxisTitle">y轴的标题</param> public LineGraphControl(System.Windows.Forms.Control GraphContainer, DataTableStruct XAxisScaleRefrence, TableColumn[] ShowValueColumns, Color[] LineColors, System.Data.DataTable DataSource, string CNNameColumn, string GraphTitle, string XAxisTitle, string YAxisTitle) { base.GraphContainer = GraphContainer; base.XAxisScaleRefrence = XAxisScaleRefrence; base.ShowValueColumns = ShowValueColumns; base.Colors = LineColors; base.DataSource = DataSource; base.CNNameColumn = CNNameColumn; base.GraphTitle = GraphTitle; base.XAxisTitle = XAxisTitle; base.YAxisTitle = YAxisTitle; }
/// <summary> /// 实例化柱状图类 /// </summary> /// <param name="GraphContainer">图形显示所需的容器</param> /// <param name="XAxisScaleRefrence">X轴刻度参照类型</param> /// <param name="ShowValueColumns">需要显示的值的列,和传入的DataSource的列对应(仅数值列)</param> /// <param name="HistogramColors">每个刻度内的柱的颜色,数组长度取决于每个刻度内的柱数</param> /// <param name="DataSource">数据源</param> /// <param name="CNNameColumn">数据源中的名称列的字段名</param> public HistogramGraphControl(System.Windows.Forms.Control GraphContainer, DataTableStruct XAxisScaleRefrence, TableColumn[] ShowValueColumns, Color[] HistogramColors, System.Data.DataTable DataSource, string CNNameColumn) { base.GraphContainer = GraphContainer; base.XAxisScaleRefrence = XAxisScaleRefrence; base.ShowValueColumns = ShowValueColumns; base.DataSource = DataSource; base.CNNameColumn = CNNameColumn; base.Colors = HistogramColors; }
/// <summary>设置数据表结构节点属性</summary> /// <param name="dtStruct"></param> /// <param name="node"></param> private void SetTableStructNode(DataTableStruct dtStruct, TreeNode node) { node.Name = dtStruct.Name; node.Text = dtStruct.DisplayName; node.ContextMenuStrip = this.contextMenuStrip_TBStruct; }