Exemple #1
0
        public void DepositoBoleto(int ID)
        {
            try
            {
                var      D             = new DepositoModel();
                var      prot          = new GerarProtocolo();
                var      userId        = ID;
                decimal  valorDeposito = Convert.ToDecimal(Request["value-deposit"]);
                DateTime pag           = Convert.ToDateTime(Request["date-payment"]);

                D.Titular        = Request["fullname"];
                D.Valor          = valorDeposito;
                D.DataVencimento = pag.AddDays(1);
                D.DataPagamento  = pag;
                D.Tipo           = 1;
                D.Status         = "F";
                D.Protocolo      = prot.Protocolo();
                D.NumBoleto      = prot.Boleto();
                D.Id             = userId;

                repository.depositoBoleto(D);
                TempData["Sucesso1"] = "Protocolo gerado: " + D.Protocolo;
                TempData["Sucesso2"] = "Código de barras do boleto: " + D.NumBoleto;
            }
            catch (Exception ex)
            {
                TempData["erro"] = "Erro: " + ex;
            }
            Response.Redirect("/Deposito/Deposito/" + ID);
        }
        public IActionResult Deposito(DepositoModel deposito)
        {
            ContaBE    contaBE    = null;
            DepositoBE depositoBE = null;

            try
            {
                contaBE    = new ContaBE();
                depositoBE = new DepositoBE(contaBE.GetSqlCommand());

                if (deposito.NomeDepositante != "" && deposito.CpfDepositante != "" && deposito.Conta.Numero != "" && deposito.Conta.Agencia != "" && deposito.Valor > 0)
                {
                    var conta = contaBE.ValidarConta(deposito.Conta);

                    if (conta != null && conta.Id > 0)
                    {
                        deposito.Conta = conta;
                        depositoBE.Inserir(deposito);
                        return(RedirectToAction("Index", "Home"));
                    }

                    ViewBag.Info = "Conta de destino não é uma conta válida.";
                    return(View());
                }

                ViewBag.Info = "Todos os campos devem ser preenchidos.";
                return(View());
            }
            catch (Exception)
            {
                return(View());
            }
        }
        // GET: Recibos
        public ActionResult Start()
        {
            if ((sesion = SessionDB.start(Request, Response, false, db)) == null)
            {
                return(Content("-1"));
            }

            DepositoModel model = new DepositoModel();

            model.sesion = sesion;
            model.clean();

            Main view = new Main();

            ViewBag.MainUser  = view.CreateMenuInfoUser(sesion);
            ViewBag.Main      = view.createMenu("Pagos", "Gestión de Pagos", sesion);
            ViewBag.sedes     = view.createSelectSedes("Sedes", sesion);
            ViewBag.DataTable = CreateDataTable(10, 1, null, "ID_DEPOSITO", "ASC", sesion);

            //Intercom
            ViewBag.User     = sesion.nickName.ToString();
            ViewBag.Email    = sesion.nickName.ToString();
            ViewBag.FechaReg = DateTime.Today;

            ViewBag.Scripts = Scripts.addScript() + Scripts.setPrivileges(Privileges, sesion);

            if (!sesion.permisos.havePermission(Privileges[0].Permiso))
            {
                return(View(Factory.View.NotAccess));
            }

            Log.write(this, "Gestión de Pagos Start", LOG.CONSULTA, "Ingresa Pantalla Deposito", sesion);

            return(View(Factory.View.Access + "Pagos/GestiondePagos/Deposito/Start.cshtml"));
        }
Exemple #4
0
        public async Task <ActionResult> Save(Guid id, Guid declaracionID)
        {
            if (id == null)
            {
                return(View(new DepositoModel()));
            }

            var deposito = await _getDepositosUserCase.Execute(id);

            if (deposito == null)
            {
                return(View(new DepositoModel
                {
                    ID = Guid.Empty,
                    DeclaracionID = declaracionID,
                    TipoDeCuenta = String.Empty,
                    TiposDeCuenta = DepositoModel.GetTipoDeCuenta(),
                    Saldo = 0
                }
                            ));
            }

            var modelView = Mapper.Map <DepositoOutput, DepositoModel>(deposito);

            return(PartialView(modelView));
        }
