public void SetParameterValueToNull(string parameterName)
        {
            EPField p = getParameterByName(parameterName);

            if (p != null)
            {
                p.SetValue(DBNull.Value);
            }
        }
        public void SetParameterValue(string parameterName, object value)
        {
            EPField p = getParameterByName(parameterName);

            if (p != null)
            {
                if (IsOleDb)
                {
                    if (value != null)
                    {
                        Type t = value.GetType();
                        if (typeof(DateTime).Equals(t))
                        {
                            DateTime dt = (DateTime)value;
                            dt = new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second);
                            p.SetValue(dt);
                            return;
                        }
                    }
                }
                p.SetValue(value);
            }
        }
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (value is string)
     {
         string data = value as string;
         if (!string.IsNullOrEmpty(data))
         {
             string[]           ss = data.Split('|');
             DbParameterListExt ps = new DbParameterListExt();
             for (int i = 0; i < ss.Length; i++)
             {
                 if (!string.IsNullOrEmpty(ss[i]))
                 {
                     string[] ss2 = ss[i].Split(';');
                     if (ss2.Length > 1)
                     {
                         EPField        f = new EPField();
                         DbCommandParam p = new DbCommandParam(f);
                         if (!string.IsNullOrEmpty(ss2[0]))
                         {
                             if (!ss2[0].StartsWith("@", StringComparison.Ordinal))
                             {
                                 f.Name = string.Format(CultureInfo.InvariantCulture, "@{0}", ss2[0]);
                             }
                             else
                             {
                                 f.Name = ss2[0];
                             }
                             if (!string.IsNullOrEmpty(ss2[1]))
                             {
                                 f.OleDbType = (OleDbType)Enum.Parse(typeof(OleDbType), ss2[1]);
                                 if (ss2.Length > 2)
                                 {
                                     int n;
                                     if (int.TryParse(ss2[2], out n))
                                     {
                                         f.DataSize = n;
                                     }
                                     if (ss2.Length > 3)
                                     {
                                         p.Direction = (ParameterDirection)Enum.Parse(typeof(ParameterDirection), ss2[3]);
                                         if (ss2.Length > 4)
                                         {
                                             f.SetValue(ss2[4]);
                                         }
                                     }
                                 }
                                 ps.Add(p);
                             }
                         }
                     }
                 }
             }
             return(ps);
         }
         else
         {
             return(new DbParameterListExt());
         }
     }
     return(base.ConvertFrom(context, culture, value));
 }
Exemplo n.º 4
0
 public override void ResetValue(object component)
 {
     _field.SetValue(VPLUtil.GetDefaultValue(PropertyType));
 }