Example #1
0
        private string GetHtmlByCampo(Campo campo, Pessoa pessoa)
        {
            var table = string.Empty;

            table += "<div class=\"rol " + (campo.HasError ? "errorField" : "") + " \">" +
                     "<div class=\"col\">" + campo.Label + ": </div>" +
                     "<div class=\"col\">";
            if (this.GetCampo(campo.Nome).IsInput())
            {
                table += "<input type=\"text\" name=\"" + campo.Nome + "\" id=\"" + campo.Nome + "\"";
                if (!string.IsNullOrEmpty(this.GetCampo(campo.Nome).Valor(pessoa).GetValor()))
                {
                    table += "value=\"" + this.GetCampo(campo.Nome).Valor(pessoa).GetValor() + "\"";
                }
                table += " />";
            }
            else if (this.GetCampo(campo.Nome).IsSelect())
            {
                table += "<select id=\"" + campo.Nome + "\" name=\"" + campo.Nome + "\">" +
                         "<option value=\"0\">-- selecione --</option>";
                foreach (var opcao in campo.Opcoes)
                {
                    table += "<option value=\"" + opcao.Opcao + "\"";
                    if (this.GetCampo(campo.Nome).Valor(pessoa).GetValor() == opcao.Opcao)
                    {
                        table += "selected=\"true\"";
                    }
                    table += ">" + opcao.Opcao + "</option>";
                }
                table += "</select>";
            }
            else if (this.GetCampo(campo.Nome).IsCheck())
            {
                foreach (var opcao in campo.Opcoes)
                {
                    table += "<div id=\"" + campo.Nome + campo.IDCampo + "\">";
                    table += "<input type=\"checkbox\" name=\"" + campo.Nome + "\" id=\"" + campo.Nome + campo.IDCampo + "\"";
                    table += "value=\"" + opcao.Opcao + "\"";
                    if (!string.IsNullOrEmpty(this.GetCampo(campo.Nome).Valor(pessoa).GetValor()) && this.GetCampo(campo.Nome).Valor(pessoa).ContainsValor(opcao.Opcao))
                    {
                        table += "checked";
                    }
                    table += ">" + opcao.Opcao + "</div>";
                }
            }
            else if (this.GetCampo(campo.Nome).IsListItem())
            {
                table += "<select id=\"" + campo.Nome + "\" name=\"" + campo.Nome + "\" multiple=\"true\">";
                table += "<option value=\"0\">-- selecione --</option>";
                foreach (var opcao in campo.Opcoes)
                {
                    table += "<option value=\"" + opcao.Opcao + "\"";
                    if (!string.IsNullOrEmpty(this.GetCampo(campo.Nome).Valor(pessoa).GetValor()) && this.GetCampo(campo.Nome).Valor(pessoa).ContainsValor(opcao.Opcao))
                    {
                        table += "selected=\"true\"";
                    }
                    table += ">" + opcao.Opcao + "</option>";
                }
                table += "</select>";
            }
            else if (this.GetCampo(campo.Nome).IsRadio())
            {
                foreach (var opcao in campo.Opcoes)
                {
                    table += "<div id=\"" + campo.Nome + campo.IDCampo + "\">";
                    table += "<input type=\"radio\" name=\"" + campo.Nome + "\" id=\"" + campo.Nome + campo.IDCampo + "\"";
                    table += "value=\"" + opcao.Opcao + "\"";
                    if (this.GetCampo(campo.Nome).Valor(pessoa).GetValor() == opcao.Opcao)
                    {
                        table += "checked";
                    }
                    table += ">" + opcao.Opcao + "</div>";
                }
            }
            else if (this.GetCampo(campo.Nome).IsTextArea())
            {
                table += "<textarea name=\"" + campo.Nome + "\" id=\"" + campo.Nome + "\">";
                if (!string.IsNullOrEmpty(this.GetCampo(campo.Nome).Valor(pessoa).GetValor()))
                {
                    table += this.GetCampo(campo.Nome).Valor(pessoa).GetValor();
                }
                table += "</textarea>";
            }
            else
            {
                table += "tipo inválido";
            }

            table += "</div></div>";
            return(table);
        }
Example #2
0
 public void SetCampo(Pessoa pessoa, string nomeCampo, string value)
 {
     var campo = new Campo();
     campo.Tabela = this;
     campo.Nome = nomeCampo;
     campo.Get();
     campo.Valor(pessoa).SetValor(value);
 }
