Ejemplo n.º 1
0
        /// <summary>
        /// Render this control to the output parameter specified.
        /// </summary>
        /// <param name="output"> The HTML writer to write out to </param>
        protected override void Render(HtmlTextWriter output)
        {
            PageErrors errors = PageErrors.getErrors(null, Page);

            if (errors != null)
            {
                if (name == null)
                {
                    if (!errors.isEmpty())
                    {
                        StringBuilder b = new StringBuilder();

                        ResourceManager rm = DBUtils.getResourceManager();

                        CultureInfo ci = CultureInfo.CurrentUICulture;
                        if (showPrompt)
                        {
                            b.Append(rm.GetString("validate.prompt", ci));
                        }

                        foreach (Error s in errors.globalErrors)
                        {
                            b.Append("\n" + s.getPrompt(errors.db, rm, ci));
                        }

                        if (showFieldErrors)
                        {
                            foreach (string key in errors.errors.Keys)
                            {
                                Error er = errors.getError(key);
                                b.Append("\n - " + er.getPrompt(errors.db, rm, ci));
                            }
                        }
                        writeError(output, b, Page, errors);

                        if (isPopup)
                        {
                            output.Write("<script defer>alert(\"");
                            output.Write(b.ToString().Replace("\n", "\\n"));
                            output.Write("\");</script>");
                        }
                        else
                        {
                            output.Write(HTMLUtils.toHTMLText(b.ToString()));
                        }
                    }
                }
                else
                {
                    if (errors.hasError(name))
                    {
                        ResourceManager rm = DBUtils.getResourceManager();
                        Error           er = errors.getError(name);
                        output.Write("<span style=\"color:#ff0000\">");
                        output.Write(er.getFieldPrompt(errors.db, rm));
                        output.Write("</span>");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public override void toControl(Hashtable values)
        {
            object o = values[name];

            if (o != null)
            {
                bool found = false;
                List <WFSelectValue> list = vl.getValues(Binding.DBConn, filter, null);
                foreach (WFSelectValue sv in list)
                {
                    if (sv.key.Equals(o))
                    {
                        o     = sv.name;
                        found = true;
                        break;
                    }
                }
                if (found || showInvalid)
                {
                    c.Text = HTMLUtils.toHTMLText(o.ToString());
                }
                else
                {
                    c.Text = "";
                }
            }
            else
            {
                c.Text = "";
            }
        }
Ejemplo n.º 3
0
        public override void toControl(Hashtable values)
        {
            object o = values[name];

            if (o != null)
            {
                //				if(field.vl!=null)
                //					o=field.vl.load(o.ToString());
                c.Value = HTMLUtils.toHTMLText(o.ToString());
            }
            else
            {
                c.Value = "";
            }
        }
Ejemplo n.º 4
0
        public override void toControl(Hashtable values)
        {
            object o = values[name];

            if (o != null)
            {
                string v;
                if (field.property.PropertyType == typeof(bool))
                {
                    bool b = o.Equals("True");
                    v = DBUtils.getResourceManager().GetString(b ? "value.true" : "value.false");
                    if (v == null)
                    {
                        v = b.ToString();
                    }
                }
                else
                {
                    if (format != null)
                    {
                        if (field.property.PropertyType == typeof(Int32))
                        {
                            if (o.Equals(""))
                            {
                                v = "";
                            }
                            else
                            {
                                int t = Convert.ToInt32(o);
                                v = t.ToString(format);
                            }
                        }
                        else if (field.property.PropertyType == typeof(double))
                        {
                            if (o.Equals(""))
                            {
                                v = "";
                            }
                            else
                            {
                                double t = (double)field.convert(o);
                                v = t.ToString(format);
                            }
                        }
                        else
                        {
                            v = o.ToString();
                        }
                    }
                    else
                    {
                        v = o.ToString();
                    }
                }
                c.Text = HTMLUtils.toHTMLText(v);
            }
            else
            {
                c.Text = "";
            }
        }
Ejemplo n.º 5
0
        public string getValue(object v, string name)
        {
            object s = null;

            if (v is DataRowView)
            {
                DataRowView r = (DataRowView)v;
                s = r[name];
            }
            else if (v is DataRow)
            {
                DataRow r = (DataRow)v;
                s = r[name];
            }
            else if (v is DBObject)
            {
                System.Reflection.PropertyInfo propInfo = v.GetType().GetProperty(name);
                if (propInfo != null)
                {
                    s = propInfo.GetValue(v, null);
                }
            }

            if (s == null || Convert.IsDBNull(s))
            {
                return("");
            }

            if (db != null)
            {
                DBField f = db.getField(name);
                if (f != null && f.transcoder != null)
                {
                    s = f.transcoder.fromDB(s);
                }
            }

            Hashtable map = (Hashtable)values[name];

            if (map != null && s != null)
            {
                object s1 = map[s.ToString()];
                if (s1 == null)
                {
                    try
                    {
                        s1 = map[Convert.ToInt32(s)];
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message);
                    }
                }
                if (s1 != null)
                {
                    s = s1;
                }
            }


            s = s.ToString().Trim();
            return(HTMLUtils.toHTMLText(s.ToString()));
        }
Ejemplo n.º 6
0
        public string getFValue(object v, string name, string format)
        {
            object s = null;

            if (v.GetType() == typeof(DataRowView))
            {
                DataRowView r = (DataRowView)v;
                s = r[name];
            }
            else if (v is DataRow)
            {
                DataRow r = (DataRow)v;
                s = r[name];
            }
            else if (v is DBObject)
            {
                System.Reflection.PropertyInfo propInfo = v.GetType().GetProperty(name);
                if (propInfo != null)
                {
                    s = propInfo.GetValue(v, null);
                }
            }

            if (s == null || Convert.IsDBNull(s))
            {
                return("");
            }

            if (db != null)
            {
                DBField f = db.getField(name);
                if (f != null && f.transcoder != null)
                {
                    s = f.transcoder.fromDB(s);
                }
            }

            Hashtable map = (Hashtable)values[name];

            if (map != null && s != null)
            {
                object s1 = map[s.ToString()];
                if (s1 == null)
                {
                    try
                    {
                        s1 = map[Convert.ToInt32(s)];
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message);
                    }
                }
                if (s1 != null)
                {
                    s = s1;
                }
            }

            if (string.IsNullOrEmpty(format) && db != null)
            {
                DBField field = db.getField(name);
                if (field != null)
                {
                    s = field.populateValue(s);
                }
                else
                {
                    s = s.ToString().Trim();
                }
            }
            else if (s is DateTime)
            {
                DateTime dt = (DateTime)s;
                if (dt.Ticks == 0)
                {
                    return("");
                }
                if (format != null)
                {
                    return(((DateTime)s).ToString(format));
                }
            }
            else if (s is decimal)
            {
                if (format != null)
                {
                    s = ((decimal)s).ToString(format);
                }
            }
            else if (s is double)
            {
                if (Double.IsNaN((double)s))
                {
                    s = "";
                }
                else if (format != null)
                {
                    s = ((double)s).ToString(format);
                }
            }
            else if (s is float)
            {
                if (float.IsNaN((float)s))
                {
                    s = "";
                }
                else if (format != null)
                {
                    s = ((float)s).ToString(format);
                }
            }
            else if (s is int)
            {
                if (format != null)
                {
                    s = ((int)s).ToString(format);
                }
            }
            else if (s is long)
            {
                if (format != null)
                {
                    s = ((long)s).ToString(format);
                }
            }
            return(HTMLUtils.toHTMLText(s.ToString().Trim()));
        }