Exemplo n.º 1
0
        public void AddListData(ExcelWorksheet ws)
        {
            var phuongTienList = BS_CUS_VANTAI_CONF_PhuongTien.get_CUS_VANTAI_CONF_PhuongTien(db, PartnerID, new Dictionary <string, string>());
            var nhanSuList     = BS_CUS_HRM_STAFF_NhanSu.get_CUS_HRM_STAFF_NhanSu(db, PartnerID, new Dictionary <string, string>());
            Dictionary <string, string> queryStrings = new Dictionary <string, string>();
            //queryStrings.Add("CodeTinhTrangLamViec", "\"PT1\", \"PT2\"");

            var lenhLamViecList = BS_CUS_VANTAI_WO_LenhLamViec.get_CUS_VANTAI_WO_LenhLamViec(db, PartnerID, queryStrings, true);
            //A.Xe
            //B.Tài xế
            //C.Phụ xe
            //D.Nội dung làm việc

            int rowid = 1;

            foreach (var item in phuongTienList)
            {
                rowid++;
                ws.Cells["A" + rowid].Value = item.Code + " [" + item.ID + "]";
            }

            rowid = 1;
            foreach (var item in nhanSuList)
            {
                if (item.IDChucDanh == 5 || item.IDChucDanh == 8 || item.IDChucDanh == 10 || item.IDChucDanh == 12)
                {
                    rowid++;
                    ws.Cells["B" + rowid].Value = item.TenDayDu + " [" + item.ID + "]";
                }
            }

            rowid = 1;
            foreach (var item in nhanSuList)
            {
                if (item.IDChucDanh == 6 || item.IDChucDanh == 9 || item.IDChucDanh == 11 || item.IDChucDanh == 14)
                {
                    rowid++;
                    ws.Cells["C" + rowid].Value = item.TenDayDu + " [" + item.ID + "]";
                }
            }


            rowid = 1;
            foreach (var item in lenhLamViecList)
            {
                rowid++;
                ws.Cells["D" + rowid].Value = item.Name + " [" + item.ID + "]";
            }
        }
