Exemplo n.º 1
0
 public DBReportParam(DBReportParam obj)
 {
     PropertyInfo[] p = obj.GetType().GetProperties();                               // get entity properties
     for (int i = 0; i < (p.Length); i++)
     {
         if (!p[i].PropertyType.Name.Contains("list") && !p[i].Name.Contains("arg"))
             p[i].SetValue(this, p[i].GetValue(obj, null), null);                    // set entity's property values to obj properties
     }
 }
Exemplo n.º 2
0
        // fetches all parameters given a report id
        public static ArrayList FetchReportParams(int id)
        {
            ArrayList list = new ArrayList();
            DBReportParam param = new DBReportParam();
            PropertyInfo[] p = param.GetType().GetProperties();

            string qryString = "SELECT * FROM REPORT_PARAMS WHERE RPT_ID = @id";

            // create database connection
            User user = (User)System.Web.HttpContext.Current.Session[Constant.session.User];
            IDBManager dbmgr = new DBManager(user.plantDBStr);
            dbmgr.ConnectionString = user.plantDBStr;

            try
            {
                dbmgr.Open();
                dbmgr.CreateParameters(1);
                dbmgr.AddParameters(0, "@id", id);
                dbmgr.ExecuteReader(System.Data.CommandType.Text, qryString);

                while (dbmgr.DataReader.Read())
                {
                    param = new DBReportParam();
                    param = (DBReportParam)TotalManager.FetchObject(param, p, dbmgr);
                    list.Add(param);
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                dbmgr.Dispose();
            }

            return list;
        }