Example #3
0
        private string GetHtmlByCampo(Campo campo, Pessoa pessoa)
        {
            var table = string.Empty;
            table += "<div class=\"rol " + (campo.HasError ? "errorField" : "") + " \">" +
                    "<div class=\"col\">" + campo.Label + ": </div>" +
                    "<div class=\"col\">";
            if (this.GetCampo(campo.Nome).IsInput())
            {
                table += "<input type=\"text\" name=\"" + campo.Nome + "\" id=\"" + campo.Nome + "\"";
                if (!string.IsNullOrEmpty(this.GetCampo(campo.Nome).Valor(pessoa).GetValor()))
                {
                    table += "value=\"" + this.GetCampo(campo.Nome).Valor(pessoa).GetValor() + "\"";
                }
                table += " />";
            }
            else if (this.GetCampo(campo.Nome).IsSelect())
            {
                table += "<select id=\"" + campo.Nome + "\" name=\"" + campo.Nome + "\">" +
                   "<option value=\"0\">-- selecione --</option>";
                foreach (var opcao in campo.Opcoes)
                {
                    table += "<option value=\"" + opcao.Opcao + "\"";
                    if (this.GetCampo(campo.Nome).Valor(pessoa).GetValor() == opcao.Opcao)
                    {
                        table += "selected=\"true\"";
                    }
                    table += ">" + opcao.Opcao + "</option>";
                }
                table += "</select>";
            }
            else if (this.GetCampo(campo.Nome).IsCheck())
            {
                foreach (var opcao in campo.Opcoes)
                {
                    table += "<div id=\"" + campo.Nome + campo.IDCampo + "\">";
                    table += "<input type=\"checkbox\" name=\"" + campo.Nome + "\" id=\"" + campo.Nome + campo.IDCampo + "\"";
                    table += "value=\"" + opcao.Opcao + "\"";
                    if (!string.IsNullOrEmpty(this.GetCampo(campo.Nome).Valor(pessoa).GetValor()) && this.GetCampo(campo.Nome).Valor(pessoa).ContainsValor(opcao.Opcao))
                    {
                        table += "checked";
                    }
                    table += ">" + opcao.Opcao + "</div>";
                }
            }
            else if (this.GetCampo(campo.Nome).IsListItem())
            {
                table += "<select id=\"" + campo.Nome + "\" name=\"" + campo.Nome + "\" multiple=\"true\">";
                table += "<option value=\"0\">-- selecione --</option>";
                foreach (var opcao in campo.Opcoes)
                {
                    table += "<option value=\"" + opcao.Opcao + "\"";
                    if (!string.IsNullOrEmpty(this.GetCampo(campo.Nome).Valor(pessoa).GetValor()) && this.GetCampo(campo.Nome).Valor(pessoa).ContainsValor(opcao.Opcao))
                    {
                        table += "selected=\"true\"";
                    }
                    table += ">" + opcao.Opcao + "</option>";
                }
                table += "</select>";
            }
            else if (this.GetCampo(campo.Nome).IsRadio())
            {
                foreach (var opcao in campo.Opcoes)
                {
                    table += "<div id=\"" + campo.Nome + campo.IDCampo + "\">";
                    table += "<input type=\"radio\" name=\"" + campo.Nome + "\" id=\"" + campo.Nome + campo.IDCampo + "\"";
                    table += "value=\"" + opcao.Opcao + "\"";
                    if (this.GetCampo(campo.Nome).Valor(pessoa).GetValor() == opcao.Opcao)
                    {
                        table += "checked";
                    }
                    table += ">" + opcao.Opcao + "</div>";
                }
            }
            else if (this.GetCampo(campo.Nome).IsTextArea())
            {
                table += "<textarea name=\"" + campo.Nome + "\" id=\"" + campo.Nome + "\">";
                if (!string.IsNullOrEmpty(this.GetCampo(campo.Nome).Valor(pessoa).GetValor()))
                {
                    table += this.GetCampo(campo.Nome).Valor(pessoa).GetValor();
                }
                table += "</textarea>";
            }
            else table += "tipo inválido";

            table += "</div></div>";
            return table;
        }
Example #4
0
        public Campo GetCampo(string nomeCampo)
        {
            var campo = new Campo();
            campo.Tabela = this;
            campo.Nome = nomeCampo;
            campo.Get();

            return campo;
        }