Ejemplo n.º 1
0
        public void AutoRun()
        {
            using (FlexCelReport ordersReport = SharedData.CreateReport())
            {
                ordersReport.SetValue("Date", DateTime.Now);
                ordersReport.SetValue("ReportCaption", "Sales by year and country");

                using (DataSet ds = new DataSet())
                {
                    SharedData.Fill(ds, @"SELECT Employees.Country, SUM([Order Details].UnitPrice * [Order Details].Quantity) AS Sales, COUNT([Order Details].Quantity) AS OrderCount, DatePart(yyyy, Orders.OrderDate) AS SaleYear, DatePart(q, Orders.OrderDate) AS Quarter FROM ((Employees INNER JOIN Orders ON Employees.EmployeeID = Orders.EmployeeID) INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID) GROUP BY Employees.Country, DatePart(yyyy, Orders.OrderDate), DatePart(q, Orders.OrderDate)", "Data");
                    ordersReport.AddTable(ds);
                    string DataPath = Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ".."), "..") + Path.DirectorySeparatorChar;

                    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        ordersReport.Run(DataPath + "Master Detail on one Table.template.xls", saveFileDialog1.FileName);

                        if (MessageBox.Show("Do you want to open the generated file?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            Process.Start(saveFileDialog1.FileName);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// tạo báo cáo
        /// </summary>
        /// <param name="path"></param>
        /// <param name="Province"></param>
        /// <returns></returns>
        public ExcelFile CreateReport(String path, string Province)
        {
            XlsFile Result = new XlsFile(true);
            Result.Open(path);

            //tính tổng tiền
            if (Province == null) Province = "0";
            DataTable dt = LayDanhSach(Province);
            String BoQuocPhong = ReportModels.CauHinhTenDonViSuDung(1);
            String QuanKhu = ReportModels.CauHinhTenDonViSuDung(2);
            //set các thông số
            FlexCelReport fr = new FlexCelReport();
            fr = ReportModels.LayThongTinChuKy(fr, "rptNhanSu_DanhSachNghiHuu");
            LoadData(fr, Province);
            if (Province != "0" & Province != "")
            {
                string sProvinceName = Province_Get_Ten(Province);
                fr.SetValue("Province", "ĐANG SINH SỐNG TẠI " + sProvinceName.ToUpper());
            }
            else
                fr.SetValue("Province", "");

            fr.SetValue("BoQuocPhong", BoQuocPhong);
            fr.SetValue("QuanKhu", QuanKhu);
            fr.Run(Result);
            return Result;
        }
        /// <summary>
        /// Tạo file PDF xuất dữ liệu
        /// </summary>
        /// <param name="path"></param>
        /// <param name="MaND"></param>
        /// <param name="sLNS"></param>
        /// <param name="iThang_Quy"></param>
        /// <param name="iID_MaDonVi"></param>
        /// <param name="iID_MaPhongBan"></param>
        /// <returns></returns>
        public ExcelFile CreateReport(String path, String MaND, String sLNS, String iThang_Quy, String iID_MaDonVi, String iID_MaPhongBan)
        {
            XlsFile Result = new XlsFile(true);
            Result.Open(path);
            FlexCelReport fr = new FlexCelReport();

            fr = ReportModels.LayThongTinChuKy(fr, "rptQuyetToan_PhongBan");

            LoadData(fr, MaND, sLNS, iThang_Quy, iID_MaDonVi, iID_MaPhongBan);

            String Nam = ReportModels.LayNamLamViec(MaND);

            if (iThang_Quy == "-1")
            {
                iThang_Quy = "Tất cả các Quý ";
            }

            if (iThang_Quy == "5")
            {
                iThang_Quy = "Bổ Sung ";
            }

            fr.SetValue("NgayThang", ReportModels.Ngay_Thang_Nam_HienTai());
            fr.SetValue("Nam", Nam);
            fr.SetValue("Quy", iThang_Quy);
            fr.Run(Result);

            return Result;
        }
 public ExcelFile CreateReport(String path,String iID_MaChungTu)
 {
     XlsFile Result = new XlsFile(true);
     Result.Open(path);
     String BoQuocPhong = ReportModels.CauHinhTenDonViSuDung(1);
     String CucTaiChinh = ReportModels.CauHinhTenDonViSuDung(2);
     FlexCelReport fr = new FlexCelReport();
     String ngay = ReportModels.Ngay_Thang_Nam_HienTai();
     DateTime dt = new System.DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
     LoadData(fr,iID_MaChungTu);
     fr = ReportModels.LayThongTinChuKy(fr, "rptKTKB_ThongTriTongHop");
     //fr.SetValue("Nam", iNamLamViec);
     fr.SetValue("So", iID_MaChungTu);
     //fr.SetValue("Thang", iThang);
     fr.SetValue("Ngay", String.Format("{0:dd}", dt));
     fr.SetValue("Thangs", String.Format("{0:MM}", dt));
     fr.SetValue("Nams", DateTime.Now.Year);
     fr.SetValue("BoQuocPhong", BoQuocPhong);
     fr.SetValue("CucTaiChinh", CucTaiChinh);
     fr.SetValue("ngay", ngay);
     fr.SetValue("ThangCT", CommonFunction.LayTruong("KTKB_ChungTuChiTiet", "iID_MaChungTu", iID_MaChungTu, "iThangCT"));
     fr.SetValue("NgayCT", CommonFunction.LayTruong("KTKB_ChungTuChiTiet", "iID_MaChungTu", iID_MaChungTu, "iNgayCT"));
     fr.Run(Result);
     return Result;
 }
 /// <summary>
 /// Tạo báo cáo
 /// </summary>
 /// <param name="path">Đường dẫn tới file báo cáo</param>
 /// <param name="iTuNgay">Từ ngày</param>
 /// <param name="iDenNgay">Đến ngày</param>
 /// <param name="iTuThang">Từ tháng</param>
 /// <param name="iDenThang">Đến tháng</param>
 /// <param name="iNam">Năm</param>
 /// <param name="iDVTinh">Đơn vị tính</param>
 /// <returns></returns>
 public ExcelFile CreateReport(String path, String iTuNgay, String iDenNgay, String iTuThang, String iDenThang, String iNam, String iDVTinh, String iSoTo, String iReport, String UserID, String iID_MaTrangThaiDuyet)
 {
     XlsFile Result = new XlsFile(true);
     Result.Open(path);
     FlexCelReport fr = new FlexCelReport();
     //Thêm chữ ký vào báo cáo
     fr = ReportModels.LayThongTinChuKy(fr, "rptKT_TongHop_RutDuToan");
     LoadData(fr, iTuNgay, iDenNgay, iTuThang, iDenThang, iNam, iDVTinh,iSoTo,iReport,UserID,iID_MaTrangThaiDuyet);
     fr.SetValue("cap1", ReportModels.CauHinhTenDonViSuDung(1).ToUpper());
     fr.SetValue("cap2", ReportModels.CauHinhTenDonViSuDung(2).ToUpper());
     fr.SetValue("NgayThang", ReportModels.Ngay_Thang_Nam_HienTai());
     DataTable dt = sLNS(GetLNS(iTuNgay, iDenNgay, iTuThang, iDenThang, iNam,UserID,iID_MaTrangThaiDuyet),iSoTo,iReport);
     if (dt.Rows.Count > 0)
         for (int i = 0; i < dt.Rows.Count; i++)
             fr.SetValue("LNS" + (i + 1), dt.Rows[i]["sMoTa"]);
     if (iDVTinh.Equals("rD"))
         fr.SetValue("DVT", "Đồng");
     else if (iDVTinh.Equals("rND"))
         fr.SetValue("DVT", "Nghìn đồng");
     else if (iDVTinh.Equals("rTrD"))
         fr.SetValue("DVT", "Triệu đồng");
     fr.SetValue("NgayThangTK", "Từ ngày " + iTuNgay + "/ " + iTuThang + " Đến ngày " + iDenNgay + " /" + iDenThang + "/" + iNam);
     if (iReport.Equals("A4Ngang"))
         fr.SetValue("SoTo", "Tờ số: "+iSoTo);
     fr.Run(Result);
     return Result;
 }
        /// <summary>
        /// tạo báo cáo
        /// </summary>
        /// <param name="path"></param>
        /// <param name="NamLamViec"></param>
        /// <param name="ThangLamViec"></param>
        /// <param name="iID_MaDonVi"></param>
        /// <param name="DoTuoi_Tu"> tuoi tu</param>
        /// <param name="DoTuoi_Den">tuoi den</param>
        /// <returns></returns>
        public ExcelFile CreateReport(String path, String DoiTuong, string LoaiIn, string Cap,string Nam, int DoTuoi_Tu, int DoTuoi_Den)
        {
            XlsFile Result = new XlsFile(true);
            Result.Open(path);

            //tính tổng tiền
            if (Nam == null) Nam = "0";
            DataTable dt = PhanTichDuToanNS_52(DoiTuong, LoaiIn,Cap,Nam, DoTuoi_Tu, DoTuoi_Den);
            String BoQuocPhong = ReportModels.CauHinhTenDonViSuDung(1);
            String QuanKhu = ReportModels.CauHinhTenDonViSuDung(2);
            //set các thông số
            FlexCelReport fr = new FlexCelReport();
            if (LoaiIn.Equals("00000000-0000-0000-0000-000000000000"))
            {
                //Toan lục luong
                fr = ReportModels.LayThongTinChuKy(fr, "rptNhanSu_DoTuoi");
            }
            else if (LoaiIn.Equals("00000000-0000-0000-0000-000000000001"))
            {
                //Theo don vi
                fr = ReportModels.LayThongTinChuKy(fr, "rptNhanSu_DoTuoiTheoDonVi");
            }
            else
            {
                //Loai don vi: khoi du an va khoi doanh nghiep
                fr = ReportModels.LayThongTinChuKy(fr, "rptNhanSu_DoTuoi_TheoLoaiDonVi");
            }
            LoadData(fr, DoiTuong, LoaiIn, Cap, Nam, DoTuoi_Tu, DoTuoi_Den);
            if (Nam != "0" & Nam != "")
                fr.SetValue("Nam", "NĂM " + Nam.ToUpper());
            else
                fr.SetValue("Nam", "");

            if (Cap != "0" & Cap != "")
                fr.SetValue("Cap", " - CÁN BỘ CẤP " + Cap.ToUpper());
            else
                fr.SetValue("Cap","");
            string sDoiTuong = "";
            if (DoiTuong == "0" || DoiTuong == "")
            {
                sDoiTuong = "TOÀN QUÂN";
            }
            else
            {
                sDoiTuong = "Đối tượng " + L_DanhMucNgachLuong_Get_Ten(DoiTuong);
            }
            fr.SetValue("DoiTuong", sDoiTuong.ToUpper());
            fr.SetValue("LoaiIn", LoaiIn);
            fr.SetValue("BoQuocPhong", BoQuocPhong);
            fr.SetValue("QuanKhu", QuanKhu);
            fr.SetValue("DoTuoi", "ĐỘ TUỔI TỪ " + DoTuoi_Tu.ToString() + " ĐẾN " + DoTuoi_Den.ToString());
            fr.Run(Result);
            return Result;
        }
        /// <summary>
        /// tạo báo cáo
        /// </summary>
        /// <param name="path"></param>
        /// <param name="NamLamViec"></param>
        /// <param name="ThangLamViec"></param>
        /// <param name="iID_MaDonVi"></param>
        /// <returns></returns>
        public ExcelFile CreateReport(String path, String ChucVu, string LoaiIn, string Cap,string Nam)
        {
            XlsFile Result = new XlsFile(true);
            Result.Open(path);

            //tính tổng tiền
            if (Nam == null) Nam = "0";
            DataTable dt = PhanTichDuToanNS_52(ChucVu, LoaiIn,Cap,Nam);
            String BoQuocPhong = ReportModels.CauHinhTenDonViSuDung(1);
            String QuanKhu = ReportModels.CauHinhTenDonViSuDung(2);
            //set các thông số
            FlexCelReport fr = new FlexCelReport();
            if (LoaiIn.Equals("00000000-0000-0000-0000-000000000000"))
            {
                //Toan lục luong
                fr = ReportModels.LayThongTinChuKy(fr, "rptNhanSu_ChucVu");
            }
            else if (LoaiIn.Equals("00000000-0000-0000-0000-000000000001"))
            {
                //Theo don vi
                fr = ReportModels.LayThongTinChuKy(fr, "rptNhanSu_ChucVuTheoDonVi");
            }
            else
            {
                //Loai don vi: khoi du an va khoi doanh nghiep
                fr = ReportModels.LayThongTinChuKy(fr, "rptNhanSu_ChucVu_TheoLoaiDonVi");
            }
            LoadData(fr, ChucVu, LoaiIn,Cap,Nam);
            if (Nam != "0" & Nam != "")
                fr.SetValue("Nam", "NĂM " + Nam.ToUpper());
            else
                fr.SetValue("Nam", "");

            //if (Cap != "0" & Cap != "")
            //    fr.SetValue("Cap", " - CÁN BỘ CẤP " + Cap.ToUpper());
            //else
            //    fr.SetValue("Cap","");
            string sChucVu = "";
            if (ChucVu == "0" || ChucVu == "")
            {
                sChucVu = "(TOÀN QUÂN)";
            }
            else
            {
                sChucVu = "(Chức vụ " + L_DanhMucChucVu_Get_Ten(ChucVu) + ")";
            }
            fr.SetValue("ChucVu", sChucVu.ToUpper());
            fr.SetValue("BoQuocPhong", BoQuocPhong);
            fr.SetValue("QuanKhu", QuanKhu);
            fr.Run(Result);
            return Result;
        }
 public ExcelFile CreateReport(String path, String TuThang, String DenThang, String NamLuong, String TrangThai)
 {
     XlsFile Result = new XlsFile(true);
     Result.Open(path);
     FlexCelReport fr = new FlexCelReport();
     fr = ReportModels.LayThongTinChuKy(fr, "rptLuong_TongHopThuThueDauVao");
     LoadData(fr, TuThang, DenThang,NamLuong,TrangThai);
     fr.SetValue("tuThang",TuThang);
     fr.SetValue("denThang", DenThang);
     fr.SetValue("NgayThang", ReportModels.Ngay_Thang_Nam_HienTai());
     fr.Run(Result);
     return Result;
 }
 public ExcelFile CreateReport(String path, String Quy, String Nam)
 {
     XlsFile Result = new XlsFile(true);
     Result.Open(path);
     FlexCelReport fr = new FlexCelReport();
     fr = ReportModels.LayThongTinChuKy(fr, "rptQLDA_DuToan_Quy");
     LoadData(fr, Quy, Nam);
     fr.SetValue("quy", Quy);
     fr.SetValue("nam", Nam);
     fr.SetValue("cap2", ReportModels.CauHinhTenDonViSuDung(2).ToUpper());
     fr.SetValue("cap3", ReportModels.CauHinhTenDonViSuDung(3).ToUpper());
     fr.Run(Result);
     return Result;
 }
Ejemplo n.º 10
0
        public FlexCelReport CreateAndConfigureReport()
        {
            var report = new FlexCelReport(true);

            report.SetValue("TaxType", PurchaseOrder.TaxType);
            report.SetValue("PoNumber", PurchaseOrder.PoNumber);
            report.SetValue("InvoiceNumber", PurchaseOrder.InvoiceNumber);
            report.SetValue("Requestor", PurchaseOrder.Requestor);

            var fpo = PurchaseOrder as FreightPurchaseOrder;

            if (fpo != null)
            {
                report.AddTable("States", fpo.States);
                report.SetValue("SubTotal", fpo.LineAmountSubtotal);
                report.SetValue("TaxTotal", fpo.TaxAmountSubtotal);
            }

            var ppo = PurchaseOrder as ProductPurchaseOrder;

            if (ppo == null)
            {
                return(report);
            }

            report.AddTable("States", ppo.States);
            report.SetValue("PickPackTotal", ppo.PickPackCharge);
            report.SetValue("BoxTotal", ppo.BoxCharge);

            return(report);
        }
        public ExcelFile CreateReport(String path, String iID_MaTaiKhoan)
        {
            XlsFile Result = new XlsFile(true);
            Result.Open(path);
            String NgayThangNam = "";
            FlexCelReport fr = new FlexCelReport();
            fr = ReportModels.LayThongTinChuKy(fr, "rptKeToanTongHop_InTaiKhoanChiTiet");
            LoadData(fr, iID_MaTaiKhoan);

            NgayThangNam = ReportModels.Ngay_Thang_Nam_HienTai();

            String QuanKhu = ReportModels.CauHinhTenDonViSuDung(2);
            String BoQuocPhong = ReportModels.CauHinhTenDonViSuDung(1);
            fr.SetValue("NgayThangNam", NgayThangNam);

            fr.SetValue("QuanKhu", QuanKhu);
            fr.SetValue("BoQuocPhong", BoQuocPhong);

            fr.SetValue("Ngay", DateTime.Now.Day);
            fr.SetValue("Thang", DateTime.Now.Month);
            fr.SetValue("Nam", DateTime.Now.Year);
            if (iID_MaTaiKhoan == Guid.Empty.ToString())
            {
                fr.SetValue("TaiKhoan", "");
            }
            else
            {
                fr.SetValue("TaiKhoan", iID_MaTaiKhoan);
            }
            fr.Run(Result);
            return Result;
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Hàm khởi tạo báo cáo
 /// </summary>
 /// <param name="path"></param>
 /// <param name="NamLamViec"></param>
 /// <returns></returns>
 public ExcelFile CreateReport(String path, String NamLamViec)
 {
     string ngay = ReportModels.Ngay_Thang_Nam_HienTai();
     XlsFile Result = new XlsFile(true);
     Result.Open(path);
     FlexCelReport fr = new FlexCelReport();
     fr = ReportModels.LayThongTinChuKy(fr, "rptQLDA_01DT");
     LoadData(fr, NamLamViec);
     fr.SetValue("Nam", NamLamViec);
     fr.SetValue("cuctaichinh", "Cục Tài Chính");
     fr.SetValue("ngay", ngay);
     fr.SetValue("Phong", "Phòng QLNS Các DA");
     fr.Run(Result);
     return Result;
 }
 /// <summary>
 /// Tạo báo cáo
 /// </summary>
 /// <param name="path">Đường dẫn tới file Excel mẫu</param>
 /// <param name="Thang">Tháng lương</param>
 /// <param name="Nam">Năm lương</param>
 /// <param name="TrangThai">Trạng thái duyệt</param>
 /// <param name="iMaDV">Mã đơn vị</param>
 /// <returns></returns>
 public ExcelFile CreateReport(String path, String Thang, String Nam, String TrangThai, String iMaDV)
 {
     XlsFile Result = new XlsFile(true);
     Result.Open(path);
     FlexCelReport fr = new FlexCelReport();
     //Thêm chữ ký vào báo cáo
     fr = ReportModels.LayThongTinChuKy(fr, "rptLuong_TongHopQuanSo");
     LoadData(fr, Thang,Nam,TrangThai,iMaDV);
     fr.SetValue("cap1", ReportModels.CauHinhTenDonViSuDung(1));
     fr.SetValue("cap2", ReportModels.CauHinhTenDonViSuDung(2));
     fr.SetValue("NgayThang", ReportModels.Ngay_Thang_Nam_HienTai());
     fr.SetValue("ThangNam", "Tháng " + Thang + " / " + Nam);
     fr.Run(Result);
     return Result;
 }
Ejemplo n.º 14
0
        public void AutoRun()
        {
            using (FlexCelReport Report = new FlexCelReport(true))
            {
                TMyData[] Data = new TMyData[1010];
                for (int i = 0; i < Data.Length; i++)
                {
                    Data[i] = new TMyData("Customer " + i.ToString());
                }
                Report.AddTable("data", Data);
                Report.SetValue("split", 40);

                string DataPath = Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ".."), "..") + Path.DirectorySeparatorChar;

                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    Report.Run(DataPath + "Overflow Sheets.template.xlsx", saveFileDialog1.FileName);

                    if (MessageBox.Show("Do you want to open the generated file?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Process.Start(saveFileDialog1.FileName);
                    }
                }
            }
        }
Ejemplo n.º 15
0
        public override ReportRunOutcome Run(IDbConnectionFactory connectionFactory, XlsFile excelFile, StringBuilder stringOutput)
        {
            if (excelFile == null)
            {
                throw new ArgumentNullException("excelFile");
            }
            using (var dataSet = GetDataSet(connectionFactory))
            {
                var orgUnit = dataSet.Tables["OrgUnit"];
                var jobAd   = dataSet.Tables["JobAd"];

                if (jobAd.Rows.Count == 0)
                {
                    return(ReportRunOutcome.NoResults); // No point in generating a report when there are no job ads.
                }
                using (var flexCelReport = new FlexCelReport(true))
                {
                    SetProperties(flexCelReport);
                    SetCreditReportProperties(flexCelReport);
                    SetJobAdReportProperties(flexCelReport);

                    flexCelReport.SetValue("ShowGrandTotal", orgUnit.Rows.Count > 1);
                    flexCelReport.AddTable("OrgUnit", orgUnit);
                    flexCelReport.AddTable("JobAd", jobAd);

                    flexCelReport.Run(excelFile);
                }

                return(ReportRunOutcome.FileResult);
            }
        }
Ejemplo n.º 16
0
        public void AutoRun()
        {
            using (FlexCelReport ordersReport = new FlexCelReport(true))
            {
                string DataPath = Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ".."), "..") + Path.DirectorySeparatorChar;
                ordersReport.SetValue("Date", DateTime.Now);

                using (northwndEntities Northwind = new northwndEntities())
                {
                    ordersReport.AddTable("Categories", Northwind.Categories);
                    ordersReport.AddTable("Products", Northwind.Products);

                    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        TransactionOptions transactionOptions = new TransactionOptions();
                        transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.Serializable; //it would be better to sue Snapshot here, but it isn't supported by SQL Sever CE
                        using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
                        {
                            ordersReport.Run(DataPath + "Entity Framework.template.xls", saveFileDialog1.FileName);
                            transactionScope.Complete();
                        }

                        if (MessageBox.Show("Do you want to open the generated file?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            Process.Start(saveFileDialog1.FileName);
                        }
                    }
                }
            }
        }
