Exemplo n.º 1
0
        public string acreditarDebitar(CreditoDebitoModels creditoDebito)
        {
            String format = "MM/dd/yyyy";
            String fecha  = creditoDebito.fecha.ToString(format);

            int error = bDservice.Upd_New_DelUnValorQry_SLID("insert into dbo.CREDITODEBITO (id_cuenta,descripcion,fecha,monto,tipo) values (" + creditoDebito.cuenta.id_cuenta +
                                                             ",'" + creditoDebito.descripcion + "','" + fecha + "'," + creditoDebito.monto + "," + creditoDebito.tipo + ")");

            if (error == 0)
            {
                return("No existe cuenta");
            }

            double saldo = getSaldoCuenta(creditoDebito.cuenta.id_cuenta);

            if (creditoDebito.tipo == 1)
            {
                saldo += creditoDebito.monto;
            }
            else
            {
                if (!tieneFondos(saldo, creditoDebito.monto))
                {
                    return("No tiene suficientes fondos");
                }
                saldo -= creditoDebito.monto;
            }
            bDservice.Upd_New_DelUnValorQry("update dbo.CUENTA set saldo = " + saldo + " where id_cuenta = " + creditoDebito.cuenta.id_cuenta);
            return("");
        }
        public void guardarTransferencia(TransferenciaModels transferencia)
        {
            String campos  = "INSERT INTO dbo.TRANSFERENCIA(monto,fecha,id_cuenta_destino,id_cuenta_origen)";
            String format  = "MM/dd/yyyy";
            String fecha   = transferencia.fecha.ToString(format);
            String valores = string.Format(" VALUES({0},'{1}',{2},{3})", transferencia.monto, fecha, transferencia.cuenta_destino.id_cuenta, transferencia.cuenta_origen.id_cuenta);
            String query   = campos + valores;

            serviceBD.Upd_New_DelUnValorQry(query);
        }