Example #1
0
        public void Salvar(Orcamento model)
        {
            if (model.Id > 0)
            {
                _rep.Update(model);
            }
            else
            {
                _rep.Add(model);
            }

            //_rep.Salvar(model);
            _rep.Commit();
        }
Example #2
0
 public void Salvar(RamalItem model)
 {
     if (model.Id == 0)
     {
         _rep.Add(model);
     }
 }
Example #3
0
        public ActionResult ImportarImagem(HttpPostedFileBase request)
        {
            if (Request.Files[0].ContentLength > 0)
            {
                foreach (string upload in Request.Files)
                {
                    if (!(Request.Files[upload] != null && Request.Files[upload].ContentLength > 0))
                    {
                        continue;
                    }

                    var imagem = new Imagem(Request.Files[upload]);

                    if (!string.IsNullOrEmpty(Imagem.MsgErro))
                    {
                        ModelState.AddModelError("Upload", Imagem.MsgErro);
                        return(View());
                    }
                    else
                    {
                        ViewBag.Message = "Arquivo salvo com sucesso!!";
                        repo.Add(imagem.Img);
                    }
                }
            }
            else
            {
                ModelState.AddModelError("Upload", "Importe seus arquivos!!");
            }
            return(View());
        }
Example #4
0
 public void Salvar(Escala model)
 {
     if (model.Id == 0)
     {
         _rep.Add(model);
     }
 }
Example #5
0
 public void Salvar(Licenca model)
 {
     if (model.Id == 0)
     {
         _rep.Add(model);
     }
 }
Example #6
0
 public void Salvar(PlanoBackupItem model)
 {
     if (model.Id == 0)
     {
         _rep.Add(model);
     }
 }
Example #7
0
        public void Add(Persona persona)
        {
            var validar = new Validations();

            validar.Validar(persona);
            var rep = new Repositorio();

            rep.Add(persona);
        }
Example #8
0
 public void Salvar(Tipo model)
 {
     if (model.Id == 0)
     {
         _rep.Add(model);
     }
     else
         _rep.Update(model);
 }
Example #9
0
 public void Salvar(Usuario model)
 {
     if (model.Id > 0)
     {
         _rep.Update(model);
     }
     else
     {
         _rep.Add(model);
     }
 }
Example #10
0
 public void Salvar(ModeloRelatorio model)
 {
     if (model.Id == 0)
     {
         _rep.Add(model);
     }
     else
     {
         _rep.Update(model);
     }
 }
Example #11
0
 public void Salvar(Departamento model)
 {
     if (model.Id > 0)
     {
         _rep.Update(model);
     }
     else
     {
         _rep.Add(model);
     }
 }
 public void Salvar(BaseConhecimento model)
 {
     if (model.Id == 0)
     {
         _rep.Add(model);
     }
     else
     {
         _rep.Update(model);
     }
 }
 public void Salvar(ChamadoStatus model)
 {
     if (model.Id > 0)
     {
         _rep.Update(model);
     }
     else
     {
         _rep.Add(model);
     }
 }
Example #14
0
 public void Salvar(Feriado model)
 {
     if (model.Id == 0)
     {
         _rep.Add(model);
     }
     else
     {
         _rep.Update(model);
     }
 }
Example #15
0
 public void Salvar(Revenda model)
 {
     if (model.Id > 0)
     {
         _rep.Update(model);
     }
     else
     {
         _rep.Add(model);
     }
 }
Example #16
0
 public void Salvar(Categoria model)
 {
     if (model.Id > 0)
     {
         _rep.Update(model);
     }
     else
     {
         _rep.Add(model);
     }
 }
Example #17
0
 public void Salvar(FormaPagto model)
 {
     if (model.Id == 0)
     {
         _rep.Add(model);
     }
     else
     {
         _rep.Update(model);
     }
 }
 public void Salvar(ClienteEspecifiacao model)
 {
     if (model.Id > 0)
     {
         _rep.Update(model);
     }
     else
     {
         _rep.Add(model);
     }
 }
Example #19
0
 public void Salvar(ContaEmail model)
 {
     if (model.Id > 0)
     {
         _rep.Update(model);
     }
     else
     {
         _rep.Add(model);
     }
 }
