|
@@ -1,4 +1,6 @@
|
|
|
|
|
|
+using DevExpress.Utils;
|
|
|
+using DevExpress.XtraCharts;
|
|
|
using OTSIncAReportApp;
|
|
|
using OTSIncAReportApp.OTSRstMgrFunction;
|
|
|
using OTSIncAReportApp.OTSSampleReportInfo;
|
|
@@ -38,20 +40,29 @@ namespace OTSIncAReportGrids
|
|
|
frmReportConditionChoose m_condition;
|
|
|
private ResultDataMgr m_DataMgr;
|
|
|
int gridheight = 0;
|
|
|
- public bool Report { set; get; }
|
|
|
+ int gridwidth = 0;
|
|
|
+ public bool Report { set; get; }
|
|
|
/// <summary>
|
|
|
/// 全部颗粒为true选择颗粒为false
|
|
|
/// </summary>
|
|
|
public bool ParticleRange { set; get; }
|
|
|
- #endregion
|
|
|
-
|
|
|
|
|
|
-
|
|
|
- #region 自定义方法
|
|
|
/// <summary>
|
|
|
- /// 绑定datagridview数据
|
|
|
+ /// 表数据
|
|
|
/// </summary>
|
|
|
- public void BindDataGridView(string path, int num, string filename,int sel)
|
|
|
+ List<DataTable> list_table_data = new List<DataTable>();
|
|
|
+ List<Point> list_table_size = new List<Point>();
|
|
|
+ List<Point> list_table_Point = new List<Point>();
|
|
|
+ List<string> list_fileName = new List<string>();
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ #region 自定义方法
|
|
|
+ /// <summary>
|
|
|
+ /// 绑定datagridview数据
|
|
|
+ /// </summary>
|
|
|
+ public void BindDataGridView(string path, int num, string filename,int sel)
|
|
|
{
|
|
|
List<string> colid = new List<string>() { "rowid", "pname", "area", "con" };
|
|
|
List<string> colname = new List<string>() { table["str1"].ToString(), table["str4"].ToString(), table["str3"].ToString(), table["str6"].ToString() };
|
|
@@ -62,13 +73,21 @@ namespace OTSIncAReportGrids
|
|
|
gridView.Columns.Add(colid[i], colname[i]);
|
|
|
}
|
|
|
DataTable dte = particledata.GetAllElement();
|
|
|
- foreach (DataRow item in dte.Rows)
|
|
|
+
|
|
|
+ DataTable table_data = new DataTable();
|
|
|
+
|
|
|
+ table_data.Columns.Add("TypeName");
|
|
|
+ table_data.Columns.Add("con");
|
|
|
+ table_data.Columns.Add("ar");
|
|
|
+ foreach (DataRow item in dte.Rows)
|
|
|
{
|
|
|
DataGridViewImageColumn iconColumn = new DataGridViewImageColumn();
|
|
|
iconColumn.Name = item["name"].ToString();
|
|
|
iconColumn.HeaderText = item["name"].ToString();
|
|
|
gridView.Columns.Add(iconColumn);
|
|
|
- }
|
|
|
+ table_data.Columns.Add(item["name"].ToString());
|
|
|
+
|
|
|
+ }
|
|
|
List<int> FLID = new List<int>() { 0, 1, 2, 4, 6, 7, 8, 9 };
|
|
|
List<string> NameList = new List<string>() { table["partcletype0"].ToString(), table["partcletype1"].ToString(), table["partcletype2"].ToString(), table["partcletype4"].ToString(), table["partcletype6"].ToString(), table["partcletype7"].ToString(), table["partcletype8"].ToString(), table["partcletype9"].ToString() };
|
|
|
|
|
@@ -84,7 +103,8 @@ namespace OTSIncAReportGrids
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
- double total = Convert.ToDouble(dt.Rows[i]["ar"]);
|
|
|
+
|
|
|
+ double total = Convert.ToDouble(dt.Rows[i]["ar"]);
|
|
|
int add_rowindex = gridView.Rows.Add();
|
|
|
gridView.Rows[add_rowindex].Cells[0].Value = add_rowindex + 1;
|
|
|
gridView.Rows[add_rowindex].Cells[1].Value = dt.Rows[i]["TypeName"];
|
|
@@ -95,7 +115,12 @@ namespace OTSIncAReportGrids
|
|
|
gridView.Rows[add_rowindex].Cells[3].Style.BackColor = Color.Azure;
|
|
|
DataTable dtp = particledata.GetAreaByIncA(dt.Rows[i]["TypeId"].ToString(), filedAndParticl);
|
|
|
|
|
|
- for (int j = 4; j < gridView.Columns.Count; j++)
|
|
|
+ DataRow row1 = table_data.NewRow();
|
|
|
+ row1["TypeName"] = dt.Rows[i]["TypeName"];
|
|
|
+ row1["con"] = dt.Rows[i]["con"];
|
|
|
+ row1["ar"] = Math.Round(total, 2);
|
|
|
+
|
|
|
+ for (int j = 4; j < gridView.Columns.Count; j++)
|
|
|
{
|
|
|
int col = 0;
|
|
|
foreach (DataRow dr in dtp.Rows)
|
|
@@ -106,7 +131,10 @@ namespace OTSIncAReportGrids
|
|
|
double p = Math.Round(ar / total, 2);
|
|
|
gridView.Rows[add_rowindex].Cells[j].Value = DrawFunction.GetProcessBitmap((float)p, Color.Azure);
|
|
|
gridView.Rows[add_rowindex].Cells[j].Tag = p;
|
|
|
- break;
|
|
|
+
|
|
|
+
|
|
|
+ row1[gridView.Columns[j].Name] = p;
|
|
|
+ break;
|
|
|
}
|
|
|
col++;
|
|
|
}
|
|
@@ -116,7 +144,10 @@ namespace OTSIncAReportGrids
|
|
|
gridView.Rows[add_rowindex].Cells[j].Tag = 0;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
+ table_data.Rows.Add(row1);
|
|
|
+
|
|
|
+ }
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
{
|
|
|
if (Convert.ToInt32(dt.Rows[i]["TypeId"]) > 100)
|
|
@@ -139,7 +170,9 @@ namespace OTSIncAReportGrids
|
|
|
gridView.Rows[add_rowindex].Cells[3].Style.BackColor = Color.Azure;
|
|
|
gridView.Rows[add_rowindex].Cells[3].Value = dt.Rows[i]["con"];
|
|
|
DataTable dtp = particledata.GetAreaByIncA(dt.Rows[i]["TypeId"].ToString(), filedAndParticl);
|
|
|
- for (int j = 4; j < gridView.Columns.Count; j++)
|
|
|
+
|
|
|
+
|
|
|
+ for (int j = 4; j < gridView.Columns.Count; j++)
|
|
|
{
|
|
|
int col = 0;
|
|
|
foreach (DataRow dr in dtp.Rows)
|
|
@@ -151,7 +184,9 @@ namespace OTSIncAReportGrids
|
|
|
double p = Math.Round(ar / total, 2);
|
|
|
gridView.Rows[add_rowindex].Cells[j].Value = DrawFunction.GetProcessBitmap((float)p, Color.Azure);
|
|
|
gridView.Rows[add_rowindex].Cells[j].Tag = p;
|
|
|
- break;
|
|
|
+
|
|
|
+
|
|
|
+ break;
|
|
|
}
|
|
|
col++;
|
|
|
}
|
|
@@ -162,17 +197,20 @@ namespace OTSIncAReportGrids
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ list_table_data.Add(table_data);
|
|
|
gridView.Name = "gridView" + num.ToString();
|
|
|
dgv = gridView;
|
|
|
- //设置grid风格
|
|
|
- SetDataGridViewStyle(gridView);
|
|
|
+ //设置grid风格
|
|
|
+ list_table_Point.Add(SetDataGridViewStyle(gridView));
|
|
|
+ //SetDataGridViewStyle(gridView);
|
|
|
panel1.Controls.Add(gridView);
|
|
|
}
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 设置DataGridView样式
|
|
|
- /// </summary>
|
|
|
- private void SetDataGridViewStyle(OTSGridView gridView)
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 设置DataGridView样式
|
|
|
+ /// </summary>
|
|
|
+ private Point SetDataGridViewStyle(OTSGridView gridView)
|
|
|
{
|
|
|
|
|
|
//用户不能调整标题的高度
|
|
@@ -216,28 +254,42 @@ namespace OTSIncAReportGrids
|
|
|
gridView.ContextMenuStrip = this.contextMenuStrip1;
|
|
|
gridView.BorderStyle = 0;
|
|
|
|
|
|
- //gridView.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
|
- //gridView.Location = new System.Drawing.Point(0, 0);
|
|
|
- gridView.Location = new System.Drawing.Point(0, gridheight);
|
|
|
- gridView.Margin = new System.Windows.Forms.Padding(2);
|
|
|
+ //gridView.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
|
+ //gridView.Location = new System.Drawing.Point(0, 0);
|
|
|
+ int outpos = gridwidth;
|
|
|
+ //gridView.Location = new System.Drawing.Point(0, gridheight);
|
|
|
+ gridView.Location = new System.Drawing.Point(gridwidth, 0);
|
|
|
+ gridView.Margin = new System.Windows.Forms.Padding(2);
|
|
|
gridView.MergeColumnHeaderBackColor = System.Drawing.SystemColors.ButtonHighlight;
|
|
|
//gridView.Name = "Gview_gz";
|
|
|
gridView.ReadOnly = true;
|
|
|
gridView.RowHeadersVisible = false;
|
|
|
gridView.RowHeadersWidth = 40;
|
|
|
gridView.RowTemplate.Height = 30;
|
|
|
- //gridView.Size = new System.Drawing.Size(667, 520);
|
|
|
- gridView.Size = new System.Drawing.Size(gridView.ColumnCount * 100 + 60, gridView.RowCount * 30 + 30);
|
|
|
- gridheight = gridheight + gridView.RowCount * 30 + 80;
|
|
|
- gridView.TabIndex = 0;
|
|
|
+
|
|
|
+ int gridView_Width = 0;
|
|
|
+
|
|
|
+ for (int i = 0; i < gridView.ColumnCount; i++)
|
|
|
+ {
|
|
|
+ gridView_Width = gridView_Width + gridView.Columns[i].Width;
|
|
|
+
|
|
|
+ }
|
|
|
+ //gridView.Size = new System.Drawing.Size(667, 520);
|
|
|
+ //gridView.Size = new System.Drawing.Size(gridView.ColumnCount * 100 + 60, gridView.RowCount * 30 + 30);
|
|
|
+ gridView.Size = new System.Drawing.Size(gridView_Width+60, gridView.RowCount * 30);
|
|
|
+ //gridheight = gridheight + gridView.RowCount * 30 + 80;
|
|
|
+ gridheight = gridheight + gridView.RowCount * 30 + 5;
|
|
|
+ gridwidth = gridwidth + gridView.ColumnCount * 100;
|
|
|
+ gridView.TabIndex = 0;
|
|
|
gridView.SortCompare += new System.Windows.Forms.DataGridViewSortCompareEventHandler(this.Gview_gz_SortCompare);
|
|
|
gridView.Sorted += new System.EventHandler(this.Gview_gz_Sorted);
|
|
|
|
|
|
//先设置一下头的高度,否则会太矮不好看
|
|
|
gridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
|
|
|
gridView.ColumnHeadersHeight = 40;
|
|
|
-
|
|
|
- }
|
|
|
+ list_table_size.Add(new Point(gridView.ColumnCount * 100 , gridView.RowCount * 30));
|
|
|
+ return new Point(outpos, gridheight);
|
|
|
+ }
|
|
|
#endregion
|
|
|
|
|
|
#region 初始化构造函数
|
|
@@ -321,10 +373,168 @@ namespace OTSIncAReportGrids
|
|
|
////设置grid风格
|
|
|
//SetDataGridViewStyle();
|
|
|
}
|
|
|
- #endregion
|
|
|
|
|
|
- #region 相关事件
|
|
|
- private void ToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
|
+ public void SetGraphicType(ReportCondition sourceGridData)
|
|
|
+ {
|
|
|
+
|
|
|
+ string stdId = "";
|
|
|
+ int stdIdIndex = 0;
|
|
|
+ //find the stdId condition
|
|
|
+ var STDIdItm = sourceGridData.ConditionItemList.Find(s => s.iItemId == OTS_REPORT_PROP_GRID_ITEMS.STD_ID);
|
|
|
+ if (STDIdItm != null)
|
|
|
+ {
|
|
|
+ stdId = STDIdItm.itemDisplayVal.ToString();
|
|
|
+ stdIdIndex = STDIdItm.comboDownList.IndexOf(stdId);
|
|
|
+ }
|
|
|
+ int high = 0;
|
|
|
+ for (int i = 0; i < list_table_Point.Count; i++)
|
|
|
+ {
|
|
|
+ if (high < list_table_Point[i].Y)
|
|
|
+ {
|
|
|
+ high = list_table_Point[i].Y;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < list_table_data.Count; i++)
|
|
|
+ {
|
|
|
+ Graphics_Stacking(list_table_data[i], stdId, list_table_size[i], list_table_Point[i], high);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// chart图创建
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dt"></param>
|
|
|
+ /// <param name="stdId"></param>
|
|
|
+ private void Graphics_Stacking(DataTable dt, string stdId, Point a_size, Point a_Location, int location_hig)
|
|
|
+ {
|
|
|
+ ChartControl chartControl1 = new ChartControl();
|
|
|
+ chartControl1.Series.Clear();
|
|
|
+
|
|
|
+ chartControl1.Size = new Size(a_size.X, a_size.Y);
|
|
|
+ chartControl1.Location = new Point(a_Location.X, location_hig);
|
|
|
+
|
|
|
+ DataTable dataTable = new DataTable();
|
|
|
+ dataTable.Columns.Add("name");
|
|
|
+ dataTable.Columns.Add("size");
|
|
|
+
|
|
|
+ if (stdId != "All")
|
|
|
+ {
|
|
|
+ for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ if (dt.Rows[i]["TypeName"].ToString() == stdId)
|
|
|
+ {
|
|
|
+ for (int a = 3; a < dt.Columns.Count; a++)
|
|
|
+ {
|
|
|
+ DataRow dr = dataTable.NewRow();
|
|
|
+ dr["name"] = dt.Columns[a].ColumnName;
|
|
|
+ if (dt.Rows[i][a].ToString() == "")
|
|
|
+ {
|
|
|
+ dr["size"] = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dr["size"] = Convert.ToDouble(dt.Rows[i][a]);
|
|
|
+ }
|
|
|
+
|
|
|
+ dataTable.Rows.Add(dr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (stdId == "All")
|
|
|
+ {
|
|
|
+ List<Series> seriesList = new List<Series>();
|
|
|
+
|
|
|
+ DataTable data = new DataTable();
|
|
|
+ data.Columns.Add("name");
|
|
|
+ data.Columns.Add("range");
|
|
|
+ data.Columns.Add("num");
|
|
|
+ for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ for (int a = 3; a < dt.Columns.Count; a++)
|
|
|
+ {
|
|
|
+ DataRow dr = data.NewRow();
|
|
|
+ dr["name"] = dt.Rows[i]["TypeName"].ToString();
|
|
|
+ dr["range"] = dt.Columns[a].ColumnName;
|
|
|
+ if (dt.Rows[i][a].ToString() == "")
|
|
|
+ {
|
|
|
+ dr["num"] = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dr["num"] = dt.Rows[i][a].ToString();
|
|
|
+ }
|
|
|
+
|
|
|
+ data.Rows.Add(dr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (DataRow dr in data.DefaultView.ToTable(true, "name").Rows)
|
|
|
+ {
|
|
|
+ Series s = new Series(dr["name"].ToString(), ViewType.StackedBar)
|
|
|
+ {
|
|
|
+ LegendTextPattern = dr["name"].ToString(),
|
|
|
+ ArgumentScaleType = ScaleType.Qualitative,
|
|
|
+ };
|
|
|
+ foreach (DataRow drl in data.Select("name='" + dr["name"].ToString() + "'"))
|
|
|
+ s.Points.Add(new SeriesPoint(drl["range"].ToString(), double.Parse(drl["num"].ToString())));
|
|
|
+ s.LabelsVisibility = DefaultBoolean.False;
|
|
|
+ seriesList.Add(s);
|
|
|
+ }
|
|
|
+ foreach (Series sr in seriesList.ToArray())
|
|
|
+ chartControl1.Series.Add(sr);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 假设你已经有一个 ChartControl 实例,并且已经添加了一个饼图 Series
|
|
|
+ Series series = new Series(stdId, ViewType.Bar);
|
|
|
+
|
|
|
+ for (int a = 0; a < dataTable.Rows.Count; a++)
|
|
|
+ {
|
|
|
+ string name = dataTable.Rows[a]["name"].ToString();
|
|
|
+ double Cunt = Convert.ToDouble(dataTable.Rows[a]["size"]);
|
|
|
+ series.Points.Add(new SeriesPoint(name, Cunt));
|
|
|
+ }
|
|
|
+ series.LabelsVisibility = DefaultBoolean.True;
|
|
|
+ chartControl1.Series.Add(series);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ((XYDiagram)chartControl1.Diagram).AxisY.Title.Text = "";
|
|
|
+ ((XYDiagram)chartControl1.Diagram).AxisX.Title.Text = "";
|
|
|
+ ((XYDiagram)chartControl1.Diagram).AxisY.Title.Visibility = DefaultBoolean.True;
|
|
|
+ ((XYDiagram)chartControl1.Diagram).AxisX.Title.Visibility = DefaultBoolean.True;
|
|
|
+ ((XYDiagram)chartControl1.Diagram).AxisY.Title.Font = new Font("Tahoma", 9);
|
|
|
+ ((XYDiagram)chartControl1.Diagram).AxisX.Title.Font = new Font("Tahoma", 9);
|
|
|
+ ((XYDiagram)chartControl1.Diagram).AxisY.Title.Alignment = System.Drawing.StringAlignment.Far;
|
|
|
+ ((XYDiagram)chartControl1.Diagram).AxisX.Title.Alignment = System.Drawing.StringAlignment.Far;
|
|
|
+
|
|
|
+ //图例的位置定义
|
|
|
+ chartControl1.Legend.AlignmentVertical = LegendAlignmentVertical.Top;
|
|
|
+ chartControl1.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.RightOutside;
|
|
|
+ chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
|
|
|
+ chartControl1.Legend.Direction = LegendDirection.TopToBottom;
|
|
|
+
|
|
|
+ //十字准线光标
|
|
|
+ chartControl1.CrosshairEnabled = DefaultBoolean.True;
|
|
|
+ chartControl1.CrosshairOptions.ShowValueLine = true;
|
|
|
+ chartControl1.CrosshairOptions.ShowArgumentLabels = true;
|
|
|
+
|
|
|
+
|
|
|
+ panel1.Controls.Add(chartControl1);
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 相关事件
|
|
|
+ private void ToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
//复制整个表
|
|
|
CopyAll();
|