public void ReportEngine(string rptNm, string OderID)
        {
            using (dbDatabaseDataDataContext db = new dbDatabaseDataDataContext())
            {
                //int sample = int.Parse(Request.QueryString["ApplicationId"]);
                crReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                crReportDocument.Load(Server.MapPath(rptNm));
                //crReportDocument.Refresh();

                ConnectionInfo connectionInfo = new ConnectionInfo();
                connectionInfo.DatabaseName = ConfigurationManager.AppSettings["DBaseName"];
                connectionInfo.UserID       = ConfigurationManager.AppSettings["DBUserName"];
                connectionInfo.Password     = ConfigurationManager.AppSettings["DBPassword"];
                connectionInfo.ServerName   = ConfigurationManager.AppSettings["DBServerName"];

                CrTables            = crReportDocument.Database.Tables;
                connectionInfo.Type = ConnectionInfoType.SQL;
                TableLogOnInfo tableLogOnInfo = new TableLogOnInfo();
                tableLogOnInfo.ConnectionInfo = connectionInfo;
                crReportDocument.DataSourceConnections[0].SetConnection(tableLogOnInfo.ConnectionInfo.ServerName, tableLogOnInfo.ConnectionInfo.DatabaseName, tableLogOnInfo.ConnectionInfo.UserID, tableLogOnInfo.ConnectionInfo.Password);

                int GrocerID = int.Parse((Session["GrocId"]).ToString());
                crReportDocument.SetParameterValue("@CustOdrID", OderID);
                crReportDocument.SetParameterValue("@GrocerId", GrocerID);



                if (System.IO.File.Exists(Server.MapPath("~/DownloadApplication/ItemLIst" + ".pdf")))
                {
                    System.IO.File.Delete(Server.MapPath("~/DownloadApplication/ItemLIst" + ".pdf"));
                }
                crReportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, Server.MapPath("~/DownloadApplication/ItemLIst" + ".pdf"));

                ViewState["ApplicationPath"] = "~/DownloadApplication/ItemLIst" + ".pdf";
                FilePath1 = Server.MapPath(ViewState["ApplicationPath"].ToString());
                System.Net.WebClient User = new System.Net.WebClient();
                byte[] FileBuffer         = User.DownloadData(FilePath1);
                if ((FileBuffer != null))
                {
                    Response.ContentType = "application/pdf";
                    Response.AddHeader("content-length", FileBuffer.Length.ToString());
                    Response.BinaryWrite(FileBuffer);
                }
                Response.Redirect(ViewState["ApplicationPath"].ToString());
            }
        }
        private void crystalReportsViewer1_Loaded(object sender, RoutedEventArgs e)
        {
            var Entity = new RTMEntities();
            var report = new RTM.Report.GenralRep.Contractors_();
            ////////Login Info
            ConnectionInfo crConnection = new ConnectionInfo();

            crConnection.ServerName   = @"GIS-SERVER";
            crConnection.DatabaseName = "ratec";
            crConnection.UserID       = "ratec";
            crConnection.Password     = "******";
            CrystalDecisions.CrystalReports.Engine.Tables tables = report.Database.Tables;
            foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
            {
                CrystalDecisions.Shared.TableLogOnInfo tableLogonInfo = table.LogOnInfo;
                tableLogonInfo.ConnectionInfo = crConnection;
                table.ApplyLogOnInfo(tableLogonInfo);
            }
            ////////



            //report.SetDatabaseLogon("ratec", "ratec");


            var result = (from items in MyList
                          select new cc
            {
                CompanyName = items.CompanyName != null?(string)items.CompanyName:"-",
                NationalIdNumber = items.NationalIdNumber != null ? (string)items.NationalIdNumber : "-",
                CompanyType = items.CompanyType != null ? (string)items.CompanyType : "-",
                Telephone = items.Telephone != null?(string)items.Telephone:"-",
                Fax = items.Fax != null?(string)items.Fax:"-",
                CeoEmailAddress = items.CeoEmailAddress != null?(string)items.CeoEmailAddress:"-",
                CompanyField1 = items.CompanyField1 != null?(string)items.CompanyField1:"-",
                CompanyBase1 = items.CompanyBase1 != null?(int)items.CompanyBase1:5,
                Design = items.Design != null?(bool)items.Design:false,
                Procurement = items.Procurement != null?(bool)items.Procurement:false,
                BuildAndOperation = items.BuildAndOperation != null?(bool)items.BuildAndOperation:false,
                Finance = items.Finance != null?(bool)items.Finance:false,
                ContractorId = (int)items.ContractorId,
            }).ToList();

            report.SetDataSource(result);
            crystalReportsViewer1.ViewerCore.ReportSource = report;
        }