Exemple #5
0
        public async Task <IActionResult> Save(DepositoModel deposito)
        {
            var depositoOutput = await _saveDepositoUserCase.Execute(deposito.ID, deposito.DeclaracionID, deposito.Institucion, deposito.TipoDeCuenta, deposito.Saldo);

            return(RedirectToAction("Actualizar", "Declaracion", new { ID = deposito.DeclaracionID }));
            //return Json(new { success = true, message = "Actualizado correctamente" });
            //return View(_mapper.Map<DepositoOutput, DepositoModel>(depositoOutput));
        }
Exemple #6
0
        public void inserirDepositoCartao(DepositoModel D)
        {
            try
            {
                string query = "USP_DEPOSITO_CARTAO";

                //Connection Factory: Classe que gerencia o local da conexão, tendo o método responsável por obter a conexão
                cf = new ConnectionFactory();

                //CreateCommand: Inicializa o objeto SqlCommand associando o Comando com a conexão do Banco onde será executado
                cf.Comando = cf.Conexao.CreateCommand();

                //Abaixo os parametros que no momento da execução serão substituídos pelos valor das propriedades
                //cf.Comando.Parameters.AddWithValue("@ID_CLINTE", c.Id);
                cf.Comando.Parameters.AddWithValue("@TIPO", D.Tipo);
                cf.Comando.Parameters.AddWithValue("@TITULAR", D.Titular);
                cf.Comando.Parameters.AddWithValue("@DTVENCIMENTO", D.DataVencimento);
                cf.Comando.Parameters.AddWithValue("@NUMCARTAO", D.NumCartao);
                cf.Comando.Parameters.AddWithValue("@CVV", D.Cvv);
                cf.Comando.Parameters.AddWithValue("@DTPAGAMENTO", D.DataPagamento);
                cf.Comando.Parameters.AddWithValue("@DPVALOR", D.Valor);
                cf.Comando.Parameters.AddWithValue("@STATUS", D.Status);
                cf.Comando.Parameters.AddWithValue("@CARTEIRAID", D.Carteira);
                cf.Comando.Parameters.AddWithValue("@PROTOCOLO", D.Protocolo);

                cf.Comando.Parameters.AddWithValue("@USERID", D.Id);

                cf.Comando.Parameters.AddWithValue("@ID_OUT", 0).Direction = ParameterDirection.Output;

                //CommandType indica que o Comando será via procedure no banco de dados
                cf.Comando.CommandType = CommandType.StoredProcedure;

                //CommandText: Propriedade do objeto command que receberá o texto do Comando a ser executado.
                cf.Comando.CommandText = query.ToString();

                //Abre a conexão
                cf.Conexao.Open();
                D.Id = 0;                                          //Define o ID inicialmente como 0.

                cf.Comando.ExecuteNonQuery();                      //Execução do Comando no Banco de dados
                object o = cf.Comando.Parameters["@ID_OUT"].Value; //Recuperando o ID salvo (que deverá ser > 0).
                cf.Conexao.Close();

                if (o != null)
                {
                    D.Id = Convert.ToInt32(o);
                }
                else
                {
                    D.Id = 0;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #7
0
        public async Task <IActionResult> Insert(DepositoModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var banco = _mapper.Map <DepositoDto>(model);
            var a     = await _depositoServicio.Insertar(banco);

            return(Ok(a));
        }
Exemple #8
0
 public List <DepositoModel> Listar(DepositoModel obj)
 {
     try
     {
         return(Selecionar(obj));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemple #9
0
 public DepositoModel Consultar(DepositoModel obj)
 {
     try
     {
         List <DepositoModel> lst = Selecionar(obj);
         return(lst.Count > 0 ? lst.FirstOrDefault() : null);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemple #10
0
        public void Inserir(DepositoModel obj)
        {
            DepositoDAO       depositoDAO       = null;
            ContaMovimentoDAO contaMovimentoDAO = null;
            ContaDAO          contaDAO          = null;

            ContaMovimentoTipoDAO contaMovimentoTipoDAO = null;
            var dataNow = DateTime.Now;

            try
            {
                contaMovimentoDAO = new ContaMovimentoDAO(GetSqlCommand());
                depositoDAO       = new DepositoDAO(GetSqlCommand());
                contaDAO          = new ContaDAO(GetSqlCommand());

                contaMovimentoTipoDAO = new ContaMovimentoTipoDAO(GetSqlCommand());

                var movimentoTipo = contaMovimentoTipoDAO.Consultar(new ContaMovimentoTipoModel()
                {
                    Sigla        = "DP",
                    TipoContabil = { Sigla = "C" }
                });

                BeginTransaction();

                obj.ContaMovimento.Id = contaMovimentoDAO.Inserir(new ContaMovimentoModel()
                {
                    Conta = { Id = obj.Conta.Id },
                    ContaMovimentoTipo = { Id = movimentoTipo.Id },
                    DataMovimento      = dataNow,
                    Valor = obj.Valor
                });

                depositoDAO.Inserir(obj);

                obj.Conta.ChequeEspecial += obj.Valor;
                var dif = obj.Conta.ChequeEspecial - 300;
                if (dif > 0)
                {
                    obj.Conta.ChequeEspecial = 300;
                    obj.Conta.Saldo         += dif;
                }

                contaDAO.AtualizarSaldo(obj.Conta);

                Commit();
            }
            catch (Exception ex)
            {
                Rollback();
                throw ex;
            }
        }
        public bool depositoBoleto(DepositoModel D)
        {
            bool salvou = false;

            new DepositoDAL().inserirDepositoBoleto(D);

            //Se o ID for maior que zero, indica que o dado foi salvo
            if (D.Id > 0)
            {
                salvou = true;
            }
            return(salvou);
        }
Exemple #12
0
        public async Task <IActionResult> Edit(long id, DepositoModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var banco = _mapper.Map <DepositoDto>(model);

            banco.Id = id;
            await _depositoServicio.Modificar(banco);

            return(Ok(model));
        }
Exemple #13
0
 public ActionResult Agregar(DepositoModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (CPMEntities datos = new CPMEntities())
             {
                 datos.sp_AgregarDeposito((int)Session["User"], model.IdCuenta, model.IdCliente, model.Valor);
             }
             return(Redirect("~/Deposito/"));
         }
         return(View(model));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        public ActionResult Generar(DepositoModel model)
        {
            sesion = SessionDB.start(Request, Response, false, model.db, SESSION_BEHAVIOR.AJAX);
            if (sesion == null)
            {
                return(Content("-1"));
            }
            model.sesion = sesion;
            int total, cuantos;

            if (model.Generar(out total, out cuantos))
            {
                return(Json(new { msg = Notification.Succes("Depositos guardados correctamente") }));
            }
            else
            {
                return(Json(new { msg = Notification.Warning("Depositos generados: " + cuantos + " / " + total) }));
            }
        }
Exemple #15
0
        public int Inserir(DepositoModel obj)
        {
            int id = 0;

            try
            {
                StringBuilder strBuilder = new StringBuilder();

                GetSqlCommand().Parameters.Clear();
                strBuilder.AppendLine(@"INSERT INTO dbo.Deposito
                                        (
	                                        IdContaMovimento, 
	                                        NomeDepositante,
	                                        CpfDepositante
                                        )
                                        VALUES              
                                        (
	                                        @IdContaMovimento, 
	                                        @NomeDepositante,
	                                        @CpfDepositante
                                        )");

                GetSqlCommand().CommandText = "";
                GetSqlCommand().CommandText = strBuilder.ToString();

                GetSqlCommand().Parameters.AddWithValue("IdContaMovimento", obj.ContaMovimento.Id);
                GetSqlCommand().Parameters.AddWithValue("NomeDepositante", obj.NomeDepositante);
                GetSqlCommand().Parameters.AddWithValue("CpfDepositante", obj.CpfDepositante);

                GetSqlCommand().ExecuteNonQuery();

                id = UltimoIdInseridoIdentity("Deposito");

                return(id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #16
0
        public void DepositoCartao(int ID)
        {
            try
            {
                var cartao = Request["card-number"];

                if (cartao.Length < 16)
                {
                    TempData["erro"] = "Erro: Número de cartão inválido";
                    Response.Redirect("/Deposito/Deposito/" + ID);
                }
                else
                {
                    var     D             = new DepositoModel();
                    var     prot          = new GerarProtocolo();
                    var     userId        = ID;
                    decimal valorDeposito = Convert.ToDecimal(Request["value-deposit"]);

                    D.Titular        = Request["cardholder-name"];
                    D.NumCartao      = Request["card-number"];
                    D.Valor          = valorDeposito;
                    D.Cvv            = Request["cvv"];
                    D.DataVencimento = Convert.ToDateTime(Request["expiration-date"]);
                    D.DataPagamento  = DateTime.Today;
                    D.Tipo           = 2;
                    D.Status         = "F";
                    D.Protocolo      = prot.Protocolo();
                    D.Id             = userId;

                    repository.depositoCartao(D);
                    TempData["Sucesso1"] = "Protocolo gerado: " + D.Protocolo;
                    Response.Redirect("/Deposito/Deposito/" + ID);
                }
            }
            catch (Exception ex)
            {
                TempData["erro"] = "Erro: " + ex;
            }
        }
        public bool ValidarExcel(string fileName, SessionDB sesion, out List <DepositoModel> listModels, string sedes)
        {
            listModels = new List <DepositoModel>();

            DepositoModel auxModel = new DepositoModel();

            auxModel.sesion = sesion;
            auxModel.cargaListas(sedes);

            // Cargar el excel en los modelos.
            try
            {
                Debug.WriteLine(fileName + " exists: " + (System.IO.File.Exists(fileName) ? "Yes" : "No"));
                using (ExcelPackage xlPackage = new ExcelPackage(new FileInfo(fileName)))
                {
                    // 1.- Get the first worksheet in the workbook
                    ExcelWorksheet           worksheet = xlPackage.Workbook.Worksheets[1];
                    Dictionary <string, int> col       = new Dictionary <string, int>();

                    int start = worksheet.Dimension.Start.Column;
                    int end   = worksheet.Dimension.End.Column;
                    int y     = worksheet.Dimension.Start.Row;
                    int y2    = y + 1;
                    for (int x = start; x <= end; x++)
                    {
                        string head = RemoveDiacritics(
                            (worksheet.Cells[y, x].Text.Replace("/", "").Trim() + " " +
                             worksheet.Cells[y2, x].Text.Replace("/", "").Trim()).Trim()
                            ).Replace(" ", "_").ToUpper();
                        if (col.Keys.Contains(head) == false)
                        {
                            col.Add(head, x);
                        }
                    }
                    start = 2 + worksheet.Dimension.Start.Row;                      // se le suma 2 por las cabeceras
                    end   = worksheet.Dimension.End.Row;

                    int errores = 0;

                    for (int row = start; row <= end; row++)
                    {
                        try
                        {
                            // ------------------- Parche para excluir las lineas vacias -------------------
                            bool emptyLine = true;
                            for (int i = 1; i <= 15; i++)
                            {
                                if (string.IsNullOrWhiteSpace(worksheet.Cells[row, i].Text) == false)
                                {
                                    emptyLine = false; break;
                                }
                            }
                            if (emptyLine)
                            {
                                continue;
                            }
                            // -----------------------------------------------------------------------------

                            DepositoModel model = new DepositoModel();
                            model.ReadWorkSheetRow(worksheet, row, col);
                            model.sesion = sesion;
                            model.CopiaListasDesde(auxModel);
                            listModels.Add(model);
                        }
                        catch (Exception) { errores++; }
                    }
                }                 // the using statement calls Dispose() which closes the package.

                sesion.vdata.Remove("DepositosExcelError");
                sesion.saveSession();

                auxModel.clean();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemple #18
0
        private List <DepositoModel> Selecionar(DepositoModel obj)
        {
            List <DepositoModel> lst = null;

            try
            {
                objSbSelect = new StringBuilder();

                objSbSelect.AppendLine(@"
                                            SELECT Deposito.IdDeposito
                                                 , Deposito.CpfDepositante
                                                 , Deposito.NomeDepositante
                                                 , ContaMovimento.IdContaMovimento
                                                 , ContaMovimento.DataMovimento
                                                 , ContaMovimento.Valor
                                                 , ContaOperacao.IdContaOperacao
                                                 , Conta.IdConta
                                                 , Conta.Agencia
                                                 , Conta.Numero
                                             FROM Deposito
                                             INNER JOIN ContaMovimento
                                                     ON Deposito.IdContaMovimento = ContaMovimento.IdContaMovimento
                                             INNER JOIN ContaOperacao
                                                     ON ContaMovimento.IdContaMovimento = ContaOperacao.IdContaMovimento
                                             INNER JOIN Conta
                                                     ON ContaMovimento.IdConta = Conta.IdConta
                                             WHERE 1 = 1 ");

                if (obj != null)
                {
                    GetSqlCommand().Parameters.Clear();
                    if (obj.Id > 0)
                    {
                        objSbSelect.AppendLine(@" AND Deposito.IdDeposito = @IdDeposito");
                        GetSqlCommand().Parameters.Add("IdDeposito", SqlDbType.Int).Value = obj.Id;
                    }
                    if (!string.IsNullOrEmpty(obj.CpfDepositante))
                    {
                        objSbSelect.AppendLine(@" AND Deposito.CpfDepositante LIKE '%@CpfDepositante%'");
                        GetSqlCommand().Parameters.Add("CpfDepositante", SqlDbType.VarChar).Value = obj.CpfDepositante;
                    }
                    if (!string.IsNullOrEmpty(obj.NomeDepositante))
                    {
                        objSbSelect.AppendLine(@" AND Deposito.NomeDepositante LIKE '%@NomeDepositante%'");
                        GetSqlCommand().Parameters.Add("NomeDepositante", SqlDbType.VarChar).Value = obj.NomeDepositante;
                    }
                    if (obj.ContaMovimento.Conta.Id > 0)
                    {
                        objSbSelect.AppendLine(@" AND Conta.IdConta = @IdConta");
                        GetSqlCommand().Parameters.Add("IdConta", SqlDbType.Int).Value = obj.ContaMovimento.Conta.Id;
                    }
                    if (obj.ContaMovimento.DataMovimento != new DateTime())
                    {
                        objSbSelect.AppendLine(@" AND ContaMovimento.DataMovimento = @DataMovimento");
                        GetSqlCommand().Parameters.Add("DataMovimento", SqlDbType.DateTime).Value = obj.ContaMovimento.DataMovimento;
                    }
                }

                GetSqlCommand().CommandText = "";
                GetSqlCommand().CommandText = objSbSelect.ToString();

                lst = new List <DepositoModel>();

                while (GetSqlDataReader().Read())
                {
                    DepositoModel item = new DepositoModel();

                    if (!(GetSqlDataReader().IsDBNull(GetSqlDataReader().GetOrdinal("IdDeposito"))))
                    {
                        item.Id = Convert.ToInt32(GetSqlDataReader()["IdDeposito"]);
                    }

                    if (!(GetSqlDataReader().IsDBNull(GetSqlDataReader().GetOrdinal("CpfDepositante"))))
                    {
                        item.CpfDepositante = Convert.ToString(GetSqlDataReader()["CpfDepositante"]);
                    }

                    if (!(GetSqlDataReader().IsDBNull(GetSqlDataReader().GetOrdinal("NomeDepositante"))))
                    {
                        item.NomeDepositante = Convert.ToString(GetSqlDataReader()["NomeDepositante"]);
                    }

                    if (!(GetSqlDataReader().IsDBNull(GetSqlDataReader().GetOrdinal("IdContaMovimento"))))
                    {
                        item.ContaMovimento.Id = Convert.ToInt32(GetSqlDataReader()["IdContaMovimento"]);
                    }

                    if (!(GetSqlDataReader().IsDBNull(GetSqlDataReader().GetOrdinal("DataMovimento"))))
                    {
                        item.ContaMovimento.DataMovimento = Convert.ToDateTime(GetSqlDataReader()["DataMovimento"]);
                    }

                    if (!(GetSqlDataReader().IsDBNull(GetSqlDataReader().GetOrdinal("Valor"))))
                    {
                        item.ContaMovimento.Valor = Convert.ToDecimal(GetSqlDataReader()["Valor"]);
                    }

                    if (!(GetSqlDataReader().IsDBNull(GetSqlDataReader().GetOrdinal("IdContaOperacao"))))
                    {
                        item.ContaMovimento.ContaOperacao.Id = Convert.ToInt32(GetSqlDataReader()["IdContaOperacao"]);
                    }

                    if (!(GetSqlDataReader().IsDBNull(GetSqlDataReader().GetOrdinal("IdConta"))))
                    {
                        item.ContaMovimento.Conta.Id = Convert.ToInt32(GetSqlDataReader()["IdConta"]);
                    }

                    if (!(GetSqlDataReader().IsDBNull(GetSqlDataReader().GetOrdinal("Agencia"))))
                    {
                        item.ContaMovimento.Conta.Agencia = Convert.ToString(GetSqlDataReader()["Agencias"]);
                    }

                    if (!(GetSqlDataReader().IsDBNull(GetSqlDataReader().GetOrdinal("Numero"))))
                    {
                        item.ContaMovimento.Conta.Numero = Convert.ToString(GetSqlDataReader()["Numero"]);
                    }

                    lst.Add(item);
                }

                return(lst);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (objSbSelect != null)
                {
                    objSbSelect = null;
                }
                Close();
            }
        }
 public Dictionary <string, DepositoModel> insert(DepositoModel dep)
 {
     return(depositoManager.Insert(dep));
 }
        public void ExportExcel()
        {
            if ((sesion = SessionDB.start(Request, Response, false, db)) == null)
            {
                return;
            }

            try
            {
                System.Data.DataTable tbl = new System.Data.DataTable();
                tbl.Columns.Add("Tipo", typeof(string));
                tbl.Columns.Add("Código", typeof(string));
                tbl.Columns.Add("Status", typeof(string));
                tbl.Columns.Add("Fecha", typeof(string));
                tbl.Columns.Add("Plaza", typeof(string));
                tbl.Columns.Add("Sucusal", typeof(string));
                tbl.Columns.Add(" ", typeof(string));
                tbl.Columns.Add("Forma", typeof(string));
                tbl.Columns.Add("Tipo ", typeof(string));
                tbl.Columns.Add("Banco", typeof(string));
                tbl.Columns.Add("Cuenta", typeof(string));
                tbl.Columns.Add("Importe", typeof(string));
                tbl.Columns.Add("Clave", typeof(string));
                tbl.Columns.Add("Nombre", typeof(string));
                tbl.Columns.Add("Referencia", typeof(string));
                tbl.Columns.Add("Concepto", typeof(string));
                tbl.Columns.Add("Días", typeof(string));
                tbl.Columns.Add("Campo para Ordenar", typeof(string));
                tbl.Rows.Add(
                    "Instrucción", "Clave", "Pago", "Aplicación/Pago", "Pago", "Pago", " ",
                    "Pago", "Cuenta", "Receptor", "Abono", "Pago", "Beneficiario", "Beneficiario", "Pago", "Pago", "Vigencia", "Información");

                List <DepositoModel> listModels = new List <DepositoModel>();
                DepositoModel        auxModel   = new DepositoModel();
                auxModel.sesion = sesion;
                ResultSet res = auxModel.getRowsTable();

                while (res.Next())
                {
                    DepositoModel model = new DepositoModel();
                    model.sesion = sesion;
                    model.edit(res);
                    tbl.Rows.Add(
                        model.TIPO_INSTRUCCION
                        , model.CODIGO_CLAVE
                        , model.STATUS_PAGO
                        , model.FECHA_APLICACION_PAGO
                        , model.PLAZA_PAGO
                        , model.SUCUSAL_PAGO
                        , ""
                        , model.FORMA_PAGO
                        , model.TIPO_CUENTA
                        , model.BANCO_RECEPTOR
                        , model.CUENTA_ABONO
                        , model.IMPORTE_PAGO
                        , model.CLAVE_BENEFICIARIO
                        , model.NOMBRE_BENEFICIARIO
                        , model.REFERENCIA_PAGO
                        , model.CONCEPTO_PAGO
                        , model.DIAS_VIGENCIA
                        , model.INFO
                        );

                    listModels.Add(model);
                }

                using (ExcelPackage pck = new ExcelPackage())
                {
                    //Create the worksheet
                    ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Depositos");

                    //Load the datatable into the sheet, starting from cell A1. Print the column names on row 1
                    ws.Cells["A1"].LoadFromDataTable(tbl, true);
                    ws.Cells["A1:R2"].AutoFitColumns();

                    //Format the header for column 1-3
                    using (ExcelRange rng = ws.Cells["A1:R2"])
                    {
                        rng.Style.Font.Bold        = true;
                        rng.Style.Fill.PatternType = ExcelFillStyle.Solid;                                              //Set Pattern for the background to Solid
                        rng.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(79, 129, 189));                          //Set color to dark blue
                        rng.Style.Font.Color.SetColor(Color.White);
                    }
                    // PAGO APLICADO

                    Dictionary <int, string> cols = new Dictionary <int, string>();
                    cols.Add((int)DEPOSITO.FECHA_APLICACION_PAGO, "D");
                    cols.Add((int)DEPOSITO.CUENTA_ABONO, "K");
                    cols.Add((int)DEPOSITO.CLAVE_BENEFICIARIO, "M");
                    cols.Add((int)DEPOSITO.CONCEPTO_PAGO, "P");

                    int row = 3;
                    foreach (DepositoModel model in listModels)
                    {
                        // Si el campo ERRORES tiene una validacion unsuccess se agrega a la lista.
                        if (model.ERRORES.IndexOf('0') >= 0)
                        {
                            foreach (KeyValuePair <int, string> pair in cols)
                            {
                                if (model.ERRORES[pair.Key] == '0')
                                {
                                    using (ExcelRange rng = ws.Cells["" + pair.Value + row + ":" + pair.Value + row])
                                    {
                                        //rng.Style.Font.Bold = true;
                                        rng.Style.Fill.PatternType = ExcelFillStyle.Solid;                                                              //Set Pattern for the background to Solid
                                        rng.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(239, 219, 67));                                          //Set color to dark blue
                                        //rng.Style.Font.Color.SetColor(Color.White);
                                    }
                                }
                            }
                        }
                        row++;
                    }

                    /*
                     * //Example how to Format Column 1 as numeric
                     * using (ExcelRange col = ws.Cells[3, 1, 3 + tbl.Rows.Count, 1])
                     * {
                     *      col.Style.Numberformat.Format = "#,##0.00";
                     *      col.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
                     * }
                     * //*/

                    //Write it back to the client
                    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                    Response.AddHeader("content-disposition", "attachment;  filename=Depositos_" + DateTime.Now.ToString("yyyyMMdd") + ".xlsx");
                    Response.BinaryWrite(pck.GetAsByteArray());
                }

                Log.write(this, "Start", LOG.CONSULTA, "Exporta Excel Estado de Cuenta", sesion);
            }
            catch (Exception e)
            {
                ViewBag.Notification = Notification.Error(e.Message);
                Log.write(this, "Start", LOG.ERROR, "Exporta Excel Estado de Cuenta" + e.Message, sesion);
            }
        }
        public Dictionary <string, DepositoModel> Insert(DepositoModel Dep)
        {
            string afectados;
            Dictionary <string, DepositoModel> result = new Dictionary <string, DepositoModel>();

            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlTransaction sqlTran = connection.BeginTransaction();

                    SqlCommand command = connection.CreateCommand();

                    command.Transaction = sqlTran;
                    //Dato Prueba Hasta que cambien los datos o cofirmes
                    command.Parameters.AddWithValue("@NroCuenta", Dep.NroCuenta);
                    command.Parameters.AddWithValue("@Monto", Dep.Monto);
                    command.Parameters.AddWithValue("@Moneda", Dep.Moneda);
                    command.Parameters.AddWithValue("@doi", Dep.Doi);
                    command.Parameters.AddWithValue("@doi_org", Dep.Doi_org);
                    command.Parameters.AddWithValue("@Usuario", Dep.Usuario);
                    command.Parameters.AddWithValue("@Turno_Usuario", Dep.IdTurno_Usuario);
                    command.Parameters.AddWithValue("@Fecha", DateTime.Now).Direction             = ParameterDirection.Output;
                    command.Parameters.AddWithValue("@ID_Movimiento", Dep.NumOperacion).Direction = ParameterDirection.Output;
                    command.Parameters.AddWithValue("@RowVer", Dep.RowVer);

                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "DepositosInsert";

                    object   a           = command.ExecuteScalar();
                    DateTime date        = Convert.ToDateTime(command.Parameters["@Fecha"].Value);
                    int      documentoId = Convert.ToInt32(command.Parameters["@ID_Movimiento"].Value);
                    Dep.NumOperacion = documentoId;
                    Dep.FechaOp      = date;
                    if (a != null)
                    {
                        afectados = (string)a;
                    }
                    else
                    {
                        afectados = "Transferido";
                        result.Add("Transferido", Dep);
                    }



                    // Commit the transaction.
                    sqlTran.Commit();

                    connection.Close();
                    connection.Dispose();

                    //if (afectados > 0)
                    return(result);
                    //else
                    //    return false;
                }
            }
            catch (SqlException e)
            {
                afectados = e.Errors[0].Message.ToString();
                return(result);
            }
        }
Exemple #22
0
 public static void Configure()
 {
     Mapper.Initialize(x =>
     {
         x.CreateMap <DepositoOutput, DepositoModel>()
         .ForMember(destination => destination.TiposDeCuenta, source => source.MapFrom(list => DepositoModel.GetTipoDeCuenta()));
         x.CreateMap <InmuebleOutput, InmuebleModel>()
         .ForMember(destination => destination.TiposDeInmuebles, source => source.MapFrom(list => InmuebleModel.GetTiposDeInmuebles()));
         x.CreateMap <DeudaBancariaOutput, DeudaBancariaModel>()
         .ForMember(destination => destination.TiposDeDeuda, source => source.MapFrom(list => DeudaBancariaModel.GetTiposDeuda()));
     });
 }
Exemple #23
0
        public async Task <ActionResult> Save(DepositoModel deposito)
        {
            var depositoOutput = await _saveDepositoUserCase.Execute(deposito.ID, deposito.DeclaracionID, deposito.Institucion, deposito.TipoDeCuenta, deposito.Saldo);

            return(Json(new { success = true, message = "Actualizado correctamente" }, JsonRequestBehavior.AllowGet));
        }