private void GetDataForCbbHours()
 {
     try
     {
         if (lines.Count > 0)
         {
             foreach (var item in lines)
             {
                 var wks = BLLShift.GetWorkingTimeOfLine(item.MaChuyen); // shiftDAO.GetListWorkHoursOfLineByLineId(line.MaChuyen);
                 if (wks != null && wks.Count > 0)
                 {
                     if (wks.Count > times.Count)
                     {
                         times.Clear();
                         times.AddRange(wks);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #2
0
        private void FrmLCDNangSuatCum_Load(object sender, EventArgs e)
        {
            try
            {
                LoadLCDConfig();
                //Get list Chuyen
                listChuyen = chuyenDAO.GetListChuyenInfByListId(AccountSuccess.strListChuyenId);
                if (listChuyen != null && listChuyen.Count > 0)
                {
                    line = listChuyen.First();
                    listClusterOfLine  = cumDAO.GetListClusterOfLine(line.MaChuyen);
                    titleLCD          += " " + line.TenChuyen;
                    listModelWorkHours = BLLShift.GetListWorkHoursOfLineByLineId(int.Parse(line.MaChuyen));// shiftDAO.GetListWorkHoursOfLineByLineId(line.MaChuyen);
                }
                //Get config information
                listTableLayoutPanelConfig = tableLayoutPanelConfigDAO.GetTableLayoutPanelConfig(tableType);
                //Get config panel
                listPanelConfig = panelConfigDAO.GetPanelConfig(tableType);
                //Get label config
                listLabelConfig = labelConfigDAO.GetLabelConfig(tableType);
                //Get label for tablepanel
                listLabelForTablePanel = labelConfigDAO.GetLabelForTablePanel(tableType);

                BuildPanelHeader();
                BuildPanelTitle1();
                BuildPanelContent();
                BuildPanelBody();
                initTimerDateTime();
                LoadDataLCDNSCum();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi: " + ex.Message);
            }
        }
 private void GetShiftToGrid()
 {
     try
     {
         var shifts = BLLShift.GetShift();
         gridControl.DataSource = null;
         gridControl.DataSource = shifts;
     }
     catch (Exception)
     {
     }
 }
Exemple #4
0
 private void GetShift_GridView()
 {
     try
     {
         lueShift.Text = "(-- Chọn Ca Làm Việc --)";
         var shifts = BLLShift.GetShift();
         if (shifts != null && shifts.Count > 0)
         {
             lueShift.Properties.DataSource    = shifts;
             lueShift.Properties.DisplayMember = "Name";
             lueShift.Properties.ValueMember   = "Id";
         }
     }
     catch (Exception)
     { }
 }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (shiftId != 0)
     {
         var kq = BLLShift.DeleteShift(shiftId);
         if (kq.IsSuccess)
         {
             MessageBox.Show("Xoá ca làm việc của chuyền thành công.", "xóa thành công", MessageBoxButtons.OK, MessageBoxIcon.None);
             ResetShiftForm();
         }
         else
         {
             MessageBox.Show("Không thể xoá ca làm việc.", "xóa thất bại", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Bạn chưa chọn ca làm việc muốn xoá , Vui lòng thực hiện thao tác này.", "Lỗi thực hiện", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
Exemple #6
0
 private void GetDataForCbbHours()
 {
     try
     {
         var line = (LineModel)cbbLine.SelectedItem;
         if (line != null)
         {
             var listModelWorkHours = BLLShift.GetWorkingTimeOfLine(line.MaChuyen);// shiftDAO.GetListWorkHoursOfLineByLineId(line.MaChuyen);
             if (listModelWorkHours != null && listModelWorkHours.Count > 0)
             {
                 cbbHours.DataSource    = listModelWorkHours;
                 cbbHours.DisplayMember = "Name";
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 private void SaveShift()
 {
     if (string.IsNullOrEmpty(txtCaLamViec.Text))
     {
         MessageBox.Show("Vui lòng nhập tên ca làm việc", "Lỗi nhập liệu");
     }
     else
     {
         var shift = new P_WorkingShift();
         shift.Id        = shiftId;
         shift.Name      = txtCaLamViec.Text;
         shift.TimeStart = DateTime.Parse(teditTimeStart.EditValue.ToString()).TimeOfDay;
         shift.TimeEnd   = DateTime.Parse(teditTimeEnd.EditValue.ToString()).TimeOfDay;
         var kq = BLLShift.InsertOrUpdateShift(shift);
         if (kq.IsSuccess)
         {
             GetShiftToGrid();
         }
         MessageBox.Show(kq.Messages[0].msg, kq.Messages[0].Title);
     }
 }
 private void GetDataForCbbHours()
 {
     try
     {
         if (listLine != null && listLine.Count > 0)
         {
             foreach (var line in listLine)
             {
                 var listModel = BLLShift.GetListWorkHoursOfLineByLineId(int.Parse(line.MaChuyen)); // shiftDAO.GetListWorkHoursOfLineByLineId(line.MaChuyen);
                 if (listModel != null && listModel.Count > 0)
                 {
                     if (listModel.Count > listModelWorkHours.Count)
                     {
                         listModelWorkHours = listModel;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #9
0
        public ResponseBase InsertOrUpdate(Chuyen_SanPham model)
        {
            var result = new ResponseBase();

            try
            {
                using (var db = new PMSEntities())
                {
                    var csp = db.Chuyen_SanPham.FirstOrDefault(x => !x.IsDelete && x.STT != model.STT && x.MaChuyen == model.MaChuyen && x.MaSanPham == model.MaSanPham && !x.IsFinish);
                    if (csp == null)
                    {
                        if (!CheckOrderIndex(model.STT, model.MaChuyen, model.STTThucHien, db))
                        {
                            if (model.STT == 0)
                            {
                                #region add
                                csp = new Chuyen_SanPham();
                                Parse.CopyObject(model, ref csp);
                                var monthDetail = new P_MonthlyProductionPlans();
                                monthDetail.Chuyen_SanPham   = csp;
                                monthDetail.Month            = DateTime.Now.Month;
                                monthDetail.Year             = DateTime.Now.Year;
                                monthDetail.ProductionPlans  = csp.SanLuongKeHoach;
                                csp.P_MonthlyProductionPlans = new List <P_MonthlyProductionPlans>();
                                csp.P_MonthlyProductionPlans.Add(monthDetail);
                                csp.TimeAdd = DateTime.Now;
                                db.Chuyen_SanPham.Add(csp);
                                db.SaveChanges();
                                result.IsSuccess = true;
                                result.Messages.Add(new Message()
                                {
                                    Title = "Thông Báo", msg = "Lưu Phân công thành công."
                                });

                                #endregion
                            }
                            else
                            {
                                csp = db.Chuyen_SanPham.FirstOrDefault(x => !x.IsDelete && x.STT == model.STT);
                                if (csp != null)
                                {
                                    var mDetail = db.P_MonthlyProductionPlans.FirstOrDefault(x => !x.IsDeleted && x.STT_C_SP == model.STT && x.Month == DateTime.Now.Month && x.Year == DateTime.Now.Year);
                                    if (mDetail != null)
                                    {
                                        if (csp.SanLuongKeHoach > model.SanLuongKeHoach)
                                        {
                                            mDetail.ProductionPlans -= (csp.SanLuongKeHoach - model.SanLuongKeHoach);
                                        }
                                        else
                                        {
                                            mDetail.ProductionPlans += (model.SanLuongKeHoach - csp.SanLuongKeHoach);
                                        }
                                    }

                                    csp.STTThucHien            = model.STTThucHien;
                                    csp.MaSanPham              = model.MaSanPham;
                                    csp.UpdatedDate            = model.UpdatedDate;
                                    csp.SanLuongKeHoach        = model.SanLuongKeHoach;
                                    csp.IsFinish               = csp.SanLuongKeHoach > csp.LuyKeTH ? false : true;
                                    csp.IsFinishBTPThoatChuyen = model.IsFinishBTPThoatChuyen;

                                    // update lai nang suat san suat va dinh muc ngay hien tai
                                    var ngay = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year;
                                    var tp   = db.ThanhPhams.FirstOrDefault(x => !x.IsDeleted && x.STTChuyen_SanPham == csp.STT && x.Ngay == ngay);
                                    var nx   = db.NangXuats.FirstOrDefault(x => !x.IsDeleted && x.STTCHuyen_SanPham == csp.STT && x.Ngay == ngay);
                                    if (tp != null && nx != null)
                                    {
                                        var tgLVTrongNgay = (int)BLLShift.GetTotalWorkingHourOfLine(csp.MaChuyen).TotalSeconds;
                                        tp.NangXuatLaoDong = (float)Math.Round((tgLVTrongNgay / csp.SanPham.ProductionTime), 2);

                                        nx.DinhMucNgay    = (float)Math.Round((tp.NangXuatLaoDong * tp.LaoDongChuyen), 1);
                                        nx.NhipDoSanXuat  = (float)Math.Round((csp.SanPham.ProductionTime / tp.LaoDongChuyen), 1);
                                        nx.TimeLastChange = DateTime.Now.TimeOfDay;
                                    }
                                    db.SaveChanges();
                                    //BLLProductivity.ResetNormsDayAndBTPInLine(2, obj.MaChuyen, false);
                                    result.IsSuccess = true;
                                    result.Messages.Add(new Message()
                                    {
                                        Title = "Thông Báo", msg = "Lưu Phân công thành công."
                                    });
                                }
                                else
                                {
                                    result.IsSuccess = false;
                                    result.Messages.Add(new Message()
                                    {
                                        Title = "Lỗi Lưu Phân Công", msg = "không tìm thấy Phân Công.\n"
                                    });
                                }
                            }
                        }
                        else
                        {
                            result.IsSuccess = false;
                            result.Messages.Add(new Message()
                            {
                                Title = "Thông Báo Trùng số thứ tự", msg = "Số thứ tự thực hiện  này được chọn. Vui lòng chọn số thứ tự thực hiện khác."
                            });
                        }
                    }
                    else
                    {
                        result.IsSuccess = false;
                        result.Messages.Add(new Message()
                        {
                            Title = "Lỗi Lưu Phân Công", msg = "Sản phẩm này đã được phân công và đang sản xuất.\n"
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Messages.Add(new Message()
                {
                    Title = "Lỗi Lưu Phân Công", msg = "Lưu Phân công cho Chuyền bị lỗi.\n" + ex.Message
                });
            }
            return(result);
        }
Exemple #10
0
        public List <Kanban_LCD> GetKanBanLCD(List <int> listLineId, int tableType, bool includingBTPHC)
        {
            var listModel = new List <Kanban_LCD>();
            var now       = DateTime.Now.ToString("d/M/yyyy");

            try
            {
                using (var db = new PMSEntities())
                {
                    if (listLineId != null && listLineId.Count > 0)
                    {
                        listLineId = listLineId.Distinct().ToList();
                        var listPCC = db.Chuyen_SanPham.Where(c => listLineId.Contains(c.MaChuyen) && !c.IsDelete && !c.IsFinish && !c.SanPham.IsDelete && !c.Chuyen.IsDeleted).ToList();
                        if (listPCC.Count > 0)
                        {
                            var listSTTLineProduct = listPCC.Select(c => c.STT).ToList();
                            var nangsuatngays      = db.NangXuats.Where(c => listSTTLineProduct.Contains(c.STTCHuyen_SanPham) && !c.IsDeleted && c.Ngay == now).ToList();
                            var thanhphamngays     = db.ThanhPhams.Where(c => listSTTLineProduct.Contains(c.STTChuyen_SanPham) && !c.IsDeleted && c.Ngay == now).ToList();
                            var btpngays           = db.BTPs.Where(c => listSTTLineProduct.Contains(c.STTChuyen_SanPham) && !c.IsDeleted && c.IsEndOfLine && (c.CommandTypeId == 8 || c.CommandTypeId == 13)).ToList();
                            foreach (var item in listPCC.OrderBy(x => x.MaChuyen).ThenBy(x => x.STTThucHien))
                            {
                                var model = new Kanban_LCD();
                                //  var line = db.Chuyens.Where(c => c.MaChuyen == item.MaChuyen && !c.IsDeleted).FirstOrDefault();
                                //  var PCOfLine = listPCC.FirstOrDefault(c => c.STT == item.STT);

                                //   var product = db.SanPhams.Where(c => c.MaSanPham == PCOfLine.MaSanPham && !c.IsDelete).FirstOrDefault();
                                var productivity = nangsuatngays.FirstOrDefault(c => c.STTCHuyen_SanPham == item.STT);
                                var dayInfo      = thanhphamngays.Where(c => c.STTChuyen_SanPham == item.STT).FirstOrDefault();
                                var listBTP      = btpngays.Where(c => c.STTChuyen_SanPham == item.STT).ToList();
                                var listTyLeDen  = db.P_ReadPercentOfLine.FirstOrDefault(x => !x.IsDeleted && !x.Chuyen_SanPham.IsDelete && x.AssignmentId == item.STT && x.P_LightPercent.Type == (int)eLightType.KanBan && x.LineId == item.MaChuyen);

                                model.LineName = item.Chuyen.TenChuyen;      // line.TenChuyen;
                                //  if (product != null)
                                model.ProductName = item.SanPham.TenSanPham; // product.TenSanPham;
                                int btpTrenChuyen = 0;
                                int dinhMucNgay   = 0;
                                if (productivity != null)
                                {
                                    btpTrenChuyen = productivity.BTPTrenChuyen;
                                    dinhMucNgay   = (int)productivity.DinhMucNgay;
                                }
                                int laoDongChuyen = 0;
                                if (dayInfo != null)
                                {
                                    laoDongChuyen = dayInfo.LaoDongChuyen;
                                }
                                int btpGiaoChuyenNgay = 0;
                                int luyKeBTP_HC = 0, luyKeBTP = 0;
                                if (listBTP != null && listBTP.Count > 0)
                                {
                                    int btpGiaoChuyenNgayTang = listBTP.Where(c => !c.IsBTP_PB_HC && c.Ngay == now && c.CommandTypeId == (int)eCommandRecive.BTPIncrease).Sum(c => c.BTPNgay);
                                    int btpGiaoChuyenNgayGiam = listBTP.Where(c => !c.IsBTP_PB_HC && c.Ngay == now && c.CommandTypeId == (int)eCommandRecive.BTPReduce).Sum(c => c.BTPNgay);
                                    btpGiaoChuyenNgay = btpGiaoChuyenNgayTang - btpGiaoChuyenNgayGiam;
                                    int luyKeBTPTang = listBTP.Where(c => c.IsBTP_PB_HC && c.CommandTypeId == (int)eCommandRecive.BTPIncrease).Sum(c => c.BTPNgay);
                                    int luyKeBTPGiam = listBTP.Where(c => c.IsBTP_PB_HC && c.CommandTypeId == (int)eCommandRecive.BTPReduce).Sum(c => c.BTPNgay);
                                    luyKeBTP_HC = luyKeBTPTang - luyKeBTPGiam;

                                    luyKeBTPTang = listBTP.Where(c => !c.IsBTP_PB_HC && c.CommandTypeId == (int)eCommandRecive.BTPIncrease).Sum(c => c.BTPNgay);
                                    luyKeBTPGiam = listBTP.Where(c => !c.IsBTP_PB_HC && c.CommandTypeId == (int)eCommandRecive.BTPReduce).Sum(c => c.BTPNgay);
                                    luyKeBTP     = luyKeBTPTang - luyKeBTPGiam;
                                }
                                int btpBinhQuan = laoDongChuyen == 0 ? 0 : (int)(Math.Ceiling((double)btpTrenChuyen / laoDongChuyen));
                                int von = btpTrenChuyen > 0 && laoDongChuyen > 0 ? (int)(Math.Ceiling((double)btpTrenChuyen / laoDongChuyen)) : 0;

                                int tyLeDenThucTe = von;
                                model.Von             = von;
                                model.BTPOnDay        = btpGiaoChuyenNgay;
                                model.LK_BTP_HC       = luyKeBTP_HC;
                                model.ProductionPlans = item.SanLuongKeHoach;    // PCOfLine.SanLuongKeHoach;
                                model.BTPBQ           = btpBinhQuan + "|" + btpTrenChuyen;
                                model.BTPBinhQuan     = btpBinhQuan;
                                model.BTPInLine       = btpTrenChuyen;
                                model.LK_BTP          = luyKeBTP;

                                string colorDen = "Black";
                                if (listTyLeDen != null)
                                {
                                    var den = db.P_LightPercent_De.FirstOrDefault(c => !c.IsDeleted && tyLeDenThucTe >= c.From && tyLeDenThucTe <= c.To && c.LightPercentId == listTyLeDen.KanbanLightPercentId);
                                    if (den != null)
                                    {
                                        if (den.ColorName.Trim().ToUpper().Equals("ĐỎ"))
                                        {
                                            colorDen = "Red";
                                        }
                                        else if (den.ColorName.Trim().ToUpper().Equals("VÀNG"))
                                        {
                                            colorDen = "Yellow";
                                        }
                                        if (den.ColorName.Trim().ToUpper().Equals("XANH"))
                                        {
                                            colorDen = "Blue";
                                        }
                                    }
                                }
                                model.StatusColor = colorDen;

                                int minBTP_HC = -1;
                                if (includingBTPHC)
                                {
                                    #region  lay thong tin btphc
                                    model.BTPHC_Structs.AddRange(db.P_Phase.Where(x => !x.IsDeleted && x.Type == (int)ePhaseType.BTP_HC && x.IsShow).Select(x => new PhaseModel()
                                    {
                                        Id    = x.Id,
                                        Index = x.Index,
                                        Name  = x.Name,
                                        Note  = "0"
                                    }).OrderBy(x => x.Index));
                                    if (model.BTPHC_Structs.Count > 0)
                                    {
                                        var btpHC_collec = db.P_Phase_Assign_Log.Where(x => x.AssignId == item.STT).ToList();
                                        if (btpHC_collec.Count > 0)
                                        {
                                            foreach (var iObj in model.BTPHC_Structs)
                                            {
                                                var sl       = 0;
                                                var foundObj = btpHC_collec.FirstOrDefault(x => x.PhaseId == iObj.Id);
                                                if (foundObj != null)
                                                {
                                                    sl = foundObj.Quantity;
                                                }
                                                iObj.Note = sl.ToString();

                                                if (minBTP_HC == -1)
                                                {
                                                    minBTP_HC = sl;
                                                }
                                                else if (sl < minBTP_HC)
                                                {
                                                    minBTP_HC = sl;
                                                }
                                            }
                                        }
                                    }
                                    #endregion
                                }
                                minBTP_HC     = minBTP_HC < 0 ? 0 : minBTP_HC;
                                model.BTP_Ton = minBTP_HC - model.LK_BTP;
                                model.BTP_Ton = model.BTP_Ton < 0 ? 0 : model.BTP_Ton;

                                //den btp con lai
                                int nangSuatGioKH      = 0;
                                var listModelWorkHours = BLLShift.GetListWorkHoursOfLineByLineId(item.MaChuyen);
                                if (listModelWorkHours != null && listModelWorkHours.Count > 0)
                                {
                                    nangSuatGioKH = (int)(dinhMucNgay / listModelWorkHours.Count);
                                }

                                colorDen = "";
                                int maTiLeBTPConLai = 0;
                                var chuyen          = db.Chuyens.FirstOrDefault(x => x.MaChuyen == item.MaChuyen);
                                if (chuyen != null && chuyen.IdTiLeBTPConLai.HasValue)
                                {
                                    maTiLeBTPConLai = chuyen.IdTiLeBTPConLai.Value;
                                }
                                if (maTiLeBTPConLai > 0)
                                {
                                    int btpconlai = model.BTP_Ton;
                                    if (btpconlai < 0)
                                    {
                                        btpconlai = 0;
                                    }
                                    var den = db.P_LightPercent_De.FirstOrDefault(c => btpconlai >= (c.From * nangSuatGioKH) && btpconlai <= (c.To * nangSuatGioKH) && c.LightPercentId == maTiLeBTPConLai && c.P_LightPercent.Type == (int)eLightType.BTPConLai);
                                    if (den != null)
                                    {
                                        if (den.ColorName.Trim().ToUpper().Equals("ĐỎ"))
                                        {
                                            colorDen = "Red";
                                        }
                                        else if (den.ColorName.Trim().ToUpper().Equals("VÀNG"))
                                        {
                                            colorDen = "Yellow";
                                        }
                                        if (den.ColorName.Trim().ToUpper().Equals("XANH"))
                                        {
                                            colorDen = "Blue";
                                        }
                                    }
                                }
                                model.LightBTPConLai = colorDen;
                                listModel.Add(model);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(listModel);
        }
Exemple #11
0
        public List <TongHop_LCD> GetTongHopLCD(List <int> lineIds, int tableTypeId, int TimesGetNS, int KhoangCachGetNSOnDay, int phaseHT)
        {
            try
            {
                using (var db = new PMSEntities())
                {
                    var listObjs = new List <TongHop_LCD>();
                    int hienThiNSGio = 1, lightId = 0;
                    var now      = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year;
                    var datetime = DateTime.Now;

                    for (int iii = 0; iii < lineIds.Count; iii++)
                    {
                        int lineId  = lineIds[iii];
                        var listPCC = db.Chuyen_SanPham.Where(c => !c.IsDelete && !c.IsFinish && !c.SanPham.IsDelete && !c.Chuyen.IsDeleted && c.MaChuyen == lineId).OrderBy(c => c.STTThucHien).ToList();
                        if (listPCC.Count > 0)
                        {
                            #region get Data
                            var listSTTLineProduct = listPCC.Select(c => c.STT).ToList();
                            var listProductivity   = db.NangXuats.Where(c => listSTTLineProduct.Contains(c.STTCHuyen_SanPham) && !c.IsDeleted).Select(x => new ProductivitiesModel()
                            {
                                #region
                                Id   = x.Id,
                                Ngay = x.Ngay,
                                STTCHuyen_SanPham      = x.STTCHuyen_SanPham,
                                BTPGiam                = x.BTPGiam,
                                BTPLoi                 = x.BTPLoi,
                                BTPTang                = x.BTPTang,
                                BTPThoatChuyenNgay     = x.BTPThoatChuyenNgay,
                                BTPThoatChuyenNgayGiam = x.BTPThoatChuyenNgayGiam,
                                BTPTrenChuyen          = x.BTPTrenChuyen,
                                DinhMucNgay            = x.DinhMucNgay,
                                IsBTP         = x.IsBTP,
                                IsChange      = x.IsChange,
                                IsChangeBTP   = x.IsChangeBTP,
                                IsEndDate     = x.IsEndDate,
                                IsStopOnDay   = x.IsStopOnDay,
                                NhipDoSanXuat = x.NhipDoSanXuat,
                                NhipDoThucTe  = x.NhipDoThucTe,
                                NhipDoThucTeBTPThoatChuyen = x.NhipDoThucTeBTPThoatChuyen,
                                SanLuongLoi      = x.SanLuongLoi,
                                SanLuongLoiGiam  = x.SanLuongLoiGiam,
                                ThucHienNgay     = x.ThucHienNgay,
                                ThucHienNgayGiam = x.ThucHienNgayGiam,
                                TimeLastChange   = x.TimeLastChange,
                                TimeStopOnDay    = x.TimeStopOnDay,
                                productId        = x.Chuyen_SanPham.SanPham.MaSanPham,
                                ProductName      = x.Chuyen_SanPham.SanPham.TenSanPham,
                                ProductPrice     = x.Chuyen_SanPham.SanPham.DonGia,
                                ProductPriceCM   = x.Chuyen_SanPham.SanPham.DonGiaCM,
                                LineId           = x.Chuyen_SanPham.MaChuyen,
                                LineName         = x.Chuyen_SanPham.Chuyen.TenChuyen,
                                IdDenNangSuat    = x.Chuyen_SanPham.Chuyen.IdDenNangSuat,
                                LaborsBase       = x.Chuyen_SanPham.Chuyen.LaoDongDinhBien,
                                TGCheTaoSP       = x.TGCheTaoSP,
                                CreatedDate      = x.CreatedDate
                                                   #endregion
                            }).ToList();

                            var thanhphams  = db.ThanhPhams.Where(c => listSTTLineProduct.Contains(c.STTChuyen_SanPham) && !c.IsDeleted).ToList();
                            var listDayInfo = db.ThanhPhams.Where(c => listSTTLineProduct.Contains(c.STTChuyen_SanPham) && !c.IsDeleted && c.Ngay == now).ToList();
                            #endregion

                            for (int z = 0; z < listSTTLineProduct.Count; z++)
                            {
                                //var historyObj = BLLHistoryPressedKeypad.Instance.Get(lineId, now);
                                //var pccSX = ((historyObj == null || historyObj.AssignmentId == null) ? listPCC.First() : listPCC.FirstOrDefault(x => x.STT == historyObj.AssignmentId));
                                //if (pccSX == null && listPCC.Count > 0)
                                //    pccSX = listPCC.First();

                                //update son ha 22/10/2018
                                var pccSX = listPCC.FirstOrDefault(x => x.STT == listSTTLineProduct[z]);

                                var productivity  = listProductivity.FirstOrDefault(c => c.STTCHuyen_SanPham == pccSX.STT && c.Ngay == now);
                                var dayInfo       = listDayInfo.FirstOrDefault(c => c.STTChuyen_SanPham == pccSX.STT);
                                var listBTPOfLine = db.BTPs.Where(c => !c.IsBTP_PB_HC && listSTTLineProduct.Contains(c.STTChuyen_SanPham) && !c.IsDeleted && c.IsEndOfLine && (c.CommandTypeId == (int)eCommandRecive.BTPIncrease || c.CommandTypeId == (int)eCommandRecive.BTPReduce)).ToList();
                                var monthDetails  = db.P_MonthlyProductionPlans.Where(x => !x.IsDeleted && x.Month == datetime.Month && x.Year == datetime.Year && listSTTLineProduct.Contains(x.STT_C_SP)).ToList();
                                var nxInMonth     = listProductivity.Where(x => x.STTCHuyen_SanPham == pccSX.STT && x.CreatedDate.Month == datetime.Month && x.CreatedDate.Year == datetime.Year).ToList();
                                var congdoanLog   = db.P_Phase_Assign_Log.FirstOrDefault(x => x.AssignId == pccSX.STT && x.PhaseId == phaseHT);

                                #region MyRegion
                                if (productivity != null && dayInfo != null)
                                {
                                    double tyLeDen = 0;
                                    var    model   = new TongHop_LCD();
                                    model.LineName     = productivity.LineName;
                                    model.ProductName  = productivity.ProductName;
                                    model.LK_KCS       = (int)pccSX.LuyKeTH;
                                    model.LK_TC        = (int)pccSX.LuyKeBTPThoatChuyen;
                                    model.LK_BTP       = pccSX.LK_BTP;
                                    model.LDDB         = productivity.LaborsBase;
                                    model.LDTT         = dayInfo.LaoDongChuyen;
                                    model.SLKH         = pccSX.SanLuongKeHoach;
                                    model.SLCL         = (pccSX.SanLuongKeHoach - model.LK_KCS);
                                    model.DMN          = (int)Math.Round(productivity.DinhMucNgay);
                                    model.KCS          = productivity.ThucHienNgay - productivity.ThucHienNgayGiam;
                                    model.TC           = productivity.BTPThoatChuyenNgay - productivity.BTPThoatChuyenNgayGiam;
                                    model.tiLeThucHien = (model.DMN > 0 && model.KCS > 0) ? ((int)((model.KCS * 100) / model.DMN)) + "" : "0";
                                    model.NhipSX       = Math.Round((double)productivity.NhipDoSanXuat, 1);
                                    model.NhipTT       = Math.Round((double)productivity.NhipDoThucTe, 1);
                                    model.NhipTC       = Math.Round((double)productivity.NhipDoThucTeBTPThoatChuyen, 1);
                                    model.Error        = productivity.SanLuongLoi - productivity.SanLuongLoiGiam;
                                    #region
                                    int btpTrenChuyenBinhQuan = dayInfo.LaoDongChuyen == 0 || productivity.BTPTrenChuyen == 0 ? 0 : (int)Math.Ceiling((double)productivity.BTPTrenChuyen / dayInfo.LaoDongChuyen);
                                    model.BTPInLine    = productivity.BTPTrenChuyen;
                                    model.BTPInLine_BQ = btpTrenChuyenBinhQuan;

                                    model.SLKH      = pccSX.SanLuongKeHoach;
                                    model.LK_TC     = pccSX.LuyKeBTPThoatChuyen;
                                    lightId         = productivity.IdDenNangSuat ?? 0;
                                    model.BTP       = 0;
                                    model.LK_BTP    = 0;
                                    model.KCSHour   = 0;
                                    model.TCHour    = 0;
                                    model.ErrHour   = 0;
                                    model.DMHour    = 0;
                                    model.TiLeLoi_D = 0;
                                    if (listBTPOfLine != null && listBTPOfLine.Count > 0)
                                    {
                                        int btpGiaoChuyenNgayTang = listBTPOfLine.Where(c => !c.IsBTP_PB_HC && c.Ngay == now && c.CommandTypeId == (int)eCommandRecive.BTPIncrease).Sum(c => c.BTPNgay);
                                        int btpGiaoChuyenNgayGiam = listBTPOfLine.Where(c => !c.IsBTP_PB_HC && c.Ngay == now && c.CommandTypeId == (int)eCommandRecive.BTPReduce).Sum(c => c.BTPNgay);
                                        model.BTP = btpGiaoChuyenNgayTang - btpGiaoChuyenNgayGiam;

                                        btpGiaoChuyenNgayTang = listBTPOfLine.Where(c => !c.IsBTP_PB_HC && c.CommandTypeId == (int)eCommandRecive.BTPIncrease).Sum(c => c.BTPNgay);
                                        btpGiaoChuyenNgayGiam = listBTPOfLine.Where(c => !c.IsBTP_PB_HC && c.CommandTypeId == (int)eCommandRecive.BTPReduce).Sum(c => c.BTPNgay);
                                        model.LK_BTP          = btpGiaoChuyenNgayTang - btpGiaoChuyenNgayGiam;
                                    }
                                    #endregion
                                    model.LK_HOANTHANH = 0;
                                    if (congdoanLog != null)
                                    {
                                        model.LK_HOANTHANH = congdoanLog.Quantity;
                                    }

                                    #region Get Hours Productivity
                                    var    totalWorkingTimeInDay = BLLShift.GetTotalWorkingHourOfLine(lineId);
                                    int    intWorkTime           = (int)(totalWorkingTimeInDay.TotalHours);
                                    int    intWorkMinuter        = (int)totalWorkingTimeInDay.TotalMinutes;
                                    double NangSuatPhutKH        = 0;
                                    int    NangSuatGioKH         = 0;
                                    var    dateNow = DateTime.Now.Date;
                                    int    tongTCNgay = 0, tongKCSNgay = 0;
                                    model.DMHour = (int)Math.Ceiling((double)model.DMN / intWorkTime);
                                    double phutToNow = GetSoPhutLamViecTrongNgay_(DateTime.Now.TimeOfDay, BLLShift.GetShiftsOfLine(lineId));
                                    if (intWorkTime > 0)
                                    {
                                        NangSuatPhutKH = (double)model.DMN / intWorkMinuter;
                                        NangSuatGioKH  = (int)(model.DMN / intWorkTime);
                                        if (model.DMN % intWorkTime != 0)
                                        {
                                            NangSuatGioKH++;
                                        }


                                        #region  hiển thị một ô năng suất hiện tại duy nhất

                                        double nsKHToNow    = (phutToNow / intWorkMinuter) * model.DMN;
                                        double tiLePhanTram = 0;
                                        tiLePhanTram = (model.KCS > 0 && nsKHToNow > 0) ? (Math.Round((double)((model.KCS * 100) / nsKHToNow), 2)) : 0;
                                        // model.CurrentNS = model.KCS + "/" + (int)nsKHToNow + "  (" + tiLePhanTram + "%)";
                                        model.SLKHToNow = (int)nsKHToNow;
                                        #endregion


                                        #region
                                        List <WorkingTimeModel> listWorkHoursOfLine = new List <WorkingTimeModel>();
                                        switch (hienThiNSGio)
                                        {
                                        case (int)eShowNSType.PercentTH_FollowHour:
                                        case (int)eShowNSType.TH_Err_FollowHour:
                                        case (int)eShowNSType.TH_DM_FollowHour:
                                        case (int)eShowNSType.TH_TC_FollowHour:
                                            listWorkHoursOfLine = BLLShift.GetListWorkHoursOfLineByLineId(lineId);
                                            break;

                                        case (int)eShowNSType.PercentTH_FollowConfig:
                                        case (int)eShowNSType.TH_Err_FollowConfig:
                                        case (int)eShowNSType.TH_DM_FollowConfig:
                                        case (int)eShowNSType.TH_TC_FollowConfig:
                                            listWorkHoursOfLine = BLLShift.GetListWorkHoursOfLineByLineId(lineId, TimesGetNS);
                                            break;

                                        case (int)eShowNSType.TH_DM_OnDay:
                                        case (int)eShowNSType.TH_TC_OnDay:
                                        case (int)eShowNSType.TH_Error_OnDay:
                                            listWorkHoursOfLine.Add(new WorkingTimeModel()
                                            {
                                                TimeStart = DateTime.Now.AddHours(-KhoangCachGetNSOnDay).TimeOfDay,
                                                TimeEnd   = DateTime.Now.TimeOfDay,
                                                IntHours  = 1,
                                            });

                                            listWorkHoursOfLine.Add(new WorkingTimeModel()
                                            {
                                                TimeStart = DateTime.Now.AddHours(-(KhoangCachGetNSOnDay + KhoangCachGetNSOnDay)).TimeOfDay,
                                                TimeEnd   = DateTime.Now.AddHours(-KhoangCachGetNSOnDay).TimeOfDay,
                                                IntHours  = 2,
                                            });
                                            break;
                                        }

                                        if (listWorkHoursOfLine != null && listWorkHoursOfLine.Count > 0)
                                        {
                                            var dayInformations = db.TheoDoiNgays.Where(c => c.MaChuyen == lineId && c.STTChuyenSanPham == pccSX.STT && c.Date == now && c.IsEndOfLine).Select(x => new DayInfoModel()
                                            {
                                                CommandTypeId       = x.CommandTypeId,
                                                CumId               = x.CumId,
                                                MaChuyen            = x.MaChuyen,
                                                MaSanPham           = x.MaSanPham,
                                                Time                = x.Time,
                                                Date                = x.Date,
                                                ErrorId             = x.ErrorId,
                                                IsEndOfLine         = x.IsEndOfLine,
                                                IsEnterByKeypad     = x.IsEnterByKeypad,
                                                STT                 = x.STT,
                                                STTChuyenSanPham    = x.STTChuyenSanPham,
                                                ThanhPham           = x.ThanhPham,
                                                ProductOutputTypeId = x.ProductOutputTypeId
                                            }).ToList();

                                            var t = dayInformations.Where(c => c.CommandTypeId == (int)eCommandRecive.ProductIncrease && c.ProductOutputTypeId == (int)eProductOutputType.TC).Sum(c => c.ThanhPham);
                                            var g = dayInformations.Where(c => c.CommandTypeId == (int)eCommandRecive.ProductReduce && c.ProductOutputTypeId == (int)eProductOutputType.TC).Sum(c => c.ThanhPham);
                                            tongTCNgay += (t - g);
                                            bool isValid = false;
                                            for (int i = 0; i < listWorkHoursOfLine.Count; i++)
                                            {
                                                if (DateTime.Now.TimeOfDay > listWorkHoursOfLine[i].TimeStart && DateTime.Now.TimeOfDay <= listWorkHoursOfLine[i].TimeEnd)
                                                {
                                                    isValid = true;
                                                }

                                                //DM Gio
                                                listWorkHoursOfLine[i].NormsHour = Math.Round(NangSuatPhutKH * (int)((listWorkHoursOfLine[0].TimeEnd - listWorkHoursOfLine[0].TimeStart).TotalMinutes));
                                                if ((hienThiNSGio == (int)eShowNSType.TH_DM_FollowHour || hienThiNSGio == (int)eShowNSType.PercentTH_FollowHour) && i == listWorkHoursOfLine.Count - 1)
                                                {
                                                    listWorkHoursOfLine[i].NormsHour = Math.Round(NangSuatPhutKH * (int)((listWorkHoursOfLine[i].TimeEnd - listWorkHoursOfLine[i].TimeStart).TotalMinutes));
                                                }

                                                #region
                                                int Tang = 0, Giam = 0;
                                                var theoDoiNgays = dayInformations.Where(c => c.MaChuyen == lineId && c.Time > listWorkHoursOfLine[i].TimeStart && c.Time <= listWorkHoursOfLine[i].TimeEnd && c.Date == now && c.IsEndOfLine).ToList();
                                                if (theoDoiNgays.Count > 0)
                                                {
                                                    //Kcs
                                                    Tang  = theoDoiNgays.Where(c => c.CommandTypeId == (int)eCommandRecive.ProductIncrease && c.ProductOutputTypeId == (int)eProductOutputType.KCS).Sum(c => c.ThanhPham);
                                                    Giam  = theoDoiNgays.Where(c => c.CommandTypeId == (int)eCommandRecive.ProductReduce && c.ProductOutputTypeId == (int)eProductOutputType.KCS).Sum(c => c.ThanhPham);
                                                    Tang -= Giam;

                                                    listWorkHoursOfLine[i].KCS = Tang;
                                                    listWorkHoursOfLine[i].HoursProductivity = (listWorkHoursOfLine[i].KCS < 0 ? 0 : listWorkHoursOfLine[i].KCS) + "/" + listWorkHoursOfLine[i].NormsHour;
                                                    tongKCSNgay += Tang;
                                                    if (isValid)
                                                    {
                                                        model.KCSHour = Tang;
                                                    }

                                                    // TC
                                                    Tang  = theoDoiNgays.Where(c => c.CommandTypeId == (int)eCommandRecive.ProductIncrease && c.ProductOutputTypeId == (int)eProductOutputType.TC).Sum(c => c.ThanhPham);
                                                    Giam  = theoDoiNgays.Where(c => c.CommandTypeId == (int)eCommandRecive.ProductReduce && c.ProductOutputTypeId == (int)eProductOutputType.TC).Sum(c => c.ThanhPham);
                                                    Tang -= Giam;

                                                    listWorkHoursOfLine[i].TC = Tang;
                                                    listWorkHoursOfLine[i].HoursProductivity_1 = (listWorkHoursOfLine[i].KCS < 0 ? 0 : listWorkHoursOfLine[i].KCS) + "/" + (listWorkHoursOfLine[i].TC < 0 ? 0 : listWorkHoursOfLine[i].TC);
                                                    //   tongTCNgay += Tang;
                                                    if (isValid)
                                                    {
                                                        model.TCHour = Tang;
                                                    }

                                                    // lỗi
                                                    Tang  = theoDoiNgays.Where(c => c.CommandTypeId == (int)eCommandRecive.ErrorIncrease).Sum(c => c.ThanhPham);
                                                    Giam  = theoDoiNgays.Where(c => c.CommandTypeId == (int)eCommandRecive.ErrorReduce).Sum(c => c.ThanhPham);
                                                    Tang -= Giam;
                                                    listWorkHoursOfLine[i].Error = Tang;
                                                    //  model.Error += Tang;
                                                    if (isValid)
                                                    {
                                                        model.ErrHour = Tang;
                                                    }
                                                }
                                                else
                                                {
                                                    listWorkHoursOfLine[i].HoursProductivity   = "0/" + listWorkHoursOfLine[i].NormsHour;
                                                    listWorkHoursOfLine[i].HoursProductivity_1 = "0/0";
                                                }
                                                #endregion
                                            }
                                        }
                                        #endregion

                                        //  model.ErrorNgay += finishError;
                                        model.listWorkHours          = listWorkHoursOfLine;
                                        model.KieuHienThiNangSuatGio = db.Configs.Where(x => x.Name.Trim().ToUpper().Equals("KieuHienThiNangSuatGio")).FirstOrDefault().ValueDefault.Trim();

                                        //  model.KCS = tongKCSNgay;
                                        model.DMN = (int)productivity.DinhMucNgay;
                                        //  model.TC = tongTCNgay;

                                        double minutes = 0, pro = 0, pro_lech = 0, time_lech = 0, LK_err = 0;
                                        minutes  = GetSoPhutLamViecTrongNgay_(DateTime.Now.TimeOfDay, BLLShift.GetShiftsOfLine(lineId));
                                        pro      = (minutes / intWorkMinuter) * model.DMN;
                                        pro_lech = pro - productivity.BTPThoatChuyenNgay;
                                        if (pro_lech > 0)
                                        {
                                            time_lech = Math.Round(((pro_lech / model.LDTT) * productivity.TGCheTaoSP) / 3600);
                                        }
                                        model.Hour_ChenhLech_Day = time_lech > 0 ? (int)time_lech : 0;

                                        var proOfCommo = listProductivity.Where(x => x.STTCHuyen_SanPham == productivity.STTCHuyen_SanPham && x.Ngay != now);
                                        foreach (var item in proOfCommo)
                                        {
                                            pro_lech = item.DinhMucNgay - (item.BTPThoatChuyenNgay - item.BTPThoatChuyenNgayGiam);
                                            if (pro_lech > 0)
                                            {
                                                time_lech += ((pro_lech / item.LaborsBase) * item.TGCheTaoSP) / 3600;
                                            }
                                            LK_err += item.SanLuongLoi - item.SanLuongLoiGiam;
                                        }

                                        model.Hour_ChenhLech = time_lech > 0 ? (int)time_lech : 0;

                                        model.KCS_QuaTay    = model.KCS + model.Error;
                                        model.LK_KCS_QuaTay = model.LK_KCS + (int)LK_err;
                                        model.TiLeLoi_D     = (model.Error != 0 ? (int)Math.Ceiling((model.Error / (double)(model.Error + model.KCS)) * 100) : 0);
                                    }
                                    #endregion

                                    //if (productivity.NhipDoThucTe > 0)
                                    //    tyLeDen = (model.NhipSX * 100) / productivity.NhipDoThucTe;

                                    // sua lai kcs / dmtoNow * 100
                                    //  if (model.SLKHToNow > 0)
                                    //      tyLeDen = Math.Round((model.KCS / model.SLKHToNow) * 100, 1);

                                    //update theo yc cua sonha 17/10/2018
                                    // tyLeDen = kcs gio/muctieugio*100
                                    if (model.SLKHToNow > 0)
                                    {
                                        tyLeDen = (model.KCSHour / model.DMHour) * 100;
                                    }

                                    var lightConfig = db.Dens.Where(c => c.IdCatalogTable == tableTypeId && c.STTParent == lightId && c.ValueFrom <= tyLeDen && tyLeDen < c.ValueTo).FirstOrDefault();
                                    model.mauDen = lightConfig != null?lightConfig.Color.Trim().ToUpper() : "ĐỎ";

                                    if (model.BTPInLine < 0)
                                    {
                                        model.BTPInLine = 0;
                                    }
                                    model.Lean      = Math.Ceiling((double)(model.BTPInLine > 0 ? (model.BTPInLine / model.LDTT) : 0));
                                    model.NSHienTai = (model.KCS + "/" + model.SLKHToNow + " (" + (model.SLKHToNow > 0 ? Math.Round((model.KCS / model.SLKHToNow), 1) : 0) + "%)");

                                    //  Hiệu suất = (Tổng sản lượng ra chuyền X thời gian chế tạo) : Số lao động X thời gian làm việc thực tế(giay).
                                    model.HieuSuat = (int)(((model.KCS * productivity.TGCheTaoSP) / Math.Round((model.LDTT * (phutToNow * 60)))) * 100);
                                    //  model.HieuSuat = (model.SLKHToNow > 0 ? (int)Math.Round((model.KCS / model.SLKHToNow), 1) : 0);

                                    lightConfig          = db.Dens.FirstOrDefault(c => c.IdCatalogTable == tableTypeId && c.STTParent == lightId && c.ValueFrom <= model.HieuSuat && model.HieuSuat < c.ValueTo);
                                    model.mauDenHieuSuat = lightConfig != null?lightConfig.Color.Trim().ToUpper() : "ĐỎ";

                                    listObjs.Add(model);
                                }
                                #endregion
                            }
                        }
                    }
                    return(listObjs);
                }
            }
            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;
            }
        }