Ejemplo n.º 17
0
        public void AutoRun()
        {
            using (FlexCelReport ordersReport = SharedData.CreateReport())
            {
                ordersReport.GetInclude += new GetIncludeEventHandler(ordersReport_GetInclude);
                ordersReport.SetValue("Date", DateTime.Now);

                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    Assembly a = Assembly.GetExecutingAssembly();
                    using (Stream InStream = a.GetManifestResourceStream("TemplatesOnTheExe.Templates.Templates On The Exe.template.xls"))
                    {
                        using (FileStream OutStream = new FileStream(saveFileDialog1.FileName, FileMode.Create))
                        {
                            ordersReport.Run(InStream, OutStream);
                        }
                    }

                    if (MessageBox.Show("Do you want to open the generated file?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Process.Start(saveFileDialog1.FileName);
                    }
                }
            }
        }
 public ExcelFile CreateReport(String path, String iNamLamViec, String iID_MaChungTu, String sSoChungTuChiTiet, String iID_MaNamNganSach, String iID_MaNguonNganSach)
 {
     XlsFile Result = new XlsFile(true);
     Result.Open(path);
     FlexCelReport fr = new FlexCelReport();
     String BoQuocPhong = ReportModels.CauHinhTenDonViSuDung(1);
     String CucTaiChinh = ReportModels.CauHinhTenDonViSuDung(2);
     String ngay = ReportModels.Ngay_Thang_Nam_HienTai();
     DateTime dt = new System.DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
     LoadData(fr, iNamLamViec, iID_MaChungTu, sSoChungTuChiTiet, iID_MaNamNganSach, iID_MaNguonNganSach);
     //Lấy thông tin đơn vị nhận
     DataTable dtDVN = dtDanhSachDonVi_Nhan(iNamLamViec, "", iID_MaChungTu);
     String DonVi = "";
     if (dtDVN.Rows.Count > 0)
     {
         DonVi=dtDVN.Rows[0]["sTenDonVi_Nhan"].ToString();
     }
     fr = ReportModels.LayThongTinChuKy(fr, "rptThongTriLoaiNS");
     fr.SetValue("Nam", iNamLamViec);
     fr.SetValue("So", sSoChungTuChiTiet);
     fr.SetValue("Thang", String.Format("{0:MM}", dt));
     fr.SetValue("Ngay", ngay);
     fr.SetValue("Ngay", String.Format("{0:dd}", dt));
     fr.SetValue("Thangs", String.Format("{0:MM}", dt));
     fr.SetValue("Nams", DateTime.Now.Year);
     fr.SetValue("ThangCT", CommonFunction.LayTruong("KTKB_ChungTuChiTiet", "sSoChungTuChiTiet", sSoChungTuChiTiet, "iThangCT"));
     fr.SetValue("DonVi", DonVi);
     //fr.SetValue("LoaiThangQuy", TenLoaiThangQuy);
     fr.SetValue("CucTaiChinh", CucTaiChinh);
     fr.SetValue("BoQuocPhong", BoQuocPhong);
     fr.SetValue("Tien", CommonFunction.TienRaChu(tong));
     fr.Run(Result);
     return Result;
 }