Example #20
0
 public void Salvar(Observacao model)
 {
     if (model.Id == 0)
     {
         _rep.Add(model);
     }
     else
     {
         _rep.Update(model);
     }
 }
Example #21
0
 public void Salvar(Ramal model)
 {
     if (model.Id == 0)
     {
         _rep.Add(model);
     }
     else
     {
         _rep.Update(model);
     }
 }
Example #22
0
 public void Salvar(Parametro model)
 {
     if (model.Id == 0)
     {
         _rep.Add(model);
     }
     else
     {
         _rep.Update(model);
     }
 }
Example #23
0
 public void Salvar(Produto model)
 {
     if (model.Id == 0)
     {
         _rep.Add(model);
     }
     else
     {
         _rep.Update(model);
     }
 }
Example #24
0
 public void Salvar(Visita model)
 {
     if (model.Id > 0)
     {
         _rep.Update(model);
     }
     else
     {
         _rep.Add(model);
     }
     _rep.Commit();
 }
Example #25
0
        protected void SalvarPrecoCasco(object sender, DirectEventArgs e)
        {
            if (Preco.Number < 0)
                return;

            using (var repo = new Repositorio())
            {
                int idProduto;
                if (int.TryParse(Id.Text, out idProduto))
                {
                    if (repo.TryEntity<Produto>(new Especificacao<Produto>(x => x.Id == idProduto)))
                    {
                        if (Preco.Number == 0)
                        {
                            var p = repo.SelectByKey<Produto>(idProduto);
                            if (p.Casco != null)
                            {
                                repo.Delete<Casco>(p.Casco);
                                p.Casco = null;
                            }
                        }
                        else
                            repo.Add(repo.SelectByKey<Produto>(idProduto).Casco = new Casco { Preco = decimal.Parse(Preco.Number.ToString()) });

                        repo.Save();
                        RefreshGrid(repo);
                        var s = string.Format("{0}.getForm().reset();", FormPanel1.ClientID);
                        X.AddScript(s);
                        s = string.Format("CorrigirCssTable({0});", GridPanel1.ClientID);
                        X.AddScript(s);
                        if (Preco.Number > 0)
                            X.Msg.Alert("Salvo", "Preço de casco salvo com sucesso").Show();
                        else
                            X.Msg.Alert("Salvo", "Preço de casco excluido.").Show();
                    }
                }
            }
        }
