Example #1
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 #2
0
        public override void Save()
        {
            if (string.IsNullOrEmpty(this.Valor))
            {
                if (!string.IsNullOrEmpty(campo.ValorDefault))
                {
                    campo.Valor(this.Pessoa).SetValor(campo.ValorDefault);
                }
                else if (!this.Campo.PermiteNulo)
                {
                    throw new TradeVisionValidationError("O campo " + this.Campo.Label + " é obrigatório.");
                }
            }
            else
            {
                if (this.Campo.Tipo == TipoCampo.Data)
                {
                    DateTime data;
                    if (!DateTime.TryParse(this.Valor, out data))
                    {
                        throw new TradeVisionValidationError("O campo " + this.Campo.Label + " é obrigatório uma data valida.");
                    }
                }

                if (this.Campo.Tipo == TipoCampo.Boleano)
                {
                    Boolean boolean;
                    if (!Boolean.TryParse(this.Valor, out boolean))
                    {
                        throw new TradeVisionValidationError("O campo " + this.Campo.Label + " precisa ser verdadeiro ou falso.");
                    }
                }

                if (this.Campo.Tipo == TipoCampo.Inteiro)
                {
                    int inteiro;
                    if (!int.TryParse(this.Valor, out inteiro))
                    {
                        throw new TradeVisionValidationError("O campo " + this.Campo.Label + " precisa ser um valor inteiro.");
                    }
                }

                if (this.Campo.Tipo == TipoCampo.Moeda)
                {
                    double moeda;
                    if (!double.TryParse(this.Valor, out moeda))
                    {
                        throw new TradeVisionValidationError("O campo " + this.Campo.Label + " precisa ser um valor do tipo moeda.");
                    }
                }
            }

            base.Save();
        }
Example #3
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);
 }