Ejemplo n.º 19
0
        public override ReportRunOutcome Run(IDbConnectionFactory connectionFactory, XlsFile excelFile, StringBuilder stringOutput)
        {
            using (var dataSet = GetDataSet(connectionFactory))
            {
                var orgUnit      = dataSet.Tables["OrgUnit"];
                var user         = dataSet.Tables["User"];
                var activeUser   = new DataView(user, ActiveUserCondition, SortUsersBy, DataViewRowState.CurrentRows);
                var inactiveUser = new DataView(user, "NOT " + ActiveUserCondition, SortUsersBy, DataViewRowState.CurrentRows);

                var haveActivity = (user.Select(HaveActivityCondition).Length > 0);

                using (var flexCelReport = new FlexCelReport(true))
                {
                    SetProperties(flexCelReport);
                    SetCreditReportProperties(flexCelReport);

                    flexCelReport.SetValue("ShowGrandTotal", orgUnit.Rows.Count > 1);
                    flexCelReport.AddTable("OrgUnit", orgUnit);
                    flexCelReport.AddTable("ActiveUser", activeUser);
                    flexCelReport.AddTable("InactiveUser", inactiveUser);

                    flexCelReport.Run(excelFile);
                }

                return(haveActivity ? ReportRunOutcome.FileResult : ReportRunOutcome.NoResults);
            }
        }
 /// <summary>
 /// Tạo báo cáo
 /// </summary>
 /// <param name="path"></param>
 /// <param name="NamLamViec"></param>
 /// <param name="iID_MaDonVi"></param>
 /// <returns></returns>
 public ExcelFile CreateReport(String path, String iID_MaChungTu, Dictionary<String, String> arrGiaTriTimKiem, String iLoai)
 {
     XlsFile Result = new XlsFile(true);
     Result.Open(path);
     FlexCelReport fr = new FlexCelReport();
     fr = ReportModels.LayThongTinChuKy(fr, "rptTCDN_BaoCaoInKiem");
     LoadData(fr, iID_MaChungTu, arrGiaTriTimKiem,iLoai);
     String Nam = "";
     String TenBieu1 = "", TenBieu2 = "";
     if (iLoai == "1")
     {
         TenBieu1 = "Biểu số 1";
         TenBieu2 = "CHỈ TIÊU HOẠT ĐỘNG SẢN XUẤT KINH DOANH";
     }
     else if (iLoai == "2")
     {
         TenBieu1 = "Biểu số 2";
         TenBieu2 = "CHỈ TIÊU THU CHI NGÂN SÁCH VÀ THU NHẬP";
     }
     else if (iLoai == "3")
     {
         TenBieu1 = "Biểu số 3";
         TenBieu2 = "CHỈ TIÊU TÀI CHÍNH";
     }
     else if (iLoai == "4")
     {
         TenBieu1 = "Biểu số 4";
         TenBieu2 = "CHỈ TIÊU ĐÁNH GIÁ HIỆU QUẢ";
     }
     String ThongTin = "";
     DataTable dtChungTu = TCDN_ChungTuModels.GetChungTu(iID_MaChungTu);
     String sTenDoanhNghiep = Convert.ToString(CommonFunction.LayTruong("TCDN_DoanhNghiep", "iID_MaDoanhNghiep",
                                               dtChungTu.Rows[0]["iID_MaDoanhNghiep"].ToString(),
                                               "sTenDoanhNghiep"));
     String iQuy = dtChungTu.Rows[0]["iQuy"].ToString();
     ThongTin = " Doanh nghiệp: " + sTenDoanhNghiep + "          Quý:" + iQuy;
     dtChungTu.Dispose();
     fr.SetValue("BoQuocPhong", ReportModels.CauHinhTenDonViSuDung(1));
     fr.SetValue("QuanKhu", ReportModels.CauHinhTenDonViSuDung(2));
     fr.SetValue("NgayThang", ReportModels.Ngay_Thang_Nam_HienTai());
     fr.SetValue("Nam", Nam);
     fr.SetValue("ThongTin",ThongTin);
     fr.SetValue("TenBieu1", TenBieu1);
     fr.SetValue("TenBieu2", TenBieu2);
     fr.Run(Result);
     return Result;
 }
        /// <summary>
        /// tạo báo cáo
        /// </summary>
        /// <param name="path"></param>
        /// <param name="NamLamViec"></param>
        /// <param name="ThangLamViec"></param>
        /// <param name="iID_MaDonVi"></param>
        /// <returns></returns>
        public ExcelFile CreateReport(String path, String DoiTuong, string LoaiIn, string Cap, string Nam, string iDaTotNghiep)
        {
            XlsFile Result = new XlsFile(true);
            Result.Open(path);

            //tính tổng tiền
            if (Nam == null) Nam = "0";
            DataTable dt = PhanTichDuToanNS_52(DoiTuong, LoaiIn, Cap, Nam, iDaTotNghiep);
            String BoQuocPhong = ReportModels.CauHinhTenDonViSuDung(1);
            String QuanKhu = ReportModels.CauHinhTenDonViSuDung(2);
            //set các thông số
            FlexCelReport fr = new FlexCelReport();
            if (LoaiIn.Equals("00000000-0000-0000-0000-000000000000"))
            {
                //Toan lục luong
                fr = ReportModels.LayThongTinChuKy(fr, "rptNhanSu_TrinhDo");
            }
            else if (LoaiIn.Equals("00000000-0000-0000-0000-000000000001"))
            {
                //Theo don vi
                fr = ReportModels.LayThongTinChuKy(fr, "rptNhanSu_TrinhDoTheoDonVi");
            }
            else
            {
                //Loai don vi: khoi du an va khoi doanh nghiep
                fr = ReportModels.LayThongTinChuKy(fr, "rptNhanSu_TrinhDo_TheoLoaiDonVi");
            }
            LoadData(fr, DoiTuong, LoaiIn, Cap, Nam, iDaTotNghiep);
            if (Nam != "0" & Nam != "")
                fr.SetValue("Nam", "NĂM " + Nam.ToUpper());
            else
                fr.SetValue("Nam", "");

            if (Cap != "0" & Cap != "")
                fr.SetValue("Cap", " - CÁN BỘ CẤP " + Cap.ToUpper());
            else
                fr.SetValue("Cap","");

            string sDoiTuong = "Trình độ " + GetTrinhDo(DoiTuong);

            fr.SetValue("DoiTuong", sDoiTuong.ToUpper());
            fr.SetValue("LoaiIn", LoaiIn);
            fr.SetValue("BoQuocPhong", BoQuocPhong);
            fr.SetValue("QuanKhu", QuanKhu);
            fr.Run(Result);
            return Result;
        }
