public FrmSendMailAndReadSound(int _timesGetNSInDay, int _getBTPInLineByType) { InitializeComponent(); timesGetNSInDay = _timesGetNSInDay; getBTPInLineByType = _getBTPInLineByType; this.cumDAO = new CumDAO(); this.chuyenDAO = new ChuyenDAO(); this.dtLoadData = new DataTable(); this.dtDataNSChuyenExportExcel = new DataTable(); this.dtDataNSCumExportExcel = new DataTable(); this.listSTTChuyen_SanPham = new List <string>(); this.listModelNangSuatCum = new List <ModelNangSuatCum>(); this.listNSCum = new List <NSCum>(); this.ChuyenSanPham = new ChuyenSanPham(); this.isSendMail = false; this.error = string.Empty; this.strType = string.Empty; this.strHost = string.Empty; this.intPort = 0; this.strFrom = string.Empty; this.strDisplayName = string.Empty; this.strPassword = string.Empty; this.strSubject = string.Empty; this.strBody = string.Empty; this.strTo = string.Empty; this.nangxuatDAO = new NangXuatDAO(); }
public ChuyenSanPham GetChuyenSanPhamInfByChuyenId(string IdChuyen) { ChuyenSanPham ChuyenSanPham = null; string strSQL = "SELECT TOP 1 csp.STT, c.TenChuyen, csp.SanLuongKeHoach, sp.TenSanPham FROM Chuyen_SanPham csp, Chuyen c, SanPham sp WHERE csp.MaChuyen = '" + IdChuyen + "' and csp.MaChuyen = c.MaChuyen and csp.IsFinish = 0 and csp.IsDelete = 0 and sp.IsDelete=0 and csp.MaSanPham = sp.MaSanPham and sp.IsDelete=0 and csp.Thang=" + DateTime.Now.Month + " and csp.Nam=" + DateTime.Now.Year + " Order By csp.STTThucHien ASC"; try { dt.Clear(); dt = dbclass.TruyVan_TraVe_DataTable(strSQL); if (dt != null && dt.Rows.Count > 0) { ChuyenSanPham = new ChuyenSanPham(); ChuyenSanPham.STT = dt.Rows[0]["STT"].ToString(); ChuyenSanPham.TenSanPham = dt.Rows[0]["TenSanPham"].ToString(); int sanLuongKeHoach = 0; int.TryParse(dt.Rows[0]["SanLuongKeHoach"].ToString(), out sanLuongKeHoach); ChuyenSanPham.SanLuongKeHoach = sanLuongKeHoach; ChuyenSanPham.TenChuyen = dt.Rows[0]["TenChuyen"].ToString(); } } catch (Exception ex) { throw ex; } return(ChuyenSanPham); }
//Load Data Of Chuyen private void LoadDataOfChuyen(string chuyenId, ChuyenSanPham ChuyenSanPham) { try { var data = btpDAO.GetDataChuyen(chuyenId, tableType, ChuyenSanPham); SetInfoForChuyen(data); } catch (Exception ex) { throw ex; } }
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); }