diff options
Diffstat (limited to 'Gestor.Model/Model.Domain.Financeiro/Fornecedor.cs')
| -rw-r--r-- | Gestor.Model/Model.Domain.Financeiro/Fornecedor.cs | 430 |
1 files changed, 430 insertions, 0 deletions
diff --git a/Gestor.Model/Model.Domain.Financeiro/Fornecedor.cs b/Gestor.Model/Model.Domain.Financeiro/Fornecedor.cs new file mode 100644 index 0000000..7bc6e4b --- /dev/null +++ b/Gestor.Model/Model.Domain.Financeiro/Fornecedor.cs @@ -0,0 +1,430 @@ +using Gestor.Model.Attributes;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using Gestor.Model.Helper;
+using Gestor.Model.Resources;
+using Gestor.Model.Validation;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+
+namespace Gestor.Model.Domain.Financeiro
+{
+ public class Fornecedor : EnderecoBase, IDomain
+ {
+ private string _nome;
+
+ private string _documento;
+
+ private string _email;
+
+ private string _observacao;
+
+ [Description("ATIVO")]
+ [Log(true)]
+ public bool Ativo
+ {
+ get;
+ set;
+ }
+
+ [Log(true)]
+ public string Documento
+ {
+ get
+ {
+ string str = this._documento;
+ if (str == null)
+ {
+ return null;
+ }
+ return str.ToUpper().Trim();
+ }
+ set
+ {
+ this._documento = value;
+ }
+ }
+
+ [Description("E-MAIL")]
+ [Log(true)]
+ public string Email
+ {
+ get
+ {
+ string str = this._email;
+ if (str != null)
+ {
+ return str.ToLower();
+ }
+ return null;
+ }
+ set
+ {
+ this._email = value;
+ }
+ }
+
+ public new long Id
+ {
+ get;
+ set;
+ }
+
+ public long? IdCentro
+ {
+ get;
+ set;
+ }
+
+ public long? IdConta
+ {
+ get;
+ set;
+ }
+
+ public long IdEmpresa
+ {
+ get;
+ set;
+ }
+
+ public long? IdPlano
+ {
+ get;
+ set;
+ }
+
+ [Log(true)]
+ [Name(true)]
+ public string Nome
+ {
+ get
+ {
+ string str = this._nome;
+ if (str != null)
+ {
+ return str.ToUpper();
+ }
+ return null;
+ }
+ set
+ {
+ object upper;
+ this._nome = value;
+ if (value != null)
+ {
+ upper = value.ToUpper();
+ }
+ else
+ {
+ upper = null;
+ }
+ this.NomeSocial = string.Format("{0} - {1}", upper, this.Id);
+ }
+ }
+
+ [Description("NOME SOCIAL")]
+ [Log(true)]
+ public string NomeSocial
+ {
+ get;
+ set;
+ }
+
+ [Description("OBSERVAÇÃO")]
+ [Log(true)]
+ public string Observacao
+ {
+ get
+ {
+ string str = this._observacao;
+ if (str != null)
+ {
+ return str.ToUpper();
+ }
+ return null;
+ }
+ set
+ {
+ this._observacao = value;
+ }
+ }
+
+ [Description("PREFIXO 1")]
+ [Log(true)]
+ public string Prefixo1
+ {
+ get;
+ set;
+ }
+
+ [Description("PREFIXO 2")]
+ [Log(true)]
+ public string Prefixo2
+ {
+ get;
+ set;
+ }
+
+ [Description("TELEFONE 1")]
+ [Log(true)]
+ public string Telefone1
+ {
+ get;
+ set;
+ }
+
+ [Description("TELEFONE 2")]
+ [Log(true)]
+ public string Telefone2
+ {
+ get;
+ set;
+ }
+
+ public Gestor.Model.Common.TipoPagamento? TipoPagamento
+ {
+ get;
+ set;
+ }
+
+ [Description("TIPO TELEFONE")]
+ [Log(true)]
+ public TipoTelefone? TipoTelefone1
+ {
+ get;
+ set;
+ }
+
+ [Description("TIPO TELEFONE 2")]
+ [Log(true)]
+ public TipoTelefone? TipoTelefone2
+ {
+ get;
+ set;
+ }
+
+ [JsonIgnore]
+ public Func<List<KeyValuePair<string, string>>> ValidationEvent
+ {
+ get
+ {
+ Fornecedor fornecedor = this;
+ return new Func<List<KeyValuePair<string, string>>>(fornecedor.Validate);
+ }
+ }
+
+ public Fornecedor()
+ {
+ }
+
+ public List<TupleList> Log()
+ {
+ string description;
+ string str;
+ string str1;
+ string str2;
+ string str3;
+ string description1;
+ List<TupleList> tupleLists = new List<TupleList>();
+ TupleList tupleList = new TupleList();
+ ObservableCollection<Tuple<string, string, string>> observableCollection = new ObservableCollection<Tuple<string, string, string>>()
+ {
+ new Tuple<string, string, string>("NOME DO FORNECEDOR", (string.IsNullOrWhiteSpace(this.Nome) ? "" : this.Nome), ""),
+ new Tuple<string, string, string>("DOCUMENTO", (string.IsNullOrWhiteSpace(this.Documento) ? "" : this.Documento), ""),
+ new Tuple<string, string, string>("CEP", (string.IsNullOrWhiteSpace(base.Cep) ? "" : base.Cep), ""),
+ new Tuple<string, string, string>("ENDEREÇO", (string.IsNullOrWhiteSpace(base.Endereco) ? "" : base.Endereco), ""),
+ new Tuple<string, string, string>("NÚMERO", (string.IsNullOrWhiteSpace(base.Numero) ? "" : base.Numero), ""),
+ new Tuple<string, string, string>("COMPLEMENTO", (string.IsNullOrWhiteSpace(base.Complemento) ? "" : base.Complemento), ""),
+ new Tuple<string, string, string>("BAIRRO", (string.IsNullOrWhiteSpace(base.Bairro) ? "" : base.Bairro), ""),
+ new Tuple<string, string, string>("CIDADE", (string.IsNullOrWhiteSpace(base.Cidade) ? "" : base.Cidade), ""),
+ new Tuple<string, string, string>("ESTADO", (string.IsNullOrWhiteSpace(base.Estado) ? "" : base.Estado), "")
+ };
+ TipoTelefone? tipoTelefone1 = this.TipoTelefone1;
+ if (!tipoTelefone1.HasValue)
+ {
+ description = "";
+ }
+ else
+ {
+ tipoTelefone1 = this.TipoTelefone1;
+ if (tipoTelefone1.HasValue)
+ {
+ description = tipoTelefone1.GetValueOrDefault().GetDescription();
+ }
+ else
+ {
+ description = null;
+ }
+ }
+ observableCollection.Add(new Tuple<string, string, string>("TIPO DO PRIMEIRO TELEFONE", description, ""));
+ observableCollection.Add(new Tuple<string, string, string>("PRIMEIRO PREFIXO", (string.IsNullOrWhiteSpace(this.Prefixo1) ? "" : this.Prefixo1), ""));
+ observableCollection.Add(new Tuple<string, string, string>("PRIMEIRO TELEFONE", (string.IsNullOrWhiteSpace(this.Telefone1) ? "" : this.Telefone1), ""));
+ tipoTelefone1 = this.TipoTelefone2;
+ if (!tipoTelefone1.HasValue)
+ {
+ str = "";
+ }
+ else
+ {
+ tipoTelefone1 = this.TipoTelefone2;
+ if (tipoTelefone1.HasValue)
+ {
+ str = tipoTelefone1.GetValueOrDefault().GetDescription();
+ }
+ else
+ {
+ str = null;
+ }
+ }
+ observableCollection.Add(new Tuple<string, string, string>("TIPO DO SEGUNDO TELEFONE", str, ""));
+ observableCollection.Add(new Tuple<string, string, string>("SEGUNDO PREFIXO", (string.IsNullOrWhiteSpace(this.Prefixo2) ? "" : this.Prefixo2), ""));
+ observableCollection.Add(new Tuple<string, string, string>("SEGUNDO TELEFONE", (string.IsNullOrWhiteSpace(this.Telefone2) ? "" : this.Telefone2), ""));
+ observableCollection.Add(new Tuple<string, string, string>("E-MAIL", (string.IsNullOrWhiteSpace(this.Email) ? "" : this.Email), ""));
+ long? idPlano = this.IdPlano;
+ if (!idPlano.HasValue)
+ {
+ str1 = "";
+ }
+ else
+ {
+ idPlano = this.IdPlano;
+ if (idPlano.HasValue)
+ {
+ str1 = idPlano.GetValueOrDefault().ToString();
+ }
+ else
+ {
+ str1 = null;
+ }
+ }
+ observableCollection.Add(new Tuple<string, string, string>("PLANO DE CONTAS", str1, ""));
+ idPlano = this.IdCentro;
+ if (!idPlano.HasValue)
+ {
+ str2 = "";
+ }
+ else
+ {
+ idPlano = this.IdCentro;
+ if (idPlano.HasValue)
+ {
+ str2 = idPlano.GetValueOrDefault().ToString();
+ }
+ else
+ {
+ str2 = null;
+ }
+ }
+ observableCollection.Add(new Tuple<string, string, string>("CENTRO DE CUSTO", str2, ""));
+ idPlano = this.IdConta;
+ if (!idPlano.HasValue)
+ {
+ str3 = "";
+ }
+ else
+ {
+ idPlano = this.IdConta;
+ if (idPlano.HasValue)
+ {
+ str3 = idPlano.GetValueOrDefault().ToString();
+ }
+ else
+ {
+ str3 = null;
+ }
+ }
+ observableCollection.Add(new Tuple<string, string, string>("CONTA CORRENTE", str3, ""));
+ Gestor.Model.Common.TipoPagamento? tipoPagamento = this.TipoPagamento;
+ if (!tipoPagamento.HasValue)
+ {
+ description1 = "";
+ }
+ else
+ {
+ tipoPagamento = this.TipoPagamento;
+ if (tipoPagamento.HasValue)
+ {
+ description1 = tipoPagamento.GetValueOrDefault().GetDescription();
+ }
+ else
+ {
+ description1 = null;
+ }
+ }
+ observableCollection.Add(new Tuple<string, string, string>("TIPO DE PAGAMENTO", description1, ""));
+ observableCollection.Add(new Tuple<string, string, string>("OBSERVAÇÕES", (string.IsNullOrWhiteSpace(this.Observacao) ? "" : this.Observacao), ""));
+ tupleList.Tuples = observableCollection;
+ tupleLists.Add(tupleList);
+ return tupleLists;
+ }
+
+ public List<KeyValuePair<string, string>> Validate()
+ {
+ int? nullable;
+ int? nullable1;
+ List<KeyValuePair<string, string>> keyValuePairs = ValidationHelper.AddValue();
+ string nome = this.Nome;
+ if (nome != null)
+ {
+ nullable1 = new int?((int)nome.Trim().Split(new char[] { ' ' }).Length);
+ }
+ else
+ {
+ nullable = null;
+ nullable1 = nullable;
+ }
+ int? nullable2 = nullable1;
+ if (nullable2.HasValue)
+ {
+ nullable = nullable2;
+ if (nullable.GetValueOrDefault() <= 1 & nullable.HasValue)
+ {
+ keyValuePairs.AddValue<string, string>("Nome", Messages.NomeInvalido, true);
+ }
+ }
+ else
+ {
+ keyValuePairs.AddValue<string, string>("Nome", Messages.Obrigatorio, true);
+ }
+ if (!string.IsNullOrWhiteSpace(this.Nome) && this.Nome.Length > 60)
+ {
+ keyValuePairs.AddValue<string, string>("Nome", string.Format(Messages.MaiorQueLimite, 60), true);
+ }
+ if (!string.IsNullOrWhiteSpace(this.Documento) && !this.Documento.ValidacaoDocumento())
+ {
+ keyValuePairs.AddValue<string, string>("Documento", Messages.Invalido, true);
+ }
+ if (!string.IsNullOrWhiteSpace(this.Prefixo1) && !this.Prefixo1.ValidacaoPrefixo())
+ {
+ keyValuePairs.AddValue<string, string>("Prefixo1", Messages.Obrigatorio, true);
+ }
+ if (!string.IsNullOrWhiteSpace(this.Telefone1) && !this.Telefone1.ValidacaoTelefone())
+ {
+ keyValuePairs.AddValue<string, string>("Telefone1", Messages.Obrigatorio, true);
+ }
+ if (!string.IsNullOrWhiteSpace(this.Email) && !this.Email.ValidacaoEmail())
+ {
+ keyValuePairs.AddValue<string, string>("Email", Messages.Obrigatorio, true);
+ }
+ if (!string.IsNullOrWhiteSpace(base.Cidade) && base.Cidade.Length > 30)
+ {
+ keyValuePairs.AddValue<string, string>("Cidade", string.Format(Messages.MaiorQueLimite, 30), true);
+ }
+ if (!string.IsNullOrWhiteSpace(base.Bairro) && base.Bairro.Length > 60)
+ {
+ keyValuePairs.AddValue<string, string>("Bairro", string.Format(Messages.MaiorQueLimite, 60), true);
+ }
+ if (!string.IsNullOrWhiteSpace(base.Complemento) && base.Complemento.Length > 40)
+ {
+ keyValuePairs.AddValue<string, string>("Complemento", string.Format(Messages.MaiorQueLimite, 40), true);
+ }
+ return keyValuePairs;
+ }
+ }
+}
\ No newline at end of file |