Ejemplo n.º 22
0
 /// <summary>
 /// hàm khởi tạo báo cáo
 /// </summary>
 /// <param name="path"></param>
 /// <param name="NamLamViec"></param>
 /// <param name="sLNS"></param>
 /// <returns></returns>
 public ExcelFile CreateReport(String path, String NamLamViec,String iID_MaTrangThaiDuyet)
 {
     String MaND = User.Identity.Name;
     XlsFile Result = new XlsFile(true);
     Result.Open(path);
     String NgayThang = ReportModels.Ngay_Thang_Nam_HienTai();
     FlexCelReport fr = new FlexCelReport();
     fr = ReportModels.LayThongTinChuKy(fr, "rptDT_CNSNamLNS2");
     LoadData(fr, NamLamViec, MaND, iID_MaTrangThaiDuyet);
         fr.SetValue("Nam", NamLamViec);
         fr.SetValue("Ngay", NgayThang);
         fr.SetValue("PhuLuc", "Phụ Lục Số : 4d2-C");
        String  TenNganSach = "Ngân sách nhà nước";
         fr.SetValue("TenNganSach", TenNganSach);
         fr.Run(Result);
         return Result;
 }
        public ExcelFile CreateReport(String path, String NamLamViec, String TuThang, String DenThang, String TrangThai)
        {
            XlsFile Result = new XlsFile(true);
            Result.Open(path);
            String NgayThangNam = "";
            FlexCelReport fr = new FlexCelReport();
            fr = ReportModels.LayThongTinChuKy(fr, "rptKeToan_SoCaiTaiKhoan");
            LoadData(fr, NamLamViec, TuThang, DenThang, TrangThai);

            NgayThangNam = ReportModels.Ngay_Thang_Nam_HienTai();
            String ThangNam = "Từ tháng " + TuThang + " đến tháng " + DenThang + " Năm " + NamLamViec;
            if (TuThang == DenThang)
                ThangNam = "Tháng " + TuThang + " Năm " + NamLamViec;

            String QuanKhu = ReportModels.CauHinhTenDonViSuDung(2);
            String BoQuocPhong = ReportModels.CauHinhTenDonViSuDung(1);
            fr.SetValue("NgayThangNam", NgayThangNam);
            fr.SetValue("ThangNam", ThangNam);
            fr.SetValue("QuanKhu", QuanKhu);
            fr.SetValue("BoQuocPhong", BoQuocPhong);
            fr.SetValue("Ngay", DateTime.Now.Day);
            fr.SetValue("Thang", DateTime.Now.Month);
            fr.SetValue("Nam", DateTime.Now.Year);

            fr.Run(Result);
            return Result;
        }
        public ExcelFile CreateReport(String path, String NamLamViec, String ThangLamViec, String TrangThai)
        {
            XlsFile Result = new XlsFile(true);
            Result.Open(path);
            String NgayThangNam = "";
            FlexCelReport fr = new FlexCelReport();
            fr = ReportModels.LayThongTinChuKy(fr, "rptKeToan_BangCanDoiSoDu");
            LoadData(fr, NamLamViec, ThangLamViec, TrangThai);

            NgayThangNam = ReportModels.Ngay_Thang_Nam_HienTai();
            String ThangNam = "Tháng "+ThangLamViec+" năm " + NamLamViec;

            String NamTruoc = "Số năm " + (Convert.ToInt16(NamLamViec) - 1) + " chuyển sang";
            String NamNay = "Số trong năm " + NamLamViec;
            String NamSau = "Số trong năm " + (Convert.ToInt16(NamLamViec) + 1);
            String QuanKhu = ReportModels.CauHinhTenDonViSuDung(2);
            String BoQuocPhong = ReportModels.CauHinhTenDonViSuDung(1);
            fr.SetValue("NgayThangNam", NgayThangNam);
            fr.SetValue("ThangNam", ThangNam);
            fr.SetValue("QuanKhu", QuanKhu);
            fr.SetValue("BoQuocPhong", BoQuocPhong);
            fr.SetValue("NamTruoc", NamTruoc);
            fr.SetValue("NamNay", NamNay);
            fr.SetValue("NamSau", NamSau);
            fr.Run(Result);
            return Result;
        }
 /// <summary>
 /// Khởi tạo báo cáo
 /// </summary>
 /// <param name="path"> đường dẫn</param>
 /// <param name="NamLamViec">Năm làm việc</param>
 /// <param name="iID_MaDonVi">Mã đơn vị</param>
 /// <param name="DotPhanBo">Mã đợt phân bổ</param>
 /// <returns></returns>
 public ExcelFile CreateReport(String path, String iID_MaDonVi, String DotPhanBo, String iID_MaTrangThaiDuyet)
 {
     String MaND = User.Identity.Name;
     XlsFile Result = new XlsFile(true);
     Result.Open(path);
     String TenDV = "";
     DataTable dtDonVi = PhanBo_ReportModels.DanhSachDonVi2(MaND,iID_MaTrangThaiDuyet, DotPhanBo);
     for (int i = 0; i < dtDonVi.Rows.Count;i++ )
     {
         if (iID_MaDonVi == dtDonVi.Rows[i]["iID_MaDonVi"].ToString())
         {
             TenDV = dtDonVi.Rows[i]["TenHT"].ToString();
             break;
         }
     }
     String NgayThangNam = ReportModels.Ngay_Thang_Nam_HienTai();
     String BoQuocPhong = ReportModels.CauHinhTenDonViSuDung(1);
     String QuanKhu = ReportModels.CauHinhTenDonViSuDung(2);
     String Dot = ReportModels.Get_STTDotPhanBo(MaND, iID_MaTrangThaiDuyet, DotPhanBo).ToString();
     //set các thông số
     FlexCelReport fr = new FlexCelReport();
     fr = ReportModels.LayThongTinChuKy(fr, "rptThongBaoBoSungNganSach");
     LoadData(fr, MaND, iID_MaTrangThaiDuyet, iID_MaDonVi, DotPhanBo);
     fr.SetValue("Nam", ReportModels.LayNamLamViec(MaND));
     fr.SetValue("TenDv", TenDV);
     fr.SetValue("NgayThangNam", NgayThangNam);
     fr.SetValue("BoQuocPhong", BoQuocPhong);
     fr.SetValue("QuanKhu", QuanKhu);
     fr.SetValue("Dot", Dot);
     fr.SetValue("Tien", CommonFunction.TienRaChu(Tong));
     fr.Run(Result);
     return Result;
 }
        /// <summary>
        /// Tạo file PDF xuất dữ liệu của quyết toán từng đơn vị
        /// </summary>
        /// <param name="path"></param>
        /// <param name="MaND">Mã người dùng</param>
        /// <param name="sLNS">Loại ngân sách</param>
        /// <param name="iThang_Quy">Quý</param>
        /// <param name="iID_MaDonVi">Mã đơn vị</param>
        /// <param name="iID_MaNamNganSach">Năm ngân sách</param>
        /// <param name="MaPhongBan">Mã phòng ban</param>
        /// <returns></returns>
        public ExcelFile CreateReport(String path, String MaND, String sLNS, String iThang_Quy, String iID_MaDonVi, String iID_MaNamNganSach, String MaPhongBan)
        {
            XlsFile Result = new XlsFile(true);
            Result.Open(path);
            FlexCelReport fr = new FlexCelReport();
            fr = ReportModels.LayThongTinChuKy(fr, "rptQuyetToan_DonVi_LNS");

            LoadData(fr, MaND, sLNS, iThang_Quy, iID_MaDonVi, iID_MaNamNganSach, MaPhongBan);
            String Nam = ReportModels.LayNamLamViec(MaND);

            String NamNganSach = "";
            if (iID_MaNamNganSach == "1")
                NamNganSach = "QUYẾT TOÁN NĂM TRƯỚC";
            else if (iID_MaNamNganSach == "2")
                NamNganSach = "QUYẾT TOÁN NĂM NAY";
            else
            {
                NamNganSach = "TỔNG HỢP";
            }

            String sTenDonVi = DonViModels.Get_TenDonVi(iID_MaDonVi);
            fr.SetValue("BoQuocPhong", ReportModels.CauHinhTenDonViSuDung(1));
            fr.SetValue("QuanKhu", ReportModels.CauHinhTenDonViSuDung(2));
            fr.SetValue("NgayThang", ReportModels.Ngay_Thang_Nam_HienTai());
            fr.SetValue("Nam", Nam);
            fr.SetValue("Quy", iThang_Quy);
            fr.SetValue("NamNganSach", NamNganSach);
            fr.SetValue("sTenDonVi", sTenDonVi);
            fr.Run(Result);

            return Result;
        }
 public ExcelFile CreateReport(String path, String NamBangLuong, String ThangBangLuong,String iID_MaTrangThaiDuyet, String iID_MaDonVi,String TongHop,String KhoGiay)
 {
     XlsFile Result = new XlsFile(true);
     Result.Open(path);
     String Ngay = "";
     int day = DateTime.Now.Day;
     int month = DateTime.Now.Month;
     int year = DateTime.Now.Year;
     Ngay = "Ngày  " + day + " Tháng  " + month + "  Năm  " + year;
        FlexCelReport fr = new FlexCelReport();
        fr = ReportModels.LayThongTinChuKy(fr, "rptLuong_TongHopLuongPhuCap");
         LoadData(fr, NamBangLuong, ThangBangLuong, iID_MaTrangThaiDuyet, iID_MaDonVi, TongHop,KhoGiay);
         fr.SetValue("Nam", NamBangLuong);
         fr.SetValue("Thang", ThangBangLuong);
         fr.SetValue("Ngay", Ngay);
         fr.Run(Result);
         return Result;
 }
