private void DrawingMQCSummary(string byPreriodTime)
        {
            DateTime from = new DateTime(dtpk_fromDate.Value.Year, dtpk_fromDate.Value.Month, dtpk_fromDate.Value.Day,
                                         tpk_from.Value.Hour, tpk_from.Value.Minute, tpk_from.Value.Second);
            DateTime to = new DateTime(dtpk_ToDate.Value.Year, dtpk_ToDate.Value.Month, dtpk_ToDate.Value.Day,
                                       tpk_to.Value.Hour, tpk_to.Value.Minute, tpk_to.Value.Second);

            if (byPreriodTime == "Date")
            {
                LoadDataSummary dataSummary = new LoadDataSummary();

                listMQCSummary = dataSummary.GetMQCSummary(from, to, "B01", "MQC");
                LiveChartDrawing liveChartDrawing = new LiveChartDrawing();
                liveChartDrawing.DrawingLiveChartDataSummary(listMQCSummary, ref ProductionLine);
                dtgv_data.DataSource = listMQCSummary;
            }
            else if (byPreriodTime == "Week")
            {
                LoadDataSummary dataSummary = new LoadDataSummary();
                listMQCSummary = dataSummary.GetMQCSummarybyWeek(from, to, "B01", "MQC");
                var ListMQCbyProduct = listMQCSummary
                                       .OrderBy(d => int.Parse(d.Time_from))
                                       .GroupBy(u => u.Time_from)
                                       .Select(grp => grp.ToList())
                                       .ToList();
                listMQCSummary = new List <MQCItemSummary>();
                foreach (var ItemGroup in ListMQCbyProduct)
                {
                    MQCItemSummary itemSummary = new MQCItemSummary();
                    itemSummary.OutputQty     = ItemGroup.Select(d => d.OutputQty).Sum();
                    itemSummary.NGQty         = ItemGroup.Select(d => d.NGQty).Sum();
                    itemSummary.ReworkQty     = ItemGroup.Select(d => d.ReworkQty).Sum();
                    itemSummary.QuantityTotal = itemSummary.OutputQty + itemSummary.NGQty /*+ itemSummary.ReworkQty*/;
                    itemSummary.OutputRate    = (itemSummary.QuantityTotal != 0) ? (itemSummary.OutputQty / itemSummary.QuantityTotal) : 0;
                    itemSummary.DefectRate    = (itemSummary.QuantityTotal != 0) ? (itemSummary.NGQty / itemSummary.QuantityTotal) : 0;
                    itemSummary.ReworkRate    = (itemSummary.QuantityTotal != 0) ? (itemSummary.ReworkQty / itemSummary.QuantityTotal) : 0;
                    itemSummary.Time_from     = "Week: " + ItemGroup[0].Time_from;

                    listMQCSummary.Add(itemSummary);
                }
                LiveChartDrawing liveChartDrawing = new LiveChartDrawing();
                liveChartDrawing.DrawingLiveChartDataSummary(listMQCSummary, ref ProductionLine);
                dtgv_data.DataSource = listMQCSummary;
            }
            else if (byPreriodTime == "Month")
            {
                LoadDataSummary dataSummary = new LoadDataSummary();
                listMQCSummary = dataSummary.GetMQCSummarybyMonth(from, to, "B01", "MQC");
                var ListMQCbyProduct = listMQCSummary
                                       .GroupBy(u => u.Time_from)
                                       .Select(grp => grp.ToList())
                                       .ToList();
                listMQCSummary = new List <MQCItemSummary>();
                foreach (var ItemGroup in ListMQCbyProduct)
                {
                    MQCItemSummary itemSummary = new MQCItemSummary();
                    itemSummary.OutputQty     = ItemGroup.Select(d => d.OutputQty).Sum();
                    itemSummary.NGQty         = ItemGroup.Select(d => d.NGQty).Sum();
                    itemSummary.ReworkQty     = ItemGroup.Select(d => d.ReworkQty).Sum();
                    itemSummary.QuantityTotal = itemSummary.OutputQty + itemSummary.NGQty /*+ itemSummary.ReworkQty*/;
                    itemSummary.OutputRate    = (itemSummary.QuantityTotal != 0) ? (itemSummary.OutputQty / itemSummary.QuantityTotal) : 0;
                    itemSummary.DefectRate    = (itemSummary.QuantityTotal != 0) ? (itemSummary.NGQty / itemSummary.QuantityTotal) : 0;
                    itemSummary.ReworkRate    = (itemSummary.QuantityTotal != 0) ? (itemSummary.ReworkQty / itemSummary.QuantityTotal) : 0;
                    itemSummary.Time_from     = ItemGroup[0].Time_from;

                    listMQCSummary.Add(itemSummary);
                }
                LiveChartDrawing liveChartDrawing = new LiveChartDrawing();
                liveChartDrawing.DrawingLiveChartDataSummary(listMQCSummary, ref ProductionLine);
                dtgv_data.DataSource = listMQCSummary;
            }
            else if (byPreriodTime == "Year")
            {
                LoadDataSummary dataSummary = new LoadDataSummary();
                listMQCSummary = dataSummary.GetMQCSummarybyYear(from, to, "B01", "MQC");
                var ListMQCbyProduct = listMQCSummary
                                       .GroupBy(u => u.Time_from)
                                       .Select(grp => grp.ToList())
                                       .ToList();
                listMQCSummary = new List <MQCItemSummary>();
                foreach (var ItemGroup in ListMQCbyProduct)
                {
                    MQCItemSummary itemSummary = new MQCItemSummary();
                    itemSummary.OutputQty     = ItemGroup.Select(d => d.OutputQty).Sum();
                    itemSummary.NGQty         = ItemGroup.Select(d => d.NGQty).Sum();
                    itemSummary.ReworkQty     = ItemGroup.Select(d => d.ReworkQty).Sum();
                    itemSummary.QuantityTotal = itemSummary.OutputQty + itemSummary.NGQty /*+ itemSummary.ReworkQty*/;
                    itemSummary.OutputRate    = (itemSummary.QuantityTotal != 0) ? (itemSummary.OutputQty / itemSummary.QuantityTotal) : 0;
                    itemSummary.DefectRate    = (itemSummary.QuantityTotal != 0) ? (itemSummary.NGQty / itemSummary.QuantityTotal) : 0;
                    itemSummary.ReworkRate    = (itemSummary.QuantityTotal != 0) ? (itemSummary.ReworkQty / itemSummary.QuantityTotal) : 0;
                    itemSummary.Time_from     = ItemGroup[0].Time_from;

                    listMQCSummary.Add(itemSummary);
                }
                LiveChartDrawing liveChartDrawing = new LiveChartDrawing();
                liveChartDrawing.DrawingLiveChartDataSummary(listMQCSummary, ref ProductionLine);
                dtgv_data.DataSource = listMQCSummary;
            }
        }