private void GetDataForChart(TimeSpan timeStart, TimeSpan timeEnd, DateTime date) { try { List <ModelSeries> listModelSeries = new List <ModelSeries>(); ModelSeries modelSeries = new ModelSeries() { SeriesName = "Chuyen", ShowInLegend = false }; List <Model.Point> listPoint = new List <Model.Point>(); var ngay = date.Day + "/" + date.Month + "/" + date.Year; var linesM = BLLReport.GetNSCErrorForChart(lines, timeStart, timeEnd, ngay); if (linesM != null && linesM.Count > 0) { foreach (var item in linesM) { listPoint.Add(new Model.Point() { X = item.TenChuyen, Y = item.TC }); } } modelSeries.ListPoint = listPoint; listModelSeries.Add(modelSeries); Helper.DrawChart.DrawBarChart(this.chartControl1, "Số Lỗi Các Chuyền " + " Ngày " + ngay, "Số Lỗi", "Chuyền", listModelSeries); } catch (Exception ex) { throw ex; } }
private void GetDataForChart(int lineId, string lineName, TimeSpan timeStart, TimeSpan timeEnd, DateTime date) { try { List <ModelSeries> listModelSeries = new List <ModelSeries>(); ModelSeries modelSeries = new ModelSeries() { SeriesName = "Cụm", ShowInLegend = false }; List <Model.Point> listPoint = new List <Model.Point>(); var ngay = date.Day + "/" + date.Month + "/" + date.Year; var clusters = BLLReport.GetNSCForChart(lineId, timeStart, timeEnd, ngay); if (clusters != null && clusters.Count > 0) { foreach (var item in clusters) { listPoint.Add(new Model.Point() { X = item.TenCum, Y = item.KCS }); } } modelSeries.ListPoint = listPoint; listModelSeries.Add(modelSeries); Helper.DrawChart.DrawBarChart(this.chartControl1, "Năng Suất Các Cụm Của " + lineName + " Ngày " + ngay, "Năng Suất", "Cụm", listModelSeries); } catch (Exception ex) { throw ex; } }
private void GetDataForChart(int lineId, string clusterName, int clusterId, DateTime date) { try { List <ModelSeries> listModelSeries = new List <ModelSeries>(); ModelSeries modelSeries = new ModelSeries() { SeriesName = "Cum", ShowInLegend = false }; List <Model.Point> listPoint = new List <Model.Point>(); var ngay = date.Day + "/" + date.Month + "/" + date.Year; var times = BLLReport.GetNSCForChart(lineId, clusterId, ngay); if (times != null && times.Count > 0) { foreach (var item in times) { listPoint.Add(new Model.Point() { X = item.IntHours, Y = item.KCS }); } modelSeries.ListPoint = listPoint; listModelSeries.Add(modelSeries); string strDate = " Ngày " + ngay; Helper.DrawChart.DrawBarChart(this.chartControl1, "Năng Suất Giờ Của Cụm " + clusterName + strDate, "Năng Suất", "Giờ", listModelSeries); } } catch (Exception ex) { throw ex; } }
private void GetDataForChart(string lineId, string lineName, TimeSpan timeStart, TimeSpan timeEnd, DateTime date) { try { List <ModelSeries> listModelSeries = new List <ModelSeries>(); ModelSeries modelSeries = new ModelSeries() { SeriesName = "Lỗi", ShowInLegend = false }; List <Model.Point> listPoint = new List <Model.Point>(); if (listError != null && listError.Count > 0) { foreach (var item in listError) { string sqlSanLuongGio = "select (select Sum(ThanhPham) from TheoDoiNgay where MaChuyen =" + lineId + " and ErrorId=" + item.Id + " and Time >= '" + timeStart + "' and Time <='" + timeEnd + "' and Date='" + date + "' and CommandTypeId=" + (int)eCommandRecive.ErrorIncrease + " and IsEndOfLine=1) AS SanLuongTang, (select Sum(ThanhPham) from TheoDoiNgay where MaChuyen =" + lineId + " and ErrorId=" + item.Id + " and Time >= '" + timeStart + "' and Time <='" + timeEnd + "' and Date='" + date + "' and CommandTypeId=" + (int)eCommandRecive.ErrorReduce + " and IsEndOfLine=1) AS SanLuongGiam"; int sanLuongGioTang = 0; int sanLuongGioGiam = 0; int sanLuongGio = 0; DataTable dtSanLuongGio = dbclass.TruyVan_TraVe_DataTable(sqlSanLuongGio); if (dtSanLuongGio != null && dtSanLuongGio.Rows.Count > 0) { DataRow rowSanLuongGio = dtSanLuongGio.Rows[0]; if (rowSanLuongGio["SanLuongTang"] != null) { int.TryParse(rowSanLuongGio["SanLuongTang"].ToString(), out sanLuongGioTang); } if (rowSanLuongGio["SanLuongGiam"] != null) { int.TryParse(rowSanLuongGio["SanLuongGiam"].ToString(), out sanLuongGioGiam); } sanLuongGio = sanLuongGioTang - sanLuongGioGiam; } if (sanLuongGio < 0) { sanLuongGio = 0; } listPoint.Add(new Model.Point() { X = item.Name, Y = sanLuongGio }); } modelSeries.ListPoint = listPoint; listModelSeries.Add(modelSeries); string strDate = " Ngày " + date.Day + "/" + date.Month + "/" + date.Year; Helper.DrawChart.DrawBarChart(this.chartControl1, "Số Lượng Lỗi Của Chuyền " + lineName + strDate, "Số Lỗi", "Loại Lỗi", listModelSeries); } } catch (Exception ex) { throw ex; } }
private void GetDataForChart(TimeSpan timeStart, TimeSpan timeEnd, DateTime date, DateTime toDate) { try { List <ModelSeries> listModelSeries = new List <ModelSeries>(); ModelSeries modelSeries = new ModelSeries() { SeriesName = "Sản lượng", ShowInLegend = true }; List <Model.Point> listPoint = new List <Model.Point>(); ModelSeries modelSeriesDM = new ModelSeries() { SeriesName = "Định mức", ShowInLegend = true }; List <Model.Point> listPointDM = new List <Model.Point>(); if (listLine != null && listLine.Count > 0) { foreach (var line in listLine) { string sqlSanLuongGio = string.Empty; if (!isNSAllDay) { sqlSanLuongGio = "select (select Sum(ThanhPham) from TheoDoiNgay where MaChuyen =" + line.MaChuyen + " and Time >= '" + timeStart + "' and Time <='" + timeEnd + "' and Date='" + date + "' and CommandTypeId=" + (int)eCommandRecive.ProductIncrease + " and ProductOutputTypeId=" + (int)eProductOutputType.KCS + " and IsEndOfLine=1) AS SanLuongTang, (select Sum(ThanhPham) from TheoDoiNgay where MaChuyen =" + line.MaChuyen + " and Time >= '" + timeStart + "' and Time <='" + timeEnd + "' and Date='" + date + "' and CommandTypeId=" + (int)eCommandRecive.ProductReduce + " and ProductOutputTypeId=" + (int)eProductOutputType.KCS + " and IsEndOfLine=1) AS SanLuongGiam"; } else { sqlSanLuongGio = "select (select Sum(ThanhPham) from TheoDoiNgay where MaChuyen =" + line.MaChuyen + " and Date >='" + date + "' and Date <='" + toDate + "' and CommandTypeId=" + (int)eCommandRecive.ProductIncrease + " and ProductOutputTypeId=" + (int)eProductOutputType.KCS + " and IsEndOfLine=1) AS SanLuongTang, (select Sum(ThanhPham) from TheoDoiNgay where MaChuyen =" + line.MaChuyen + " and Date >='" + date + "' and Date <='" + toDate + "' and CommandTypeId=" + (int)eCommandRecive.ProductReduce + " and ProductOutputTypeId=" + (int)eProductOutputType.KCS + " and IsEndOfLine=1) AS SanLuongGiam"; } int sanLuongGioTang = 0; int sanLuongGioGiam = 0; int sanLuongGio = 0; DataTable dtSanLuongGio = dbclass.TruyVan_TraVe_DataTable(sqlSanLuongGio); if (dtSanLuongGio != null && dtSanLuongGio.Rows.Count > 0) { DataRow rowSanLuongGio = dtSanLuongGio.Rows[0]; if (rowSanLuongGio["SanLuongTang"] != null) { int.TryParse(rowSanLuongGio["SanLuongTang"].ToString(), out sanLuongGioTang); } if (rowSanLuongGio["SanLuongGiam"] != null) { int.TryParse(rowSanLuongGio["SanLuongGiam"].ToString(), out sanLuongGioGiam); } sanLuongGio = sanLuongGioTang - sanLuongGioGiam; } if (sanLuongGio < 0) { sanLuongGio = 0; } listPoint.Add(new Model.Point() { X = line.TenChuyen, Y = sanLuongGio }); string sqlDinhMuc = string.Empty; double dinhMuc = 0; if (!isNSAllDay) { sqlDinhMuc = "select SUM(nx.DinhMucNgay) as DinhMucNgay from NangXuat nx, Chuyen_SanPham csp where nx.Ngay='" + date + "' and nx.STTChuyen_SanPham=csp.STT and csp.MaChuyen=" + line.MaChuyen; } else { sqlDinhMuc = "select SUM(nx.DinhMucNgay) as DinhMucNgay from NangXuat nx, Chuyen_SanPham csp where nx.Ngay>='" + date + "' and nx.Ngay<='" + toDate + "' and nx.STTChuyen_SanPham=csp.STT and csp.MaChuyen=" + line.MaChuyen; } DataTable dtDinhMuc = dbclass.TruyVan_TraVe_DataTable(sqlDinhMuc); if (dtDinhMuc != null && dtDinhMuc.Rows.Count > 0) { DataRow rowDinhMuc = dtDinhMuc.Rows[0]; if (rowDinhMuc["DinhMucNgay"] != null) { double.TryParse(rowDinhMuc["DinhMucNgay"].ToString(), out dinhMuc); } } if (!isNSAllDay) { var workTimeInDate = BLLShift.GetTotalWorkingHourOfLine(int.Parse(line.MaChuyen));// shiftDAO.TimeIsWorkAllDayOfLine(line.MaChuyen); int intHour = workTimeInDate.Hours; if (workTimeInDate.Minutes > 0) { intHour++; } dinhMuc = dinhMuc / intHour; } listPointDM.Add(new Model.Point() { X = line.TenChuyen, Y = (int)dinhMuc }); } } modelSeriesDM.ListPoint = listPointDM; modelSeries.ListPoint = listPoint; listModelSeries.Add(modelSeries); listModelSeries.Add(modelSeriesDM); string strDate = string.Empty; if (!isNSAllDay) { strDate = " Ngày " + date.Day + "/" + date.Month + "/" + date.Year; } else { strDate = " Từ Ngày " + date.Day + "/" + date.Month + "/" + date.Year + " Đến Ngày " + toDate.Day + "/" + toDate.Month + "/" + toDate.Year; } Helper.DrawChart.DrawBarChart(this.chartControl1, "Năng Suất Các Chuyền " + strDate, "Năng Suất", "Chuyền", listModelSeries); } catch (Exception ex) { throw ex; } }