コード例 #1
0
ファイル: Report.cs プロジェクト: iiSergey/AppPosht
        public Task SaveAsync()
        {
            return(Task.Run(() =>
            {
                Status = ReportStatus.ReportStatusSaving;
                string directoryNameOut = Settings.Default.DirectoryNameOut;
                using (var dbf = new DBFWriter
                {
                    Fields = new[]
                    {
                        new DBFField("ls", NativeDbType.Char, 12),
                        new DBFField("ls_old", NativeDbType.Char, 12),
                        new DBFField("fio", NativeDbType.Char, 50),
                        new DBFField("adress", NativeDbType.Char, 100),
                        new DBFField("paymonth", NativeDbType.Numeric, 2),
                        new DBFField("payyear", NativeDbType.Numeric, 4),
                        new DBFField("sum", NativeDbType.Numeric, 14, 2),
                        new DBFField("date", NativeDbType.Date),
                        new DBFField("eval0", NativeDbType.Numeric, 12, 2),
                        new DBFField("eval1", NativeDbType.Numeric, 12, 2),
                        new DBFField("date_eval1", NativeDbType.Date),
                        new DBFField("rgc_format", NativeDbType.Numeric, 1)
                    },
                    CharEncoding = Encoding.GetEncoding("cp866") //koi8-u
                })
                {
                    foreach (var piple in Piples)
                    {
                        dbf.AddRecord(piple.Number,
                                      "",
                                      piple.FullName,
                                      piple.Adress,
                                      piple.DatePay.Month,
                                      piple.DatePay.Year,
                                      piple.Sum,
                                      piple.DatePay,
                                      0,
                                      0,
                                      piple.DatePay,
                                      0);
                    }
                    using (
                        Stream fos =
                            File.Open(directoryNameOut + "0500_polgaz_" + DateReport.ToString("dd.MM.yyyy") + ".dbf",
                                      FileMode.Create,
                                      FileAccess.Write))
                    {
                        dbf.Write(fos);
                    }
                }

                Status = ReportStatus.ReportStatusSaved;
            }));
        }
コード例 #2
0
ファイル: PrintReport.aspx.cs プロジェクト: chilesju/CityCode
        private void Page_Load(object sender, EventArgs e)
        {
            base.Request.QueryString.ToString();
            string         text1     = base.Request.QueryString[0];
            string         text2     = base.Request.QueryString[1].Substring(0, 4);
            string         text3     = base.Request.QueryString[2];
            string         text4     = base.Request.QueryString[3];
            DateReport     report1   = new DateReport(Convert.ToDateTime(text4), Convert.ToDateTime(text3), text2);
            ReportDocument document1 = report1.GetDocument(text1);
            MemoryStream   stream1   = report1.ConvertToPDF(document1);

            base.Response.Clear();
            base.Response.Buffer      = true;
            base.Response.ContentType = "application/pdf";
            base.Response.BinaryWrite(stream1.ToArray());
            base.Response.End();
        }
コード例 #3
0
        public string PrintDyncReport(KendoFilterRequestDto Request)
        {
            using (EAharaDB context = new EAharaDB())
            {
                ReportDocument rd = new ReportDocument();

                DateReport dreport = new DateReport();
                dreport.From = Request.FromDate.Value;
                dreport.To   = Request.ToDate.Value;
                context.DateReports.Add(dreport);
                context.SaveChanges();

                Guid   id1        = Guid.NewGuid();
                var    pdfName    = Request.RPTName + id1 + ".pdf";
                string strRptPath = System.Web.HttpContext.Current.Server.MapPath("~/") + "Reports\\" + Request.RPTName + ".rpt";
                string strPdfPath = System.Web.HttpContext.Current.Server.MapPath("~/") + "Reports\\" + pdfName;

                rd.Load(strRptPath);
                rd.Refresh();

                string connectionString =
                    ConfigurationManager.ConnectionStrings["EAharaDB"].ConnectionString;

                SqlConnectionStringBuilder SConn = new SqlConnectionStringBuilder(connectionString);

                rd.DataSourceConnections[0].SetConnection(
                    SConn.DataSource, SConn.InitialCatalog, SConn.UserID, SConn.Password);


                foreach (ReportDocument srd in rd.Subreports)
                {
                    srd.DataSourceConnections[0].SetConnection(SConn.DataSource, SConn.InitialCatalog, SConn.UserID, SConn.Password);
                }
                //rd.SetParameterValue(0, dreport.Id);
                rd.SetParameterValue("FromDate", Request.FromDate);
                rd.SetParameterValue("ToDate", Request.ToDate);
                System.IO.File.Delete(strPdfPath);
                //rd.PrintOptions.PaperSize = PaperSize.PaperA5;
                rd.ExportToDisk(ExportFormatType.PortableDocFormat, strPdfPath);

                return(pdfName);
            }
        }
コード例 #4
0
        public string PrintShopDyncReport(KendoFilterRequestDto Request)
        {
            using (EAharaDB context = new EAharaDB())
            {
                BasicAuthenticationIdentity identity = (BasicAuthenticationIdentity)User.Identity;

                var user  = context.Users.FirstOrDefault(x => x.Id == identity.Id);
                var shops = context.Shops.Where(x => x.IsActive);

                if (user.Role == "Employee")
                {
                    if (user.Employee != null)
                    {
                        shops = shops.Where(x => x.LocationId == user.Employee.LocationId);
                    }
                }

                long[] items = shops.Select(x => x.Id).ToArray();

                if (Request.Shops.Count > 0)
                {
                    items = Request.Shops.ToArray();
                }
                //foreach (var det in Request.Shops)
                //{

                //}

                ReportDocument rd = new ReportDocument();

                DateReport dreport = new DateReport();
                dreport.From = Request.FromDate.Value;
                dreport.To   = Request.ToDate.Value;
                context.DateReports.Add(dreport);
                context.SaveChanges();



                Guid   id1        = Guid.NewGuid();
                var    pdfName    = Request.RPTName + id1 + ".pdf";
                string strRptPath = System.Web.HttpContext.Current.Server.MapPath("~/") + "Reports\\" + Request.RPTName + ".rpt";
                string strPdfPath = System.Web.HttpContext.Current.Server.MapPath("~/") + "Reports\\" + pdfName;

                rd.Load(strRptPath);
                rd.Refresh();

                string connectionString =
                    ConfigurationManager.ConnectionStrings["EAharaDB"].ConnectionString;

                SqlConnectionStringBuilder SConn = new SqlConnectionStringBuilder(connectionString);

                rd.DataSourceConnections[0].SetConnection(
                    SConn.DataSource, SConn.InitialCatalog, SConn.UserID, SConn.Password);


                foreach (ReportDocument srd in rd.Subreports)
                {
                    srd.DataSourceConnections[0].SetConnection(SConn.DataSource, SConn.InitialCatalog, SConn.UserID, SConn.Password);
                }

                rd.SetParameterValue(0, items);
                rd.SetParameterValue("FromDate", Request.FromDate);
                rd.SetParameterValue("ToDate", Request.ToDate);
                System.IO.File.Delete(strPdfPath);
                //rd.PrintOptions.PaperSize = PaperSize.PaperA5;
                rd.ExportToDisk(ExportFormatType.PortableDocFormat, strPdfPath);

                return(pdfName);
            }
        }