Ejemplo n.º 28
0
        private void Export(DataSet data)
        {
            using (FlexCelReport Report = new FlexCelReport(true))
            {
                Report.AddTable(data);
                Report.SetValue("FeedName", ((FeedData)cbFeeds.SelectedValue).Name);
                Report.SetValue("FeedUrl", ((FeedData)cbFeeds.SelectedValue).Url);
                Report.SetValue("ShowCount", cbShowFeedCount.Checked);

                using (FileStream fs = new FileStream(Path.Combine(Path.Combine(DataPath, "logos"), ((FeedData)cbFeeds.SelectedValue).Logo), FileMode.Open))
                {
                    byte[] b = new byte[fs.Length];
                    fs.Read(b, 0, b.Length);
                    Report.SetValue("Logo", b);
                }
                Report.Run(DataPath + "Meta Templates.template.xls", saveFileDialog1.FileName);
            }
        }
 public ExcelFile CreateReport(String path, String iID_MaChungTu, String iID_MaDonVi, String LoaiTK, String iThang, String iNam, String iID_MaThongTri)
 {
     String BoQuocPhong = ReportModels.CauHinhTenDonViSuDung(1);
     String CucTaiChinh = ReportModels.CauHinhTenDonViSuDung(2);
     string ngay = ReportModels.Ngay_Thang_Nam_HienTai();
     Thang = iThang + "/" + iNam;
     XlsFile Result = new XlsFile(true);
     Result.Open(path);
     FlexCelReport fr = new FlexCelReport();
     fr = ReportModels.LayThongTinChuKy(fr, "rptKTTongHop_ThongTri_PhongBan");
     LoadData(fr, iID_MaChungTu, iID_MaDonVi, LoaiTK);
     fr.SetValue("TenDV", DonViModels.Get_TenDonVi(iID_MaDonVi));
     fr.SetValue("ThangNam", Thang);
     fr.SetValue("BoQuocPhong", BoQuocPhong);
     fr.SetValue("CucTaiChinh", CucTaiChinh);
     fr.SetValue("NgayGS", ngayGS);
     fr.SetValue("Ngay", ngay);
     //lay ten thong tri
     if (!String.IsNullOrEmpty(iID_MaThongTri))
     {
         DataTable dtLoaiThongTri;
         String SQL = "SELECT sLoaiThongTri,sTenLoaiNS FROM KT_LoaiThongTri WHERE iID_MaThongTri=@iID_MaThongTri";
         SqlCommand cmd = new SqlCommand(SQL);
         cmd.Parameters.AddWithValue("@iID_MaThongTri", iID_MaThongTri);
         dtLoaiThongTri = Connection.GetDataTable(cmd);
         cmd.Dispose();
         if (dtLoaiThongTri != null && dtLoaiThongTri.Rows.Count > 0)
         {
             LoaiTT = Convert.ToString(dtLoaiThongTri.Rows[0]["sLoaiThongTri"]);
             LoaiNS = Convert.ToString(dtLoaiThongTri.Rows[0]["sTenLoaiNS"]);
             dtLoaiThongTri.Dispose();
         }
     }
     else
     {
         LoaiTT = "Thông tri Cấp";
         LoaiNS = "Kinh phí...";
     }
     fr.SetValue("LoaiTT", LoaiTT.ToUpper());
     fr.SetValue("LoaiNS", LoaiNS.ToUpper());
     fr.SetValue("Tien", CommonFunction.TienRaChu(tong));
     fr.Run(Result);
     return Result;
 }
Ejemplo n.º 30
0
        private FlexCelReport CreateReport()
        {
            FlexCelReport Result = new FlexCelReport(true);

            Result.SetValue("test", 3);
            Result.SetValue("tagval", 1);
            Result.SetValue("refval", "l");

            //Here we will add a dummy table with some fantasy values
            DataTable dt = new DataTable("testdb");

            dt.Columns.Add("key", typeof(int));
            dt.Columns.Add("data", typeof(string));
            dt.Rows.Add(new object[] { 5, "cat" });
            dt.Rows.Add(new object[] { 6, "dog" });
            Result.AddTable("testdb", dt, TDisposeMode.DisposeAfterRun);

            return(Result);
        }
Ejemplo n.º 31
0
        public void AutoRun()
        {
            using (FlexCelReport ordersReport = SharedData.CreateReport())
            {
                ordersReport.SetValue("Date", DateTime.Now);
                ordersReport.SetValue("ReportCaption", "Suppliers");
                string DataPath = Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ".."), "..") + Path.DirectorySeparatorChar;

                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    ordersReport.Run(DataPath + "Regular Expressions.template.xls", saveFileDialog1.FileName);

                    if (MessageBox.Show("Do you want to open the generated file?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Process.Start(saveFileDialog1.FileName);
                    }
                }
            }
        }
