Example #1
0
 public void CreateChartSeriesFromObjectArray(HraObject[] p, string name)
 {
     ObjectArray = p;
     if (p != null)
     {
         ChartElement = new Element();
         ChartElement.Name = name;
         ChartElement.YValue = p.Length;
     }
 }
Example #2
0
 private static void UpdateModelFromControl(object sender, HraObject hraObject)
 {
     Control control = sender as Control;
     if (control != null)
     {
         string name = control.Name;
         PropertyInfo property = hraObject.GetPropertyWithNameLike(name);
         if (property != null)
         {
             object text = control.Text;
             property.SetValue(hraObject, text, null);
         }
     }
 }
 public HraListChangedEventArgs(HraListChangeType hraListChangeType, HraObject hraOperand)
 {
     this.hraListChangeType = hraListChangeType;
     this.hraOperand = hraOperand;
 }
Example #4
0
        protected void DoListLoad(LoadListArgs lla)
        {
            lock (this)
            {
#if international
                string region = RiskApps3.Utilities.Configurator.getNodeValue("globals", "CultureRegion");

                if (string.IsNullOrEmpty(region) == false)
                {
                    CultureInfo culture = new CultureInfo(region);
                    Thread.CurrentThread.CurrentCulture   = culture;
                    Thread.CurrentThread.CurrentUICulture = culture;
                }
#endif
                this.Clear();
                //TODO initial contents are never attached to ItemChanged - is this intentional?
                this.AddRange(lla.initialContents);

                using (SqlConnection connection = new SqlConnection(BCDB2.Instance.getConnectionString()))
                {
                    connection.Open();

                    SqlCommand cmdProcedure = new SqlCommand(lla.sp, connection);
                    cmdProcedure.CommandType    = CommandType.StoredProcedure;
                    cmdProcedure.CommandTimeout = 600;
                    foreach (string param in lla.sPparams.getKeys())
                    {
                        cmdProcedure.Parameters.Add("@" + param, lla.sPparams[param].sqlType);
                        cmdProcedure.Parameters["@" + param].Value = lla.sPparams[param].obj;
                    }
                    string current = "";
                    try
                    {
                        SqlDataReader reader = cmdProcedure.ExecuteReader(CommandBehavior.CloseConnection);

                        if (reader != null)
                        {
                            while (reader.Read())
                            {
                                object o = Activator.CreateInstance(lla.type, lla.constructor_params);
                                T      localHraObject = (T)o;
                                for (int i = 0; i < reader.FieldCount; i++)
                                {
                                    if (reader.IsDBNull(i) == false)
                                    {
                                        current = reader.GetName(i);
                                        foreach (FieldInfo fi in lla.type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
                                        {
                                            string name = fi.Name;
                                            if (string.Compare(name, reader.GetName(i), true) == 0)
                                            {
                                                HraObject.SetFieldInfoValue(fi, reader.GetValue(i), localHraObject);
                                                break;
                                            }
                                        }
                                    }
                                }

                                localHraObject.HraState = HraObject.States.Ready;
                                this.AddToList(localHraObject, new HraModelChangedEventArgs(null), false);
                            }
                            reader.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Instance.WriteToLog("Error on " + current + " : " + ex.ToString());
                    }
                }
                loaded = true;
            }
        }
Example #5
0
        private void FillControlsByControlName(HraObject hraObject)
        {
            var hraObjectGetters = hraObject.GetType()
                .GetMembers(BindingFlags.NonPublic | BindingFlags.Instance);

            foreach (var property in hraObjectGetters)
            {
                // ReSharper disable StringLastIndexOfIsCultureSpecific.1   - Not Applicable
                int indexOfLastunderscore = property.Name.LastIndexOf("_");
                // ReSharper restore StringLastIndexOfIsCultureSpecific.1
                string propertyNameWithoutGetPrefix = property.Name.Remove(0, indexOfLastunderscore + 1);

                Control controlToUpdate = this.groupBox.Controls.Cast<Control>()
                    .SingleOrDefault(control => String.Equals(control.Name, propertyNameWithoutGetPrefix, StringComparison.CurrentCultureIgnoreCase));

                if (controlToUpdate != null)
                {
                    var memberWithName = hraObject.GetMemberByName(propertyNameWithoutGetPrefix);
                    FieldInfo propertyInfo = memberWithName as FieldInfo;
                    if (propertyInfo != null)
                    {
                        object hraObjectValue = propertyInfo.GetValue(hraObject);
                        if (hraObjectValue != null)
                        {
                            controlToUpdate.Text = hraObjectValue.ToString();
                        }
                    }
                }
            }
        }
Example #6
0
        private ListViewItem GetListViewAndUpdateHtml(string p, HraObject[] hraObject, ref string patients_html)
        {
            ReportSeries rs = new ReportSeries();
            rs.CreateChartSeriesFromObjectArray(hraObject, p);

            ListViewItem lvi = new ListViewItem(p);
            lvi.Tag = rs;
            lvi.SubItems.Add(hraObject.Length.ToString());
            patients_html = dt.InsertTwoColumnLeftRightTableRow(patients_html, p, hraObject.Length.ToString());
            return lvi;
        }
Example #7
0
 /// <summary>
 /// Attempts to fill a <code>Control.Text</code> value by finding the
 ///  member with the given name in the given HraObject.
 /// </summary>
 /// <param name="hraObject">object containing the data to set</param>
 /// <param name="name">name of field to search for</param>
 /// <param name="control">control to populate</param>
 private static void TryToSetControlValueFromHraObject(HraObject hraObject, string name, Control control)
 {
     FieldInfo hraField = hraObject.GetHraFieldWithNameLike(name);
     if (hraField != null)
     {
         object memberValue = hraField.GetValue(hraObject);
         if (memberValue is string)
         {
             control.Text = memberValue as string;
         }
     }
 }
 public HraListChangedEventArgs(HraListChangeType hraListChangeType, HraObject hraOperand)
 {
     this.hraListChangeType = hraListChangeType;
     this.hraOperand        = hraOperand;
 }