private void InitChart <T>(LineItems <T> itemData) { this.dataGridView1.DataSource = itemData.Table; var ser = this.chart1.Series[0]; ser.Name = itemData.YLable; ser.Label = "#VAL"; ser.ChartType = SeriesChartType.Line; ser.XValueType = ChartValueType.String; ser.Points.DataBindXY(itemData.XPoints, itemData.YPoints); ser.ToolTip = "#VALX:#VAL"; }
public LineItems <double> GetErrMoneyLine(List <ExcelModel> list) { LineItems <double> item = new LineItems <double>(); var xdata = list.Where(p => string.IsNullOrEmpty(p.ExPeriod) == false).Select(p => p.ExPeriod).Distinct().ToList(); List <double> ylist = new List <double>(); DataTable dt = new DataTable(); dt.Columns.Add("周期跟物流核对"); dt.Columns.Add("报废金额"); item.XLable = "周期跟物流核对"; item.YLable = "报废金额"; foreach (var row in xdata) { var num = list.Where(p => p.ExPeriod == row && p.ExErrMoney != null).Sum(p => p.ExErrMoney); double numd = 0; if (num != null) { numd = Math.Round(num.Value, 2); } ylist.Add(numd); var rowd = dt.NewRow(); rowd["报废金额"] = numd; rowd["周期跟物流核对"] = row; dt.Rows.Add(rowd); } item.XPoints = xdata; item.YPoints = ylist; item.Table = dt; return(item); }
public LineItems <int> GetErrItemLine(List <ExcelModel> list) { LineItems <int> item = new LineItems <int>(); var xdata = list.Where(p => string.IsNullOrEmpty(p.ExPeriod) == false).Select(p => p.ExPeriod).Distinct().ToList(); List <int> ylist = new List <int>(); DataTable dt = new DataTable(); dt.Columns.Add("周期跟物流核对"); dt.Columns.Add("零件数量"); item.XLable = "周期跟物流核对"; item.YLable = "零件数量"; foreach (var row in xdata) { var num = list.Where(p => p.ExPeriod == row && string.IsNullOrEmpty(p.ExItemNo) == false).Select(p => p.ExItemNo).Distinct().Count(); ylist.Add(num); var rowd = dt.NewRow(); rowd["零件数量"] = num; rowd["周期跟物流核对"] = row; dt.Rows.Add(rowd); } item.XPoints = xdata; item.YPoints = ylist; item.Table = dt; return(item); }