Ejemplo n.º 32
0
 /// <summary>
 /// Khởi tạo báo cáo
 /// </summary>
 /// <param name="path"></param>
 /// <param name="NgayGui"></param>
 /// <param name="iID_MaDonVi"></param>
 /// <returns></returns>
 public ExcelFile CreateReport(String path, String NgayGui, String iID_MaDonVi)
 {
     XlsFile Result = new XlsFile(true);
     Result.Open(path);
     String tendv = "";
     DataTable teN = tendonvi(iID_MaDonVi);
     if (teN.Rows.Count > 0)
     {
         tendv = teN.Rows[0][0].ToString();
     }
     FlexCelReport fr = new FlexCelReport();
     fr = ReportModels.LayThongTinChuKy(fr, "rptDuToan_InBia");
     fr.SetValue("cap1", ReportModels.CauHinhTenDonViSuDung(1).ToUpper());
     fr.SetValue("nam", ("năm "+DateTime.Now.Year).ToUpper());
     fr.SetValue("Donvi", tendv.ToUpper());
     fr.SetValue("NgayGui", NgayGui);
     fr.Run(Result);
     return Result;
 }
 public ExcelFile CreateReport(String path, String iNamLamViec, String iThang, String iTrangThai)
 {
     String BoQuocPhong = ReportModels.CauHinhTenDonViSuDung(1);
     String CucTaiChinh = ReportModels.CauHinhTenDonViSuDung(2);
     String Ngay = ReportModels.Ngay_Thang_Nam_HienTai();
     XlsFile Result = new XlsFile(true);
     Result.Open(path);
     FlexCelReport fr = new FlexCelReport();
     fr = ReportModels.LayThongTinChuKy(fr, "rptKT_ChiTiet_TaiKhoanTheoDonVi1");
     DateTime dt = new System.DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
     LoadData(fr, iNamLamViec, iThang, iTrangThai);
     fr.SetValue("Nam", NguoiDungCauHinhModels.iNamLamViec.ToString());
     fr.SetValue("Thang", iThang);
     fr.SetValue("BoQuocPhong", BoQuocPhong);
     fr.SetValue("CucTaiChinh", CucTaiChinh);
     fr.SetValue("Ngay", Ngay);
     fr.Run(Result);
     return Result;
 }
        /// <summary>
        /// Khởi tạo báo cáo
        /// </summary>
        /// <param name="path">Đường dẫn</param>
        /// <param name="NamLamViec">Năm làm việc</param>
        /// <param name="DotPhanBo">Mã đợt phân bổ</param>
        /// <param name="LuyKe">Lũy kế</param>
        /// <param name="opDonViNganh"></param>
        /// <returns></returns>
        public ExcelFile CreateReport(String path, String DotPhanBo, String LuyKe, String opDonViNganh, String iID_MaTrangThaiDuyet)
        {
            String MaND = User.Identity.Name;
            XlsFile Result = new XlsFile(true);

            Result.Open(path);
            String TenDot = "";
            String TenTT = "";
            if (LuyKe == "on")
            {
                TenTT = "Đến đợt: " + ReportModels.Get_STTDotPhanBo(MaND, iID_MaTrangThaiDuyet, DotPhanBo);
            }
            else
            {
                TenTT = "Đợt " + ReportModels.Get_STTDotPhanBo(MaND, iID_MaTrangThaiDuyet, DotPhanBo);
            }
            if (!String.IsNullOrEmpty(DotPhanBo))
            {
                TenDot = Convert.ToString(CommonFunction.LayTruong("PB_DotPhanBo", "iID_MaDotPhanBo", DotPhanBo, "dNgayDotPhanBo"));

                if (!String.IsNullOrEmpty(TenDot))
                {
                    DateTime dt = Convert.ToDateTime(TenDot);
                    TenDot = Convert.ToString(CommonFunction.LayXauNgay(dt));

                    TenDot = " Tháng " + TenDot.Substring(3, 2) + " năm " + TenDot.Substring(6, 4);
                }
            }
            String NgayThangNam = ReportModels.Ngay_Thang_Nam_HienTai();
            String QuanKhu = ReportModels.CauHinhTenDonViSuDung(2);
            String BoQuocPhong = ReportModels.CauHinhTenDonViSuDung(1);
            FlexCelReport fr = new FlexCelReport();
            fr = ReportModels.LayThongTinChuKy(fr, "rptPhanBo_16D_TheoNganh");
            LoadData(fr, MaND, iID_MaTrangThaiDuyet, DotPhanBo, LuyKe, opDonViNganh);
            fr.SetValue("Nam", ReportModels.LayNamLamViec(MaND));
            fr.SetValue("TenDot", TenDot);
            fr.SetValue("TenTT", TenTT);
            fr.SetValue("QuanKhu", QuanKhu);
            fr.SetValue("BoQuocPhong", BoQuocPhong);
            fr.SetValue("NgayThangNam", NgayThangNam);
            fr.Run(Result);
            return Result;
        }
 /// <summary>
 /// Tạo báo cáo
 /// </summary>
 /// <param name="path"></param>
 /// <param name="NamLamViec"></param>
 /// <returns></returns>
 public ExcelFile CreateReport(String path, String MaND, String iID_MaTrangThaiDuyet)
 {
     DataTable dt = NguoiDungCauHinhModels.LayCauHinh(MaND);
     String iNamLamViec = DateTime.Now.Year.ToString();
     if (dt.Rows.Count > 0)
     {
         iNamLamViec = Convert.ToString(dt.Rows[0]["iNamLamViec"]);
     }
     dt.Dispose();
     XlsFile Result = new XlsFile(true);
     Result.Open(path);
     FlexCelReport fr = new FlexCelReport();
     fr = ReportModels.LayThongTinChuKy(fr, "rptDuToanChiNganSachQuocPhongNamTuyVien");
     LoadData(fr, MaND, iID_MaTrangThaiDuyet);
     fr.SetValue("Nam", iNamLamViec);
     fr.SetValue("cap1", ReportModels.CauHinhTenDonViSuDung(1));
     fr.SetValue("NgayThang", ReportModels.Ngay_Thang_Nam_HienTai());
     fr.Run(Result);
     return Result;
 }
        /// <summary>
        /// hàm khởi tạo báo cáo
        /// </summary>
        /// <param name="path"></param>
        /// <param name="NamLamViec"></param>
        /// <returns></returns>
        public ExcelFile CreateReport(String path, String MaND, String iID_MaPhongBan)
        {
            DataTable dtCauHinh = NguoiDungCauHinhModels.LayCauHinh(MaND);
            String iNamLamViec = Convert.ToString(dtCauHinh.Rows[0]["iNamLamViec"]);

            String sTenDonVi = "B - "+iID_MaPhongBan;
            if (iID_MaPhongBan == "-1" || iID_MaPhongBan == "")
                sTenDonVi = ReportModels.CauHinhTenDonViSuDung(2);
            XlsFile Result = new XlsFile(true);
            Result.Open(path);
            FlexCelReport fr = new FlexCelReport();
            LoadData(fr, MaND, iID_MaPhongBan);
            fr = ReportModels.LayThongTinChuKy(fr, "rptDuToan_TongHop_2");
            fr.SetValue("Nam", iNamLamViec);
            fr.SetValue("Cap2", sTenDonVi);
            fr.SetValue("Cap1", ReportModels.CauHinhTenDonViSuDung(1));
            fr.SetValue("Ngay", ReportModels.Ngay_Thang_Nam_HienTai());
            fr.Run(Result);
            return Result;
        }
 public ExcelFile CreateReport(String path, String MaBL)
 {
     XlsFile Result = new XlsFile(true);
     Result.Open(path);
     using (FlexCelReport fr = new FlexCelReport())
     {
         LoadData(fr, MaBL);
         fr.SetValue("NgayThang", ReportModels.Ngay_Thang_Nam_HienTai());
         fr.Run(Result);
         return Result;
     }
 }
        /// <summary>
        /// tạo báo cáo
        /// </summary>
        /// <param name="path"></param>
        /// <param name="NgoaiTe"></param>
        /// <param name="Quy"></param>
        /// <param name="Nam"></param>
        /// <returns></returns>
        public ExcelFile CreateReport(String path, String sDeAn, String NgoaiTe, String Quy, String iNamLamViec, String iCapTongHop)
        {
            XlsFile Result = new XlsFile(true);
            Result.Open(path);

            String BoQuocPhong = ReportModels.CauHinhTenDonViSuDung(1);
            String QuanKhu = ReportModels.CauHinhTenDonViSuDung(2);
            DataTable dtDVT = QLDA_ReportModel.getdtTien();
            String DVT = " triệu đồng";
            for (int i = 1; i < dtDVT.Rows.Count; i++)
            {
                if (NgoaiTe == dtDVT.Rows[i]["iID_MaNgoaiTe"].ToString())
                {
                    DVT = dtDVT.Rows[i]["sTen"].ToString();
                }

            }
            dtDVT.Dispose();
            //set các thông số
            FlexCelReport fr = new FlexCelReport();
            //Toan lục luong
            fr = ReportModels.LayThongTinChuKy(fr, "rptKHV_02DT_DTQuy");

            LoadData(fr, sDeAn, NgoaiTe, Quy, iNamLamViec);
            fr.SetValue("Nam", iNamLamViec);
            fr.SetValue("Quy", Quy);
            fr.SetValue("Ngay", "Ngày " + DateTime.Now.Day.ToString() + " tháng " + DateTime.Now.Month.ToString() + " năm " + DateTime.Now.Year.ToString());
            fr.SetValue("DonVi", DVT);
            fr.SetValue("BoQuocPhong", BoQuocPhong);
            fr.SetValue("QuanKhu", QuanKhu);
            fr.Run(Result);
            return Result;
        }
 /// <summary>
 /// Tạo báo cáo
 /// </summary>
 /// <param name="path"></param>
 /// <param name="NamLamViec"></param>
 /// <param name="sNG"></param>
 /// <returns></returns>
 public ExcelFile CreateReport(String path, String iID_MaTrangThaiDuyet, String sNG)
 {
     String MaND = User.Identity.Name;
     XlsFile Result = new XlsFile(true);
     DataTable dt = NguoiDungCauHinhModels.LayCauHinh(MaND);
     String DK = "", iNamLamViec = DateTime.Now.Year.ToString(), iID_MaNamNganSach = "1", iID_MaNguonNganSach = "1";
     if (dt.Rows.Count > 0)
     {
         iNamLamViec = Convert.ToString(dt.Rows[0]["iNamLamViec"]);
         iID_MaNamNganSach = Convert.ToString(dt.Rows[0]["iID_MaNamNganSach"]);
         iID_MaNguonNganSach = Convert.ToString(dt.Rows[0]["iID_MaNguonNganSach"]);
     }
     Result.Open(path);
     FlexCelReport fr = new FlexCelReport();
     fr = ReportModels.LayThongTinChuKy(fr, "rptDuToanChiNganSachQuocPhongNganSachBaoDamToanQuan");
     LoadData(fr, iID_MaTrangThaiDuyet, sNG,MaND);
     fr.SetValue("Nam", iNamLamViec);
     fr.SetValue("cap1", ReportModels.CauHinhTenDonViSuDung(1));
     fr.SetValue("NgayThang", ReportModels.Ngay_Thang_Nam_HienTai());
     fr.Run(Result);
     return Result;
 }
 /// <summary>
 /// hàm khởi tạo báo cáo
 /// </summary>
 /// <param name="path"></param>
 /// <param name="NamLamViec"></param>
 /// <param name="sLNS"></param>
 /// <returns></returns>
 public ExcelFile CreateReport(String path, String sLNS,String MaND,String iID_MaTrangThaiDuyet)
 {
     DataTable dt = NguoiDungCauHinhModels.LayCauHinh(MaND);
     String  iNamLamViec = DateTime.Now.Year.ToString(), iID_MaNamNganSach = "1", iID_MaNguonNganSach = "1";
     if (dt.Rows.Count > 0)
     {
         iNamLamViec = Convert.ToString(dt.Rows[0]["iNamLamViec"]);
         iID_MaNamNganSach = Convert.ToString(dt.Rows[0]["iID_MaNamNganSach"]);
         iID_MaNguonNganSach = Convert.ToString(dt.Rows[0]["iID_MaNguonNganSach"]);
     }
     XlsFile Result = new XlsFile(true);
     Result.Open(path);
          FlexCelReport fr = new FlexCelReport();
          fr = ReportModels.LayThongTinChuKy(fr, "rptDuToanNganSachNhaNuocController");
          LoadData(fr, sLNS, MaND, iID_MaTrangThaiDuyet);
         fr.SetValue("PhuLuc", "Phụ Lục 5-C");
         fr.SetValue("Cap1", ReportModels.CauHinhTenDonViSuDung(1));
         fr.SetValue("TenTieuDe", "DỰ TOÁN NGÂN SÁCH NHÀ NƯỚC GIAO NĂM");
         fr.SetValue("Ngay", ReportModels.Ngay_Thang_Nam_HienTai());
         fr.SetValue("Nam", iNamLamViec);
         fr.Run(Result);
         return Result;
 }
Ejemplo n.º 41
0
    private ExcelFile CreateReport()
    {
        XlsFile Result = new XlsFile(true);

        Result.Open(MapPath("~/App_Data/template.xls"));
        using (FlexCelReport fr = new FlexCelReport())
        {
            LoadData(fr);

            fr.SetValue("ReportCaption", "Hello from FlexCel!");
            fr.Run(Result);
            return(Result);
        }
    }