Exemple #3
0
        public static void LogonReport(CrystalDecisions.CrystalReports.Engine.ReportDocument reportdocument)
        {
            System.Data.SqlClient.SqlConnectionStringBuilder con = new System.Data.SqlClient.SqlConnectionStringBuilder();
            con.ConnectionString = ConfigurationManager.ConnectionStrings["SPDDevConnectionString"].ConnectionString;

            CrystalDecisions.Shared.ConnectionInfo consinfo = new CrystalDecisions.Shared.ConnectionInfo();
            consinfo.ServerName   = con.DataSource;
            consinfo.UserID       = con.UserID;
            consinfo.DatabaseName = con.InitialCatalog;
            consinfo.Password     = con.Password;
            consinfo.Type         = CrystalDecisions.Shared.ConnectionInfoType.SQL;

            CrystalDecisions.CrystalReports.Engine.Tables myTables = reportdocument.Database.Tables;
            foreach (CrystalDecisions.CrystalReports.Engine.Table myTable in myTables)
            {
                CrystalDecisions.Shared.TableLogOnInfo myTableLogonInfo = myTable.LogOnInfo;
                myTableLogonInfo.ConnectionInfo = consinfo;
                myTable.ApplyLogOnInfo(myTableLogonInfo);
            }
        }
Exemple #4
0
        private void crystalReportsViewer1_Loaded(object sender, RoutedEventArgs e)
        {
            var report = new RTM.Report.GenralRep.WebDocRecieve();
            //report.SetDatabaseLogon("ratec", "ratec");
            ConnectionInfo crConnection = new ConnectionInfo();

            crConnection.ServerName   = @"GIS-SERVER";
            crConnection.DatabaseName = "ratec";
            crConnection.UserID       = "ratec";
            crConnection.Password     = "******";
            CrystalDecisions.CrystalReports.Engine.Tables tables = report.Database.Tables;
            foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
            {
                CrystalDecisions.Shared.TableLogOnInfo tableLogonInfo = table.LogOnInfo;
                tableLogonInfo.ConnectionInfo = crConnection;
                table.ApplyLogOnInfo(tableLogonInfo);
            }
            foreach (TenderingFileDownload t in MyList)
            {
                t.PersianDate = DateConverter.ConvertDate(t.date);
            }
            report.SetDataSource(MyList);
            crystalReportsViewer1.ViewerCore.ReportSource = report;
        }
Exemple #5
0
        private void crystalReportsViewer1_Loaded(object sender, RoutedEventArgs e)
        {
            var Entity = new RTMEntities();
            ////////Login Info
            ConnectionInfo crConnection = new ConnectionInfo();

            crConnection.ServerName   = @"Gis-Server";
            crConnection.DatabaseName = "ratec";
            crConnection.UserID       = "ratec";
            crConnection.Password     = "******";
            //crConnection.ServerName = @".";
            //crConnection.DatabaseName = "ratec";
            //crConnection.UserID = "sa";
            //crConnection.Password = "******";
            CrystalDecisions.CrystalReports.Engine.Tables tables = report.Database.Tables;
            foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
            {
                CrystalDecisions.Shared.TableLogOnInfo tableLogonInfo = table.LogOnInfo;
                tableLogonInfo.ConnectionInfo = crConnection;
                table.ApplyLogOnInfo(tableLogonInfo);
            }
            ////////
            var x = (from n in Entity.OrganizationalCharts where n.ChartNodeId == CurrentContract.SupervisingUnitHigher select n).FirstOrDefault();

            CalculateExtrasContract();
            //report.SetDatabaseLogon("ratec", "ratec");
            report.SetParameterValue("ContractId", CurrentContract.Contractid);
            report.SetParameterValue("DraftId", CurrentDraft.PaymentDraftId);
            report.SetParameterValue("Date", DateConverter.ConvertDate((DateTime)(((CurrentContract.ContractDate).Value).Date)).Substring(4));

            if (Convert.ToString(CurrentDraft.PayableAmount) != string.Empty)
            {
                report.SetParameterValue("Amount", CurrentDraft.PayableAmount);
            }
            else
            {
                report.SetParameterValue("Amount", 0);
            }

            if (x != null)
            {
                report.SetParameterValue("Supervisor", x.Title);
            }
            else
            {
                report.SetParameterValue("Supervisor", "-");
            }
            ////////////////////////////////////////////////////////////////////////// you have a problem here in your code
            decimal B;

            if (CurrentDraft.EmployerInsurancePercentage != 0 || CurrentDraft.EmployerInsurancePercentage != null)
            {
                B = ((((decimal)CurrentDraft.CurrentSituationDraft) - ((decimal)CurrentDraft.PerviousSituationDraft)) * (((decimal)(CurrentDraft.EmployerInsurancePercentage)) / 100));
            }
            else
            {
                B = ((((decimal)CurrentDraft.CurrentSituationDraft) - ((decimal)CurrentDraft.PerviousSituationDraft)));
            }

            report.SetParameterValue("Bimeh", B);
            report.SetParameterValue("HaveTrans", HaveTrans);
            // added by naseri
            PNumberTString dd       = new PNumberTString();
            decimal        Subtract = (((decimal)CurrentDraft.CurrentSituationDraft) - ((decimal)CurrentDraft.PerviousSituationDraft));

            report.SetParameterValue("Subtract", Subtract);
            try
            {
                report.SetParameterValue("NumToWord", dd.num2str(Convert.ToString(Convert.ToInt64(CurrentDraft.PayableAmount))));
            }
            catch (Exception)
            {}
            if (!HaveTrans)
            {
                report.SetParameterValue("User", string.Empty);
            }
            // added by naseri
            crystalReportsViewer1.ViewerCore.ReportSource = report;
        }