//Set information for label Chuyen private void SetInfoForChuyen(ModelInfoChuyenOfKANBAN modelInfoChuyenKB) { try { List <ChuyenLabelKB> listChuyenLabel = null; if (listLabelForContent != null && listLabelForContent.Count > 0 && modelInfoChuyenKB != null) { listChuyenLabel = listLabelForContent.Where(c => c.chuyenId == modelInfoChuyenKB.chuyenId).ToList(); } if (listChuyenLabel != null && listChuyenLabel.Count > 0) { foreach (var item in listChuyenLabel) { if (item.systemName.Trim().Equals("maHang")) { item.label.Text = modelInfoChuyenKB.maHang; } else if (item.systemName.Trim().Equals("btpGiaoChuyenNgay")) { item.label.Text = modelInfoChuyenKB.btpGiaoChuyenNgay; } else if (item.systemName.Trim().Equals("luyKeBTP")) { item.label.Text = modelInfoChuyenKB.luyKeBTP; } else if (item.systemName.Trim().Equals("btpBinhQuanBTPTrenNgay")) { item.label.Text = modelInfoChuyenKB.btpBinhQuanBTPTrenNgay; } else if (item.systemName.Trim().Equals("tinhTrangBTP")) { item.panel.BackColor = DuAn03_HaiDang.Helper.HelperControl.GetColor(modelInfoChuyenKB.tinhTrangBTP); } } } } catch (Exception ex) { MessageBox.Show("Lỗi: " + ex.Message); } }
public ModelInfoChuyenOfKANBAN GetDataChuyen(string chuyenId, int tableType, ChuyenSanPham ChuyenSanPham) { ModelInfoChuyenOfKANBAN data = null; try { if (ChuyenSanPham == null) { var listChuyenSanPham = chuyenSanPhamDAO.GetListChuyenSanPham(chuyenId, false); if (listChuyenSanPham != null) { ChuyenSanPham = listChuyenSanPham.FirstOrDefault(); } } if (ChuyenSanPham != null) { int btpTrenChuyen = 0; int dinhMucNgay = 0; var ngay = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year; var nangSuat = nangSuatDAO.TTNangXuatTrongNgay(ngay, ChuyenSanPham.STT); if (nangSuat != null) { btpTrenChuyen = nangSuat.BTPTrenChuyen; dinhMucNgay = (int)nangSuat.DinhMucNgay; } btpTrenChuyen = btpTrenChuyen < 0 ? 0 : btpTrenChuyen; int laoDongChuyen = 0; var thanhPham = thanhPhamDAO.GetThanhPhamByNgayAndSTT(ngay, ChuyenSanPham.STT); if (thanhPham != null) { laoDongChuyen = thanhPham.LaoDongChuyen; } var listBTP = GetListBTPBySTT(ChuyenSanPham.STT); int btpGiaoChuyenNgay = 0; int luyKeBTP = 0; if (listBTP != null && listBTP.Count > 0) { int btpGiaoChuyenNgayTang = listBTP.Where(c => c.Ngay == ngay && c.IsEndOfLine == true && c.CommandTypeId == (int)eCommandRecive.BTPIncrease).Sum(c => c.BTPNgay); int btpGiaoChuyenNgayGiam = listBTP.Where(c => c.Ngay == ngay && c.IsEndOfLine == true && c.CommandTypeId == (int)eCommandRecive.BTPReduce).Sum(c => c.BTPNgay); btpGiaoChuyenNgay = btpGiaoChuyenNgayTang - btpGiaoChuyenNgayGiam; int luyKeBTPTang = listBTP.Where(c => c.IsEndOfLine && c.CommandTypeId == (int)eCommandRecive.BTPIncrease).Sum(c => c.BTPNgay); int luyKeBTPGiam = listBTP.Where(c => c.IsEndOfLine && c.CommandTypeId == (int)eCommandRecive.BTPReduce).Sum(c => c.BTPNgay); luyKeBTP = luyKeBTPTang - luyKeBTPGiam; } int btpBinhQuan = laoDongChuyen < 0 || btpTrenChuyen < 0 ? 0 : (int)(Math.Ceiling((double)btpTrenChuyen / laoDongChuyen)); // int tyLeDenThucTe = dinhMucNgay < 0 ? 0 : (btpTrenChuyen * 100) / dinhMucNgay; // string colorDen = denDAO.GetColorDen(ChuyenSanPham.IdDen, tableType, tyLeDenThucTe); int von = btpTrenChuyen > 0 && laoDongChuyen > 0 ? (int)(Math.Ceiling((double)btpTrenChuyen / laoDongChuyen)) : 0; string colorDen = denDAO.GetColorDen(ChuyenSanPham.IdDen, tableType, von); data = new ModelInfoChuyenOfKANBAN() { chuyenId = int.Parse(ChuyenSanPham.MaChuyen), maHang = ChuyenSanPham.TenSanPham, btpGiaoChuyenNgay = btpGiaoChuyenNgay.ToString(), luyKeBTP = luyKeBTP.ToString(), btpBinhQuanBTPTrenNgay = ((btpBinhQuan > 0 ? btpBinhQuan.ToString() : "0") + " / " + (btpTrenChuyen > 0 ? btpTrenChuyen.ToString() : "0")), btpTrenChuyen = btpTrenChuyen.ToString(), tinhTrangBTP = colorDen }; } } catch (Exception ex) { throw ex; } return(data); }