Ejemplo n.º 42
0
 protected void SetProperties(FlexCelReport flexCelReport)
 {
     flexCelReport.SetValue("ReportedOrgName", _organisation.FullName);
     flexCelReport.SetValue("FromDate", _dateRange.Start.Value.ToString(DateFormat));
     flexCelReport.SetValue("ToDate", _dateRange.End.Value.ToString(DateFormat));
     flexCelReport.SetValue("AccountManagerName", _accountManager.FullName);
     flexCelReport.SetValue("AccountManagerPhone", Constants.PhoneNumbers.FreecallText);
     flexCelReport.SetValue("AccountManagerEmail", _accountManager.EmailAddress.Address);
 }
Ejemplo n.º 43
0
        public static void LoadData(FlexCelReport reportStart, string CityName, string DataPath, bool UseOfflineData)
        {
            reportStart.SetValue("Date", DateTime.Now);
            DataSet ds = new DataSet();

            ds.Locale             = CultureInfo.InvariantCulture;
            ds.EnforceConstraints = false;
            ds.ReadXmlSchema(Path.Combine(DataPath, "TripSearchResponse.xsd"));
            ds.Tables["Result"].Columns.Add("ImageData", typeof(byte[])); //Add a column for the actual images.
            if (UseOfflineData)
            {
                ds.ReadXml(Path.Combine(DataPath, "OfflineData.xml"));
            }
            else
            {
                // Create the web request
                string         url     = String.Format("http://travel.yahooapis.com/TripService/V1.1/tripSearch?appid=YahooDemo&query={0}&results=20", CityName);
                UriBuilder     uri     = new UriBuilder(url);
                HttpWebRequest request = WebRequest.Create(uri.Uri.AbsoluteUri) as HttpWebRequest;

                // Get response
                using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                {
                    // Load data into a dataset
                    ds.ReadXml(response.GetResponseStream());
                }
            }

            if (ds.Tables["ResultSet"].Rows.Count <= 0)
            {
                throw new Exception("Error loading the data.");
            }
            if (Convert.ToInt32(ds.Tables["ResultSet"].Rows[0]["totalResultsReturned"]) <= 0)
            {
                throw new Exception("There are no travel plans for this location");
            }

            LoadImageData(ds, UseOfflineData, DataPath);

            /* Uncomment this code to create an offline image of the data.*/
#if (CreateOffline)
            ds.WriteXml(Path.Combine(DataPath, "OfflineData.xml"));
#endif

            reportStart.AddTable(ds);
        }
Ejemplo n.º 44
0
        /// <summary>
        /// 生成报表
        /// </summary>
        public void CreateExcelFile(DataSet dataSource)
        {
            string fileName          = SysContext.CommonService.CreateUniqueNameForFile(TemplatePath);
            string physicalDirectory = SysContext.Config.TempDirectory_Physical;
            string fileSavePath      = physicalDirectory + "\\" + fileName;

            FlexCelReport cellReport = new FlexCelReport(true);

            cellReport.AddTable(dataSource);
            using (FlexCelReport ordersReport = cellReport)
            {
                ordersReport.SetValue("Date", DateTime.Now);
                ordersReport.Run(TemplatePath, fileSavePath);
            }

            FilePhysicalPath = fileSavePath;
        }
Ejemplo n.º 45
0
 protected XlsFile ExportExcelError(string value = "Xảy ra lỗi trong quá trình hiển thị báo cáo! Liên hệ trung tâm CSKH để được hỗ trợ!")
 {
     try
     {
         XlsFile result;
         result = new XlsFile(true);
         result.Open(Server.MapPath("~/PDFTemplate/rptError.xls"));
         var fr = new FlexCelReport();
         fr.SetValue("error", value);
         fr.Run(result);
         fr.Dispose();
         return(result);
     }
     catch (Exception ex)
     {
         Logger.Error($"{DateTime.Now.ToString("HH:mm:ss dd/MM/yyyy")} ExportExcelError {ex.Message} {JsonConvert.SerializeObject(ex)}");
         return(null);
     }
 }
Ejemplo n.º 46
0
        public void AutoRun()
        {
            using (FlexCelReport ordersReport = SharedData.CreateReport())
            {
                ordersReport.SetValue("Date", DateTime.Now);
                ordersReport.SetUserFormat("ZipCode", new ZipCodeImp());
                ordersReport.SetUserFormat("ShipFormat", new ShipFormatImp());

                string DataPath = Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ".."), "..") + Path.DirectorySeparatorChar;

                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    ordersReport.Run(DataPath + "User Defined Formats.template.xlsx", saveFileDialog1.FileName);

                    if (MessageBox.Show("Do you want to open the generated file?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Process.Start(saveFileDialog1.FileName);
                    }
                }
            }
        }
Ejemplo n.º 47
0
        public void ManualRun()
        {
            using (FlexCelReport ordersReport = SharedData.CreateReport())
            {
                ordersReport.BeforeReadTemplate    += new GenerateEventHandler(ordersReport_BeforeReadTemplate);
                ordersReport.AfterGenerateSheet    += new GenerateEventHandler(ordersReport_AfterGenerateSheet);
                ordersReport.AfterGenerateWorkbook += new GenerateEventHandler(ordersReport_AfterGenerateWorkbook);

                ordersReport.SetValue("Date", DateTime.Now);

                string DataPath = Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ".."), "..") + Path.DirectorySeparatorChar;

                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    ordersReport.Run(DataPath + "Encryption And Subtotals.template.xls", saveFileDialog1.FileName);

                    if (MessageBox.Show("Do you want to open the generated file?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Process.Start(saveFileDialog1.FileName);
                    }
                }
            }
        }
Ejemplo n.º 48
0
        private void SetJobAdReportProperties(FlexCelReport flexCelReport)
        {
            if (_includeCredits)
            {
                var posterIds = GetPosterIds();

                var jobAdReport       = _jobAdReportsQuery.GetJobAdReport(posterIds, _dateRange);
                var jobAdTotalsReport = _jobAdReportsQuery.GetJobAdTotalsReport(jobAdReport.ClosedJobAds);

                flexCelReport.SetValue("OpenedJobAds", jobAdReport.OpenedJobAds.Count);
                flexCelReport.SetValue("ClosedJobAds", jobAdReport.ClosedJobAds.Count);
                flexCelReport.SetValue("TotalApplications", jobAdReport.Totals.Applications);
                flexCelReport.SetValue("TotalViews", jobAdReport.Totals.Views);

                flexCelReport.SetValue("TotalClosedJobAdApplications", jobAdTotalsReport.Applications);
                flexCelReport.SetValue("TotalClosedJobAdViews", jobAdTotalsReport.Views);
            }
        }
Ejemplo n.º 49
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            using (FlexCelReport genericReport = new FlexCelReport(true))
            {
                IDbDataAdapter genericAdapter = SharedData.GetDataAdapter();
                try
                {
                    genericReport.SetValue("ReportCaption", "Sales by Country and Employee");
                    genericReport.AddConnection("Northwind", genericAdapter, CultureInfo.CurrentCulture);

                    //In OleDb the parameters are positional, you don't really need to name them when creating them.
                    //But when you are using an SQL Server connection, you *need*
                    //to specify the parameter name ("@StartDate") and make it equal to "@" + the name
                    //of the parameter. It is recommended that you always specify the name, even in OleDb connections.

                    //Also, we are not going to create the parameters directly here (using new SqlCeParameter(...).
                    //We are going to centralize all data access for the demos in SharedData, so we can change it and change all demos.
                    genericReport.AddSqlParameter("StartDate", SharedData.CreateParameter("@StartDate", startDate.Value.Date));
                    genericReport.AddSqlParameter("EndDate", SharedData.CreateParameter("@EndDate", endDate.Value.Date));
                    string DataPath = Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ".."), "..") + Path.DirectorySeparatorChar;

                    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        genericReport.Run(DataPath + "Direct SQL.template.xls", saveFileDialog1.FileName);

                        if (MessageBox.Show("Do you want to open the generated file?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            Process.Start(saveFileDialog1.FileName);
                        }
                    }
                }
                finally
                {
                    ((IDisposable)genericAdapter).Dispose();
                }
            }
        }
Ejemplo n.º 50
0
        private void SetCreditReportProperties(FlexCelReport flexCelReport)
        {
            if (_includeCredits)
            {
                var report = _creditReportsQuery.GetCreditReport <ApplicantCredit>(_organisation.Id, _dateRange);

                flexCelReport.SetValue("OpeningCredits", GetCreditValue(report.OpeningCredits) ?? "unlimited");
                flexCelReport.SetValue("ClosingCredits", GetCreditValue(report.ClosingCredits) ?? "unlimited");
                flexCelReport.SetValue("CreditsUsed", GetCreditValue(report.CreditsUsed) ?? string.Empty);
                flexCelReport.SetValue("CreditsAdded", GetCreditValue(report.CreditsAdded) ?? string.Empty);
                flexCelReport.SetValue("CreditsExpired", GetCreditValue(report.CreditsExpired) ?? string.Empty);

                if (report.ClosingCredits == null || report.CreditsUsed == null || report.CreditsUsed.Value == 0)
                {
                    flexCelReport.SetValue("MonthsToTopUp", string.Empty);
                }
                else
                {
                    flexCelReport.SetValue("MonthsToTopUp", Math.Max(1, report.ClosingCredits.Value / report.CreditsUsed.Value));
                }
            }
        }
