Page 3 of 3

get data, do some processes on them, retrive and display them on report??

Posted: Wed Mar 31, 2010 5:19 pm
by Jan
Hello,

Please show me how you call this function in report? I mean text expression which use this function.

Thank you.

get data, do some processes on them, retrive and display them on report??

Posted: Thu Apr 01, 2010 12:56 am
by M.I.A
hello Andrew, Jan, Vladimir and all of the rest in this forum, i would like to tell you that my report and my function are working now exactly as i want.

I really appreciate your help and your great support.

About my last problem it is just small wrong from me, because in the datasourse in stimulsoft report environment under the Date column i put the datatype String, and after i changed it to DateTime my report working properly now.

This is the last code which is working now, and after i did few changes in that application you sent to me.

Code: Select all


namespace MyClassNamespace
{
    public class MyClass
    {
        public static string GetUserText(DateTime greg)
        {
            GregorianCalendar Grn = new GregorianCalendar();
            UmAlQuraCalendar Umq = new UmAlQuraCalendar();

            int year = Umq.GetYear(greg);
            int month = Umq.GetMonth(greg);
            int day = Umq.GetDayOfMonth(greg);

            string hijri = year.ToString() + "/" + month.ToString() + "/" + day.ToString();
            return hijri;
        }
    }
}

namespace WebViewer_UserFunction
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(General.ConnString);

            string sql= "SELECT EnrDate, EnrStudentName FROM nEnrollment";

            SqlDataAdapter da = new SqlDataAdapter(sql, conn);
            DataSet ds = new DataSet();
            da.Fill(ds);

            string appDirectory = HttpContext.Current.Server.MapPath(string.Empty);
            string reportPart = appDirectory + "\\SampleReport.mrt";
            
            
            StiReport report = new StiReport();
            report.Load(reportPart);

            report.RegData(ds);
            report.Script = string.Format("using MyClassNamespace;\n{0}", report.Script);

            string[] referencedAssemblies = new string[report.ReferencedAssemblies.Length + 1];
            report.ReferencedAssemblies.CopyTo(referencedAssemblies, 0);
            referencedAssemblies[referencedAssemblies.Length - 1] = "WebViewer_UserFunction.dll";
            report.ReferencedAssemblies = referencedAssemblies;

            StiWebViewer1.Report = report;
        }
    }
}
And in the text editor of the Text Component i wrote this:

{MyClass.GetUserText(DataSource1.EnrDate)}


So my report is working properly now :).

Thank you again.

get data, do some processes on them, retrive and display them on report??

Posted: Fri Apr 02, 2010 1:18 am
by Andrew
Thank you for your post! That will be very helpful for all forum community.