Exemplo n.º 2
0
        public void AddRows(ExcelWorksheet ws)
        {
            var phuongTienList  = BS_CUS_VANTAI_CONF_PhuongTien.get_CUS_VANTAI_CONF_PhuongTien(db, PartnerID, new Dictionary <string, string>()).ToList();
            var lenhLamViecList = BS_CUS_VANTAI_WO_LenhLamViec.get_CUS_VANTAI_WO_LenhLamViec(db, PartnerID, new Dictionary <string, string>(), true);
            var nhanSuList      = BS_CUS_HRM_STAFF_NhanSu.get_CUS_HRM_STAFF_NhanSu(db, PartnerID, new Dictionary <string, string>());
            int rowid           = 1;

            foreach (var lenhLamViec in lenhLamViecList)
            {
                var nhatKyLamViecList = db.tbl_CUS_VANTAI_WO_NhatKyLamViec.Where(d => d.IsDeleted == false && d.IDPartner == PartnerID && d.IDLenhLamViec == lenhLamViec.ID).ToList();
                if (nhatKyLamViecList.Count() == 0 && lenhLamViec.NgayThucHien <= DateTime.Today && DateTime.Today <= lenhLamViec.NgayDuKienKetThuc && (lenhLamViec.IDTinhTrangLamViec == 2 || lenhLamViec.IDTinhTrangLamViec == 5))
                {
                    var tempNhatKy = new tbl_CUS_VANTAI_WO_NhatKyLamViec()
                    {
                        IDLenhLamViec = lenhLamViec.ID, IDPhuongTien = lenhLamViec.IDPhuongTien
                    };
                    tempNhatKy.NgayThucHien = DateTime.Today;
                    if (lenhLamViec.TaiXe.HasValue)
                    {
                        tempNhatKy.TaiXe = lenhLamViec.TaiXe.Value;
                    }
                    if (lenhLamViec.PhuXe.HasValue)
                    {
                        tempNhatKy.PhuXe = lenhLamViec.PhuXe.Value;
                    }

                    nhatKyLamViecList.Add(tempNhatKy);
                }

                foreach (var item in nhatKyLamViecList)
                {
                    rowid++;

                    //ws.Cells["A" + rowid].Value = item.ID;
                    ws.Cells["B" + rowid].Value = item.NgayThucHien.ToOADate();
                    var phuongtien = phuongTienList.FirstOrDefault(d => d.ID == item.IDPhuongTien);
                    if (phuongtien != null)
                    {
                        ws.Cells["C" + rowid].Value = phuongtien.Code + " [" + phuongtien.ID + "]";
                    }



                    ws.Cells["D" + rowid].Value = lenhLamViec.Name + " [" + lenhLamViec.ID + "]";

                    var taixe = BS_CUS_HRM_STAFF_NhanSu.get_CUS_HRM_STAFF_NhanSu(db, PartnerID, item.TaiXe);
                    if (taixe != null)
                    {
                        ws.Cells["E" + rowid].Value = taixe.TenDayDu + " [" + taixe.ID + "]";
                    }

                    var phuxe = BS_CUS_HRM_STAFF_NhanSu.get_CUS_HRM_STAFF_NhanSu(db, PartnerID, item.PhuXe.GetValueOrDefault());
                    if (phuxe != null)
                    {
                        ws.Cells["F" + rowid].Value = phuxe.TenDayDu + " [" + phuxe.ID + "]";
                    }

                    if (!string.IsNullOrEmpty(item.SangBatDau))
                    {
                        ws.Cells["G" + rowid].Value = TimeSpan.Parse(item.SangBatDau).TotalDays;
                    }
                    if (!string.IsNullOrEmpty(item.SangKetThuc))
                    {
                        ws.Cells["H" + rowid].Value = TimeSpan.Parse(item.SangKetThuc).TotalDays;
                    }
                    if (!string.IsNullOrEmpty(item.TruaBatDau))
                    {
                        ws.Cells["I" + rowid].Value = TimeSpan.Parse(item.TruaBatDau).TotalDays;
                    }
                    if (!string.IsNullOrEmpty(item.TruaKetThuc))
                    {
                        ws.Cells["J" + rowid].Value = TimeSpan.Parse(item.TruaKetThuc).TotalDays;
                    }
                    if (!string.IsNullOrEmpty(item.ChieuBatDau))
                    {
                        ws.Cells["K" + rowid].Value = TimeSpan.Parse(item.ChieuBatDau).TotalDays;
                    }
                    if (!string.IsNullOrEmpty(item.ChieuKetThuc))
                    {
                        ws.Cells["L" + rowid].Value = TimeSpan.Parse(item.ChieuKetThuc).TotalDays;
                    }
                    if (!string.IsNullOrEmpty(item.ToiBatDau))
                    {
                        ws.Cells["M" + rowid].Value = TimeSpan.Parse(item.ToiBatDau).TotalDays;
                    }
                    if (!string.IsNullOrEmpty(item.ToiKetThuc))
                    {
                        ws.Cells["N" + rowid].Value = TimeSpan.Parse(item.ToiKetThuc).TotalDays;
                    }

                    ws.Cells["O" + rowid].Formula = string.Format("N{0}-M{0}+L{0}-K{0}+J{0}-I{0}+H{0}-G{0}", rowid);
                    ws.Cells["P" + rowid].Value   = item.GiamSatThiCong;
                    ws.Cells["Q" + rowid].Value   = item.GiamSatThiCongXacNhan ? "ok" : "";
                    ws.Cells["R" + rowid].Value   = item.GiamSatThiCongNhanXet;
                    ws.Cells["S" + rowid].Value   = item.ChiHuyTruong;
                    ws.Cells["T" + rowid].Value   = item.ChiHuyTruongXacNhan ? "ok" : "";
                    ws.Cells["U" + rowid].Value   = item.ChiHuyTruongNhanXet;
                }
            }
        }