Example #26
0
        public void Replicar(int id)
        {
            Repositorio <OrcamentoItem>       repItem       = new Repositorio <OrcamentoItem>();
            Repositorio <OrcamentoEmail>      repEmail      = new Repositorio <OrcamentoEmail>();
            Repositorio <Contato>             repContato    = new Repositorio <Contato>();
            Repositorio <OrcamentoVencimento> repVencimento = new Repositorio <OrcamentoVencimento>();
            Repositorio <OrcamentoItemModulo> repItemModulo = new Repositorio <OrcamentoItemModulo>();

            DateTime dataOrcamento = DateTime.Now.Date;

            Orcamento orcamento = new Orcamento();

            var model = _rep.context.Orcamentos.AsNoTracking().Single(x => x.Id == id);

            if (model != null)
            {
                dataOrcamento          = model.Data;
                orcamento              = model;
                orcamento.Numero       = IncrementarNumero();
                orcamento.Data         = DateTime.Now.Date;
                orcamento.DataSituacao = orcamento.Data;

                _rep.Add(orcamento);
                _rep.Commit();
            }

            //=================================================================
            // itens
            //List<OrcamentoItem> Itens = new List<OrcamentoItem>();
            var Itens = _rep.context.OrcamentoItens.AsNoTracking().Where(x => x.OrcamentoId == id).ToList();

            if (Itens != null)
            {
                foreach (var item in Itens)
                {
                    int idItem = item.Id;
                    item.Id          = 0;
                    item.OrcamentoId = orcamento.Id;
                    repItem.Add(item);

                    repItem.Commit();
                    //=================================================================
                    // itens modulos

                    var itensModulos = repItemModulo.context.OrcamentoItemModulos.AsNoTracking().Where(x => x.OrcamentoItemId == idItem).ToList();
                    if (itensModulos != null)
                    {
                        foreach (var modulo in itensModulos)
                        {
                            modulo.Id = 0;
                            modulo.OrcamentoItemId = item.Id;
                            repItemModulo.Add(modulo);
                        }
                        repItemModulo.Commit();
                    }
                }
            }
            //=================================================================
            // emails
            var emails = _rep.context.OrcamentoEmails.AsNoTracking().Where(x => x.OrcamentoId == id).ToList();

            if (emails != null)
            {
                foreach (var email in emails)
                {
                    email.Id          = 0;
                    email.OrcamentoId = orcamento.Id;
                    repEmail.Add(email);
                }
                repEmail.Commit();
            }

            //=================================================================
            // contatos
            var contatos = _rep.context.Contatos.AsNoTracking().Where(x => x.OrcamentoId == id).ToList();

            if (contatos != null)
            {
                foreach (var contato in contatos)
                {
                    contato.Id          = 0;
                    contato.OrcamentoId = orcamento.Id;
                    repContato.Add(contato);
                }
                repContato.Commit();
            }

            //=================================================================
            // Vencimentos
            var vencimentos = _rep.context.OrcamentoVencimentos.AsNoTracking().Where(x => x.OrcamentoId == id).ToList();

            if (vencimentos != null)
            {
                foreach (var vencto in vencimentos)
                {
                    vencto.Id          = 0;
                    vencto.OrcamentoId = orcamento.Id;

                    // calcular novo vencimento vencimento - data do orcamento
                    DateTime dataVencimento = vencto.Data;
                    TimeSpan dias           = dataVencimento.Subtract(dataOrcamento);
                    vencto.Data = DateTime.Now.Date + dias;

                    repVencimento.Add(vencto);
                }
                repVencimento.Commit();
            }
        }
Example #27
0
        protected void btnCadastro_Click(object sender, DirectEventArgs e)
        {
            /*
            if (IsValidCustom(e.ExtraParams["challengeValue"], e.ExtraParams["responseValue"])) // Check if Captcha is verified or not.
            {
                // Captcha provided by the user is valid.
                FormsAuthentication.SetAuthCookie(this.txtUsername.Text, false);
            }
            //else
            {
                // Captcha provided by the user is invalid.
                X.MessageBox.Alert("Erro", "Código invalido.").Show();
            }
             */
            if (string.IsNullOrWhiteSpace(this.Senha.Text))
            {
                X.MessageBox.Alert("Erro", "Senha invalida.").Show();
                return;
            }
            Usuario usuario = new Usuario
            {
                Email = this.EmailCadastro.Text,
                Senha = FormsAuthentication.HashPasswordForStoringInConfigFile(this.Senha.Text, "md5")
            };
            Telefone Fixo    = ObterTelefoneFixo();
            Telefone Celular = ObterTelefoneCelular();
            if (Fixo == null && Celular == null)
            {
                X.MessageBox.Alert("Erro", "Pelo menos um telefone é necessário. Favor preencher ou telefone fixo ou telefone celular.").Show();
                return;
            }

            int numCad;
            if (int.TryParse(this.NumeroCadastro.Text, out numCad))
            {
                var Endereco = new Endereco
                {
                    Rua = this.RuaCadastro.Text,
                    Numero = numCad,
                    Complemento = this.ComplementoCadastro.Text,
                    Bairro = this.BairroCadastro.Text,
                    Cidade = "Belo Horizonte",
                    Estado = "Minas Gerais"
                };
                if (Endereco.IsValid)
                {
                    using (var repositorio = new Repositorio())
                    {
                        repositorio.Add(Endereco);

                        Endereco.Usuario = usuario;

                        repositorio.Add(usuario);

                        if (Fixo != null)
                        {
                            Fixo.Usuario = usuario;
                            repositorio.Add(Fixo);
                        }

                        if (Celular != null)
                        {
                            Celular.Usuario = usuario;
                            repositorio.Add(Celular);
                        }

                        repositorio.Save();
                    }
                }
                else
                {
                    X.MessageBox.Alert("Erro", "Endereço invalido.").Show();
                    return;
                }
            }
        }