Ejemplo n.º 51
0
        public ActionResult XuatExcel(string tungay, string denngay)
        {
            IQueryable <SanPham> model = db.SanPhams;

            if (!string.IsNullOrEmpty(tungay) || !string.IsNullOrEmpty(denngay))
            {
                string dateFrom = tungay.Split('-')[1] + "/" + tungay.Split('-')[2] + "/" + tungay.Split('-')[0];
                var    _tungay  = Convert.ToDateTime(dateFrom);

                if (!string.IsNullOrEmpty(denngay))
                {
                    string dateTo   = denngay.Split('-')[1] + "/" + denngay.Split('-')[2] + "/" + denngay.Split('-')[0];
                    var    _denngay = Convert.ToDateTime(dateTo).AddDays(1).AddMilliseconds(-1);
                    model = model.Where(n => n.NgayTao >= _tungay && n.NgayTao <= _denngay);
                }
                else
                {
                    string dateTo   = DateTime.Now.ToShortDateString();
                    var    _denngay = Convert.ToDateTime(dateTo).AddDays(1).AddMilliseconds(-1);
                    model = model.Where(n => n.NgayTao >= _tungay && n.NgayTao <= _denngay);
                }

                ViewBag.dem = model.Count();

                try
                {
                    if (model.Count() >= 1)
                    {
                        using (FlexCelReport fr = new FlexCelReport(true))
                        {
                            fr.SetValue("tungay", tungay);
                            fr.SetValue("denngay", denngay);
                            fr.AddTable("sanpham", model.ToList());
                            string uploadPath = Server.MapPath("~/Content/Template");

                            var luufile = @"E:/STYDY/DATN/Export";
                            //Nếu chưa tồn tại thì tạo ra folder mới
                            if (!Directory.Exists(luufile))
                            {
                                Directory.CreateDirectory(luufile);
                            }

                            fr.Run(
                                Path.Combine(uploadPath + "/Book.xlsx"),
                                Path.Combine(luufile + "/Sanpham_" + DateTime.Now.ToString("dd_MM_yy_hh_mm_ss") + ".xlsx")
                                );
                        }
                        SetAlert("Xuất thành công " + model.Count() + " sản phẩm!", "success");
                        logger.Info("Xuất thành công " + model.Count() + " sản phẩm!");
                    }
                    else
                    {
                        SetAlert("Không có sản phẩm nào được tìm thấy!", "error");
                        logger.Error("Không có sản phẩm nào được tìm thấy!");
                    }
                }
                catch (Exception ex)
                {
                    SetAlert("Xuất thống kê báo cáo thất bại!", "error");
                    logger.Error("Xuất thống kê báo cáo thất bại!" + ex.Message);
                }
            }
            return(View("XuatExcel"));
        }
Ejemplo n.º 52
0
 public void SetValue(string name, object value)
 {
     _report.SetValue(name, value);
 }
Ejemplo n.º 53
0
        public static void SetupNOAA(FlexCelReport reportStart, string CityName, string DataPath, bool UseOfflineData, Dictionary <string, LatLong> Cities)
        {
            LatLong CityCoords;

            GetCity(Cities, CityName, out CityCoords);
            reportStart.SetValue("Date", DateTime.Now);
            string   forecasts;
            DateTime dtStart = DateTime.Now;

            if (UseOfflineData)
            {
                using (StreamReader fs = new StreamReader(Path.Combine(DataPath, "OfflineData.xml")))
                {
                    forecasts = fs.ReadToEnd();
                }
            }
            else
            {
                ndfdXML nd = new ndfdXML();
                forecasts = nd.NDFDgen(CityCoords.Latitude, CityCoords.Longitude, productType.glance, dtStart, dtStart.AddDays(7), unitType.m, new weatherParametersType());

#if (SAVEOFFLINEDATA)
                using (StreamWriter sw = new StreamWriter(Path.Combine(DataPath, "OfflineData.xml")))
                {
                    sw.Write(forecasts);
                }
#endif
            }

            if (String.IsNullOrEmpty(forecasts))
            {
                throw new Exception("Can't find the place " + CityName);
            }

            DataSet ds = new DataSet();
            //Load the data into a dataset. On this web service, we cannot just call DataSet.ReadXml as the data is not on the correct format.
            XmlDocument xmlDoc = new XmlDocument();
            {
                xmlDoc.LoadXml(forecasts);
                XmlNodeList HighList = xmlDoc.SelectNodes("/dwml/data/parameters/temperature[@type='maximum']/value/text()");
                XmlNodeList LowList  = xmlDoc.SelectNodes("/dwml/data/parameters/temperature[@type='minimum']/value/text()");
                XmlNodeList IconList = xmlDoc.SelectNodes("/dwml/data/parameters/conditions-icon/icon-link/text()");

                DataTable WeatherTable = ds.Tables.Add("Weather");

                WeatherTable.Columns.Add("Day", typeof(DateTime));
                WeatherTable.Columns.Add("Low", typeof(double));
                WeatherTable.Columns.Add("High", typeof(double));
                WeatherTable.Columns.Add("Icon", typeof(byte[]));

                for (int i = 0; i < Math.Min(Math.Min(HighList.Count, LowList.Count), IconList.Count); i++)
                {
                    WeatherTable.Rows.Add(new object[] {
                        dtStart.AddDays(i),
                        Convert.ToDouble(LowList[i].Value),
                        Convert.ToDouble(HighList[i].Value),
                        LoadIcon(IconList[i].Value, UseOfflineData, DataPath)
                    });
                }
            }


            reportStart.AddTable(ds, TDisposeMode.DisposeAfterRun);
            reportStart.SetValue("Latitude", CityCoords.Latitude);
            reportStart.SetValue("Longitude", CityCoords.Longitude);
            reportStart.SetValue("Place", CityName);
        }
Ejemplo n.º 54
0
        public async Task <byte[]> GoToViewPhieuTiepNhan(PhieuTiepNhanInputDto input)
        {
            try
            {
                byte[]    fileTemplate = null;
                ExcelFile xls          = null;
                XlsFile   Result       = new XlsFile(true);

                using (FlexCelReport fr = new FlexCelReport(true))
                {
                    string DuongDan = "/ThuTuc_37/PhieuTiepNhan.xlsx";
                    var    path     = _appFolders.PDFTemplate + DuongDan;

                    var hoso = await _hoSoRepos.GetAsync(input.HoSoId);

                    fr.SetValue("HoVaTen", hoso.TenNguoiDaiDien);
                    fr.SetValue("DiaChi", hoso.DiaChi);
                    fr.SetValue("DienThoai", hoso.SoDienThoai);
                    fr.SetValue("SoGiayTiepNhan", Utility.GetCodeRandom());
                    if (input.ListTaiLieuDaNhan.Count > 0)
                    {
                        fr.AddTable("ListTaiLieuDaNhan", input.ListTaiLieuDaNhan);
                    }

                    fr.SetValue("NgayHen", input.NgayHenCap.Value.ToString("dd/MM/yyyy"));

                    var listHoSoXyLyBoSung = _hoSoXuLyRepos.GetAll().Where(x => x.HoSoId == hoso.Id && x.IsHoSoBS == true).ToList();
                    List <TiepNhanBoSungReport37Dto> ListTiepNhanBoSung = new List <TiepNhanBoSungReport37Dto>();
                    if (listHoSoXyLyBoSung.Count > 0)
                    {
                        if (listHoSoXyLyBoSung.Count == 1) // lần đầu nộp bổ xung
                        {
                            ListTiepNhanBoSung.Add(new TiepNhanBoSungReport37Dto()
                            {
                                SoLanBoSung            = listHoSoXyLyBoSung.Count,
                                NgayTraGiayTiepNhanStr = "ngày " + DateTime.Now.Day + " tháng " + DateTime.Now.Month + " năm " + DateTime.Now.Year
                            });
                        }
                        else
                        {
                            for (int i = 0; i < listHoSoXyLyBoSung.Count; i++)
                            {
                                var NguoiNhan = _userRepos.Get(listHoSoXyLyBoSung[i].VanThuId.Value);
                                var tiepNhanBoSungReport37Dto = new TiepNhanBoSungReport37Dto()
                                {
                                    SoLanBoSung            = i + 1,
                                    NgayTraGiayTiepNhanStr = listHoSoXyLyBoSung[i].NgayTraGiayTiepNhan.Value.ToShortDateString()
                                };
                                ListTiepNhanBoSung.Add(tiepNhanBoSungReport37Dto);
                            }
                            ListTiepNhanBoSung.Add(new TiepNhanBoSungReport37Dto()
                            {
                                SoLanBoSung            = listHoSoXyLyBoSung.Count + 1,
                                NgayTraGiayTiepNhanStr = DateTime.Now.ToShortDateString()
                            });
                        }
                    }

                    fr.AddTable("ListTiepNhanBoSung", ListTiepNhanBoSung);
                    var currentUser = _userRepos.Get(_session.UserId.Value);
                    fr.SetValue("NguoiKy", currentUser.Surname + " " + currentUser.Name);
                    var day   = String.Empty;
                    var month = String.Empty;
                    if (DateTime.Today.Day <= 9)
                    {
                        day = string.Format("0{0}", DateTime.Today.Day);
                    }
                    else
                    {
                        day = DateTime.Today.Day.ToString();
                    }
                    if (DateTime.Today.Month <= 9)
                    {
                        month = string.Format("0{0}", DateTime.Today.Month);
                    }
                    else
                    {
                        month = DateTime.Today.Month.ToString();
                    }
                    string NgayKy = "Hà nội, ngày " + day + " tháng " + month + " năm " + DateTime.Today.Year;
                    if (currentUser.TinhId.HasValue)
                    {
                        var tinh = _tinhRepos.Get(currentUser.TinhId.Value);
                        NgayKy = tinh.Ten + ", ngày " + DateTime.Today.Day + " tháng " + DateTime.Today.Month + " năm " + DateTime.Today.Year;
                    }
                    fr.SetValue("NgayKy", NgayKy);
                    Result.Open(path);
                    fr.Run(Result);
                    fr.Dispose();
                    xls = Result;

                    var outS = new System.IO.MemoryStream();
                    using (FlexCel.Render.FlexCelPdfExport pdf = new FlexCel.Render.FlexCelPdfExport(xls, true))
                    {
                        pdf.Export(outS);
                    }
                    fileTemplate = outS.ToArray();
                    return(fileTemplate);
                }
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex.Message);
                return(null);
            }
        }