Exemplo n.º 1
0
        public Resultado SaveData(AAT_TBL_EMPRESTIMO_DESCONTO updLancamentoDesc)
        {
            Resultado res = new Resultado();

            try
            {
                var atualiza = m_DbContext.AAT_TBL_EMPRESTIMO_DESCONTO.Find(updLancamentoDesc.COD_EMPRESTIMO_DESCONTO);

                if (atualiza != null)
                {
                    m_DbContext.Entry(atualiza).CurrentValues.SetValues(updLancamentoDesc);
                    m_DbContext.SaveChanges();
                    res.Sucesso("Lançamento salvo com sucesso!");
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                res.Erro(Util.GetEntityValidationErrors(ex));
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
            {
                res.Erro(Util.GetInnerException(ex));
            }
            return(res);
        }
        public Resultado DePara(DataTable dt, String Mesref, String Anoref, String LOG_INCLUSAO)
        {
            Resultado res = new Resultado();
            List <AAT_TBL_EMPRESTIMO_DESCONTO> lsDescontos = new List <AAT_TBL_EMPRESTIMO_DESCONTO>();

            DateTime currentDateTime = DateTime.Now;
            long     PK = base.GetMaxPk();

            foreach (DataRow row in dt.Rows)
            {
                String _data = row["Empresa"].ToString();
                AAT_TBL_EMPRESTIMO_DESCONTO newRetDebConta = new AAT_TBL_EMPRESTIMO_DESCONTO();

                newRetDebConta.COD_EMPRESTIMO_DESCONTO = PK;
                newRetDebConta.COD_EMPRS        = Util.String2Short(row["Empresa"].ToString()) ?? 0;
                newRetDebConta.NUM_RGTRO_EMPRG  = Util.String2Int32(row["Registro"].ToString()) ?? 0;
                newRetDebConta.NUM_MATR_PARTF   = Util.String2Int32(row["MATRICULA"].ToString()) ?? 0;
                newRetDebConta.NUM_IDNTF_RPTANT = Util.String2Int32(row["IDENTIFCAÇÃO REPRESENTANTE"].ToString()) ?? 0;
                newRetDebConta.MES_REF          = Util.String2Short(Mesref) ?? 0;
                newRetDebConta.ANO_REF          = Util.String2Short(Anoref) ?? 0;
                newRetDebConta.COD_STATUS       = 1;
                newRetDebConta.LOG_INCLUSAO     = LOG_INCLUSAO;
                newRetDebConta.DTH_INCLUSAO     = currentDateTime;

                switch (row["Perfil"].ToString().ToUpper())
                {
                default:
                case "ASSISTIDO":
                    newRetDebConta.COD_TIPO = "A";
                    break;

                case "PENSIONISTA":
                    newRetDebConta.COD_TIPO = "P";
                    break;

                case "DESLIGADO":
                    newRetDebConta.COD_TIPO = "D";
                    break;
                }

                newRetDebConta.NUM_CPF    = Util.String2Int64(row["CPF"].ToString());
                newRetDebConta.VLR_DIVIDA = Util.String2Decimal(row["Saldo em  atraso"].ToString());
                //newRetDebConta.LOG_INCLUSAO = ed.LOG_INCLUSAO
                //newRetDebConta.DTH_INCLUSAO = ed.DTH_INCLUSAO
                //newRetDebConta.DTH_EXCLUSAO = ed.DTH_EXCLUSAO
                //newRetDebConta.NOM_EMPRG = emp.NOM_EMPRG

                //newRetDebConta.AAT_TBL_RET_DEB_CONTA_MOTIVO = GetMotivo(newRetDebConta.COD_MOTIVO_RET);
                //newRetDebConta.NUM_SEQ_LINHA = line_count;
                PK++;
                lsDescontos.Add(newRetDebConta);
            }

            //Criticar(lsDebConta);

            if (lsDescontos.Count > 0)
            {
                base.DeleteData(Util.String2Short(Anoref) ?? 0, Util.String2Short(Mesref) ?? 0);
                res = base.Persistir(lsDescontos);
                //res.Sucesso(lsDescontos.Count + " registro(s) importado(s) com sucesso.");
            }
            else
            {
                res.Erro("Nenhum registro importado.");
            }
            return(res);
        }
Exemplo n.º 3
0
        protected void grdEnvio_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int iCOD_EMPRESTIMO_DESCONTO;

            if (e.CommandName != "Sort")
            {
                iCOD_EMPRESTIMO_DESCONTO = Util.String2Int32(e.CommandArgument.ToString()) ?? 0;
                var user = (ConectaAD)Session["objUser"];

                EmprestimoDescontoBLL bll = new EmprestimoDescontoBLL();

                switch (e.CommandName)
                {
                case "Gravar":

                    Resultado res = new Resultado();

                    string VLR_DIVIDA = ((TextBox)grdEnvio.Rows[grdEnvio.EditIndex].FindControl("txtVlrSaldo")).Text;
                    string VLR_CARGA  = ((TextBox)grdEnvio.Rows[grdEnvio.EditIndex].FindControl("txtVlrDivida")).Text;
                    //string VLR_ACERTO = ((TextBox)grdReembolsoAjustes.Rows[grdReembolsoAjustes.EditIndex].FindControl("txtVlrAcerto")).Text;

                    //if (ValidarLancamento(PK, COD_EMPRS, NUM_RGTRO_EMPRG, VLR_LANCAMENTO, COD_VERBA))
                    //{

                    decimal dVLR_DIVIDA;
                    decimal.TryParse(VLR_DIVIDA, out dVLR_DIVIDA);

                    decimal dVLR_CARGA;
                    decimal.TryParse(VLR_CARGA, out dVLR_CARGA);

                    //decimal dVLR_ACERTO;
                    //decimal.TryParse(VLR_ACERTO, out dVLR_ACERTO);
                    AAT_TBL_EMPRESTIMO_DESCONTO updLancamentoDesc =
                        bll.GetLancamentoDesconto(iCOD_EMPRESTIMO_DESCONTO);
                    updLancamentoDesc.VLR_DIVIDA = dVLR_DIVIDA;
                    //updLancamentoDesc.VLR_DIVIDA_POSS = dVLR_DIVIDA_POSS;
                    updLancamentoDesc.VLR_CARGA = dVLR_CARGA;

                    //res = Demons.SaveData(updLancamento, dVLR_ACERTO);
                    res = bll.SaveData(updLancamentoDesc);

                    if (res.Ok)
                    {
                        grdEnvio.EditIndex = -1;
                        grdEnvio.DataBind();
                    }
                    else
                    {
                        MostraMensagem(TbUpload_Mensagem, res.Mensagem);
                    }
                    //}

                    break;

                case "Excluir":

                    res = bll.DeleteData(iCOD_EMPRESTIMO_DESCONTO);
                    if (res.Ok)
                    {
                        //pnlNovoLancamento.Visible = false;
                        grdEnvio.DataBind();
                    }
                    else
                    {
                        MostraMensagem(TbUpload_Mensagem, res.Mensagem);
                    }
                    break;

                default:
                    break;
                }
            }
        }