Example #1
0
        /*********************************************/

        public EstipulanteTaxa SalvarTaxa(EstipulanteTaxa taxa)
        {
            using (ISession sessao = ObterSessao())
            {
                using (ITransaction tran = sessao.BeginTransaction())
                {
                    sessao.SaveOrUpdate(taxa);
                    tran.Commit();
                }
            }

            return(taxa);
        }
Example #2
0
        protected void cmdSalvar_Click(object sender, EventArgs e)
        {
            #region validacoes

            long estipulanteId = Util.CTipos.CToLong(txtIdEstipulante.Text);

            DateTime vigencia = Util.CTipos.CStringToDateTime(txtVigencia.Text);
            if (vigencia == DateTime.MinValue)
            {
                //Util.Geral.JSScript(this, "showModalTaxas();alert('Data de vigência não informada ou inválida.');");
                Util.Geral.Alerta(this, "Data de vigência não informada ou inválida.");
                return;
            }

            if (cboTaxaTipo.SelectedIndex == 0)
            {
                //Util.Geral.JSScript(this, "showModalTaxas();alert('Tipo de taxa não informado.');");
                Util.Geral.Alerta(this, "Tipo de taxa não informado.");
                return;
            }

            bool vigenciaOK = EstipulanteFacade.Instancia.ValidarVigenciaTaxa(null, estipulanteId, vigencia);
            if (!vigenciaOK)
            {
                //Util.Geral.JSScript(this, "showModalTaxas();alert('Vigência inválida. Certifique-se de não haver outra taxa com mesma data.');");
                Util.Geral.Alerta(this, "Vigência inválida. Certifique-se de não haver outra taxa com mesma data.");
                return;
            }

            #endregion

            EstipulanteTaxa taxa = new EstipulanteTaxa();
            taxa.EstipulanteId = estipulanteId;
            taxa.Tipo          = (TipoTaxa)Enum.Parse(typeof(TipoTaxa), cboTaxaTipo.SelectedValue);
            taxa.Valor         = Util.CTipos.ToDecimal(txtTaxaValor.Text);
            taxa.Vigencia      = vigencia;

            EstipulanteFacade.Instancia.SalvarTaxa(taxa);
            this.carregarTaxas();

            //Util.Geral.JSScript(this, "showModalTaxas();alert('Taxa salva com sucesso.');");
            Util.Geral.Alerta(this, "Taxa salva com sucesso.");
        }
Example #3
0
        public EstipulanteTaxa CarregarTaxa(long id, long?contratanteId = null)
        {
            EstipulanteTaxa ret = null;

            using (ISession sessao = ObterSessao())
            {
                ret = sessao.Query <EstipulanteTaxa>()
                      .Where(c => c.ID == id).SingleOrDefault();

                if (contratanteId.HasValue && contratanteId.Value > 0)
                {
                    var estipulante = sessao.Query <Estipulante>()
                                      .Where(c => c.ID == ret.EstipulanteId && c.ContratanteId == contratanteId.Value).SingleOrDefault();

                    if (estipulante == null)
                    {
                        throw new ApplicationException("Security exception.");
                    }
                }
            }

            return(ret);
        }