Click here to Skip to main content
15,886,026 members
Articles / Programming Languages / C#

Custom Field in Crystal Report

Rate me:
Please Sign up or sign in to vote.
4.75/5 (17 votes)
6 Aug 2008CPOL3 min read 115.8K   5.9K   45  
This application will adjust the position of the fields in Crystal report, which are dragged and dropped during design time
using System;

using System.Reflection;
using System.Web;
using System.Threading;
using HMIS;
using System.Data;
using System.Collections.Specialized;
//using HMIS.Global.Providers;
//using HMIS.Global;
using HMIS.Main.Registration_Comm;
using System.Configuration;





namespace HMIS.Main.Registration_Comm {

    public abstract class RegistrationProvider 
    {
        #region Class Variables
        public abstract DataTable GetPatientsByRegDate(DateTime from, DateTime to);
        static RegistrationProvider _provider;
       // static CacheManager cache = null;
        #endregion

        #region Properties
        private DataSet _ds = null;

        public DataSet ds
        {
            get {
                return this._ds;
            }
            set {
                this._ds = value;
            }
        }
        #endregion
                       
        #region Instance Function
        public static RegistrationProvider Instance()
        {

             //Use the cache because the reflection used later is expensive
            //if(cache==null)
            //    cache = CacheFactory.GetCacheManager("MyCache1");

            Type type = null;
            string cacheKey = null;

            if (_provider == null)
            {
                string ss=System.Configuration.ConfigurationManager.ConnectionStrings["AdventureWorksDB"].ConnectionString;
                _provider=(RegistrationProvider)(new SqlRegistrationProvider(ss));
            }

            Configuration config=ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            //config.AppSettings.Settings.Add(

            return _provider;

            // Get the names of the providers
            //RegistrationConfiguration config = RegistrationConfiguration.GetConfig();

            // Read the configuration specific information
            // for this provider
           // Provider registrationProvider = (Provider)config.Providers[config.DefaultProvider];

            // In the cache?
            //cacheKey = "Registration::" + config.DefaultProvider;
            //if (!cache.Contains(cacheKey)) {

            //    // The assembly should be in \bin or GAC, so we simply need
            //    // to get an instance of the type
            //    try {

            //        type = Type.GetType(registrationProvider.Type);

            //        // Insert the type into the cache
            //        Type[] paramTypes = new Type[1];
            //        paramTypes[0] = typeof(string);
            //        cache.Add(cacheKey, type.GetConstructor(paramTypes), CacheItemPriority.NotRemovable, null, null);
            //        //cache.Insert( cacheKey, type.GetConstructor(paramTypes) );

            //    } catch (Exception e) {
            //        throw new Exception("Unable to load Registration provider", e);
            //    }

            //}

            // Load the configuration settings
          //  object[] paramArray = new object[1];
        //    paramArray[0] = registrationProvider.Attributes["connectionString"];

         //   type = Type.GetType("HMIS.Main.Registration_Comm.SqlRegistrationProvider, SqlRegistrationProvider");
          //  Type[] paramTypes = new Type[1];
           // paramTypes[0] = typeof(string);
           // return (RegistrationProvider)(type.GetConstructor(paramTypes).Invoke(paramArray));

            

            //return (RegistrationProvider)(((ConstructorInfo)cache.GetData(cacheKey)).Invoke(paramArray));
        }
        #endregion

       

       

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Ciklum
Pakistan Pakistan
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions